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