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