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