configure: use here-docs instead of echo for writing config.{h,mak}
[libav.git] / configure
CommitLineData
aeb29222 1#!/bin/sh
0f3cb305 2#
f57620d5
MR
3# FFmpeg configure script
4#
949906ea
DB
5# Copyright (c) 2000-2002 Fabrice Bellard
6# Copyright (c) 2005-2008 Diego Biurrun
7# Copyright (c) 2005-2008 Mans Rullgard
0f3cb305 8#
cf9d24ad 9
31e647f8 10# Prevent locale nonsense from breaking basic text processing.
79ab96ba
DB
11LC_ALL=C
12export LC_ALL
31e647f8 13
cde2d79a 14# make sure we are running under a compatible shell
c21d6325
MR
15# try to make this part work with most shells
16
17try_exec(){
0dbe81bb 18 echo "Trying shell $1"
2270b4b2 19 type "$1" > /dev/null 2>&1 && exec "$@"
c21d6325
MR
20}
21
5237ce67 22unset foo
2270b4b2 23(: ${foo%%bar}) 2> /dev/null
0dbe81bb
MR
24E1="$?"
25
2270b4b2 26(: ${foo?}) 2> /dev/null
0dbe81bb
MR
27E2="$?"
28
29if test "$E1" != 0 || test "$E2" = 0; then
30 echo "Broken shell detected. Trying alternatives."
c21d6325
MR
31 export FF_CONF_EXEC
32 if test "0$FF_CONF_EXEC" -lt 1; then
33 FF_CONF_EXEC=1
34 try_exec bash "$0" "$@"
35 fi
36 if test "0$FF_CONF_EXEC" -lt 2; then
37 FF_CONF_EXEC=2
38 try_exec ksh "$0" "$@"
39 fi
40 if test "0$FF_CONF_EXEC" -lt 3; then
41 FF_CONF_EXEC=3
42 try_exec /usr/xpg4/bin/sh "$0" "$@"
cde2d79a
MR
43 fi
44 echo "No compatible shell script interpreter found."
fc53da20 45 echo "This configure script requires a POSIX-compatible shell"
c21d6325 46 echo "such as bash or ksh."
505dfb09
DB
47 echo "THIS IS NOT A BUG IN FFMPEG, DO NOT REPORT IT AS SUCH."
48 echo "Instead, install a working POSIX-compatible shell."
49 echo "Disabling this configure test will create a broken FFmpeg."
c21d6325
MR
50 if test "$BASH_VERSION" = '2.04.0(1)-release'; then
51 echo "This bash version ($BASH_VERSION) is broken on your platform."
52 echo "Upgrade to a later version if available."
53 fi
cde2d79a
MR
54 exit 1
55fi
56
74c53c2d
MR
57show_help(){
58 echo "Usage: configure [options]"
59 echo "Options: [defaults in brackets after descriptions]"
60 echo
61 echo "Standard options:"
62 echo " --help print this message"
8c6afa4d
DB
63 echo " --logfile=FILE log tests and output to FILE [config.err]"
64 echo " --disable-logging do not log configure debug information"
3e89171a 65 echo " --prefix=PREFIX install in PREFIX [$prefix]"
d156bede 66 echo " --bindir=DIR install binaries in DIR [PREFIX/bin]"
14a8acf1 67 echo " --datadir=DIR install data files in DIR [PREFIX/share/ffmpeg]"
74c53c2d 68 echo " --libdir=DIR install libs in DIR [PREFIX/lib]"
84c22efd 69 echo " --shlibdir=DIR install shared libs in DIR [PREFIX/lib]"
5341d856 70 echo " --incdir=DIR install includes in DIR [PREFIX/include]"
4ca5ece5 71 echo " --mandir=DIR install man page in DIR [PREFIX/share/man]"
62560865
DB
72 echo
73 echo "Configuration options:"
e6b9d588
DB
74 echo " --disable-static do not build static libraries [no]"
75 echo " --enable-shared build shared libraries [no]"
0a23c0bb
DB
76 echo " --enable-gpl allow use of GPL code, the resulting libs"
77 echo " and binaries will be under GPL [no]"
9cad0e4e 78 echo " --enable-version3 upgrade (L)GPL to version 3 [no]"
0a23c0bb
DB
79 echo " --enable-nonfree allow use of nonfree code, the resulting libs"
80 echo " and binaries will be unredistributable [no]"
c73f65d9 81 echo " --disable-doc do not build documentation"
62560865
DB
82 echo " --disable-ffmpeg disable ffmpeg build"
83 echo " --disable-ffplay disable ffplay build"
84 echo " --disable-ffserver disable ffserver build"
e6b9d588 85 echo " --enable-postproc enable GPLed postprocessing support [no]"
fdf11906 86 echo " --enable-avfilter video filter support [no]"
0a23c0bb 87 echo " --enable-avfilter-lavf video filters dependent on avformat [no]"
e6b9d588
DB
88 echo " --enable-beosthreads use BeOS threads [no]"
89 echo " --enable-os2threads use OS/2 threads [no]"
90 echo " --enable-pthreads use pthreads [no]"
91 echo " --enable-w32threads use Win32 threads [no]"
92 echo " --enable-x11grab enable X11 grabbing [no]"
62560865
DB
93 echo " --disable-network disable network support [no]"
94 echo " --disable-ipv6 disable IPv6 support [no]"
95 echo " --disable-mpegaudio-hp faster (but less accurate) MPEG audio decoding [no]"
96 echo " --enable-gray enable full grayscale support (slower color)"
a9ddb5b1 97 echo " --disable-swscale-alpha disable alpha channel support in swscale"
aa033b1e 98 echo " --disable-fastdiv disable table-based division"
62560865
DB
99 echo " --enable-small optimize for size instead of speed"
100 echo " --disable-aandct disable AAN DCT code"
101 echo " --disable-fft disable FFT code"
102 echo " --disable-golomb disable Golomb code"
f4d608e3 103 echo " --disable-lpc disable LPC code"
62560865 104 echo " --disable-mdct disable MDCT code"
68602540 105 echo " --disable-rdft disable RDFT code"
17492d5e
DB
106 echo " --disable-vaapi disable VAAPI code"
107 echo " --disable-vdpau disable VDPAU code"
e90f5b5a 108 echo " --enable-runtime-cpudetect detect cpu capabilities at runtime (bigger binary)"
62560865
DB
109 echo " --enable-hardcoded-tables use hardcoded tables instead of runtime generation"
110 echo " --enable-memalign-hack emulate memalign, interferes with memory debuggers"
111 echo " --enable-beos-netserver enable BeOS netserver"
112 echo " --disable-encoder=NAME disable encoder NAME"
113 echo " --enable-encoder=NAME enable encoder NAME"
114 echo " --disable-encoders disable all encoders"
115 echo " --disable-decoder=NAME disable decoder NAME"
116 echo " --enable-decoder=NAME enable decoder NAME"
117 echo " --disable-decoders disable all decoders"
5666fd73
GB
118 echo " --disable-hwaccel=NAME disable hwaccel NAME"
119 echo " --enable-hwaccel=NAME enable hwaccel NAME"
120 echo " --disable-hwaccels disable all hwaccels"
62560865
DB
121 echo " --disable-muxer=NAME disable muxer NAME"
122 echo " --enable-muxer=NAME enable muxer NAME"
123 echo " --disable-muxers disable all muxers"
124 echo " --disable-demuxer=NAME disable demuxer NAME"
125 echo " --enable-demuxer=NAME enable demuxer NAME"
126 echo " --disable-demuxers disable all demuxers"
127 echo " --enable-parser=NAME enable parser NAME"
128 echo " --disable-parser=NAME disable parser NAME"
129 echo " --disable-parsers disable all parsers"
130 echo " --enable-bsf=NAME enable bitstream filter NAME"
131 echo " --disable-bsf=NAME disable bitstream filter NAME"
132 echo " --disable-bsfs disable all bitstream filters"
133 echo " --enable-protocol=NAME enable protocol NAME"
134 echo " --disable-protocol=NAME disable protocol NAME"
135 echo " --disable-protocols disable all protocols"
38e54a75
SS
136 echo " --disable-indev=NAME disable input device NAME"
137 echo " --disable-outdev=NAME disable output device NAME"
62560865
DB
138 echo " --disable-indevs disable input devices"
139 echo " --disable-outdevs disable output devices"
140 echo " --disable-devices disable all devices"
141 echo " --enable-filter=NAME enable filter NAME"
142 echo " --disable-filter=NAME disable filter NAME"
143 echo " --disable-filters disable all filters"
144 echo " --list-decoders show all available decoders"
145 echo " --list-encoders show all available encoders"
5666fd73 146 echo " --list-hwaccels show all available hardware accelerators"
62560865
DB
147 echo " --list-muxers show all available muxers"
148 echo " --list-demuxers show all available demuxers"
149 echo " --list-parsers show all available parsers"
150 echo " --list-protocols show all available protocols"
151 echo " --list-bsfs show all available bitstream filters"
152 echo " --list-indevs show all available input devices"
153 echo " --list-outdevs show all available output devices"
154 echo " --list-filters show all available filters"
0a622b98
MR
155 echo
156 echo "External library support:"
0a23c0bb 157 echo " --enable-avisynth enable reading of AVISynth script files [no]"
27cb5cbc 158 echo " --enable-bzlib enable bzlib [autodetect]"
0b175caa
DB
159 echo " --enable-libopencore-amrnb enable AMR-NB de/encoding via libopencore-amrnb [no]"
160 echo " --enable-libopencore-amrwb enable AMR-WB decoding via libopencore-amrwb [no]"
f7b8bffe 161 echo " --enable-libdc1394 enable IIDC-1394 grabbing using libdc1394"
e6b9d588
DB
162 echo " and libraw1394 [no]"
163 echo " --enable-libdirac enable Dirac support via libdirac [no]"
164 echo " --enable-libfaac enable FAAC support via libfaac [no]"
165 echo " --enable-libfaad enable FAAD support via libfaad [no]"
166 echo " --enable-libfaadbin open libfaad.so.0 at runtime [no]"
167 echo " --enable-libgsm enable GSM support via libgsm [no]"
168 echo " --enable-libmp3lame enable MP3 encoding via libmp3lame [no]"
31235134 169 echo " --enable-libnut enable NUT (de)muxing via libnut,"
0a23c0bb 170 echo " native (de)muxer exists [no]"
9a77d59a 171 echo " --enable-libopenjpeg enable JPEG 2000 decoding via OpenJPEG [no]"
e6b9d588
DB
172 echo " --enable-libschroedinger enable Dirac support via libschroedinger [no]"
173 echo " --enable-libspeex enable Speex decoding via libspeex [no]"
174 echo " --enable-libtheora enable Theora encoding via libtheora [no]"
f9def9cc 175 echo " --enable-libvorbis enable Vorbis encoding via libvorbis,"
e6b9d588
DB
176 echo " native implementation exists [no]"
177 echo " --enable-libx264 enable H.264 encoding via x264 [no]"
1cc60c47 178 echo " --enable-libxvid enable Xvid encoding via xvidcore,"
e6b9d588 179 echo " native MPEG-4/Xvid encoder exists [no]"
732c9a34 180 echo " --enable-mlib enable Sun medialib [no]"
27cb5cbc 181 echo " --enable-zlib enable zlib [autodetect]"
74c53c2d
MR
182 echo ""
183 echo "Advanced options (experts only):"
184 echo " --source-path=PATH path to source code [$source_path]"
185 echo " --cross-prefix=PREFIX use PREFIX for compilation tools [$cross_prefix]"
db6107b6 186 echo " --enable-cross-compile assume a cross-compiler is used"
c5200f17
MR
187 echo " --sysroot=PATH root of cross-build tree"
188 echo " --sysinclude=PATH location of cross-build system headers"
4f854758 189 echo " --target-os=OS compiler targets OS [$target_os]"
a7ada2ba
MR
190 echo " --target-exec=CMD command to run executables on target"
191 echo " --target-path=DIR path to view of build directory on target"
89641463 192 echo " --nm=NM use nm tool"
313c46a6 193 echo " --as=AS use assembler AS [$as_default]"
15396d5c 194 echo " --cc=CC use C compiler CC [$cc_default]"
684b28e0 195 echo " --ld=LD use linker LD"
9da6609f
MR
196 echo " --host-cc=HOSTCC use host C compiler HOSTCC"
197 echo " --host-cflags=HCFLAGS use HCFLAGS when compiling for host"
198 echo " --host-ldflags=HLDFLAGS use HLDFLAGS when linking for host"
199 echo " --host-libs=HLIBS use libs HLIBS when linking for host"
74c53c2d
MR
200 echo " --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS [$CFLAGS]"
201 echo " --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]"
202 echo " --extra-libs=ELIBS add ELIBS [$ELIBS]"
ac63af34 203 echo " --extra-version=STRING version string suffix []"
0a23c0bb
DB
204 echo " --build-suffix=SUFFIX library name suffix []"
205 echo " --arch=ARCH select architecture [$arch]"
206 echo " --cpu=CPU select the minimum required CPU (affects"
7c758d33 207 echo " instruction selection, may crash on older CPUs)"
2b4c3615 208 echo " --enable-powerpc-perf enable performance report on PPC"
74c53c2d 209 echo " (requires enabling PMC)"
4f50c3d5 210 echo " --disable-altivec disable AltiVec optimizations"
3bf96eec 211 echo " --disable-amd3dnow disable 3DNow! optimizations"
a1ef9f08 212 echo " --disable-amd3dnowext disable 3DNow! extended optimizations"
0a23c0bb
DB
213 echo " --disable-mmx disable MMX optimizations"
214 echo " --disable-mmx2 disable MMX2 optimizations"
1bb04d5a 215 echo " --disable-sse disable SSE optimizations"
0a23c0bb
DB
216 echo " --disable-ssse3 disable SSSE3 optimizations"
217 echo " --disable-armv5te disable armv5te optimizations"
218 echo " --disable-armv6 disable armv6 optimizations"
26c7aa17 219 echo " --disable-armv6t2 disable armv6t2 optimizations"
3bbcba32 220 echo " --disable-armvfp disable ARM VFP optimizations"
0a23c0bb 221 echo " --disable-iwmmxt disable iwmmxt optimizations"
49276307
DB
222 echo " --disable-mmi disable MMI optimizations"
223 echo " --disable-neon disable neon optimizations"
224 echo " --disable-vis disable VIS optimizations"
7595a5e4 225 echo " --disable-yasm disable use of yasm assembler"
8a3c8627 226 echo " --enable-pic build position-independent code"
0a622b98
MR
227 echo
228 echo "Developer options (useful when working on FFmpeg itself):"
9c56a1f9 229 echo " --disable-debug disable debugging symbols"
b7d49373 230 echo " --enable-debug=LEVEL set the debug level [$debuglevel]"
0a622b98 231 echo " --enable-gprof enable profiling with gprof [$gprof]"
d2bbb2f7 232 echo " --disable-optimizations disable compiler optimizations"
0a622b98 233 echo " --enable-extra-warnings enable more compiler warnings"
87a0fb62 234 echo " --disable-stripping disable stripping of executables and shared libraries"
74c53c2d
MR
235 echo ""
236 echo "NOTE: Object files are built at the place where configure is launched."
60e8bc13 237 exit 0
74c53c2d 238}
cf9d24ad 239
57bd82d4 240log(){
2270b4b2 241 echo "$@" >> $logfile
57bd82d4
MR
242}
243
720c69da 244log_file(){
c8e9f801 245 log BEGIN $1
2270b4b2 246 pr -n -t $1 >> $logfile
c8e9f801
MR
247 log END $1
248}
249
2ba042a7 250echolog(){
c8e9f801 251 log "$@"
57bd82d4 252 echo "$@"
2ba042a7
MR
253}
254
255die(){
256 echolog "$@"
257 cat <<EOF
d326cf7f 258
2ba042a7
MR
259If you think configure made a mistake, make sure you are using the latest
260version from SVN. If the latest version fails, report the problem to the
e5d8ccd7 261ffmpeg-user@mplayerhq.hu mailing list or IRC #ffmpeg on irc.freenode.net.
2ba042a7 262EOF
e155a21a 263 if disabled logging; then
2ba042a7 264 cat <<EOF
e155a21a
DB
265Rerun configure with logging enabled (do not use --disable-logging), and
266include the log this produces with your report.
2ba042a7
MR
267EOF
268 else
269cat <<EOF
e155a21a
DB
270Include the log file "$logfile" produced by configure as this will help
271solving the problem.
2ba042a7
MR
272EOF
273 fi
57bd82d4
MR
274 exit 1
275}
276
6c6007d6 277# Avoid locale weirdness, besides we really just want to translate ASCII.
44161118 278toupper(){
6c6007d6 279 echo "$@" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
44161118
MR
280}
281
4a5444db 282tolower(){
6c6007d6 283 echo "$@" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
4a5444db
MR
284}
285
14a8acf1
MR
286c_escape(){
287 echo "$*" | sed 's/["\\]/\\\0/g'
288}
289
b04251c5
MR
290sh_quote(){
291 v=$(echo "$1" | sed "s/'/'\\\\''/g")
292 test "$v" = "${v#*[ |&;<>()$\`\\\"\'*?\[\]#~=%]}" || v="'$v'"
293 echo "$v"
294}
295
be8f2501
MR
296filter(){
297 pat=$1
298 shift
299 for v; do
98ef6079 300 eval "case $v in $pat) echo $v ;; esac"
be8f2501
MR
301 done
302}
303
a8d04fba
MR
304set_all(){
305 value=$1
306 shift
307 for var in $*; do
308 eval $var=$value
309 done
310}
311
72a43668
MR
312set_weak(){
313 value=$1
314 shift
315 for var; do
316 eval : \${$var:=$value}
317 done
318}
319
799c9e9b
MR
320pushvar(){
321 for var in $*; do
322 eval level=\${${var}_level:=0}
323 eval ${var}_${level}="\$$var"
324 eval ${var}_level=$(($level+1))
325 done
326}
327
328popvar(){
329 for var in $*; do
330 eval level=\${${var}_level:-0}
331 test $level = 0 && continue
332 eval level=$(($level-1))
333 eval $var="\${${var}_${level}}"
334 eval ${var}_level=$level
335 eval unset ${var}_${level}
336 done
337}
338
a8d04fba
MR
339enable(){
340 set_all yes $*
341}
342
343disable(){
344 set_all no $*
345}
346
72a43668
MR
347enable_weak(){
348 set_weak yes $*
349}
350
351disable_weak(){
352 set_weak no $*
353}
354
72702705
MR
355enable_safe(){
356 enable $(echo "$*" | sed 's/[^A-Za-z0-9_ ]/_/g')
357}
358
359disable_safe(){
360 disable $(echo "$*" | sed 's/[^A-Za-z0-9_ ]/_/g')
361}
362
f9d328da
MR
363do_enable_deep(){
364 for var; do
365 enabled $var && continue
366 eval sel="\$${var}_select"
c510c7b5
MR
367 eval sgs="\$${var}_suggest"
368 pushvar var sgs
f9d328da 369 enable_deep $sel
c510c7b5
MR
370 popvar sgs
371 enable_deep_weak $sgs
f9d328da
MR
372 popvar var
373 done
374}
375
376enable_deep(){
377 do_enable_deep $*
378 enable $*
379}
380
72a43668
MR
381enable_deep_weak(){
382 do_enable_deep $*
383 enable_weak $*
384}
385
57bd82d4 386enabled(){
3250003c
MR
387 test "${1#!}" = "$1" && op== || op=!=
388 eval test "x\$${1#!}" $op "xyes"
44161118
MR
389}
390
37970ebf 391disabled(){
3250003c
MR
392 test "${1#!}" = "$1" && op== || op=!=
393 eval test "x\$${1#!}" $op "xno"
37970ebf
RP
394}
395
44161118
MR
396enabled_all(){
397 for opt; do
398 enabled $opt || return 1
399 done
400}
401
85bca2c5
DB
402disabled_all(){
403 for opt; do
404 disabled $opt || return 1
405 done
406}
407
44161118
MR
408enabled_any(){
409 for opt; do
410 enabled $opt && return 0
411 done
412}
413
85bca2c5
DB
414disabled_any(){
415 for opt; do
416 disabled $opt && return 0
417 done
f7b230a7 418 return 1
85bca2c5
DB
419}
420
c9d19248
MR
421set_default(){
422 for opt; do
88268e94 423 eval : \${$opt:=\$${opt}_default}
c9d19248
MR
424 done
425}
426
4a0d6686
AJ
427is_in(){
428 value=$1
429 shift
430 for var in $*; do
431 [ $var = $value ] && return 0
432 done
433 return 1
434}
435
30fd06be
MR
436check_deps(){
437 for cfg; do
3250003c 438 cfg="${cfg#!}"
799c9e9b
MR
439 enabled ${cfg}_checking && die "Circular dependency for $cfg."
440 disabled ${cfg}_checking && continue
441 enable ${cfg}_checking
442
30fd06be
MR
443 eval dep_all="\$${cfg}_deps"
444 eval dep_any="\$${cfg}_deps_any"
7ef3425f 445 eval dep_sel="\$${cfg}_select"
c510c7b5 446 eval dep_sgs="\$${cfg}_suggest"
799c9e9b 447
c510c7b5
MR
448 pushvar cfg dep_all dep_any dep_sel dep_sgs
449 check_deps $dep_all $dep_any $dep_sel $dep_sgs
450 popvar cfg dep_all dep_any dep_sel dep_sgs
799c9e9b 451
6a702d4c
MR
452 enabled_all $dep_all || disable $cfg
453 enabled_any $dep_any || disable $cfg
7ef3425f 454 disabled_any $dep_sel && disable $cfg
799c9e9b 455
4ec45764
RP
456 if enabled $cfg; then
457 eval dep_extralibs="\$${cfg}_extralibs"
458 test -n "$dep_extralibs" && add_extralibs $dep_extralibs
f9d328da 459 enable_deep $dep_sel
c510c7b5 460 enable_deep_weak $dep_sgs
4ec45764
RP
461 fi
462
799c9e9b 463 disable ${cfg}_checking
30fd06be
MR
464 done
465}
466
44161118
MR
467print_config(){
468 pfx=$1
469 header=$2
470 makefile=$3
471 shift 3
472 for cfg; do
5e622c40 473 ucname="$(toupper $cfg)"
44161118 474 if enabled $cfg; then
3d907e22 475 echo "#define ${pfx}${ucname} 1" >> $header
3d907e22
MR
476 echo "${pfx}${ucname}=yes" >> $makefile
477 else
b250f9c6 478 echo "#define ${pfx}${ucname} 0" >> $header
44161118
MR
479 fi
480 done
57bd82d4
MR
481}
482
483flags_saved(){
2270b4b2 484 (: ${SAVE_CFLAGS?}) 2> /dev/null
57bd82d4
MR
485}
486
dcd479c0 487save_flags(){
57bd82d4 488 flags_saved && return
dcd479c0
MR
489 SAVE_CFLAGS="$CFLAGS"
490 SAVE_LDFLAGS="$LDFLAGS"
491 SAVE_extralibs="$extralibs"
492}
493
494restore_flags(){
f5d28d10 495 flags_saved || return
dcd479c0
MR
496 CFLAGS="$SAVE_CFLAGS"
497 LDFLAGS="$SAVE_LDFLAGS"
498 extralibs="$SAVE_extralibs"
499 unset SAVE_CFLAGS
500 unset SAVE_LDFLAGS
501 unset SAVE_extralibs
502}
503
504temp_cflags(){
505 save_flags
506 CFLAGS="$CFLAGS $*"
507}
508
509temp_ldflags(){
510 save_flags
511 LDFLAGS="$LDFLAGS $*"
512}
513
514temp_extralibs(){
515 save_flags
516 extralibs="$extralibs $*"
517}
518
57bd82d4
MR
519append(){
520 var=$1
521 shift
522 flags_saved && eval "SAVE_$var=\"\$SAVE_$var $*\""
523 eval "$var=\"\$$var $*\""
524}
525
50a334e4 526add_cppflags(){
caf458dd 527 append CPPFLAGS $($filter_cppflags "$@")
50a334e4
MR
528}
529
57bd82d4 530add_cflags(){
caf458dd 531 append CFLAGS $($filter_cflags "$@")
57bd82d4
MR
532}
533
2f2e6c7c 534add_asflags(){
caf458dd 535 append ASFLAGS $($filter_asflags "$@")
2f2e6c7c
MR
536}
537
57bd82d4
MR
538add_ldflags(){
539 append LDFLAGS "$@"
540}
541
542add_extralibs(){
543 append extralibs "$@"
544}
545
b0cfb663 546check_cmd(){
b3cb5d51 547 log "$@"
2270b4b2 548 "$@" >> $logfile 2>&1
b0cfb663
MR
549}
550
dcd479c0 551check_cc(){
57bd82d4 552 log check_cc "$@"
2270b4b2 553 cat > $TMPC
720c69da 554 log_file $TMPC
50a334e4 555 check_cmd $cc $CPPFLAGS $CFLAGS "$@" -c -o $TMPO $TMPC
57bd82d4
MR
556}
557
558check_cpp(){
559 log check_cpp "$@"
2270b4b2 560 cat > $TMPC
720c69da 561 log_file $TMPC
9e7f3277 562 check_cmd $cc $CPPFLAGS $CFLAGS "$@" -E -o $TMPO $TMPC
dcd479c0
MR
563}
564
f65883c8
MR
565check_as(){
566 log check_as "$@"
567 cat > $TMPC
568 log_file $TMPC
2f2e6c7c 569 check_cmd $as $CPPFLAGS $ASFLAGS "$@" -c -o $TMPO $TMPC
f65883c8
MR
570}
571
940f335a
MR
572check_asm(){
573 log check_asm "$@"
574 name="$1"
575 asm="$2"
576 shift 2
49214f61
MR
577 disable $name
578 check_as "$@" <<EOF && enable $name
124c21d7 579void foo(void){ __asm__ volatile($asm); }
940f335a
MR
580EOF
581}
582
304d586d
LM
583check_yasm(){
584 log check_yasm "$@"
585 echo "$1" > $TMPS
586 log_file $TMPS
587 shift 1
588 check_cmd $yasmexe $YASMFLAGS "$@" -o $TMPO $TMPS
589}
590
dcd479c0 591check_ld(){
57bd82d4 592 log check_ld "$@"
0607887f 593 check_cc || return
3155a644
MR
594 flags=''
595 libs=''
596 for f; do
597 test "${f}" = "${f#-l}" && flags="$flags $f" || libs="$libs $f"
598 done
684b28e0 599 check_cmd $ld $LDFLAGS $flags -o $TMPE $TMPO $extralibs $libs
dcd479c0
MR
600}
601
50a334e4
MR
602check_cppflags(){
603 log check_cppflags "$@"
caf458dd
MR
604 set -- $($filter_cppflags "$@")
605 check_cc "$@" <<EOF && append CPPFLAGS "$@"
50a334e4
MR
606int x;
607EOF
608}
609
dcd479c0 610check_cflags(){
57bd82d4 611 log check_cflags "$@"
caf458dd
MR
612 set -- $($filter_cflags "$@")
613 check_cc "$@" <<EOF && append CFLAGS "$@"
dcd479c0
MR
614int x;
615EOF
616}
617
618check_ldflags(){
57bd82d4
MR
619 log check_ldflags "$@"
620 check_ld "$@" <<EOF && add_ldflags "$@"
c23a0ac8 621int main(void){ return 0; }
dcd479c0
MR
622EOF
623}
624
625check_header(){
57bd82d4 626 log check_header "$@"
dcd479c0
MR
627 header=$1
628 shift
b77df637
MR
629 disable_safe $header
630 check_cpp "$@" <<EOF && enable_safe $header
dcd479c0
MR
631#include <$header>
632int x;
633EOF
634}
635
636check_func(){
57bd82d4 637 log check_func "$@"
dcd479c0
MR
638 func=$1
639 shift
d8bc5f06
MR
640 disable $func
641 check_ld "$@" <<EOF && enable $func
dcd479c0 642extern int $func();
c23a0ac8 643int main(void){ $func(); }
dcd479c0
MR
644EOF
645}
646
2446d3d6
DB
647check_func_headers(){
648 log check_func_headers "$@"
f8d7b072
MR
649 headers=$1
650 func=$2
651 shift 2
652 disable $func
653 incs=""
654 for hdr in $headers; do
655 incs="$incs
656#include <$hdr>"
657 done
cd0d9a9d 658 check_ld "$@" <<EOF && enable $func && enable_safe $headers
f8d7b072 659$incs
d6773f56 660int main(int argc, char **argv){
2b2c2a81 661 return (long) $func;
f8d7b072
MR
662}
663EOF
664}
665
a5344cf7
SS
666check_cpp_condition(){
667 log check_cpp_condition "$@"
668 header=$1
669 condition=$2
670 check_cpp <<EOF
671#include <$header>
672#if !($condition)
673#error "unsatisfied condition: $condition"
674#endif
675EOF
676}
677
57bd82d4
MR
678check_lib(){
679 log check_lib "$@"
680 header="$1"
681 func="$2"
682 shift 2
fcfcde17
MR
683 temp_extralibs "$@"
684 check_header $header && check_func $func && add_extralibs "$@"
685 err=$?
686 restore_flags
687 return $err
57bd82d4
MR
688}
689
f8d7b072
MR
690check_lib2(){
691 log check_lib2 "$@"
692 headers="$1"
693 func="$2"
694 shift 2
695 temp_extralibs "$@"
2446d3d6 696 check_func_headers "$headers" $func && add_extralibs "$@"
f8d7b072
MR
697 err=$?
698 restore_flags
699 return $err
700}
701
dcd479c0 702check_exec(){
2270b4b2 703 check_ld "$@" && { enabled cross_compile || $TMPE >> $logfile 2>&1; }
57bd82d4
MR
704}
705
7dfef245 706check_exec_crash(){
5e622c40 707 code=$(cat)
7dfef245
MR
708
709 # exit() is not async signal safe. _Exit (C99) and _exit (POSIX)
710 # are safe but may not be available everywhere. Thus we use
711 # raise(SIGTERM) instead. The check is run in a subshell so we
712 # can redirect the "Terminated" message from the shell. SIGBUS
713 # is not defined by standard C so it is used conditionally.
714
2270b4b2 715 (check_exec "$@") >> $logfile 2>&1 <<EOF
7dfef245
MR
716#include <signal.h>
717static void sighandler(int sig){
718 raise(SIGTERM);
719}
e5af4a11 720int main(void){
7dfef245
MR
721 signal(SIGILL, sighandler);
722 signal(SIGFPE, sighandler);
723 signal(SIGSEGV, sighandler);
724#ifdef SIGBUS
725 signal(SIGBUS, sighandler);
726#endif
727 { $code }
728}
729EOF
730}
731
72be9e73
DY
732check_type(){
733 log check_type "$@"
734 headers=$1
735 type=$2
736 shift 2
737 disable $type
738 incs=""
739 for hdr in $headers; do
740 incs="$incs
741#include <$hdr>"
742 done
743 check_cc "$@" <<EOF && enable $type
744$incs
745$type v;
746EOF
747}
748
57bd82d4
MR
749require(){
750 name="$1"
751 header="$2"
752 func="$3"
753 shift 3
754 check_lib $header $func "$@" || die "ERROR: $name not found"
dcd479c0
MR
755}
756
f8d7b072
MR
757require2(){
758 name="$1"
759 headers="$2"
760 func="$3"
761 shift 3
762 check_lib2 "$headers" $func "$@" || die "ERROR: $name not found"
763}
764
eea50282
MR
765check_foo_config(){
766 cfg=$1
767 pkg=$2
768 header=$3
769 func=$4
770 shift 4
771 disable $cfg
772 check_cmd ${pkg}-config --version
773 err=$?
774 if test "$err" = 0; then
5e622c40
DB
775 temp_cflags $(${pkg}-config --cflags)
776 temp_extralibs $(${pkg}-config --libs)
eea50282
MR
777 check_lib "$@" $header $func && enable $cfg
778 fi
779 return $err
780}
781
f0125de9
MR
782check_host_cc(){
783 log check_host_cc "$@"
784 cat > $TMPC
785 log_file $TMPC
786 check_cmd $host_cc $host_cflags "$@" -c -o $TMPO $TMPC
787}
788
789check_host_cflags(){
790 log check_host_cflags "$@"
791 check_host_cc "$@" <<EOF && append host_cflags "$@"
792int x;
793EOF
794}
795
c505dd31
MR
796apply(){
797 file=$1
798 shift
799 "$@" < "$file" > "$file.tmp" && mv "$file.tmp" "$file" || rm "$file.tmp"
800}
801
dcd61286
DB
802# CONFIG_LIST contains configurable options, while HAVE_LIST is for
803# system-dependent things.
804
4a0d6686
AJ
805COMPONENT_LIST="
806 bsfs
807 decoders
808 demuxers
809 encoders
3cde40aa 810 filters
5666fd73 811 hwaccels
c552605c 812 indevs
4a0d6686 813 muxers
c552605c 814 outdevs
4a0d6686
AJ
815 parsers
816 protocols
817"
818
819CONFIG_LIST="
820 $COMPONENT_LIST
e8ed9b7a 821 aandct
f7679c54
VS
822 avfilter
823 avfilter_lavf
c88f5d72
MR
824 avisynth
825 beos_netserver
f402916e 826 bzlib
c73f65d9 827 doc
27a9466b 828 fastdiv
c88f5d72
MR
829 ffmpeg
830 ffplay
831 ffserver
1848f7d9 832 fft
4f034993 833 golomb
c88f5d72 834 gpl
ecfc4f44 835 gprof
d8d0d0b2 836 gray
3abe5fbd 837 hardcoded_tables
c88f5d72 838 ipv6
f7b8bffe 839 libdc1394
690bfceb 840 libdirac
2eed5a46
DB
841 libfaac
842 libfaad
843 libfaadbin
c88f5d72 844 libgsm
6ebe07fb 845 libmp3lame
c88f5d72 846 libnut
0b175caa
DB
847 libopencore_amrnb
848 libopencore_amrwb
9a77d59a 849 libopenjpeg
f7cd9eed 850 libschroedinger
ae14f311 851 libspeex
150d2772 852 libtheora
c88f5d72 853 libvorbis
1cc60c47
DB
854 libx264
855 libxvid
f4d608e3 856 lpc
47a158cb 857 mdct
c88f5d72 858 memalign_hack
a8150374 859 mlib
c88f5d72
MR
860 mpegaudio_hp
861 network
3fe142e2 862 nonfree
8a3c8627 863 pic
4a24ab64 864 postproc
2b4c3615 865 powerpc_perf
68602540 866 rdft
e90f5b5a 867 runtime_cpudetect
2e35e684 868 shared
bd2216e4 869 small
2e35e684 870 static
a9ddb5b1 871 swscale_alpha
17492d5e
DB
872 vaapi
873 vdpau
9cad0e4e 874 version3
56a059ac 875 x11grab
c88f5d72 876 zlib
4a0d6686 877"
c88f5d72 878
8eee7025
DB
879THREADS_LIST='
880 beosthreads
d22e8442 881 os2threads
8eee7025
DB
882 pthreads
883 w32threads
884'
885
3f5b56e5
MR
886ARCH_LIST='
887 alpha
a2fc0f6a 888 arm
fdcd782d
MR
889 avr32
890 avr32_ap
891 avr32_uc
3f5b56e5
MR
892 bfin
893 ia64
894 m68k
895 mips
bae3abb0 896 mips64
3f5b56e5 897 parisc
79cb09b2 898 ppc
34d11b87 899 ppc64
3f5b56e5
MR
900 s390
901 sh4
902 sparc
903 sparc64
904 x86
905 x86_32
906 x86_64
907'
908
909ARCH_EXT_LIST='
1ac9331a 910 altivec
3bf96eec 911 amd3dnow
a1ef9f08 912 amd3dnowext
1ac9331a 913 armv5te
edab3048 914 armv6
ab5cb084 915 armv6t2
f55b299a 916 armvfp
3f5b56e5
MR
917 iwmmxt
918 mmi
919 mmx
d7f0920b 920 mmx2
6b18d278 921 neon
799fde37 922 ppc4xx
1bb04d5a 923 sse
9eeed841 924 ssse3
bd9d34a0 925 vis
3f5b56e5
MR
926'
927
928HAVE_LIST="
929 $ARCH_EXT_LIST
930 $THREADS_LIST
35fd8122 931 alsa_asoundlib_h
3f5b56e5 932 altivec_h
c9fdab0d 933 arpa_inet_h
e7ea5e3d 934 attribute_packed
08a85a59 935 bigendian
6bd859d6 936 bswap
ecf97f22 937 closesocket
1ac9331a 938 cmov
e16e49ac 939 conio_h
c88f5d72 940 dcbzl
f8aa696f
DB
941 dev_bktr_ioctl_bt848_h
942 dev_bktr_ioctl_meteor_h
943 dev_ic_bt8xx_h
944 dev_video_meteor_ioctl_meteor_h
945 dev_video_bktr_ioctl_bt848_h
18b67ae5 946 dlfcn_h
c88f5d72 947 dlopen
bc574408 948 dos_paths
245626d0
DB
949 ebp_available
950 ebx_available
c2a29455 951 fast_64bit
7073e9fc 952 fast_cmov
7b829d2a 953 fast_unaligned
9d99cc5a 954 fork
da9e86f8 955 gethrtime
4e68cb8a 956 GetProcessTimes
66be5b45 957 getrusage
2e1913b1 958 inet_aton
61d251db 959 inline_asm
abfc8d05 960 isatty
9f5ff83f 961 ldbrx
0b4a1821
AS
962 libdc1394_1
963 libdc1394_2
a33cab3a 964 llrint
291fd18a 965 log2
85dd97ad 966 loongson
a33cab3a 967 lrint
c88f5d72 968 lrintf
e4673692 969 lzo1x_999_compress
f8aa696f
DB
970 machine_ioctl_bt848_h
971 machine_ioctl_meteor_h
c88f5d72
MR
972 malloc_h
973 memalign
6ffa87d3 974 mkstemp
b4e806b2 975 pld
1f91cdce 976 posix_memalign
a33cab3a
MK
977 round
978 roundf
c88f5d72
MR
979 sdl
980 sdl_video_size
b507ebd1 981 setmode
72be9e73 982 socklen_t
deb29777 983 soundcard_h
f8cda19e 984 poll_h
b58412f1 985 sys_mman_h
b091aa44 986 sys_resource_h
81644c2e 987 sys_select_h
deb29777 988 sys_soundcard_h
1b6e8b73 989 sys_videoio_h
d3a4b4e0 990 ten_operands
e16e49ac 991 termios_h
b265431e 992 threads
7b04b8a0 993 truncf
ce742de2 994 vfp_args
7c5bfe7a 995 VirtualAlloc
6ff3f3e7 996 winsock2_h
cc078b5d 997 xform_asm
304d586d 998 yasm
0cb78cef 999"
44161118 1000
b6bb00b0
MR
1001# options emitted with CONFIG_ prefix but not available on command line
1002CONFIG_EXTRA="
9cad0e4e
DB
1003 gplv3
1004 lgplv3
b6bb00b0
MR
1005"
1006
520cc7f1 1007CMDLINE_SELECT="
3f5b56e5 1008 $ARCH_EXT_LIST
520cc7f1 1009 $CONFIG_LIST
8eee7025 1010 $THREADS_LIST
db6107b6 1011 cross_compile
520cc7f1
MR
1012 debug
1013 extra_warnings
8c6afa4d 1014 logging
d2bbb2f7 1015 optimizations
87a0fb62 1016 stripping
7595a5e4 1017 yasm
520cc7f1 1018"
426be5dc
DB
1019
1020PATHS_LIST='
d156bede 1021 bindir
14a8acf1 1022 datadir
26759c44
MR
1023 incdir
1024 libdir
26759c44
MR
1025 mandir
1026 prefix
1027 shlibdir
426be5dc
DB
1028'
1029
1030CMDLINE_SET="
1031 $PATHS_LIST
1032 arch
313c46a6 1033 as
426be5dc
DB
1034 build_suffix
1035 cc
1036 cpu
1037 cross_prefix
50567afa 1038 dep_cc
ac63af34 1039 extra_version
9da6609f
MR
1040 host_cc
1041 host_cflags
1042 host_ldflags
1043 host_libs
82bb3329 1044 host_os
684b28e0 1045 ld
426be5dc 1046 logfile
89641463 1047 nm
26759c44 1048 source_path
c5200f17
MR
1049 sysinclude
1050 sysroot
a7ada2ba 1051 target_exec
26759c44 1052 target_os
a7ada2ba 1053 target_path
426be5dc 1054"
520cc7f1 1055
89f2932b
MR
1056CMDLINE_APPEND="
1057 extra_cflags
1058"
1059
912f3148
DB
1060# code dependency declarations
1061
9eeed841 1062# architecture extensions
79cb09b2 1063altivec_deps="ppc"
3bf96eec 1064amd3dnow_deps="mmx"
a1ef9f08 1065amd3dnowext_deps="amd3dnow"
a2fc0f6a
MR
1066armv5te_deps="arm"
1067armv6_deps="arm"
ab5cb084 1068armv6t2_deps="arm"
a2fc0f6a
MR
1069armvfp_deps="arm"
1070iwmmxt_deps="arm"
e241ba14 1071mmi_deps="mips"
9eeed841 1072mmx_deps="x86"
75aa95a6 1073mmx2_deps="mmx"
a2fc0f6a 1074neon_deps="arm"
799fde37 1075ppc4xx_deps="ppc"
75aa95a6
DB
1076sse_deps="mmx"
1077ssse3_deps="sse"
bd9d34a0 1078vis_deps="sparc"
9eeed841 1079
89e053f8 1080need_memalign="altivec neon sse"
6fec122a 1081inline_asm_deps="!tms470"
89e053f8 1082
5666fd73 1083# decoders / encoders / hardware accelerators
47a158cb 1084aac_decoder_select="fft mdct"
84c04e25 1085aac_encoder_select="fft mdct"
47a158cb 1086ac3_decoder_select="fft mdct"
f4d608e3 1087alac_encoder_select="lpc"
47a158cb 1088atrac3_decoder_select="fft mdct"
4f034993 1089cavs_decoder_select="golomb"
47a158cb 1090cook_decoder_select="fft mdct"
2eef7c62 1091cscd_decoder_suggest="zlib"
47a158cb 1092dca_decoder_select="fft mdct"
e8ed9b7a 1093dnxhd_encoder_select="aandct"
2eef7c62 1094dxa_decoder_select="zlib"
baf91bb9 1095eac3_decoder_select="ac3_decoder"
84c04e25 1096eamad_decoder_select="aandct"
e8ed9b7a 1097eatgq_decoder_select="aandct"
d52b39c7 1098eatqi_decoder_select="aandct"
4f034993
MR
1099ffv1_decoder_select="golomb"
1100flac_decoder_select="golomb"
f4d608e3 1101flac_encoder_select="golomb lpc"
2eef7c62
AJ
1102flashsv_decoder_select="zlib"
1103flashsv_encoder_select="zlib"
4d4b4bd1 1104flv_encoder_select="h263_encoder"
e8ed9b7a
DB
1105h261_encoder_select="aandct"
1106h263_encoder_select="aandct"
ff418735 1107h263_vaapi_hwaccel_deps="va_va_h"
95a61cfc 1108h263_vaapi_hwaccel_select="vaapi h263_decoder"
fe629c2d 1109h263p_encoder_select="h263_encoder"
4f034993 1110h264_decoder_select="golomb"
ff418735 1111h264_vaapi_hwaccel_deps="va_va_h"
17492d5e 1112h264_vaapi_hwaccel_select="vaapi"
711dae77 1113h264_vdpau_decoder_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
95a61cfc 1114h264_vdpau_decoder_select="vdpau h264_decoder"
47a158cb 1115imc_decoder_select="fft mdct"
4f034993
MR
1116jpegls_decoder_select="golomb"
1117jpegls_encoder_select="golomb"
e8ed9b7a 1118ljpeg_encoder_select="aandct"
4f034993 1119loco_decoder_select="golomb"
e8ed9b7a
DB
1120mjpeg_encoder_select="aandct"
1121mpeg1video_encoder_select="aandct"
1122mpeg2video_encoder_select="aandct"
c37de5e1 1123mpeg4_encoder_select="h263_encoder"
711dae77 1124mpeg_vdpau_decoder_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
95a61cfc 1125mpeg_vdpau_decoder_select="vdpau mpegvideo_decoder"
711dae77 1126mpeg1_vdpau_decoder_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
95a61cfc 1127mpeg1_vdpau_decoder_select="vdpau mpeg1video_decoder"
ff418735 1128mpeg2_vaapi_hwaccel_deps="va_va_h"
95a61cfc 1129mpeg2_vaapi_hwaccel_select="vaapi mpeg2video_decoder"
ff418735 1130mpeg4_vaapi_hwaccel_deps="va_va_h"
95a61cfc 1131mpeg4_vaapi_hwaccel_select="vaapi mpeg4_decoder"
8f6f050a 1132mpeg_xvmc_decoder_deps="X11_extensions_XvMClib_h"
4d8eecf4 1133mpeg_xvmc_decoder_select="mpegvideo_decoder"
4e169d89
DB
1134msmpeg4v1_encoder_select="h263_encoder"
1135msmpeg4v2_encoder_select="h263_encoder"
1136msmpeg4v3_encoder_select="h263_encoder"
47a158cb
MR
1137nellymoser_decoder_select="fft mdct"
1138nellymoser_encoder_select="fft mdct"
2eef7c62
AJ
1139png_decoder_select="zlib"
1140png_encoder_select="zlib"
63cae55d 1141qdm2_decoder_select="fft mdct rdft"
b2bf38b4
DB
1142rv10_encoder_select="h263_encoder"
1143rv20_encoder_select="h263_encoder"
d52b39c7
AJ
1144rv30_decoder_select="golomb"
1145rv40_decoder_select="golomb"
4f034993
MR
1146shorten_decoder_select="golomb"
1147sonic_decoder_select="golomb"
1148sonic_encoder_select="golomb"
1149sonic_ls_encoder_select="golomb"
1150svq3_decoder_select="golomb"
bee2eac5 1151svq3_decoder_suggest="zlib"
4eef77c1 1152theora_decoder_select="vp3_decoder"
2eef7c62
AJ
1153tiff_decoder_suggest="zlib"
1154tiff_encoder_suggest="zlib"
1155tscc_decoder_select="zlib"
ff418735 1156vc1_vaapi_hwaccel_deps="va_va_h"
95a61cfc 1157vc1_vaapi_hwaccel_select="vaapi vc1_decoder"
711dae77 1158vc1_vdpau_decoder_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
95a61cfc 1159vc1_vdpau_decoder_select="vdpau vc1_decoder"
47a158cb
MR
1160vorbis_decoder_select="fft mdct"
1161vorbis_encoder_select="fft mdct"
e82dc4c9
DB
1162vp6a_decoder_select="vp6_decoder"
1163vp6f_decoder_select="vp6_decoder"
47a158cb
MR
1164wmav1_decoder_select="fft mdct"
1165wmav1_encoder_select="fft mdct"
1166wmav2_decoder_select="fft mdct"
1167wmav2_encoder_select="fft mdct"
665507aa 1168wmv1_encoder_select="h263_encoder"
1746e2a9 1169wmv2_encoder_select="h263_encoder"
015f8ee0
DB
1170wmv3_decoder_select="vc1_decoder"
1171wmv3_vaapi_hwaccel_select="vc1_vaapi_hwaccel"
1172wmv3_vdpau_decoder_select="vc1_vdpau_decoder"
2eef7c62
AJ
1173zlib_decoder_select="zlib"
1174zlib_encoder_select="zlib"
1175zmbv_decoder_select="zlib"
1176zmbv_encoder_select="zlib"
30fd06be 1177
28b80940
DB
1178# parsers
1179h264_parser_select="golomb"
1180
912f3148 1181# external libraries
1b71f045 1182libdirac_decoder_deps="libdirac !libschroedinger"
690bfceb 1183libdirac_encoder_deps="libdirac"
c9171a83 1184libfaac_encoder_deps="libfaac"
69ddbd1d 1185libfaad_decoder_deps="libfaad"
4ec45764 1186libfaadbin_decoder_extralibs='$ldl'
299c77d5
MR
1187libgsm_decoder_deps="libgsm"
1188libgsm_encoder_deps="libgsm"
8ffed8d8
MR
1189libgsm_ms_decoder_deps="libgsm"
1190libgsm_ms_encoder_deps="libgsm"
1cc60c47 1191libmp3lame_encoder_deps="libmp3lame"
0b175caa
DB
1192libopencore_amrnb_decoder_deps="libopencore_amrnb"
1193libopencore_amrnb_encoder_deps="libopencore_amrnb"
1194libopencore_amrwb_decoder_deps="libopencore_amrwb"
9a77d59a 1195libopenjpeg_decoder_deps="libopenjpeg"
f7cd9eed
AS
1196libschroedinger_decoder_deps="libschroedinger"
1197libschroedinger_encoder_deps="libschroedinger"
ae14f311 1198libspeex_decoder_deps="libspeex"
150d2772 1199libtheora_encoder_deps="libtheora"
b0caf888 1200libvorbis_encoder_deps="libvorbis"
1cc60c47
DB
1201libx264_encoder_deps="libx264"
1202libxvid_encoder_deps="libxvid"
30fd06be 1203
912f3148 1204# demuxers / muxers
03a76ba9 1205ac3_demuxer_deps="ac3_parser"
647c2356 1206asf_stream_muxer_select="asf_muxer"
4e622dea
SS
1207avisynth_demuxer_deps="avisynth"
1208dirac_demuxer_deps="dirac_parser"
647c2356 1209ipod_muxer_select="mov_muxer"
4e622dea
SS
1210libnut_demuxer_deps="libnut"
1211libnut_muxer_deps="libnut"
647c2356 1212matroska_audio_muxer_select="matroska_muxer"
4e622dea
SS
1213matroska_demuxer_suggest="zlib bzlib"
1214mov_demuxer_suggest="zlib"
1215mp3_demuxer_deps="mpegaudio_parser"
647c2356
DB
1216mp4_muxer_select="mov_muxer"
1217mpegtsraw_demuxer_select="mpegts_demuxer"
1218mxf_d10_muxer_select="mxf_muxer"
1219psp_muxer_select="mov_muxer"
4e622dea
SS
1220rtp_muxer_deps="network rtp_protocol"
1221rtsp_demuxer_deps="sdp_demuxer"
1222sdp_demuxer_deps="rtp_protocol mpegts_demuxer"
647c2356
DB
1223tg2_muxer_select="mov_muxer"
1224tgp_muxer_select="mov_muxer"
6bdaa5f4 1225w64_demuxer_deps="wav_demuxer"
4e622dea
SS
1226
1227# indevs / outdevs
38e54a75
SS
1228alsa_indev_deps="alsa_asoundlib_h snd_pcm_htimestamp"
1229alsa_indev_extralibs="-lasound"
1230alsa_outdev_deps="alsa_asoundlib_h"
1231alsa_outdev_extralibs="-lasound"
1232audio_beos_indev_deps="audio_beos"
1233audio_beos_indev_extralibs="-lmedia -lbe"
1234audio_beos_outdev_deps="audio_beos"
1235audio_beos_outdev_extralibs="-lmedia -lbe"
38e54a75 1236bktr_indev_deps_any="dev_bktr_ioctl_bt848_h machine_ioctl_bt848_h dev_video_bktr_ioctl_bt848_h dev_ic_bt8xx_h"
38e54a75
SS
1237dv1394_indev_deps="dv1394 dv_demuxer"
1238jack_indev_deps="jack_jack_h"
1239jack_indev_extralibs="-ljack"
1240libdc1394_indev_deps="libdc1394"
38e54a75
SS
1241oss_indev_deps_any="soundcard_h sys_soundcard_h"
1242oss_outdev_deps_any="soundcard_h sys_soundcard_h"
38e54a75
SS
1243v4l_indev_deps="linux_videodev_h"
1244v4l2_indev_deps_any="linux_videodev2_h sys_videoio_h"
1245vfwcap_indev_deps="capCreateCaptureWindow"
1246vfwcap_indev_extralibs="-lvfw32"
1247x11_grab_device_indev_deps="x11grab XShmCreateImage"
1248x11_grab_device_indev_extralibs="-lX11 -lXext"
30fd06be 1249
912f3148 1250# protocols
3fff6382 1251gopher_protocol_deps="network"
c08fb000 1252http_protocol_deps="network"
cbf29889 1253rtmp_protocol_deps="tcp_protocol"
c08fb000
AB
1254rtp_protocol_deps="udp_protocol"
1255tcp_protocol_deps="network"
1256udp_protocol_deps="network"
1257
f7679c54 1258# filters
81124ba0 1259movie_filter_deps="avfilter_lavf"
f7679c54 1260
912f3148 1261# programs
fa859b4d 1262ffplay_deps="sdl"
6ad42348 1263ffserver_deps="ffm_muxer rtp_protocol rtsp_demuxer"
4ec45764 1264ffserver_extralibs='$ldl'
a2830dca 1265
c73f65d9 1266doc_deps="texi2html"
912f3148 1267
de6d9b64 1268# default parameters
8a608357 1269
2ba042a7 1270logfile="config.err"
8a608357
MR
1271
1272# installation paths
c9d19248
MR
1273prefix_default="/usr/local"
1274bindir_default='${prefix}/bin'
14a8acf1 1275datadir_default='${prefix}/share/ffmpeg'
c9d19248
MR
1276incdir_default='${prefix}/include'
1277libdir_default='${prefix}/lib'
1278mandir_default='${prefix}/share/man'
1279shlibdir_default="$libdir_default"
8a608357
MR
1280
1281# toolchain
11e6d03a 1282ar="ar"
13c7df3d 1283cc_default="gcc"
a3d7c197 1284cc_version=\"unknown\"
9da6609f 1285host_cc_default="gcc"
11e6d03a 1286ln_s="ln -sf"
89641463 1287nm_default="nm"
11e6d03a 1288objformat="elf"
be7109c1 1289ranlib="ranlib"
0f3cb305 1290strip="strip"
11e6d03a 1291yasmexe="yasm"
8a608357
MR
1292
1293# machine
5e622c40 1294arch=$(uname -m)
38d0a8aa 1295cpu="generic"
8a608357 1296
8a608357 1297# OS
4f854758 1298target_os=$(tolower $(uname -s))
82bb3329 1299host_os=$target_os
8a608357 1300
8a608357 1301# configurable options
497237c7 1302enable debug
c73f65d9 1303enable doc
aa033b1e 1304enable fastdiv
497237c7
RP
1305enable ffmpeg
1306enable ffplay
1307enable ffserver
1308enable ipv6
497237c7
RP
1309enable mpegaudio_hp
1310enable network
8400d6b8 1311enable optimizations
497237c7 1312enable protocols
530dc538 1313enable static
87a0fb62 1314enable stripping
a9ddb5b1 1315enable swscale_alpha
8a608357 1316
8a608357 1317# build settings
9987769a 1318SHFLAGS='-shared -Wl,-soname,$$(@F)'
c536cb09 1319FFSERVERLDFLAGS=-Wl,-E
f3ec2d46
SG
1320LIBPREF="lib"
1321LIBSUF=".a"
c5f14466
RP
1322FULLNAME='$(NAME)$(BUILDSUF)'
1323LIBNAME='$(LIBPREF)$(FULLNAME)$(LIBSUF)'
f3ec2d46
SG
1324SLIBPREF="lib"
1325SLIBSUF=".so"
c5f14466 1326SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF)'
b29bddab
DB
1327SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
1328SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
24743a76 1329LIB_INSTALL_EXTRA_CMD='$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
ef0bc4c9 1330
7e6c86e6
MR
1331CC_O='-o $@'
1332
f0125de9 1333host_cflags='-D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112 -O3 -g -Wall'
9da6609f
MR
1334host_libs='-lm'
1335
a7ada2ba
MR
1336target_path='.'
1337
0d7dca36
DB
1338# gcc stupidly only outputs the basename of targets with -MM, but we need the
1339# full relative path for objects in subdirectories for non-recursive Make.
c1c3933a 1340DEPEND_CMD='$(DEPCC) $(DEPFLAGS) $< | sed -e "/^\#.*/d" -e "s,^[[:space:]]*$(*F)\\.o,$(@D)/$(*F).o," > $(@:.o=.d)'
d8059267 1341DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -MM'
315c741d 1342
c597172e 1343# find source path
5e622c40 1344source_path="$(dirname "$0")"
497237c7 1345enable source_path_used
24524f36 1346if test -f configure; then
5e622c40 1347 source_path="$(pwd)"
497237c7 1348 disable source_path_used
c597172e 1349else
5e622c40 1350 source_path="$(cd "$source_path"; pwd)"
c597172e 1351 echo "$source_path" | grep -q '[[:blank:]]' &&
7483e694 1352 die "Out of tree builds are impossible with whitespace in source path."
337cee68
MC
1353 test -e "$source_path/config.h" &&
1354 die "Out of tree builds are impossible with config.h in source dir."
c597172e
MR
1355fi
1356
13cbe2c0 1357for v in "$@"; do
b04251c5
MR
1358 r=${v#*=}
1359 l=${v%"$r"}
1360 r=$(sh_quote "$r")
13cbe2c0
MR
1361 FFMPEG_CONFIGURATION="${FFMPEG_CONFIGURATION# } ${l}${r}"
1362done
c597172e 1363
73ef8980
MR
1364find_things(){
1365 thing=$1
1366 pattern=$2
1367 file=$source_path/$3
932ccf39 1368 sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" "$file"
73ef8980
MR
1369}
1370
1371ENCODER_LIST=$(find_things encoder ENC libavcodec/allcodecs.c)
1372DECODER_LIST=$(find_things decoder DEC libavcodec/allcodecs.c)
5666fd73 1373HWACCEL_LIST=$(find_things hwaccel HWACCEL libavcodec/allcodecs.c)
73ef8980
MR
1374PARSER_LIST=$(find_things parser PARSER libavcodec/allcodecs.c)
1375BSF_LIST=$(find_things bsf BSF libavcodec/allcodecs.c)
1376MUXER_LIST=$(find_things muxer _MUX libavformat/allformats.c)
1377DEMUXER_LIST=$(find_things demuxer DEMUX libavformat/allformats.c)
38e54a75
SS
1378OUTDEV_LIST=$(find_things outdev OUTDEV libavdevice/alldevices.c)
1379INDEV_LIST=$(find_things indev _IN libavdevice/alldevices.c)
73ef8980 1380PROTOCOL_LIST=$(find_things protocol PROTOCOL libavformat/allformats.c)
81124ba0 1381FILTER_LIST=$(find_things filter FILTER libavfilter/allfilters.c)
c597172e 1382
7483e694
DB
1383enable $ARCH_EXT_LIST \
1384 $DECODER_LIST \
1385 $ENCODER_LIST \
5666fd73 1386 $HWACCEL_LIST \
7483e694
DB
1387 $PARSER_LIST \
1388 $BSF_LIST \
1389 $DEMUXER_LIST \
1390 $MUXER_LIST \
f7679c54 1391 $FILTER_LIST \
7483e694
DB
1392 $PROTOCOL_LIST \
1393 $INDEV_LIST \
1394 $OUTDEV_LIST \
c597172e
MR
1395
1396die_unknown(){
1397 echo "Unknown option \"$1\"."
1398 echo "See $0 --help for available options."
1399 exit 1
1400}
1401
794f8e97 1402show_list() {
bf0c4afa
RP
1403 suffix=_$1
1404 shift
1405 echo $* | sed s/$suffix//g | tr ' ' '\n' | sort
794f8e97
PI
1406 exit 0
1407}
1408
c597172e 1409for opt do
7483e694
DB
1410 optval="${opt#*=}"
1411 case "$opt" in
0f010b2f 1412 --extra-ldflags=*) add_ldflags $optval
7483e694 1413 ;;
0f010b2f 1414 --extra-libs=*) add_extralibs $optval
7483e694 1415 ;;
8fb1cb58 1416 --disable-devices) disable $INDEV_LIST $OUTDEV_LIST
9aa8ed9d 1417 ;;
40bcf4c7
BL
1418 --enable-debug=*) debuglevel="$optval"
1419 ;;
7483e694 1420 --enable-*=*|--disable-*=*)
8b93ddc3 1421 eval $(echo "${opt%%=*}" | sed 's/--/action=/;s/-/ thing=/')
be8f2501
MR
1422 is_in "${thing}s" $COMPONENT_LIST || die_unknown "$opt"
1423 eval list=\$$(toupper $thing)_LIST
8b93ddc3
MR
1424 name=$(echo "${optval}" | sed "s/,/_${thing}|/g")_${thing}
1425 $action $(filter "$name" $list)
7483e694
DB
1426 ;;
1427 --enable-?*|--disable-?*)
5e622c40 1428 eval $(echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g')
e3773a55 1429 if is_in $option $COMPONENT_LIST; then
fed5d54b 1430 test $action = disable && action=unset
e3773a55
MR
1431 eval $action \$$(toupper ${option%s})_LIST
1432 elif is_in $option $CMDLINE_SELECT; then
1433 $action $option
1434 else
1435 die_unknown $opt
1436 fi
7483e694
DB
1437 ;;
1438 --list-*)
1439 NAME="${opt#--list-}"
1440 is_in $NAME $COMPONENT_LIST || die_unknown $opt
1441 NAME=${NAME%s}
1442 eval show_list $NAME \$$(toupper $NAME)_LIST
1443 ;;
1444 --help|-h) show_help
1445 ;;
1446 *)
884a36a7 1447 optname="${opt%%=*}"
26759c44
MR
1448 optname="${optname#--}"
1449 optname=$(echo "$optname" | sed 's/-/_/g')
89f2932b
MR
1450 if is_in $optname $CMDLINE_SET; then
1451 eval $optname='$optval'
1452 elif is_in $optname $CMDLINE_APPEND; then
1453 append $optname "$optval"
1454 else
1455 die_unknown $opt
1456 fi
7483e694
DB
1457 ;;
1458 esac
c597172e
MR
1459done
1460
bcea99bb
MR
1461disabled logging && logfile=/dev/null
1462
13cbe2c0 1463echo "# $0 $FFMPEG_CONFIGURATION" > $logfile
bcea99bb
MR
1464set >> $logfile
1465
9da6609f
MR
1466test -n "$cross_prefix" && enable cross_compile
1467
adb2b908 1468ar="${cross_prefix}${ar}"
11e6d03a 1469cc_default="${cross_prefix}${cc_default}"
20e0ed95 1470nm_default="${cross_prefix}${nm_default}"
adb2b908
RP
1471ranlib="${cross_prefix}${ranlib}"
1472strip="${cross_prefix}${strip}"
1473
c5200f17
MR
1474sysinclude_default="${sysroot}/usr/include"
1475
75800dce 1476set_default cc nm sysinclude
9da6609f
MR
1477enabled cross_compile || host_cc_default=$cc
1478set_default host_cc
13c7df3d 1479
82bb3329
MR
1480exesuf() {
1481 case $1 in
1482 mingw32*|cygwin*|*-dos|freedos|opendos|os/2*) echo .exe ;;
1483 esac
1484}
1485
1486EXESUF=$(exesuf $target_os)
1487HOSTEXESUF=$(exesuf $host_os)
c0f5b7f1 1488
e4e69e0b 1489# set temporary file name
a49d42c2 1490: ${TMPDIR:=$TEMPDIR}
c51fafa1 1491: ${TMPDIR:=$TMP}
a49d42c2 1492: ${TMPDIR:=/tmp}
e4e69e0b 1493
54460a83
MR
1494if ! check_cmd type mktemp; then
1495 # simple replacement for missing mktemp
1496 # NOT SAFE FOR GENERAL USE
1497 mktemp(){
1498 echo "${2%XXX*}.${HOSTNAME}.${UID}.$$"
1499 }
1500fi
1501
1502tmpfile(){
1503 tmp=$(mktemp -u "${TMPDIR}/ffconf.XXXXXXXX")$2 &&
1504 (set -C; exec > $tmp) 2>/dev/null ||
f7ba16a7 1505 die "Unable to create temporary file in $TMPDIR."
54460a83
MR
1506 append TMPFILES $tmp
1507 eval $1=$tmp
1508}
1509
1510trap 'rm -f -- $TMPFILES' EXIT
1511trap exit HUP INT TERM
1512
1513tmpfile TMPC .c
1514tmpfile TMPE $EXESUF
1515tmpfile TMPH .h
1516tmpfile TMPO .o
1517tmpfile TMPS .S
1518tmpfile TMPSH .sh
1519
1520unset -f mktemp
e4e69e0b 1521
993f2d0f
MR
1522# make sure we can execute files in $TMPDIR
1523cat > $TMPSH 2>> $logfile <<EOF
1524#! /bin/sh
1525EOF
1526chmod +x $TMPSH >> $logfile 2>&1
1527if ! $TMPSH >> $logfile 2>&1; then
1528 cat <<EOF
1529Unable to create and execute files in $TMPDIR. Set the TMPDIR environment
1530variable to another directory and make sure that it is not mounted noexec.
1531EOF
1532 die "Sanity test failed."
1533fi
993f2d0f 1534
19b4c628
MR
1535filter_cflags=echo
1536filter_cppflags=echo
1537filter_asflags=echo
1538
8f0c157a 1539if $cc -v 2>&1 | grep -qi ^gcc; then
629687f6 1540 cc_type=gcc
a3d7c197 1541 cc_version=__VERSION__
aef6bd1b
MR
1542 if ! $cc -dumpversion | grep -q '^2\.'; then
1543 CC_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
1544 AS_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
1545 fi
629687f6
MR
1546elif $cc --version 2>/dev/null | grep -q Intel; then
1547 cc_type=icc
6e3fa35d 1548 cc_version="AV_STRINGIFY(__INTEL_COMPILER)"
07dec06e
MR
1549 CC_DEPFLAGS='-MMD'
1550 AS_DEPFLAGS='-MMD'
629687f6
MR
1551elif $cc -v 2>&1 | grep -q xlc; then
1552 cc_type=xlc
6e3fa35d 1553 cc_version="AV_STRINGIFY(__IBMC__)"
df442a8d
MR
1554elif $cc -V 2>/dev/null | grep -q Compaq; then
1555 cc_type=ccc
6e3fa35d 1556 cc_version="AV_STRINGIFY(__DECC_VER)"
d8059267 1557 DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -M'
03754fcd 1558 debuglevel=3
df442a8d 1559 add_ldflags -Wl,-z,now # calls to libots crash without this
6a0d5493 1560elif $cc --vsn 2>/dev/null | grep -q "ARM C/C++ Compiler"; then
03e37762
MR
1561 test -d "$sysroot" || die "No valid sysroot specified."
1562 cc_type=armcc
6e3fa35d 1563 cc_version="AV_STRINGIFY(__ARMCC_VERSION)"
03e37762
MR
1564 armcc_conf="$PWD/armcc.conf"
1565 $cc --arm_linux_configure \
1566 --arm_linux_config_file="$armcc_conf" \
1567 --configure_sysroot="$sysroot" \
1568 --configure_cpp_headers="$sysinclude" >>$logfile 2>&1 ||
1569 die "Error creating armcc configuration file."
1570 cc="$cc --arm_linux_config_file=$armcc_conf --translate_gcc"
75800dce 1571 as_default="${cross_prefix}gcc"
07dec06e
MR
1572 CC_DEPFLAGS='-MMD'
1573 AS_DEPFLAGS='-MMD'
6fec122a
MR
1574elif $cc -version 2>/dev/null | grep -q TMS470; then
1575 cc_type=tms470
6e3fa35d 1576 cc_version="AV_STRINGIFY(__TI_COMPILER_VERSION__)"
6fec122a
MR
1577 cc="$cc --gcc --abi=eabi -eo=.o -mc -me"
1578 CC_O='-fr=$(@D)'
1579 as_default="${cross_prefix}gcc"
1580 ld_default="${cross_prefix}gcc"
6fec122a
MR
1581 TMPO=$(basename $TMPC .c).o
1582 append TMPFILES $TMPO
1583 add_cflags -D__gnuc_va_list=va_list -D__USER_LABEL_PREFIX__=
07dec06e
MR
1584 CC_DEPFLAGS='-ppa -ppd=$(@:.o=.d)'
1585 AS_DEPFLAGS='-MMD'
6fec122a
MR
1586 filter_cflags=tms470_flags
1587 tms470_flags(){
1588 for flag; do
1589 case $flag in
1590 -march=*|-mcpu=*)
1591 case "${flag#*=}" in
1592 armv7-a|cortex-a*) echo -mv=7a8 ;;
1593 armv7-r|cortex-r*) echo -mv=7r4 ;;
1594 armv7-m|cortex-m*) echo -mv=7m3 ;;
1595 armv6*|arm11*) echo -mv=6 ;;
1596 armv5*e|arm[79]*e*|arm9[24]6*|arm96*|arm102[26])
1597 echo -mv=5e ;;
1598 armv4*|arm7*|arm9[24]*) echo -mv=4 ;;
1599 esac
1600 ;;
1601 -mfpu=neon) echo --float_support=vfpv3 --neon ;;
1602 -mfpu=vfp) echo --float_support=vfpv2 ;;
a2709020 1603 -msoft-float) echo --float_support=vfplib ;;
6fec122a
MR
1604 -Os) echo -O3 -mf=2 ;;
1605 -O[0-3]) echo $flag -mf=5 ;;
1606 -g) echo -g -mn ;;
1607 esac
1608 done
1609 }
06da6943
DC
1610elif $cc -v 2>&1 | grep -q clang; then
1611 cc_type=clang
1612 cc_version=__VERSION__
1613 CC_DEPFLAGS='-MMD'
1614 AS_DEPFLAGS='-MMD'
2a472e9c
MK
1615elif $cc -V 2>&1 | grep -q Sun; then
1616 cc_type=suncc
1617 cc_version="AV_STRINGIFY(__SUNPRO_C)"
1618 DEPEND_CMD='$(DEPCC) $(DEPFLAGS) $< | sed -e "1s,^.*: ,$@: ," -e "\$$!s,\$$, \\\\\\," -e "1!s,^.*: , ," > $(@:.o=.d)'
1619 DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -xM1'
629687f6
MR
1620fi
1621
1622test -n "$cc_type" && enable $cc_type || echolog "Unknown C compiler $cc"
1623
75bafbac 1624: ${as_default:=$cc}
50567afa 1625: ${dep_cc_default:=$cc}
684b28e0 1626: ${ld_default:=$cc}
50567afa 1627set_default as dep_cc ld
75800dce 1628
07dec06e
MR
1629test -n "$CC_DEPFLAGS" || CCDEP=$DEPEND_CMD
1630test -n "$AS_DEPFLAGS" || ASDEP=$DEPEND_CMD
1631
7f32f40c 1632add_cflags $extra_cflags
2f2e6c7c 1633add_asflags $extra_cflags
7f32f40c 1634
154d432c
MR
1635if test -n "$sysroot"; then
1636 case "$cc_type" in
1637 gcc)
467256f2 1638 add_cppflags --sysroot="$sysroot"
154d432c
MR
1639 add_ldflags --sysroot="$sysroot"
1640 ;;
6fec122a
MR
1641 tms470)
1642 add_cppflags -I"$sysinclude"
1643 add_ldflags --sysroot="$sysroot"
1644 ;;
06da6943
DC
1645 clang)
1646 add_cppflags -isysroot="$sysroot"
1647 add_ldflags -isysroot="$sysroot"
1648 ;;
154d432c
MR
1649 esac
1650fi
1651
d22c13a8
MR
1652if test "$cpu" = host; then
1653 enabled cross_compile && die "--cpu=host makes no sense when cross-compiling."
1654
1655 case "$cc_type" in
1656 gcc)
1657 check_native(){
1658 $cc $1=native -v -c -o $TMPO $TMPC >$TMPE 2>&1 || return
1659 awk "/$1=/{ match(\$0, /$1=(\\w+)/, a);print a[1];exit }" $TMPE
1660 }
1661 cpu=$(check_native -march || check_native -mcpu)
1662 ;;
1663 esac
1664
1665 test "${cpu:-host}" = host && die "--cpu=host not supported with compiler $cc"
1666fi
1667
df5cdc24
MR
1668# Add processor-specific flags
1669case $cpu in
1670 601|ppc601|PowerPC601)
1671 cpuflags="-mcpu=601"
1672 ;;
1673 603*|ppc603*|PowerPC603*)
1674 cpuflags="-mcpu=603"
1675 ;;
1676 604*|ppc604*|PowerPC604*)
1677 cpuflags="-mcpu=604"
1678 ;;
1679 G3|g3|75*|ppc75*|PowerPC75*)
1680 cpuflags="-mcpu=750 -mpowerpc-gfxopt"
1681 ;;
1682 G4|g4|745*|ppc745*|PowerPC745*)
1683 cpuflags="-mcpu=7450 -mpowerpc-gfxopt"
1684 ;;
1685 74*|ppc74*|PowerPC74*)
1686 cpuflags="-mcpu=7400 -mpowerpc-gfxopt"
1687 ;;
1688 G5|g5|970|ppc970|PowerPC970|power4*|Power4*)
1689 cpuflags="-mcpu=970 -mpowerpc-gfxopt -mpowerpc64"
1690 ;;
1691 Cell|CELL|cell)
1692 cpuflags="-mcpu=cell"
1693 enable ldbrx
1694 ;;
1695 # targets that do NOT support conditional mov (cmov)
1696 i[345]86|pentium|pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
1697 cpuflags="-march=$cpu"
1698 disable cmov
1699 ;;
1700 # targets that do support conditional mov (cmov)
d3ee7715 1701 i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64|k8|opteron|athlon-fx|core2|amdfam10)
df5cdc24
MR
1702 cpuflags="-march=$cpu"
1703 enable cmov
1704 enable fast_cmov
1705 ;;
1706 # targets that do support conditional mov but on which it's slow
1707 pentium4|pentium4m|prescott|nocona)
1708 cpuflags="-march=$cpu"
1709 enable cmov
1710 disable fast_cmov
1711 ;;
1712 sparc64)
1713 cpuflags="-mcpu=v9"
1714 ;;
1715 arm11*|cortex*)
1716 cpuflags="-mcpu=$cpu"
1717 enable fast_unaligned
1718 ;;
1719 armv[67]*)
1720 cpuflags="-march=$cpu"
1721 enable fast_unaligned
1722 ;;
1723 armv*)
1724 cpuflags="-march=$cpu"
1725 ;;
1726 arm*)
1727 cpuflags="-mcpu=$cpu"
1728 ;;
1729 ev4|ev45|ev5|ev56|pca56|ev6|ev67)
1730 enabled ccc && cpuflags="-arch $cpu" || cpuflags="-mcpu=$cpu"
1731 ;;
1732 bf*)
1733 cpuflags="-mcpu=$cpu"
1734 ;;
1735 mips*|[45]k*|[237]4k*|m4k|r*000|loongson2[ef])
1736 cpuflags="-march=$cpu"
1737 ;;
fdcd782d
MR
1738 ap7[02]0[0-2])
1739 subarch="avr32_ap"
1740 cpuflags="-mpart=$cpu"
1741 ;;
1742 ap)
1743 subarch="avr32_ap"
1744 cpuflags="-march=$cpu"
1745 ;;
1746 uc3[ab]*)
1747 subarch="avr32_uc"
1748 cpuflags="-mcpu=$cpu"
1749 ;;
1750 uc)
1751 subarch="avr32_uc"
1752 cpuflags="-march=$cpu"
1753 ;;
df5cdc24
MR
1754 generic)
1755 ;;
1756 *)
1757 echo "WARNING: Unknown CPU \"$cpu\", ignored."
1758 ;;
1759esac
1760
1761add_cflags $cpuflags
1762add_asflags $cpuflags
1763
993f2d0f
MR
1764# compiler sanity check
1765check_exec <<EOF
1766int main(void){ return 0; }
1767EOF
1768if test "$?" != 0; then
1769 echo "$cc is unable to create an executable file."
1770 if test -z "$cross_prefix" && ! enabled cross_compile ; then
1771 echo "If $cc is a cross-compiler, use the --enable-cross-compile option."
1772 echo "Only do this if you know what cross compiling means."
1773 fi
1774 die "C compiler test failed."
1775fi
1776
38a9c529 1777add_cppflags -D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112
e9b9a2f8 1778check_cflags -std=c99
50a334e4 1779check_cc -D_FILE_OFFSET_BITS=64 <<EOF && add_cppflags -D_FILE_OFFSET_BITS=64
9d821fc2
DB
1780#include <stdlib.h>
1781EOF
50a334e4 1782check_cc -D_LARGEFILE_SOURCE <<EOF && add_cppflags -D_LARGEFILE_SOURCE
9d821fc2
DB
1783#include <stdlib.h>
1784EOF
e9b9a2f8 1785
f0125de9
MR
1786check_host_cflags -std=c99
1787
b24dbcbd 1788case "$arch" in
b24dbcbd
RP
1789 alpha)
1790 arch="alpha"
1791 enable fast_64bit
c0a02a3e 1792 check_cflags -mieee
8a3c8627 1793 spic=$shared
b24dbcbd 1794 ;;
cfdb6148
MR
1795 arm|armv[4567]*l)
1796 arch="arm"
b24dbcbd 1797 ;;
f4870943
MR
1798 avr32)
1799 ;;
cfdb6148
MR
1800 bfin)
1801 arch="bfin"
1802 ;;
1803 ia64)
1804 arch="ia64"
b24dbcbd 1805 enable fast_64bit
8a3c8627 1806 spic=$shared
0956bc9b
RD
1807 # HACK: currently fails to build if .bss is > 4MB and shared libs are built
1808 enabled shared && enable hardcoded_tables
cfdb6148
MR
1809 ;;
1810 m68k)
1811 arch="m68k"
b24dbcbd 1812 ;;
de3a1240 1813 mips|mipsel|IP*)
b24dbcbd 1814 arch="mips"
8a3c8627 1815 spic=$shared
b24dbcbd 1816 ;;
de3a1240
DB
1817 mips64)
1818 arch="mips"
bae3abb0 1819 subarch="mips64"
de3a1240 1820 enable fast_64bit
8a3c8627 1821 spic=$shared
de3a1240 1822 ;;
61597a98 1823 parisc|hppa)
b24dbcbd 1824 arch="parisc"
8a3c8627 1825 spic=$shared
b24dbcbd 1826 ;;
61597a98 1827 parisc64|hppa64)
b24dbcbd
RP
1828 arch="parisc"
1829 enable fast_64bit
8a3c8627 1830 spic=$shared
b24dbcbd 1831 ;;
cfdb6148
MR
1832 "Power Macintosh"|ppc|powerpc)
1833 arch="ppc"
1834 enable fast_unaligned
1835 ;;
1836 ppc64)
1837 arch="ppc"
34d11b87 1838 subarch="ppc64"
cfdb6148
MR
1839 enable fast_64bit
1840 enable fast_unaligned
1841 ;;
b24dbcbd
RP
1842 s390|s390x)
1843 arch="s390"
1844 ;;
cfdb6148
MR
1845 sh4|sh)
1846 arch="sh4"
b24dbcbd 1847 ;;
cfdb6148
MR
1848 sparc)
1849 arch="sparc"
8a3c8627 1850 spic=$shared
cfdb6148
MR
1851 ;;
1852 sun4u|sparc64)
1853 arch="sparc"
1854 subarch="sparc64"
b24dbcbd 1855 enable fast_64bit
8a3c8627 1856 spic=$shared
b24dbcbd 1857 ;;
de27f4d9 1858 i386|i486|i586|i686|i86pc|BePC|x86_64|amd64)
cfdb6148
MR
1859 arch="x86"
1860 subarch="x86_32"
1861 enable fast_unaligned
8a3c8627 1862 check_cc <<EOF && enable fast_64bit && subarch="x86_64" && spic=$shared
cfdb6148
MR
1863 int test[sizeof(char*) - 7];
1864EOF
de27f4d9
DC
1865 if test "$subarch" = "x86_64"; then
1866 enable cmov
1867 enable fast_cmov
1868 fi
b24dbcbd
RP
1869 ;;
1870 *)
1871 arch="unknown"
1872 ;;
1873esac
1874
62045d48 1875enable $arch $subarch
8a3c8627 1876enabled spic && enable pic
b24dbcbd 1877
7483e694 1878# OS specific
4f854758 1879case $target_os in
7483e694 1880 beos|haiku|zeta)
c9d19248 1881 prefix_default="$HOME/config"
7483e694 1882 # helps building libavcodec
50a334e4
MR
1883 add_cppflags -DPIC
1884 add_cflags -fomit-frame-pointer
7483e694 1885 # 3 gcc releases known for BeOS, each with ugly bugs
5e622c40 1886 gcc_version="$($cc -v 2>&1 | grep version | cut -d ' ' -f3-)"
7483e694
DB
1887 case "$gcc_version" in
1888 2.9-beos-991026*|2.9-beos-000224*) echo "R5/GG gcc"
1889 disable mmx
1890 ;;
1891 *20010315*) echo "BeBits gcc"
0f010b2f 1892 add_cflags -fno-expensive-optimizations
7483e694
DB
1893 ;;
1894 esac
7483e694
DB
1895 SHFLAGS=-nostart
1896 # enable BeOS things
1897 enable audio_beos
1898 # no need for libm, but the inet stuff
1899 # Check for BONE
1900 # XXX: actually should check for NOT net_server
78fe7631 1901 if echo $BEINCLUDES | grep -q 'headers/be/bone'; then
7483e694
DB
1902 network_extralibs="-lbind -lsocket"
1903 else
1904 enable beos_netserver
1905 network_extralibs="-lnet"
1906 fi ;;
1907 sunos)
1908 FFSERVERLDFLAGS=""
9987769a 1909 SHFLAGS='-shared -Wl,-h,$$(@F)'
0600d30a 1910 enabled x86 && SHFLAGS="-mimpure-text $SHFLAGS"
7483e694 1911 network_extralibs="-lsocket -lnsl"
50a334e4 1912 add_cppflags -D__EXTENSIONS__
7483e694
DB
1913 ;;
1914 netbsd)
07a8eef6
MR
1915 oss_indev_extralibs="-lossaudio"
1916 oss_outdev_extralibs="-lossaudio"
7483e694
DB
1917 ;;
1918 openbsd)
89e053f8 1919 enable malloc_aligned
cd78208b 1920 enable pic
7483e694 1921 SHFLAGS='-shared'
07a8eef6
MR
1922 oss_indev_extralibs="-lossaudio"
1923 oss_outdev_extralibs="-lossaudio"
7483e694 1924 ;;
90b4f091 1925 freebsd|dragonfly)
89e053f8 1926 enable malloc_aligned
7483e694
DB
1927 ;;
1928 bsd/os)
1929 osextralibs="-lpoll -lgnugetopt"
1930 strip="strip -d"
1931 ;;
1932 darwin)
89e053f8 1933 enable malloc_aligned
0138c54e 1934 SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(SHLIBDIR)/$(SLIBNAME),-current_version,$(LIBVERSION),-compatibility_version,$(LIBMAJOR) -Wl,-read_only_relocs,suppress'
7483e694
DB
1935 strip="strip -x"
1936 FFLDFLAGS="-Wl,-dynamic,-search_paths_first"
1937 SLIBSUF=".dylib"
1938 SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME).$(LIBVERSION)$(SLIBSUF)'
1939 SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME).$(LIBMAJOR)$(SLIBSUF)'
1940 FFSERVERLDFLAGS=-Wl,-bind_at_load
304d586d 1941 objformat="macho"
1b0f6fb8 1942 enabled x86_64 && objformat="macho64"
8dfa86f7 1943 enabled_any pic shared ||
2704bd1a 1944 { check_cflags -mdynamic-no-pic && add_asflags -mdynamic-no-pic; }
7483e694
DB
1945 ;;
1946 mingw32*)
9d3f4f50 1947 if test $target_os = "mingw32ce"; then
1aa71e25
MS
1948 disable network
1949 else
1950 target_os=mingw32
1951 fi
dcc01c06 1952 LIBTARGET=i386
1fc9fb8a 1953 if enabled x86_64; then
89e053f8 1954 enable malloc_aligned
dcc01c06 1955 LIBTARGET=x64
336cc1b0
MS
1956 elif enabled arm; then
1957 LIBTARGET=arm
dcc01c06 1958 fi
fbd971a4 1959 shlibdir_default="$bindir_default"
7483e694
DB
1960 disable ffserver
1961 SLIBPREF=""
1962 SLIBSUF=".dll"
7483e694
DB
1963 SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
1964 SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
06abe7f5 1965 SLIB_EXTRA_CMD='-lib.exe /machine:$(LIBTARGET) /def:$$(@:$(SLIBSUF)=.def) /out:$(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)'
4c25d159 1966 SLIB_INSTALL_EXTRA_CMD='-install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"; \
b9349ff4
MS
1967 install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)"; \
1968 install -d "$(LIBDIR)"; \
1969 install -m 644 $(SUBDIR)lib$(SLIBNAME:$(SLIBSUF)=.dll.a) "$(LIBDIR)/lib$(SLIBNAME:$(SLIBSUF)=.dll.a)"'
7483e694 1970 SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"'
4b51fb1c 1971 SHFLAGS='-shared -Wl,--output-def,$$(@:$(SLIBSUF)=.def) -Wl,--out-implib,$(SUBDIR)lib$(SLIBNAME:$(SLIBSUF)=.dll.a) -Wl,--enable-runtime-pseudo-reloc -Wl,--enable-auto-image-base'
304d586d 1972 objformat="win32"
bc574408 1973 enable dos_paths
1894e741 1974 check_cflags -fno-common
b1549d61 1975 if ! enabled x86_64; then
f7ad5aa2
RP
1976 check_cpp_condition _mingw.h "(__MINGW32_MAJOR_VERSION > 3) || (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" ||
1977 die "ERROR: MinGW runtime version must be >= 3.15."
8beb4178 1978 enabled_any avisynth vfwcap_indev &&
f7ad5aa2 1979 { check_cpp_condition w32api.h "(__W32API_MAJOR_VERSION > 3) || (__W32API_MAJOR_VERSION == 3 && __W32API_MINOR_VERSION >= 13)" ||
8beb4178 1980 die "ERROR: avisynth and vfwcap_indev require w32api version 3.13 or later."; }
f7ad5aa2 1981 fi
7483e694
DB
1982 ;;
1983 cygwin*)
4f854758 1984 target_os=cygwin
fbd971a4 1985 shlibdir_default="$bindir_default"
7483e694
DB
1986 SLIBPREF="cyg"
1987 SLIBSUF=".dll"
1988 SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
1989 SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
1990 SHFLAGS='-shared -Wl,--enable-auto-image-base'
304d586d 1991 objformat="win32"
bc574408 1992 enable dos_paths
1894e741 1993 check_cflags -fno-common
7483e694 1994 ;;
4f365f37 1995 *-dos|freedos|opendos)
fdf11906 1996 disable ffplay ffserver
4f365f37
MK
1997 disable $INDEV_LIST $OUTDEV_LIST
1998 network_extralibs="-lsocket"
ff1c015d 1999 objformat="coff"
bc574408 2000 enable dos_paths
4f365f37 2001 ;;
7483e694 2002 linux)
7483e694
DB
2003 enable dv1394
2004 ;;
2005 irix*)
4f854758 2006 target_os=irix
7483e694
DB
2007 ranlib="echo ignoring ranlib"
2008 ;;
d22e8442 2009 os/2*)
d22e8442
DY
2010 strip="lxlite"
2011 ln_s="cp -f"
d22e8442 2012 FFLDFLAGS="-Zomf -Zbin-files -Zargs-wild -Zmap"
71c61f62 2013 SHFLAGS='$(SUBDIR)$(NAME).def -Zdll -Zomf'
d22e8442 2014 FFSERVERLDFLAGS=""
287d3b13 2015 LIBSUF="_s.a"
d22e8442
DY
2016 SLIBPREF=""
2017 SLIBSUF=".dll"
2018 SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
2019 SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(shell echo $(NAME) | cut -c1-6)$(LIBMAJOR)$(SLIBSUF)'
71c61f62
MR
2020 SLIB_CREATE_DEF_CMD='echo LIBRARY $(SLIBNAME_WITH_MAJOR) INITINSTANCE TERMINSTANCE > $(SUBDIR)$(NAME).def; \
2021 echo PROTMODE >> $(SUBDIR)$(NAME).def; \
2022 echo CODE PRELOAD MOVEABLE DISCARDABLE >> $(SUBDIR)$(NAME).def; \
2023 echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $(SUBDIR)$(NAME).def; \
2024 echo EXPORTS >> $(SUBDIR)$(NAME).def; \
2025 emxexp -o $(OBJS) >> $(SUBDIR)$(NAME).def'
2026 SLIB_EXTRA_CMD='emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(NAME).def; \
2027 emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib $(SUBDIR)$(NAME).def;'
2028 SLIB_INSTALL_EXTRA_CMD='install -m 644 $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib "$(LIBDIR)"'
d22e8442 2029 SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.a "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.lib'
bc574408 2030 enable dos_paths
d22e8442 2031 ;;
83993c1c
AM
2032 gnu/kfreebsd)
2033 ;;
34e82167 2034 gnu)
34e82167 2035 ;;
d22e8442 2036
7483e694 2037 *)
4f924f9a 2038 die "Unknown OS '$target_os'."
7483e694
DB
2039 ;;
2040esac
2041
c9d19248
MR
2042set_default $PATHS_LIST
2043
c597172e 2044add_extralibs $osextralibs
de6d9b64 2045
28d8e661
DB
2046# Combine FFLDFLAGS and the LDFLAGS environment variable.
2047LDFLAGS="$FFLDFLAGS $LDFLAGS"
e89b8b0a 2048
320d060a 2049# we need to build at least one lib type
93b3c083 2050if ! enabled_any static shared; then
320d060a
DB
2051 cat <<EOF
2052At least one library type must be built.
2053Specify --enable-static to build the static libraries or --enable-shared to
2054build the shared libraries as well. To only build the shared libraries specify
2055--disable-static in addition to --enable-shared.
2056EOF
2057 exit 1;
2058fi
2059
abc4e572 2060disabled static && LIBNAME=""
2a320695 2061
a2234ceb
RP
2062if enabled_any libfaad libfaadbin ; then
2063 if check_header faad.h; then
295b8c70 2064 check_cc <<EOF
a2234ceb
RP
2065#include <faad.h>
2066#ifndef FAAD2_VERSION
2067ok faad1
2068#endif
db817cf3 2069int main(void) { return 0; }
a2234ceb
RP
2070EOF
2071 test $? = 0 && enable libfaad2
2072 else
ff3dac65 2073 die "FAAD test failed."
a2234ceb
RP
2074 fi
2075fi
2076
2077
2184c6f7 2078die_license_disabled() {
4c27207c 2079 enabled $1 || { enabled $2 && die "$2 is $1 and --enable-$1 is not specified."; }
2184c6f7
DB
2080}
2081
2082die_license_disabled gpl libfaad2
2083die_license_disabled gpl libx264
2084die_license_disabled gpl libxvid
2085die_license_disabled gpl postproc
2086die_license_disabled gpl x11grab
2087
2f7ae63b 2088die_license_disabled nonfree libfaac
b2e3c528 2089
0b175caa
DB
2090die_license_disabled version3 libopencore_amrnb
2091die_license_disabled version3 libopencore_amrwb
2092
9cad0e4e 2093enabled version3 && { enabled gpl && enable gplv3 || enable lgplv3; }
3fe142e2 2094
9eeed841 2095check_deps $ARCH_EXT_LIST
0f3cb305 2096
40617a6d 2097disabled optimizations || check_cflags -fomit-frame-pointer
cf9d24ad 2098
e276d9e8
MR
2099enable_pic() {
2100 enable pic
bce7b696
MR
2101 add_cppflags -DPIC
2102 add_cflags -fPIC
2103 add_asflags -fPIC
e276d9e8
MR
2104}
2105
2106enabled pic && enable_pic
bce7b696 2107
b4d96ba2
MR
2108check_cc <<EOF || die "Symbol mangling check failed."
2109int ff_extern;
2110EOF
2f05d9c1 2111sym=$($nm -P -g $TMPO | grep ff_extern)
b4d96ba2
MR
2112extern_prefix=${sym%%ff_extern*}
2113
f65883c8
MR
2114check_cc <<EOF && enable inline_asm
2115void foo(void) { __asm__ volatile ("" ::); }
2116EOF
61d251db 2117
df5e3978
MR
2118_restrict=
2119for restrict_keyword in restrict __restrict__ __restrict; do
2120 check_cc <<EOF && _restrict=$restrict_keyword && break
2121void foo(char * $restrict_keyword p);
2122EOF
2123done
2124
2125check_cc <<EOF && enable attribute_packed
2126struct { int x; } __attribute__((packed)) x;
2127EOF
2128
2129check_cc <<EOF || die "endian test failed"
2130unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
2131EOF
2132od -A n -t x1 $TMPO | grep -q '42 *49 *47 *45' && enable bigendian
2133
fa0912fe 2134if enabled arm; then
e45391bb 2135
50fa82e6
MR
2136 check_cflags -marm
2137
fa0912fe
MR
2138 check_ld <<EOF && enable vfp_args
2139__asm__ (".eabi_attribute 28, 1");
2140int main(void) { return 0; }
2141EOF
2142
2143 # We have to check if pld is a nop and disable it.
2144 check_asm pld '"pld [r0]"'
2145
2146 enabled armv5te && check_asm armv5te '"qadd r0, r0, r0"'
2147 enabled armv6 && check_asm armv6 '"sadd16 r0, r0, r0"'
2148 enabled armv6t2 && check_asm armv6t2 '"movt r0, #0"'
2149 enabled armvfp && check_asm armvfp '"fadds s0, s0, s0"'
2150 enabled iwmmxt && check_asm iwmmxt '"wunpckelub wr6, wr4"'
2151 enabled neon && check_asm neon '"vadd.i16 q0, q0, q0"'
e45391bb 2152
e276d9e8
MR
2153 enabled_all armv6t2 shared !pic && enable_pic
2154
fa0912fe 2155elif enabled mips; then
e45391bb 2156
fa0912fe
MR
2157 check_asm loongson '"dmult.g $1, $2, $3"'
2158 enabled mmi && check_asm mmi '"lq $2, 0($2)"'
e45391bb 2159
fa0912fe 2160elif enabled ppc; then
e45391bb 2161
fa0912fe
MR
2162 check_asm dcbzl '"dcbzl 0, 1"'
2163 check_asm ppc4xx '"maclhw r10, r11, r12"'
2164 check_asm xform_asm '"lwzx 0, %y0" :: "Z"(*(int*)0)'
2165
2166 # AltiVec flags: The FSF version of GCC differs from the Apple version
2167 if enabled altivec; then
2168 check_cflags -maltivec -mabi=altivec &&
2169 { check_header altivec.h && inc_altivec_h="#include <altivec.h>" ; } ||
2170 check_cflags -faltivec
2171
2172 # check if our compiler supports Motorola AltiVec C API
2173 check_cc <<EOF || disable altivec
2174$inc_altivec_h
2175int main(void) {
2176 vector signed int v1, v2, v3;
2177 v1 = vec_add(v2,v3);
2178 return 0;
2179}
2180EOF
2181
2182 # check if our compiler supports braces for vector declarations
2183 check_cc <<EOF || die "You need a compiler that supports {} in AltiVec vector declarations."
2184$inc_altivec_h
2185int main (void) { (vector int) {1}; return 0; }
2186EOF
2187 fi
e45391bb 2188
fa0912fe 2189elif enabled sparc; then
e45391bb 2190
fa0912fe
MR
2191 enabled vis && check_asm vis '"pdist %f0, %f0, %f0"' -mcpu=ultrasparc &&
2192 add_cflags -mcpu=ultrasparc -mtune=ultrasparc
e45391bb 2193
fa0912fe 2194elif enabled x86; then
e45391bb 2195
44965991
PI
2196 # check whether EBP is available on x86
2197 # As 'i' is stored on the stack, this program will crash
2198 # if the base pointer is used to access it because the
2199 # base pointer is cleared in the inline assembly code.
7dfef245 2200 check_exec_crash <<EOF && enable ebp_available
44965991 2201 volatile int i=0;
be449fca 2202 __asm__ volatile (
44965991
PI
2203 "xorl %%ebp, %%ebp"
2204 ::: "%ebp");
2205 return i;
44965991
PI
2206EOF
2207
f494213c 2208 # check whether EBX is available on x86
7cee5421
MR
2209 check_asm ebx_available '""::"b"(0)' &&
2210 check_asm ebx_available '"":::"%ebx"'
8e380710 2211
d3a4b4e0
DB
2212 # check whether more than 10 operands are supported
2213 check_cc <<EOF && enable ten_operands
2214int main(void) {
2215 int x=0;
2216 __asm__ volatile(
2217 ""
2218 :"+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x)
2219 );
2220 return 0;
2221}
2222EOF
2223
d7f0920b 2224 # check whether binutils is new enough to compile SSSE3/MMX2
940f335a 2225 enabled ssse3 && check_asm ssse3 '"pabsw %xmm0, %xmm0"'
5fd89ca0 2226 enabled mmx2 && check_asm mmx2 '"pmaxub %mm0, %mm1"'
6bd859d6
MR
2227
2228 check_asm bswap '"bswap %%eax" ::: "%eax"'
304d586d 2229
d52481b9 2230 YASMFLAGS="-f $objformat -DARCH_$(toupper $subarch)"
304d586d
LM
2231 enabled x86_64 && append YASMFLAGS "-m amd64"
2232 enabled_all x86_64 shared && append YASMFLAGS "-DPIC"
2233 case "$objformat" in
2234 elf) enabled debug && append YASMFLAGS "-g dwarf2" ;;
1b0f6fb8 2235 macho64) append YASMFLAGS "-DPIC -DPREFIX" ;;
304d586d
LM
2236 *) append YASMFLAGS "-DPREFIX" ;;
2237 esac
7595a5e4 2238 disabled yasm || { check_yasm "pabsw xmm0, xmm0" && enable yasm; }
e45391bb 2239
44965991
PI
2240fi
2241
a98bb16d
RP
2242if check_func dlopen; then
2243 ldl=
2244elif check_func dlopen -ldl; then
2245 ldl=-ldl
8bf5d58f
MN
2246fi
2247
75ecf149
DB
2248# Solaris has nanosleep in -lrt, OpenSolaris no longer needs that
2249check_func nanosleep || { check_func nanosleep -lrt && add_extralibs -lrt; }
2250
7483e694
DB
2251check_func fork
2252check_func gethrtime
2253check_func getrusage
094c09bb 2254check_func inet_aton $network_extralibs
abfc8d05 2255check_func isatty
7483e694
DB
2256check_func memalign
2257check_func mkstemp
1f91cdce 2258check_func posix_memalign
b507ebd1 2259check_func_headers io.h setmode
e4673692 2260check_func_headers lzo/lzo1x.h lzo1x_999_compress
2446d3d6 2261check_func_headers windows.h GetProcessTimes
7c5bfe7a 2262check_func_headers windows.h VirtualAlloc
6ffa87d3 2263
e16e49ac 2264check_header conio.h
a98bb16d
RP
2265check_header dlfcn.h
2266check_header malloc.h
bf6ce82d 2267check_header poll.h
b58412f1 2268check_header sys/mman.h
b091aa44 2269check_header sys/resource.h
bf6ce82d 2270check_header sys/select.h
a98bb16d 2271check_header termios.h
272081b0
CEH
2272check_header vdpau/vdpau.h
2273check_header vdpau/vdpau_x11.h
68178ca9 2274check_header X11/extensions/XvMClib.h
a98bb16d 2275
89e053f8
MR
2276if ! enabled_any memalign memalign_hack posix_memalign malloc_aligned &&
2277 enabled_any $need_memalign ; then
1f91cdce 2278 die "Error, no aligned memory allocator but SSE enabled, disable it or use --enable-memalign-hack."
a98bb16d 2279fi
e16e49ac 2280
a4fa192c 2281disabled zlib || check_lib zlib.h zlibVersion -lz || disable zlib
632948bd 2282disabled bzlib || check_lib2 bzlib.h BZ2_bzlibVersion -lbz2 || disable bzlib
57bd82d4
MR
2283
2284# check for some common methods of building with pthread support
2285# do this before the optional library checks as some of them require pthreads
2286if enabled pthreads; then
9e7fd101
MR
2287 if check_func pthread_create; then
2288 :
2289 elif check_func pthread_create -pthread; then
2290 add_cflags -pthread
afc9aee2 2291 add_extralibs -pthread
9e7fd101
MR
2292 elif check_func pthread_create -pthreads; then
2293 add_cflags -pthreads
afc9aee2 2294 add_extralibs -pthreads
8d94f606
GT
2295 elif check_func pthread_create -lpthreadGC2; then
2296 add_extralibs -lpthreadGC2
9e7fd101
MR
2297 elif ! check_lib pthread.h pthread_create -lpthread; then
2298 die "ERROR: can't find pthreads library"
2299 fi
57bd82d4
MR
2300fi
2301
8eee7025 2302for thread in $THREADS_LIST; do
e5f94c2b 2303 if enabled $thread; then
3ae3b721
RP
2304 test -n "$thread_type" &&
2305 die "ERROR: Only one thread type must be selected." ||
e5f94c2b 2306 thread_type="$thread"
e5f94c2b
RP
2307 fi
2308done
2309
fdf88598 2310check_lib math.h sin -lm
ff418735 2311check_lib va/va.h vaInitialize -lva
fdf88598 2312
ad420e25
MR
2313check_func llrint
2314check_func log2
2315check_func lrint
2316check_func lrintf
2317check_func round
2318check_func roundf
2319check_func truncf
f32adb22 2320
57bd82d4 2321# these are off by default, so fail if requested and not available
79fda097 2322enabled avisynth && require2 vfw32 "windows.h vfw.h" AVIFileInit -lvfw32
e3cc7d6f 2323enabled libdirac && add_cflags $(pkg-config --cflags dirac) &&
2513b2b4
DB
2324 require libdirac libdirac_decoder/dirac_parser.h dirac_decoder_init $(pkg-config --libs dirac) &&
2325 require libdirac libdirac_encoder/dirac_encoder.h dirac_encoder_init $(pkg-config --libs dirac)
79fda097
DB
2326enabled libfaac && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
2327enabled libfaad && require2 libfaad faad.h faacDecOpen -lfaad
7483e694 2328enabled libgsm && require libgsm gsm.h gsm_create -lgsm
2bfecf73 2329enabled libmp3lame && require libmp3lame lame/lame.h lame_init -lmp3lame -lm
7483e694 2330enabled libnut && require libnut libnut.h nut_demuxer_init -lnut
0b175caa
DB
2331enabled libopencore_amrnb && require libopencore_amrnb opencore-amrnb/interf_dec.h Decoder_Interface_init -lopencore-amrnb -lm
2332enabled libopencore_amrwb && require libopencore_amrwb opencore-amrwb/dec_if.h D_IF_init -lopencore-amrwb -lm
3d6fac8c 2333enabled libopenjpeg && require libopenjpeg openjpeg.h opj_version -lopenjpeg
36718e51
DB
2334enabled libschroedinger && add_cflags $(pkg-config --cflags schroedinger-1.0) &&
2335 require libschroedinger schroedinger/schro.h schro_init $(pkg-config --libs schroedinger-1.0)
ae14f311 2336enabled libspeex && require libspeex speex/speex.h speex_decoder_init -lspeex
7483e694
DB
2337enabled libtheora && require libtheora theora/theora.h theora_info_init -ltheora -logg
2338enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
e69bb386 2339enabled libx264 && require libx264 x264.h x264_encoder_encode -lx264 -lm &&
19538981
JGG
2340 { check_cpp_condition x264.h "X264_BUILD >= 78" ||
2341 die "ERROR: libx264 version must be >= 0.78."; }
2bfecf73 2342enabled libxvid && require libxvid xvid.h xvid_global -lxvidcore
7483e694 2343enabled mlib && require mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
8ac17293 2344
0b4a1821
AS
2345# libdc1394 check
2346if enabled libdc1394; then
2347 { check_lib dc1394/dc1394.h dc1394_new -ldc1394 -lraw1394 &&
2348 enable libdc1394_2; } ||
2349 { check_lib libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394 &&
2350 enable libdc1394_1; } ||
2351 die "ERROR: No version of libdc1394 found "
2352fi
2353
497237c7
RP
2354disable sdl_too_old
2355disable sdl
6a1a892f 2356SDL_CONFIG="${cross_prefix}sdl-config"
2270b4b2 2357if "${SDL_CONFIG}" --version > /dev/null 2>&1; then
5e622c40 2358 sdl_cflags=$("${SDL_CONFIG}" --cflags)
b4f93564 2359 sdl_libs=$("${SDL_CONFIG}" --libs)
225e21ef 2360 temp_cflags $sdl_cflags
b4f93564 2361 temp_extralibs $sdl_libs
1ca5d97f 2362 if check_lib2 SDL.h SDL_Init; then
5e622c40 2363 _sdlversion=$("${SDL_CONFIG}" --version | sed 's/[^0-9]//g')
29f3b38a 2364 if test "$_sdlversion" -lt 121 ; then
497237c7 2365 enable sdl_too_old
dcd479c0 2366 else
497237c7 2367 enable sdl
225e21ef 2368 check_cc $sdl_cflags <<EOF && enable sdl_video_size
29f3b38a 2369#include <SDL.h>
d6773f56 2370int main(int argc, char **argv){
29f3b38a
MR
2371 const SDL_VideoInfo *vi = SDL_GetVideoInfo();
2372 int w = vi->current_w;
2373 return 0;
2374}
2375EOF
dcd479c0
MR
2376 fi
2377 fi
29f3b38a 2378 restore_flags
c3f6b472 2379fi
57bd82d4 2380
2270b4b2 2381texi2html -version > /dev/null 2>&1 && enable texi2html || disable texi2html
146ea952 2382
73b46a95 2383if enabled network; then
96000432 2384 check_type "sys/types.h sys/socket.h" socklen_t
73b46a95
RP
2385 # Prefer arpa/inet.h over winsock2
2386 if check_header arpa/inet.h ; then
2387 check_func closesocket
2388 elif check_header winsock2.h ; then
f4c13872
MS
2389 check_func_headers winsock2.h closesocket -lws2 && \
2390 network_extralibs="-lws2" || \
2391 { check_func_headers winsock2.h closesocket -lws2_32 && \
2392 network_extralibs="-lws2_32"; }
72be9e73 2393 check_type ws2tcpip.h socklen_t
28c9f069
MK
2394 else
2395 disable network
73b46a95
RP
2396 fi
2397fi
2398
b6f3d925 2399enabled_all network ipv6 && check_ld <<EOF || disable ipv6
7a91333f
HZ
2400#include <sys/types.h>
2401#include <sys/socket.h>
2402#include <netinet/in.h>
2403#include <netdb.h>
db817cf3 2404int main(void) {
7483e694
DB
2405 struct sockaddr_storage saddr;
2406 struct ipv6_mreq mreq6;
2407 getaddrinfo(0,0,0,0);
2408 getnameinfo(0,0,0,0,0,0,0);
2409 IN6_IS_ADDR_MULTICAST((const struct in6_addr *)0);
7a91333f
HZ
2410}
2411EOF
2412
06e31011
RP
2413check_header linux/videodev.h
2414check_header linux/videodev2.h
1b6e8b73 2415check_header sys/videoio.h
47f38850 2416
2446d3d6 2417check_func_headers "windows.h vfw.h" capCreateCaptureWindow -lvfw32
c2345207 2418
f8aa696f 2419# check for ioctl_meteor.h, ioctl_bt848.h and alternatives
1c915f83
RP
2420{ check_header dev/bktr/ioctl_meteor.h &&
2421 check_header dev/bktr/ioctl_bt848.h; } ||
2422{ check_header machine/ioctl_meteor.h &&
2423 check_header machine/ioctl_bt848.h; } ||
2424{ check_header dev/video/meteor/ioctl_meteor.h &&
2425 check_header dev/video/bktr/ioctl_bt848.h; } ||
2426check_header dev/ic/bt8xx.h
f8aa696f 2427
c7682de0
RP
2428check_header sys/soundcard.h
2429check_header soundcard.h
deb29777 2430
b6f3d925 2431enabled_any alsa_indev alsa_outdev && check_lib2 alsa/asoundlib.h snd_pcm_htimestamp -lasound
35fd8122 2432
0e57fe17 2433enabled jack_indev && check_lib2 jack/jack.h jack_client_open -ljack
80ff8a16 2434
56a059ac 2435enabled x11grab &&
f58f4ce1
GP
2436check_header X11/Xlib.h &&
2437check_header X11/extensions/XShm.h &&
2438check_func XOpenDisplay -lX11 &&
06eab4ba 2439check_func XShmCreateImage -lX11 -lXext
f58f4ce1 2440
95e561ec 2441enabled debug && add_cflags -g"$debuglevel" && add_asflags -g"$debuglevel"
57bd82d4
MR
2442
2443# add some useful compiler flags if supported
2444check_cflags -Wdeclaration-after-statement
dcd479c0
MR
2445check_cflags -Wall
2446check_cflags -Wno-switch
c07bd6a9
MN
2447check_cflags -Wdisabled-optimization
2448check_cflags -Wpointer-arith
2449check_cflags -Wredundant-decls
cc1fb623 2450check_cflags -Wno-pointer-sign
f4929996 2451check_cflags -Wcast-qual
9aceb3cf 2452check_cflags -Wwrite-strings
652a5bf6 2453check_cflags -Wtype-limits
764551c6 2454check_cflags -Wundef
5af4e0cc 2455enabled extra_warnings && check_cflags -Winline
cf9d24ad 2456
57bd82d4 2457# add some linker flags
5c0e9479 2458check_ldflags -Wl,--warn-common
8351d2ba
DB
2459check_ldflags -Wl,--as-needed
2460check_ldflags '-Wl,-rpath-link,\$(BUILD_ROOT)/libpostproc -Wl,-rpath-link,\$(BUILD_ROOT)/libswscale -Wl,-rpath-link,\$(BUILD_ROOT)/libavfilter -Wl,-rpath-link,\$(BUILD_ROOT)/libavdevice -Wl,-rpath-link,\$(BUILD_ROOT)/libavformat -Wl,-rpath-link,\$(BUILD_ROOT)/libavcodec -Wl,-rpath-link,\$(BUILD_ROOT)/libavutil'
c2fd6530 2461check_ldflags -Wl,-Bsymbolic
94a3401e 2462
bd2216e4
MR
2463if enabled small; then
2464 check_cflags -Os # not all compilers support -Os
8400d6b8
DB
2465 optimizations="small"
2466elif enabled optimizations; then
629687f6 2467 if enabled xlc; then
0f010b2f
DB
2468 add_cflags -O5
2469 add_ldflags -O5
df442a8d
MR
2470 elif enabled ccc; then
2471 add_cflags -fast
cf9d24ad 2472 else
0f010b2f 2473 add_cflags -O3
cf9d24ad 2474 fi
cddf3f45 2475fi
11fdbc44 2476check_cflags -fno-math-errno
b2eb2ff0 2477check_cflags -fno-signed-zeros
cddf3f45 2478
629687f6 2479if enabled icc; then
b1598b58
MR
2480 # Just warnings, no remarks
2481 check_cflags -w1
2482 # -wd: Disable following warnings
2483 # 144, 167, 556: -Wno-pointer-sign
2484 # 10006: ignoring unknown option -fno-signed-zeros
2485 # 10156: ignoring option '-W'; no argument required
2486 check_cflags -wd144,167,556,10006,10156
2487 # 11030: Warning unknown option --as-needed
2488 # 10156: ignoring option '-export'; no argument required
2489 check_ldflags -wd10156,11030
2490 # Allow to compile with optimizations
2491 check_ldflags -march=$cpu
be2cf98a
CEH
2492 # icc 11.0 and 11.1 work with ebp_available, but don't pass the test
2493 enable ebp_available
df442a8d
MR
2494elif enabled ccc; then
2495 # disable some annoying warnings
2496 add_cflags -msg_disable cvtu32to64
2497 add_cflags -msg_disable embedcomment
2498 add_cflags -msg_disable needconstext
2499 add_cflags -msg_disable nomainieee
2500 add_cflags -msg_disable ptrmismatch1
2501 add_cflags -msg_disable unreachcode
973859f5
MR
2502elif enabled gcc; then
2503 check_cflags -fno-tree-vectorize
06da6943
DC
2504elif enabled clang; then
2505 check_cflags -Qunused-arguments
504a64b9
CEH
2506fi
2507
90be59ef 2508if enabled gprof; then
0f010b2f
DB
2509 add_cflags -p
2510 add_ldflags -p
1db54e20
DB
2511fi
2512
7f3c02fc 2513# Find out if the .align argument is a power of two or not.
9377b6ce 2514check_asm asmalign_pot '".align 3"'
4454dc1b 2515
7483e694
DB
2516enabled_any $DECODER_LIST && enable decoders
2517enabled_any $ENCODER_LIST && enable encoders
5666fd73 2518enabled_any $HWACCEL_LIST && enable hwaccels
7483e694
DB
2519enabled_any $BSF_LIST && enable bsfs
2520enabled_any $DEMUXER_LIST && enable demuxers
2521enabled_any $MUXER_LIST && enable muxers
f7679c54 2522enabled_any $FILTER_LIST && enable filters
63d72fda
DB
2523enabled_any $INDEV_LIST && enable indevs
2524enabled_any $OUTDEV_LIST && enable outdevs
7483e694
DB
2525enabled_any $PROTOCOL_LIST && enable protocols
2526
2527enabled_any $THREADS_LIST && enable threads
2528
2529check_deps $CONFIG_LIST \
b6bb00b0 2530 $CONFIG_EXTRA \
7483e694
DB
2531 $HAVE_LIST \
2532 $DECODER_LIST \
2533 $ENCODER_LIST \
5666fd73 2534 $HWACCEL_LIST \
7483e694
DB
2535 $PARSER_LIST \
2536 $BSF_LIST \
2537 $DEMUXER_LIST \
2538 $MUXER_LIST \
f7679c54 2539 $FILTER_LIST \
7483e694
DB
2540 $INDEV_LIST \
2541 $OUTDEV_LIST \
2542 $PROTOCOL_LIST \
f70f03f6 2543
3e89171a 2544echo "install prefix $prefix"
f36958f8
DB
2545echo "source path $source_path"
2546echo "C compiler $cc"
bfd5afd8 2547echo ".align is power-of-two $asmalign_pot"
f36958f8 2548echo "ARCH $arch ($cpu)"
ce8871c2
MR
2549if test "$build_suffix" != ""; then
2550 echo "build suffix $build_suffix"
eb94aca9 2551fi
ac63af34
DB
2552if test "$extra_version" != ""; then
2553 echo "version string suffix $extra_version"
2554fi
0db2ce77 2555echo "big-endian ${bigendian-no}"
e90f5b5a 2556echo "runtime cpu detection ${runtime_cpudetect-no}"
5b6c2cbd 2557if enabled x86; then
af44e8e4 2558 echo "yasm ${yasm-no}"
0db2ce77 2559 echo "MMX enabled ${mmx-no}"
30e98e62 2560 echo "MMX2 enabled ${mmx2-no}"
3bf96eec 2561 echo "3DNow! enabled ${amd3dnow-no}"
a1ef9f08 2562 echo "3DNow! extended enabled ${amd3dnowext-no}"
1bb04d5a 2563 echo "SSE enabled ${sse-no}"
30e98e62 2564 echo "SSSE3 enabled ${ssse3-no}"
0db2ce77
MR
2565 echo "CMOV enabled ${cmov-no}"
2566 echo "CMOV is fast ${fast_cmov-no}"
971cc990
MN
2567 echo "EBX available ${ebx_available-no}"
2568 echo "EBP available ${ebp_available-no}"
d3a4b4e0 2569 echo "10 operands supported ${ten_operands-no}"
e41e8342 2570fi
5b6c2cbd 2571if enabled arm; then
0db2ce77
MR
2572 echo "ARMv5TE enabled ${armv5te-no}"
2573 echo "ARMv6 enabled ${armv6-no}"
ab5cb084 2574 echo "ARMv6T2 enabled ${armv6t2-no}"
f55b299a 2575 echo "ARM VFP enabled ${armvfp-no}"
0db2ce77 2576 echo "IWMMXT enabled ${iwmmxt-no}"
6b18d278 2577 echo "NEON enabled ${neon-no}"
eba9ae3c 2578fi
5b6c2cbd 2579if enabled mips; then
0db2ce77 2580 echo "MMI enabled ${mmi-no}"
e41e8342 2581fi
5b6c2cbd 2582if enabled ppc; then
0db2ce77 2583 echo "AltiVec enabled ${altivec-no}"
30e98e62 2584 echo "PPC 4xx optimizations ${ppc4xx-no}"
0db2ce77 2585 echo "dcbzl available ${dcbzl-no}"
30e98e62
DB
2586 echo "performance report ${powerpc_perf-no}"
2587fi
2588if enabled sparc; then
2589 echo "VIS enabled ${vis-no}"
e41e8342 2590fi
0db2ce77
MR
2591echo "gprof enabled ${gprof-no}"
2592echo "debug symbols ${debug-no}"
87a0fb62 2593echo "strip symbols ${stripping-no}"
8400d6b8 2594echo "optimizations ${optimizations-no}"
0db2ce77
MR
2595echo "static ${static-no}"
2596echo "shared ${shared-no}"
4a24ab64 2597echo "postprocessing support ${postproc-no}"
f7679c54 2598echo "new filter support ${avfilter-no}"
81124ba0 2599echo "filters using lavformat ${avfilter_lavf-no}"
0db2ce77 2600echo "network support ${network-no}"
90be59ef 2601if enabled network; then
0db2ce77 2602 echo "IPv6 support ${ipv6-no}"
bfd5afd8 2603fi
0db2ce77
MR
2604echo "threading support ${thread_type-no}"
2605echo "SDL support ${sdl-no}"
90be59ef 2606if enabled sdl_too_old; then
bfd5afd8
DB
2607 echo "-> Your SDL version is too old - please upgrade to have FFplay/SDL support."
2608fi
0db2ce77
MR
2609echo "Sun medialib support ${mlib-no}"
2610echo "AVISynth enabled ${avisynth-no}"
f7b8bffe 2611echo "libdc1394 support ${libdc1394-no}"
690bfceb 2612echo "libdirac enabled ${libdirac-no}"
0db2ce77
MR
2613echo "libfaac enabled ${libfaac-no}"
2614echo "libfaad enabled ${libfaad-no}"
7e0871a7 2615echo "libfaad dlopened ${libfaadbin-no}"
0db2ce77
MR
2616echo "libgsm enabled ${libgsm-no}"
2617echo "libmp3lame enabled ${libmp3lame-no}"
2618echo "libnut enabled ${libnut-no}"
0b175caa
DB
2619echo "libopencore-amrnb support ${libopencore_amrnb-no}"
2620echo "libopencore-amrwb support ${libopencore_amrwb-no}"
9a77d59a 2621echo "libopenjpeg enabled ${libopenjpeg-no}"
f7cd9eed 2622echo "libschroedinger enabled ${libschroedinger-no}"
ae14f311 2623echo "libspeex enabled ${libspeex-no}"
0db2ce77
MR
2624echo "libtheora enabled ${libtheora-no}"
2625echo "libvorbis enabled ${libvorbis-no}"
d6bd62db
DB
2626echo "libx264 enabled ${libx264-no}"
2627echo "libxvid enabled ${libxvid-no}"
0db2ce77 2628echo "zlib enabled ${zlib-no}"
f402916e 2629echo "bzlib enabled ${bzlib-no}"
2c62e737 2630echo
de6d9b64 2631
5666fd73 2632for type in decoder encoder hwaccel parser demuxer muxer protocol filter bsf indev outdev; do
8138b9db 2633 echo "Enabled ${type}s:"
f65c9da1 2634 eval list=\$$(toupper $type)_LIST
8138b9db 2635 for part in $list; do
f65c9da1
MR
2636 enabled $part && echo ${part%_*}
2637 done | sort | pr -3 -t
2638 echo
8138b9db
RP
2639done
2640
ba7a7039 2641license="LGPL version 2.1 or later"
ba321adb 2642if enabled nonfree; then
ba7a7039 2643 license="nonfree and unredistributable"
9cad0e4e
DB
2644elif enabled gplv3; then
2645 license="GPL version 3 or later"
2646elif enabled lgplv3; then
2647 license="LGPL version 3 or later"
ba321adb 2648elif enabled gpl; then
ba7a7039 2649 license="GPL version 2 or later"
ba321adb
JK
2650fi
2651
2652echo "License: $license"
ca5323af 2653
cf1392e9
DB
2654echo "Creating config.mak and config.h..."
2655
ad212cc6
MR
2656enabled stripping || strip="echo skipping strip"
2657
173c983b
MR
2658cat > config.mak <<EOF
2659# Automatically generated by configure - do not modify!
2660ifndef FFMPEG_CONFIG_MAK
2661FFMPEG_CONFIG_MAK=1
2662FFMPEG_CONFIGURATION=$FFMPEG_CONFIGURATION
2663prefix=$prefix
2664LIBDIR=\$(DESTDIR)$libdir
2665SHLIBDIR=\$(DESTDIR)$shlibdir
2666INCDIR=\$(DESTDIR)$incdir
2667BINDIR=\$(DESTDIR)$bindir
2668DATADIR=\$(DESTDIR)$datadir
2669MANDIR=\$(DESTDIR)$mandir
2670SRC_PATH="$source_path"
2671SRC_PATH_BARE=$source_path
2672BUILD_ROOT="$PWD"
2673ARCH=$arch
2674CC=$cc
2675AS=$as
2676LD=$ld
2677DEPCC=$dep_cc
2678YASM=$yasmexe
2679AR=$ar
2680RANLIB=$ranlib
2681LN_S=$ln_s
2682STRIP=$strip
2683CPPFLAGS=$CPPFLAGS
2684CFLAGS=$CFLAGS
2685ASFLAGS=$ASFLAGS
2686CC_O=$CC_O
2687LDFLAGS=$LDFLAGS
2688FFSERVERLDFLAGS=$FFSERVERLDFLAGS
2689SHFLAGS=$SHFLAGS
2690YASMFLAGS=$YASMFLAGS
2691BUILDSUF=$build_suffix
2692FULLNAME=$FULLNAME
2693LIBPREF=$LIBPREF
2694LIBSUF=$LIBSUF
2695LIBNAME=$LIBNAME
2696SLIBPREF=$SLIBPREF
2697SLIBSUF=$SLIBSUF
2698EXESUF=$EXESUF
2699EXTRA_VERSION=$extra_version
2700DEPFLAGS=$DEPFLAGS
2701CCDEP=$CCDEP
2702ASDEP=$ASDEP
2703CC_DEPFLAGS=$CC_DEPFLAGS
2704AS_DEPFLAGS=$AS_DEPFLAGS
2705HOSTCC=$host_cc
2706HOSTCFLAGS=$host_cflags
2707HOSTEXESUF=$HOSTEXESUF
2708HOSTLDFLAGS=$host_ldflags
2709HOSTLIBS=$host_libs
2710TARGET_EXEC=$target_exec
2711TARGET_PATH=$target_path
2712SDL_LIBS=$sdl_libs
2713SDL_CFLAGS=$sdl_cflags
2714LIB_INSTALL_EXTRA_CMD=$LIB_INSTALL_EXTRA_CMD
2715EXTRALIBS=$extralibs
2716EOF
5a872801 2717
719c8e00
MR
2718get_version(){
2719 name=$1
2720 file=$source_path/$2
147e7692
MR
2721 eval $(grep "#define ${name}_VERSION_M" "$file" | awk '{ print $2"="$3 }')
2722 eval ${name}_VERSION=\$${name}_VERSION_MAJOR.\$${name}_VERSION_MINOR.\$${name}_VERSION_MICRO
0e32c8c6
MR
2723 lcname=$(tolower $name)
2724 eval echo "${lcname}_VERSION=\$${name}_VERSION" >> config.mak
2725 eval echo "${lcname}_VERSION_MAJOR=\$${name}_VERSION_MAJOR" >> config.mak
719c8e00
MR
2726}
2727
147e7692
MR
2728get_version LIBSWSCALE libswscale/swscale.h
2729get_version LIBPOSTPROC libpostproc/postprocess.h
2730get_version LIBAVCODEC libavcodec/avcodec.h
2731get_version LIBAVDEVICE libavdevice/avdevice.h
2732get_version LIBAVFORMAT libavformat/avformat.h
2733get_version LIBAVUTIL libavutil/avutil.h
a6601d69 2734get_version LIBAVFILTER libavfilter/avfilter.h
5a872801 2735
173c983b
MR
2736enabled shared && cat >> config.mak <<EOF
2737LIBTARGET=${LIBTARGET}
2738SLIBNAME=${SLIBNAME}
2739SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}
2740SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}
2741SLIB_CREATE_DEF_CMD=${SLIB_CREATE_DEF_CMD}
2742SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}
2743SLIB_INSTALL_EXTRA_CMD=${SLIB_INSTALL_EXTRA_CMD}
2744SLIB_UNINSTALL_EXTRA_CMD=${SLIB_UNINSTALL_EXTRA_CMD}
2745EOF
523ef551 2746
173c983b
MR
2747enabled asmalign_pot || align_shift="1 <<"
2748
2749cat > $TMPH <<EOF
2750/* Automatically generated by configure - do not modify! */
2751#ifndef FFMPEG_CONFIG_H
2752#define FFMPEG_CONFIG_H
2753#define FFMPEG_CONFIGURATION "$(c_escape $FFMPEG_CONFIGURATION)"
2754#define FFMPEG_DATADIR "$(eval c_escape $datadir)"
2755#define CC_TYPE "$cc_type"
2756#define CC_VERSION $cc_version
2757#define restrict $_restrict
2758#define ASMALIGN(ZEROBITS) ".align $align_shift " #ZEROBITS "\\n\\t"
2759#define EXTERN_PREFIX "${extern_prefix}"
2760#define EXTERN_ASM ${extern_prefix}
2761EOF
523ef551
DB
2762
2763if enabled small || disabled optimizations; then
2764 echo "#define av_always_inline" >> $TMPH
2765fi
2766
3d907e22
MR
2767print_config ARCH_ $TMPH config.mak $ARCH_LIST
2768print_config HAVE_ $TMPH config.mak $HAVE_LIST
7483e694 2769print_config CONFIG_ $TMPH config.mak $CONFIG_LIST \
b6bb00b0 2770 $CONFIG_EXTRA \
7483e694
DB
2771 $DECODER_LIST \
2772 $ENCODER_LIST \
5666fd73 2773 $HWACCEL_LIST \
7483e694
DB
2774 $PARSER_LIST \
2775 $BSF_LIST \
2776 $DEMUXER_LIST \
2777 $MUXER_LIST \
f7679c54 2778 $FILTER_LIST \
7483e694
DB
2779 $PROTOCOL_LIST \
2780 $INDEV_LIST \
2781 $OUTDEV_LIST \
8ac17293 2782
9c05103f 2783echo "#endif /* FFMPEG_CONFIG_H */" >> $TMPH
8c6d2da5 2784echo "endif # FFMPEG_CONFIG_MAK" >> config.mak
9c05103f 2785
b7860763 2786# Do not overwrite an unchanged config.h to avoid superfluous rebuilds.
3ae3b721
RP
2787cmp -s $TMPH config.h &&
2788 echo "config.h is unchanged" ||
2789 mv -f $TMPH config.h
3d204385 2790
165af439 2791# build tree in object directory if source path is different from current one
90be59ef 2792if enabled source_path_used; then
b767b9cd
MR
2793 DIRS="
2794 doc
2795 libavcodec
2796 libavcodec/$arch
2797 libavdevice
2798 libavfilter
2799 libavformat
2800 libavutil
2801 libavutil/$arch
2802 libpostproc
2803 libswscale
2804 libswscale/$arch
2805 tests
2806 tools
2807 "
2808 FILES="
2809 Makefile
2810 common.mak
2811 subdir.mak
2812 doc/texi2pod.pl
2813 libavcodec/Makefile
2814 libavdevice/Makefile
2815 libavfilter/Makefile
2816 libavformat/Makefile
2817 libavutil/Makefile
2818 libpostproc/Makefile
2819 libswscale/Makefile
2820 "
165af439 2821 for dir in $DIRS ; do
7483e694 2822 mkdir -p $dir
165af439
MR
2823 done
2824 for f in $FILES ; do
20369773 2825 $ln_s "$source_path/$f" $f
165af439
MR
2826 done
2827fi
def4272a 2828
def4272a 2829
d0674868 2830# build pkg-config files
def4272a 2831
d0674868
DB
2832pkgconfig_generate(){
2833name=$1
b0dfd108 2834shortname=${name#lib}${build_suffix}
d0674868
DB
2835comment=$2
2836version=$3
2837libs=$4
2838requires=$5
25cd5cb3 2839cat <<EOF > $name/$name.pc
3e89171a 2840prefix=$prefix
a94e666c 2841exec_prefix=\${prefix}
f2b7382c 2842libdir=$libdir
7622778e 2843includedir=$incdir
def4272a 2844
d0674868
DB
2845Name: $name
2846Description: $comment
2847Version: $version
8cd6b388 2848Requires: $(enabled shared || echo $requires)
5dcfe9f8 2849Requires.private: $(enabled shared && echo $requires)
def4272a 2850Conflicts:
8cd6b388 2851Libs: -L\${libdir} -l${shortname} $(enabled shared || echo $libs)
12701f6e 2852Libs.private: $(enabled shared && echo $libs)
76a448ed 2853Cflags: -I\${includedir}
def4272a 2854EOF
25cd5cb3 2855cat <<EOF > $name/$name-uninstalled.pc
def4272a
AJ
2856prefix=
2857exec_prefix=
46d1ff83 2858libdir=\${pcfiledir}
1d44d365 2859includedir=${source_path}
def4272a 2860
d0674868
DB
2861Name: $name
2862Description: $comment
2863Version: $version
2864Requires: $requires
def4272a 2865Conflicts:
12701f6e 2866Libs: \${libdir}/${LIBPREF}${shortname}${LIBSUF} $libs
def4272a
AJ
2867Cflags: -I\${includedir}
2868EOF
d0674868 2869}
def4272a 2870
e426941d 2871pkgconfig_generate libavutil "FFmpeg utility library" "$LIBAVUTIL_VERSION"
46983309
RT
2872pkgconfig_generate libavcodec "FFmpeg codec library" "$LIBAVCODEC_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION"
2873pkgconfig_generate libavformat "FFmpeg container format library" "$LIBAVFORMAT_VERSION" "$extralibs" "libavcodec = $LIBAVCODEC_VERSION"
2874pkgconfig_generate libavdevice "FFmpeg device handling library" "$LIBAVDEVICE_VERSION" "$extralibs" "libavformat = $LIBAVFORMAT_VERSION"
3ed1a2ee 2875enabled avfilter &&
46983309 2876 pkgconfig_generate libavfilter "FFmpeg video filtering library" "$LIBAVFILTER_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION"
3ed1a2ee 2877enabled postproc &&
e426941d 2878 pkgconfig_generate libpostproc "FFmpeg post processing library" "$LIBPOSTPROC_VERSION"
5add54b4 2879pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "" "libavutil = $LIBAVUTIL_VERSION"