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 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 mpeg2thread"                                      \
1694     mpeg4="mpeg4 mpeg4adv mpeg4nr mpeg4thread error rc"                 \
1695     msmpeg4v3=msmpeg4                                                   \
1696     msmpeg4v2                                                           \
1697     pbm=pbmpipe                                                         \
1698     pcx                                                                 \
1699     pgm="pgm pgmpipe"                                                   \
1700     png                                                                 \
1701     ppm="ppm ppmpipe"                                                   \
1702     rawvideo="rgb yuv"                                                  \
1703     roq                                                                 \
1704     rv10                                                                \
1705     rv20                                                                \
1706     sgi                                                                 \
1707     snow="snow snowll"                                                  \
1708     svq1                                                                \
1709     targa=tga                                                           \
1710     tiff                                                                \
1711     wmav1                                                               \
1712     wmav2                                                               \
1713     wmv1                                                                \
1714     wmv2                                                                \
1715
1716 test_deps _muxer _demuxer                                               \
1717     aiff                                                                \
1718     pcm_alaw=alaw                                                       \
1719     asf                                                                 \
1720     au                                                                  \
1721     avi                                                                 \
1722     dv=dv_fmt                                                           \
1723     ffm                                                                 \
1724     flv=flv_fmt                                                         \
1725     gxf                                                                 \
1726     matroska=mkv                                                        \
1727     mmf                                                                 \
1728     mov                                                                 \
1729     pcm_mulaw=mulaw                                                     \
1730     mxf="mxf mxf_d10"                                                   \
1731     nut                                                                 \
1732     ogg                                                                 \
1733     rawvideo=pixfmt                                                     \
1734     rm                                                                  \
1735     swf                                                                 \
1736     mpegts=ts                                                           \
1737     voc                                                                 \
1738     wav                                                                 \
1739     yuv4mpegpipe=yuv4mpeg                                               \
1740
1741 ac3_fixed_test_deps="ac3_fixed_encoder ac3_decoder rm_muxer rm_demuxer"
1742 mpg_test_deps="mpeg1system_muxer mpegps_demuxer"
1743
1744 # default parameters
1745
1746 logfile="config.log"
1747
1748 # installation paths
1749 prefix_default="/usr/local"
1750 bindir_default='${prefix}/bin'
1751 datadir_default='${prefix}/share/ffmpeg'
1752 incdir_default='${prefix}/include'
1753 libdir_default='${prefix}/lib'
1754 mandir_default='${prefix}/share/man'
1755 shlibdir_default="$libdir_default"
1756
1757 # toolchain
1758 ar_default="ar"
1759 cc_default="gcc"
1760 cxx_default="g++"
1761 cc_version=\"unknown\"
1762 host_cc_default="gcc"
1763 install="install"
1764 ln_s="ln -sf"
1765 nm_default="nm"
1766 objformat="elf"
1767 pkg_config_default=pkg-config
1768 ranlib="ranlib"
1769 strip_default="strip"
1770 yasmexe="yasm"
1771 nogas=":"
1772
1773 nm_opts='-g'
1774
1775 # machine
1776 arch_default=$(uname -m)
1777 cpu="generic"
1778
1779 # OS
1780 target_os_default=$(tolower $(uname -s))
1781 host_os=$target_os_default
1782
1783 # configurable options
1784 enable avcodec
1785 enable avdevice
1786 enable avfilter
1787 enable avformat
1788 enable avutil
1789 enable asm
1790 enable debug
1791 enable doc
1792 enable fastdiv
1793 enable ffmpeg
1794 enable avconv
1795 enable ffplay
1796 enable ffprobe
1797 enable ffserver
1798 enable network
1799 enable optimizations
1800 enable postproc
1801 enable protocols
1802 enable static
1803 enable stripping
1804 enable swresample
1805 enable swscale
1806 enable swscale_alpha
1807
1808 # build settings
1809 SHFLAGS='-shared -Wl,-soname,$$(@F)'
1810 FFSERVERLDFLAGS=-Wl,-E
1811 LIBPREF="lib"
1812 LIBSUF=".a"
1813 FULLNAME='$(NAME)$(BUILDSUF)'
1814 LIBNAME='$(LIBPREF)$(FULLNAME)$(LIBSUF)'
1815 SLIBPREF="lib"
1816 SLIBSUF=".so"
1817 SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF)'
1818 SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
1819 SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
1820 LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
1821 SLIB_INSTALL_NAME='$(SLIBNAME_WITH_VERSION)'
1822 SLIB_INSTALL_LINKS='$(SLIBNAME_WITH_MAJOR) $(SLIBNAME)'
1823
1824 AS_O='-o $@'
1825 CC_O='-o $@'
1826 CXX_O='-o $@'
1827
1828 host_cflags='-D_ISOC99_SOURCE -O3 -g'
1829 host_libs='-lm'
1830
1831 target_path='$(CURDIR)'
1832
1833 # since the object filename is not given with the -MM flag, the compiler
1834 # is only able to print the basename, and we must add the path ourselves
1835 DEPEND_CMD='$(DEPCC) $(DEPFLAGS) $< | sed -e "/^\#.*/d" -e "s,^[[:space:]]*$(*F)\\.o,$(@D)/$(*F).o," > $(@:.o=.d)'
1836 DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -MM'
1837
1838 # find source path
1839 if test -f configure; then
1840     source_path=.
1841 else
1842     source_path=$(cd $(dirname "$0"); pwd)
1843     echo "$source_path" | grep -q '[[:blank:]]' &&
1844         die "Out of tree builds are impossible with whitespace in source path."
1845     test -e "$source_path/config.h" &&
1846         die "Out of tree builds are impossible with config.h in source dir."
1847 fi
1848
1849 for v in "$@"; do
1850     r=${v#*=}
1851     l=${v%"$r"}
1852     r=$(sh_quote "$r")
1853     FFMPEG_CONFIGURATION="${FFMPEG_CONFIGURATION# } ${l}${r}"
1854 done
1855
1856 find_things(){
1857     thing=$1
1858     pattern=$2
1859     file=$source_path/$3
1860     sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" "$file"
1861 }
1862
1863 ENCODER_LIST=$(find_things  encoder  ENC      libavcodec/allcodecs.c)
1864 DECODER_LIST=$(find_things  decoder  DEC      libavcodec/allcodecs.c)
1865 HWACCEL_LIST=$(find_things  hwaccel  HWACCEL  libavcodec/allcodecs.c)
1866 PARSER_LIST=$(find_things   parser   PARSER   libavcodec/allcodecs.c)
1867 BSF_LIST=$(find_things      bsf      BSF      libavcodec/allcodecs.c)
1868 MUXER_LIST=$(find_things    muxer    _MUX     libavformat/allformats.c)
1869 DEMUXER_LIST=$(find_things  demuxer  DEMUX    libavformat/allformats.c)
1870 OUTDEV_LIST=$(find_things   outdev   OUTDEV   libavdevice/alldevices.c)
1871 INDEV_LIST=$(find_things    indev    _IN      libavdevice/alldevices.c)
1872 PROTOCOL_LIST=$(find_things protocol PROTOCOL libavformat/allformats.c)
1873 FILTER_LIST=$(find_things   filter   FILTER   libavfilter/allfilters.c)
1874
1875 find_tests(){
1876     map "echo ${2}\${v}_test" $(ls "$source_path"/tests/ref/$1 | grep -v '[^-a-z0-9_]')
1877 }
1878
1879 ACODEC_TESTS=$(find_tests acodec)
1880 VCODEC_TESTS=$(find_tests vsynth1)
1881 LAVF_TESTS=$(find_tests lavf)
1882 LAVFI_TESTS=$(find_tests lavfi)
1883 SEEK_TESTS=$(find_tests seek seek_)
1884
1885 pcm_test_deps=$(map 'echo ${v%_*}_decoder $v' $(filter pcm_* $ENCODER_LIST))
1886
1887 for n in $COMPONENT_LIST; do
1888     v=$(toupper ${n%s})_LIST
1889     eval enable \$$v
1890     eval ${n}_if_any="\$$v"
1891 done
1892
1893 enable $ARCH_EXT_LIST $ACODEC_TESTS $VCODEC_TESTS $LAVF_TESTS $LAVFI_TESTS $SEEK_TESTS
1894
1895 die_unknown(){
1896     echo "Unknown option \"$1\"."
1897     echo "See $0 --help for available options."
1898     exit 1
1899 }
1900
1901 show_list() {
1902     suffix=_$1
1903     shift
1904     echo $* | sed s/$suffix//g | tr ' ' '\n' | sort | pr -3 -t
1905     exit 0
1906 }
1907
1908 for opt do
1909     optval="${opt#*=}"
1910     case "$opt" in
1911     --extra-ldflags=*) add_ldflags $optval
1912     ;;
1913     --extra-libs=*) add_extralibs $optval
1914     ;;
1915     --disable-devices) disable $INDEV_LIST $OUTDEV_LIST
1916     ;;
1917     --enable-debug=*) debuglevel="$optval"
1918     ;;
1919     --disable-everything)
1920     map 'eval unset \${$(toupper ${v%s})_LIST}' $COMPONENT_LIST
1921     ;;
1922     --enable-*=*|--disable-*=*)
1923     eval $(echo "${opt%%=*}" | sed 's/--/action=/;s/-/ thing=/')
1924     is_in "${thing}s" $COMPONENT_LIST || die_unknown "$opt"
1925     eval list=\$$(toupper $thing)_LIST
1926     name=$(echo "${optval}" | sed "s/,/_${thing}|/g")_${thing}
1927     $action $(filter "$name" $list)
1928     ;;
1929     --enable-?*|--disable-?*)
1930     eval $(echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g')
1931     if is_in $option $COMPONENT_LIST; then
1932         test $action = disable && action=unset
1933         eval $action \$$(toupper ${option%s})_LIST
1934     elif is_in $option $CMDLINE_SELECT; then
1935         $action $option
1936     else
1937         die_unknown $opt
1938     fi
1939     ;;
1940     --list-*)
1941         NAME="${opt#--list-}"
1942         is_in $NAME $COMPONENT_LIST || die_unknown $opt
1943         NAME=${NAME%s}
1944         eval show_list $NAME \$$(toupper $NAME)_LIST
1945     ;;
1946     --help|-h) show_help
1947     ;;
1948     *)
1949     optname="${opt%%=*}"
1950     optname="${optname#--}"
1951     optname=$(echo "$optname" | sed 's/-/_/g')
1952     if is_in $optname $CMDLINE_SET; then
1953         eval $optname='$optval'
1954     elif is_in $optname $CMDLINE_APPEND; then
1955         append $optname "$optval"
1956     else
1957          die_unknown $opt
1958     fi
1959     ;;
1960     esac
1961 done
1962
1963 disabled logging && logfile=/dev/null
1964
1965 echo "# $0 $FFMPEG_CONFIGURATION" > $logfile
1966 set >> $logfile
1967
1968 test -n "$cross_prefix" && enable cross_compile
1969
1970 if enabled cross_compile; then
1971     test -n "$arch" && test -n "$target_os" ||
1972         die "Must specify target arch and OS when cross-compiling"
1973 fi
1974
1975 set_default arch target_os
1976
1977 ar_default="${cross_prefix}${ar_default}"
1978 cc_default="${cross_prefix}${cc_default}"
1979 cxx_default="${cross_prefix}${cxx_default}"
1980 nm_default="${cross_prefix}${nm_default}"
1981 pkg_config_default="${cross_prefix}${pkg_config_default}"
1982 ranlib="${cross_prefix}${ranlib}"
1983 strip_default="${cross_prefix}${strip_default}"
1984
1985 sysinclude_default="${sysroot}/usr/include"
1986
1987 set_default cc cxx nm pkg_config strip sysinclude
1988 enabled cross_compile || host_cc_default=$cc
1989 set_default host_cc
1990
1991 if ! $pkg_config --version >/dev/null 2>&1; then
1992     warn "$pkg_config not found, library detection may fail."
1993     pkg_config=false
1994 fi
1995
1996 exesuf() {
1997     case $1 in
1998         mingw32*|cygwin*|*-dos|freedos|opendos|os/2*|symbian) echo .exe ;;
1999     esac
2000 }
2001
2002 EXESUF=$(exesuf $target_os)
2003 HOSTEXESUF=$(exesuf $host_os)
2004
2005 # set temporary file name
2006 : ${TMPDIR:=$TEMPDIR}
2007 : ${TMPDIR:=$TMP}
2008 : ${TMPDIR:=/tmp}
2009
2010 if ! check_cmd mktemp -u XXXXXX; then
2011     # simple replacement for missing mktemp
2012     # NOT SAFE FOR GENERAL USE
2013     mktemp(){
2014         echo "${2%%XXX*}.${HOSTNAME}.${UID}.$$"
2015     }
2016 fi
2017
2018 tmpfile(){
2019     tmp=$(mktemp -u "${TMPDIR}/ffconf.XXXXXXXX")$2 &&
2020         (set -C; exec > $tmp) 2>/dev/null ||
2021         die "Unable to create temporary file in $TMPDIR."
2022     append TMPFILES $tmp
2023     eval $1=$tmp
2024 }
2025
2026 trap 'rm -f -- $TMPFILES' EXIT
2027
2028 tmpfile TMPC  .c
2029 tmpfile TMPCPP .cpp
2030 tmpfile TMPE  $EXESUF
2031 tmpfile TMPH  .h
2032 tmpfile TMPO  .o
2033 tmpfile TMPS  .S
2034 tmpfile TMPV  .ver
2035 tmpfile TMPSH .sh
2036 tmpfile TMPASM .asm
2037
2038 unset -f mktemp
2039
2040 chmod +x $TMPE
2041
2042 # make sure we can execute files in $TMPDIR
2043 cat > $TMPSH 2>> $logfile <<EOF
2044 #! /bin/sh
2045 EOF
2046 chmod +x $TMPSH >> $logfile 2>&1
2047 if ! $TMPSH >> $logfile 2>&1; then
2048     cat <<EOF
2049 Unable to create and execute files in $TMPDIR.  Set the TMPDIR environment
2050 variable to another directory and make sure that it is not mounted noexec.
2051 EOF
2052     die "Sanity test failed."
2053 fi
2054
2055 filter_cflags=echo
2056 filter_cppflags=echo
2057 filter_asflags=echo
2058
2059 if   $cc -v 2>&1 | grep -q '^gcc.*LLVM'; then
2060     cc_type=llvm_gcc
2061     cc_version=__VERSION__
2062     gcc_extra_ver=$(expr "$($cc --version | head -n1)" : '.*\((.*)\)')
2063     cc_ident="llvm-gcc $($cc -dumpversion) $gcc_extra_ver"
2064     CC_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
2065     AS_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
2066     speed_cflags='-O3'
2067     size_cflags='-Os'
2068 elif $cc -v 2>&1 | grep -qi ^gcc; then
2069     cc_type=gcc
2070     cc_version=__VERSION__
2071     gcc_version=$($cc --version | head -n1)
2072     gcc_basever=$($cc -dumpversion)
2073     gcc_pkg_ver=$(expr "$gcc_version" : '[^ ]* \(([^)]*)\)')
2074     gcc_ext_ver=$(expr "$gcc_version" : ".*$gcc_pkg_ver $gcc_basever \\(.*\\)")
2075     cc_ident=$(cleanws "gcc $gcc_basever $gcc_pkg_ver $gcc_ext_ver")
2076     if ! $cc -dumpversion | grep -q '^2\.'; then
2077         CC_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
2078         AS_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
2079     fi
2080     speed_cflags='-O3'
2081     size_cflags='-Os'
2082 elif $cc --version 2>/dev/null | grep -q Intel; then
2083     cc_type=icc
2084     cc_version="AV_STRINGIFY(__INTEL_COMPILER)"
2085     cc_ident=$($cc --version | head -n1)
2086     icc_version=$($cc -dumpversion)
2087     CC_DEPFLAGS='-MMD'
2088     AS_DEPFLAGS='-MMD'
2089     speed_cflags='-O3'
2090     size_cflags='-Os'
2091     noopt_cflags='-O1'
2092 elif $cc -v 2>&1 | grep -q xlc; then
2093     cc_type=xlc
2094     cc_version="AV_STRINGIFY(__IBMC__)"
2095     cc_ident=$($cc -qversion 2>/dev/null | head -n1)
2096     speed_cflags='-O5'
2097     size_cflags='-O5 -qcompact'
2098 elif $cc -V 2>/dev/null | grep -q Compaq; then
2099     cc_type=ccc
2100     cc_version="AV_STRINGIFY(__DECC_VER)"
2101     cc_ident=$($cc -V | head -n1 | cut -d' ' -f1-3)
2102     DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -M'
2103     debuglevel=3
2104     add_ldflags -Wl,-z,now # calls to libots crash without this
2105     speed_cflags='-fast'
2106     size_cflags='-O1'
2107 elif $cc --vsn 2>/dev/null | grep -q "ARM C/C++ Compiler"; then
2108     test -d "$sysroot" || die "No valid sysroot specified."
2109     cc_type=armcc
2110     cc_version="AV_STRINGIFY(__ARMCC_VERSION)"
2111     cc_ident=$($cc --vsn | head -n1)
2112     armcc_conf="$PWD/armcc.conf"
2113     $cc --arm_linux_configure                 \
2114         --arm_linux_config_file="$armcc_conf" \
2115         --configure_sysroot="$sysroot"        \
2116         --configure_cpp_headers="$sysinclude" >>$logfile 2>&1 ||
2117         die "Error creating armcc configuration file."
2118     $cc --vsn | grep -q RVCT && armcc_opt=rvct || armcc_opt=armcc
2119     cc="$cc --arm_linux_config_file=$armcc_conf --translate_gcc"
2120     as_default="${cross_prefix}gcc"
2121     CC_DEPFLAGS='-MMD'
2122     AS_DEPFLAGS='-MMD'
2123     speed_cflags='-O3'
2124     size_cflags='-Os'
2125     filter_asflags="filter_out -W${armcc_opt}*"
2126 elif $cc -version 2>/dev/null | grep -q TMS470; then
2127     cc_type=tms470
2128     cc_version="AV_STRINGIFY(__TI_COMPILER_VERSION__)"
2129     cc_ident=$($cc -version | head -n1 | tr -s ' ')
2130     cc="$cc --gcc --abi=eabi -eo=.o -mc -me"
2131     CC_O='-fr=$(@D)'
2132     as_default="${cross_prefix}gcc"
2133     ld_default="${cross_prefix}gcc"
2134     TMPO=$(basename $TMPC .c).o
2135     append TMPFILES $TMPO
2136     add_cflags -D__gnuc_va_list=va_list -D__USER_LABEL_PREFIX__=
2137     CC_DEPFLAGS='-ppa -ppd=$(@:.o=.d)'
2138     AS_DEPFLAGS='-MMD'
2139     speed_cflags='-O3 -mf=5'
2140     size_cflags='-O3 -mf=2'
2141     filter_cflags=tms470_flags
2142     tms470_flags(){
2143         for flag; do
2144             case $flag in
2145                 -march=*|-mcpu=*)
2146                     case "${flag#*=}" in
2147                         armv7-a|cortex-a*)      echo -mv=7a8 ;;
2148                         armv7-r|cortex-r*)      echo -mv=7r4 ;;
2149                         armv7-m|cortex-m*)      echo -mv=7m3 ;;
2150                         armv6*|arm11*)          echo -mv=6   ;;
2151                         armv5*e|arm[79]*e*|arm9[24]6*|arm96*|arm102[26])
2152                                                 echo -mv=5e  ;;
2153                         armv4*|arm7*|arm9[24]*) echo -mv=4   ;;
2154                     esac
2155                     ;;
2156                 -mfpu=neon)     echo --float_support=vfpv3 --neon ;;
2157                 -mfpu=vfp)      echo --float_support=vfpv2        ;;
2158                 -mfpu=vfpv3)    echo --float_support=vfpv3        ;;
2159                 -msoft-float)   echo --float_support=vfplib       ;;
2160                 -O[0-3]|-mf=*)  echo $flag                        ;;
2161                 -g)             echo -g -mn                       ;;
2162                 -pds=*)         echo $flag                        ;;
2163             esac
2164         done
2165     }
2166 elif $cc -v 2>&1 | grep -q clang; then
2167     cc_type=clang
2168     $cc -dM -E $TMPC | grep -q __clang_version__ &&
2169         cc_version=__clang_version__ || cc_version=__VERSION__
2170     cc_ident=$($cc --version | head -n1)
2171     CC_DEPFLAGS='-MMD'
2172     AS_DEPFLAGS='-MMD'
2173     speed_cflags='-O3'
2174     size_cflags='-Os'
2175 elif $cc -V 2>&1 | grep -q Sun; then
2176     cc_type=suncc
2177     cc_version="AV_STRINGIFY(__SUNPRO_C)"
2178     cc_ident=$($cc -V 2>&1 | head -n1 | cut -d' ' -f 2-)
2179     DEPEND_CMD='$(DEPCC) $(DEPFLAGS) $< | sed -e "1s,^.*: ,$@: ," -e "\$$!s,\$$, \\\," -e "1!s,^.*: , ," > $(@:.o=.d)'
2180     DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -xM1'
2181     add_ldflags -xc99
2182     speed_cflags='-O5'
2183     size_cflags='-O5 -xspace'
2184     filter_cflags=suncc_flags
2185     suncc_flags(){
2186         for flag; do
2187             case $flag in
2188                 -march=*|-mcpu=*)
2189                     case "${flag#*=}" in
2190                         native)                   echo -xtarget=native       ;;
2191                         v9|niagara)               echo -xarch=sparc          ;;
2192                         ultrasparc)               echo -xarch=sparcvis       ;;
2193                         ultrasparc3|niagara2)     echo -xarch=sparcvis2      ;;
2194                         i586|pentium)             echo -xchip=pentium        ;;
2195                         i686|pentiumpro|pentium2) echo -xtarget=pentium_pro  ;;
2196                         pentium3*|c3-2)           echo -xtarget=pentium3     ;;
2197                         pentium-m)          echo -xarch=sse2 -xchip=pentium3 ;;
2198                         pentium4*)          echo -xtarget=pentium4           ;;
2199                         prescott|nocona)    echo -xarch=sse3 -xchip=pentium4 ;;
2200                         *-sse3)             echo -xarch=sse3                 ;;
2201                         core2)              echo -xarch=ssse3 -xchip=core2   ;;
2202                         amdfam10|barcelona)       echo -xarch=sse4_1         ;;
2203                         athlon-4|athlon-[mx]p)    echo -xarch=ssea           ;;
2204                         k8|opteron|athlon64|athlon-fx)
2205                                                   echo -xarch=sse2a          ;;
2206                         athlon*)                  echo -xarch=pentium_proa   ;;
2207                     esac
2208                     ;;
2209                 -std=c99)             echo -xc99              ;;
2210                 -fomit-frame-pointer) echo -xregs=frameptr    ;;
2211                 -fPIC)                echo -KPIC -xcode=pic32 ;;
2212                 -W*,*)                echo $flag              ;;
2213                 -f*-*|-W*)                                    ;;
2214                 *)                    echo $flag              ;;
2215             esac
2216         done
2217     }
2218 elif $cc -v 2>&1 | grep -q 'PathScale\|Path64'; then
2219     cc_type=pathscale
2220     cc_version=__PATHSCALE__
2221     cc_ident=$($cc -v 2>&1 | head -n1 | tr -d :)
2222     CC_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
2223     AS_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
2224     speed_cflags='-O2'
2225     size_cflags='-Os'
2226     filter_cflags='filter_out -Wdisabled-optimization'
2227 elif $cc -v 2>&1 | grep -q Open64; then
2228     cc_type=open64
2229     cc_version=__OPEN64__
2230     cc_ident=$($cc -v 2>&1 | head -n1 | tr -d :)
2231     CC_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
2232     AS_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
2233     speed_cflags='-O2'
2234     size_cflags='-Os'
2235     filter_cflags='filter_out -Wdisabled-optimization|-Wtype-limits|-fno-signed-zeros'
2236 fi
2237
2238 test -n "$cc_type" && enable $cc_type ||
2239     warn "Unknown C compiler $cc, unable to select optimal CFLAGS"
2240
2241 : ${as_default:=$cc}
2242 : ${dep_cc_default:=$cc}
2243 : ${ld_default:=$cc}
2244 set_default ar as dep_cc ld
2245
2246 test -n "$CC_DEPFLAGS" || CCDEP=$DEPEND_CMD
2247 test -n "$CXX_DEPFLAGS" || CXXDEP=$DEPEND_CMD
2248 test -n "$AS_DEPFLAGS" || ASDEP=$DEPEND_CMD
2249
2250 add_cflags $extra_cflags
2251 add_cxxflags $extra_cxxflags
2252 add_asflags $extra_cflags
2253
2254 if test -n "$sysroot"; then
2255     case "$cc_type" in
2256         gcc|llvm_gcc|clang)
2257             add_cppflags --sysroot="$sysroot"
2258             add_ldflags --sysroot="$sysroot"
2259         ;;
2260         tms470)
2261             add_cppflags -I"$sysinclude"
2262             add_ldflags  --sysroot="$sysroot"
2263         ;;
2264     esac
2265 fi
2266
2267 if test "$cpu" = host; then
2268     enabled cross_compile && die "--cpu=host makes no sense when cross-compiling."
2269
2270     case "$cc_type" in
2271         gcc|llvm_gcc)
2272             check_native(){
2273                 $cc $1=native -v -c -o $TMPO $TMPC >$TMPE 2>&1 || return
2274                 sed -n "/cc1.*$1=/{
2275                             s/.*$1=\\([^ ]*\\).*/\\1/
2276                             p
2277                             q
2278                         }" $TMPE
2279             }
2280             cpu=$(check_native -march || check_native -mcpu)
2281         ;;
2282     esac
2283
2284     test "${cpu:-host}" = host && die "--cpu=host not supported with compiler $cc"
2285 fi
2286
2287 # Deal with common $arch aliases
2288 case "$arch" in
2289     arm*)
2290         arch="arm"
2291     ;;
2292     mips|mipsel|IP*)
2293         arch="mips"
2294     ;;
2295     mips64*)
2296         arch="mips"
2297         subarch="mips64"
2298     ;;
2299     parisc|hppa)
2300         arch="parisc"
2301     ;;
2302     parisc64|hppa64)
2303         arch="parisc"
2304         subarch="parisc64"
2305     ;;
2306     "Power Macintosh"|ppc|powerpc|ppc64|powerpc64)
2307         arch="ppc"
2308     ;;
2309     s390|s390x)
2310         arch="s390"
2311     ;;
2312     sh4|sh)
2313         arch="sh4"
2314     ;;
2315     sun4u|sparc64)
2316         arch="sparc"
2317         subarch="sparc64"
2318     ;;
2319     i[3-6]86|i86pc|BePC|x86pc|x86_64|x86_32|amd64)
2320         arch="x86"
2321     ;;
2322 esac
2323
2324 is_in $arch $ARCH_LIST || warn "unknown architecture $arch"
2325 enable $arch
2326
2327 # Add processor-specific flags
2328 if test "$cpu" = generic; then
2329     : do nothing
2330 elif enabled ppc; then
2331
2332     case $(tolower $cpu) in
2333         601|ppc601|powerpc601)
2334             cpuflags="-mcpu=601"
2335             disable altivec
2336         ;;
2337         603*|ppc603*|powerpc603*)
2338             cpuflags="-mcpu=603"
2339             disable altivec
2340         ;;
2341         604*|ppc604*|powerpc604*)
2342             cpuflags="-mcpu=604"
2343             disable altivec
2344         ;;
2345         g3|75*|ppc75*|powerpc75*)
2346             cpuflags="-mcpu=750 -mpowerpc-gfxopt"
2347             disable altivec
2348         ;;
2349         g4|745*|ppc745*|powerpc745*)
2350             cpuflags="-mcpu=7450 -mpowerpc-gfxopt"
2351         ;;
2352         74*|ppc74*|powerpc74*)
2353             cpuflags="-mcpu=7400 -mpowerpc-gfxopt"
2354         ;;
2355         g5|970|ppc970|powerpc970|power4*)
2356             cpuflags="-mcpu=970 -mpowerpc-gfxopt -mpowerpc64"
2357         ;;
2358         cell)
2359             cpuflags="-mcpu=cell"
2360             enable ldbrx
2361         ;;
2362         e500v2)
2363             cpuflags="-mcpu=8548 -mhard-float -mfloat-gprs=double"
2364             disable altivec
2365         ;;
2366         e500)
2367             cpuflags="-mcpu=8540 -mhard-float"
2368             disable altivec
2369         ;;
2370     esac
2371
2372 elif enabled x86; then
2373
2374     case $cpu in
2375         i[345]86|pentium)
2376             cpuflags="-march=$cpu"
2377             disable mmx
2378         ;;
2379         # targets that do NOT support conditional mov (cmov)
2380         pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
2381             cpuflags="-march=$cpu"
2382             disable cmov
2383         ;;
2384         # targets that do support conditional mov (cmov)
2385         i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64*|k8*|opteron*|athlon-fx|core2|amdfam10|barcelona|atom)
2386             cpuflags="-march=$cpu"
2387             enable cmov
2388             enable fast_cmov
2389         ;;
2390         # targets that do support conditional mov but on which it's slow
2391         pentium4|pentium4m|prescott|nocona)
2392             cpuflags="-march=$cpu"
2393             enable cmov
2394             disable fast_cmov
2395         ;;
2396     esac
2397
2398 elif enabled sparc; then
2399
2400     case $cpu in
2401         niagara)
2402             cpuflags="-mcpu=$cpu"
2403             disable vis
2404         ;;
2405         sparc64)
2406             cpuflags="-mcpu=v9"
2407         ;;
2408     esac
2409
2410 elif enabled arm; then
2411
2412     case $cpu in
2413         armv*)
2414             cpuflags="-march=$cpu"
2415             subarch=$(echo $cpu | sed 's/[^a-z0-9]//g')
2416         ;;
2417         *)
2418             cpuflags="-mcpu=$cpu"
2419             case $cpu in
2420                 cortex-a*)                               subarch=armv7a  ;;
2421                 cortex-r*)                               subarch=armv7r  ;;
2422                 cortex-m*)                 enable thumb; subarch=armv7m  ;;
2423                 arm11*)                                  subarch=armv6   ;;
2424                 arm[79]*e*|arm9[24]6*|arm96*|arm102[26]) subarch=armv5te ;;
2425                 armv4*|arm7*|arm9[24]*)                  subarch=armv4   ;;
2426             esac
2427         ;;
2428     esac
2429
2430 elif enabled alpha; then
2431
2432     enabled ccc && cpuflags="-arch $cpu" || cpuflags="-mcpu=$cpu"
2433
2434 elif enabled bfin; then
2435
2436     cpuflags="-mcpu=$cpu"
2437
2438 elif enabled mips; then
2439
2440     cpuflags="-march=$cpu"
2441
2442 elif enabled avr32; then
2443
2444     case $cpu in
2445         ap7[02]0[0-2])
2446             subarch="avr32_ap"
2447             cpuflags="-mpart=$cpu"
2448         ;;
2449         ap)
2450             subarch="avr32_ap"
2451             cpuflags="-march=$cpu"
2452         ;;
2453         uc3[ab]*)
2454             subarch="avr32_uc"
2455             cpuflags="-mcpu=$cpu"
2456         ;;
2457         uc)
2458             subarch="avr32_uc"
2459             cpuflags="-march=$cpu"
2460         ;;
2461     esac
2462
2463 fi
2464
2465 add_cflags $cpuflags
2466 add_asflags $cpuflags
2467
2468 # compiler sanity check
2469 check_exec <<EOF
2470 int main(void){ return 0; }
2471 EOF
2472 if test "$?" != 0; then
2473     echo "$cc is unable to create an executable file."
2474     if test -z "$cross_prefix" && ! enabled cross_compile ; then
2475         echo "If $cc is a cross-compiler, use the --enable-cross-compile option."
2476         echo "Only do this if you know what cross compiling means."
2477     fi
2478     die "C compiler test failed."
2479 fi
2480
2481 add_cppflags -D_ISOC99_SOURCE
2482 add_cxxflags -D__STDC_CONSTANT_MACROS
2483 check_cflags -std=c99
2484 check_cc -D_FILE_OFFSET_BITS=64 <<EOF && add_cppflags -D_FILE_OFFSET_BITS=64
2485 #include <stdlib.h>
2486 EOF
2487 check_cc -D_LARGEFILE_SOURCE <<EOF && add_cppflags -D_LARGEFILE_SOURCE
2488 #include <stdlib.h>
2489 EOF
2490
2491 check_host_cflags -std=c99
2492 check_host_cflags -Wall
2493
2494 case "$arch" in
2495     alpha|ia64|mips|parisc|sparc)
2496         spic=$shared
2497     ;;
2498     x86)
2499         subarch="x86_32"
2500         check_cc <<EOF && subarch="x86_64"
2501         int test[(int)sizeof(char*) - 7];
2502 EOF
2503         if test "$subarch" = "x86_64"; then
2504             spic=$shared
2505         fi
2506     ;;
2507     ppc)
2508         check_cc <<EOF && subarch="ppc64"
2509         int test[(int)sizeof(char*) - 7];
2510 EOF
2511     ;;
2512 esac
2513
2514 enable $subarch
2515 enabled spic && enable pic
2516
2517 # OS specific
2518 case $target_os in
2519     haiku)
2520         prefix_default="/boot/common"
2521         network_extralibs="-lnetwork"
2522         host_libs=
2523         ;;
2524     sunos)
2525         FFSERVERLDFLAGS=""
2526         SHFLAGS='-shared -Wl,-h,$$(@F)'
2527         enabled x86 && SHFLAGS="-mimpure-text $SHFLAGS"
2528         network_extralibs="-lsocket -lnsl"
2529         add_cppflags -D__EXTENSIONS__
2530         # When using suncc to build, the Solaris linker will mark
2531         # an executable with each instruction set encountered by
2532         # the Solaris assembler.  As our libraries contain their own
2533         # guards for processor-specific code, instead suppress
2534         # generation of the HWCAPS ELF section on Solaris x86 only.
2535         enabled_all suncc x86 && echo "hwcap_1 = OVERRIDE;" > mapfile && add_ldflags -Wl,-M,mapfile
2536         nm_opts='-P -g'
2537         ;;
2538     netbsd)
2539         disable symver
2540         oss_indev_extralibs="-lossaudio"
2541         oss_outdev_extralibs="-lossaudio"
2542         ;;
2543     openbsd)
2544         enable malloc_aligned
2545         # On OpenBSD 4.5. the compiler does not use PIC unless
2546         # explicitly using -fPIC. FFmpeg builds fine without PIC,
2547         # however the generated executable will not do anything
2548         # (simply quits with exit-code 1, no crash, no output).
2549         # Thus explicitly enable PIC here.
2550         enable pic
2551         disable symver
2552         SHFLAGS='-shared'
2553         oss_indev_extralibs="-lossaudio"
2554         oss_outdev_extralibs="-lossaudio"
2555         ;;
2556     dragonfly)
2557         enable malloc_aligned
2558         disable symver
2559         ;;
2560     freebsd)
2561         enable malloc_aligned
2562         ;;
2563     bsd/os)
2564         add_extralibs -lpoll -lgnugetopt
2565         strip="strip -d"
2566         ;;
2567     darwin)
2568         enable malloc_aligned
2569         gas="gas-preprocessor.pl $cc"
2570         enabled ppc && add_asflags -force_cpusubtype_ALL
2571         SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(SHLIBDIR)/$(SLIBNAME),-current_version,$(LIBVERSION),-compatibility_version,$(LIBMAJOR)'
2572         enabled x86_32 && append SHFLAGS -Wl,-read_only_relocs,suppress
2573         strip="${strip} -x"
2574         add_ldflags -Wl,-dynamic,-search_paths_first
2575         SLIBSUF=".dylib"
2576         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME).$(LIBVERSION)$(SLIBSUF)'
2577         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME).$(LIBMAJOR)$(SLIBSUF)'
2578         FFSERVERLDFLAGS=-Wl,-bind_at_load
2579         objformat="macho"
2580         enabled x86_64 && objformat="macho64"
2581         enabled_any pic shared ||
2582             { check_cflags -mdynamic-no-pic && add_asflags -mdynamic-no-pic; }
2583         ;;
2584     mingw32*)
2585         if test $target_os = "mingw32ce"; then
2586             disable network
2587         else
2588             target_os=mingw32
2589         fi
2590         LIBTARGET=i386
2591         if enabled x86_64; then
2592             enable malloc_aligned
2593             LIBTARGET=x64
2594         elif enabled arm; then
2595             LIBTARGET=arm-wince
2596         fi
2597         shlibdir_default="$bindir_default"
2598         SLIBPREF=""
2599         SLIBSUF=".dll"
2600         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
2601         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
2602         SLIB_EXTRA_CMD='-lib.exe /machine:$(LIBTARGET) /def:$$(@:$(SLIBSUF)=.def) /out:$(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib)'
2603         SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
2604         SLIB_INSTALL_LINKS=
2605         SLIB_INSTALL_EXTRA_SHLIB='$(SLIBNAME:$(SLIBSUF)=.lib)'
2606         SLIB_INSTALL_EXTRA_LIB='lib$(SLIBNAME:$(SLIBSUF)=.dll.a) $(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.def)'
2607         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'
2608         objformat="win32"
2609         enable dos_paths
2610         check_cflags -fno-common
2611         check_cpp_condition _mingw.h "defined (__MINGW64_VERSION_MAJOR) || (__MINGW32_MAJOR_VERSION > 3) \
2612                                       || (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" ||
2613                 die "ERROR: MinGW runtime version must be >= 3.15."
2614         add_cppflags -U__STRICT_ANSI__
2615         ;;
2616     cygwin*)
2617         target_os=cygwin
2618         shlibdir_default="$bindir_default"
2619         SLIBPREF="cyg"
2620         SLIBSUF=".dll"
2621         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
2622         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
2623         SHFLAGS='-shared -Wl,--enable-auto-image-base'
2624         objformat="win32"
2625         enable dos_paths
2626         check_cflags -fno-common
2627         add_cppflags -U__STRICT_ANSI__
2628         ;;
2629     *-dos|freedos|opendos)
2630         network_extralibs="-lsocket"
2631         objformat="coff"
2632         enable dos_paths
2633         add_cppflags -U__STRICT_ANSI__
2634         ;;
2635     linux)
2636         add_cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
2637         enable dv1394
2638         ;;
2639     irix*)
2640         target_os=irix
2641         ranlib="echo ignoring ranlib"
2642         ;;
2643     os/2*)
2644         strip="lxlite -CS"
2645         ln_s="cp -f"
2646         objformat="aout"
2647         add_cppflags -D_GNU_SOURCE
2648         add_ldflags -Zomf -Zbin-files -Zargs-wild -Zmap
2649         SHFLAGS='$(SUBDIR)$(NAME).def -Zdll -Zomf'
2650         FFSERVERLDFLAGS=""
2651         LIBSUF="_s.a"
2652         SLIBPREF=""
2653         SLIBSUF=".dll"
2654         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
2655         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(shell echo $(NAME) | cut -c1-6)$(LIBMAJOR)$(SLIBSUF)'
2656         SLIB_CREATE_DEF_CMD='echo LIBRARY $(SLIBNAME_WITH_MAJOR) INITINSTANCE TERMINSTANCE > $(SUBDIR)$(NAME).def; \
2657           echo PROTMODE >> $(SUBDIR)$(NAME).def; \
2658           echo CODE PRELOAD MOVEABLE DISCARDABLE >> $(SUBDIR)$(NAME).def; \
2659           echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $(SUBDIR)$(NAME).def; \
2660           echo EXPORTS >> $(SUBDIR)$(NAME).def; \
2661           emxexp -o $(OBJS) >> $(SUBDIR)$(NAME).def'
2662         SLIB_EXTRA_CMD='emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(NAME).def; \
2663           emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib $(SUBDIR)$(NAME).def;'
2664         SLIB_INSTALL_EXTRA_LIB='$(LIBPREF)$(NAME)_dll.a $(LIBPREF)$(NAME)_dll.lib'
2665         enable dos_paths
2666         enable_weak os2threads
2667         ;;
2668     gnu/kfreebsd)
2669         add_cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -D_BSD_SOURCE
2670         ;;
2671     gnu)
2672         add_cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
2673         ;;
2674     qnx)
2675         add_cppflags -D_QNX_SOURCE
2676         network_extralibs="-lsocket"
2677         ;;
2678     symbian)
2679         SLIBSUF=".dll"
2680         enable dos_paths
2681         add_cflags --include=$sysinclude/gcce/gcce.h -fvisibility=default
2682         add_cppflags -D__GCCE__ -D__SYMBIAN32__ -DSYMBIAN_OE_POSIX_SIGNALS
2683         add_ldflags -Wl,--target1-abs,--no-undefined \
2684                     -Wl,-Ttext,0x80000,-Tdata,0x1000000 -shared \
2685                     -Wl,--entry=_E32Startup -Wl,-u,_E32Startup
2686         add_extralibs -l:eexe.lib -l:usrt2_2.lib -l:dfpaeabi.dso \
2687                       -l:drtaeabi.dso -l:scppnwdl.dso -lsupc++ -lgcc \
2688                       -l:libc.dso -l:libm.dso -l:euser.dso -l:libcrt0.lib
2689         ;;
2690     none)
2691         ;;
2692     *)
2693         die "Unknown OS '$target_os'."
2694         ;;
2695 esac
2696
2697 echo "config:$arch:$subarch:$cpu:$target_os:$cc_ident:$FFMPEG_CONFIGURATION" >config.fate
2698
2699 check_cpp_condition stdlib.h "defined(__PIC__) || defined(__pic__) || defined(PIC)" && enable pic
2700
2701 set_default $PATHS_LIST
2702
2703 # we need to build at least one lib type
2704 if ! enabled_any static shared; then
2705     cat <<EOF
2706 At least one library type must be built.
2707 Specify --enable-static to build the static libraries or --enable-shared to
2708 build the shared libraries as well. To only build the shared libraries specify
2709 --disable-static in addition to --enable-shared.
2710 EOF
2711     exit 1;
2712 fi
2713
2714 die_license_disabled() {
2715     enabled $1 || { enabled $2 && die "$2 is $1 and --enable-$1 is not specified."; }
2716 }
2717
2718 die_license_disabled gpl libcdio
2719 die_license_disabled gpl libx264
2720 die_license_disabled gpl libxavs
2721 die_license_disabled gpl libxvid
2722 die_license_disabled gpl x11grab
2723
2724 die_license_disabled nonfree libaacplus
2725 die_license_disabled nonfree libfaac
2726 die_license_disabled nonfree openssl
2727
2728 die_license_disabled version3 libopencore_amrnb
2729 die_license_disabled version3 libopencore_amrwb
2730 die_license_disabled version3 libvo_aacenc
2731 die_license_disabled version3 libvo_amrwbenc
2732
2733 enabled version3 && { enabled gpl && enable gplv3 || enable lgplv3; }
2734
2735 disabled optimizations || check_cflags -fomit-frame-pointer
2736
2737 enable_pic() {
2738     enable pic
2739     add_cppflags -DPIC
2740     add_cflags   -fPIC
2741     add_asflags  -fPIC
2742 }
2743
2744 enabled pic && enable_pic
2745
2746 check_cc <<EOF || die "Symbol mangling check failed."
2747 int ff_extern;
2748 EOF
2749 sym=$($nm $nm_opts $TMPO | awk '/ff_extern/{ print substr($0, match($0, /[^ \t]*ff_extern/)) }')
2750 extern_prefix=${sym%%ff_extern*}
2751
2752 check_cc <<EOF && enable inline_asm
2753 void foo(void) { __asm__ volatile ("" ::); }
2754 EOF
2755
2756 _restrict=
2757 for restrict_keyword in restrict __restrict__ __restrict; do
2758     check_cc <<EOF && _restrict=$restrict_keyword && break
2759 void foo(char * $restrict_keyword p);
2760 EOF
2761 done
2762
2763 check_cc <<EOF && enable attribute_packed
2764 struct { int x; } __attribute__((packed)) x;
2765 EOF
2766
2767 check_cc <<EOF && enable attribute_may_alias
2768 union { int x; } __attribute__((may_alias)) x;
2769 EOF
2770
2771 check_cc <<EOF || die "endian test failed"
2772 unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
2773 EOF
2774 od -t x1 $TMPO | grep -q '42 *49 *47 *45' && enable bigendian
2775
2776 if enabled alpha; then
2777
2778     check_cflags -mieee
2779
2780 elif enabled arm; then
2781
2782     enabled thumb && check_cflags -mthumb || check_cflags -marm
2783     nogas=die
2784
2785     if     check_cpp_condition stddef.h "defined __ARM_PCS_VFP"; then
2786         enable vfp_args
2787     elif ! check_cpp_condition stddef.h "defined __ARM_PCS || defined __SOFTFP__"; then
2788         case "${cross_prefix:-$cc}" in
2789             *hardfloat*)         enable vfp_args;   fpabi=vfp ;;
2790             *) check_ld "cc" <<EOF && enable vfp_args && fpabi=vfp || fpabi=soft ;;
2791 __asm__ (".eabi_attribute 28, 1");
2792 int main(void) { return 0; }
2793 EOF
2794         esac
2795         warn "Compiler does not indicate floating-point ABI, guessing $fpabi."
2796     fi
2797
2798     enabled armv5te && check_asm armv5te '"qadd r0, r0, r0"'
2799     enabled armv6   && check_asm armv6   '"sadd16 r0, r0, r0"'
2800     enabled armv6t2 && check_asm armv6t2 '"movt r0, #0"'
2801     enabled armvfp  && check_asm armvfp  '"fadds s0, s0, s0"'
2802     enabled iwmmxt  && check_asm iwmmxt  '"wunpckelub wr6, wr4"'
2803     enabled neon    && check_asm neon    '"vadd.i16 q0, q0, q0"'
2804     enabled vfpv3   && check_asm vfpv3   '"vmov.f32 s0, #1.0"'
2805
2806     check_asm asm_mod_y '"vmul.i32 d0, d0, %y0" :: "x"(0)'
2807
2808     enabled_all armv6t2 shared !pic && enable_pic
2809
2810 elif enabled mips; then
2811
2812     check_asm loongson '"dmult.g $1, $2, $3"'
2813     enabled mmi     && check_asm mmi     '"lq $2, 0($2)"'
2814
2815 elif enabled ppc; then
2816
2817     enable local_aligned_8 local_aligned_16
2818
2819     check_asm dcbzl     '"dcbzl 0, %0" :: "r"(0)'
2820     check_asm ibm_asm   '"add 0, 0, 0"'
2821     check_asm ppc4xx    '"maclhw r10, r11, r12"'
2822     check_asm xform_asm '"lwzx %1, %y0" :: "Z"(*(int*)0), "r"(0)'
2823
2824     # AltiVec flags: The FSF version of GCC differs from the Apple version
2825     if enabled altivec; then
2826         nogas=warn
2827         check_cflags -maltivec -mabi=altivec &&
2828         { check_header altivec.h && inc_altivec_h="#include <altivec.h>" ; } ||
2829         check_cflags -faltivec
2830
2831         # check if our compiler supports Motorola AltiVec C API
2832         check_cc <<EOF || disable altivec
2833 $inc_altivec_h
2834 int main(void) {
2835     vector signed int v1, v2, v3;
2836     v1 = vec_add(v2,v3);
2837     return 0;
2838 }
2839 EOF
2840
2841         # check if our compiler supports braces for vector declarations
2842         check_cc <<EOF || die "You need a compiler that supports {} in AltiVec vector declarations."
2843 $inc_altivec_h
2844 int main (void) { (vector int) {1}; return 0; }
2845 EOF
2846     fi
2847
2848 elif enabled sparc; then
2849
2850     enabled vis && check_asm vis '"pdist %f0, %f0, %f0"' -mcpu=ultrasparc &&
2851         add_cflags -mcpu=ultrasparc -mtune=ultrasparc
2852
2853 elif enabled x86; then
2854
2855     enable local_aligned_8 local_aligned_16
2856
2857     # check whether EBP is available on x86
2858     # As 'i' is stored on the stack, this program will crash
2859     # if the base pointer is used to access it because the
2860     # base pointer is cleared in the inline assembly code.
2861     check_exec_crash <<EOF && enable ebp_available
2862     volatile int i=0;
2863     __asm__ volatile (
2864         "xorl %%ebp, %%ebp"
2865     ::: "%ebp");
2866     return i;
2867 EOF
2868
2869     # check whether EBX is available on x86
2870     check_asm ebx_available '""::"b"(0)' &&
2871         check_asm ebx_available '"":::"%ebx"'
2872
2873     # check whether xmm clobbers are supported
2874     check_asm xmm_clobbers '"":::"%xmm0"'
2875
2876     # check whether binutils is new enough to compile SSSE3/MMX2
2877     enabled ssse3 && check_asm ssse3 '"pabsw %xmm0, %xmm0"'
2878     enabled mmx2  && check_asm mmx2  '"pmaxub %mm0, %mm1"'
2879
2880     check_asm bswap '"bswap %%eax" ::: "%eax"'
2881
2882     if ! disabled_any asm mmx yasm; then
2883         if check_cmd $yasmexe --version; then
2884             enabled x86_64 && yasm_extra="-m amd64"
2885             yasm_debug="-g dwarf2"
2886         elif check_cmd nasm -v; then
2887             yasmexe=nasm
2888             yasm_debug="-g -F dwarf"
2889             enabled x86_64 && test "$objformat" = elf && objformat=elf64
2890         fi
2891
2892         YASMFLAGS="-f $objformat $yasm_extra"
2893         enabled pic               && append YASMFLAGS "-DPIC"
2894         test -n "$extern_prefix"  && append YASMFLAGS "-DPREFIX"
2895         case "$objformat" in
2896             elf*) enabled debug && append YASMFLAGS $yasm_debug ;;
2897         esac
2898
2899         check_yasm "pextrd [eax], xmm0, 1" && enable yasm ||
2900             die "yasm not found, use --disable-yasm for a crippled build"
2901         check_yasm "vextractf128 xmm0, ymm0, 0" || disable avx
2902     fi
2903
2904     case "$cpu" in
2905         athlon*|opteron*|k8*|pentium|pentium-mmx|prescott|nocona|atom|geode)
2906             disable fast_clz
2907         ;;
2908     esac
2909
2910 fi
2911
2912 if enabled asm; then
2913     as=${gas:=$as}
2914     check_asm gnu_as '".macro m n\n\\n:.int 0\n.endm\nm x"' ||
2915         $nogas "GNU assembler not found, install gas-preprocessor"
2916 fi
2917
2918 check_ldflags -Wl,--as-needed
2919
2920 if check_func dlopen; then
2921     ldl=
2922 elif check_func dlopen -ldl; then
2923     ldl=-ldl
2924 fi
2925
2926 if enabled network; then
2927     check_type "sys/types.h sys/socket.h" socklen_t
2928     check_type netdb.h "struct addrinfo"
2929     check_type netinet/in.h "struct ipv6_mreq" -D_DARWIN_C_SOURCE
2930     check_type netinet/in.h "struct sockaddr_in6"
2931     check_type "sys/types.h sys/socket.h" "struct sockaddr_storage"
2932     check_struct "sys/types.h sys/socket.h" "struct sockaddr" sa_len
2933     # Prefer arpa/inet.h over winsock2
2934     if check_header arpa/inet.h ; then
2935         check_func closesocket
2936     elif check_header winsock2.h ; then
2937         check_func_headers winsock2.h closesocket -lws2 && \
2938             network_extralibs="-lws2" || \
2939         { check_func_headers winsock2.h closesocket -lws2_32 && \
2940             network_extralibs="-lws2_32"; }
2941         check_type ws2tcpip.h socklen_t
2942         check_type ws2tcpip.h "struct addrinfo"
2943         check_type ws2tcpip.h "struct ipv6_mreq"
2944         check_type ws2tcpip.h "struct sockaddr_in6"
2945         check_type ws2tcpip.h "struct sockaddr_storage"
2946         check_struct winsock2.h "struct sockaddr" sa_len
2947     else
2948         disable network
2949     fi
2950 fi
2951
2952 # Solaris has nanosleep in -lrt, OpenSolaris no longer needs that
2953 check_func nanosleep || { check_func nanosleep -lrt && add_extralibs -lrt; }
2954
2955 check_func  fcntl
2956 check_func  fork
2957 check_func  getaddrinfo $network_extralibs
2958 check_func  gethrtime
2959 check_func  getrusage
2960 check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss
2961 check_func  inet_aton $network_extralibs
2962 check_func  isatty
2963 check_func  localtime_r
2964 check_func  ${malloc_prefix}memalign            && enable memalign
2965 check_func  mkstemp
2966 check_func  mmap
2967 check_func  ${malloc_prefix}posix_memalign      && enable posix_memalign
2968 check_func  setrlimit
2969 check_func  strerror_r
2970 check_func  strptime
2971 check_func_headers conio.h kbhit
2972 check_func_headers windows.h PeekNamedPipe
2973 check_func_headers io.h setmode
2974 check_func_headers lzo/lzo1x.h lzo1x_999_compress
2975 check_lib2 "windows.h psapi.h" GetProcessMemoryInfo -lpsapi
2976 check_func_headers windows.h GetProcessTimes
2977 check_func_headers windows.h MapViewOfFile
2978 check_func_headers windows.h VirtualAlloc
2979
2980 check_header dlfcn.h
2981 check_header dxva2api.h -D_WIN32_WINNT=0x0600
2982 check_header libcrystalhd/libcrystalhd_if.h
2983 check_header malloc.h
2984 check_header poll.h
2985 check_header sys/mman.h
2986 check_header sys/resource.h
2987 check_header sys/select.h
2988 check_header termios.h
2989 check_header vdpau/vdpau.h
2990 check_header vdpau/vdpau_x11.h
2991 check_header X11/extensions/XvMClib.h
2992
2993 disabled  zlib || check_lib   zlib.h      zlibVersion -lz   || disable  zlib
2994 disabled bzlib || check_lib2 bzlib.h BZ2_bzlibVersion -lbz2 || disable bzlib
2995
2996 # check for VDA header
2997 if ! disabled vda; then
2998     if check_header VideoDecodeAcceleration/VDADecoder.h; then
2999         enable vda
3000         add_ldflags -framework CoreFoundation -framework VideoDecodeAcceleration -framework QuartzCore
3001     fi
3002 fi
3003
3004 if ! disabled w32threads && ! enabled pthreads; then
3005     check_func _beginthreadex && enable w32threads
3006 fi
3007
3008 # check for some common methods of building with pthread support
3009 # do this before the optional library checks as some of them require pthreads
3010 if ! disabled pthreads && ! enabled w32threads && ! enabled os2threads; then
3011     enable pthreads
3012     if check_func pthread_create; then
3013         :
3014     elif check_func pthread_create -pthread; then
3015         add_cflags -pthread
3016         add_extralibs -pthread
3017     elif check_func pthread_create -pthreads; then
3018         add_cflags -pthreads
3019         add_extralibs -pthreads
3020     elif check_func pthread_create -lpthreadGC2; then
3021         add_extralibs -lpthreadGC2
3022     elif ! check_lib pthread.h pthread_create -lpthread; then
3023         disable pthreads
3024     fi
3025 fi
3026
3027 for thread in $THREADS_LIST; do
3028     if enabled $thread; then
3029         test -n "$thread_type" &&
3030             die "ERROR: Only one thread type must be selected." ||
3031             thread_type="$thread"
3032     fi
3033 done
3034
3035 check_lib math.h sin -lm && LIBM="-lm"
3036 disabled crystalhd || check_lib libcrystalhd/libcrystalhd_if.h DtsCrystalHDVersion -lcrystalhd || disable crystalhd
3037 enabled vaapi && require vaapi va/va.h vaInitialize -lva
3038
3039 check_mathfunc cbrtf
3040 check_mathfunc exp2
3041 check_mathfunc exp2f
3042 check_mathfunc llrint
3043 check_mathfunc llrintf
3044 check_mathfunc log2
3045 check_mathfunc log2f
3046 check_mathfunc lrint
3047 check_mathfunc lrintf
3048 check_mathfunc round
3049 check_mathfunc roundf
3050 check_mathfunc trunc
3051 check_mathfunc truncf
3052
3053 # these are off by default, so fail if requested and not available
3054 enabled avisynth   && require2 vfw32 "windows.h vfw.h" AVIFileInit -lavifil32
3055 enabled libcelt    && require libcelt celt/celt.h celt_decode -lcelt0
3056 enabled frei0r     && { check_header frei0r.h || die "ERROR: frei0r.h header not found"; }
3057 enabled libaacplus && require  "libaacplus >= 2.0.0" aacplus.h aacplusEncOpen -laacplus
3058 enabled libdc1394  && require_pkg_config libdc1394-2 dc1394/dc1394.h dc1394_new
3059 enabled gnutls     && require_pkg_config gnutls gnutls/gnutls.h gnutls_global_init
3060 enabled libdirac   && require_pkg_config dirac                          \
3061     "libdirac_decoder/dirac_parser.h libdirac_encoder/dirac_encoder.h"  \
3062     "dirac_decoder_init dirac_encoder_init"
3063 enabled libfaac    && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
3064 enabled libfreetype && require_pkg_config freetype2 "ft2build.h freetype/freetype.h" FT_Init_FreeType
3065 enabled libgsm     && require  libgsm gsm/gsm.h gsm_create -lgsm
3066 enabled libmodplug && require  libmodplug libmodplug/modplug.h ModPlug_Load -lmodplug
3067 enabled libmp3lame && require  "libmp3lame >= 3.98.3" lame/lame.h lame_set_VBR_quality -lmp3lame
3068 enabled libnut     && require  libnut libnut.h nut_demuxer_init -lnut
3069 enabled libopencore_amrnb  && require libopencore_amrnb opencore-amrnb/interf_dec.h Decoder_Interface_init -lopencore-amrnb
3070 enabled libopencore_amrwb  && require libopencore_amrwb opencore-amrwb/dec_if.h D_IF_init -lopencore-amrwb
3071 enabled libopencv  && require_pkg_config opencv opencv/cxcore.h cvCreateImageHeader
3072 enabled libopenjpeg && require libopenjpeg openjpeg.h opj_version -lopenjpeg
3073 enabled libpulse && require_pkg_config libpulse-simple pulse/simple.h pa_simple_new
3074 enabled librtmp    && require_pkg_config librtmp librtmp/rtmp.h RTMP_Socket
3075 enabled libschroedinger && require_pkg_config schroedinger-1.0 schroedinger/schro.h schro_init
3076 enabled libspeex   && require  libspeex speex/speex.h speex_decoder_init -lspeex
3077 enabled libstagefright_h264  && require_cpp libstagefright_h264 "binder/ProcessState.h media/stagefright/MetaData.h
3078     media/stagefright/MediaBufferGroup.h media/stagefright/MediaDebug.h media/stagefright/MediaDefs.h
3079     media/stagefright/OMXClient.h media/stagefright/OMXCodec.h" android::OMXClient -lstagefright -lmedia -lutils -lbinder
3080 enabled libtheora  && require  libtheora theora/theoraenc.h th_info_init -ltheoraenc -ltheoradec -logg
3081 enabled libutvideo    && require_cpp utvideo "stdint.h stdlib.h utvideo/utvideo.h utvideo/Codec.h" 'CCodec*' -lutvideo -lstdc++
3082 enabled libv4l2    && require_pkg_config libv4l2 libv4l2.h v4l2_ioctl
3083 enabled libvo_aacenc && require libvo_aacenc vo-aacenc/voAAC.h voGetAACEncAPI -lvo-aacenc
3084 enabled libvo_amrwbenc && require libvo_amrwbenc vo-amrwbenc/enc_if.h E_IF_init -lvo-amrwbenc
3085 enabled libvorbis  && require  libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
3086 enabled libvpx     && {
3087     enabled libvpx_decoder && { check_lib2 "vpx/vpx_decoder.h vpx/vp8dx.h" vpx_codec_dec_init_ver -lvpx ||
3088                                 die "ERROR: libvpx decoder version must be >=0.9.1"; }
3089     enabled libvpx_encoder && { check_lib2 "vpx/vpx_encoder.h vpx/vp8cx.h" "vpx_codec_enc_init_ver VPX_CQ" -lvpx ||
3090                                 die "ERROR: libvpx encoder version must be >=0.9.6"; } }
3091 enabled libx264    && require  libx264 x264.h x264_encoder_encode -lx264 &&
3092                       { check_cpp_condition x264.h "X264_BUILD >= 118" ||
3093                         die "ERROR: libx264 version must be >= 0.118."; }
3094 enabled libxavs    && require  libxavs xavs.h xavs_encoder_encode -lxavs
3095 enabled libxvid    && require  libxvid xvid.h xvid_global -lxvidcore
3096 enabled openal     && { { for al_libs in "${OPENAL_LIBS}" "-lopenal" "-lOpenAL32"; do
3097                         check_lib 'AL/al.h' alGetError "${al_libs}" && break; done } ||
3098                         die "ERROR: openal not found"; } &&
3099                       { check_cpp_condition "AL/al.h" "defined(AL_VERSION_1_1)" ||
3100                         die "ERROR: openal version must be 1.1 or compatible"; }
3101 enabled mlib       && require  mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
3102 enabled openssl    && { check_lib openssl/ssl.h SSL_library_init -lssl -lcrypto ||
3103                         check_lib openssl/ssl.h SSL_library_init -lssl32 -leay32 ||
3104                         check_lib openssl/ssl.h SSL_library_init -lssl -lcrypto -lws2_32 -lgdi32 ||
3105                         die "ERROR: openssl not found"; }
3106
3107 SDL_CONFIG="${cross_prefix}sdl-config"
3108 if check_pkg_config sdl SDL_version.h SDL_Linked_Version; then
3109     check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x010201" $sdl_cflags &&
3110     enable sdl &&
3111     check_struct SDL.h SDL_VideoInfo current_w $sdl_cflags && enable sdl_video_size
3112 else
3113   if "${SDL_CONFIG}" --version > /dev/null 2>&1; then
3114     sdl_cflags=$("${SDL_CONFIG}" --cflags)
3115     sdl_libs=$("${SDL_CONFIG}" --libs)
3116     check_func_headers SDL_version.h SDL_Linked_Version $sdl_cflags $sdl_libs &&
3117     check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x010201" $sdl_cflags &&
3118     enable sdl &&
3119     check_struct SDL.h SDL_VideoInfo current_w $sdl_cflags && enable sdl_video_size
3120   fi
3121 fi
3122 enabled sdl && add_cflags $sdl_cflags && add_extralibs $sdl_libs
3123
3124 texi2html -version > /dev/null 2>&1 && enable texi2html || disable texi2html
3125
3126 check_header linux/fb.h
3127 check_header linux/videodev.h
3128 check_header linux/videodev2.h
3129 check_header sys/videoio.h
3130
3131 check_func_headers "windows.h vfw.h" capCreateCaptureWindow "$vfwcap_indev_extralibs"
3132 # check that WM_CAP_DRIVER_CONNECT is defined to the proper value
3133 # w32api 3.12 had it defined wrong
3134 check_cpp_condition vfw.h "WM_CAP_DRIVER_CONNECT > WM_USER" && enable vfwcap_defines
3135
3136 check_type "dshow.h" IBaseFilter
3137
3138 # check for ioctl_meteor.h, ioctl_bt848.h and alternatives
3139 { check_header dev/bktr/ioctl_meteor.h &&
3140   check_header dev/bktr/ioctl_bt848.h; } ||
3141 { check_header machine/ioctl_meteor.h &&
3142   check_header machine/ioctl_bt848.h; } ||
3143 { check_header dev/video/meteor/ioctl_meteor.h &&
3144   check_header dev/video/bktr/ioctl_bt848.h; } ||
3145 check_header dev/ic/bt8xx.h
3146
3147 check_header sndio.h
3148 if check_struct sys/soundcard.h audio_buf_info bytes; then
3149     enable_safe sys/soundcard.h
3150 else
3151     check_cc -D__BSD_VISIBLE -D__XSI_VISIBLE <<EOF && add_cppflags -D__BSD_VISIBLE -D__XSI_VISIBLE && enable_safe sys/soundcard.h
3152     #include <sys/soundcard.h>
3153     audio_buf_info abc;
3154 EOF
3155 fi
3156 check_header soundcard.h
3157
3158 enabled_any alsa_indev alsa_outdev && check_lib2 alsa/asoundlib.h snd_pcm_htimestamp -lasound
3159
3160 enabled jack_indev && check_lib2 jack/jack.h jack_client_open -ljack && check_func sem_timedwait
3161
3162 enabled_any sndio_indev sndio_outdev && check_lib2 sndio.h sio_open -lsndio
3163
3164 enabled libcdio &&
3165     check_lib2 "cdio/cdda.h cdio/paranoia.h" cdio_cddap_open "-lcdio_paranoia -lcdio_cdda -lcdio"
3166
3167 enabled x11grab                         &&
3168 check_header X11/Xlib.h                 &&
3169 check_header X11/extensions/XShm.h      &&
3170 check_header X11/extensions/Xfixes.h    &&
3171 check_func XOpenDisplay -lX11           &&
3172 check_func XShmCreateImage -lX11 -lXext &&
3173 check_func XFixesGetCursorImage -lX11 -lXext -lXfixes
3174
3175 if ! disabled vaapi; then
3176     check_lib va/va.h vaInitialize -lva && {
3177         check_cpp_condition va/va_version.h "VA_CHECK_VERSION(0,32,0)" ||
3178         warn "Please upgrade to VA-API >= 0.32 if you would like full VA-API support.";
3179     } || disable vaapi
3180 fi
3181
3182 if ! disabled vdpau && enabled vdpau_vdpau_h; then
3183 check_cpp_condition \
3184     vdpau/vdpau.h "defined VDP_DECODER_PROFILE_MPEG4_PART2_ASP" ||
3185     { echolog "Please upgrade to libvdpau >= 0.2 if you would like vdpau support." &&
3186       disable vdpau; }
3187 fi
3188
3189 enabled debug && add_cflags -g"$debuglevel" && add_asflags -g"$debuglevel"
3190
3191 # add some useful compiler flags if supported
3192 check_cflags -Wdeclaration-after-statement
3193 check_cflags -Wall
3194 check_cflags -Wno-parentheses
3195 check_cflags -Wno-switch
3196 check_cflags -Wno-format-zero-length
3197 check_cflags -Wdisabled-optimization
3198 check_cflags -Wpointer-arith
3199 check_cflags -Wredundant-decls
3200 check_cflags -Wno-pointer-sign
3201 check_cflags -Wcast-qual
3202 check_cflags -Wwrite-strings
3203 check_cflags -Wtype-limits
3204 check_cflags -Wundef
3205 check_cflags -Wmissing-prototypes
3206 check_cflags -Wno-pointer-to-int-cast
3207 check_cflags -Wstrict-prototypes
3208 enabled extra_warnings && check_cflags -Winline
3209
3210 # add some linker flags
3211 check_ldflags -Wl,--warn-common
3212 check_ldflags -Wl,-rpath-link=libpostproc:libswresample:libswscale:libavfilter:libavdevice:libavformat:libavcodec:libavutil
3213 test_ldflags -Wl,-Bsymbolic && append SHFLAGS -Wl,-Bsymbolic
3214
3215 echo "X{};" > $TMPV
3216 if test_ldflags -Wl,--version-script,$TMPV; then
3217     append SHFLAGS '-Wl,--version-script,\$(SUBDIR)lib\$(NAME).ver'
3218     check_cc <<EOF && enable symver_asm_label
3219 void ff_foo(void) __asm__ ("av_foo@VERSION");
3220 void ff_foo(void) { ${inline_asm+__asm__($quotes);} }
3221 EOF
3222     check_cc <<EOF && enable symver_gnu_asm
3223 __asm__(".symver ff_foo,av_foo@VERSION");
3224 void ff_foo(void) {}
3225 EOF
3226 fi
3227
3228 if [ -n "$optflags" ]; then
3229     add_cflags $optflags
3230 elif enabled small; then
3231     add_cflags $size_cflags
3232 elif enabled optimizations; then
3233     add_cflags $speed_cflags
3234 else
3235     add_cflags $noopt_cflags
3236 fi
3237 check_cflags -fno-math-errno
3238 check_cflags -fno-signed-zeros
3239 check_cc -mno-red-zone <<EOF && noredzone_flags="-mno-red-zone"
3240 int x;
3241 EOF
3242
3243
3244 if enabled icc; then
3245     # Just warnings, no remarks
3246     check_cflags -w1
3247     # -wd: Disable following warnings
3248     # 144, 167, 556: -Wno-pointer-sign
3249     # 1292: attribute "foo" ignored
3250     # 10006: ignoring unknown option -fno-signed-zeros
3251     # 10148: ignoring unknown option -Wno-parentheses
3252     # 10156: ignoring option '-W'; no argument required
3253     check_cflags -wd144,167,556,1292,10006,10148,10156
3254     # 11030: Warning unknown option --as-needed
3255     # 10156: ignoring option '-export'; no argument required
3256     check_ldflags -wd10156,11030
3257     # Allow to compile with optimizations
3258     check_ldflags -march=$cpu
3259     # icc 11.0 and 11.1 work with ebp_available, but don't pass the test
3260     enable ebp_available
3261     if enabled x86_32; then
3262         test ${icc_version%%.*} -ge 11 && \
3263             check_cflags -falign-stack=maintain-16-byte || \
3264             disable aligned_stack
3265     fi
3266 elif enabled ccc; then
3267     # disable some annoying warnings
3268     add_cflags -msg_disable cvtu32to64
3269     add_cflags -msg_disable embedcomment
3270     add_cflags -msg_disable needconstext
3271     add_cflags -msg_disable nomainieee
3272     add_cflags -msg_disable ptrmismatch1
3273     add_cflags -msg_disable unreachcode
3274 elif enabled gcc; then
3275     check_cflags -fno-tree-vectorize
3276     check_cflags -Werror=implicit-function-declaration
3277     check_cflags -Werror=missing-prototypes
3278 elif enabled llvm_gcc; then
3279     check_cflags -mllvm -stack-alignment=16
3280 elif enabled clang; then
3281     check_cflags -mllvm -stack-alignment=16
3282     check_cflags -Qunused-arguments
3283 elif enabled armcc; then
3284     # 2523: use of inline assembler is deprecated
3285     add_cflags -W${armcc_opt},--diag_suppress=2523
3286     add_cflags -W${armcc_opt},--diag_suppress=1207
3287     add_cflags -W${armcc_opt},--diag_suppress=1293 # assignment in condition
3288     add_cflags -W${armcc_opt},--diag_suppress=3343 # hardfp compat
3289     add_cflags -W${armcc_opt},--diag_suppress=167  # pointer sign
3290     add_cflags -W${armcc_opt},--diag_suppress=513  # pointer sign
3291 elif enabled tms470; then
3292     add_cflags -pds=824 -pds=837
3293 elif enabled pathscale; then
3294     add_cflags -fstrict-overflow -OPT:wrap_around_unsafe_opt=OFF
3295 fi
3296
3297 enabled_any $THREADS_LIST      && enable threads
3298
3299 check_deps $CONFIG_LIST       \
3300            $CONFIG_EXTRA      \
3301            $HAVE_LIST         \
3302            $DECODER_LIST      \
3303            $ENCODER_LIST      \
3304            $HWACCEL_LIST      \
3305            $PARSER_LIST       \
3306            $BSF_LIST          \
3307            $DEMUXER_LIST      \
3308            $MUXER_LIST        \
3309            $FILTER_LIST       \
3310            $INDEV_LIST        \
3311            $OUTDEV_LIST       \
3312            $PROTOCOL_LIST     \
3313            $ACODEC_TESTS      \
3314            $VCODEC_TESTS      \
3315            $LAVF_TESTS        \
3316            $LAVFI_TESTS       \
3317            $SEEK_TESTS        \
3318
3319 enabled asm || { arch=c; disable $ARCH_LIST $ARCH_EXT_LIST; }
3320
3321 if test $target_os = "haiku"; then
3322     disable memalign
3323     disable posix_memalign
3324 fi
3325
3326 ! enabled_any memalign posix_memalign malloc_aligned &&
3327     enabled_any $need_memalign && enable memalign_hack
3328
3329 echo "install prefix            $prefix"
3330 echo "source path               $source_path"
3331 echo "C compiler                $cc"
3332 echo "ARCH                      $arch ($cpu)"
3333 if test "$build_suffix" != ""; then
3334     echo "build suffix              $build_suffix"
3335 fi
3336 if test "$progs_suffix" != ""; then
3337     echo "progs suffix              $progs_suffix"
3338 fi
3339 if test "$extra_version" != ""; then
3340     echo "version string suffix     $extra_version"
3341 fi
3342 echo "big-endian                ${bigendian-no}"
3343 echo "runtime cpu detection     ${runtime_cpudetect-no}"
3344 if enabled x86; then
3345     echo "${yasmexe}                      ${yasm-no}"
3346     echo "MMX enabled               ${mmx-no}"
3347     echo "MMX2 enabled              ${mmx2-no}"
3348     echo "3DNow! enabled            ${amd3dnow-no}"
3349     echo "3DNow! extended enabled   ${amd3dnowext-no}"
3350     echo "SSE enabled               ${sse-no}"
3351     echo "SSSE3 enabled             ${ssse3-no}"
3352     echo "AVX enabled               ${avx-no}"
3353     echo "CMOV enabled              ${cmov-no}"
3354     echo "CMOV is fast              ${fast_cmov-no}"
3355     echo "EBX available             ${ebx_available-no}"
3356     echo "EBP available             ${ebp_available-no}"
3357 fi
3358 if enabled arm; then
3359     echo "ARMv5TE enabled           ${armv5te-no}"
3360     echo "ARMv6 enabled             ${armv6-no}"
3361     echo "ARMv6T2 enabled           ${armv6t2-no}"
3362     echo "ARM VFP enabled           ${armvfp-no}"
3363     echo "IWMMXT enabled            ${iwmmxt-no}"
3364     echo "NEON enabled              ${neon-no}"
3365 fi
3366 if enabled mips; then
3367     echo "MMI enabled               ${mmi-no}"
3368 fi
3369 if enabled ppc; then
3370     echo "AltiVec enabled           ${altivec-no}"
3371     echo "PPC 4xx optimizations     ${ppc4xx-no}"
3372     echo "dcbzl available           ${dcbzl-no}"
3373 fi
3374 if enabled sparc; then
3375     echo "VIS enabled               ${vis-no}"
3376 fi
3377 echo "debug symbols             ${debug-no}"
3378 echo "strip symbols             ${stripping-no}"
3379 echo "optimize for size         ${small-no}"
3380 echo "optimizations             ${optimizations-no}"
3381 echo "static                    ${static-no}"
3382 echo "shared                    ${shared-no}"
3383 echo "postprocessing support    ${postproc-no}"
3384 echo "new filter support        ${avfilter-no}"
3385 echo "network support           ${network-no}"
3386 echo "threading support         ${thread_type-no}"
3387 echo "SDL support               ${sdl-no}"
3388 echo "Sun medialib support      ${mlib-no}"
3389 echo "libdxva2 enabled          ${dxva2-no}"
3390 echo "libva enabled             ${vaapi-no}"
3391 echo "libvdpau enabled          ${vdpau-no}"
3392 echo "AVISynth enabled          ${avisynth-no}"
3393 echo "libcelt enabled           ${libcelt-no}"
3394 echo "frei0r enabled            ${frei0r-no}"
3395 echo "gnutls enabled            ${gnutls-no}"
3396 echo "libcdio support           ${libcdio-no}"
3397 echo "libdc1394 support         ${libdc1394-no}"
3398 echo "libdirac enabled          ${libdirac-no}"
3399 echo "libfaac enabled           ${libfaac-no}"
3400 echo "libaacplus enabled        ${libaacplus-no}"
3401 echo "libgsm enabled            ${libgsm-no}"
3402 echo "libmodplug enabled        ${libmodplug-no}"
3403 echo "libmp3lame enabled        ${libmp3lame-no}"
3404 echo "libnut enabled            ${libnut-no}"
3405 echo "libopencore-amrnb support ${libopencore_amrnb-no}"
3406 echo "libopencore-amrwb support ${libopencore_amrwb-no}"
3407 echo "libopencv support         ${libopencv-no}"
3408 echo "libopenjpeg enabled       ${libopenjpeg-no}"
3409 echo "libpulse enabled          ${libpulse-no}"
3410 echo "librtmp enabled           ${librtmp-no}"
3411 echo "libschroedinger enabled   ${libschroedinger-no}"
3412 echo "libspeex enabled          ${libspeex-no}"
3413 echo "libstagefright-h264 enabled    ${libstagefright_h264-no}"
3414 echo "libtheora enabled         ${libtheora-no}"
3415 echo "libutvideo enabled        ${libutvideo-no}"
3416 echo "libv4l2 enabled           ${libv4l2-no}"
3417 echo "libvo-aacenc support      ${libvo_aacenc-no}"
3418 echo "libvo-amrwbenc support    ${libvo_amrwbenc-no}"
3419 echo "libvorbis enabled         ${libvorbis-no}"
3420 echo "libvpx enabled            ${libvpx-no}"
3421 echo "libx264 enabled           ${libx264-no}"
3422 echo "libxavs enabled           ${libxavs-no}"
3423 echo "libxvid enabled           ${libxvid-no}"
3424 echo "openal enabled            ${openal-no}"
3425 echo "openssl enabled           ${openssl-no}"
3426 echo "zlib enabled              ${zlib-no}"
3427 echo "bzlib enabled             ${bzlib-no}"
3428 echo
3429
3430 for type in decoder encoder hwaccel parser demuxer muxer protocol filter bsf indev outdev; do
3431     echo "Enabled ${type}s:"
3432     eval list=\$$(toupper $type)_LIST
3433     print_enabled '_*' $list | sort | pr -r -3 -t
3434     echo
3435 done
3436
3437 license="LGPL version 2.1 or later"
3438 if enabled nonfree; then
3439     license="nonfree and unredistributable"
3440 elif enabled gplv3; then
3441     license="GPL version 3 or later"
3442 elif enabled lgplv3; then
3443     license="LGPL version 3 or later"
3444 elif enabled gpl; then
3445     license="GPL version 2 or later"
3446 fi
3447
3448 echo "License: $license"
3449
3450 echo "Creating config.mak and config.h..."
3451
3452 test -e Makefile || $ln_s "$source_path/Makefile" .
3453
3454 enabled stripping || strip="echo skipping strip"
3455
3456 config_files="$TMPH config.mak"
3457
3458 cat > config.mak <<EOF
3459 # Automatically generated by configure - do not modify!
3460 ifndef FFMPEG_CONFIG_MAK
3461 FFMPEG_CONFIG_MAK=1
3462 FFMPEG_CONFIGURATION=$FFMPEG_CONFIGURATION
3463 prefix=$prefix
3464 LIBDIR=\$(DESTDIR)$libdir
3465 SHLIBDIR=\$(DESTDIR)$shlibdir
3466 INCDIR=\$(DESTDIR)$incdir
3467 BINDIR=\$(DESTDIR)$bindir
3468 DATADIR=\$(DESTDIR)$datadir
3469 MANDIR=\$(DESTDIR)$mandir
3470 SRC_PATH=$source_path
3471 ifndef MAIN_MAKEFILE
3472 SRC_PATH:=\$(SRC_PATH:.%=..%)
3473 endif
3474 CC_IDENT=$cc_ident
3475 ARCH=$arch
3476 CC=$cc
3477 CXX=$cxx
3478 AS=$as
3479 LD=$ld
3480 DEPCC=$dep_cc
3481 YASM=$yasmexe
3482 YASMDEP=$yasmexe
3483 AR=$ar
3484 RANLIB=$ranlib
3485 CP=cp -p
3486 LN_S=$ln_s
3487 STRIP=$strip
3488 CPPFLAGS=$CPPFLAGS
3489 CFLAGS=$CFLAGS
3490 CXXFLAGS=$CXXFLAGS
3491 ASFLAGS=$ASFLAGS
3492 AS_O=$CC_O
3493 CC_O=$CC_O
3494 CXX_O=$CXX_O
3495 LDFLAGS=$LDFLAGS
3496 FFSERVERLDFLAGS=$FFSERVERLDFLAGS
3497 SHFLAGS=$SHFLAGS
3498 YASMFLAGS=$YASMFLAGS
3499 BUILDSUF=$build_suffix
3500 PROGSSUF=$progs_suffix
3501 FULLNAME=$FULLNAME
3502 LIBPREF=$LIBPREF
3503 LIBSUF=$LIBSUF
3504 LIBNAME=$LIBNAME
3505 SLIBPREF=$SLIBPREF
3506 SLIBSUF=$SLIBSUF
3507 EXESUF=$EXESUF
3508 EXTRA_VERSION=$extra_version
3509 DEPFLAGS=$DEPFLAGS
3510 CCDEP=$CCDEP
3511 CXXDEP=$CXXDEP
3512 ASDEP=$ASDEP
3513 CC_DEPFLAGS=$CC_DEPFLAGS
3514 AS_DEPFLAGS=$AS_DEPFLAGS
3515 HOSTCC=$host_cc
3516 HOSTCFLAGS=$host_cflags
3517 HOSTEXESUF=$HOSTEXESUF
3518 HOSTLDFLAGS=$host_ldflags
3519 HOSTLIBS=$host_libs
3520 TARGET_EXEC=$target_exec
3521 TARGET_PATH=$target_path
3522 SDL_LIBS=$sdl_libs
3523 SDL_CFLAGS=$sdl_cflags
3524 LIB_INSTALL_EXTRA_CMD=$LIB_INSTALL_EXTRA_CMD
3525 EXTRALIBS=$extralibs
3526 INSTALL=$install
3527 LIBTARGET=${LIBTARGET}
3528 SLIBNAME=${SLIBNAME}
3529 SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}
3530 SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}
3531 SLIB_CREATE_DEF_CMD=${SLIB_CREATE_DEF_CMD}
3532 SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}
3533 SLIB_INSTALL_NAME=${SLIB_INSTALL_NAME}
3534 SLIB_INSTALL_LINKS=${SLIB_INSTALL_LINKS}
3535 SLIB_INSTALL_EXTRA_LIB=${SLIB_INSTALL_EXTRA_LIB}
3536 SLIB_INSTALL_EXTRA_SHLIB=${SLIB_INSTALL_EXTRA_SHLIB}
3537 SAMPLES:=${samples:-\$(FATE_SAMPLES)}
3538 NOREDZONE_FLAGS=$noredzone_flags
3539 EOF
3540
3541 get_version(){
3542     name=$1
3543     file=$source_path/$2
3544     eval $(grep "#define ${name}_VERSION_M" "$file" | awk '{ print $2"="$3 }')
3545     eval ${name}_VERSION=\$${name}_VERSION_MAJOR.\$${name}_VERSION_MINOR.\$${name}_VERSION_MICRO
3546     lcname=$(tolower $name)
3547     eval echo "${lcname}_VERSION=\$${name}_VERSION" >> config.mak
3548     eval echo "${lcname}_VERSION_MAJOR=\$${name}_VERSION_MAJOR" >> config.mak
3549 }
3550
3551 get_version LIBSWSCALE  libswscale/swscale.h
3552 get_version LIBSWRESAMPLE libswresample/swresample.h
3553 get_version LIBPOSTPROC libpostproc/postprocess.h
3554 get_version LIBAVCODEC  libavcodec/version.h
3555 get_version LIBAVDEVICE libavdevice/avdevice.h
3556 get_version LIBAVFORMAT libavformat/version.h
3557 get_version LIBAVUTIL   libavutil/avutil.h
3558 get_version LIBAVFILTER libavfilter/avfilter.h
3559
3560 cat > $TMPH <<EOF
3561 /* Automatically generated by configure - do not modify! */
3562 #ifndef FFMPEG_CONFIG_H
3563 #define FFMPEG_CONFIG_H
3564 #define FFMPEG_CONFIGURATION "$(c_escape $FFMPEG_CONFIGURATION)"
3565 #define FFMPEG_LICENSE "$(c_escape $license)"
3566 #define FFMPEG_DATADIR "$(eval c_escape $datadir)"
3567 #define AVCONV_DATADIR "$(eval c_escape $datadir)"
3568 #define CC_TYPE "$cc_type"
3569 #define CC_VERSION $cc_version
3570 #define restrict $_restrict
3571 #define EXTERN_PREFIX "${extern_prefix}"
3572 #define EXTERN_ASM ${extern_prefix}
3573 #define SLIBSUF "$SLIBSUF"
3574 EOF
3575
3576 test -n "$malloc_prefix" &&
3577     echo "#define MALLOC_PREFIX $malloc_prefix" >>$TMPH
3578
3579 if enabled small || disabled optimizations; then
3580     echo "#undef  av_always_inline"  >> $TMPH
3581     if enabled small; then
3582         echo "#define av_always_inline inline"  >> $TMPH
3583     else
3584         echo "#define av_always_inline av_unused"  >> $TMPH
3585     fi
3586 fi
3587
3588 if enabled yasm; then
3589     append config_files $TMPASM
3590     printf '' >$TMPASM
3591 fi
3592
3593 print_config ARCH_   "$config_files" $ARCH_LIST
3594 print_config HAVE_   "$config_files" $HAVE_LIST
3595 print_config CONFIG_ "$config_files" $CONFIG_LIST       \
3596                                      $CONFIG_EXTRA      \
3597                                      $DECODER_LIST      \
3598                                      $ENCODER_LIST      \
3599                                      $HWACCEL_LIST      \
3600                                      $PARSER_LIST       \
3601                                      $BSF_LIST          \
3602                                      $DEMUXER_LIST      \
3603                                      $MUXER_LIST        \
3604                                      $FILTER_LIST       \
3605                                      $PROTOCOL_LIST     \
3606                                      $INDEV_LIST        \
3607                                      $OUTDEV_LIST       \
3608
3609 cat >>config.mak <<EOF
3610 ACODEC_TESTS=$(print_enabled -n _test $ACODEC_TESTS)
3611 VCODEC_TESTS=$(print_enabled -n _test $VCODEC_TESTS)
3612 LAVF_TESTS=$(print_enabled   -n _test $LAVF_TESTS)
3613 LAVFI_TESTS=$(print_enabled  -n _test $LAVFI_TESTS)
3614 SEEK_TESTS=$(print_enabled   -n _test $SEEK_TESTS)
3615 EOF
3616
3617 echo "#endif /* FFMPEG_CONFIG_H */" >> $TMPH
3618 echo "endif # FFMPEG_CONFIG_MAK" >> config.mak
3619
3620 # Do not overwrite an unchanged config.h to avoid superfluous rebuilds.
3621 cp_if_changed $TMPH config.h
3622 touch .config
3623
3624 enabled yasm && cp_if_changed $TMPASM config.asm
3625
3626 cat > $TMPH <<EOF
3627 /* Generated by ffconf */
3628 #ifndef AVUTIL_AVCONFIG_H
3629 #define AVUTIL_AVCONFIG_H
3630 EOF
3631
3632 print_config AV_HAVE_ $TMPH $HAVE_LIST_PUB
3633
3634 echo "#endif /* AVUTIL_AVCONFIG_H */" >> $TMPH
3635
3636 cp_if_changed $TMPH libavutil/avconfig.h
3637
3638 test -n "$WARNINGS" && printf "\n$WARNINGS"
3639
3640 # build pkg-config files
3641
3642 pkgconfig_generate(){
3643 name=$1
3644 shortname=${name#lib}${build_suffix}
3645 comment=$2
3646 version=$3
3647 libs=$4
3648 requires=$5
3649 enabled ${name#lib} || return 0
3650 mkdir -p $name
3651 cat <<EOF > $name/$name.pc
3652 prefix=$prefix
3653 exec_prefix=\${prefix}
3654 libdir=$libdir
3655 includedir=$incdir
3656
3657 Name: $name
3658 Description: $comment
3659 Version: $version
3660 Requires: $(enabled shared || echo $requires)
3661 Requires.private: $(enabled shared && echo $requires)
3662 Conflicts:
3663 Libs: -L\${libdir} -l${shortname} $(enabled shared || echo $libs)
3664 Libs.private: $(enabled shared && echo $libs)
3665 Cflags: -I\${includedir}
3666 EOF
3667 cat <<EOF > $name/$name-uninstalled.pc
3668 prefix=
3669 exec_prefix=
3670 libdir=\${pcfiledir}
3671 includedir=${source_path}
3672
3673 Name: $name
3674 Description: $comment
3675 Version: $version
3676 Requires: $requires
3677 Conflicts:
3678 Libs: \${libdir}/${LIBPREF}${shortname}${LIBSUF} $libs
3679 Cflags: -I\${includedir}
3680 EOF
3681 }
3682
3683 pkgconfig_generate libavutil "FFmpeg utility library" "$LIBAVUTIL_VERSION" "$LIBM"
3684 pkgconfig_generate libavcodec "FFmpeg codec library" "$LIBAVCODEC_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION"
3685 pkgconfig_generate libavformat "FFmpeg container format library" "$LIBAVFORMAT_VERSION" "$extralibs" "libavcodec = $LIBAVCODEC_VERSION"
3686 pkgconfig_generate libavdevice "FFmpeg device handling library" "$LIBAVDEVICE_VERSION" "$extralibs" "libavformat = $LIBAVFORMAT_VERSION"
3687 pkgconfig_generate libavfilter "FFmpeg video filtering library" "$LIBAVFILTER_VERSION" "$extralibs"
3688 pkgconfig_generate libpostproc "FFmpeg postprocessing library" "$LIBPOSTPROC_VERSION" "" "libavutil = $LIBAVUTIL_VERSION"
3689 pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "$LIBM" "libavutil = $LIBAVUTIL_VERSION"
3690 pkgconfig_generate libswresample "FFmpeg audio rescaling library" "$LIBSWRESAMPLE_VERSION" "$LIBM" "libavutil = $LIBAVUTIL_VERSION"