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