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