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