Mark the AOT escape value as supported.
[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.
c1c3933a 1312DEPEND_CMD='$(DEPCC) $(DEPFLAGS) $< | sed -e "/^\#.*/d" -e "s,^[[:space:]]*$(*F)\\.o,$(@D)/$(*F).o," > $(@:.o=.d)'
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-*=*)
8b93ddc3 1393 eval $(echo "${opt%%=*}" | sed 's/--/action=/;s/-/ thing=/')
be8f2501
MR
1394 is_in "${thing}s" $COMPONENT_LIST || die_unknown "$opt"
1395 eval list=\$$(toupper $thing)_LIST
8b93ddc3
MR
1396 name=$(echo "${optval}" | sed "s/,/_${thing}|/g")_${thing}
1397 $action $(filter "$name" $list)
7483e694
DB
1398 ;;
1399 --enable-?*|--disable-?*)
5e622c40 1400 eval $(echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g')
e3773a55 1401 if is_in $option $COMPONENT_LIST; then
fed5d54b 1402 test $action = disable && action=unset
e3773a55
MR
1403 eval $action \$$(toupper ${option%s})_LIST
1404 elif is_in $option $CMDLINE_SELECT; then
1405 $action $option
1406 else
1407 die_unknown $opt
1408 fi
7483e694
DB
1409 ;;
1410 --list-*)
1411 NAME="${opt#--list-}"
1412 is_in $NAME $COMPONENT_LIST || die_unknown $opt
1413 NAME=${NAME%s}
1414 eval show_list $NAME \$$(toupper $NAME)_LIST
1415 ;;
1416 --help|-h) show_help
1417 ;;
1418 *)
884a36a7 1419 optname="${opt%%=*}"
26759c44
MR
1420 optname="${optname#--}"
1421 optname=$(echo "$optname" | sed 's/-/_/g')
89f2932b
MR
1422 if is_in $optname $CMDLINE_SET; then
1423 eval $optname='$optval'
1424 elif is_in $optname $CMDLINE_APPEND; then
1425 append $optname "$optval"
1426 else
1427 die_unknown $opt
1428 fi
7483e694
DB
1429 ;;
1430 esac
c597172e
MR
1431done
1432
bcea99bb
MR
1433disabled logging && logfile=/dev/null
1434
13cbe2c0 1435echo "# $0 $FFMPEG_CONFIGURATION" > $logfile
bcea99bb
MR
1436set >> $logfile
1437
9da6609f
MR
1438test -n "$cross_prefix" && enable cross_compile
1439
adb2b908 1440ar="${cross_prefix}${ar}"
11e6d03a 1441cc_default="${cross_prefix}${cc_default}"
20e0ed95 1442nm_default="${cross_prefix}${nm_default}"
adb2b908
RP
1443ranlib="${cross_prefix}${ranlib}"
1444strip="${cross_prefix}${strip}"
1445
c5200f17
MR
1446sysinclude_default="${sysroot}/usr/include"
1447
75800dce 1448set_default cc nm sysinclude
9da6609f
MR
1449enabled cross_compile || host_cc_default=$cc
1450set_default host_cc
13c7df3d 1451
82bb3329
MR
1452exesuf() {
1453 case $1 in
1454 mingw32*|cygwin*|*-dos|freedos|opendos|os/2*) echo .exe ;;
1455 esac
1456}
1457
1458EXESUF=$(exesuf $target_os)
1459HOSTEXESUF=$(exesuf $host_os)
c0f5b7f1 1460
e4e69e0b 1461# set temporary file name
a49d42c2 1462: ${TMPDIR:=$TEMPDIR}
c51fafa1 1463: ${TMPDIR:=$TMP}
a49d42c2 1464: ${TMPDIR:=/tmp}
e4e69e0b 1465
54460a83
MR
1466if ! check_cmd type mktemp; then
1467 # simple replacement for missing mktemp
1468 # NOT SAFE FOR GENERAL USE
1469 mktemp(){
1470 echo "${2%XXX*}.${HOSTNAME}.${UID}.$$"
1471 }
1472fi
1473
1474tmpfile(){
1475 tmp=$(mktemp -u "${TMPDIR}/ffconf.XXXXXXXX")$2 &&
1476 (set -C; exec > $tmp) 2>/dev/null ||
1477 die "Unable to create temoporary file in $TMPDIR."
1478 append TMPFILES $tmp
1479 eval $1=$tmp
1480}
1481
1482trap 'rm -f -- $TMPFILES' EXIT
1483trap exit HUP INT TERM
1484
1485tmpfile TMPC .c
1486tmpfile TMPE $EXESUF
1487tmpfile TMPH .h
1488tmpfile TMPO .o
1489tmpfile TMPS .S
1490tmpfile TMPSH .sh
1491
1492unset -f mktemp
e4e69e0b 1493
993f2d0f
MR
1494# make sure we can execute files in $TMPDIR
1495cat > $TMPSH 2>> $logfile <<EOF
1496#! /bin/sh
1497EOF
1498chmod +x $TMPSH >> $logfile 2>&1
1499if ! $TMPSH >> $logfile 2>&1; then
1500 cat <<EOF
1501Unable to create and execute files in $TMPDIR. Set the TMPDIR environment
1502variable to another directory and make sure that it is not mounted noexec.
1503EOF
1504 die "Sanity test failed."
1505fi
993f2d0f 1506
19b4c628
MR
1507filter_cflags=echo
1508filter_cppflags=echo
1509filter_asflags=echo
1510
8f0c157a 1511if $cc -v 2>&1 | grep -qi ^gcc; then
629687f6 1512 cc_type=gcc
aef6bd1b
MR
1513 if ! $cc -dumpversion | grep -q '^2\.'; then
1514 CC_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
1515 AS_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
1516 fi
629687f6
MR
1517elif $cc --version 2>/dev/null | grep -q Intel; then
1518 cc_type=icc
07dec06e
MR
1519 CC_DEPFLAGS='-MMD'
1520 AS_DEPFLAGS='-MMD'
629687f6
MR
1521elif $cc -v 2>&1 | grep -q xlc; then
1522 cc_type=xlc
df442a8d
MR
1523elif $cc -V 2>/dev/null | grep -q Compaq; then
1524 cc_type=ccc
d8059267 1525 DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -M'
03754fcd 1526 debuglevel=3
df442a8d 1527 add_ldflags -Wl,-z,now # calls to libots crash without this
03e37762
MR
1528elif $cc --vsn 2>/dev/null | grep -q RVCT; then
1529 test -d "$sysroot" || die "No valid sysroot specified."
1530 cc_type=armcc
1531 armcc_conf="$PWD/armcc.conf"
1532 $cc --arm_linux_configure \
1533 --arm_linux_config_file="$armcc_conf" \
1534 --configure_sysroot="$sysroot" \
1535 --configure_cpp_headers="$sysinclude" >>$logfile 2>&1 ||
1536 die "Error creating armcc configuration file."
1537 cc="$cc --arm_linux_config_file=$armcc_conf --translate_gcc"
75800dce 1538 as_default="${cross_prefix}gcc"
07dec06e
MR
1539 CC_DEPFLAGS='-MMD'
1540 AS_DEPFLAGS='-MMD'
6fec122a
MR
1541elif $cc -version 2>/dev/null | grep -q TMS470; then
1542 cc_type=tms470
1543 cc="$cc --gcc --abi=eabi -eo=.o -mc -me"
1544 CC_O='-fr=$(@D)'
1545 as_default="${cross_prefix}gcc"
1546 ld_default="${cross_prefix}gcc"
6fec122a
MR
1547 TMPO=$(basename $TMPC .c).o
1548 append TMPFILES $TMPO
1549 add_cflags -D__gnuc_va_list=va_list -D__USER_LABEL_PREFIX__=
07dec06e
MR
1550 CC_DEPFLAGS='-ppa -ppd=$(@:.o=.d)'
1551 AS_DEPFLAGS='-MMD'
6fec122a
MR
1552 filter_cflags=tms470_flags
1553 tms470_flags(){
1554 for flag; do
1555 case $flag in
1556 -march=*|-mcpu=*)
1557 case "${flag#*=}" in
1558 armv7-a|cortex-a*) echo -mv=7a8 ;;
1559 armv7-r|cortex-r*) echo -mv=7r4 ;;
1560 armv7-m|cortex-m*) echo -mv=7m3 ;;
1561 armv6*|arm11*) echo -mv=6 ;;
1562 armv5*e|arm[79]*e*|arm9[24]6*|arm96*|arm102[26])
1563 echo -mv=5e ;;
1564 armv4*|arm7*|arm9[24]*) echo -mv=4 ;;
1565 esac
1566 ;;
1567 -mfpu=neon) echo --float_support=vfpv3 --neon ;;
1568 -mfpu=vfp) echo --float_support=vfpv2 ;;
1569 -mfpu=softvfp) echo --float_support=vfplib ;;
1570 -Os) echo -O3 -mf=2 ;;
1571 -O[0-3]) echo $flag -mf=5 ;;
1572 -g) echo -g -mn ;;
1573 esac
1574 done
1575 }
629687f6
MR
1576fi
1577
1578test -n "$cc_type" && enable $cc_type || echolog "Unknown C compiler $cc"
1579
75bafbac 1580: ${as_default:=$cc}
50567afa 1581: ${dep_cc_default:=$cc}
684b28e0 1582: ${ld_default:=$cc}
50567afa 1583set_default as dep_cc ld
75800dce 1584
07dec06e
MR
1585test -n "$CC_DEPFLAGS" || CCDEP=$DEPEND_CMD
1586test -n "$AS_DEPFLAGS" || ASDEP=$DEPEND_CMD
1587
7f32f40c 1588add_cflags $extra_cflags
2f2e6c7c 1589add_asflags $extra_cflags
7f32f40c 1590
154d432c
MR
1591if test -n "$sysroot"; then
1592 case "$cc_type" in
1593 gcc)
467256f2 1594 add_cppflags --sysroot="$sysroot"
154d432c
MR
1595 add_ldflags --sysroot="$sysroot"
1596 ;;
6fec122a
MR
1597 tms470)
1598 add_cppflags -I"$sysinclude"
1599 add_ldflags --sysroot="$sysroot"
1600 ;;
154d432c
MR
1601 esac
1602fi
1603
d22c13a8
MR
1604if test "$cpu" = host; then
1605 enabled cross_compile && die "--cpu=host makes no sense when cross-compiling."
1606
1607 case "$cc_type" in
1608 gcc)
1609 check_native(){
1610 $cc $1=native -v -c -o $TMPO $TMPC >$TMPE 2>&1 || return
1611 awk "/$1=/{ match(\$0, /$1=(\\w+)/, a);print a[1];exit }" $TMPE
1612 }
1613 cpu=$(check_native -march || check_native -mcpu)
1614 ;;
1615 esac
1616
1617 test "${cpu:-host}" = host && die "--cpu=host not supported with compiler $cc"
1618fi
1619
df5cdc24
MR
1620# Add processor-specific flags
1621case $cpu in
1622 601|ppc601|PowerPC601)
1623 cpuflags="-mcpu=601"
1624 ;;
1625 603*|ppc603*|PowerPC603*)
1626 cpuflags="-mcpu=603"
1627 ;;
1628 604*|ppc604*|PowerPC604*)
1629 cpuflags="-mcpu=604"
1630 ;;
1631 G3|g3|75*|ppc75*|PowerPC75*)
1632 cpuflags="-mcpu=750 -mpowerpc-gfxopt"
1633 ;;
1634 G4|g4|745*|ppc745*|PowerPC745*)
1635 cpuflags="-mcpu=7450 -mpowerpc-gfxopt"
1636 ;;
1637 74*|ppc74*|PowerPC74*)
1638 cpuflags="-mcpu=7400 -mpowerpc-gfxopt"
1639 ;;
1640 G5|g5|970|ppc970|PowerPC970|power4*|Power4*)
1641 cpuflags="-mcpu=970 -mpowerpc-gfxopt -mpowerpc64"
1642 ;;
1643 Cell|CELL|cell)
1644 cpuflags="-mcpu=cell"
1645 enable ldbrx
1646 ;;
1647 # targets that do NOT support conditional mov (cmov)
1648 i[345]86|pentium|pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
1649 cpuflags="-march=$cpu"
1650 disable cmov
1651 ;;
1652 # targets that do support conditional mov (cmov)
1653 i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64|k8|opteron|athlon-fx|core2)
1654 cpuflags="-march=$cpu"
1655 enable cmov
1656 enable fast_cmov
1657 ;;
1658 # targets that do support conditional mov but on which it's slow
1659 pentium4|pentium4m|prescott|nocona)
1660 cpuflags="-march=$cpu"
1661 enable cmov
1662 disable fast_cmov
1663 ;;
1664 sparc64)
1665 cpuflags="-mcpu=v9"
1666 ;;
1667 arm11*|cortex*)
1668 cpuflags="-mcpu=$cpu"
1669 enable fast_unaligned
1670 ;;
1671 armv[67]*)
1672 cpuflags="-march=$cpu"
1673 enable fast_unaligned
1674 ;;
1675 armv*)
1676 cpuflags="-march=$cpu"
1677 ;;
1678 arm*)
1679 cpuflags="-mcpu=$cpu"
1680 ;;
1681 ev4|ev45|ev5|ev56|pca56|ev6|ev67)
1682 enabled ccc && cpuflags="-arch $cpu" || cpuflags="-mcpu=$cpu"
1683 ;;
1684 bf*)
1685 cpuflags="-mcpu=$cpu"
1686 ;;
1687 mips*|[45]k*|[237]4k*|m4k|r*000|loongson2[ef])
1688 cpuflags="-march=$cpu"
1689 ;;
1690 generic)
1691 ;;
1692 *)
1693 echo "WARNING: Unknown CPU \"$cpu\", ignored."
1694 ;;
1695esac
1696
1697add_cflags $cpuflags
1698add_asflags $cpuflags
1699
993f2d0f
MR
1700# compiler sanity check
1701check_exec <<EOF
1702int main(void){ return 0; }
1703EOF
1704if test "$?" != 0; then
1705 echo "$cc is unable to create an executable file."
1706 if test -z "$cross_prefix" && ! enabled cross_compile ; then
1707 echo "If $cc is a cross-compiler, use the --enable-cross-compile option."
1708 echo "Only do this if you know what cross compiling means."
1709 fi
1710 die "C compiler test failed."
1711fi
1712
38a9c529 1713add_cppflags -D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112
e9b9a2f8 1714check_cflags -std=c99
50a334e4 1715check_cc -D_FILE_OFFSET_BITS=64 <<EOF && add_cppflags -D_FILE_OFFSET_BITS=64
9d821fc2
DB
1716#include <stdlib.h>
1717EOF
50a334e4 1718check_cc -D_LARGEFILE_SOURCE <<EOF && add_cppflags -D_LARGEFILE_SOURCE
9d821fc2
DB
1719#include <stdlib.h>
1720EOF
e9b9a2f8 1721
b24dbcbd 1722case "$arch" in
b24dbcbd
RP
1723 alpha)
1724 arch="alpha"
1725 enable fast_64bit
c0a02a3e 1726 check_cflags -mieee
a15b0af8 1727 pic=$shared
b24dbcbd 1728 ;;
cfdb6148
MR
1729 arm|armv[4567]*l)
1730 arch="arm"
b24dbcbd 1731 ;;
f4870943
MR
1732 avr32)
1733 ;;
cfdb6148
MR
1734 bfin)
1735 arch="bfin"
1736 ;;
1737 ia64)
1738 arch="ia64"
b24dbcbd 1739 enable fast_64bit
a15b0af8 1740 pic=$shared
cfdb6148
MR
1741 ;;
1742 m68k)
1743 arch="m68k"
b24dbcbd 1744 ;;
de3a1240 1745 mips|mipsel|IP*)
b24dbcbd 1746 arch="mips"
a15b0af8 1747 pic=$shared
b24dbcbd 1748 ;;
de3a1240
DB
1749 mips64)
1750 arch="mips"
bae3abb0 1751 subarch="mips64"
de3a1240 1752 enable fast_64bit
a15b0af8 1753 pic=$shared
de3a1240 1754 ;;
61597a98 1755 parisc|hppa)
b24dbcbd 1756 arch="parisc"
a15b0af8 1757 pic=$shared
b24dbcbd 1758 ;;
61597a98 1759 parisc64|hppa64)
b24dbcbd
RP
1760 arch="parisc"
1761 enable fast_64bit
a15b0af8 1762 pic=$shared
b24dbcbd 1763 ;;
cfdb6148
MR
1764 "Power Macintosh"|ppc|powerpc)
1765 arch="ppc"
1766 enable fast_unaligned
1767 ;;
1768 ppc64)
1769 arch="ppc"
34d11b87 1770 subarch="ppc64"
cfdb6148
MR
1771 enable fast_64bit
1772 enable fast_unaligned
1773 ;;
b24dbcbd
RP
1774 s390|s390x)
1775 arch="s390"
1776 ;;
cfdb6148
MR
1777 sh4|sh)
1778 arch="sh4"
b24dbcbd 1779 ;;
cfdb6148
MR
1780 sparc)
1781 arch="sparc"
a15b0af8 1782 pic=$shared
cfdb6148
MR
1783 ;;
1784 sun4u|sparc64)
1785 arch="sparc"
1786 subarch="sparc64"
b24dbcbd 1787 enable fast_64bit
a15b0af8 1788 pic=$shared
b24dbcbd 1789 ;;
cfdb6148
MR
1790 i386|i486|i586|i686|i86pc|BePC)
1791 arch="x86"
1792 subarch="x86_32"
1793 enable fast_unaligned
1794 ;;
1795 x86_64|amd64)
1796 arch="x86"
1797 subarch="x86_32"
1798 enable cmov
1799 enable fast_cmov
1800 enable fast_unaligned
a15b0af8 1801 check_cc <<EOF && enable fast_64bit && subarch="x86_64" && pic=$shared
cfdb6148
MR
1802 int test[sizeof(char*) - 7];
1803EOF
b24dbcbd
RP
1804 ;;
1805 *)
1806 arch="unknown"
1807 ;;
1808esac
1809
62045d48 1810enable $arch $subarch
b24dbcbd 1811
7483e694 1812# OS specific
4f854758 1813case $target_os in
7483e694 1814 beos|haiku|zeta)
c9d19248 1815 prefix_default="$HOME/config"
7483e694 1816 # helps building libavcodec
50a334e4
MR
1817 add_cppflags -DPIC
1818 add_cflags -fomit-frame-pointer
7483e694 1819 # 3 gcc releases known for BeOS, each with ugly bugs
5e622c40 1820 gcc_version="$($cc -v 2>&1 | grep version | cut -d ' ' -f3-)"
7483e694
DB
1821 case "$gcc_version" in
1822 2.9-beos-991026*|2.9-beos-000224*) echo "R5/GG gcc"
1823 disable mmx
1824 ;;
1825 *20010315*) echo "BeBits gcc"
0f010b2f 1826 add_cflags -fno-expensive-optimizations
7483e694
DB
1827 ;;
1828 esac
7483e694
DB
1829 SHFLAGS=-nostart
1830 # enable BeOS things
1831 enable audio_beos
1832 # no need for libm, but the inet stuff
1833 # Check for BONE
1834 # XXX: actually should check for NOT net_server
78fe7631 1835 if echo $BEINCLUDES | grep -q 'headers/be/bone'; then
7483e694
DB
1836 network_extralibs="-lbind -lsocket"
1837 else
1838 enable beos_netserver
1839 network_extralibs="-lnet"
1840 fi ;;
1841 sunos)
1842 FFSERVERLDFLAGS=""
9987769a 1843 SHFLAGS='-shared -Wl,-h,$$(@F)'
7483e694 1844 network_extralibs="-lsocket -lnsl"
50a334e4 1845 add_cppflags -D__EXTENSIONS__
7483e694
DB
1846 ;;
1847 netbsd)
07a8eef6
MR
1848 oss_indev_extralibs="-lossaudio"
1849 oss_outdev_extralibs="-lossaudio"
7483e694
DB
1850 ;;
1851 openbsd)
89e053f8 1852 enable malloc_aligned
cd78208b 1853 enable pic
7483e694 1854 SHFLAGS='-shared'
07a8eef6
MR
1855 oss_indev_extralibs="-lossaudio"
1856 oss_outdev_extralibs="-lossaudio"
7483e694 1857 ;;
90b4f091 1858 freebsd|dragonfly)
89e053f8 1859 enable malloc_aligned
7483e694
DB
1860 ;;
1861 bsd/os)
1862 osextralibs="-lpoll -lgnugetopt"
1863 strip="strip -d"
1864 ;;
1865 darwin)
89e053f8 1866 enable malloc_aligned
0138c54e 1867 SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(SHLIBDIR)/$(SLIBNAME),-current_version,$(LIBVERSION),-compatibility_version,$(LIBMAJOR) -Wl,-read_only_relocs,suppress'
7483e694
DB
1868 strip="strip -x"
1869 FFLDFLAGS="-Wl,-dynamic,-search_paths_first"
1870 SLIBSUF=".dylib"
1871 SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME).$(LIBVERSION)$(SLIBSUF)'
1872 SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME).$(LIBMAJOR)$(SLIBSUF)'
1873 FFSERVERLDFLAGS=-Wl,-bind_at_load
304d586d 1874 objformat="macho"
1b0f6fb8 1875 enabled x86_64 && objformat="macho64"
2704bd1a
AS
1876 enabled shared ||
1877 { check_cflags -mdynamic-no-pic && add_asflags -mdynamic-no-pic; }
7483e694
DB
1878 ;;
1879 mingw32*)
9d3f4f50 1880 if test $target_os = "mingw32ce"; then
1aa71e25
MS
1881 disable network
1882 else
1883 target_os=mingw32
1884 fi
dcc01c06 1885 LIBTARGET=i386
1fc9fb8a 1886 if enabled x86_64; then
89e053f8 1887 enable malloc_aligned
dcc01c06 1888 LIBTARGET=x64
336cc1b0
MS
1889 elif enabled arm; then
1890 LIBTARGET=arm
dcc01c06 1891 fi
fbd971a4 1892 shlibdir_default="$bindir_default"
7483e694
DB
1893 disable ffserver
1894 SLIBPREF=""
1895 SLIBSUF=".dll"
7483e694
DB
1896 SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
1897 SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
06abe7f5 1898 SLIB_EXTRA_CMD='-lib.exe /machine:$(LIBTARGET) /def:$$(@:$(SLIBSUF)=.def) /out:$(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)'
4c25d159 1899 SLIB_INSTALL_EXTRA_CMD='-install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"; \
b9349ff4
MS
1900 install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)"; \
1901 install -d "$(LIBDIR)"; \
1902 install -m 644 $(SUBDIR)lib$(SLIBNAME:$(SLIBSUF)=.dll.a) "$(LIBDIR)/lib$(SLIBNAME:$(SLIBSUF)=.dll.a)"'
7483e694 1903 SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"'
4b51fb1c 1904 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 1905 objformat="win32"
bc574408 1906 enable dos_paths
1894e741 1907 check_cflags -fno-common
b1549d61 1908 if ! enabled x86_64; then
f7ad5aa2
RP
1909 check_cpp_condition _mingw.h "(__MINGW32_MAJOR_VERSION > 3) || (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" ||
1910 die "ERROR: MinGW runtime version must be >= 3.15."
8beb4178 1911 enabled_any avisynth vfwcap_indev &&
f7ad5aa2 1912 { check_cpp_condition w32api.h "(__W32API_MAJOR_VERSION > 3) || (__W32API_MAJOR_VERSION == 3 && __W32API_MINOR_VERSION >= 13)" ||
8beb4178 1913 die "ERROR: avisynth and vfwcap_indev require w32api version 3.13 or later."; }
f7ad5aa2 1914 fi
7483e694
DB
1915 ;;
1916 cygwin*)
4f854758 1917 target_os=cygwin
fbd971a4 1918 shlibdir_default="$bindir_default"
7483e694
DB
1919 SLIBPREF="cyg"
1920 SLIBSUF=".dll"
1921 SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
1922 SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
1923 SHFLAGS='-shared -Wl,--enable-auto-image-base'
304d586d 1924 objformat="win32"
bc574408 1925 enable dos_paths
1894e741 1926 check_cflags -fno-common
7483e694 1927 ;;
4f365f37 1928 *-dos|freedos|opendos)
fdf11906 1929 disable ffplay ffserver
4f365f37
MK
1930 disable $INDEV_LIST $OUTDEV_LIST
1931 network_extralibs="-lsocket"
ff1c015d 1932 objformat="coff"
bc574408 1933 enable dos_paths
4f365f37 1934 ;;
7483e694 1935 linux)
7483e694
DB
1936 enable dv1394
1937 ;;
1938 irix*)
4f854758 1939 target_os=irix
7483e694
DB
1940 ranlib="echo ignoring ranlib"
1941 ;;
d22e8442 1942 os/2*)
d22e8442
DY
1943 strip="lxlite"
1944 ln_s="cp -f"
d22e8442 1945 FFLDFLAGS="-Zomf -Zbin-files -Zargs-wild -Zmap"
71c61f62 1946 SHFLAGS='$(SUBDIR)$(NAME).def -Zdll -Zomf'
d22e8442 1947 FFSERVERLDFLAGS=""
287d3b13 1948 LIBSUF="_s.a"
d22e8442
DY
1949 SLIBPREF=""
1950 SLIBSUF=".dll"
1951 SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
1952 SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(shell echo $(NAME) | cut -c1-6)$(LIBMAJOR)$(SLIBSUF)'
71c61f62
MR
1953 SLIB_CREATE_DEF_CMD='echo LIBRARY $(SLIBNAME_WITH_MAJOR) INITINSTANCE TERMINSTANCE > $(SUBDIR)$(NAME).def; \
1954 echo PROTMODE >> $(SUBDIR)$(NAME).def; \
1955 echo CODE PRELOAD MOVEABLE DISCARDABLE >> $(SUBDIR)$(NAME).def; \
1956 echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $(SUBDIR)$(NAME).def; \
1957 echo EXPORTS >> $(SUBDIR)$(NAME).def; \
1958 emxexp -o $(OBJS) >> $(SUBDIR)$(NAME).def'
1959 SLIB_EXTRA_CMD='emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(NAME).def; \
1960 emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib $(SUBDIR)$(NAME).def;'
1961 SLIB_INSTALL_EXTRA_CMD='install -m 644 $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib "$(LIBDIR)"'
d22e8442 1962 SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.a "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.lib'
bc574408 1963 enable dos_paths
d22e8442 1964 ;;
83993c1c
AM
1965 gnu/kfreebsd)
1966 ;;
34e82167 1967 gnu)
34e82167 1968 ;;
d22e8442 1969
7483e694 1970 *)
4f924f9a 1971 die "Unknown OS '$target_os'."
7483e694
DB
1972 ;;
1973esac
1974
c9d19248
MR
1975set_default $PATHS_LIST
1976
c597172e 1977add_extralibs $osextralibs
de6d9b64 1978
28d8e661
DB
1979# Combine FFLDFLAGS and the LDFLAGS environment variable.
1980LDFLAGS="$FFLDFLAGS $LDFLAGS"
e89b8b0a 1981
320d060a 1982# we need to build at least one lib type
93b3c083 1983if ! enabled_any static shared; then
320d060a
DB
1984 cat <<EOF
1985At least one library type must be built.
1986Specify --enable-static to build the static libraries or --enable-shared to
1987build the shared libraries as well. To only build the shared libraries specify
1988--disable-static in addition to --enable-shared.
1989EOF
1990 exit 1;
1991fi
1992
abc4e572 1993disabled static && LIBNAME=""
2a320695 1994
a2234ceb
RP
1995if enabled_any libfaad libfaadbin ; then
1996 if check_header faad.h; then
295b8c70 1997 check_cc <<EOF
a2234ceb
RP
1998#include <faad.h>
1999#ifndef FAAD2_VERSION
2000ok faad1
2001#endif
db817cf3 2002int main(void) { return 0; }
a2234ceb
RP
2003EOF
2004 test $? = 0 && enable libfaad2
2005 else
ff3dac65 2006 die "FAAD test failed."
a2234ceb
RP
2007 fi
2008fi
2009
2010
2184c6f7 2011die_license_disabled() {
4c27207c 2012 enabled $1 || { enabled $2 && die "$2 is $1 and --enable-$1 is not specified."; }
2184c6f7
DB
2013}
2014
2015die_license_disabled gpl libfaad2
2016die_license_disabled gpl libx264
2017die_license_disabled gpl libxvid
2018die_license_disabled gpl postproc
2019die_license_disabled gpl x11grab
2020
2f7ae63b 2021die_license_disabled nonfree libfaac
b2e3c528 2022
0b175caa
DB
2023die_license_disabled version3 libopencore_amrnb
2024die_license_disabled version3 libopencore_amrwb
2025
9cad0e4e 2026enabled version3 && { enabled gpl && enable gplv3 || enable lgplv3; }
3fe142e2 2027
9eeed841 2028check_deps $ARCH_EXT_LIST
0f3cb305 2029
40617a6d 2030disabled optimizations || check_cflags -fomit-frame-pointer
cf9d24ad 2031
b4d96ba2
MR
2032check_cc <<EOF || die "Symbol mangling check failed."
2033int ff_extern;
2034EOF
2f05d9c1 2035sym=$($nm -P -g $TMPO | grep ff_extern)
b4d96ba2
MR
2036extern_prefix=${sym%%ff_extern*}
2037
f65883c8
MR
2038check_cc <<EOF && enable inline_asm
2039void foo(void) { __asm__ volatile ("" ::); }
2040EOF
61d251db 2041
df5e3978
MR
2042_restrict=
2043for restrict_keyword in restrict __restrict__ __restrict; do
2044 check_cc <<EOF && _restrict=$restrict_keyword && break
2045void foo(char * $restrict_keyword p);
2046EOF
2047done
2048
2049check_cc <<EOF && enable attribute_packed
2050struct { int x; } __attribute__((packed)) x;
2051EOF
2052
2053check_cc <<EOF || die "endian test failed"
2054unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
2055EOF
2056od -A n -t x1 $TMPO | grep -q '42 *49 *47 *45' && enable bigendian
2057
fa0912fe 2058if enabled arm; then
e45391bb 2059
fa0912fe
MR
2060 check_ld <<EOF && enable vfp_args
2061__asm__ (".eabi_attribute 28, 1");
2062int main(void) { return 0; }
2063EOF
2064
2065 # We have to check if pld is a nop and disable it.
2066 check_asm pld '"pld [r0]"'
2067
2068 enabled armv5te && check_asm armv5te '"qadd r0, r0, r0"'
2069 enabled armv6 && check_asm armv6 '"sadd16 r0, r0, r0"'
2070 enabled armv6t2 && check_asm armv6t2 '"movt r0, #0"'
2071 enabled armvfp && check_asm armvfp '"fadds s0, s0, s0"'
2072 enabled iwmmxt && check_asm iwmmxt '"wunpckelub wr6, wr4"'
2073 enabled neon && check_asm neon '"vadd.i16 q0, q0, q0"'
e45391bb 2074
fa0912fe 2075elif enabled mips; then
e45391bb 2076
fa0912fe
MR
2077 check_asm loongson '"dmult.g $1, $2, $3"'
2078 enabled mmi && check_asm mmi '"lq $2, 0($2)"'
e45391bb 2079
fa0912fe 2080elif enabled ppc; then
e45391bb 2081
fa0912fe
MR
2082 check_asm dcbzl '"dcbzl 0, 1"'
2083 check_asm ppc4xx '"maclhw r10, r11, r12"'
2084 check_asm xform_asm '"lwzx 0, %y0" :: "Z"(*(int*)0)'
2085
2086 # AltiVec flags: The FSF version of GCC differs from the Apple version
2087 if enabled altivec; then
2088 check_cflags -maltivec -mabi=altivec &&
2089 { check_header altivec.h && inc_altivec_h="#include <altivec.h>" ; } ||
2090 check_cflags -faltivec
2091
2092 # check if our compiler supports Motorola AltiVec C API
2093 check_cc <<EOF || disable altivec
2094$inc_altivec_h
2095int main(void) {
2096 vector signed int v1, v2, v3;
2097 v1 = vec_add(v2,v3);
2098 return 0;
2099}
2100EOF
2101
2102 # check if our compiler supports braces for vector declarations
2103 check_cc <<EOF || die "You need a compiler that supports {} in AltiVec vector declarations."
2104$inc_altivec_h
2105int main (void) { (vector int) {1}; return 0; }
2106EOF
2107 fi
e45391bb 2108
fa0912fe 2109elif enabled sparc; then
e45391bb 2110
fa0912fe
MR
2111 enabled vis && check_asm vis '"pdist %f0, %f0, %f0"' -mcpu=ultrasparc &&
2112 add_cflags -mcpu=ultrasparc -mtune=ultrasparc
e45391bb 2113
fa0912fe 2114elif enabled x86; then
e45391bb 2115
44965991
PI
2116 # check whether EBP is available on x86
2117 # As 'i' is stored on the stack, this program will crash
2118 # if the base pointer is used to access it because the
2119 # base pointer is cleared in the inline assembly code.
7dfef245 2120 check_exec_crash <<EOF && enable ebp_available
44965991 2121 volatile int i=0;
be449fca 2122 __asm__ volatile (
44965991
PI
2123 "xorl %%ebp, %%ebp"
2124 ::: "%ebp");
2125 return i;
44965991
PI
2126EOF
2127
2128 # check wether EBX is available on x86
940f335a 2129 check_asm ebx_available '"":::"%ebx"'
8e380710 2130
d3a4b4e0
DB
2131 # check whether more than 10 operands are supported
2132 check_cc <<EOF && enable ten_operands
2133int main(void) {
2134 int x=0;
2135 __asm__ volatile(
2136 ""
2137 :"+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x)
2138 );
2139 return 0;
2140}
2141EOF
2142
d7f0920b 2143 # check whether binutils is new enough to compile SSSE3/MMX2
940f335a 2144 enabled ssse3 && check_asm ssse3 '"pabsw %xmm0, %xmm0"'
5fd89ca0 2145 enabled mmx2 && check_asm mmx2 '"pmaxub %mm0, %mm1"'
6bd859d6
MR
2146
2147 check_asm bswap '"bswap %%eax" ::: "%eax"'
304d586d 2148
d52481b9 2149 YASMFLAGS="-f $objformat -DARCH_$(toupper $subarch)"
304d586d
LM
2150 enabled x86_64 && append YASMFLAGS "-m amd64"
2151 enabled_all x86_64 shared && append YASMFLAGS "-DPIC"
2152 case "$objformat" in
2153 elf) enabled debug && append YASMFLAGS "-g dwarf2" ;;
1b0f6fb8 2154 macho64) append YASMFLAGS "-DPIC -DPREFIX" ;;
304d586d
LM
2155 *) append YASMFLAGS "-DPREFIX" ;;
2156 esac
7595a5e4 2157 disabled yasm || { check_yasm "pabsw xmm0, xmm0" && enable yasm; }
e45391bb 2158
44965991
PI
2159fi
2160
a98bb16d
RP
2161if check_func dlopen; then
2162 ldl=
2163elif check_func dlopen -ldl; then
2164 ldl=-ldl
8bf5d58f
MN
2165fi
2166
75ecf149
DB
2167# Solaris has nanosleep in -lrt, OpenSolaris no longer needs that
2168check_func nanosleep || { check_func nanosleep -lrt && add_extralibs -lrt; }
2169
7483e694
DB
2170check_func fork
2171check_func gethrtime
2172check_func getrusage
094c09bb 2173check_func inet_aton $network_extralibs
abfc8d05 2174check_func isatty
7483e694
DB
2175check_func memalign
2176check_func mkstemp
1f91cdce 2177check_func posix_memalign
b507ebd1 2178check_func_headers io.h setmode
e4673692 2179check_func_headers lzo/lzo1x.h lzo1x_999_compress
2446d3d6 2180check_func_headers windows.h GetProcessTimes
7c5bfe7a 2181check_func_headers windows.h VirtualAlloc
6ffa87d3 2182
e16e49ac 2183check_header conio.h
a98bb16d
RP
2184check_header dlfcn.h
2185check_header malloc.h
bf6ce82d 2186check_header poll.h
b58412f1 2187check_header sys/mman.h
b091aa44 2188check_header sys/resource.h
bf6ce82d 2189check_header sys/select.h
a98bb16d 2190check_header termios.h
272081b0
CEH
2191check_header vdpau/vdpau.h
2192check_header vdpau/vdpau_x11.h
68178ca9 2193check_header X11/extensions/XvMClib.h
a98bb16d 2194
89e053f8
MR
2195if ! enabled_any memalign memalign_hack posix_memalign malloc_aligned &&
2196 enabled_any $need_memalign ; then
1f91cdce 2197 die "Error, no aligned memory allocator but SSE enabled, disable it or use --enable-memalign-hack."
a98bb16d 2198fi
e16e49ac 2199
a4fa192c 2200disabled zlib || check_lib zlib.h zlibVersion -lz || disable zlib
632948bd 2201disabled bzlib || check_lib2 bzlib.h BZ2_bzlibVersion -lbz2 || disable bzlib
57bd82d4
MR
2202
2203# check for some common methods of building with pthread support
2204# do this before the optional library checks as some of them require pthreads
2205if enabled pthreads; then
9e7fd101
MR
2206 if check_func pthread_create; then
2207 :
2208 elif check_func pthread_create -pthread; then
2209 add_cflags -pthread
afc9aee2 2210 add_extralibs -pthread
9e7fd101
MR
2211 elif check_func pthread_create -pthreads; then
2212 add_cflags -pthreads
afc9aee2 2213 add_extralibs -pthreads
8d94f606
GT
2214 elif check_func pthread_create -lpthreadGC2; then
2215 add_extralibs -lpthreadGC2
9e7fd101
MR
2216 elif ! check_lib pthread.h pthread_create -lpthread; then
2217 die "ERROR: can't find pthreads library"
2218 fi
57bd82d4
MR
2219fi
2220
8eee7025 2221for thread in $THREADS_LIST; do
e5f94c2b 2222 if enabled $thread; then
3ae3b721
RP
2223 test -n "$thread_type" &&
2224 die "ERROR: Only one thread type must be selected." ||
e5f94c2b 2225 thread_type="$thread"
e5f94c2b
RP
2226 fi
2227done
2228
fdf88598 2229check_lib math.h sin -lm
ff418735 2230check_lib va/va.h vaInitialize -lva
fdf88598 2231
ad420e25
MR
2232check_func llrint
2233check_func log2
2234check_func lrint
2235check_func lrintf
2236check_func round
2237check_func roundf
2238check_func truncf
f32adb22 2239
57bd82d4 2240# these are off by default, so fail if requested and not available
79fda097 2241enabled avisynth && require2 vfw32 "windows.h vfw.h" AVIFileInit -lvfw32
e3cc7d6f 2242enabled libdirac && add_cflags $(pkg-config --cflags dirac) &&
2513b2b4
DB
2243 require libdirac libdirac_decoder/dirac_parser.h dirac_decoder_init $(pkg-config --libs dirac) &&
2244 require libdirac libdirac_encoder/dirac_encoder.h dirac_encoder_init $(pkg-config --libs dirac)
79fda097
DB
2245enabled libfaac && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
2246enabled libfaad && require2 libfaad faad.h faacDecOpen -lfaad
7483e694 2247enabled libgsm && require libgsm gsm.h gsm_create -lgsm
2bfecf73 2248enabled libmp3lame && require libmp3lame lame/lame.h lame_init -lmp3lame -lm
7483e694 2249enabled libnut && require libnut libnut.h nut_demuxer_init -lnut
0b175caa
DB
2250enabled libopencore_amrnb && require libopencore_amrnb opencore-amrnb/interf_dec.h Decoder_Interface_init -lopencore-amrnb -lm
2251enabled libopencore_amrwb && require libopencore_amrwb opencore-amrwb/dec_if.h D_IF_init -lopencore-amrwb -lm
3d6fac8c 2252enabled libopenjpeg && require libopenjpeg openjpeg.h opj_version -lopenjpeg
36718e51
DB
2253enabled libschroedinger && add_cflags $(pkg-config --cflags schroedinger-1.0) &&
2254 require libschroedinger schroedinger/schro.h schro_init $(pkg-config --libs schroedinger-1.0)
ae14f311 2255enabled libspeex && require libspeex speex/speex.h speex_decoder_init -lspeex
7483e694
DB
2256enabled libtheora && require libtheora theora/theora.h theora_info_init -ltheora -logg
2257enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
2bfecf73 2258enabled libx264 && require libx264 x264.h x264_encoder_open -lx264 -lm &&
57f0ec6e
MR
2259 { check_cpp_condition x264.h "X264_BUILD >= 65" ||
2260 die "ERROR: libx264 version must be >= 0.65."; }
2bfecf73 2261enabled libxvid && require libxvid xvid.h xvid_global -lxvidcore
7483e694 2262enabled mlib && require mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
8ac17293 2263
0b4a1821
AS
2264# libdc1394 check
2265if enabled libdc1394; then
2266 { check_lib dc1394/dc1394.h dc1394_new -ldc1394 -lraw1394 &&
2267 enable libdc1394_2; } ||
2268 { check_lib libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394 &&
2269 enable libdc1394_1; } ||
2270 die "ERROR: No version of libdc1394 found "
2271fi
2272
497237c7
RP
2273disable sdl_too_old
2274disable sdl
6a1a892f 2275SDL_CONFIG="${cross_prefix}sdl-config"
2270b4b2 2276if "${SDL_CONFIG}" --version > /dev/null 2>&1; then
5e622c40 2277 sdl_cflags=$("${SDL_CONFIG}" --cflags)
225e21ef 2278 temp_cflags $sdl_cflags
5e622c40 2279 temp_extralibs $("${SDL_CONFIG}" --libs)
1ca5d97f 2280 if check_lib2 SDL.h SDL_Init; then
5e622c40 2281 _sdlversion=$("${SDL_CONFIG}" --version | sed 's/[^0-9]//g')
29f3b38a 2282 if test "$_sdlversion" -lt 121 ; then
497237c7 2283 enable sdl_too_old
dcd479c0 2284 else
497237c7 2285 enable sdl
225e21ef 2286 check_cc $sdl_cflags <<EOF && enable sdl_video_size
29f3b38a 2287#include <SDL.h>
d6773f56 2288int main(int argc, char **argv){
29f3b38a
MR
2289 const SDL_VideoInfo *vi = SDL_GetVideoInfo();
2290 int w = vi->current_w;
2291 return 0;
2292}
2293EOF
dcd479c0
MR
2294 fi
2295 fi
29f3b38a 2296 restore_flags
c3f6b472 2297fi
57bd82d4 2298
2270b4b2 2299texi2html -version > /dev/null 2>&1 && enable texi2html || disable texi2html
146ea952 2300
73b46a95 2301if enabled network; then
96000432 2302 check_type "sys/types.h sys/socket.h" socklen_t
73b46a95
RP
2303 # Prefer arpa/inet.h over winsock2
2304 if check_header arpa/inet.h ; then
2305 check_func closesocket
2306 elif check_header winsock2.h ; then
f4c13872
MS
2307 check_func_headers winsock2.h closesocket -lws2 && \
2308 network_extralibs="-lws2" || \
2309 { check_func_headers winsock2.h closesocket -lws2_32 && \
2310 network_extralibs="-lws2_32"; }
72be9e73 2311 check_type ws2tcpip.h socklen_t
28c9f069
MK
2312 else
2313 disable network
73b46a95
RP
2314 fi
2315fi
2316
b6f3d925 2317enabled_all network ipv6 && check_ld <<EOF || disable ipv6
7a91333f
HZ
2318#include <sys/types.h>
2319#include <sys/socket.h>
2320#include <netinet/in.h>
2321#include <netdb.h>
db817cf3 2322int main(void) {
7483e694
DB
2323 struct sockaddr_storage saddr;
2324 struct ipv6_mreq mreq6;
2325 getaddrinfo(0,0,0,0);
2326 getnameinfo(0,0,0,0,0,0,0);
2327 IN6_IS_ADDR_MULTICAST((const struct in6_addr *)0);
7a91333f
HZ
2328}
2329EOF
2330
06e31011
RP
2331check_header linux/videodev.h
2332check_header linux/videodev2.h
1b6e8b73 2333check_header sys/videoio.h
47f38850 2334
2446d3d6 2335check_func_headers "windows.h vfw.h" capCreateCaptureWindow -lvfw32
c2345207 2336
f8aa696f 2337# check for ioctl_meteor.h, ioctl_bt848.h and alternatives
1c915f83
RP
2338{ check_header dev/bktr/ioctl_meteor.h &&
2339 check_header dev/bktr/ioctl_bt848.h; } ||
2340{ check_header machine/ioctl_meteor.h &&
2341 check_header machine/ioctl_bt848.h; } ||
2342{ check_header dev/video/meteor/ioctl_meteor.h &&
2343 check_header dev/video/bktr/ioctl_bt848.h; } ||
2344check_header dev/ic/bt8xx.h
f8aa696f 2345
c7682de0
RP
2346check_header sys/soundcard.h
2347check_header soundcard.h
deb29777 2348
b6f3d925 2349enabled_any alsa_indev alsa_outdev && check_lib2 alsa/asoundlib.h snd_pcm_htimestamp -lasound
35fd8122 2350
0e57fe17 2351enabled jack_indev && check_lib2 jack/jack.h jack_client_open -ljack
80ff8a16 2352
56a059ac 2353enabled x11grab &&
f58f4ce1
GP
2354check_header X11/Xlib.h &&
2355check_header X11/extensions/XShm.h &&
2356check_func XOpenDisplay -lX11 &&
06eab4ba 2357check_func XShmCreateImage -lX11 -lXext
f58f4ce1 2358
40bcf4c7 2359enabled debug && add_cflags -g"$debuglevel"
57bd82d4
MR
2360
2361# add some useful compiler flags if supported
2362check_cflags -Wdeclaration-after-statement
dcd479c0
MR
2363check_cflags -Wall
2364check_cflags -Wno-switch
c07bd6a9
MN
2365check_cflags -Wdisabled-optimization
2366check_cflags -Wpointer-arith
2367check_cflags -Wredundant-decls
cc1fb623 2368check_cflags -Wno-pointer-sign
f4929996 2369check_cflags -Wcast-qual
9aceb3cf 2370check_cflags -Wwrite-strings
652a5bf6 2371check_cflags -Wtype-limits
764551c6 2372check_cflags -Wundef
5af4e0cc 2373enabled extra_warnings && check_cflags -Winline
cf9d24ad 2374
57bd82d4 2375# add some linker flags
5c0e9479 2376check_ldflags -Wl,--warn-common
8351d2ba
DB
2377check_ldflags -Wl,--as-needed
2378check_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 2379check_ldflags -Wl,-Bsymbolic
94a3401e 2380
bd2216e4
MR
2381if enabled small; then
2382 check_cflags -Os # not all compilers support -Os
8400d6b8
DB
2383 optimizations="small"
2384elif enabled optimizations; then
629687f6 2385 if enabled xlc; then
0f010b2f
DB
2386 add_cflags -O5
2387 add_ldflags -O5
df442a8d
MR
2388 elif enabled ccc; then
2389 add_cflags -fast
cf9d24ad 2390 else
0f010b2f 2391 add_cflags -O3
cf9d24ad 2392 fi
cddf3f45 2393fi
11fdbc44 2394check_cflags -fno-math-errno
b2eb2ff0 2395check_cflags -fno-signed-zeros
cddf3f45 2396
629687f6 2397if enabled icc; then
b1598b58
MR
2398 # Just warnings, no remarks
2399 check_cflags -w1
2400 # -wd: Disable following warnings
2401 # 144, 167, 556: -Wno-pointer-sign
2402 # 10006: ignoring unknown option -fno-signed-zeros
2403 # 10156: ignoring option '-W'; no argument required
2404 check_cflags -wd144,167,556,10006,10156
2405 # 11030: Warning unknown option --as-needed
2406 # 10156: ignoring option '-export'; no argument required
2407 check_ldflags -wd10156,11030
2408 # Allow to compile with optimizations
2409 check_ldflags -march=$cpu
be2cf98a
CEH
2410 # icc 11.0 and 11.1 work with ebp_available, but don't pass the test
2411 enable ebp_available
df442a8d
MR
2412elif enabled ccc; then
2413 # disable some annoying warnings
2414 add_cflags -msg_disable cvtu32to64
2415 add_cflags -msg_disable embedcomment
2416 add_cflags -msg_disable needconstext
2417 add_cflags -msg_disable nomainieee
2418 add_cflags -msg_disable ptrmismatch1
2419 add_cflags -msg_disable unreachcode
973859f5
MR
2420elif enabled gcc; then
2421 check_cflags -fno-tree-vectorize
504a64b9
CEH
2422fi
2423
a15b0af8 2424enabled pic && LIBOBJFLAGS='$(PIC)'
80581e98 2425
90be59ef 2426if enabled gprof; then
0f010b2f
DB
2427 add_cflags -p
2428 add_ldflags -p
1db54e20
DB
2429fi
2430
7f3c02fc 2431# Find out if the .align argument is a power of two or not.
9377b6ce 2432check_asm asmalign_pot '".align 3"'
4454dc1b 2433
7483e694
DB
2434enabled_any $DECODER_LIST && enable decoders
2435enabled_any $ENCODER_LIST && enable encoders
5666fd73 2436enabled_any $HWACCEL_LIST && enable hwaccels
7483e694
DB
2437enabled_any $BSF_LIST && enable bsfs
2438enabled_any $DEMUXER_LIST && enable demuxers
2439enabled_any $MUXER_LIST && enable muxers
f7679c54 2440enabled_any $FILTER_LIST && enable filters
63d72fda
DB
2441enabled_any $INDEV_LIST && enable indevs
2442enabled_any $OUTDEV_LIST && enable outdevs
7483e694
DB
2443enabled_any $PROTOCOL_LIST && enable protocols
2444
2445enabled_any $THREADS_LIST && enable threads
2446
2447check_deps $CONFIG_LIST \
b6bb00b0 2448 $CONFIG_EXTRA \
7483e694
DB
2449 $HAVE_LIST \
2450 $DECODER_LIST \
2451 $ENCODER_LIST \
5666fd73 2452 $HWACCEL_LIST \
7483e694
DB
2453 $PARSER_LIST \
2454 $BSF_LIST \
2455 $DEMUXER_LIST \
2456 $MUXER_LIST \
f7679c54 2457 $FILTER_LIST \
7483e694
DB
2458 $INDEV_LIST \
2459 $OUTDEV_LIST \
2460 $PROTOCOL_LIST \
f70f03f6 2461
3e89171a 2462echo "install prefix $prefix"
f36958f8
DB
2463echo "source path $source_path"
2464echo "C compiler $cc"
bfd5afd8 2465echo ".align is power-of-two $asmalign_pot"
f36958f8 2466echo "ARCH $arch ($cpu)"
ce8871c2
MR
2467if test "$build_suffix" != ""; then
2468 echo "build suffix $build_suffix"
eb94aca9 2469fi
ac63af34
DB
2470if test "$extra_version" != ""; then
2471 echo "version string suffix $extra_version"
2472fi
0db2ce77 2473echo "big-endian ${bigendian-no}"
e90f5b5a 2474echo "runtime cpu detection ${runtime_cpudetect-no}"
5b6c2cbd 2475if enabled x86; then
af44e8e4 2476 echo "yasm ${yasm-no}"
0db2ce77 2477 echo "MMX enabled ${mmx-no}"
30e98e62 2478 echo "MMX2 enabled ${mmx2-no}"
3bf96eec 2479 echo "3DNow! enabled ${amd3dnow-no}"
a1ef9f08 2480 echo "3DNow! extended enabled ${amd3dnowext-no}"
1bb04d5a 2481 echo "SSE enabled ${sse-no}"
30e98e62 2482 echo "SSSE3 enabled ${ssse3-no}"
0db2ce77
MR
2483 echo "CMOV enabled ${cmov-no}"
2484 echo "CMOV is fast ${fast_cmov-no}"
971cc990
MN
2485 echo "EBX available ${ebx_available-no}"
2486 echo "EBP available ${ebp_available-no}"
d3a4b4e0 2487 echo "10 operands supported ${ten_operands-no}"
e41e8342 2488fi
5b6c2cbd 2489if enabled arm; then
0db2ce77
MR
2490 echo "ARMv5TE enabled ${armv5te-no}"
2491 echo "ARMv6 enabled ${armv6-no}"
ab5cb084 2492 echo "ARMv6T2 enabled ${armv6t2-no}"
f55b299a 2493 echo "ARM VFP enabled ${armvfp-no}"
0db2ce77 2494 echo "IWMMXT enabled ${iwmmxt-no}"
6b18d278 2495 echo "NEON enabled ${neon-no}"
eba9ae3c 2496fi
5b6c2cbd 2497if enabled mips; then
0db2ce77 2498 echo "MMI enabled ${mmi-no}"
e41e8342 2499fi
5b6c2cbd 2500if enabled ppc; then
0db2ce77 2501 echo "AltiVec enabled ${altivec-no}"
30e98e62 2502 echo "PPC 4xx optimizations ${ppc4xx-no}"
0db2ce77 2503 echo "dcbzl available ${dcbzl-no}"
30e98e62
DB
2504 echo "performance report ${powerpc_perf-no}"
2505fi
2506if enabled sparc; then
2507 echo "VIS enabled ${vis-no}"
e41e8342 2508fi
0db2ce77
MR
2509echo "gprof enabled ${gprof-no}"
2510echo "debug symbols ${debug-no}"
87a0fb62 2511echo "strip symbols ${stripping-no}"
8400d6b8 2512echo "optimizations ${optimizations-no}"
0db2ce77
MR
2513echo "static ${static-no}"
2514echo "shared ${shared-no}"
4a24ab64 2515echo "postprocessing support ${postproc-no}"
f7679c54 2516echo "new filter support ${avfilter-no}"
81124ba0 2517echo "filters using lavformat ${avfilter_lavf-no}"
0db2ce77 2518echo "network support ${network-no}"
90be59ef 2519if enabled network; then
0db2ce77 2520 echo "IPv6 support ${ipv6-no}"
bfd5afd8 2521fi
0db2ce77
MR
2522echo "threading support ${thread_type-no}"
2523echo "SDL support ${sdl-no}"
90be59ef 2524if enabled sdl_too_old; then
bfd5afd8
DB
2525 echo "-> Your SDL version is too old - please upgrade to have FFplay/SDL support."
2526fi
0db2ce77
MR
2527echo "Sun medialib support ${mlib-no}"
2528echo "AVISynth enabled ${avisynth-no}"
f7b8bffe 2529echo "libdc1394 support ${libdc1394-no}"
690bfceb 2530echo "libdirac enabled ${libdirac-no}"
0db2ce77
MR
2531echo "libfaac enabled ${libfaac-no}"
2532echo "libfaad enabled ${libfaad-no}"
7e0871a7 2533echo "libfaad dlopened ${libfaadbin-no}"
0db2ce77
MR
2534echo "libgsm enabled ${libgsm-no}"
2535echo "libmp3lame enabled ${libmp3lame-no}"
2536echo "libnut enabled ${libnut-no}"
0b175caa
DB
2537echo "libopencore-amrnb support ${libopencore_amrnb-no}"
2538echo "libopencore-amrwb support ${libopencore_amrwb-no}"
9a77d59a 2539echo "libopenjpeg enabled ${libopenjpeg-no}"
f7cd9eed 2540echo "libschroedinger enabled ${libschroedinger-no}"
ae14f311 2541echo "libspeex enabled ${libspeex-no}"
0db2ce77
MR
2542echo "libtheora enabled ${libtheora-no}"
2543echo "libvorbis enabled ${libvorbis-no}"
d6bd62db
DB
2544echo "libx264 enabled ${libx264-no}"
2545echo "libxvid enabled ${libxvid-no}"
0db2ce77 2546echo "zlib enabled ${zlib-no}"
f402916e 2547echo "bzlib enabled ${bzlib-no}"
2c62e737 2548echo
de6d9b64 2549
5666fd73 2550for type in decoder encoder hwaccel parser demuxer muxer protocol filter bsf indev outdev; do
8138b9db 2551 echo "Enabled ${type}s:"
f65c9da1 2552 eval list=\$$(toupper $type)_LIST
8138b9db 2553 for part in $list; do
f65c9da1
MR
2554 enabled $part && echo ${part%_*}
2555 done | sort | pr -3 -t
2556 echo
8138b9db
RP
2557done
2558
ba7a7039 2559license="LGPL version 2.1 or later"
ba321adb 2560if enabled nonfree; then
ba7a7039 2561 license="nonfree and unredistributable"
9cad0e4e
DB
2562elif enabled gplv3; then
2563 license="GPL version 3 or later"
2564elif enabled lgplv3; then
2565 license="LGPL version 3 or later"
ba321adb 2566elif enabled gpl; then
ba7a7039 2567 license="GPL version 2 or later"
ba321adb
JK
2568fi
2569
2570echo "License: $license"
ca5323af 2571
cf1392e9
DB
2572echo "Creating config.mak and config.h..."
2573
29799f8b
DB
2574echo "# Automatically generated by configure - do not modify!" > config.mak
2575echo "/* Automatically generated by configure - do not modify! */" > $TMPH
9c05103f
DB
2576echo "#ifndef FFMPEG_CONFIG_H" >> $TMPH
2577echo "#define FFMPEG_CONFIG_H" >> $TMPH
b04251c5 2578echo "#define FFMPEG_CONFIGURATION \"$(c_escape $FFMPEG_CONFIGURATION)\"" >> $TMPH
14a8acf1 2579echo "#define FFMPEG_DATADIR \"$(eval c_escape $datadir)\"" >> $TMPH
de6d9b64 2580
8c6d2da5
MR
2581echo "ifndef FFMPEG_CONFIG_MAK" >> config.mak
2582echo "FFMPEG_CONFIG_MAK=1" >> config.mak
2583
d921f03f 2584echo "FFMPEG_CONFIGURATION=$FFMPEG_CONFIGURATION" >> config.mak
c9d19248 2585echo "prefix=$prefix" >> config.mak
22a324da
DB
2586echo "LIBDIR=\$(DESTDIR)$libdir" >> config.mak
2587echo "SHLIBDIR=\$(DESTDIR)$shlibdir" >> config.mak
2588echo "INCDIR=\$(DESTDIR)$incdir" >> config.mak
2589echo "BINDIR=\$(DESTDIR)$bindir" >> config.mak
14a8acf1 2590echo "DATADIR=\$(DESTDIR)$datadir" >> config.mak
22a324da 2591echo "MANDIR=\$(DESTDIR)$mandir" >> config.mak
0a7ee3ef
DB
2592echo "SRC_PATH=\"$source_path\"" >> config.mak
2593echo "SRC_PATH_BARE=$source_path" >> config.mak
2594echo "BUILD_ROOT=\"$PWD\"" >> config.mak
980fc7b8 2595echo "CC=$cc" >> config.mak
313c46a6 2596echo "AS=$as" >> config.mak
684b28e0 2597echo "LD=$ld" >> config.mak
50567afa 2598echo "DEPCC=$dep_cc" >> config.mak
304d586d 2599echo "YASM=$yasmexe" >> config.mak
980fc7b8 2600echo "AR=$ar" >> config.mak
be7109c1 2601echo "RANLIB=$ranlib" >> config.mak
20369773 2602echo "LN_S=$ln_s" >> config.mak
87a0fb62 2603enabled stripping &&
3ae3b721 2604 echo "STRIP=$strip" >> config.mak ||
f25fc9b1 2605 echo "STRIP=echo ignoring strip" >> config.mak
75388c74 2606
ce40e347 2607echo "CPPFLAGS=$CPPFLAGS" >> config.mak
3198f618 2608echo "CFLAGS=$CFLAGS" >> config.mak
2f2e6c7c 2609echo "ASFLAGS=$ASFLAGS" >> config.mak
7e6c86e6 2610echo "CC_O=$CC_O" >> config.mak
0f3cb305 2611echo "LDFLAGS=$LDFLAGS" >> config.mak
c536cb09 2612echo "FFSERVERLDFLAGS=$FFSERVERLDFLAGS" >> config.mak
e1707f52 2613echo "SHFLAGS=$SHFLAGS" >> config.mak
304d586d 2614echo "YASMFLAGS=$YASMFLAGS" >> config.mak
80581e98 2615echo "LIBOBJFLAGS=$LIBOBJFLAGS" >> config.mak
ac0bed54 2616echo "PIC=-fPIC -DPIC" >> config.mak
ce8871c2 2617echo "BUILDSUF=$build_suffix" >> config.mak
c5f14466 2618echo "FULLNAME=$FULLNAME" >> config.mak
f3ec2d46 2619echo "LIBPREF=$LIBPREF" >> config.mak
c5f14466 2620echo "LIBSUF=$LIBSUF" >> config.mak
24743a76 2621echo "LIBNAME=$LIBNAME" >> config.mak
f3ec2d46 2622echo "SLIBPREF=$SLIBPREF" >> config.mak
c5f14466
RP
2623echo "SLIBSUF=$SLIBSUF" >> config.mak
2624echo "EXESUF=$EXESUF" >> config.mak
ac63af34 2625echo "EXTRA_VERSION=$extra_version" >> config.mak
d8059267 2626echo "DEPFLAGS=$DEPFLAGS" >> config.mak
07dec06e
MR
2627echo "CCDEP=$CCDEP" >> config.mak
2628echo "ASDEP=$ASDEP" >> config.mak
2629echo "CC_DEPFLAGS=$CC_DEPFLAGS" >> config.mak
2630echo "AS_DEPFLAGS=$AS_DEPFLAGS" >> config.mak
9da6609f
MR
2631echo "HOSTCC=$host_cc" >> config.mak
2632echo "HOSTCFLAGS=$host_cflags" >> config.mak
82bb3329 2633echo "HOSTEXESUF=$HOSTEXESUF" >> config.mak
9da6609f
MR
2634echo "HOSTLDFLAGS=$host_ldflags" >> config.mak
2635echo "HOSTLIBS=$host_libs" >> config.mak
a7ada2ba
MR
2636echo "TARGET_EXEC=$target_exec" >> config.mak
2637echo "TARGET_PATH=$target_path" >> config.mak
4dc62701 2638
90be59ef 2639if enabled sdl; then
5e622c40
DB
2640 echo "SDL_LIBS=$("${SDL_CONFIG}" --libs)" >> config.mak
2641 echo "SDL_CFLAGS=$("${SDL_CONFIG}" --cflags)" >> config.mak
a86b921c 2642fi
90be59ef 2643if enabled texi2html; then
7483e694 2644 echo "BUILD_DOC=yes" >> config.mak
146ea952 2645fi
5a872801 2646
719c8e00
MR
2647get_version(){
2648 name=$1
2649 file=$source_path/$2
147e7692
MR
2650 eval $(grep "#define ${name}_VERSION_M" "$file" | awk '{ print $2"="$3 }')
2651 eval ${name}_VERSION=\$${name}_VERSION_MAJOR.\$${name}_VERSION_MINOR.\$${name}_VERSION_MICRO
0e32c8c6
MR
2652 lcname=$(tolower $name)
2653 eval echo "${lcname}_VERSION=\$${name}_VERSION" >> config.mak
2654 eval echo "${lcname}_VERSION_MAJOR=\$${name}_VERSION_MAJOR" >> config.mak
719c8e00
MR
2655}
2656
147e7692
MR
2657get_version LIBSWSCALE libswscale/swscale.h
2658get_version LIBPOSTPROC libpostproc/postprocess.h
2659get_version LIBAVCODEC libavcodec/avcodec.h
2660get_version LIBAVDEVICE libavdevice/avdevice.h
2661get_version LIBAVFORMAT libavformat/avformat.h
2662get_version LIBAVUTIL libavutil/avutil.h
a6601d69 2663get_version LIBAVFILTER libavfilter/avfilter.h
5a872801 2664
5af4e0cc 2665if enabled shared; then
dcc01c06 2666 echo "LIBTARGET=${LIBTARGET}" >> config.mak
7483e694
DB
2667 echo "SLIBNAME=${SLIBNAME}" >> config.mak
2668 echo "SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}" >> config.mak
2669 echo "SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}" >> config.mak
d22e8442 2670 echo "SLIB_CREATE_DEF_CMD=${SLIB_CREATE_DEF_CMD}" >> config.mak
7483e694
DB
2671 echo "SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}" >> config.mak
2672 echo "SLIB_INSTALL_EXTRA_CMD=${SLIB_INSTALL_EXTRA_CMD}" >> config.mak
2673 echo "SLIB_UNINSTALL_EXTRA_CMD=${SLIB_UNINSTALL_EXTRA_CMD}" >> config.mak
0319c531 2674fi
d7e27559 2675echo "LIB_INSTALL_EXTRA_CMD=${LIB_INSTALL_EXTRA_CMD}" >> config.mak
ef0bc4c9 2676echo "EXTRALIBS=$extralibs" >> config.mak
d2845d68 2677
7b5e8a27
DB
2678echo "ARCH=$arch" >> config.mak
2679
3d907e22
MR
2680print_config ARCH_ $TMPH config.mak $ARCH_LIST
2681print_config HAVE_ $TMPH config.mak $HAVE_LIST
7483e694 2682print_config CONFIG_ $TMPH config.mak $CONFIG_LIST \
b6bb00b0 2683 $CONFIG_EXTRA \
7483e694
DB
2684 $DECODER_LIST \
2685 $ENCODER_LIST \
5666fd73 2686 $HWACCEL_LIST \
7483e694
DB
2687 $PARSER_LIST \
2688 $BSF_LIST \
2689 $DEMUXER_LIST \
2690 $MUXER_LIST \
f7679c54 2691 $FILTER_LIST \
7483e694
DB
2692 $PROTOCOL_LIST \
2693 $INDEV_LIST \
2694 $OUTDEV_LIST \
8ac17293 2695
c13e1abd
FH
2696echo "#define restrict $_restrict" >> $TMPH
2697
abbe30ad 2698if enabled small || disabled optimizations; then
7483e694 2699 echo "#define av_always_inline" >> $TMPH
bb801c97
MN
2700fi
2701
0f3cb305 2702
8156056e 2703# Apparently it's not possible to portably echo a backslash.
3ae3b721 2704enabled asmalign_pot &&
7483e694 2705 printf '#define ASMALIGN(ZEROBITS) ".align " #ZEROBITS "\\n\\t"\n' >> $TMPH ||
295b8c70 2706 printf '#define ASMALIGN(ZEROBITS) ".align 1 << " #ZEROBITS "\\n\\t"\n' >> $TMPH
4454dc1b 2707
b4d96ba2 2708echo "#define EXTERN_PREFIX \"${extern_prefix}\"" >> $TMPH
bc634f6f 2709
9c05103f 2710echo "#endif /* FFMPEG_CONFIG_H */" >> $TMPH
8c6d2da5 2711echo "endif # FFMPEG_CONFIG_MAK" >> config.mak
9c05103f 2712
b7860763 2713# Do not overwrite an unchanged config.h to avoid superfluous rebuilds.
3ae3b721
RP
2714cmp -s $TMPH config.h &&
2715 echo "config.h is unchanged" ||
2716 mv -f $TMPH config.h
3d204385 2717
165af439 2718# build tree in object directory if source path is different from current one
90be59ef 2719if enabled source_path_used; then
165af439 2720 DIRS="\
7483e694
DB
2721 doc \
2722 libavcodec \
2723 libavcodec/alpha \
a2fc0f6a 2724 libavcodec/arm \
7483e694 2725 libavcodec/bfin \
7483e694
DB
2726 libavcodec/mlib \
2727 libavcodec/ppc \
2728 libavcodec/sh4 \
2729 libavcodec/sparc \
a6493a8f 2730 libavcodec/x86 \
52a9cf34 2731 libavdevice \
f7679c54 2732 libavfilter \
7483e694
DB
2733 libavformat \
2734 libavutil \
2735 libpostproc \
2736 libswscale \
b2cfd7e3
RP
2737 libswscale/bfin \
2738 libswscale/mlib \
2739 libswscale/ppc \
2740 libswscale/sparc \
2741 libswscale/x86 \
7483e694
DB
2742 tests \
2743 tools \
7483e694 2744 "
165af439 2745 FILES="\
7483e694
DB
2746 Makefile \
2747 common.mak \
71c61f62 2748 subdir.mak \
7483e694
DB
2749 doc/texi2pod.pl \
2750 libavcodec/Makefile \
52a9cf34 2751 libavdevice/Makefile \
f7679c54 2752 libavfilter/Makefile \
7483e694
DB
2753 libavformat/Makefile \
2754 libavutil/Makefile \
2755 libpostproc/Makefile \
2756 libswscale/Makefile \
2757 "
165af439 2758 for dir in $DIRS ; do
7483e694 2759 mkdir -p $dir
165af439
MR
2760 done
2761 for f in $FILES ; do
20369773 2762 $ln_s "$source_path/$f" $f
165af439
MR
2763 done
2764fi
def4272a 2765
def4272a 2766
d0674868 2767# build pkg-config files
def4272a 2768
d0674868
DB
2769pkgconfig_generate(){
2770name=$1
b0dfd108 2771shortname=${name#lib}${build_suffix}
d0674868
DB
2772comment=$2
2773version=$3
2774libs=$4
2775requires=$5
25cd5cb3 2776cat <<EOF > $name/$name.pc
3e89171a 2777prefix=$prefix
a94e666c 2778exec_prefix=\${prefix}
f2b7382c 2779libdir=$libdir
7622778e 2780includedir=$incdir
def4272a 2781
d0674868
DB
2782Name: $name
2783Description: $comment
2784Version: $version
5dcfe9f8
AH
2785Requires: $(disabled shared && echo $requires)
2786Requires.private: $(enabled shared && echo $requires)
def4272a 2787Conflicts:
12701f6e
AH
2788Libs: -L\${libdir} -l${shortname} $(disabled shared && echo $libs)
2789Libs.private: $(enabled shared && echo $libs)
76a448ed 2790Cflags: -I\${includedir}
def4272a 2791EOF
25cd5cb3 2792cat <<EOF > $name/$name-uninstalled.pc
def4272a
AJ
2793prefix=
2794exec_prefix=
46d1ff83 2795libdir=\${pcfiledir}
1d44d365 2796includedir=${source_path}
def4272a 2797
d0674868
DB
2798Name: $name
2799Description: $comment
2800Version: $version
2801Requires: $requires
def4272a 2802Conflicts:
12701f6e 2803Libs: \${libdir}/${LIBPREF}${shortname}${LIBSUF} $libs
def4272a
AJ
2804Cflags: -I\${includedir}
2805EOF
d0674868 2806}
def4272a 2807
e426941d 2808pkgconfig_generate libavutil "FFmpeg utility library" "$LIBAVUTIL_VERSION"
46983309
RT
2809pkgconfig_generate libavcodec "FFmpeg codec library" "$LIBAVCODEC_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION"
2810pkgconfig_generate libavformat "FFmpeg container format library" "$LIBAVFORMAT_VERSION" "$extralibs" "libavcodec = $LIBAVCODEC_VERSION"
2811pkgconfig_generate libavdevice "FFmpeg device handling library" "$LIBAVDEVICE_VERSION" "$extralibs" "libavformat = $LIBAVFORMAT_VERSION"
3ed1a2ee 2812enabled avfilter &&
46983309 2813 pkgconfig_generate libavfilter "FFmpeg video filtering library" "$LIBAVFILTER_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION"
3ed1a2ee 2814enabled postproc &&
e426941d 2815 pkgconfig_generate libpostproc "FFmpeg post processing library" "$LIBPOSTPROC_VERSION"
5add54b4 2816pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "" "libavutil = $LIBAVUTIL_VERSION"