]> git.sesse.net Git - ffmpeg/blob - configure
fix chroma alpha in the drawtext filter
[ffmpeg] / configure
1 #!/bin/sh
2 #
3 # FFmpeg configure script
4 #
5 # Copyright (c) 2000-2002 Fabrice Bellard
6 # Copyright (c) 2005-2008 Diego Biurrun
7 # Copyright (c) 2005-2008 Mans Rullgard
8 #
9
10 # Prevent locale nonsense from breaking basic text processing.
11 LC_ALL=C
12 export LC_ALL
13
14 # make sure we are running under a compatible shell
15 # try to make this part work with most shells
16
17 try_exec(){
18     echo "Trying shell $1"
19     type "$1" > /dev/null 2>&1 && exec "$@"
20 }
21
22 unset foo
23 (: ${foo%%bar}) 2> /dev/null
24 E1="$?"
25
26 (: ${foo?}) 2> /dev/null
27 E2="$?"
28
29 if test "$E1" != 0 || test "$E2" = 0; then
30     echo "Broken shell detected.  Trying alternatives."
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" "$@"
43     fi
44     echo "No compatible shell script interpreter found."
45     echo "This configure script requires a POSIX-compatible shell"
46     echo "such as bash or ksh."
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."
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
54     exit 1
55 fi
56
57 show_help(){
58 cat <<EOF
59 Usage: configure [options]
60 Options: [defaults in brackets after descriptions]
61
62 Standard options:
63   --help                   print this message
64   --logfile=FILE           log tests and output to FILE [config.log]
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
74 Configuration 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-ffprobe        disable ffprobe build
86   --disable-ffserver       disable ffserver build
87   --disable-avdevice       disable libavdevice build
88   --disable-avcodec        disable libavcodec build
89   --disable-avformat       disable libavformat build
90   --disable-swscale        disable libswscale build
91   --enable-postproc        enable GPLed postprocessing support [no]
92   --disable-avfilter       disable video filter support [no]
93   --disable-pthreads       disable pthreads [auto]
94   --enable-w32threads      use Win32 threads [no]
95   --enable-x11grab         enable X11 grabbing [no]
96   --disable-network        disable network support [no]
97   --disable-mpegaudio-hp   faster (but less accurate) MPEG audio decoding [no]
98   --enable-gray            enable full grayscale support (slower color)
99   --disable-swscale-alpha  disable alpha channel support in swscale
100   --disable-fastdiv        disable table-based division
101   --enable-small           optimize for size instead of speed
102   --disable-aandct         disable AAN DCT code
103   --disable-dct            disable DCT code
104   --disable-fft            disable FFT code
105   --disable-golomb         disable Golomb code
106   --disable-huffman        disable Huffman code
107   --disable-lpc            disable LPC code
108   --disable-mdct           disable MDCT code
109   --disable-rdft           disable RDFT code
110   --disable-vaapi          disable VAAPI code
111   --disable-vdpau          disable VDPAU code
112   --disable-dxva2          disable DXVA2 code
113   --enable-runtime-cpudetect detect cpu capabilities at runtime (bigger binary)
114   --enable-hardcoded-tables use hardcoded tables instead of runtime generation
115   --enable-memalign-hack   emulate memalign, interferes with memory debuggers
116   --disable-everything     disable all components listed below
117   --disable-encoder=NAME   disable encoder NAME
118   --enable-encoder=NAME    enable encoder NAME
119   --disable-encoders       disable all encoders
120   --disable-decoder=NAME   disable decoder NAME
121   --enable-decoder=NAME    enable decoder NAME
122   --disable-decoders       disable all decoders
123   --disable-hwaccel=NAME   disable hwaccel NAME
124   --enable-hwaccel=NAME    enable hwaccel NAME
125   --disable-hwaccels       disable all hwaccels
126   --disable-muxer=NAME     disable muxer NAME
127   --enable-muxer=NAME      enable muxer NAME
128   --disable-muxers         disable all muxers
129   --disable-demuxer=NAME   disable demuxer NAME
130   --enable-demuxer=NAME    enable demuxer NAME
131   --disable-demuxers       disable all demuxers
132   --enable-parser=NAME     enable parser NAME
133   --disable-parser=NAME    disable parser NAME
134   --disable-parsers        disable all parsers
135   --enable-bsf=NAME        enable bitstream filter NAME
136   --disable-bsf=NAME       disable bitstream filter NAME
137   --disable-bsfs           disable all bitstream filters
138   --enable-protocol=NAME   enable protocol NAME
139   --disable-protocol=NAME  disable protocol NAME
140   --disable-protocols      disable all protocols
141   --disable-indev=NAME     disable input device NAME
142   --disable-outdev=NAME    disable output device NAME
143   --disable-indevs         disable input devices
144   --disable-outdevs        disable output devices
145   --disable-devices        disable all devices
146   --enable-filter=NAME     enable filter NAME
147   --disable-filter=NAME    disable filter NAME
148   --disable-filters        disable all filters
149   --list-decoders          show all available decoders
150   --list-encoders          show all available encoders
151   --list-hwaccels          show all available hardware accelerators
152   --list-muxers            show all available muxers
153   --list-demuxers          show all available demuxers
154   --list-parsers           show all available parsers
155   --list-protocols         show all available protocols
156   --list-bsfs              show all available bitstream filters
157   --list-indevs            show all available input devices
158   --list-outdevs           show all available output devices
159   --list-filters           show all available filters
160
161 External library support:
162   --enable-avisynth        enable reading of AVISynth script files [no]
163   --enable-bzlib           enable bzlib [autodetect]
164   --enable-frei0r          enable frei0r video filtering
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-libopencv       enable video filtering via libopencv [no]
168   --enable-libdc1394       enable IIDC-1394 grabbing using libdc1394
169                            and libraw1394 [no]
170   --enable-libdirac        enable Dirac support via libdirac [no]
171   --enable-libfaac         enable FAAC support via libfaac [no]
172   --enable-libfreetype     enable libfreetype [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-librtmp         enable RTMP[E] support via librtmp [no]
179   --enable-libschroedinger enable Dirac support via libschroedinger [no]
180   --enable-libspeex        enable Speex decoding via libspeex [no]
181   --enable-libtheora       enable Theora encoding via libtheora [no]
182   --enable-libvorbis       enable Vorbis encoding via libvorbis,
183                            native implementation exists [no]
184   --enable-libvpx          enable VP8 support via libvpx [no]
185   --enable-libx264         enable H.264 encoding via x264 [no]
186   --enable-libxavs         enable AVS encoding via xavs [no]
187   --enable-libxvid         enable Xvid encoding via xvidcore,
188                            native MPEG-4/Xvid encoder exists [no]
189   --enable-mlib            enable Sun medialib [no]
190   --enable-zlib            enable zlib [autodetect]
191
192 Advanced options (experts only):
193   --source-path=PATH       path to source code [$source_path]
194   --cross-prefix=PREFIX    use PREFIX for compilation tools [$cross_prefix]
195   --enable-cross-compile   assume a cross-compiler is used
196   --sysroot=PATH           root of cross-build tree
197   --sysinclude=PATH        location of cross-build system headers
198   --target-os=OS           compiler targets OS [$target_os]
199   --target-exec=CMD        command to run executables on target
200   --target-path=DIR        path to view of build directory on target
201   --nm=NM                  use nm tool
202   --ar=AR                  use archive tool AR [$ar_default]
203   --as=AS                  use assembler AS [$as_default]
204   --cc=CC                  use C compiler CC [$cc_default]
205   --ld=LD                  use linker LD
206   --host-cc=HOSTCC         use host C compiler HOSTCC
207   --host-cflags=HCFLAGS    use HCFLAGS when compiling for host
208   --host-ldflags=HLDFLAGS  use HLDFLAGS when linking for host
209   --host-libs=HLIBS        use libs HLIBS when linking for host
210   --extra-cflags=ECFLAGS   add ECFLAGS to CFLAGS [$CFLAGS]
211   --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]
212   --extra-libs=ELIBS       add ELIBS [$ELIBS]
213   --extra-version=STRING   version string suffix []
214   --build-suffix=SUFFIX    library name suffix []
215   --arch=ARCH              select architecture [$arch]
216   --cpu=CPU                select the minimum required CPU (affects
217                            instruction selection, may crash on older CPUs)
218   --disable-asm            disable all assembler optimizations
219   --disable-altivec        disable AltiVec optimizations
220   --disable-amd3dnow       disable 3DNow! optimizations
221   --disable-amd3dnowext    disable 3DNow! extended optimizations
222   --disable-mmx            disable MMX optimizations
223   --disable-mmx2           disable MMX2 optimizations
224   --disable-sse            disable SSE optimizations
225   --disable-ssse3          disable SSSE3 optimizations
226   --disable-avx            disable AVX optimizations
227   --disable-armv5te        disable armv5te optimizations
228   --disable-armv6          disable armv6 optimizations
229   --disable-armv6t2        disable armv6t2 optimizations
230   --disable-armvfp         disable ARM VFP optimizations
231   --disable-iwmmxt         disable iwmmxt optimizations
232   --disable-mmi            disable MMI optimizations
233   --disable-neon           disable neon optimizations
234   --disable-vis            disable VIS optimizations
235   --disable-yasm           disable use of yasm assembler
236   --enable-pic             build position-independent code
237   --malloc-prefix=PFX      prefix malloc and related names with PFX
238   --enable-sram            allow use of on-chip SRAM
239   --disable-symver         disable symbol versioning
240
241 Developer options (useful when working on FFmpeg itself):
242   --disable-debug          disable debugging symbols
243   --enable-debug=LEVEL     set the debug level [$debuglevel]
244   --disable-optimizations  disable compiler optimizations
245   --enable-extra-warnings  enable more compiler warnings
246   --disable-stripping      disable stripping of executables and shared libraries
247   --samples=PATH           location of test samples for FATE
248
249 NOTE: Object files are built at the place where configure is launched.
250 EOF
251   exit 0
252 }
253
254 quotes='""'
255
256 log(){
257     echo "$@" >> $logfile
258 }
259
260 log_file(){
261     log BEGIN $1
262     pr -n -t $1 >> $logfile
263     log END $1
264 }
265
266 echolog(){
267     log "$@"
268     echo "$@"
269 }
270
271 warn(){
272     log "WARNING: $*"
273     WARNINGS="${WARNINGS}WARNING: $*\n"
274 }
275
276 die(){
277     echolog "$@"
278     cat <<EOF
279
280 If you think configure made a mistake, make sure you are using the latest
281 version from Git.  If the latest version fails, report the problem to the
282 ffmpeg-user@mplayerhq.hu mailing list or IRC #ffmpeg on irc.freenode.net.
283 EOF
284     if disabled logging; then
285         cat <<EOF
286 Rerun configure with logging enabled (do not use --disable-logging), and
287 include the log this produces with your report.
288 EOF
289     else
290 cat <<EOF
291 Include the log file "$logfile" produced by configure as this will help
292 solving the problem.
293 EOF
294     fi
295     exit 1
296 }
297
298 # Avoid locale weirdness, besides we really just want to translate ASCII.
299 toupper(){
300     echo "$@" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
301 }
302
303 tolower(){
304     echo "$@" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
305 }
306
307 c_escape(){
308     echo "$*" | sed 's/["\\]/\\\0/g'
309 }
310
311 sh_quote(){
312     v=$(echo "$1" | sed "s/'/'\\\\''/g")
313     test "x$v" = "x${v#*[!A-Za-z0-9_/.+-]}" || v="'$v'"
314     echo "$v"
315 }
316
317 cleanws(){
318     echo "$@" | sed 's/^ *//;s/  */ /g;s/ *$//'
319 }
320
321 filter(){
322     pat=$1
323     shift
324     for v; do
325         eval "case $v in $pat) echo $v ;; esac"
326     done
327 }
328
329 filter_out(){
330     pat=$1
331     shift
332     for v; do
333         eval "case $v in $pat) ;; *) echo $v ;; esac"
334     done
335 }
336
337 map(){
338     m=$1
339     shift
340     for v; do eval $m; done
341 }
342
343 set_all(){
344     value=$1
345     shift
346     for var in $*; do
347         eval $var=$value
348     done
349 }
350
351 set_weak(){
352     value=$1
353     shift
354     for var; do
355         eval : \${$var:=$value}
356     done
357 }
358
359 pushvar(){
360     for var in $*; do
361         eval level=\${${var}_level:=0}
362         eval ${var}_${level}="\$$var"
363         eval ${var}_level=$(($level+1))
364     done
365 }
366
367 popvar(){
368     for var in $*; do
369         eval level=\${${var}_level:-0}
370         test $level = 0 && continue
371         eval level=$(($level-1))
372         eval $var="\${${var}_${level}}"
373         eval ${var}_level=$level
374         eval unset ${var}_${level}
375     done
376 }
377
378 enable(){
379     set_all yes $*
380 }
381
382 disable(){
383     set_all no $*
384 }
385
386 enable_weak(){
387     set_weak yes $*
388 }
389
390 disable_weak(){
391     set_weak no $*
392 }
393
394 enable_safe(){
395     for var; do
396         enable $(echo "$var" | sed 's/[^A-Za-z0-9_]/_/g')
397     done
398 }
399
400 disable_safe(){
401     for var; do
402         disable $(echo "$var" | sed 's/[^A-Za-z0-9_]/_/g')
403     done
404 }
405
406 do_enable_deep(){
407     for var; do
408         enabled $var && continue
409         eval sel="\$${var}_select"
410         eval sgs="\$${var}_suggest"
411         pushvar var sgs
412         enable_deep $sel
413         popvar sgs
414         enable_deep_weak $sgs
415         popvar var
416     done
417 }
418
419 enable_deep(){
420     do_enable_deep $*
421     enable $*
422 }
423
424 enable_deep_weak(){
425     do_enable_deep $*
426     enable_weak $*
427 }
428
429 enabled(){
430     test "${1#!}" = "$1" && op== || op=!=
431     eval test "x\$${1#!}" $op "xyes"
432 }
433
434 disabled(){
435     test "${1#!}" = "$1" && op== || op=!=
436     eval test "x\$${1#!}" $op "xno"
437 }
438
439 enabled_all(){
440     for opt; do
441         enabled $opt || return 1
442     done
443 }
444
445 disabled_all(){
446     for opt; do
447         disabled $opt || return 1
448     done
449 }
450
451 enabled_any(){
452     for opt; do
453         enabled $opt && return 0
454     done
455 }
456
457 disabled_any(){
458     for opt; do
459         disabled $opt && return 0
460     done
461     return 1
462 }
463
464 set_default(){
465     for opt; do
466         eval : \${$opt:=\$${opt}_default}
467     done
468 }
469
470 is_in(){
471     value=$1
472     shift
473     for var in $*; do
474         [ $var = $value ] && return 0
475     done
476     return 1
477 }
478
479 check_deps(){
480     for cfg; do
481         cfg="${cfg#!}"
482         enabled ${cfg}_checking && die "Circular dependency for $cfg."
483         disabled ${cfg}_checking && continue
484         enable ${cfg}_checking
485
486         eval dep_all="\$${cfg}_deps"
487         eval dep_any="\$${cfg}_deps_any"
488         eval dep_sel="\$${cfg}_select"
489         eval dep_sgs="\$${cfg}_suggest"
490         eval dep_ifa="\$${cfg}_if"
491         eval dep_ifn="\$${cfg}_if_any"
492
493         pushvar cfg dep_all dep_any dep_sel dep_sgs dep_ifa dep_ifn
494         check_deps $dep_all $dep_any $dep_sel $dep_sgs $dep_ifa $dep_ifn
495         popvar cfg dep_all dep_any dep_sel dep_sgs dep_ifa dep_ifn
496
497         [ -n "$dep_ifa" ] && { enabled_all $dep_ifa && enable_weak $cfg; }
498         [ -n "$dep_ifn" ] && { enabled_any $dep_ifn && enable_weak $cfg; }
499         enabled_all  $dep_all || disable $cfg
500         enabled_any  $dep_any || disable $cfg
501         disabled_any $dep_sel && disable $cfg
502
503         if enabled $cfg; then
504             eval dep_extralibs="\$${cfg}_extralibs"
505             test -n "$dep_extralibs" && add_extralibs $dep_extralibs
506             enable_deep $dep_sel
507             enable_deep_weak $dep_sgs
508         fi
509
510         disable ${cfg}_checking
511     done
512 }
513
514 print_config_h(){
515     enabled $1 && v=1 || v=0
516     echo "#define $2 $v"
517 }
518
519 print_config_mak(){
520     enabled $1 && v= || v=!
521     echo "$v$2=yes"
522 }
523
524 print_config_asm(){
525     enabled $1 && echo "%define $2"
526 }
527
528 print_config(){
529     pfx=$1
530     files=$2
531     shift 2
532     for cfg; do
533         ucname="$(toupper $cfg)"
534         for f in $files; do
535             "print_config_${f##*.}" $cfg ${pfx}${ucname} >>$f
536         done
537     done
538 }
539
540 print_enabled(){
541     test "$1" = -n && end=" " && shift || end="\n"
542     suf=$1
543     shift
544     for v; do
545         enabled $v && printf "%s$end" ${v%$suf};
546     done
547 }
548
549 append(){
550     var=$1
551     shift
552     eval "$var=\"\$$var $*\""
553 }
554
555 prepend(){
556     var=$1
557     shift
558     eval "$var=\"$* \$$var\""
559 }
560
561 add_cppflags(){
562     append CPPFLAGS $($filter_cppflags "$@")
563 }
564
565 add_cflags(){
566     append CFLAGS $($filter_cflags "$@")
567 }
568
569 add_asflags(){
570     append ASFLAGS $($filter_asflags "$@")
571 }
572
573 add_ldflags(){
574     append LDFLAGS "$@"
575 }
576
577 add_extralibs(){
578     prepend extralibs "$@"
579 }
580
581 check_cmd(){
582     log "$@"
583     "$@" >> $logfile 2>&1
584 }
585
586 check_cc(){
587     log check_cc "$@"
588     cat > $TMPC
589     log_file $TMPC
590     check_cmd $cc $CPPFLAGS $CFLAGS "$@" -c -o $TMPO $TMPC
591 }
592
593 check_cpp(){
594     log check_cpp "$@"
595     cat > $TMPC
596     log_file $TMPC
597     check_cmd $cc $CPPFLAGS $CFLAGS "$@" -E -o $TMPO $TMPC
598 }
599
600 check_as(){
601     log check_as "$@"
602     cat > $TMPC
603     log_file $TMPC
604     check_cmd $as $CPPFLAGS $ASFLAGS "$@" -c -o $TMPO $TMPC
605 }
606
607 check_asm(){
608     log check_asm "$@"
609     name="$1"
610     code="$2"
611     shift 2
612     disable $name
613     check_as "$@" <<EOF && enable $name
614 void foo(void){ __asm__ volatile($code); }
615 EOF
616 }
617
618 check_yasm(){
619     log check_yasm "$@"
620     echo "$1" > $TMPS
621     log_file $TMPS
622     shift 1
623     check_cmd $yasmexe $YASMFLAGS "$@" -o $TMPO $TMPS
624 }
625
626 check_ld(){
627     log check_ld "$@"
628     flags=''
629     libs=''
630     for f; do
631         test "${f}" = "${f#-l}" && flags="$flags $f" || libs="$libs $f"
632     done
633     check_cc $($filter_cflags $flags) || return
634     check_cmd $ld $LDFLAGS $flags -o $TMPE $TMPO $extralibs $libs
635 }
636
637 check_cppflags(){
638     log check_cppflags "$@"
639     set -- $($filter_cppflags "$@")
640     check_cc "$@" <<EOF && append CPPFLAGS "$@"
641 int x;
642 EOF
643 }
644
645 check_cflags(){
646     log check_cflags "$@"
647     set -- $($filter_cflags "$@")
648     check_cc "$@" <<EOF && append CFLAGS "$@"
649 int x;
650 EOF
651 }
652
653 test_ldflags(){
654     log test_ldflags "$@"
655     check_ld "$@" <<EOF
656 int main(void){ return 0; }
657 EOF
658 }
659
660 check_ldflags(){
661     log check_ldflags "$@"
662     test_ldflags "$@" && add_ldflags "$@"
663 }
664
665 check_header(){
666     log check_header "$@"
667     header=$1
668     shift
669     disable_safe $header
670     check_cpp "$@" <<EOF && enable_safe $header
671 #include <$header>
672 int x;
673 EOF
674 }
675
676 check_func(){
677     log check_func "$@"
678     func=$1
679     shift
680     disable $func
681     check_ld "$@" <<EOF && enable $func
682 extern int $func();
683 int main(void){ $func(); }
684 EOF
685 }
686
687 check_mathfunc(){
688     log check_mathfunc "$@"
689     func=$1
690     shift
691     disable $func
692     check_ld "$@" <<EOF && enable $func
693 #include <math.h>
694 float foo(float f) { return $func(f); }
695 int main(void){ return 0; }
696 EOF
697 }
698
699 check_func_headers(){
700     log check_func_headers "$@"
701     headers=$1
702     func=$2
703     shift 2
704     disable $func
705     incs=""
706     for hdr in $headers; do
707         incs="$incs
708 #include <$hdr>"
709     done
710     check_ld "$@" <<EOF && enable $func && enable_safe $headers
711 $incs
712 int main(int argc, char **argv){
713     return (long) $func;
714 }
715 EOF
716 }
717
718 check_cpp_condition(){
719     log check_cpp_condition "$@"
720     header=$1
721     condition=$2
722     shift 2
723     check_cpp $($filter_cppflags "$@") <<EOF
724 #include <$header>
725 #if !($condition)
726 #error "unsatisfied condition: $condition"
727 #endif
728 EOF
729 }
730
731 check_lib(){
732     log check_lib "$@"
733     header="$1"
734     func="$2"
735     shift 2
736     check_header $header && check_func $func "$@" && add_extralibs "$@"
737 }
738
739 check_lib2(){
740     log check_lib2 "$@"
741     headers="$1"
742     func="$2"
743     shift 2
744     check_func_headers "$headers" $func "$@" && add_extralibs "$@"
745 }
746
747 check_exec(){
748     check_ld "$@" && { enabled cross_compile || $TMPE >> $logfile 2>&1; }
749 }
750
751 check_exec_crash(){
752     code=$(cat)
753
754     # exit() is not async signal safe.  _Exit (C99) and _exit (POSIX)
755     # are safe but may not be available everywhere.  Thus we use
756     # raise(SIGTERM) instead.  The check is run in a subshell so we
757     # can redirect the "Terminated" message from the shell.  SIGBUS
758     # is not defined by standard C so it is used conditionally.
759
760     (check_exec "$@") >> $logfile 2>&1 <<EOF
761 #include <signal.h>
762 static void sighandler(int sig){
763     raise(SIGTERM);
764 }
765 int main(void){
766     signal(SIGILL, sighandler);
767     signal(SIGFPE, sighandler);
768     signal(SIGSEGV, sighandler);
769 #ifdef SIGBUS
770     signal(SIGBUS, sighandler);
771 #endif
772     { $code }
773 }
774 EOF
775 }
776
777 check_type(){
778     log check_type "$@"
779     headers=$1
780     type=$2
781     shift 2
782     disable_safe "$type"
783     incs=""
784     for hdr in $headers; do
785         incs="$incs
786 #include <$hdr>"
787     done
788     check_cc "$@" <<EOF && enable_safe "$type"
789 $incs
790 $type v;
791 EOF
792 }
793
794 check_struct(){
795     log check_type "$@"
796     headers=$1
797     struct=$2
798     member=$3
799     shift 3
800     disable_safe "${struct}_${member}"
801     incs=""
802     for hdr in $headers; do
803         incs="$incs
804 #include <$hdr>"
805     done
806     check_cc "$@" <<EOF && enable_safe "${struct}_${member}"
807 $incs
808 const void *p = &(($struct *)0)->$member;
809 EOF
810 }
811
812 require(){
813     name="$1"
814     header="$2"
815     func="$3"
816     shift 3
817     check_lib $header $func "$@" || die "ERROR: $name not found"
818 }
819
820 require2(){
821     name="$1"
822     headers="$2"
823     func="$3"
824     shift 3
825     check_lib2 "$headers" $func "$@" || die "ERROR: $name not found"
826 }
827
828 check_host_cc(){
829     log check_host_cc "$@"
830     cat > $TMPC
831     log_file $TMPC
832     check_cmd $host_cc $host_cflags "$@" -c -o $TMPO $TMPC
833 }
834
835 check_host_cflags(){
836     log check_host_cflags "$@"
837     check_host_cc "$@" <<EOF && append host_cflags "$@"
838 int x;
839 EOF
840 }
841
842 apply(){
843     file=$1
844     shift
845     "$@" < "$file" > "$file.tmp" && mv "$file.tmp" "$file" || rm "$file.tmp"
846 }
847
848 cp_if_changed(){
849     cmp -s "$1" "$2" &&
850         echo "$2 is unchanged" ||
851         cp -f "$1" "$2"
852 }
853
854 # CONFIG_LIST contains configurable options, while HAVE_LIST is for
855 # system-dependent things.
856
857 COMPONENT_LIST="
858     bsfs
859     decoders
860     demuxers
861     encoders
862     filters
863     hwaccels
864     indevs
865     muxers
866     outdevs
867     parsers
868     protocols
869 "
870
871 CONFIG_LIST="
872     $COMPONENT_LIST
873     aandct
874     avcodec
875     avdevice
876     avfilter
877     avformat
878     avisynth
879     bzlib
880     dct
881     doc
882     dwt
883     dxva2
884     fastdiv
885     ffmpeg
886     ffplay
887     ffprobe
888     ffserver
889     fft
890     frei0r
891     golomb
892     gpl
893     gray
894     h264dsp
895     h264pred
896     hardcoded_tables
897     huffman
898     libdc1394
899     libdirac
900     libfaac
901     libfreetype
902     libgsm
903     libmp3lame
904     libnut
905     libopencore_amrnb
906     libopencore_amrwb
907     libopencv
908     libopenjpeg
909     librtmp
910     libschroedinger
911     libspeex
912     libtheora
913     libvorbis
914     libvpx
915     libx264
916     libxavs
917     libxvid
918     lpc
919     lsp
920     mdct
921     memalign_hack
922     mlib
923     mpegaudio_hp
924     network
925     nonfree
926     pic
927     postproc
928     rdft
929     rtpdec
930     runtime_cpudetect
931     shared
932     small
933     sram
934     static
935     swscale
936     swscale_alpha
937     vaapi
938     vdpau
939     version3
940     x11grab
941     zlib
942 "
943
944 THREADS_LIST='
945     pthreads
946     w32threads
947 '
948
949 ARCH_LIST='
950     alpha
951     arm
952     avr32
953     avr32_ap
954     avr32_uc
955     bfin
956     ia64
957     m68k
958     mips
959     mips64
960     parisc
961     ppc
962     ppc64
963     s390
964     sh4
965     sparc
966     sparc64
967     tomi
968     x86
969     x86_32
970     x86_64
971 '
972
973 ARCH_EXT_LIST='
974     altivec
975     amd3dnow
976     amd3dnowext
977     armv5te
978     armv6
979     armv6t2
980     armvfp
981     avx
982     iwmmxt
983     mmi
984     mmx
985     mmx2
986     neon
987     ppc4xx
988     sse
989     ssse3
990     vis
991 '
992
993 HAVE_LIST_PUB='
994     bigendian
995     fast_unaligned
996 '
997
998 HAVE_LIST="
999     $ARCH_EXT_LIST
1000     $HAVE_LIST_PUB
1001     $THREADS_LIST
1002     aligned_stack
1003     alsa_asoundlib_h
1004     altivec_h
1005     arpa_inet_h
1006     attribute_may_alias
1007     attribute_packed
1008     bswap
1009     closesocket
1010     cmov
1011     conio_h
1012     dcbzl
1013     dev_bktr_ioctl_bt848_h
1014     dev_bktr_ioctl_meteor_h
1015     dev_ic_bt8xx_h
1016     dev_video_meteor_ioctl_meteor_h
1017     dev_video_bktr_ioctl_bt848_h
1018     dlfcn_h
1019     dlopen
1020     dos_paths
1021     ebp_available
1022     ebx_available
1023     exp2
1024     exp2f
1025     fast_64bit
1026     fast_clz
1027     fast_cmov
1028     fcntl
1029     fork
1030     getaddrinfo
1031     gethrtime
1032     GetProcessMemoryInfo
1033     GetProcessTimes
1034     getrusage
1035     gnu_as
1036     struct_rusage_ru_maxrss
1037     ibm_asm
1038     inet_aton
1039     inline_asm
1040     isatty
1041     ldbrx
1042     libdc1394_1
1043     libdc1394_2
1044     llrint
1045     llrintf
1046     local_aligned_16
1047     local_aligned_8
1048     localtime_r
1049     log2
1050     log2f
1051     loongson
1052     lrint
1053     lrintf
1054     lzo1x_999_compress
1055     machine_ioctl_bt848_h
1056     machine_ioctl_meteor_h
1057     malloc_h
1058     MapViewOfFile
1059     memalign
1060     mkstemp
1061     mmap
1062     pld
1063     posix_memalign
1064     round
1065     roundf
1066     sdl
1067     sdl_video_size
1068     setmode
1069     socklen_t
1070     soundcard_h
1071     poll_h
1072     setrlimit
1073     strerror_r
1074     strtok_r
1075     struct_addrinfo
1076     struct_ipv6_mreq
1077     struct_sockaddr_in6
1078     struct_sockaddr_sa_len
1079     struct_sockaddr_storage
1080     symver
1081     symver_gnu_asm
1082     symver_asm_label
1083     sys_mman_h
1084     sys_resource_h
1085     sys_select_h
1086     sys_soundcard_h
1087     sys_videoio_h
1088     ten_operands
1089     termios_h
1090     threads
1091     truncf
1092     vfp_args
1093     VirtualAlloc
1094     winsock2_h
1095     xform_asm
1096     xmm_clobbers
1097     yasm
1098 "
1099
1100 # options emitted with CONFIG_ prefix but not available on command line
1101 CONFIG_EXTRA="
1102     avutil
1103     gplv3
1104     lgplv3
1105 "
1106
1107 CMDLINE_SELECT="
1108     $ARCH_EXT_LIST
1109     $CONFIG_LIST
1110     $THREADS_LIST
1111     asm
1112     cross_compile
1113     debug
1114     extra_warnings
1115     logging
1116     optimizations
1117     stripping
1118     symver
1119     yasm
1120 "
1121
1122 PATHS_LIST='
1123     bindir
1124     datadir
1125     incdir
1126     libdir
1127     mandir
1128     prefix
1129     shlibdir
1130 '
1131
1132 CMDLINE_SET="
1133     $PATHS_LIST
1134     ar
1135     arch
1136     as
1137     build_suffix
1138     cc
1139     cpu
1140     cross_prefix
1141     dep_cc
1142     extra_version
1143     host_cc
1144     host_cflags
1145     host_ldflags
1146     host_libs
1147     host_os
1148     ld
1149     logfile
1150     malloc_prefix
1151     nm
1152     samples
1153     source_path
1154     strip
1155     sysinclude
1156     sysroot
1157     target_exec
1158     target_os
1159     target_path
1160 "
1161
1162 CMDLINE_APPEND="
1163     extra_cflags
1164 "
1165
1166 # code dependency declarations
1167
1168 # architecture extensions
1169
1170 armv5te_deps="arm"
1171 armv6_deps="arm"
1172 armv6t2_deps="arm"
1173 armvfp_deps="arm"
1174 iwmmxt_deps="arm"
1175 neon_deps="arm"
1176
1177 mmi_deps="mips"
1178
1179 altivec_deps="ppc"
1180 ppc4xx_deps="ppc"
1181
1182 vis_deps="sparc"
1183
1184 x86_64_suggest="cmov fast_cmov"
1185 amd3dnow_deps="mmx"
1186 amd3dnowext_deps="amd3dnow"
1187 mmx_deps="x86"
1188 mmx2_deps="mmx"
1189 sse_deps="mmx"
1190 ssse3_deps="sse"
1191 avx_deps="ssse3"
1192
1193 aligned_stack_if_any="ppc x86"
1194 fast_64bit_if_any="alpha ia64 mips64 parisc64 ppc64 sparc64 x86_64"
1195 fast_clz_if_any="alpha armv5te avr32 mips ppc x86"
1196 fast_unaligned_if_any="armv6 ppc x86"
1197
1198 need_memalign="altivec neon sse"
1199 inline_asm_deps="!tms470"
1200
1201 symver_if_any="symver_asm_label symver_gnu_asm"
1202
1203 # subsystems
1204 dct_select="rdft"
1205 mdct_select="fft"
1206 rdft_select="fft"
1207
1208 # decoders / encoders / hardware accelerators
1209 aac_decoder_select="mdct rdft"
1210 aac_encoder_select="mdct"
1211 aac_latm_decoder_select="aac_decoder aac_latm_parser"
1212 ac3_decoder_select="mdct ac3_parser"
1213 ac3_encoder_select="mdct"
1214 alac_encoder_select="lpc"
1215 amrnb_decoder_select="lsp"
1216 amrwb_decoder_select="lsp"
1217 atrac1_decoder_select="mdct"
1218 atrac3_decoder_select="mdct"
1219 binkaudio_dct_decoder_select="mdct rdft dct"
1220 binkaudio_rdft_decoder_select="mdct rdft"
1221 cavs_decoder_select="golomb"
1222 cook_decoder_select="mdct"
1223 cscd_decoder_suggest="zlib"
1224 dca_decoder_select="mdct"
1225 dnxhd_encoder_select="aandct"
1226 dxa_decoder_select="zlib"
1227 eac3_decoder_select="ac3_decoder"
1228 eamad_decoder_select="aandct"
1229 eatgq_decoder_select="aandct"
1230 eatqi_decoder_select="aandct"
1231 ffv1_decoder_select="golomb"
1232 flac_decoder_select="golomb"
1233 flac_encoder_select="golomb lpc"
1234 flashsv_decoder_select="zlib"
1235 flashsv_encoder_select="zlib"
1236 flv_decoder_select="h263_decoder"
1237 flv_encoder_select="h263_encoder"
1238 fraps_decoder_select="huffman"
1239 h261_encoder_select="aandct"
1240 h263_decoder_select="h263_parser"
1241 h263_encoder_select="aandct"
1242 h263_vaapi_hwaccel_select="vaapi h263_decoder"
1243 h263i_decoder_select="h263_decoder"
1244 h263p_encoder_select="h263_encoder"
1245 h264_decoder_select="golomb h264dsp h264pred"
1246 h264_dxva2_hwaccel_deps="dxva2api_h"
1247 h264_dxva2_hwaccel_select="dxva2 h264_decoder"
1248 h264_vaapi_hwaccel_select="vaapi"
1249 h264_vdpau_decoder_select="vdpau h264_decoder"
1250 imc_decoder_select="fft mdct"
1251 jpegls_decoder_select="golomb"
1252 jpegls_encoder_select="golomb"
1253 ljpeg_encoder_select="aandct"
1254 loco_decoder_select="golomb"
1255 mjpeg_encoder_select="aandct"
1256 mlp_decoder_select="mlp_parser"
1257 mp1float_decoder_select="dct"
1258 mp2float_decoder_select="dct"
1259 mp3adufloat_decoder_select="dct"
1260 mp3float_decoder_select="dct"
1261 mp3on4float_decoder_select="dct"
1262 mpeg1video_encoder_select="aandct"
1263 mpeg2video_encoder_select="aandct"
1264 mpeg4_decoder_select="h263_decoder mpeg4video_parser"
1265 mpeg4_encoder_select="h263_encoder"
1266 mpeg_vdpau_decoder_select="vdpau mpegvideo_decoder"
1267 mpeg1_vdpau_decoder_select="vdpau mpeg1video_decoder"
1268 mpeg2_dxva2_hwaccel_deps="dxva2api_h"
1269 mpeg2_dxva2_hwaccel_select="dxva2 mpeg2video_decoder"
1270 mpeg2_vaapi_hwaccel_select="vaapi mpeg2video_decoder"
1271 mpeg4_vaapi_hwaccel_select="vaapi mpeg4_decoder"
1272 mpeg4_vdpau_decoder_select="vdpau mpeg4_decoder"
1273 mpeg_xvmc_decoder_deps="X11_extensions_XvMClib_h"
1274 mpeg_xvmc_decoder_select="mpegvideo_decoder"
1275 msmpeg4v1_decoder_select="h263_decoder"
1276 msmpeg4v1_encoder_select="h263_encoder"
1277 msmpeg4v2_decoder_select="h263_decoder"
1278 msmpeg4v2_encoder_select="h263_encoder"
1279 msmpeg4v3_decoder_select="h263_decoder"
1280 msmpeg4v3_encoder_select="h263_encoder"
1281 nellymoser_decoder_select="mdct"
1282 nellymoser_encoder_select="mdct"
1283 png_decoder_select="zlib"
1284 png_encoder_select="zlib"
1285 qcelp_decoder_select="lsp"
1286 qdm2_decoder_select="mdct rdft"
1287 ra_144_encoder_select="lpc"
1288 rv10_decoder_select="h263_decoder"
1289 rv10_encoder_select="h263_encoder"
1290 rv20_decoder_select="h263_decoder"
1291 rv20_encoder_select="h263_encoder"
1292 rv30_decoder_select="golomb h264pred"
1293 rv40_decoder_select="golomb h264pred"
1294 shorten_decoder_select="golomb"
1295 sipr_decoder_select="lsp"
1296 snow_decoder_select="dwt"
1297 snow_encoder_select="aandct dwt"
1298 sonic_decoder_select="golomb"
1299 sonic_encoder_select="golomb"
1300 sonic_ls_encoder_select="golomb"
1301 svq1_encoder_select="aandct"
1302 svq3_decoder_select="golomb h264dsp h264pred"
1303 svq3_decoder_suggest="zlib"
1304 theora_decoder_select="vp3_decoder"
1305 tiff_decoder_suggest="zlib"
1306 tiff_encoder_suggest="zlib"
1307 truehd_decoder_select="mlp_decoder"
1308 tscc_decoder_select="zlib"
1309 twinvq_decoder_select="mdct lsp"
1310 vc1_decoder_select="h263_decoder"
1311 vc1_dxva2_hwaccel_deps="dxva2api_h DXVA_PictureParameters_wDecodedPictureIndex"
1312 vc1_dxva2_hwaccel_select="dxva2 vc1_decoder"
1313 vc1_vaapi_hwaccel_select="vaapi vc1_decoder"
1314 vc1_vdpau_decoder_select="vdpau vc1_decoder"
1315 vorbis_decoder_select="mdct"
1316 vorbis_encoder_select="mdct"
1317 vp6_decoder_select="huffman"
1318 vp6a_decoder_select="vp6_decoder"
1319 vp6f_decoder_select="vp6_decoder"
1320 vp8_decoder_select="h264pred"
1321 wmapro_decoder_select="mdct"
1322 wmav1_decoder_select="mdct"
1323 wmav1_encoder_select="mdct"
1324 wmav2_decoder_select="mdct"
1325 wmav2_encoder_select="mdct"
1326 wmavoice_decoder_select="lsp rdft dct mdct"
1327 wmv1_decoder_select="h263_decoder"
1328 wmv1_encoder_select="h263_encoder"
1329 wmv2_decoder_select="h263_decoder"
1330 wmv2_encoder_select="h263_encoder"
1331 wmv3_decoder_select="vc1_decoder"
1332 wmv3_dxva2_hwaccel_select="vc1_dxva2_hwaccel"
1333 wmv3_vaapi_hwaccel_select="vc1_vaapi_hwaccel"
1334 wmv3_vdpau_decoder_select="vc1_vdpau_decoder"
1335 zlib_decoder_select="zlib"
1336 zlib_encoder_select="zlib"
1337 zmbv_decoder_select="zlib"
1338 zmbv_encoder_select="zlib"
1339
1340 vaapi_deps="va_va_h"
1341 vdpau_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
1342
1343 # parsers
1344 h264_parser_select="golomb h264dsp h264pred"
1345
1346 # external libraries
1347 libdirac_decoder_deps="libdirac !libschroedinger"
1348 libdirac_encoder_deps="libdirac"
1349 libfaac_encoder_deps="libfaac"
1350 libgsm_decoder_deps="libgsm"
1351 libgsm_encoder_deps="libgsm"
1352 libgsm_ms_decoder_deps="libgsm"
1353 libgsm_ms_encoder_deps="libgsm"
1354 libmp3lame_encoder_deps="libmp3lame"
1355 libopencore_amrnb_decoder_deps="libopencore_amrnb"
1356 libopencore_amrnb_encoder_deps="libopencore_amrnb"
1357 libopencore_amrwb_decoder_deps="libopencore_amrwb"
1358 libopenjpeg_decoder_deps="libopenjpeg"
1359 libschroedinger_decoder_deps="libschroedinger"
1360 libschroedinger_encoder_deps="libschroedinger"
1361 libspeex_decoder_deps="libspeex"
1362 libtheora_encoder_deps="libtheora"
1363 libvorbis_encoder_deps="libvorbis"
1364 libvpx_decoder_deps="libvpx"
1365 libvpx_encoder_deps="libvpx"
1366 libx264_encoder_deps="libx264"
1367 libxavs_encoder_deps="libxavs"
1368 libxvid_encoder_deps="libxvid"
1369
1370 # demuxers / muxers
1371 ac3_demuxer_select="ac3_parser"
1372 asf_stream_muxer_select="asf_muxer"
1373 avisynth_demuxer_deps="avisynth"
1374 dirac_demuxer_select="dirac_parser"
1375 eac3_demuxer_select="ac3_parser"
1376 flac_demuxer_select="flac_parser"
1377 ipod_muxer_select="mov_muxer"
1378 libnut_demuxer_deps="libnut"
1379 libnut_muxer_deps="libnut"
1380 matroska_audio_muxer_select="matroska_muxer"
1381 matroska_demuxer_suggest="zlib bzlib"
1382 mov_demuxer_suggest="zlib"
1383 mp3_demuxer_select="mpegaudio_parser"
1384 mp4_muxer_select="mov_muxer"
1385 mpegtsraw_demuxer_select="mpegts_demuxer"
1386 mxf_d10_muxer_select="mxf_muxer"
1387 ogg_demuxer_select="golomb"
1388 psp_muxer_select="mov_muxer"
1389 rtp_demuxer_select="sdp_demuxer"
1390 rtpdec_select="asf_demuxer rm_demuxer rtp_protocol mpegts_demuxer mov_demuxer"
1391 rtsp_demuxer_select="http_protocol rtpdec"
1392 rtsp_muxer_select="rtp_muxer http_protocol rtp_protocol"
1393 sap_demuxer_select="sdp_demuxer"
1394 sap_muxer_select="rtp_muxer rtp_protocol"
1395 sdp_demuxer_select="rtpdec"
1396 spdif_muxer_select="aac_parser"
1397 tg2_muxer_select="mov_muxer"
1398 tgp_muxer_select="mov_muxer"
1399 w64_demuxer_deps="wav_demuxer"
1400
1401 # indevs / outdevs
1402 alsa_indev_deps="alsa_asoundlib_h snd_pcm_htimestamp"
1403 alsa_outdev_deps="alsa_asoundlib_h"
1404 bktr_indev_deps_any="dev_bktr_ioctl_bt848_h machine_ioctl_bt848_h dev_video_bktr_ioctl_bt848_h dev_ic_bt8xx_h"
1405 dv1394_indev_deps="dv1394 dv_demuxer"
1406 jack_indev_deps="jack_jack_h"
1407 libdc1394_indev_deps="libdc1394"
1408 oss_indev_deps_any="soundcard_h sys_soundcard_h"
1409 oss_outdev_deps_any="soundcard_h sys_soundcard_h"
1410 v4l_indev_deps="linux_videodev_h"
1411 v4l2_indev_deps_any="linux_videodev2_h sys_videoio_h"
1412 vfwcap_indev_deps="capCreateCaptureWindow vfwcap_defines"
1413 vfwcap_indev_extralibs="-lavicap32"
1414 x11_grab_device_indev_deps="x11grab XShmCreateImage"
1415 x11_grab_device_indev_extralibs="-lX11 -lXext -lXfixes"
1416
1417 # protocols
1418 gopher_protocol_deps="network"
1419 http_protocol_deps="network"
1420 http_protocol_select="tcp_protocol"
1421 mmsh_protocol_select="http_protocol"
1422 mmst_protocol_deps="network"
1423 rtmp_protocol_select="tcp_protocol"
1424 rtp_protocol_select="udp_protocol"
1425 tcp_protocol_deps="network"
1426 udp_protocol_deps="network"
1427
1428 # filters
1429 blackframe_filter_deps="gpl"
1430 cropdetect_filter_deps="gpl"
1431 drawtext_filter_deps="libfreetype"
1432 frei0r_filter_deps="frei0r dlopen strtok_r"
1433 frei0r_src_filter_deps="frei0r dlopen strtok_r"
1434 hqdn3d_filter_deps="gpl"
1435 mp_filter_deps="gpl"
1436 scale_filter_deps="swscale"
1437 ocv_filter_deps="libopencv"
1438 yadif_filter_deps="gpl"
1439
1440 # libraries
1441 avdevice_deps="avcodec avformat"
1442 avformat_deps="avcodec"
1443
1444 # programs
1445 ffmpeg_deps="avcodec avformat swscale"
1446 ffmpeg_select="buffer_filter"
1447 ffplay_deps="avcodec avformat swscale sdl"
1448 ffplay_select="rdft"
1449 ffprobe_deps="avcodec avformat"
1450 ffserver_deps="avformat ffm_muxer rtp_protocol rtsp_demuxer"
1451 ffserver_extralibs='$ldl'
1452
1453 doc_deps="texi2html"
1454
1455 # tests
1456
1457 test_deps(){
1458     suf1=$1
1459     suf2=$2
1460     shift 2
1461     for v; do
1462         dep=${v%=*}
1463         tests=${v#*=}
1464         for name in ${tests}; do
1465             eval ${name}_test_deps="'${dep}$suf1 ${dep}$suf2'"
1466         done
1467     done
1468 }
1469
1470 set_ne_test_deps(){
1471     eval ${1}_be_test_deps="bigendian"
1472     eval ${1}_le_test_deps="!bigendian"
1473 }
1474
1475 test_deps _encoder _decoder                                             \
1476     adpcm_g726=g726                                                     \
1477     adpcm_ima_qt                                                        \
1478     adpcm_ima_wav                                                       \
1479     adpcm_ms                                                            \
1480     adpcm_swf                                                           \
1481     adpcm_yamaha=adpcm_yam                                              \
1482     alac                                                                \
1483     asv1                                                                \
1484     asv2                                                                \
1485     bmp                                                                 \
1486     dnxhd="dnxhd_1080i dnxhd_720p dnxhd_720p_rd"                        \
1487     dvvideo="dv dv50"                                                   \
1488     ffv1                                                                \
1489     flac                                                                \
1490     flashsv                                                             \
1491     flv                                                                 \
1492     gif                                                                 \
1493     h261                                                                \
1494     h263="h263 h263p"                                                   \
1495     huffyuv                                                             \
1496     jpegls                                                              \
1497     mjpeg="jpg mjpeg ljpeg"                                             \
1498     mp2                                                                 \
1499     mpeg1video="mpeg mpeg1b"                                            \
1500     mpeg2video="mpeg2 mpeg2thread"                                      \
1501     mpeg4="mpeg4 mpeg4adv mpeg4nr mpeg4thread error rc"                 \
1502     msmpeg4v3=msmpeg4                                                   \
1503     msmpeg4v2                                                           \
1504     pbm=pbmpipe                                                         \
1505     pcx                                                                 \
1506     pgm="pgm pgmpipe"                                                   \
1507     png                                                                 \
1508     ppm="ppm ppmpipe"                                                   \
1509     rawvideo="rgb yuv"                                                  \
1510     roq                                                                 \
1511     rv10                                                                \
1512     rv20                                                                \
1513     sgi                                                                 \
1514     snow="snow snowll"                                                  \
1515     svq1                                                                \
1516     targa=tga                                                           \
1517     tiff                                                                \
1518     wmav1                                                               \
1519     wmav2                                                               \
1520     wmv1                                                                \
1521     wmv2                                                                \
1522
1523 test_deps _muxer _demuxer                                               \
1524     aiff                                                                \
1525     pcm_alaw=alaw                                                       \
1526     asf                                                                 \
1527     au                                                                  \
1528     avi                                                                 \
1529     dv=dv_fmt                                                           \
1530     ffm                                                                 \
1531     flv=flv_fmt                                                         \
1532     gxf                                                                 \
1533     matroska=mkv                                                        \
1534     mmf                                                                 \
1535     mov                                                                 \
1536     pcm_mulaw=mulaw                                                     \
1537     mxf                                                                 \
1538     nut                                                                 \
1539     ogg                                                                 \
1540     rawvideo=pixfmt                                                     \
1541     rm                                                                  \
1542     swf                                                                 \
1543     mpegts=ts                                                           \
1544     voc                                                                 \
1545     wav                                                                 \
1546     yuv4mpegpipe=yuv4mpeg                                               \
1547
1548 ac3_fixed_test_deps="ac3_fixed_encoder ac3_decoder rm_muxer rm_demuxer"
1549 mpg_test_deps="mpeg1system_muxer mpegps_demuxer"
1550
1551 set_ne_test_deps pixdesc
1552 set_ne_test_deps pixfmts_copy
1553 set_ne_test_deps pixfmts_crop
1554 set_ne_test_deps pixfmts_hflip
1555 set_ne_test_deps pixfmts_null
1556 set_ne_test_deps pixfmts_pad
1557 set_ne_test_deps pixfmts_scale
1558 set_ne_test_deps pixfmts_vflip
1559
1560 # default parameters
1561
1562 logfile="config.log"
1563
1564 # installation paths
1565 prefix_default="/usr/local"
1566 bindir_default='${prefix}/bin'
1567 datadir_default='${prefix}/share/ffmpeg'
1568 incdir_default='${prefix}/include'
1569 libdir_default='${prefix}/lib'
1570 mandir_default='${prefix}/share/man'
1571 shlibdir_default="$libdir_default"
1572
1573 # toolchain
1574 ar_default="ar"
1575 cc_default="gcc"
1576 cc_version=\"unknown\"
1577 host_cc_default="gcc"
1578 ln_s="ln -sf"
1579 nm_default="nm"
1580 objformat="elf"
1581 ranlib="ranlib"
1582 strip_default="strip"
1583 yasmexe="yasm"
1584 nogas=":"
1585
1586 nm_opts='-g'
1587
1588 # machine
1589 arch_default=$(uname -m)
1590 cpu="generic"
1591
1592 # OS
1593 target_os_default=$(tolower $(uname -s))
1594 host_os=$target_os_default
1595
1596 # configurable options
1597 enable avcodec
1598 enable avdevice
1599 enable avfilter
1600 enable avformat
1601 enable avutil
1602 enable asm
1603 enable debug
1604 enable doc
1605 enable fastdiv
1606 enable ffmpeg
1607 enable ffplay
1608 enable ffprobe
1609 enable ffserver
1610 enable mpegaudio_hp
1611 enable network
1612 enable optimizations
1613 enable protocols
1614 enable static
1615 enable stripping
1616 enable swscale
1617 enable swscale_alpha
1618
1619 # build settings
1620 SHFLAGS='-shared -Wl,-soname,$$(@F)'
1621 FFSERVERLDFLAGS=-Wl,-E
1622 LIBPREF="lib"
1623 LIBSUF=".a"
1624 FULLNAME='$(NAME)$(BUILDSUF)'
1625 LIBNAME='$(LIBPREF)$(FULLNAME)$(LIBSUF)'
1626 SLIBPREF="lib"
1627 SLIBSUF=".so"
1628 SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF)'
1629 SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
1630 SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
1631 LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
1632
1633 CC_O='-o $@'
1634
1635 host_cflags='-D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112 -O3 -g -Wall'
1636 host_libs='-lm'
1637
1638 target_path='$(CURDIR)'
1639
1640 # since the object filename is not given with the -MM flag, the compiler
1641 # is only able to print the basename, and we must add the path ourselves
1642 DEPEND_CMD='$(DEPCC) $(DEPFLAGS) $< | sed -e "/^\#.*/d" -e "s,^[[:space:]]*$(*F)\\.o,$(@D)/$(*F).o," > $(@:.o=.d)'
1643 DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -MM'
1644
1645 # find source path
1646 source_path="$(dirname "$0")"
1647 enable source_path_used
1648 if test -f configure; then
1649     source_path="$(pwd)"
1650     disable source_path_used
1651 else
1652     source_path="$(cd "$source_path"; pwd)"
1653     echo "$source_path" | grep -q '[[:blank:]]' &&
1654         die "Out of tree builds are impossible with whitespace in source path."
1655     test -e "$source_path/config.h" &&
1656         die "Out of tree builds are impossible with config.h in source dir."
1657 fi
1658
1659 for v in "$@"; do
1660     r=${v#*=}
1661     l=${v%"$r"}
1662     r=$(sh_quote "$r")
1663     FFMPEG_CONFIGURATION="${FFMPEG_CONFIGURATION# } ${l}${r}"
1664 done
1665
1666 find_things(){
1667     thing=$1
1668     pattern=$2
1669     file=$source_path/$3
1670     sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" "$file"
1671 }
1672
1673 ENCODER_LIST=$(find_things  encoder  ENC      libavcodec/allcodecs.c)
1674 DECODER_LIST=$(find_things  decoder  DEC      libavcodec/allcodecs.c)
1675 HWACCEL_LIST=$(find_things  hwaccel  HWACCEL  libavcodec/allcodecs.c)
1676 PARSER_LIST=$(find_things   parser   PARSER   libavcodec/allcodecs.c)
1677 BSF_LIST=$(find_things      bsf      BSF      libavcodec/allcodecs.c)
1678 MUXER_LIST=$(find_things    muxer    _MUX     libavformat/allformats.c)
1679 DEMUXER_LIST=$(find_things  demuxer  DEMUX    libavformat/allformats.c)
1680 OUTDEV_LIST=$(find_things   outdev   OUTDEV   libavdevice/alldevices.c)
1681 INDEV_LIST=$(find_things    indev    _IN      libavdevice/alldevices.c)
1682 PROTOCOL_LIST=$(find_things protocol PROTOCOL libavformat/allformats.c)
1683 FILTER_LIST=$(find_things   filter   FILTER   libavfilter/allfilters.c)
1684
1685 find_tests(){
1686     map "echo ${2}\${v}_test" $(ls "$source_path"/tests/ref/$1 | grep -v '[^-a-z0-9_]')
1687 }
1688
1689 ACODEC_TESTS=$(find_tests acodec)
1690 VCODEC_TESTS=$(find_tests vsynth1)
1691 LAVF_TESTS=$(find_tests lavf)
1692 LAVFI_TESTS=$(find_tests lavfi)
1693 SEEK_TESTS=$(find_tests seek seek_)
1694
1695 pcm_test_deps=$(map 'echo ${v%_*}_decoder $v' $(filter pcm_* $ENCODER_LIST))
1696
1697 for n in $COMPONENT_LIST; do
1698     v=$(toupper ${n%s})_LIST
1699     eval enable \$$v
1700     eval ${n}_if_any="\$$v"
1701 done
1702
1703 enable $ARCH_EXT_LIST $ACODEC_TESTS $VCODEC_TESTS $LAVF_TESTS $LAVFI_TESTS $SEEK_TESTS
1704
1705 die_unknown(){
1706     echo "Unknown option \"$1\"."
1707     echo "See $0 --help for available options."
1708     exit 1
1709 }
1710
1711 show_list() {
1712     suffix=_$1
1713     shift
1714     echo $* | sed s/$suffix//g | tr ' ' '\n' | sort | pr -3 -t
1715     exit 0
1716 }
1717
1718 for opt do
1719     optval="${opt#*=}"
1720     case "$opt" in
1721     --extra-ldflags=*) add_ldflags $optval
1722     ;;
1723     --extra-libs=*) add_extralibs $optval
1724     ;;
1725     --disable-devices) disable $INDEV_LIST $OUTDEV_LIST
1726     ;;
1727     --enable-debug=*) debuglevel="$optval"
1728     ;;
1729     --disable-everything)
1730     map 'eval unset \${$(toupper ${v%s})_LIST}' $COMPONENT_LIST
1731     ;;
1732     --enable-*=*|--disable-*=*)
1733     eval $(echo "${opt%%=*}" | sed 's/--/action=/;s/-/ thing=/')
1734     is_in "${thing}s" $COMPONENT_LIST || die_unknown "$opt"
1735     eval list=\$$(toupper $thing)_LIST
1736     name=$(echo "${optval}" | sed "s/,/_${thing}|/g")_${thing}
1737     $action $(filter "$name" $list)
1738     ;;
1739     --enable-?*|--disable-?*)
1740     eval $(echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g')
1741     if is_in $option $COMPONENT_LIST; then
1742         test $action = disable && action=unset
1743         eval $action \$$(toupper ${option%s})_LIST
1744     elif is_in $option $CMDLINE_SELECT; then
1745         $action $option
1746     else
1747         die_unknown $opt
1748     fi
1749     ;;
1750     --list-*)
1751         NAME="${opt#--list-}"
1752         is_in $NAME $COMPONENT_LIST || die_unknown $opt
1753         NAME=${NAME%s}
1754         eval show_list $NAME \$$(toupper $NAME)_LIST
1755     ;;
1756     --help|-h) show_help
1757     ;;
1758     *)
1759     optname="${opt%%=*}"
1760     optname="${optname#--}"
1761     optname=$(echo "$optname" | sed 's/-/_/g')
1762     if is_in $optname $CMDLINE_SET; then
1763         eval $optname='$optval'
1764     elif is_in $optname $CMDLINE_APPEND; then
1765         append $optname "$optval"
1766     else
1767          die_unknown $opt
1768     fi
1769     ;;
1770     esac
1771 done
1772
1773 disabled logging && logfile=/dev/null
1774
1775 echo "# $0 $FFMPEG_CONFIGURATION" > $logfile
1776 set >> $logfile
1777
1778 test -n "$cross_prefix" && enable cross_compile
1779
1780 if enabled cross_compile; then
1781     test -n "$arch" && test -n "$target_os" ||
1782         die "Must specify target arch and OS when cross-compiling"
1783 fi
1784
1785 set_default arch target_os
1786
1787 ar_default="${cross_prefix}${ar_default}"
1788 cc_default="${cross_prefix}${cc_default}"
1789 nm_default="${cross_prefix}${nm_default}"
1790 ranlib="${cross_prefix}${ranlib}"
1791 strip_default="${cross_prefix}${strip_default}"
1792
1793 sysinclude_default="${sysroot}/usr/include"
1794
1795 set_default cc nm strip sysinclude
1796 enabled cross_compile || host_cc_default=$cc
1797 set_default host_cc
1798
1799 exesuf() {
1800     case $1 in
1801         mingw32*|cygwin*|*-dos|freedos|opendos|os/2*) echo .exe ;;
1802     esac
1803 }
1804
1805 EXESUF=$(exesuf $target_os)
1806 HOSTEXESUF=$(exesuf $host_os)
1807
1808 # set temporary file name
1809 : ${TMPDIR:=$TEMPDIR}
1810 : ${TMPDIR:=$TMP}
1811 : ${TMPDIR:=/tmp}
1812
1813 if ! check_cmd mktemp -u XXXXXX; then
1814     # simple replacement for missing mktemp
1815     # NOT SAFE FOR GENERAL USE
1816     mktemp(){
1817         echo "${2%%XXX*}.${HOSTNAME}.${UID}.$$"
1818     }
1819 fi
1820
1821 tmpfile(){
1822     tmp=$(mktemp -u "${TMPDIR}/ffconf.XXXXXXXX")$2 &&
1823         (set -C; exec > $tmp) 2>/dev/null ||
1824         die "Unable to create temporary file in $TMPDIR."
1825     append TMPFILES $tmp
1826     eval $1=$tmp
1827 }
1828
1829 trap 'rm -f -- $TMPFILES' EXIT
1830
1831 tmpfile TMPC  .c
1832 tmpfile TMPE  $EXESUF
1833 tmpfile TMPH  .h
1834 tmpfile TMPO  .o
1835 tmpfile TMPS  .S
1836 tmpfile TMPV  .ver
1837 tmpfile TMPSH .sh
1838 tmpfile TMPASM .asm
1839
1840 unset -f mktemp
1841
1842 chmod +x $TMPE
1843
1844 # make sure we can execute files in $TMPDIR
1845 cat > $TMPSH 2>> $logfile <<EOF
1846 #! /bin/sh
1847 EOF
1848 chmod +x $TMPSH >> $logfile 2>&1
1849 if ! $TMPSH >> $logfile 2>&1; then
1850     cat <<EOF
1851 Unable to create and execute files in $TMPDIR.  Set the TMPDIR environment
1852 variable to another directory and make sure that it is not mounted noexec.
1853 EOF
1854     die "Sanity test failed."
1855 fi
1856
1857 filter_cflags=echo
1858 filter_cppflags=echo
1859 filter_asflags=echo
1860
1861 if   $cc -v 2>&1 | grep -q '^gcc.*LLVM'; then
1862     cc_type=llvm_gcc
1863     cc_version=__VERSION__
1864     gcc_extra_ver=$(expr "$($cc --version | head -n1)" : '.*\((.*)\)')
1865     cc_ident="llvm-gcc $($cc -dumpversion) $gcc_extra_ver"
1866     CC_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
1867     AS_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
1868     speed_cflags='-O3'
1869     size_cflags='-Os'
1870 elif $cc -v 2>&1 | grep -qi ^gcc; then
1871     cc_type=gcc
1872     cc_version=__VERSION__
1873     gcc_version=$($cc --version | head -n1)
1874     gcc_basever=$($cc -dumpversion)
1875     gcc_pkg_ver=$(expr "$gcc_version" : '[^ ]* \(([^)]*)\)')
1876     gcc_ext_ver=$(expr "$gcc_version" : ".*$gcc_pkg_ver $gcc_basever \\(.*\\)")
1877     cc_ident=$(cleanws "gcc $gcc_basever $gcc_pkg_ver $gcc_ext_ver")
1878     if ! $cc -dumpversion | grep -q '^2\.'; then
1879         CC_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
1880         AS_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
1881     fi
1882     speed_cflags='-O3'
1883     size_cflags='-Os'
1884 elif $cc --version 2>/dev/null | grep -q Intel; then
1885     cc_type=icc
1886     cc_version="AV_STRINGIFY(__INTEL_COMPILER)"
1887     cc_ident=$($cc --version | head -n1)
1888     icc_version=$($cc -dumpversion)
1889     CC_DEPFLAGS='-MMD'
1890     AS_DEPFLAGS='-MMD'
1891     speed_cflags='-O3'
1892     size_cflags='-Os'
1893     noopt_cflags='-O1'
1894 elif $cc -v 2>&1 | grep -q xlc; then
1895     cc_type=xlc
1896     cc_version="AV_STRINGIFY(__IBMC__)"
1897     cc_ident=$($cc -qversion 2>/dev/null | head -n1)
1898     speed_cflags='-O5'
1899     size_cflags='-O5 -qcompact'
1900 elif $cc -V 2>/dev/null | grep -q Compaq; then
1901     cc_type=ccc
1902     cc_version="AV_STRINGIFY(__DECC_VER)"
1903     cc_ident=$($cc -V | head -n1 | cut -d' ' -f1-3)
1904     DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -M'
1905     debuglevel=3
1906     add_ldflags -Wl,-z,now # calls to libots crash without this
1907     speed_cflags='-fast'
1908     size_cflags='-O1'
1909 elif $cc --vsn 2>/dev/null | grep -q "ARM C/C++ Compiler"; then
1910     test -d "$sysroot" || die "No valid sysroot specified."
1911     cc_type=armcc
1912     cc_version="AV_STRINGIFY(__ARMCC_VERSION)"
1913     cc_ident=$($cc --vsn | head -n1)
1914     armcc_conf="$PWD/armcc.conf"
1915     $cc --arm_linux_configure                 \
1916         --arm_linux_config_file="$armcc_conf" \
1917         --configure_sysroot="$sysroot"        \
1918         --configure_cpp_headers="$sysinclude" >>$logfile 2>&1 ||
1919         die "Error creating armcc configuration file."
1920     $cc --vsn | grep -q RVCT && armcc_opt=rvct || armcc_opt=armcc
1921     cc="$cc --arm_linux_config_file=$armcc_conf --translate_gcc"
1922     as_default="${cross_prefix}gcc"
1923     CC_DEPFLAGS='-MMD'
1924     AS_DEPFLAGS='-MMD'
1925     speed_cflags='-O3'
1926     size_cflags='-Os'
1927     filter_asflags="filter_out -W${armcc_opt}*"
1928 elif $cc -version 2>/dev/null | grep -q TMS470; then
1929     cc_type=tms470
1930     cc_version="AV_STRINGIFY(__TI_COMPILER_VERSION__)"
1931     cc_ident=$($cc -version | head -n1 | tr -s ' ')
1932     cc="$cc --gcc --abi=eabi -eo=.o -mc -me"
1933     CC_O='-fr=$(@D)'
1934     as_default="${cross_prefix}gcc"
1935     ld_default="${cross_prefix}gcc"
1936     TMPO=$(basename $TMPC .c).o
1937     append TMPFILES $TMPO
1938     add_cflags -D__gnuc_va_list=va_list -D__USER_LABEL_PREFIX__=
1939     CC_DEPFLAGS='-ppa -ppd=$(@:.o=.d)'
1940     AS_DEPFLAGS='-MMD'
1941     speed_cflags='-O3 -mf=5'
1942     size_cflags='-O3 -mf=2'
1943     filter_cflags=tms470_flags
1944     tms470_flags(){
1945         for flag; do
1946             case $flag in
1947                 -march=*|-mcpu=*)
1948                     case "${flag#*=}" in
1949                         armv7-a|cortex-a*)      echo -mv=7a8 ;;
1950                         armv7-r|cortex-r*)      echo -mv=7r4 ;;
1951                         armv7-m|cortex-m*)      echo -mv=7m3 ;;
1952                         armv6*|arm11*)          echo -mv=6   ;;
1953                         armv5*e|arm[79]*e*|arm9[24]6*|arm96*|arm102[26])
1954                                                 echo -mv=5e  ;;
1955                         armv4*|arm7*|arm9[24]*) echo -mv=4   ;;
1956                     esac
1957                     ;;
1958                 -mfpu=neon)     echo --float_support=vfpv3 --neon ;;
1959                 -mfpu=vfp)      echo --float_support=vfpv2        ;;
1960                 -mfpu=vfpv3)    echo --float_support=vfpv3        ;;
1961                 -msoft-float)   echo --float_support=vfplib       ;;
1962                 -O[0-3]|-mf=*)  echo $flag                        ;;
1963                 -g)             echo -g -mn                       ;;
1964                 -pds=*)         echo $flag                        ;;
1965             esac
1966         done
1967     }
1968 elif $cc -v 2>&1 | grep -q clang; then
1969     cc_type=clang
1970     $cc -dM -E $TMPC | grep -q __clang_version__ &&
1971         cc_version=__clang_version__ || cc_version=__VERSION__
1972     cc_ident=$($cc --version | head -n1)
1973     CC_DEPFLAGS='-MMD'
1974     AS_DEPFLAGS='-MMD'
1975     speed_cflags='-O3'
1976     size_cflags='-Os'
1977 elif $cc -V 2>&1 | grep -q Sun; then
1978     cc_type=suncc
1979     cc_version="AV_STRINGIFY(__SUNPRO_C)"
1980     cc_ident=$($cc -V 2>&1 | head -n1 | cut -d' ' -f 2-)
1981     DEPEND_CMD='$(DEPCC) $(DEPFLAGS) $< | sed -e "1s,^.*: ,$@: ," -e "\$$!s,\$$, \\\," -e "1!s,^.*: , ," > $(@:.o=.d)'
1982     DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -xM1'
1983     speed_cflags='-O5'
1984     size_cflags='-O5 -xspace'
1985     filter_cflags=suncc_flags
1986     suncc_flags(){
1987         for flag; do
1988             case $flag in
1989                 -march=*|-mcpu=*)
1990                     case "${flag#*=}" in
1991                         native)                   echo -xtarget=native       ;;
1992                         v9|niagara)               echo -xarch=sparc          ;;
1993                         ultrasparc)               echo -xarch=sparcvis       ;;
1994                         ultrasparc3|niagara2)     echo -xarch=sparcvis2      ;;
1995                         i586|pentium)             echo -xchip=pentium        ;;
1996                         i686|pentiumpro|pentium2) echo -xtarget=pentium_pro  ;;
1997                         pentium3*|c3-2)           echo -xtarget=pentium3     ;;
1998                         pentium-m)          echo -xarch=sse2 -xchip=pentium3 ;;
1999                         pentium4*)          echo -xtarget=pentium4           ;;
2000                         prescott|nocona)    echo -xarch=sse3 -xchip=pentium4 ;;
2001                         *-sse3)             echo -xarch=sse3                 ;;
2002                         core2)              echo -xarch=ssse3 -xchip=core2   ;;
2003                         amdfam10|barcelona)       echo -xarch=sse4_1         ;;
2004                         athlon-4|athlon-[mx]p)    echo -xarch=ssea           ;;
2005                         k8|opteron|athlon64|athlon-fx)
2006                                                   echo -xarch=sse2a          ;;
2007                         athlon*)                  echo -xarch=pentium_proa   ;;
2008                     esac
2009                     ;;
2010                 -std=c99)             echo -xc99              ;;
2011                 -fomit-frame-pointer) echo -xregs=frameptr    ;;
2012                 -fPIC)                echo -KPIC -xcode=pic32 ;;
2013                 -W*,*)                echo $flag              ;;
2014                 -f*-*|-W*)                                    ;;
2015                 *)                    echo $flag              ;;
2016             esac
2017         done
2018     }
2019 elif $cc -v 2>&1 | grep -q 'PathScale\|Path64'; then
2020     cc_type=pathscale
2021     cc_version=__PATHSCALE__
2022     cc_ident=$($cc -v 2>&1 | head -n1 | tr -d :)
2023     CC_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
2024     AS_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
2025     speed_cflags='-O2'
2026     size_cflags='-Os'
2027 elif $cc -v 2>&1 | grep -q Open64; then
2028     cc_type=open64
2029     cc_version=__OPEN64__
2030     cc_ident=$($cc -v 2>&1 | head -n1 | tr -d :)
2031     CC_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
2032     AS_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
2033     speed_cflags='-O2'
2034     size_cflags='-Os'
2035 fi
2036
2037 test -n "$cc_type" && enable $cc_type ||
2038     warn "Unknown C compiler $cc, unable to select optimal CFLAGS"
2039
2040 : ${as_default:=$cc}
2041 : ${dep_cc_default:=$cc}
2042 : ${ld_default:=$cc}
2043 set_default ar as dep_cc ld
2044
2045 test -n "$CC_DEPFLAGS" || CCDEP=$DEPEND_CMD
2046 test -n "$AS_DEPFLAGS" || ASDEP=$DEPEND_CMD
2047
2048 add_cflags $extra_cflags
2049 add_asflags $extra_cflags
2050
2051 if test -n "$sysroot"; then
2052     case "$cc_type" in
2053         gcc|llvm_gcc)
2054             add_cppflags --sysroot="$sysroot"
2055             add_ldflags --sysroot="$sysroot"
2056         ;;
2057         tms470)
2058             add_cppflags -I"$sysinclude"
2059             add_ldflags  --sysroot="$sysroot"
2060         ;;
2061         clang)
2062             add_cppflags -isysroot "$sysroot"
2063             add_ldflags -isysroot "$sysroot"
2064         ;;
2065     esac
2066 fi
2067
2068 if test "$cpu" = host; then
2069     enabled cross_compile && die "--cpu=host makes no sense when cross-compiling."
2070
2071     case "$cc_type" in
2072         gcc|llvm_gcc)
2073             check_native(){
2074                 $cc $1=native -v -c -o $TMPO $TMPC >$TMPE 2>&1 || return
2075                 sed -n "/$1=/{
2076                             s/.*$1=\\([^ ]*\\).*/\\1/
2077                             p
2078                             q
2079                         }" $TMPE
2080             }
2081             cpu=$(check_native -march || check_native -mcpu)
2082         ;;
2083     esac
2084
2085     test "${cpu:-host}" = host && die "--cpu=host not supported with compiler $cc"
2086 fi
2087
2088 # Deal with common $arch aliases
2089 case "$arch" in
2090     arm*)
2091         arch="arm"
2092     ;;
2093     mips|mipsel|IP*)
2094         arch="mips"
2095     ;;
2096     mips64*)
2097         arch="mips"
2098         subarch="mips64"
2099     ;;
2100     parisc|hppa)
2101         arch="parisc"
2102     ;;
2103     parisc64|hppa64)
2104         arch="parisc"
2105         subarch="parisc64"
2106     ;;
2107     "Power Macintosh"|ppc|powerpc)
2108         arch="ppc"
2109     ;;
2110     ppc64|powerpc64)
2111         arch="ppc"
2112         subarch="ppc64"
2113     ;;
2114     s390|s390x)
2115         arch="s390"
2116     ;;
2117     sh4|sh)
2118         arch="sh4"
2119     ;;
2120     sun4u|sparc64)
2121         arch="sparc"
2122         subarch="sparc64"
2123     ;;
2124     i[3-6]86|i86pc|BePC|x86pc|x86_64|amd64)
2125         arch="x86"
2126     ;;
2127 esac
2128
2129 is_in $arch $ARCH_LIST || warn "unknown architecture $arch"
2130 enable $arch
2131
2132 # Add processor-specific flags
2133 if test "$cpu" = generic; then
2134     : do nothing
2135 elif enabled ppc; then
2136
2137     case $(tolower $cpu) in
2138         601|ppc601|powerpc601)
2139             cpuflags="-mcpu=601"
2140             disable altivec
2141         ;;
2142         603*|ppc603*|powerpc603*)
2143             cpuflags="-mcpu=603"
2144             disable altivec
2145         ;;
2146         604*|ppc604*|powerpc604*)
2147             cpuflags="-mcpu=604"
2148             disable altivec
2149         ;;
2150         g3|75*|ppc75*|powerpc75*)
2151             cpuflags="-mcpu=750 -mpowerpc-gfxopt"
2152             disable altivec
2153         ;;
2154         g4|745*|ppc745*|powerpc745*)
2155             cpuflags="-mcpu=7450 -mpowerpc-gfxopt"
2156         ;;
2157         74*|ppc74*|powerpc74*)
2158             cpuflags="-mcpu=7400 -mpowerpc-gfxopt"
2159         ;;
2160         g5|970|ppc970|powerpc970|power4*)
2161             cpuflags="-mcpu=970 -mpowerpc-gfxopt -mpowerpc64"
2162         ;;
2163         cell)
2164             cpuflags="-mcpu=cell"
2165             enable ldbrx
2166         ;;
2167         e500v2)
2168             cpuflags="-mcpu=8548 -mhard-float -mfloat-gprs=double"
2169             disable altivec
2170         ;;
2171         e500)
2172             cpuflags="-mcpu=8540 -mhard-float"
2173             disable altivec
2174         ;;
2175     esac
2176
2177 elif enabled x86; then
2178
2179     case $cpu in
2180         i[345]86|pentium)
2181             cpuflags="-march=$cpu"
2182             disable mmx
2183         ;;
2184         # targets that do NOT support conditional mov (cmov)
2185         pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
2186             cpuflags="-march=$cpu"
2187             disable cmov
2188         ;;
2189         # targets that do support conditional mov (cmov)
2190         i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64|k8|opteron|athlon-fx|core2|amdfam10|barcelona|atom)
2191             cpuflags="-march=$cpu"
2192             enable cmov
2193             enable fast_cmov
2194         ;;
2195         # targets that do support conditional mov but on which it's slow
2196         pentium4|pentium4m|prescott|nocona)
2197             cpuflags="-march=$cpu"
2198             enable cmov
2199             disable fast_cmov
2200         ;;
2201     esac
2202
2203 elif enabled sparc; then
2204
2205     case $cpu in
2206         niagara)
2207             cpuflags="-mcpu=$cpu"
2208             disable vis
2209         ;;
2210         sparc64)
2211             cpuflags="-mcpu=v9"
2212         ;;
2213     esac
2214
2215 elif enabled arm; then
2216
2217     case $cpu in
2218         armv*)
2219             cpuflags="-march=$cpu"
2220             subarch=$(echo $cpu | sed 's/[^a-z0-9]//g')
2221         ;;
2222         *)
2223             cpuflags="-mcpu=$cpu"
2224             case $cpu in
2225                 cortex-a*)                               subarch=armv7a  ;;
2226                 cortex-r*)                               subarch=armv7r  ;;
2227                 cortex-m*)                               subarch=armv7m  ;;
2228                 arm11*)                                  subarch=armv6   ;;
2229                 arm[79]*e*|arm9[24]6*|arm96*|arm102[26]) subarch=armv5te ;;
2230                 armv4*|arm7*|arm9[24]*)                  subarch=armv4   ;;
2231             esac
2232         ;;
2233     esac
2234
2235 elif enabled alpha; then
2236
2237     enabled ccc && cpuflags="-arch $cpu" || cpuflags="-mcpu=$cpu"
2238
2239 elif enabled bfin; then
2240
2241     cpuflags="-mcpu=$cpu"
2242
2243 elif enabled mips; then
2244
2245     cpuflags="-march=$cpu"
2246
2247 elif enabled avr32; then
2248
2249     case $cpu in
2250         ap7[02]0[0-2])
2251             subarch="avr32_ap"
2252             cpuflags="-mpart=$cpu"
2253         ;;
2254         ap)
2255             subarch="avr32_ap"
2256             cpuflags="-march=$cpu"
2257         ;;
2258         uc3[ab]*)
2259             subarch="avr32_uc"
2260             cpuflags="-mcpu=$cpu"
2261         ;;
2262         uc)
2263             subarch="avr32_uc"
2264             cpuflags="-march=$cpu"
2265         ;;
2266     esac
2267
2268 fi
2269
2270 add_cflags $cpuflags
2271 add_asflags $cpuflags
2272
2273 # compiler sanity check
2274 check_exec <<EOF
2275 int main(void){ return 0; }
2276 EOF
2277 if test "$?" != 0; then
2278     echo "$cc is unable to create an executable file."
2279     if test -z "$cross_prefix" && ! enabled cross_compile ; then
2280         echo "If $cc is a cross-compiler, use the --enable-cross-compile option."
2281         echo "Only do this if you know what cross compiling means."
2282     fi
2283     die "C compiler test failed."
2284 fi
2285
2286 add_cppflags -D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112
2287 check_cflags -std=c99
2288 check_cc -D_FILE_OFFSET_BITS=64 <<EOF && add_cppflags -D_FILE_OFFSET_BITS=64
2289 #include <stdlib.h>
2290 EOF
2291 check_cc -D_LARGEFILE_SOURCE <<EOF && add_cppflags -D_LARGEFILE_SOURCE
2292 #include <stdlib.h>
2293 EOF
2294
2295 check_host_cflags -std=c99
2296
2297 case "$arch" in
2298     alpha|ia64|mips|parisc|sparc)
2299         spic=$shared
2300     ;;
2301     x86)
2302         subarch="x86_32"
2303         check_cc <<EOF && subarch="x86_64"
2304         int test[(int)sizeof(char*) - 7];
2305 EOF
2306         if test "$subarch" = "x86_64"; then
2307             spic=$shared
2308         fi
2309     ;;
2310 esac
2311
2312 enable $subarch
2313 enabled spic && enable pic
2314
2315 # OS specific
2316 case $target_os in
2317     haiku)
2318         prefix_default="/boot/common"
2319         network_extralibs="-lnetwork"
2320         host_libs=
2321         ;;
2322     sunos)
2323         FFSERVERLDFLAGS=""
2324         SHFLAGS='-shared -Wl,-h,$$(@F)'
2325         enabled x86 && SHFLAGS="-mimpure-text $SHFLAGS"
2326         network_extralibs="-lsocket -lnsl"
2327         add_cppflags -D__EXTENSIONS__
2328         nm_opts='-P -g'
2329         ;;
2330     netbsd)
2331         disable symver
2332         oss_indev_extralibs="-lossaudio"
2333         oss_outdev_extralibs="-lossaudio"
2334         add_cppflags -D_XOPEN_SOURCE=600
2335         ;;
2336     openbsd)
2337         enable malloc_aligned
2338         # On OpenBSD 4.5. the compiler does not use PIC unless
2339         # explicitly using -fPIC. FFmpeg builds fine without PIC,
2340         # however the generated executable will not do anything
2341         # (simply quits with exit-code 1, no crash, no output).
2342         # Thus explicitly enable PIC here.
2343         enable pic
2344         disable symver
2345         SHFLAGS='-shared'
2346         oss_indev_extralibs="-lossaudio"
2347         oss_outdev_extralibs="-lossaudio"
2348         ;;
2349     dragonfly)
2350         enable malloc_aligned
2351         disable symver
2352         ;;
2353     freebsd)
2354         enable malloc_aligned
2355         ;;
2356     bsd/os)
2357         add_extralibs -lpoll -lgnugetopt
2358         strip="strip -d"
2359         ;;
2360     darwin)
2361         enable malloc_aligned
2362         gas="gas-preprocessor.pl $cc"
2363         enabled ppc && add_asflags -force_cpusubtype_ALL
2364         SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(SHLIBDIR)/$(SLIBNAME),-current_version,$(LIBVERSION),-compatibility_version,$(LIBMAJOR) -Wl,-read_only_relocs,suppress'
2365         strip="${strip} -x"
2366         add_ldflags -Wl,-dynamic,-search_paths_first
2367         SLIBSUF=".dylib"
2368         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME).$(LIBVERSION)$(SLIBSUF)'
2369         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME).$(LIBMAJOR)$(SLIBSUF)'
2370         FFSERVERLDFLAGS=-Wl,-bind_at_load
2371         objformat="macho"
2372         enabled x86_64 && objformat="macho64"
2373         enabled_any pic shared ||
2374             { check_cflags -mdynamic-no-pic && add_asflags -mdynamic-no-pic; }
2375         ;;
2376     mingw32*)
2377         if test $target_os = "mingw32ce"; then
2378             disable network
2379         else
2380             target_os=mingw32
2381         fi
2382         LIBTARGET=i386
2383         if enabled x86_64; then
2384             enable malloc_aligned
2385             LIBTARGET=x64
2386         elif enabled arm; then
2387             LIBTARGET=arm
2388         fi
2389         shlibdir_default="$bindir_default"
2390         disable ffserver
2391         SLIBPREF=""
2392         SLIBSUF=".dll"
2393         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
2394         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
2395         SLIB_EXTRA_CMD='-lib.exe /machine:$(LIBTARGET) /def:$$(@:$(SLIBSUF)=.def) /out:$(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)'
2396         SLIB_INSTALL_EXTRA_CMD='-install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"; \
2397             install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)"; \
2398             install -d "$(LIBDIR)"; \
2399             install -m 644 $(SUBDIR)lib$(SLIBNAME:$(SLIBSUF)=.dll.a) "$(LIBDIR)/lib$(SLIBNAME:$(SLIBSUF)=.dll.a)"'
2400         SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"'
2401         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'
2402         objformat="win32"
2403         enable dos_paths
2404         check_cflags -fno-common
2405         check_cpp_condition _mingw.h "defined (__MINGW64_VERSION_MAJOR) || (__MINGW32_MAJOR_VERSION > 3) \
2406                                       || (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" ||
2407                 die "ERROR: MinGW runtime version must be >= 3.15."
2408         ;;
2409     cygwin*)
2410         target_os=cygwin
2411         shlibdir_default="$bindir_default"
2412         SLIBPREF="cyg"
2413         SLIBSUF=".dll"
2414         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
2415         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
2416         SHFLAGS='-shared -Wl,--enable-auto-image-base'
2417         objformat="win32"
2418         enable dos_paths
2419         check_cflags -fno-common
2420         ;;
2421     *-dos|freedos|opendos)
2422         disable ffplay ffserver
2423         disable $INDEV_LIST $OUTDEV_LIST
2424         network_extralibs="-lsocket"
2425         objformat="coff"
2426         enable dos_paths
2427         ;;
2428     linux)
2429         enable dv1394
2430         ;;
2431     irix*)
2432         target_os=irix
2433         ranlib="echo ignoring ranlib"
2434         ;;
2435     os/2*)
2436         strip="lxlite"
2437         ln_s="cp -f"
2438         add_ldflags -Zomf -Zbin-files -Zargs-wild -Zmap
2439         SHFLAGS='$(SUBDIR)$(NAME).def -Zdll -Zomf'
2440         FFSERVERLDFLAGS=""
2441         LIBSUF="_s.a"
2442         SLIBPREF=""
2443         SLIBSUF=".dll"
2444         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
2445         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(shell echo $(NAME) | cut -c1-6)$(LIBMAJOR)$(SLIBSUF)'
2446         SLIB_CREATE_DEF_CMD='echo LIBRARY $(SLIBNAME_WITH_MAJOR) INITINSTANCE TERMINSTANCE > $(SUBDIR)$(NAME).def; \
2447           echo PROTMODE >> $(SUBDIR)$(NAME).def; \
2448           echo CODE PRELOAD MOVEABLE DISCARDABLE >> $(SUBDIR)$(NAME).def; \
2449           echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $(SUBDIR)$(NAME).def; \
2450           echo EXPORTS >> $(SUBDIR)$(NAME).def; \
2451           emxexp -o $(OBJS) >> $(SUBDIR)$(NAME).def'
2452         SLIB_EXTRA_CMD='emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(NAME).def; \
2453           emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib $(SUBDIR)$(NAME).def;'
2454         SLIB_INSTALL_EXTRA_CMD='install -m 644 $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib "$(LIBDIR)"'
2455         SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.a "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.lib'
2456         enable dos_paths
2457         ;;
2458     gnu/kfreebsd)
2459         ;;
2460     gnu)
2461         ;;
2462     qnx)
2463         add_cppflags -D_QNX_SOURCE
2464         network_extralibs="-lsocket"
2465         ;;
2466     none)
2467         ;;
2468     *)
2469         die "Unknown OS '$target_os'."
2470         ;;
2471 esac
2472
2473 echo "config:$arch:$subarch:$cpu:$target_os:$cc_ident:$FFMPEG_CONFIGURATION" >config.fate
2474
2475 check_cpp_condition stdlib.h "defined(__PIC__) || defined(__pic__) || defined(PIC)" && enable pic
2476
2477 set_default $PATHS_LIST
2478
2479 # we need to build at least one lib type
2480 if ! enabled_any static shared; then
2481     cat <<EOF
2482 At least one library type must be built.
2483 Specify --enable-static to build the static libraries or --enable-shared to
2484 build the shared libraries as well. To only build the shared libraries specify
2485 --disable-static in addition to --enable-shared.
2486 EOF
2487     exit 1;
2488 fi
2489
2490 disabled static && LIBNAME=""
2491
2492 die_license_disabled() {
2493     enabled $1 || { enabled $2 && die "$2 is $1 and --enable-$1 is not specified."; }
2494 }
2495
2496 die_license_disabled gpl libx264
2497 die_license_disabled gpl libxavs
2498 die_license_disabled gpl libxvid
2499 die_license_disabled gpl postproc
2500 die_license_disabled gpl x11grab
2501
2502 die_license_disabled nonfree libfaac
2503
2504 die_license_disabled version3 libopencore_amrnb
2505 die_license_disabled version3 libopencore_amrwb
2506
2507 enabled version3 && { enabled gpl && enable gplv3 || enable lgplv3; }
2508
2509 disabled optimizations || check_cflags -fomit-frame-pointer
2510
2511 enable_pic() {
2512     enable pic
2513     add_cppflags -DPIC
2514     add_cflags   -fPIC
2515     add_asflags  -fPIC
2516 }
2517
2518 enabled pic && enable_pic
2519
2520 check_cc <<EOF || die "Symbol mangling check failed."
2521 int ff_extern;
2522 EOF
2523 sym=$($nm $nm_opts $TMPO | awk '/ff_extern/{ print substr($0, match($0, /[^ \t]*ff_extern/)) }')
2524 extern_prefix=${sym%%ff_extern*}
2525
2526 check_cc <<EOF && enable inline_asm
2527 void foo(void) { __asm__ volatile ("" ::); }
2528 EOF
2529
2530 _restrict=
2531 for restrict_keyword in restrict __restrict__ __restrict; do
2532     check_cc <<EOF && _restrict=$restrict_keyword && break
2533 void foo(char * $restrict_keyword p);
2534 EOF
2535 done
2536
2537 check_cc <<EOF && enable attribute_packed
2538 struct { int x; } __attribute__((packed)) x;
2539 EOF
2540
2541 check_cc <<EOF && enable attribute_may_alias
2542 union { int x; } __attribute__((may_alias)) x;
2543 EOF
2544
2545 check_cc <<EOF || die "endian test failed"
2546 unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
2547 EOF
2548 od -t x1 $TMPO | grep -q '42 *49 *47 *45' && enable bigendian
2549
2550 if enabled alpha; then
2551
2552     check_cflags -mieee
2553
2554 elif enabled arm; then
2555
2556     check_cflags -marm
2557     nogas=die
2558
2559     if     check_cpp_condition stddef.h "defined __ARM_PCS_VFP"; then
2560         enable vfp_args
2561     elif ! check_cpp_condition stddef.h "defined __ARM_PCS || defined __SOFTFP__"; then
2562         case "${cross_prefix:-$cc}" in
2563             *hardfloat*)         enable vfp_args;   fpabi=vfp ;;
2564             *) check_ld <<EOF && enable vfp_args && fpabi=vfp || fpabi=soft ;;
2565 __asm__ (".eabi_attribute 28, 1");
2566 int main(void) { return 0; }
2567 EOF
2568         esac
2569         warn "Compiler does not indicate floating-point ABI, guessing $fpabi."
2570     fi
2571
2572     # We have to check if pld is a nop and disable it.
2573     check_asm pld '"pld [r0]"'
2574
2575     enabled armv5te && check_asm armv5te '"qadd r0, r0, r0"'
2576     enabled armv6   && check_asm armv6   '"sadd16 r0, r0, r0"'
2577     enabled armv6t2 && check_asm armv6t2 '"movt r0, #0"'
2578     enabled armvfp  && check_asm armvfp  '"fadds s0, s0, s0"'
2579     enabled iwmmxt  && check_asm iwmmxt  '"wunpckelub wr6, wr4"'
2580     enabled neon    && check_asm neon    '"vadd.i16 q0, q0, q0"'
2581
2582     enabled_all armv6t2 shared !pic && enable_pic
2583
2584 elif enabled mips; then
2585
2586     check_asm loongson '"dmult.g $1, $2, $3"'
2587     enabled mmi     && check_asm mmi     '"lq $2, 0($2)"'
2588
2589 elif enabled ppc; then
2590
2591     enable local_aligned_8 local_aligned_16
2592
2593     check_asm dcbzl     '"dcbzl 0, %0" :: "r"(0)'
2594     check_asm ibm_asm   '"add 0, 0, 0"'
2595     check_asm ppc4xx    '"maclhw r10, r11, r12"'
2596     check_asm xform_asm '"lwzx %1, %y0" :: "Z"(*(int*)0), "r"(0)'
2597
2598     # AltiVec flags: The FSF version of GCC differs from the Apple version
2599     if enabled altivec; then
2600         nogas=warn
2601         check_cflags -maltivec -mabi=altivec &&
2602         { check_header altivec.h && inc_altivec_h="#include <altivec.h>" ; } ||
2603         check_cflags -faltivec
2604
2605         # check if our compiler supports Motorola AltiVec C API
2606         check_cc <<EOF || disable altivec
2607 $inc_altivec_h
2608 int main(void) {
2609     vector signed int v1, v2, v3;
2610     v1 = vec_add(v2,v3);
2611     return 0;
2612 }
2613 EOF
2614
2615         # check if our compiler supports braces for vector declarations
2616         check_cc <<EOF || die "You need a compiler that supports {} in AltiVec vector declarations."
2617 $inc_altivec_h
2618 int main (void) { (vector int) {1}; return 0; }
2619 EOF
2620     fi
2621
2622 elif enabled sparc; then
2623
2624     enabled vis && check_asm vis '"pdist %f0, %f0, %f0"' -mcpu=ultrasparc &&
2625         add_cflags -mcpu=ultrasparc -mtune=ultrasparc
2626
2627 elif enabled x86; then
2628
2629     enable local_aligned_8 local_aligned_16
2630
2631     # check whether EBP is available on x86
2632     # As 'i' is stored on the stack, this program will crash
2633     # if the base pointer is used to access it because the
2634     # base pointer is cleared in the inline assembly code.
2635     check_exec_crash <<EOF && enable ebp_available
2636     volatile int i=0;
2637     __asm__ volatile (
2638         "xorl %%ebp, %%ebp"
2639     ::: "%ebp");
2640     return i;
2641 EOF
2642
2643     # check whether EBX is available on x86
2644     check_asm ebx_available '""::"b"(0)' &&
2645         check_asm ebx_available '"":::"%ebx"'
2646
2647     # check whether xmm clobbers are supported
2648     check_asm xmm_clobbers '"":::"%xmm0"'
2649
2650     # check whether more than 10 operands are supported
2651     check_cc <<EOF && enable ten_operands
2652 int main(void) {
2653     int x=0;
2654     __asm__ volatile(
2655         ""
2656         :"+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x)
2657     );
2658     return 0;
2659 }
2660 EOF
2661
2662     # check whether binutils is new enough to compile SSSE3/MMX2
2663     enabled ssse3 && check_asm ssse3 '"pabsw %xmm0, %xmm0"'
2664     enabled mmx2  && check_asm mmx2  '"pmaxub %mm0, %mm1"'
2665
2666     check_asm bswap '"bswap %%eax" ::: "%eax"'
2667
2668     if ! disabled_any asm mmx yasm; then
2669         if check_cmd $yasmexe --version; then
2670             enabled x86_64 && yasm_extra="-m amd64"
2671             yasm_debug="-g dwarf2"
2672         elif check_cmd nasm -v; then
2673             yasmexe=nasm
2674             yasm_debug="-g -F dwarf"
2675             enabled x86_64 && test "$objformat" = elf && objformat=elf64
2676         fi
2677
2678         YASMFLAGS="-f $objformat $yasm_extra"
2679         enabled pic               && append YASMFLAGS "-DPIC"
2680         test -n "$extern_prefix"  && append YASMFLAGS "-DPREFIX"
2681         case "$objformat" in
2682             elf*) enabled debug && append YASMFLAGS $yasm_debug ;;
2683         esac
2684
2685         check_yasm "pextrd [eax], xmm0, 1" && enable yasm ||
2686             die "yasm not found, use --disable-yasm for a crippled build"
2687         check_yasm "vpaddw xmm0, xmm0, xmm0" || disable avx
2688     fi
2689
2690     case "$cpu" in
2691         athlon*|opteron*|k8*|pentium|pentium-mmx|prescott|nocona|atom|geode)
2692             disable fast_clz
2693         ;;
2694     esac
2695
2696 fi
2697
2698 if enabled asm; then
2699     as=${gas:=$as}
2700     check_asm gnu_as '".macro m n\n\\n:.int 0\n.endm\nm x"' ||
2701         $nogas "GNU assembler not found, install gas-preprocessor"
2702 fi
2703
2704 if check_func dlopen; then
2705     ldl=
2706 elif check_func dlopen -ldl; then
2707     ldl=-ldl
2708 fi
2709
2710 if enabled network; then
2711     check_type "sys/types.h sys/socket.h" socklen_t
2712     check_type netdb.h "struct addrinfo"
2713     check_type netinet/in.h "struct ipv6_mreq" -D_DARWIN_C_SOURCE
2714     check_type netinet/in.h "struct sockaddr_in6"
2715     check_type "sys/types.h sys/socket.h" "struct sockaddr_storage"
2716     check_struct "sys/types.h sys/socket.h" "struct sockaddr" sa_len
2717     # Prefer arpa/inet.h over winsock2
2718     if check_header arpa/inet.h ; then
2719         check_func closesocket
2720     elif check_header winsock2.h ; then
2721         check_func_headers winsock2.h closesocket -lws2 && \
2722             network_extralibs="-lws2" || \
2723         { check_func_headers winsock2.h closesocket -lws2_32 && \
2724             network_extralibs="-lws2_32"; }
2725         check_type ws2tcpip.h socklen_t
2726         check_type ws2tcpip.h "struct addrinfo"
2727         check_type ws2tcpip.h "struct ipv6_mreq"
2728         check_type ws2tcpip.h "struct sockaddr_in6"
2729         check_type ws2tcpip.h "struct sockaddr_storage"
2730         check_struct winsock2.h "struct sockaddr" sa_len
2731     else
2732         disable network
2733     fi
2734 fi
2735
2736 # Solaris has nanosleep in -lrt, OpenSolaris no longer needs that
2737 check_func nanosleep || { check_func nanosleep -lrt && add_extralibs -lrt; }
2738
2739 check_func  fcntl
2740 check_func  fork
2741 check_func  getaddrinfo $network_extralibs
2742 check_func  gethrtime
2743 check_func  getrusage
2744 check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss
2745 check_func  inet_aton $network_extralibs
2746 check_func  isatty
2747 check_func  localtime_r
2748 check_func  ${malloc_prefix}memalign            && enable memalign
2749 check_func  mkstemp
2750 check_func  mmap
2751 check_func  ${malloc_prefix}posix_memalign      && enable posix_memalign
2752 check_func  setrlimit
2753 check_func  strerror_r
2754 check_func  strtok_r
2755 check_func_headers io.h setmode
2756 check_func_headers lzo/lzo1x.h lzo1x_999_compress
2757 check_lib2 "windows.h psapi.h" GetProcessMemoryInfo -lpsapi
2758 check_func_headers windows.h GetProcessTimes
2759 check_func_headers windows.h MapViewOfFile
2760 check_func_headers windows.h VirtualAlloc
2761
2762 check_header conio.h
2763 check_header dlfcn.h
2764 check_header dxva2api.h
2765 check_header malloc.h
2766 check_header poll.h
2767 check_header sys/mman.h
2768 check_header sys/resource.h
2769 check_header sys/select.h
2770 check_header termios.h
2771 check_header vdpau/vdpau.h
2772 check_header vdpau/vdpau_x11.h
2773 check_header X11/extensions/XvMClib.h
2774
2775 check_struct dxva2api.h DXVA_PictureParameters wDecodedPictureIndex
2776
2777 if ! enabled_any memalign memalign_hack posix_memalign malloc_aligned &&
2778      enabled_any $need_memalign ; then
2779     die "Error, no aligned memory allocator but SSE enabled, disable it or use --enable-memalign-hack."
2780 fi
2781
2782 disabled  zlib || check_lib   zlib.h      zlibVersion -lz   || disable  zlib
2783 disabled bzlib || check_lib2 bzlib.h BZ2_bzlibVersion -lbz2 || disable bzlib
2784
2785 # check for some common methods of building with pthread support
2786 # do this before the optional library checks as some of them require pthreads
2787 if ! disabled pthreads && ! enabled w32threads; then
2788     enable pthreads
2789     if check_func pthread_create; then
2790         :
2791     elif check_func pthread_create -pthread; then
2792         add_cflags -pthread
2793         add_extralibs -pthread
2794     elif check_func pthread_create -pthreads; then
2795         add_cflags -pthreads
2796         add_extralibs -pthreads
2797     elif check_func pthread_create -lpthreadGC2; then
2798         add_extralibs -lpthreadGC2
2799     elif ! check_lib pthread.h pthread_create -lpthread; then
2800         disable pthreads
2801     fi
2802 fi
2803
2804 for thread in $THREADS_LIST; do
2805     if enabled $thread; then
2806         test -n "$thread_type" &&
2807             die "ERROR: Only one thread type must be selected." ||
2808             thread_type="$thread"
2809     fi
2810 done
2811
2812 check_lib math.h sin -lm
2813 disabled vaapi || check_lib va/va.h vaInitialize -lva
2814
2815 check_mathfunc exp2
2816 check_mathfunc exp2f
2817 check_mathfunc llrint
2818 check_mathfunc llrintf
2819 check_mathfunc log2
2820 check_mathfunc log2f
2821 check_mathfunc lrint
2822 check_mathfunc lrintf
2823 check_mathfunc round
2824 check_mathfunc roundf
2825 check_mathfunc truncf
2826
2827 # these are off by default, so fail if requested and not available
2828 enabled avisynth   && require2 vfw32 "windows.h vfw.h" AVIFileInit -lavifil32
2829 enabled frei0r     && { check_header frei0r.h || die "ERROR: frei0r.h header not found"; }
2830 enabled libdirac   && add_cflags $(pkg-config --cflags dirac) &&
2831                       require  libdirac libdirac_decoder/dirac_parser.h dirac_decoder_init $(pkg-config --libs dirac) &&
2832                       require  libdirac libdirac_encoder/dirac_encoder.h dirac_encoder_init $(pkg-config --libs dirac)
2833 enabled libfaac    && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
2834 enabled libfreetype && add_cflags $(pkg-config --cflags freetype2) && require libfreetype ft2build.h FT_Init_FreeType -lfreetype
2835 enabled libgsm     && require  libgsm gsm/gsm.h gsm_create -lgsm
2836 enabled libmp3lame && require  "libmp3lame >= 3.98.3" lame/lame.h lame_set_VBR_quality -lmp3lame
2837 enabled libnut     && require  libnut libnut.h nut_demuxer_init -lnut
2838 enabled libopencore_amrnb  && require libopencore_amrnb opencore-amrnb/interf_dec.h Decoder_Interface_init -lopencore-amrnb
2839 enabled libopencore_amrwb  && require libopencore_amrwb opencore-amrwb/dec_if.h D_IF_init -lopencore-amrwb
2840 enabled libopencv  && { check_lib opencv/cv.h cvCreateImageHeader $(pkg-config --libs opencv) ||
2841                         die "ERROR: libopencv not found"; }
2842 enabled libopenjpeg && require libopenjpeg openjpeg.h opj_version -lopenjpeg
2843 enabled librtmp    && { check_lib librtmp/rtmp.h RTMP_Socket $(pkg-config --libs librtmp) ||
2844                         die "ERROR: librtmp not found or RTMP_Socket() missing, librtmp version must be >= 2.2.f"; }
2845 enabled libschroedinger && add_cflags $(pkg-config --cflags schroedinger-1.0) &&
2846                            require libschroedinger schroedinger/schro.h schro_init $(pkg-config --libs schroedinger-1.0)
2847 enabled libspeex   && require  libspeex speex/speex.h speex_decoder_init -lspeex
2848 enabled libtheora  && require  libtheora theora/theoraenc.h th_info_init -ltheoraenc -ltheoradec -logg
2849 enabled libvorbis  && require  libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
2850 enabled libvpx     && {
2851     enabled libvpx_decoder && { check_lib2 "vpx/vpx_decoder.h vpx/vp8dx.h" vpx_codec_dec_init_ver -lvpx ||
2852                                 die "ERROR: libvpx decoder version must be >=0.9.1"; }
2853     enabled libvpx_encoder && { check_lib2 "vpx/vpx_encoder.h vpx/vp8cx.h" vpx_codec_enc_init_ver -lvpx ||
2854                                 die "ERROR: libvpx encoder version must be >=0.9.1"; } }
2855 enabled libx264    && require  libx264 x264.h x264_encoder_encode -lx264 &&
2856                       { check_cpp_condition x264.h "X264_BUILD >= 99" ||
2857                         die "ERROR: libx264 version must be >= 0.99."; }
2858 enabled libxavs    && require  libxavs xavs.h xavs_encoder_encode -lxavs
2859 enabled libxvid    && require  libxvid xvid.h xvid_global -lxvidcore
2860 enabled mlib       && require  mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
2861
2862 # libdc1394 check
2863 if enabled libdc1394; then
2864     { check_lib dc1394/dc1394.h dc1394_new -ldc1394 -lraw1394 &&
2865         enable libdc1394_2; } ||
2866     { check_lib libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394 &&
2867         enable libdc1394_1; } ||
2868     die "ERROR: No version of libdc1394 found "
2869 fi
2870
2871 SDL_CONFIG="${cross_prefix}sdl-config"
2872 if "${SDL_CONFIG}" --version > /dev/null 2>&1; then
2873     sdl_cflags=$("${SDL_CONFIG}" --cflags)
2874     sdl_libs=$("${SDL_CONFIG}" --libs)
2875     check_func_headers SDL.h SDL_Init $sdl_cflags $sdl_libs &&
2876     check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x010201" $sdl_cflags &&
2877     enable sdl &&
2878     check_struct SDL.h SDL_VideoInfo current_w $sdl_cflags && enable sdl_video_size
2879 fi
2880
2881 texi2html -version > /dev/null 2>&1 && enable texi2html || disable texi2html
2882
2883 check_header linux/videodev.h
2884 check_header linux/videodev2.h
2885 check_header sys/videoio.h
2886
2887 check_func_headers "windows.h vfw.h" capCreateCaptureWindow "$vfwcap_indev_extralibs"
2888 # check that WM_CAP_DRIVER_CONNECT is defined to the proper value
2889 # w32api 3.12 had it defined wrong
2890 check_cpp_condition vfw.h "WM_CAP_DRIVER_CONNECT > WM_USER" && enable vfwcap_defines
2891
2892 # check for ioctl_meteor.h, ioctl_bt848.h and alternatives
2893 { check_header dev/bktr/ioctl_meteor.h &&
2894   check_header dev/bktr/ioctl_bt848.h; } ||
2895 { check_header machine/ioctl_meteor.h &&
2896   check_header machine/ioctl_bt848.h; } ||
2897 { check_header dev/video/meteor/ioctl_meteor.h &&
2898   check_header dev/video/bktr/ioctl_bt848.h; } ||
2899 check_header dev/ic/bt8xx.h
2900
2901 check_header sys/soundcard.h
2902 check_header soundcard.h
2903
2904 enabled_any alsa_indev alsa_outdev && check_lib2 alsa/asoundlib.h snd_pcm_htimestamp -lasound
2905
2906 enabled jack_indev && check_lib2 jack/jack.h jack_client_open -ljack
2907
2908 enabled x11grab                         &&
2909 check_header X11/Xlib.h                 &&
2910 check_header X11/extensions/XShm.h      &&
2911 check_header X11/extensions/Xfixes.h    &&
2912 check_func XOpenDisplay -lX11           &&
2913 check_func XShmCreateImage -lX11 -lXext &&
2914 check_func XFixesGetCursorImage -lX11 -lXext -lXfixes
2915
2916 if ! disabled vdpau && enabled vdpau_vdpau_h; then
2917 check_cpp_condition \
2918     vdpau/vdpau.h "defined VDP_DECODER_PROFILE_MPEG4_PART2_ASP" ||
2919     { echolog "Please upgrade to libvdpau >= 0.2 if you would like vdpau support." &&
2920       disable vdpau; }
2921 fi
2922
2923 enabled debug && add_cflags -g"$debuglevel" && add_asflags -g"$debuglevel"
2924
2925 # add some useful compiler flags if supported
2926 check_cflags -Wdeclaration-after-statement
2927 check_cflags -Wall
2928 check_cflags -Wno-parentheses
2929 check_cflags -Wno-switch
2930 check_cflags -Wdisabled-optimization
2931 check_cflags -Wpointer-arith
2932 check_cflags -Wredundant-decls
2933 check_cflags -Wno-pointer-sign
2934 check_cflags -Wcast-qual
2935 check_cflags -Wwrite-strings
2936 check_cflags -Wtype-limits
2937 check_cflags -Wundef
2938 check_cflags -Wmissing-prototypes
2939 enabled extra_warnings && check_cflags -Winline
2940
2941 # add some linker flags
2942 check_ldflags -Wl,--warn-common
2943 check_ldflags -Wl,--as-needed
2944 check_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'
2945 test_ldflags -Wl,-Bsymbolic && append SHFLAGS -Wl,-Bsymbolic
2946
2947 echo "X{};" > $TMPV
2948 if test_ldflags -Wl,--version-script,$TMPV; then
2949     append SHFLAGS '-Wl,--version-script,\$(SUBDIR)lib\$(NAME).ver'
2950     check_cc <<EOF && enable symver_asm_label
2951 void ff_foo(void) __asm__ ("av_foo@VERSION");
2952 void ff_foo(void) { ${inline_asm+__asm__($quotes);} }
2953 EOF
2954     check_cc <<EOF && enable symver_gnu_asm
2955 __asm__(".symver ff_foo,av_foo@VERSION");
2956 void ff_foo(void) {}
2957 EOF
2958 fi
2959
2960 if enabled small; then
2961     add_cflags $size_cflags
2962     optimizations="small"
2963 elif enabled optimizations; then
2964     add_cflags $speed_cflags
2965 else
2966     add_cflags $noopt_cflags
2967 fi
2968 check_cflags -fno-math-errno
2969 check_cflags -fno-signed-zeros
2970
2971 if enabled icc; then
2972     # Just warnings, no remarks
2973     check_cflags -w1
2974     # -wd: Disable following warnings
2975     # 144, 167, 556: -Wno-pointer-sign
2976     # 10006: ignoring unknown option -fno-signed-zeros
2977     # 10148: ignoring unknown option -Wno-parentheses
2978     # 10156: ignoring option '-W'; no argument required
2979     check_cflags -wd144,167,556,10006,10148,10156
2980     # 11030: Warning unknown option --as-needed
2981     # 10156: ignoring option '-export'; no argument required
2982     check_ldflags -wd10156,11030
2983     # Allow to compile with optimizations
2984     check_ldflags -march=$cpu
2985     # icc 11.0 and 11.1 work with ebp_available, but don't pass the test
2986     enable ebp_available
2987     if enabled x86_32; then
2988         test ${icc_version%%.*} -ge 11 && \
2989             check_cflags -falign-stack=maintain-16-byte || \
2990             disable aligned_stack
2991     fi
2992 elif enabled ccc; then
2993     # disable some annoying warnings
2994     add_cflags -msg_disable cvtu32to64
2995     add_cflags -msg_disable embedcomment
2996     add_cflags -msg_disable needconstext
2997     add_cflags -msg_disable nomainieee
2998     add_cflags -msg_disable ptrmismatch1
2999     add_cflags -msg_disable unreachcode
3000 elif enabled gcc; then
3001     check_cflags -fno-tree-vectorize
3002     check_cflags -Werror=implicit-function-declaration
3003     check_cflags -Werror=missing-prototypes
3004 elif enabled llvm_gcc; then
3005     check_cflags -mllvm -stack-alignment=16
3006 elif enabled clang; then
3007     check_cflags -mllvm -stack-alignment=16
3008     check_cflags -Qunused-arguments
3009 elif enabled armcc; then
3010     # 2523: use of inline assembler is deprecated
3011     add_cflags -W${armcc_opt},--diag_suppress=2523
3012     add_cflags -W${armcc_opt},--diag_suppress=1207
3013     add_cflags -W${armcc_opt},--diag_suppress=1293 # assignment in condition
3014     add_cflags -W${armcc_opt},--diag_suppress=3343 # hardfp compat
3015 elif enabled tms470; then
3016     add_cflags -pds=824 -pds=837
3017 elif enabled pathscale; then
3018     add_cflags -fstrict-overflow -OPT:wrap_around_unsafe_opt=OFF
3019 fi
3020
3021 enabled_any $THREADS_LIST      && enable threads
3022
3023 check_deps $CONFIG_LIST       \
3024            $CONFIG_EXTRA      \
3025            $HAVE_LIST         \
3026            $DECODER_LIST      \
3027            $ENCODER_LIST      \
3028            $HWACCEL_LIST      \
3029            $PARSER_LIST       \
3030            $BSF_LIST          \
3031            $DEMUXER_LIST      \
3032            $MUXER_LIST        \
3033            $FILTER_LIST       \
3034            $INDEV_LIST        \
3035            $OUTDEV_LIST       \
3036            $PROTOCOL_LIST     \
3037            $ACODEC_TESTS      \
3038            $VCODEC_TESTS      \
3039            $LAVF_TESTS        \
3040            $LAVFI_TESTS       \
3041            $SEEK_TESTS        \
3042
3043 enabled asm || { arch=c; disable $ARCH_LIST $ARCH_EXT_LIST; }
3044
3045 echo "install prefix            $prefix"
3046 echo "source path               $source_path"
3047 echo "C compiler                $cc"
3048 echo "ARCH                      $arch ($cpu)"
3049 if test "$build_suffix" != ""; then
3050     echo "build suffix              $build_suffix"
3051 fi
3052 if test "$extra_version" != ""; then
3053     echo "version string suffix     $extra_version"
3054 fi
3055 echo "big-endian                ${bigendian-no}"
3056 echo "runtime cpu detection     ${runtime_cpudetect-no}"
3057 if enabled x86; then
3058     echo "yasm                      ${yasm-no}"
3059     echo "MMX enabled               ${mmx-no}"
3060     echo "MMX2 enabled              ${mmx2-no}"
3061     echo "3DNow! enabled            ${amd3dnow-no}"
3062     echo "3DNow! extended enabled   ${amd3dnowext-no}"
3063     echo "SSE enabled               ${sse-no}"
3064     echo "SSSE3 enabled             ${ssse3-no}"
3065     echo "CMOV enabled              ${cmov-no}"
3066     echo "CMOV is fast              ${fast_cmov-no}"
3067     echo "EBX available             ${ebx_available-no}"
3068     echo "EBP available             ${ebp_available-no}"
3069     echo "10 operands supported     ${ten_operands-no}"
3070 fi
3071 if enabled arm; then
3072     echo "ARMv5TE enabled           ${armv5te-no}"
3073     echo "ARMv6 enabled             ${armv6-no}"
3074     echo "ARMv6T2 enabled           ${armv6t2-no}"
3075     echo "ARM VFP enabled           ${armvfp-no}"
3076     echo "IWMMXT enabled            ${iwmmxt-no}"
3077     echo "NEON enabled              ${neon-no}"
3078 fi
3079 if enabled mips; then
3080     echo "MMI enabled               ${mmi-no}"
3081 fi
3082 if enabled ppc; then
3083     echo "AltiVec enabled           ${altivec-no}"
3084     echo "PPC 4xx optimizations     ${ppc4xx-no}"
3085     echo "dcbzl available           ${dcbzl-no}"
3086 fi
3087 if enabled sparc; then
3088     echo "VIS enabled               ${vis-no}"
3089 fi
3090 echo "debug symbols             ${debug-no}"
3091 echo "strip symbols             ${stripping-no}"
3092 echo "optimizations             ${optimizations-no}"
3093 echo "static                    ${static-no}"
3094 echo "shared                    ${shared-no}"
3095 echo "postprocessing support    ${postproc-no}"
3096 echo "new filter support        ${avfilter-no}"
3097 echo "network support           ${network-no}"
3098 echo "threading support         ${thread_type-no}"
3099 echo "SDL support               ${sdl-no}"
3100 echo "Sun medialib support      ${mlib-no}"
3101 echo "AVISynth enabled          ${avisynth-no}"
3102 echo "frei0r enabled            ${frei0r-no}"
3103 echo "libdc1394 support         ${libdc1394-no}"
3104 echo "libdirac enabled          ${libdirac-no}"
3105 echo "libfaac enabled           ${libfaac-no}"
3106 echo "libgsm enabled            ${libgsm-no}"
3107 echo "libmp3lame enabled        ${libmp3lame-no}"
3108 echo "libnut enabled            ${libnut-no}"
3109 echo "libopencore-amrnb support ${libopencore_amrnb-no}"
3110 echo "libopencore-amrwb support ${libopencore_amrwb-no}"
3111 echo "libopencv support         ${libopencv-no}"
3112 echo "libopenjpeg enabled       ${libopenjpeg-no}"
3113 echo "librtmp enabled           ${librtmp-no}"
3114 echo "libschroedinger enabled   ${libschroedinger-no}"
3115 echo "libspeex enabled          ${libspeex-no}"
3116 echo "libtheora enabled         ${libtheora-no}"
3117 echo "libvorbis enabled         ${libvorbis-no}"
3118 echo "libvpx enabled            ${libvpx-no}"
3119 echo "libx264 enabled           ${libx264-no}"
3120 echo "libxavs enabled           ${libxavs-no}"
3121 echo "libxvid enabled           ${libxvid-no}"
3122 echo "zlib enabled              ${zlib-no}"
3123 echo "bzlib enabled             ${bzlib-no}"
3124 echo
3125
3126 for type in decoder encoder hwaccel parser demuxer muxer protocol filter bsf indev outdev; do
3127     echo "Enabled ${type}s:"
3128     eval list=\$$(toupper $type)_LIST
3129     print_enabled '_*' $list | sort | pr -3 -t
3130     echo
3131 done
3132
3133 license="LGPL version 2.1 or later"
3134 if enabled nonfree; then
3135     license="nonfree and unredistributable"
3136 elif enabled gplv3; then
3137     license="GPL version 3 or later"
3138 elif enabled lgplv3; then
3139     license="LGPL version 3 or later"
3140 elif enabled gpl; then
3141     license="GPL version 2 or later"
3142 fi
3143
3144 echo "License: $license"
3145
3146 echo "Creating config.mak and config.h..."
3147
3148 # build tree in object directory if source path is different from current one
3149 if enabled source_path_used; then
3150     DIRS="
3151         doc
3152         libavcodec
3153         libavcodec/$arch
3154         libavdevice
3155         libavfilter
3156         libavfilter/$arch
3157         libavfilter/libmpcodecs
3158         libavfilter/libmpcodecs/libvo
3159         libavformat
3160         libavutil
3161         libavutil/$arch
3162         libpostproc
3163         libswscale
3164         libswscale/$arch
3165         tests
3166         tools
3167     "
3168     FILES="
3169         Makefile
3170         common.mak
3171         subdir.mak
3172         doc/texi2pod.pl
3173         libavcodec/Makefile
3174         libavcodec/${arch}/Makefile
3175         libavdevice/Makefile
3176         libavfilter/Makefile
3177         libavfilter/${arch}/Makefile
3178         libavformat/Makefile
3179         libavutil/Makefile
3180         libpostproc/Makefile
3181         libswscale/Makefile
3182     "
3183     map 'mkdir -p $v' $DIRS;
3184     map 'test -f "$source_path/$v" && $ln_s "$source_path/$v" $v' $FILES
3185 fi
3186
3187 enabled stripping || strip="echo skipping strip"
3188
3189 config_files="$TMPH config.mak"
3190
3191 cat > config.mak <<EOF
3192 # Automatically generated by configure - do not modify!
3193 ifndef FFMPEG_CONFIG_MAK
3194 FFMPEG_CONFIG_MAK=1
3195 FFMPEG_CONFIGURATION=$FFMPEG_CONFIGURATION
3196 prefix=$prefix
3197 LIBDIR=\$(DESTDIR)$libdir
3198 SHLIBDIR=\$(DESTDIR)$shlibdir
3199 INCDIR=\$(DESTDIR)$incdir
3200 BINDIR=\$(DESTDIR)$bindir
3201 DATADIR=\$(DESTDIR)$datadir
3202 MANDIR=\$(DESTDIR)$mandir
3203 SRC_PATH="$source_path"
3204 SRC_PATH_BARE=$source_path
3205 BUILD_ROOT="$PWD"
3206 CC_IDENT=$cc_ident
3207 ARCH=$arch
3208 CC=$cc
3209 AS=$as
3210 LD=$ld
3211 DEPCC=$dep_cc
3212 YASM=$yasmexe
3213 YASMDEP=$yasmexe
3214 AR=$ar
3215 RANLIB=$ranlib
3216 CP=cp -p
3217 LN_S=$ln_s
3218 STRIP=$strip
3219 CPPFLAGS=$CPPFLAGS
3220 CFLAGS=$CFLAGS
3221 ASFLAGS=$ASFLAGS
3222 CC_O=$CC_O
3223 LDFLAGS=$LDFLAGS
3224 FFSERVERLDFLAGS=$FFSERVERLDFLAGS
3225 SHFLAGS=$SHFLAGS
3226 YASMFLAGS=$YASMFLAGS
3227 BUILDSUF=$build_suffix
3228 FULLNAME=$FULLNAME
3229 LIBPREF=$LIBPREF
3230 LIBSUF=$LIBSUF
3231 LIBNAME=$LIBNAME
3232 SLIBPREF=$SLIBPREF
3233 SLIBSUF=$SLIBSUF
3234 EXESUF=$EXESUF
3235 EXTRA_VERSION=$extra_version
3236 DEPFLAGS=$DEPFLAGS
3237 CCDEP=$CCDEP
3238 ASDEP=$ASDEP
3239 CC_DEPFLAGS=$CC_DEPFLAGS
3240 AS_DEPFLAGS=$AS_DEPFLAGS
3241 HOSTCC=$host_cc
3242 HOSTCFLAGS=$host_cflags
3243 HOSTEXESUF=$HOSTEXESUF
3244 HOSTLDFLAGS=$host_ldflags
3245 HOSTLIBS=$host_libs
3246 TARGET_EXEC=$target_exec
3247 TARGET_PATH=$target_path
3248 SDL_LIBS=$sdl_libs
3249 SDL_CFLAGS=$sdl_cflags
3250 LIB_INSTALL_EXTRA_CMD=$LIB_INSTALL_EXTRA_CMD
3251 EXTRALIBS=$extralibs
3252 INSTALL=install
3253 LIBTARGET=${LIBTARGET}
3254 SLIBNAME=${SLIBNAME}
3255 SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}
3256 SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}
3257 SLIB_CREATE_DEF_CMD=${SLIB_CREATE_DEF_CMD}
3258 SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}
3259 SLIB_INSTALL_EXTRA_CMD=${SLIB_INSTALL_EXTRA_CMD}
3260 SLIB_UNINSTALL_EXTRA_CMD=${SLIB_UNINSTALL_EXTRA_CMD}
3261 SAMPLES=$samples
3262 EOF
3263
3264 get_version(){
3265     name=$1
3266     file=$source_path/$2
3267     eval $(grep "#define ${name}_VERSION_M" "$file" | awk '{ print $2"="$3 }')
3268     eval ${name}_VERSION=\$${name}_VERSION_MAJOR.\$${name}_VERSION_MINOR.\$${name}_VERSION_MICRO
3269     lcname=$(tolower $name)
3270     eval echo "${lcname}_VERSION=\$${name}_VERSION" >> config.mak
3271     eval echo "${lcname}_VERSION_MAJOR=\$${name}_VERSION_MAJOR" >> config.mak
3272 }
3273
3274 get_version LIBSWSCALE  libswscale/swscale.h
3275 get_version LIBPOSTPROC libpostproc/postprocess.h
3276 get_version LIBAVCODEC  libavcodec/avcodec.h
3277 get_version LIBAVDEVICE libavdevice/avdevice.h
3278 get_version LIBAVFORMAT libavformat/version.h
3279 get_version LIBAVUTIL   libavutil/avutil.h
3280 get_version LIBAVFILTER libavfilter/avfilter.h
3281
3282 cat > $TMPH <<EOF
3283 /* Automatically generated by configure - do not modify! */
3284 #ifndef FFMPEG_CONFIG_H
3285 #define FFMPEG_CONFIG_H
3286 #define FFMPEG_CONFIGURATION "$(c_escape $FFMPEG_CONFIGURATION)"
3287 #define FFMPEG_LICENSE "$(c_escape $license)"
3288 #define FFMPEG_DATADIR "$(eval c_escape $datadir)"
3289 #define CC_TYPE "$cc_type"
3290 #define CC_VERSION $cc_version
3291 #define restrict $_restrict
3292 #define EXTERN_PREFIX "${extern_prefix}"
3293 #define EXTERN_ASM ${extern_prefix}
3294 #define SLIBSUF "$SLIBSUF"
3295 EOF
3296
3297 test -n "$malloc_prefix" &&
3298     echo "#define MALLOC_PREFIX $malloc_prefix" >>$TMPH
3299
3300 if enabled small || disabled optimizations; then
3301     echo "#undef  av_always_inline"  >> $TMPH
3302     if enabled small; then
3303         echo "#define av_always_inline inline"  >> $TMPH
3304     else
3305         echo "#define av_always_inline av_unused"  >> $TMPH
3306     fi
3307 fi
3308
3309 if enabled yasm; then
3310     append config_files $TMPASM
3311     printf '' >$TMPASM
3312 fi
3313
3314 print_config ARCH_   "$config_files" $ARCH_LIST
3315 print_config HAVE_   "$config_files" $HAVE_LIST
3316 print_config CONFIG_ "$config_files" $CONFIG_LIST       \
3317                                      $CONFIG_EXTRA      \
3318                                      $DECODER_LIST      \
3319                                      $ENCODER_LIST      \
3320                                      $HWACCEL_LIST      \
3321                                      $PARSER_LIST       \
3322                                      $BSF_LIST          \
3323                                      $DEMUXER_LIST      \
3324                                      $MUXER_LIST        \
3325                                      $FILTER_LIST       \
3326                                      $PROTOCOL_LIST     \
3327                                      $INDEV_LIST        \
3328                                      $OUTDEV_LIST       \
3329
3330 cat >>config.mak <<EOF
3331 ACODEC_TESTS=$(print_enabled -n _test $ACODEC_TESTS)
3332 VCODEC_TESTS=$(print_enabled -n _test $VCODEC_TESTS)
3333 LAVF_TESTS=$(print_enabled   -n _test $LAVF_TESTS)
3334 LAVFI_TESTS=$(print_enabled  -n _test $LAVFI_TESTS)
3335 SEEK_TESTS=$(print_enabled   -n _test $SEEK_TESTS)
3336 EOF
3337
3338 echo "#endif /* FFMPEG_CONFIG_H */" >> $TMPH
3339 echo "endif # FFMPEG_CONFIG_MAK" >> config.mak
3340
3341 # Do not overwrite an unchanged config.h to avoid superfluous rebuilds.
3342 cp_if_changed $TMPH config.h
3343 touch .config
3344
3345 enabled yasm && cp_if_changed $TMPASM config.asm
3346
3347 cat > $TMPH <<EOF
3348 /* Generated by ffconf */
3349 #ifndef AVUTIL_AVCONFIG_H
3350 #define AVUTIL_AVCONFIG_H
3351 EOF
3352
3353 print_config AV_HAVE_ $TMPH $HAVE_LIST_PUB
3354
3355 echo "#endif /* AVUTIL_AVCONFIG_H */" >> $TMPH
3356
3357 cp_if_changed $TMPH libavutil/avconfig.h
3358
3359 test -n "$WARNINGS" && printf "\n$WARNINGS"
3360
3361 # build pkg-config files
3362
3363 pkgconfig_generate(){
3364 name=$1
3365 shortname=${name#lib}${build_suffix}
3366 comment=$2
3367 version=$3
3368 libs=$4
3369 requires=$5
3370 enabled ${name#lib} || return 0
3371 cat <<EOF > $name/$name.pc
3372 prefix=$prefix
3373 exec_prefix=\${prefix}
3374 libdir=$libdir
3375 includedir=$incdir
3376
3377 Name: $name
3378 Description: $comment
3379 Version: $version
3380 Requires: $(enabled shared || echo $requires)
3381 Requires.private: $(enabled shared && echo $requires)
3382 Conflicts:
3383 Libs: -L\${libdir} -l${shortname} $(enabled shared || echo $libs)
3384 Libs.private: $(enabled shared && echo $libs)
3385 Cflags: -I\${includedir}
3386 EOF
3387 cat <<EOF > $name/$name-uninstalled.pc
3388 prefix=
3389 exec_prefix=
3390 libdir=\${pcfiledir}
3391 includedir=${source_path}
3392
3393 Name: $name
3394 Description: $comment
3395 Version: $version
3396 Requires: $requires
3397 Conflicts:
3398 Libs: \${libdir}/${LIBPREF}${shortname}${LIBSUF} $libs
3399 Cflags: -I\${includedir}
3400 EOF
3401 }
3402
3403 pkgconfig_generate libavutil "FFmpeg utility library" "$LIBAVUTIL_VERSION"
3404 pkgconfig_generate libavcodec "FFmpeg codec library" "$LIBAVCODEC_VERSION" "$extralibs"
3405 pkgconfig_generate libavformat "FFmpeg container format library" "$LIBAVFORMAT_VERSION" "$extralibs" "libavcodec = $LIBAVCODEC_VERSION"
3406 pkgconfig_generate libavdevice "FFmpeg device handling library" "$LIBAVDEVICE_VERSION" "$extralibs" "libavformat = $LIBAVFORMAT_VERSION"
3407 pkgconfig_generate libavfilter "FFmpeg video filtering library" "$LIBAVFILTER_VERSION" "$extralibs"
3408 pkgconfig_generate libpostproc "FFmpeg post processing library" "$LIBPOSTPROC_VERSION"
3409 pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "" "libavutil = $LIBAVUTIL_VERSION"