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