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