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