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