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