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