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