x86: add missing XOP checks and macros
[ffmpeg.git] / configure
1 #!/bin/sh
2 #
3 # Libav 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 LIBAV, 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 Libav."
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 test -d /usr/xpg4/bin && PATH=/usr/xpg4/bin:$PATH
58
59 show_help(){
60     cat <<EOF
61 Usage: configure [options]
62 Options: [defaults in brackets after descriptions]
63
64 Help options:
65   --help                   print this message
66   --list-decoders          show all available decoders
67   --list-encoders          show all available encoders
68   --list-hwaccels          show all available hardware accelerators
69   --list-demuxers          show all available demuxers
70   --list-muxers            show all available muxers
71   --list-parsers           show all available parsers
72   --list-protocols         show all available protocols
73   --list-bsfs              show all available bitstream filters
74   --list-indevs            show all available input devices
75   --list-outdevs           show all available output devices
76   --list-filters           show all available filters
77
78 Standard options:
79   --logfile=FILE           log tests and output to FILE [config.log]
80   --disable-logging        do not log configure debug information
81   --prefix=PREFIX          install in PREFIX [$prefix]
82   --bindir=DIR             install binaries in DIR [PREFIX/bin]
83   --datadir=DIR            install data files in DIR [PREFIX/share/avconv]
84   --docdir=DIR             install documentation in DIR [PREFIX/share/doc/libav]
85   --libdir=DIR             install libs in DIR [PREFIX/lib]
86   --shlibdir=DIR           install shared libs in DIR [PREFIX/lib]
87   --incdir=DIR             install includes in DIR [PREFIX/include]
88   --mandir=DIR             install man page in DIR [PREFIX/share/man]
89
90 Licensing options:
91   --enable-gpl             allow use of GPL code, the resulting libs
92                            and binaries will be under GPL [no]
93   --enable-version3        upgrade (L)GPL to version 3 [no]
94   --enable-nonfree         allow use of nonfree code, the resulting libs
95                            and binaries will be unredistributable [no]
96
97 Configuration options:
98   --disable-static         do not build static libraries [no]
99   --enable-shared          build shared libraries [no]
100   --enable-small           optimize for size instead of speed
101   --enable-runtime-cpudetect detect cpu capabilities at runtime (bigger binary)
102   --enable-gray            enable full grayscale support (slower color)
103   --disable-swscale-alpha  disable alpha channel support in swscale
104   --disable-all            disable building components, libraries and programs
105
106 Program options:
107   --disable-programs       do not build command line programs
108   --disable-avconv         disable avconv build
109   --disable-avplay         disable avplay build
110   --disable-avprobe        disable avprobe build
111   --disable-avserver       disable avserver build
112
113 Component options:
114   --disable-doc            do not build documentation
115   --disable-avdevice       disable libavdevice build
116   --disable-avcodec        disable libavcodec build
117   --disable-avformat       disable libavformat build
118   --disable-avutil         disable libavutil build
119   --disable-swscale        disable libswscale build
120   --disable-avfilter       disable video filter support [no]
121   --disable-avresample     disable libavresample build [no]
122   --disable-pthreads       disable pthreads [auto]
123   --disable-w32threads     disable Win32 threads [auto]
124   --disable-network        disable network support [no]
125   --disable-dct            disable DCT code
126   --disable-error-resilience disable error resilience code
127   --disable-lsp            disable LSP code
128   --disable-lzo            disable LZO decoder code
129   --disable-mdct           disable MDCT code
130   --disable-rdft           disable RDFT code
131   --disable-fft            disable FFT code
132
133 Hardware accelerators:
134   --enable-dxva2           enable DXVA2 code
135   --enable-vaapi           enable VAAPI code
136   --enable-vda             enable VDA code
137   --enable-vdpau           enable VDPAU code
138
139 Individual component options:
140   --disable-everything     disable all components listed below
141   --disable-encoder=NAME   disable encoder NAME
142   --enable-encoder=NAME    enable encoder NAME
143   --disable-encoders       disable all encoders
144   --disable-decoder=NAME   disable decoder NAME
145   --enable-decoder=NAME    enable decoder NAME
146   --disable-decoders       disable all decoders
147   --disable-hwaccel=NAME   disable hwaccel NAME
148   --enable-hwaccel=NAME    enable hwaccel NAME
149   --disable-hwaccels       disable all hwaccels
150   --disable-muxer=NAME     disable muxer NAME
151   --enable-muxer=NAME      enable muxer NAME
152   --disable-muxers         disable all muxers
153   --disable-demuxer=NAME   disable demuxer NAME
154   --enable-demuxer=NAME    enable demuxer NAME
155   --disable-demuxers       disable all demuxers
156   --enable-parser=NAME     enable parser NAME
157   --disable-parser=NAME    disable parser NAME
158   --disable-parsers        disable all parsers
159   --enable-bsf=NAME        enable bitstream filter NAME
160   --disable-bsf=NAME       disable bitstream filter NAME
161   --disable-bsfs           disable all bitstream filters
162   --enable-protocol=NAME   enable protocol NAME
163   --disable-protocol=NAME  disable protocol NAME
164   --disable-protocols      disable all protocols
165   --enable-indev=NAME      enable input device NAME
166   --disable-indev=NAME     disable input device NAME
167   --disable-indevs         disable input devices
168   --enable-outdev=NAME     enable output device NAME
169   --disable-outdev=NAME    disable output device NAME
170   --disable-outdevs        disable output devices
171   --disable-devices        disable all devices
172   --enable-filter=NAME     enable filter NAME
173   --disable-filter=NAME    disable filter NAME
174   --disable-filters        disable all filters
175
176 External library support:
177   --enable-avisynth        enable reading of AviSynth script files [no]
178   --enable-bzlib           enable bzlib [autodetect]
179   --enable-frei0r          enable frei0r video filtering
180   --enable-gnutls          enable gnutls [no]
181   --enable-libcdio         enable audio CD grabbing with libcdio
182   --enable-libdc1394       enable IIDC-1394 grabbing using libdc1394
183                            and libraw1394 [no]
184   --enable-libfaac         enable AAC encoding via libfaac [no]
185   --enable-libfdk-aac      enable AAC de/encoding via libfdk-aac [no]
186   --enable-libfreetype     enable libfreetype [no]
187   --enable-libgsm          enable GSM de/encoding via libgsm [no]
188   --enable-libilbc         enable iLBC de/encoding via libilbc [no]
189   --enable-libmp3lame      enable MP3 encoding via libmp3lame [no]
190   --enable-libopencore-amrnb enable AMR-NB de/encoding via libopencore-amrnb [no]
191   --enable-libopencore-amrwb enable AMR-WB decoding via libopencore-amrwb [no]
192   --enable-libopencv       enable video filtering via libopencv [no]
193   --enable-libopenjpeg     enable JPEG 2000 de/encoding via OpenJPEG [no]
194   --enable-libopus         enable Opus decoding via libopus [no]
195   --enable-libpulse        enable Pulseaudio input via libpulse [no]
196   --enable-librtmp         enable RTMP[E] support via librtmp [no]
197   --enable-libschroedinger enable Dirac de/encoding via libschroedinger [no]
198   --enable-libspeex        enable Speex de/encoding via libspeex [no]
199   --enable-libtheora       enable Theora encoding via libtheora [no]
200   --enable-libvo-aacenc    enable AAC encoding via libvo-aacenc [no]
201   --enable-libvo-amrwbenc  enable AMR-WB encoding via libvo-amrwbenc [no]
202   --enable-libvorbis       enable Vorbis encoding via libvorbis [no]
203   --enable-libvpx          enable VP8 and VP9 de/encoding via libvpx [no]
204   --enable-libwavpack      enable wavpack encoding via libwavpack [no]
205   --enable-libwebp         enable WebP encoding via libwebp [no]
206   --enable-libx264         enable H.264 encoding via x264 [no]
207   --enable-libx265         enable HEVC encoding via x265 [no]
208   --enable-libxavs         enable AVS encoding via xavs [no]
209   --enable-libxvid         enable Xvid encoding via xvidcore,
210                            native MPEG-4/Xvid encoder exists [no]
211   --enable-openssl         enable openssl [no]
212   --enable-x11grab         enable X11 grabbing [no]
213   --enable-zlib            enable zlib [autodetect]
214
215 Advanced options (experts only):
216   --cross-prefix=PREFIX    use PREFIX for compilation tools [$cross_prefix]
217   --enable-cross-compile   assume a cross-compiler is used
218   --sysroot=PATH           root of cross-build tree
219   --sysinclude=PATH        location of cross-build system headers
220   --target-os=OS           compiler targets OS [$target_os]
221   --target-exec=CMD        command to run executables on target
222   --target-path=DIR        path to view of build directory on target
223   --target-samples=DIR     path to samples directory on target
224   --toolchain=NAME         set tool defaults according to NAME
225   --nm=NM                  use nm tool
226   --ar=AR                  use archive tool AR [$ar_default]
227   --as=AS                  use assembler AS [$as_default]
228   --cc=CC                  use C compiler CC [$cc_default]
229   --dep-cc=DEPCC           use dependency generator DEPCC [$cc_default]
230   --ld=LD                  use linker LD
231   --host-cc=HOSTCC         use host C compiler HOSTCC
232   --host-cflags=HCFLAGS    use HCFLAGS when compiling for host
233   --host-cppflags=HCPPFLAGS use HCPPFLAGS when compiling for host
234   --host-ld=HOSTLD         use host linker HOSTLD
235   --host-ldflags=HLDFLAGS  use HLDFLAGS when linking for host
236   --host-libs=HLIBS        use libs HLIBS when linking for host
237   --host-os=OS             compiler host OS [$target_os]
238   --extra-cflags=ECFLAGS   add ECFLAGS to CFLAGS [$CFLAGS]
239   --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]
240   --extra-libs=ELIBS       add ELIBS [$ELIBS]
241   --extra-version=STRING   version string suffix []
242   --optflags=OPTFLAGS      override optimization-related compiler flags
243   --build-suffix=SUFFIX    library name suffix []
244   --malloc-prefix=PREFIX   prefix malloc and related names with PREFIX
245   --arch=ARCH              select architecture [$arch]
246   --cpu=CPU                select the minimum required CPU (affects
247                            instruction selection, may crash on older CPUs)
248   --enable-pic             build position-independent code
249   --enable-sram            allow use of on-chip SRAM
250   --enable-thumb           compile for Thumb instruction set
251   --disable-symver         disable symbol versioning
252   --enable-hardcoded-tables use hardcoded tables instead of runtime generation
253   --disable-safe-bitstream-reader
254                            disable buffer boundary checking in bitreaders
255                            (faster, but may crash)
256   --enable-memalign-hack   emulate memalign, interferes with memory debuggers
257   --enable-lto             use link-time optimization
258
259 Optimization options (experts only):
260   --disable-asm            disable all assembler optimizations
261   --disable-altivec        disable AltiVec optimizations
262   --disable-amd3dnow       disable 3DNow! optimizations
263   --disable-amd3dnowext    disable 3DNow! extended optimizations
264   --disable-mmx            disable MMX optimizations
265   --disable-mmxext         disable MMXEXT optimizations
266   --disable-sse            disable SSE optimizations
267   --disable-sse2           disable SSE2 optimizations
268   --disable-sse3           disable SSE3 optimizations
269   --disable-ssse3          disable SSSE3 optimizations
270   --disable-sse4           disable SSE4 optimizations
271   --disable-sse42          disable SSE4.2 optimizations
272   --disable-avx            disable AVX optimizations
273   --disable-xop            disable XOP optimizations
274   --disable-fma4           disable FMA4 optimizations
275   --disable-avx2           disable AVX2 optimizations
276   --disable-armv5te        disable armv5te optimizations
277   --disable-armv6          disable armv6 optimizations
278   --disable-armv6t2        disable armv6t2 optimizations
279   --disable-vfp            disable VFP optimizations
280   --disable-neon           disable NEON optimizations
281   --disable-vis            disable VIS optimizations
282   --disable-inline-asm     disable use of inline assembler
283   --disable-yasm           disable use of yasm assembler
284
285 Developer options (useful when working on Libav itself):
286   --disable-debug          disable debugging symbols
287   --enable-debug=LEVEL     set the debug level [$debuglevel]
288   --disable-optimizations  disable compiler optimizations
289   --enable-extra-warnings  enable more compiler warnings
290   --samples=PATH           location of test samples for FATE, if not set use
291                            \$LIBAV_SAMPLES at make invocation time.
292   --enable-neon-clobber-test check NEON registers for clobbering (should be
293                            used only for debugging purposes)
294   --enable-xmm-clobber-test check XMM registers for clobbering (Win64-only;
295                            should be used only for debugging purposes)
296   --enable-random          randomly enable/disable components
297   --disable-random
298   --enable-random=LIST     randomly enable/disable specific components or
299   --disable-random=LIST    component groups. LIST is a comma-separated list
300                            of NAME[:PROB] entries where NAME is a component
301                            (group) and PROB the probability associated with
302                            NAME (default 0.5).
303   --random-seed=VALUE      seed value for --enable/disable-random
304
305 NOTE: Object files are built at the place where configure is launched.
306 EOF
307   exit 0
308 }
309
310 quotes='""'
311
312 log(){
313     echo "$@" >> $logfile
314 }
315
316 log_file(){
317     log BEGIN $1
318     pr -n -t $1 >> $logfile
319     log END $1
320 }
321
322 echolog(){
323     log "$@"
324     echo "$@"
325 }
326
327 warn(){
328     log "WARNING: $*"
329     WARNINGS="${WARNINGS}WARNING: $*\n"
330 }
331
332 die(){
333     echolog "$@"
334     cat <<EOF
335
336 If you think configure made a mistake, make sure you are using the latest
337 version from Git.  If the latest version fails, report the problem to the
338 libav-tools@libav.org mailing list or IRC #libav on irc.freenode.net.
339 EOF
340     if disabled logging; then
341         cat <<EOF
342 Rerun configure with logging enabled (do not use --disable-logging), and
343 include the log this produces with your report.
344 EOF
345     else
346         cat <<EOF
347 Include the log file "$logfile" produced by configure as this will help
348 solving the problem.
349 EOF
350     fi
351     exit 1
352 }
353
354 # Avoid locale weirdness, besides we really just want to translate ASCII.
355 toupper(){
356     echo "$@" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
357 }
358
359 tolower(){
360     echo "$@" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
361 }
362
363 c_escape(){
364     echo "$*" | sed 's/["\\]/\\\0/g'
365 }
366
367 sh_quote(){
368     v=$(echo "$1" | sed "s/'/'\\\\''/g")
369     test "x$v" = "x${v#*[!A-Za-z0-9_/.+-]}" || v="'$v'"
370     echo "$v"
371 }
372
373 cleanws(){
374     echo "$@" | sed 's/^ *//;s/  */ /g;s/ *$//'
375 }
376
377 filter(){
378     pat=$1
379     shift
380     for v; do
381         eval "case $v in $pat) echo $v ;; esac"
382     done
383 }
384
385 filter_out(){
386     pat=$1
387     shift
388     for v; do
389         eval "case $v in $pat) ;; *) echo $v ;; esac"
390     done
391 }
392
393 map(){
394     m=$1
395     shift
396     for v; do eval $m; done
397 }
398
399 add_suffix(){
400     suffix=$1
401     shift
402     for v; do echo ${v}${suffix}; done
403 }
404
405 set_all(){
406     value=$1
407     shift
408     for var in $*; do
409         eval $var=$value
410     done
411 }
412
413 set_weak(){
414     value=$1
415     shift
416     for var; do
417         eval : \${$var:=$value}
418     done
419 }
420
421 sanitize_var_name(){
422     echo $@ | sed 's/[^A-Za-z0-9_]/_/g'
423 }
424
425 set_safe(){
426     var=$1
427     shift
428     eval $(sanitize_var_name "$var")='$*'
429 }
430
431 get_safe(){
432     eval echo \$$(sanitize_var_name "$1")
433 }
434
435 pushvar(){
436     for pvar in $*; do
437         eval level=\${${pvar}_level:=0}
438         eval ${pvar}_${level}="\$$pvar"
439         eval ${pvar}_level=$(($level+1))
440     done
441 }
442
443 popvar(){
444     for pvar in $*; do
445         eval level=\${${pvar}_level:-0}
446         test $level = 0 && continue
447         eval level=$(($level-1))
448         eval $pvar="\${${pvar}_${level}}"
449         eval ${pvar}_level=$level
450         eval unset ${pvar}_${level}
451     done
452 }
453
454 enable(){
455     set_all yes $*
456 }
457
458 disable(){
459     set_all no $*
460 }
461
462 enable_weak(){
463     set_weak yes $*
464 }
465
466 disable_weak(){
467     set_weak no $*
468 }
469
470 enable_safe(){
471     for var; do
472         enable $(echo "$var" | sed 's/[^A-Za-z0-9_]/_/g')
473     done
474 }
475
476 disable_safe(){
477     for var; do
478         disable $(echo "$var" | sed 's/[^A-Za-z0-9_]/_/g')
479     done
480 }
481
482 do_enable_deep(){
483     for var; do
484         enabled $var && continue
485         eval sel="\$${var}_select"
486         eval sgs="\$${var}_suggest"
487         pushvar var sgs
488         enable_deep $sel
489         popvar sgs
490         enable_deep_weak $sgs
491         popvar var
492     done
493 }
494
495 enable_deep(){
496     do_enable_deep $*
497     enable $*
498 }
499
500 enable_deep_weak(){
501     for var; do
502         disabled $var && continue
503         pushvar var
504         do_enable_deep $var
505         popvar var
506         enable_weak $var
507     done
508 }
509
510 enabled(){
511     test "${1#!}" = "$1" && op== || op=!=
512     eval test "x\$${1#!}" $op "xyes"
513 }
514
515 disabled(){
516     test "${1#!}" = "$1" && op== || op=!=
517     eval test "x\$${1#!}" $op "xno"
518 }
519
520 enabled_all(){
521     for opt; do
522         enabled $opt || return 1
523     done
524 }
525
526 disabled_all(){
527     for opt; do
528         disabled $opt || return 1
529     done
530 }
531
532 enabled_any(){
533     for opt; do
534         enabled $opt && return 0
535     done
536 }
537
538 disabled_any(){
539     for opt; do
540         disabled $opt && return 0
541     done
542     return 1
543 }
544
545 set_default(){
546     for opt; do
547         eval : \${$opt:=\$${opt}_default}
548     done
549 }
550
551 is_in(){
552     value=$1
553     shift
554     for var in $*; do
555         [ $var = $value ] && return 0
556     done
557     return 1
558 }
559
560 do_check_deps(){
561     for cfg; do
562         cfg="${cfg#!}"
563         enabled ${cfg}_checking && die "Circular dependency for $cfg."
564         disabled ${cfg}_checking && continue
565         enable ${cfg}_checking
566         append allopts $cfg
567
568         eval dep_all="\$${cfg}_deps"
569         eval dep_any="\$${cfg}_deps_any"
570         eval dep_sel="\$${cfg}_select"
571         eval dep_sgs="\$${cfg}_suggest"
572         eval dep_ifa="\$${cfg}_if"
573         eval dep_ifn="\$${cfg}_if_any"
574
575         pushvar cfg dep_all dep_any dep_sel dep_sgs dep_ifa dep_ifn
576         do_check_deps $dep_all $dep_any $dep_sel $dep_sgs $dep_ifa $dep_ifn
577         popvar cfg dep_all dep_any dep_sel dep_sgs dep_ifa dep_ifn
578
579         [ -n "$dep_ifa" ] && { enabled_all $dep_ifa && enable_weak $cfg; }
580         [ -n "$dep_ifn" ] && { enabled_any $dep_ifn && enable_weak $cfg; }
581         enabled_all  $dep_all || disable $cfg
582         enabled_any  $dep_any || disable $cfg
583         disabled_any $dep_sel && disable $cfg
584
585         if enabled $cfg; then
586             enable_deep $dep_sel
587             enable_deep_weak $dep_sgs
588         fi
589
590         disable ${cfg}_checking
591     done
592 }
593
594 check_deps(){
595     unset allopts
596
597     do_check_deps "$@"
598
599     for cfg in $allopts; do
600         enabled $cfg || continue
601         eval dep_extralibs="\$${cfg}_extralibs"
602         test -n "$dep_extralibs" && add_extralibs $dep_extralibs
603     done
604 }
605
606 print_config(){
607     pfx=$1
608     files=$2
609     shift 2
610     map 'eval echo "$v \${$v:-no}"' "$@" |
611     awk "BEGIN { split(\"$files\", files) }
612         {
613             c = \"$pfx\" toupper(\$1);
614             v = \$2;
615             sub(/yes/, 1, v);
616             sub(/no/,  0, v);
617             for (f in files) {
618                 file = files[f];
619                 if (file ~ /\\.h\$/) {
620                     printf(\"#define %s %d\\n\", c, v) >>file;
621                 } else if (file ~ /\\.asm\$/) {
622                     printf(\"%%define %s %d\\n\", c, v) >>file;
623                 } else if (file ~ /\\.mak\$/) {
624                     n = -v ? \"\" : \"!\";
625                     printf(\"%s%s=yes\\n\", n, c) >>file;
626                 }
627             }
628         }"
629 }
630
631 print_enabled(){
632     suf=$1
633     shift
634     for v; do
635         enabled $v && printf "%s\n" ${v%$suf};
636     done
637 }
638
639 append(){
640     var=$1
641     shift
642     eval "$var=\"\$$var $*\""
643 }
644
645 prepend(){
646     var=$1
647     shift
648     eval "$var=\"$* \$$var\""
649 }
650
651 add_cppflags(){
652     append CPPFLAGS "$@"
653 }
654
655 add_cflags(){
656     append CFLAGS $($cflags_filter "$@")
657 }
658
659 add_asflags(){
660     append ASFLAGS $($asflags_filter "$@")
661 }
662
663 add_ldflags(){
664     append LDFLAGS $($ldflags_filter "$@")
665 }
666
667 add_stripflags(){
668     append STRIPFLAGS "$@"
669 }
670
671 add_extralibs(){
672     prepend extralibs $($ldflags_filter "$@")
673 }
674
675 add_host_cppflags(){
676     append host_cppflags "$@"
677 }
678
679 add_host_cflags(){
680     append host_cflags $($host_cflags_filter "$@")
681 }
682
683 add_host_ldflags(){
684     append host_ldflags $($host_ldflags_filter "$@")
685 }
686
687 add_compat(){
688     append compat_objs $1
689     shift
690     map 'add_cppflags -D$v' "$@"
691 }
692
693 check_cmd(){
694     log "$@"
695     "$@" >> $logfile 2>&1
696 }
697
698 cc_o(){
699     eval printf '%s\\n' $CC_O
700 }
701
702 cc_e(){
703     eval printf '%s\\n' $CC_E
704 }
705
706 check_cc(){
707     log check_cc "$@"
708     cat > $TMPC
709     log_file $TMPC
710     check_cmd $cc $CPPFLAGS $CFLAGS "$@" $CC_C $(cc_o $TMPO) $TMPC
711 }
712
713 check_cpp(){
714     log check_cpp "$@"
715     cat > $TMPC
716     log_file $TMPC
717     check_cmd $cc $CPPFLAGS $CFLAGS "$@" $(cc_e $TMPO) $TMPC
718 }
719
720 as_o(){
721     eval printf '%s\\n' $AS_O
722 }
723
724 check_as(){
725     log check_as "$@"
726     cat > $TMPS
727     log_file $TMPS
728     check_cmd $as $CPPFLAGS $ASFLAGS "$@" $AS_C $(as_o $TMPO) $TMPS
729 }
730
731 check_inline_asm(){
732     log check_inline_asm "$@"
733     name="$1"
734     code="$2"
735     shift 2
736     disable $name
737     check_cc "$@" <<EOF && enable $name
738 void foo(void){ __asm__ volatile($code); }
739 EOF
740 }
741
742 check_insn(){
743     log check_insn "$@"
744     check_inline_asm ${1}_inline "\"$2\""
745     echo "$2" | check_as && enable ${1}_external || disable ${1}_external
746 }
747
748 check_yasm(){
749     log check_yasm "$@"
750     echo "$1" > $TMPS
751     log_file $TMPS
752     shift 1
753     check_cmd $yasmexe $YASMFLAGS "$@" -o $TMPO $TMPS
754 }
755
756 ld_o(){
757     eval printf '%s\\n' $LD_O
758 }
759
760 check_ld(){
761     log check_ld "$@"
762     flags=$(filter_out '-l*' "$@")
763     libs=$(filter '-l*' "$@")
764     check_cc $($cflags_filter $flags) || return
765     flags=$($ldflags_filter $flags)
766     libs=$($ldflags_filter $libs)
767     check_cmd $ld $LDFLAGS $flags $(ld_o $TMPE) $TMPO $libs $extralibs
768 }
769
770 print_include(){
771     hdr=$1
772     test "${hdr%.h}" = "${hdr}" &&
773         echo "#include $hdr"    ||
774         echo "#include <$hdr>"
775 }
776
777 check_code(){
778     log check_code "$@"
779     check=$1
780     headers=$2
781     code=$3
782     shift 3
783     {
784         for hdr in $headers; do
785             print_include $hdr
786         done
787         echo "int main(void) { $code; return 0; }"
788     } | check_$check "$@"
789 }
790
791 check_cppflags(){
792     log check_cppflags "$@"
793     check_cc "$@" <<EOF && append CPPFLAGS "$@"
794 int x;
795 EOF
796 }
797
798 test_cflags(){
799     log test_cflags "$@"
800     set -- $($cflags_filter "$@")
801     check_cc "$@" <<EOF
802 int x;
803 EOF
804 }
805
806 check_cflags(){
807     log check_cflags "$@"
808     test_cflags "$@" && add_cflags "$@"
809 }
810
811 test_ldflags(){
812     log test_ldflags "$@"
813     check_ld "$@" <<EOF
814 int main(void){ return 0; }
815 EOF
816 }
817
818 check_ldflags(){
819     log check_ldflags "$@"
820     test_ldflags "$@" && add_ldflags "$@"
821 }
822
823 test_stripflags(){
824     log test_stripflags "$@"
825     # call check_cc to get a fresh TMPO
826     check_cc <<EOF
827 int main(void) { return 0; }
828 EOF
829     check_cmd $strip $STRIPFLAGS "$@" $TMPO
830 }
831
832 check_stripflags(){
833     log check_stripflags "$@"
834     test_stripflags "$@" && add_stripflags "$@"
835 }
836
837 check_header(){
838     log check_header "$@"
839     header=$1
840     shift
841     disable_safe $header
842     check_cpp "$@" <<EOF && enable_safe $header
843 #include <$header>
844 int x;
845 EOF
846 }
847
848 check_func(){
849     log check_func "$@"
850     func=$1
851     shift
852     disable $func
853     check_ld "$@" <<EOF && enable $func
854 extern int $func();
855 int main(void){ $func(); }
856 EOF
857 }
858
859 check_mathfunc(){
860     log check_mathfunc "$@"
861     func=$1
862     narg=$2
863     shift 2
864     test $narg = 2 && args="f, g" || args="f"
865     disable $func
866     check_ld "$@" <<EOF && enable $func
867 #include <math.h>
868 float foo(float f, float g) { return $func($args); }
869 int main(void){ return 0; }
870 EOF
871 }
872
873 check_func_headers(){
874     log check_func_headers "$@"
875     headers=$1
876     funcs=$2
877     shift 2
878     {
879         for hdr in $headers; do
880             print_include $hdr
881         done
882         for func in $funcs; do
883             echo "long check_$func(void) { return (long) $func; }"
884         done
885         echo "int main(void) { return 0; }"
886     } | check_ld "$@" && enable $funcs && enable_safe $headers
887 }
888
889 check_cpp_condition(){
890     log check_cpp_condition "$@"
891     header=$1
892     condition=$2
893     shift 2
894     check_cpp "$@" <<EOF
895 #include <$header>
896 #if !($condition)
897 #error "unsatisfied condition: $condition"
898 #endif
899 EOF
900 }
901
902 check_lib(){
903     log check_lib "$@"
904     header="$1"
905     func="$2"
906     shift 2
907     check_header $header && check_func $func "$@" && add_extralibs "$@"
908 }
909
910 check_lib2(){
911     log check_lib2 "$@"
912     headers="$1"
913     funcs="$2"
914     shift 2
915     check_func_headers "$headers" "$funcs" "$@" && add_extralibs "$@"
916 }
917
918 check_pkg_config(){
919     log check_pkg_config "$@"
920     pkg="$1"
921     headers="$2"
922     funcs="$3"
923     shift 3
924     check_cmd $pkg_config --exists --print-errors $pkg || return
925     pkg_cflags=$($pkg_config --cflags $pkg)
926     pkg_libs=$($pkg_config --libs $pkg)
927     check_func_headers "$headers" "$funcs" $pkg_cflags $pkg_libs "$@" &&
928         set_safe ${pkg}_cflags $pkg_cflags   &&
929         set_safe ${pkg}_libs   $pkg_libs
930 }
931
932 check_exec(){
933     check_ld "$@" && { enabled cross_compile || $TMPE >> $logfile 2>&1; }
934 }
935
936 check_exec_crash(){
937     code=$(cat)
938
939     # exit() is not async signal safe.  _Exit (C99) and _exit (POSIX)
940     # are safe but may not be available everywhere.  Thus we use
941     # raise(SIGTERM) instead.  The check is run in a subshell so we
942     # can redirect the "Terminated" message from the shell.  SIGBUS
943     # is not defined by standard C so it is used conditionally.
944
945     (check_exec "$@") >> $logfile 2>&1 <<EOF
946 #include <signal.h>
947 static void sighandler(int sig){
948     raise(SIGTERM);
949 }
950 int foo(void){
951     $code
952 }
953 int (*func_ptr)(void) = foo;
954 int main(void){
955     signal(SIGILL, sighandler);
956     signal(SIGFPE, sighandler);
957     signal(SIGSEGV, sighandler);
958 #ifdef SIGBUS
959     signal(SIGBUS, sighandler);
960 #endif
961     return func_ptr();
962 }
963 EOF
964 }
965
966 check_type(){
967     log check_type "$@"
968     headers=$1
969     type=$2
970     shift 2
971     disable_safe "$type"
972     check_code cc "$headers" "$type v" "$@" && enable_safe "$type"
973 }
974
975 check_struct(){
976     log check_struct "$@"
977     headers=$1
978     struct=$2
979     member=$3
980     shift 3
981     disable_safe "${struct}_${member}"
982     check_code cc "$headers" "const void *p = &(($struct *)0)->$member" "$@" &&
983         enable_safe "${struct}_${member}"
984 }
985
986 check_builtin(){
987     log check_builtin "$@"
988     name=$1
989     headers=$2
990     builtin=$3
991     shift 3
992     disable "$name"
993     check_code ld "$headers" "$builtin" "$@" && enable "$name"
994 }
995
996 require(){
997     name="$1"
998     header="$2"
999     func="$3"
1000     shift 3
1001     check_lib $header $func "$@" || die "ERROR: $name not found"
1002 }
1003
1004 require2(){
1005     name="$1"
1006     headers="$2"
1007     func="$3"
1008     shift 3
1009     check_lib2 "$headers" $func "$@" || die "ERROR: $name not found"
1010 }
1011
1012 require_pkg_config(){
1013     pkg="$1"
1014     check_pkg_config "$@" || die "ERROR: $pkg not found"
1015     add_cflags    $(get_safe ${pkg}_cflags)
1016     add_extralibs $(get_safe ${pkg}_libs)
1017 }
1018
1019 hostcc_e(){
1020     eval printf '%s\\n' $HOSTCC_E
1021 }
1022
1023 hostcc_o(){
1024     eval printf '%s\\n' $HOSTCC_O
1025 }
1026
1027 check_host_cc(){
1028     log check_host_cc "$@"
1029     cat > $TMPC
1030     log_file $TMPC
1031     check_cmd $host_cc $host_cflags "$@" $HOSTCC_C $(hostcc_o $TMPO) $TMPC
1032 }
1033
1034 check_host_cpp(){
1035     log check_host_cpp "$@"
1036     cat > $TMPC
1037     log_file $TMPC
1038     check_cmd $host_cc $HOSTCPPFLAGS $HOSTCFLAGS "$@" $(hostcc_e $TMPO) $TMPC
1039 }
1040
1041 check_host_cppflags(){
1042     log check_host_cppflags "$@"
1043     check_host_cc "$@" <<EOF && append host_cppflags "$@"
1044 int x;
1045 EOF
1046 }
1047
1048 check_host_cflags(){
1049     log check_host_cflags "$@"
1050     set -- $($host_cflags_filter "$@")
1051     check_host_cc "$@" <<EOF && append host_cflags "$@"
1052 int x;
1053 EOF
1054 }
1055
1056 check_host_cpp_condition(){
1057     log check_host_cpp_condition "$@"
1058     header=$1
1059     condition=$2
1060     shift 2
1061     check_host_cpp "$@" <<EOF
1062 #include <$header>
1063 #if !($condition)
1064 #error "unsatisfied condition: $condition"
1065 #endif
1066 EOF
1067 }
1068
1069 apply(){
1070     file=$1
1071     shift
1072     "$@" < "$file" > "$file.tmp" && mv "$file.tmp" "$file" || rm "$file.tmp"
1073 }
1074
1075 cp_if_changed(){
1076     cmp -s "$1" "$2" && echo "$2 is unchanged" && return
1077     mkdir -p "$(dirname $2)"
1078     $cp_f "$1" "$2"
1079 }
1080
1081 # CONFIG_LIST contains configurable options, while HAVE_LIST is for
1082 # system-dependent things.
1083
1084 COMPONENT_LIST="
1085     bsfs
1086     decoders
1087     demuxers
1088     encoders
1089     filters
1090     hwaccels
1091     indevs
1092     muxers
1093     outdevs
1094     parsers
1095     protocols
1096 "
1097
1098 EXAMPLE_LIST="
1099     avcodec_example
1100     metadata_example
1101     output_example
1102     transcode_aac_example
1103 "
1104
1105 EXTERNAL_LIBRARY_LIST="
1106     avisynth
1107     bzlib
1108     frei0r
1109     gnutls
1110     libcdio
1111     libdc1394
1112     libfaac
1113     libfdk_aac
1114     libfreetype
1115     libgsm
1116     libilbc
1117     libmp3lame
1118     libopencore_amrnb
1119     libopencore_amrwb
1120     libopencv
1121     libopenjpeg
1122     libopus
1123     libpulse
1124     librtmp
1125     libschroedinger
1126     libspeex
1127     libtheora
1128     libvo_aacenc
1129     libvo_amrwbenc
1130     libvorbis
1131     libvpx
1132     libwavpack
1133     libwebp
1134     libx264
1135     libx265
1136     libxavs
1137     libxvid
1138     openssl
1139     x11grab
1140     zlib
1141 "
1142
1143 HWACCEL_LIST="
1144     dxva2
1145     vaapi
1146     vda
1147     vdpau
1148 "
1149 LIBRARY_LIST="
1150     avcodec
1151     avdevice
1152     avfilter
1153     avformat
1154     avresample
1155     avutil
1156     swscale
1157 "
1158
1159 PROGRAM_LIST="
1160     avconv
1161     avplay
1162     avprobe
1163     avserver
1164 "
1165
1166 CONFIG_LIST="
1167     $COMPONENT_LIST
1168     $EXAMPLE_LIST
1169     $EXTERNAL_LIBRARY_LIST
1170     $HWACCEL_LIST
1171     $LIBRARY_LIST
1172     $PROGRAM_LIST
1173     dct
1174     doc
1175     error_resilience
1176     fft
1177     gpl
1178     gray
1179     hardcoded_tables
1180     lsp
1181     lzo
1182     mdct
1183     memalign_hack
1184     neon_clobber_test
1185     network
1186     nonfree
1187     pod2man
1188     pic
1189     rdft
1190     runtime_cpudetect
1191     safe_bitstream_reader
1192     shared
1193     small
1194     sram
1195     static
1196     swscale_alpha
1197     texi2html
1198     thumb
1199     version3
1200     xmm_clobber_test
1201 "
1202
1203 THREADS_LIST='
1204     pthreads
1205     w32threads
1206 '
1207
1208 ATOMICS_LIST='
1209     atomics_gcc
1210     atomics_suncc
1211     atomics_win32
1212 '
1213
1214 ARCH_LIST='
1215     aarch64
1216     alpha
1217     arm
1218     avr32
1219     avr32_ap
1220     avr32_uc
1221     bfin
1222     ia64
1223     m68k
1224     mips
1225     mips64
1226     parisc
1227     ppc
1228     ppc64
1229     s390
1230     sh4
1231     sparc
1232     sparc64
1233     tilegx
1234     tilepro
1235     tomi
1236     x86
1237     x86_32
1238     x86_64
1239 '
1240
1241 ARCH_EXT_LIST_ARM='
1242     armv5te
1243     armv6
1244     armv6t2
1245     neon
1246     vfp
1247     vfpv3
1248 '
1249
1250 ARCH_EXT_LIST_X86='
1251     amd3dnow
1252     amd3dnowext
1253     avx
1254     avx2
1255     cpunop
1256     xop
1257     fma4
1258     i686
1259     mmx
1260     mmxext
1261     sse
1262     sse2
1263     sse3
1264     sse4
1265     sse42
1266     ssse3
1267 '
1268
1269 ARCH_EXT_LIST="
1270     $ARCH_EXT_LIST_ARM
1271     $ARCH_EXT_LIST_X86
1272     altivec
1273     ppc4xx
1274     vis
1275 "
1276
1277 HAVE_LIST_CMDLINE='
1278     inline_asm
1279     symver
1280     yasm
1281 '
1282
1283 HAVE_LIST_PUB='
1284     bigendian
1285     fast_unaligned
1286 '
1287
1288 MATH_FUNCS="
1289     atanf
1290     atan2f
1291     cbrtf
1292     cosf
1293     exp2
1294     exp2f
1295     expf
1296     isinf
1297     isnan
1298     ldexpf
1299     llrint
1300     llrintf
1301     log2
1302     log2f
1303     log10f
1304     lrint
1305     lrintf
1306     powf
1307     rint
1308     round
1309     roundf
1310     sinf
1311     trunc
1312     truncf
1313 "
1314
1315 HAVE_LIST="
1316     $ARCH_EXT_LIST
1317     $(add_suffix _external $ARCH_EXT_LIST)
1318     $(add_suffix _inline   $ARCH_EXT_LIST)
1319     $HAVE_LIST_CMDLINE
1320     $HAVE_LIST_PUB
1321     $THREADS_LIST
1322     $ATOMICS_LIST
1323     $MATH_FUNCS
1324     aligned_malloc
1325     aligned_stack
1326     alsa_asoundlib_h
1327     altivec_h
1328     arpa_inet_h
1329     asm_mod_q
1330     asm_mod_y
1331     atomic_cas_ptr
1332     atomics_native
1333     attribute_may_alias
1334     attribute_packed
1335     cdio_paranoia_h
1336     cdio_paranoia_paranoia_h
1337     closesocket
1338     CommandLineToArgvW
1339     CryptGenRandom
1340     dcbzl
1341     dev_bktr_ioctl_bt848_h
1342     dev_bktr_ioctl_meteor_h
1343     dev_ic_bt8xx_h
1344     dev_video_bktr_ioctl_bt848_h
1345     dev_video_meteor_ioctl_meteor_h
1346     direct_h
1347     dlfcn_h
1348     dlopen
1349     dos_paths
1350     dxva_h
1351     ebp_available
1352     ebx_available
1353     fast_64bit
1354     fast_clz
1355     fast_cmov
1356     fcntl
1357     fork
1358     getaddrinfo
1359     gethrtime
1360     getopt
1361     GetProcessAffinityMask
1362     GetProcessMemoryInfo
1363     GetProcessTimes
1364     GetSystemTimeAsFileTime
1365     getrusage
1366     getservbyport
1367     gettimeofday
1368     gnu_as
1369     gsm_h
1370     ibm_asm
1371     inet_aton
1372     io_h
1373     inline_asm_labels
1374     isatty
1375     jack_port_get_latency_range
1376     ldbrx
1377     libc_msvcrt
1378     libdc1394_1
1379     libdc1394_2
1380     local_aligned_16
1381     local_aligned_8
1382     localtime_r
1383     loongson
1384     machine_ioctl_bt848_h
1385     machine_ioctl_meteor_h
1386     machine_rw_barrier
1387     malloc_h
1388     MapViewOfFile
1389     memalign
1390     MemoryBarrier
1391     mkstemp
1392     mm_empty
1393     mmap
1394     mprotect
1395     nanosleep
1396     poll_h
1397     posix_memalign
1398     pragma_deprecated
1399     rdtsc
1400     sched_getaffinity
1401     sdl
1402     SetConsoleTextAttribute
1403     setmode
1404     setrlimit
1405     Sleep
1406     sndio_h
1407     socklen_t
1408     soundcard_h
1409     strerror_r
1410     strptime
1411     strtok_r
1412     struct_addrinfo
1413     struct_group_source_req
1414     struct_ip_mreq_source
1415     struct_ipv6_mreq
1416     struct_pollfd
1417     struct_rusage_ru_maxrss
1418     struct_sockaddr_in6
1419     struct_sockaddr_sa_len
1420     struct_sockaddr_storage
1421     struct_v4l2_frmivalenum_discrete
1422     symver_asm_label
1423     symver_gnu_asm
1424     sync_val_compare_and_swap
1425     sysconf
1426     sysctl
1427     sys_mman_h
1428     sys_param_h
1429     sys_resource_h
1430     sys_select_h
1431     sys_soundcard_h
1432     sys_time_h
1433     sys_un_h
1434     sys_videoio_h
1435     threads
1436     unistd_h
1437     usleep
1438     vdpau_x11
1439     vfp_args
1440     VirtualAlloc
1441     windows_h
1442     winsock2_h
1443     xform_asm
1444     xlib
1445     xmm_clobbers
1446 "
1447
1448 # options emitted with CONFIG_ prefix but not available on the command line
1449 CONFIG_EXTRA="
1450     aandcttables
1451     ac3dsp
1452     audio_frame_queue
1453     dsputil
1454     gcrypt
1455     golomb
1456     gplv3
1457     h263dsp
1458     h264chroma
1459     h264dsp
1460     h264pred
1461     h264qpel
1462     hpeldsp
1463     huffman
1464     intrax8
1465     lgplv3
1466     lpc
1467     mpegaudio
1468     mpegaudiodsp
1469     mpegvideo
1470     mpegvideoenc
1471     nettle
1472     rangecoder
1473     riffdec
1474     riffenc
1475     rtpdec
1476     rtpenc_chain
1477     sinewin
1478     videodsp
1479     vp3dsp
1480 "
1481
1482 CMDLINE_SELECT="
1483     $ARCH_EXT_LIST
1484     $CONFIG_LIST
1485     $HAVE_LIST_CMDLINE
1486     $THREADS_LIST
1487     asm
1488     cross_compile
1489     debug
1490     extra_warnings
1491     logging
1492     lto
1493     optimizations
1494 "
1495
1496 PATHS_LIST='
1497     bindir
1498     datadir
1499     docdir
1500     incdir
1501     libdir
1502     mandir
1503     prefix
1504     shlibdir
1505 '
1506
1507 CMDLINE_SET="
1508     $PATHS_LIST
1509     ar
1510     arch
1511     as
1512     build_suffix
1513     cc
1514     cpu
1515     cross_prefix
1516     dep_cc
1517     extra_version
1518     host_cc
1519     host_cflags
1520     host_ld
1521     host_ldflags
1522     host_libs
1523     host_os
1524     ld
1525     logfile
1526     malloc_prefix
1527     nm
1528     optflags
1529     pkg_config
1530     random_seed
1531     samples
1532     sysinclude
1533     sysroot
1534     target_exec
1535     target_os
1536     target_path
1537     target_samples
1538     toolchain
1539 "
1540
1541 CMDLINE_APPEND="
1542     extra_cflags
1543     host_cppflags
1544 "
1545
1546 # code dependency declarations
1547
1548 # architecture extensions
1549
1550 armv5te_deps="arm"
1551 armv6_deps="arm"
1552 armv6t2_deps="arm"
1553 neon_deps_any="aarch64 arm"
1554 vfp_deps_any="aarch64 arm"
1555 vfpv3_deps="vfp"
1556
1557 map 'eval ${v}_inline_deps=inline_asm' $ARCH_EXT_LIST_ARM
1558
1559 altivec_deps="ppc"
1560 ppc4xx_deps="ppc"
1561
1562 vis_deps="sparc"
1563
1564 cpunop_deps="i686"
1565 x86_64_select="i686"
1566 x86_64_suggest="fast_cmov"
1567
1568 amd3dnow_deps="mmx"
1569 amd3dnowext_deps="amd3dnow"
1570 i686_deps="x86"
1571 mmx_deps="x86"
1572 mmxext_deps="mmx"
1573 sse_deps="mmxext"
1574 sse2_deps="sse"
1575 sse3_deps="sse2"
1576 ssse3_deps="sse3"
1577 sse4_deps="ssse3"
1578 sse42_deps="sse4"
1579 avx_deps="sse42"
1580 xop_deps="avx"
1581 fma4_deps="avx"
1582 avx2_deps="avx"
1583
1584 mmx_external_deps="yasm"
1585 mmx_inline_deps="inline_asm"
1586 mmx_suggest="mmx_external mmx_inline"
1587
1588 for ext in $(filter_out mmx $ARCH_EXT_LIST_X86); do
1589     eval dep=\$${ext}_deps
1590     eval ${ext}_external_deps='"${dep}_external"'
1591     eval ${ext}_inline_deps='"${dep}_inline"'
1592     eval ${ext}_suggest='"${ext}_external ${ext}_inline"'
1593 done
1594
1595 aligned_stack_if_any="aarch64 ppc x86"
1596 fast_64bit_if_any="aarch64 alpha ia64 mips64 parisc64 ppc64 sparc64 x86_64"
1597 fast_clz_if_any="aarch64 alpha avr32 mips ppc x86"
1598 fast_unaligned_if_any="aarch64 ppc x86"
1599
1600 need_memalign="altivec neon sse"
1601
1602 # system capabilities
1603 log2_deps="!libc_msvcrt"
1604
1605 symver_if_any="symver_asm_label symver_gnu_asm"
1606
1607 # threading support
1608 atomics_gcc_if="sync_val_compare_and_swap"
1609 atomics_suncc_if="atomic_cas_ptr machine_rw_barrier"
1610 atomics_win32_if="MemoryBarrier"
1611 atomics_native_if_any="$ATOMICS_LIST"
1612 w32threads_deps="atomics_native"
1613 threads_if_any="$THREADS_LIST"
1614
1615 # subsystems
1616 dct_select="rdft"
1617 error_resilience_select="dsputil"
1618 lpc_select="dsputil"
1619 mdct_select="fft"
1620 rdft_select="fft"
1621 mpegaudio_select="mpegaudiodsp"
1622 mpegaudiodsp_select="dct"
1623 mpegvideo_select="dsputil hpeldsp videodsp"
1624 mpegvideoenc_select="mpegvideo"
1625
1626 # decoders / encoders
1627 aac_decoder_select="mdct sinewin"
1628 aac_encoder_select="audio_frame_queue mdct sinewin"
1629 aac_latm_decoder_select="aac_decoder aac_latm_parser"
1630 ac3_decoder_select="mdct ac3dsp ac3_parser dsputil"
1631 ac3_encoder_select="mdct ac3dsp dsputil"
1632 ac3_fixed_encoder_select="mdct ac3dsp dsputil"
1633 aic_decoder_select="dsputil golomb"
1634 alac_encoder_select="lpc"
1635 als_decoder_select="dsputil"
1636 amrnb_decoder_select="lsp"
1637 amrwb_decoder_select="lsp"
1638 amv_decoder_select="dsputil hpeldsp"
1639 ape_decoder_select="dsputil"
1640 asv1_decoder_select="dsputil"
1641 asv1_encoder_select="dsputil"
1642 asv2_decoder_select="dsputil"
1643 asv2_encoder_select="dsputil"
1644 atrac1_decoder_select="mdct sinewin"
1645 atrac3_decoder_select="mdct"
1646 atrac3p_decoder_select="mdct sinewin"
1647 bink_decoder_select="dsputil hpeldsp"
1648 binkaudio_dct_decoder_select="mdct rdft dct sinewin"
1649 binkaudio_rdft_decoder_select="mdct rdft sinewin"
1650 cavs_decoder_select="dsputil golomb h264chroma videodsp"
1651 cllc_decoder_select="dsputil"
1652 comfortnoise_encoder_select="lpc"
1653 cook_decoder_select="dsputil mdct sinewin"
1654 cscd_decoder_select="lzo"
1655 cscd_decoder_suggest="zlib"
1656 dca_decoder_select="mdct"
1657 dnxhd_decoder_select="dsputil"
1658 dnxhd_encoder_select="aandcttables dsputil mpegvideoenc"
1659 dvvideo_decoder_select="dsputil"
1660 dvvideo_encoder_select="dsputil"
1661 dxa_decoder_deps="zlib"
1662 eac3_decoder_select="ac3_decoder"
1663 eac3_encoder_select="ac3_encoder"
1664 eamad_decoder_select="aandcttables dsputil mpegvideo"
1665 eatgq_decoder_select="aandcttables dsputil"
1666 eatqi_decoder_select="aandcttables error_resilience mpegvideo"
1667 ffv1_decoder_select="dsputil golomb rangecoder"
1668 ffv1_encoder_select="dsputil rangecoder"
1669 ffvhuff_decoder_select="dsputil"
1670 ffvhuff_encoder_select="dsputil huffman"
1671 fic_decoder_select="dsputil golomb"
1672 flac_decoder_select="golomb"
1673 flac_encoder_select="dsputil golomb lpc"
1674 flashsv_decoder_deps="zlib"
1675 flashsv_encoder_deps="zlib"
1676 flashsv2_decoder_deps="zlib"
1677 flv_decoder_select="h263_decoder"
1678 flv_encoder_select="h263_encoder"
1679 fourxm_decoder_select="dsputil"
1680 fraps_decoder_select="dsputil huffman"
1681 g2m_decoder_deps="zlib"
1682 g2m_decoder_select="dsputil"
1683 h261_decoder_select="error_resilience mpegvideo"
1684 h261_encoder_select="aandcttables mpegvideoenc"
1685 h263_decoder_select="error_resilience h263_parser h263dsp mpegvideo"
1686 h263_encoder_select="aandcttables h263dsp mpegvideoenc"
1687 h263i_decoder_select="h263_decoder"
1688 h263p_encoder_select="h263_encoder"
1689 h264_decoder_select="golomb h264chroma h264dsp h264pred h264qpel videodsp"
1690 h264_decoder_suggest="error_resilience"
1691 hevc_decoder_select="dsputil golomb videodsp"
1692 huffyuv_decoder_select="dsputil"
1693 huffyuv_encoder_select="dsputil huffman"
1694 iac_decoder_select="dsputil fft mdct sinewin"
1695 imc_decoder_select="dsputil fft mdct sinewin"
1696 indeo3_decoder_select="hpeldsp"
1697 interplay_video_decoder_select="hpeldsp"
1698 jpegls_decoder_select="dsputil golomb hpeldsp"
1699 jpegls_encoder_select="golomb"
1700 jv_decoder_select="dsputil"
1701 lagarith_decoder_select="dsputil"
1702 ljpeg_encoder_select="aandcttables mpegvideoenc"
1703 loco_decoder_select="golomb"
1704 mdec_decoder_select="dsputil error_resilience mpegvideo"
1705 metasound_decoder_select="lsp mdct sinewin"
1706 mimic_decoder_select="dsputil hpeldsp"
1707 mjpeg_decoder_select="dsputil hpeldsp"
1708 mjpegb_decoder_select="dsputil hpeldsp"
1709 mjpeg_encoder_select="aandcttables dsputil mpegvideoenc"
1710 mlp_decoder_select="dsputil mlp_parser"
1711 motionpixels_decoder_select="dsputil"
1712 mp1_decoder_select="mpegaudio"
1713 mp1float_decoder_select="mpegaudio"
1714 mp2_decoder_select="mpegaudio"
1715 mp2float_decoder_select="mpegaudio"
1716 mp3_decoder_select="mpegaudio"
1717 mp3adu_decoder_select="mpegaudio"
1718 mp3adufloat_decoder_select="mpegaudio"
1719 mp3float_decoder_select="mpegaudio"
1720 mp3on4_decoder_select="mpegaudio"
1721 mp3on4float_decoder_select="mpegaudio"
1722 mpc7_decoder_select="dsputil mpegaudiodsp"
1723 mpc8_decoder_select="dsputil mpegaudiodsp"
1724 mpeg_xvmc_decoder_deps="X11_extensions_XvMClib_h"
1725 mpeg_xvmc_decoder_select="mpeg2video_decoder"
1726 mpeg1video_decoder_select="error_resilience mpegvideo"
1727 mpeg1video_encoder_select="aandcttables mpegvideoenc"
1728 mpeg2video_decoder_select="error_resilience mpegvideo"
1729 mpeg2video_encoder_select="aandcttables mpegvideoenc"
1730 mpeg4_decoder_select="h263_decoder mpeg4video_parser"
1731 mpeg4_encoder_select="h263_encoder"
1732 msmpeg4v1_decoder_select="h263_decoder"
1733 msmpeg4v2_decoder_select="h263_decoder"
1734 msmpeg4v2_encoder_select="h263_encoder"
1735 msmpeg4v3_decoder_select="h263_decoder"
1736 msmpeg4v3_encoder_select="h263_encoder"
1737 mss2_decoder_select="error_resilience vc1_decoder"
1738 mxpeg_decoder_select="dsputil hpeldsp"
1739 nellymoser_decoder_select="mdct sinewin"
1740 nellymoser_encoder_select="audio_frame_queue mdct sinewin"
1741 nuv_decoder_select="dsputil lzo"
1742 png_decoder_deps="zlib"
1743 png_decoder_select="dsputil"
1744 png_encoder_deps="zlib"
1745 png_encoder_select="dsputil"
1746 prores_decoder_select="dsputil"
1747 prores_encoder_select="dsputil"
1748 qcelp_decoder_select="lsp"
1749 qdm2_decoder_select="mdct rdft mpegaudiodsp"
1750 ra_144_encoder_select="audio_frame_queue lpc"
1751 ralf_decoder_select="golomb"
1752 rv10_decoder_select="error_resilience h263_decoder h263dsp"
1753 rv10_encoder_select="h263_encoder"
1754 rv20_decoder_select="error_resilience h263_decoder h263dsp"
1755 rv20_encoder_select="h263_encoder"
1756 rv30_decoder_select="error_resilience golomb h264chroma h264pred h264qpel mpegvideo videodsp"
1757 rv40_decoder_select="error_resilience golomb h264chroma h264pred h264qpel mpegvideo videodsp"
1758 shorten_decoder_select="golomb"
1759 sipr_decoder_select="lsp"
1760 sp5x_decoder_select="dsputil hpeldsp"
1761 svq1_decoder_select="hpeldsp"
1762 svq1_encoder_select="aandcttables dsputil hpeldsp mpegvideoenc"
1763 svq3_decoder_select="golomb h264chroma h264dsp h264pred h264qpel hpeldsp mpegvideo videodsp"
1764 svq3_decoder_suggest="error_resilience zlib"
1765 tak_decoder_select="dsputil"
1766 theora_decoder_select="vp3_decoder"
1767 tiff_decoder_suggest="zlib"
1768 tiff_encoder_suggest="zlib"
1769 thp_decoder_select="dsputil hpeldsp"
1770 truehd_decoder_select="mlp_decoder"
1771 truemotion2_decoder_select="dsputil"
1772 truespeech_decoder_select="dsputil"
1773 tscc_decoder_deps="zlib"
1774 twinvq_decoder_select="mdct lsp sinewin"
1775 utvideo_decoder_select="dsputil"
1776 utvideo_encoder_select="dsputil huffman"
1777 vble_decoder_select="dsputil"
1778 vc1_decoder_select="error_resilience h263_decoder h264chroma h264qpel intrax8"
1779 vc1image_decoder_select="vc1_decoder"
1780 vorbis_decoder_select="mdct"
1781 vorbis_encoder_select="mdct"
1782 vp3_decoder_select="hpeldsp vp3dsp videodsp"
1783 vp5_decoder_select="h264chroma hpeldsp videodsp vp3dsp"
1784 vp6_decoder_select="h264chroma hpeldsp huffman videodsp vp3dsp"
1785 vp6a_decoder_select="vp6_decoder"
1786 vp6f_decoder_select="vp6_decoder"
1787 vp8_decoder_select="h264pred videodsp"
1788 vp9_decoder_select="videodsp"
1789 webp_decoder_select="vp8_decoder"
1790 wmapro_decoder_select="mdct sinewin"
1791 wmav1_decoder_select="mdct sinewin"
1792 wmav1_encoder_select="mdct sinewin"
1793 wmav2_decoder_select="mdct sinewin"
1794 wmav2_encoder_select="mdct sinewin"
1795 wmavoice_decoder_select="lsp rdft dct mdct sinewin"
1796 wmv1_decoder_select="h263_decoder"
1797 wmv1_encoder_select="h263_encoder"
1798 wmv2_decoder_select="h263_decoder intrax8 videodsp"
1799 wmv2_encoder_select="h263_encoder"
1800 wmv3_decoder_select="vc1_decoder"
1801 wmv3image_decoder_select="wmv3_decoder"
1802 zerocodec_decoder_deps="zlib"
1803 zlib_decoder_deps="zlib"
1804 zlib_encoder_deps="zlib"
1805 zmbv_decoder_deps="zlib"
1806 zmbv_encoder_deps="zlib"
1807
1808 # hardware accelerators
1809 dxva2_deps="dxva2api_h"
1810 vaapi_deps="va_va_h"
1811 vda_deps="VideoDecodeAcceleration_VDADecoder_h pthreads"
1812 vda_extralibs="-framework CoreFoundation -framework VideoDecodeAcceleration -framework QuartzCore"
1813 vdpau_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
1814
1815 h263_vaapi_hwaccel_deps="vaapi"
1816 h263_vaapi_hwaccel_select="h263_decoder"
1817 h263_vdpau_hwaccel_deps="vdpau"
1818 h263_vdpau_hwaccel_select="h263_decoder"
1819 h264_dxva2_hwaccel_deps="dxva2"
1820 h264_dxva2_hwaccel_select="h264_decoder"
1821 h264_vaapi_hwaccel_deps="vaapi"
1822 h264_vaapi_hwaccel_select="h264_decoder"
1823 h264_vda_hwaccel_deps="vda"
1824 h264_vda_hwaccel_select="h264_decoder"
1825 h264_vdpau_hwaccel_deps="vdpau"
1826 h264_vdpau_hwaccel_select="h264_decoder"
1827 mpeg1_vdpau_hwaccel_deps="vdpau"
1828 mpeg1_vdpau_hwaccel_select="mpeg1video_decoder"
1829 mpeg2_dxva2_hwaccel_deps="dxva2"
1830 mpeg2_dxva2_hwaccel_select="mpeg2video_decoder"
1831 mpeg2_vaapi_hwaccel_deps="vaapi"
1832 mpeg2_vaapi_hwaccel_select="mpeg2video_decoder"
1833 mpeg2_vdpau_hwaccel_deps="vdpau"
1834 mpeg2_vdpau_hwaccel_select="mpeg2video_decoder"
1835 mpeg4_vaapi_hwaccel_deps="vaapi"
1836 mpeg4_vaapi_hwaccel_select="mpeg4_decoder"
1837 mpeg4_vdpau_hwaccel_deps="vdpau"
1838 mpeg4_vdpau_hwaccel_select="mpeg4_decoder"
1839 vc1_dxva2_hwaccel_deps="dxva2"
1840 vc1_dxva2_hwaccel_select="vc1_decoder"
1841 vc1_vaapi_hwaccel_deps="vaapi"
1842 vc1_vaapi_hwaccel_select="vc1_decoder"
1843 vc1_vdpau_hwaccel_deps="vdpau"
1844 vc1_vdpau_hwaccel_select="vc1_decoder"
1845 wmv3_dxva2_hwaccel_select="vc1_dxva2_hwaccel"
1846 wmv3_vaapi_hwaccel_select="vc1_vaapi_hwaccel"
1847 wmv3_vdpau_hwaccel_select="vc1_vdpau_hwaccel"
1848
1849 # parsers
1850 h264_parser_select="golomb h264chroma h264dsp h264pred h264qpel videodsp"
1851 mpeg4video_parser_select="error_resilience h263dsp mpegvideo"
1852 mpegvideo_parser_select="error_resilience mpegvideo"
1853 vc1_parser_select="mpegvideo"
1854
1855 # external libraries
1856 libfaac_encoder_deps="libfaac"
1857 libfaac_encoder_select="audio_frame_queue"
1858 libfdk_aac_decoder_deps="libfdk_aac"
1859 libfdk_aac_encoder_deps="libfdk_aac"
1860 libfdk_aac_encoder_select="audio_frame_queue"
1861 libgsm_decoder_deps="libgsm"
1862 libgsm_encoder_deps="libgsm"
1863 libgsm_ms_decoder_deps="libgsm"
1864 libgsm_ms_encoder_deps="libgsm"
1865 libilbc_decoder_deps="libilbc"
1866 libilbc_encoder_deps="libilbc"
1867 libmp3lame_encoder_deps="libmp3lame"
1868 libmp3lame_encoder_select="audio_frame_queue"
1869 libopencore_amrnb_decoder_deps="libopencore_amrnb"
1870 libopencore_amrnb_encoder_deps="libopencore_amrnb"
1871 libopencore_amrnb_encoder_select="audio_frame_queue"
1872 libopencore_amrwb_decoder_deps="libopencore_amrwb"
1873 libopenjpeg_decoder_deps="libopenjpeg"
1874 libopenjpeg_encoder_deps="libopenjpeg"
1875 libopus_decoder_deps="libopus"
1876 libopus_encoder_deps="libopus"
1877 libopus_encoder_select="audio_frame_queue"
1878 libschroedinger_decoder_deps="libschroedinger"
1879 libschroedinger_encoder_deps="libschroedinger"
1880 libspeex_decoder_deps="libspeex"
1881 libspeex_encoder_deps="libspeex"
1882 libspeex_encoder_select="audio_frame_queue"
1883 libtheora_encoder_deps="libtheora"
1884 libvo_aacenc_encoder_deps="libvo_aacenc"
1885 libvo_aacenc_encoder_select="audio_frame_queue"
1886 libvo_amrwbenc_encoder_deps="libvo_amrwbenc"
1887 libvorbis_encoder_deps="libvorbis"
1888 libvorbis_encoder_select="audio_frame_queue"
1889 libvpx_vp8_decoder_deps="libvpx"
1890 libvpx_vp8_encoder_deps="libvpx"
1891 libvpx_vp9_decoder_deps="libvpx"
1892 libvpx_vp9_encoder_deps="libvpx"
1893 libwavpack_encoder_deps="libwavpack"
1894 libwebp_encoder_deps="libwebp"
1895 libx264_encoder_deps="libx264"
1896 libx265_encoder_deps="libx265"
1897 libxavs_encoder_deps="libxavs"
1898 libxvid_encoder_deps="libxvid"
1899
1900 # demuxers / muxers
1901 ac3_demuxer_select="ac3_parser"
1902 asf_demuxer_select="riffdec"
1903 asf_muxer_select="riffenc"
1904 asf_stream_muxer_select="asf_muxer"
1905 avi_demuxer_select="riffdec"
1906 avi_muxer_select="riffenc"
1907 avisynth_demuxer_deps="avisynth"
1908 avisynth_demuxer_select="riffdec"
1909 caf_demuxer_select="riffdec"
1910 dirac_demuxer_select="dirac_parser"
1911 dxa_demuxer_select="riffdec"
1912 eac3_demuxer_select="ac3_parser"
1913 f4v_muxer_select="mov_muxer"
1914 flac_demuxer_select="flac_parser"
1915 hds_muxer_select="flv_muxer"
1916 hls_muxer_select="mpegts_muxer"
1917 ipod_muxer_select="mov_muxer"
1918 ismv_muxer_select="mov_muxer"
1919 matroska_audio_muxer_select="matroska_muxer"
1920 matroska_demuxer_select="riffdec"
1921 matroska_demuxer_suggest="bzlib lzo zlib"
1922 matroska_muxer_select="riffenc"
1923 mmf_muxer_select="riffenc"
1924 mov_demuxer_select="riffdec"
1925 mov_demuxer_suggest="zlib"
1926 mov_muxer_select="riffenc rtpenc_chain"
1927 mp3_demuxer_select="mpegaudio_parser"
1928 mp4_muxer_select="mov_muxer"
1929 mpegts_muxer_select="adts_muxer latm_muxer"
1930 mpegtsraw_demuxer_select="mpegts_demuxer"
1931 mxf_d10_muxer_select="mxf_muxer"
1932 nut_muxer_select="riffenc"
1933 nuv_demuxer_select="riffdec"
1934 ogg_demuxer_select="golomb"
1935 psp_muxer_select="mov_muxer"
1936 rtp_demuxer_select="sdp_demuxer"
1937 rtpdec_select="asf_demuxer rm_demuxer rtp_protocol mpegts_demuxer mov_demuxer"
1938 rtsp_demuxer_select="http_protocol rtpdec"
1939 rtsp_muxer_select="rtp_muxer http_protocol rtp_protocol rtpenc_chain"
1940 sap_demuxer_select="sdp_demuxer"
1941 sap_muxer_select="rtp_muxer rtp_protocol rtpenc_chain"
1942 sdp_demuxer_select="rtpdec"
1943 smoothstreaming_muxer_select="ismv_muxer"
1944 spdif_muxer_select="aac_parser"
1945 tak_demuxer_select="tak_parser"
1946 tg2_muxer_select="mov_muxer"
1947 tgp_muxer_select="mov_muxer"
1948 w64_demuxer_select="wav_demuxer"
1949 wav_demuxer_select="riffdec"
1950 wav_muxer_select="riffenc"
1951 webm_muxer_select="riffenc"
1952 wtv_demuxer_select="riffdec"
1953 xmv_demuxer_select="riffdec"
1954 xwma_demuxer_select="riffdec"
1955
1956 # indevs / outdevs
1957 alsa_indev_deps="alsa_asoundlib_h snd_pcm_htimestamp"
1958 alsa_outdev_deps="alsa_asoundlib_h"
1959 bktr_indev_deps_any="dev_bktr_ioctl_bt848_h machine_ioctl_bt848_h dev_video_bktr_ioctl_bt848_h dev_ic_bt8xx_h"
1960 dv1394_indev_deps="dv1394"
1961 dv1394_indev_select="dv_demuxer"
1962 fbdev_indev_deps="linux_fb_h"
1963 jack_indev_deps="jack_jack_h pthreads"
1964 libcdio_indev_deps="libcdio"
1965 libdc1394_indev_deps="libdc1394"
1966 oss_indev_deps_any="soundcard_h sys_soundcard_h"
1967 oss_outdev_deps_any="soundcard_h sys_soundcard_h"
1968 pulse_indev_deps="libpulse"
1969 sndio_indev_deps="sndio_h"
1970 sndio_outdev_deps="sndio_h"
1971 v4l2_indev_deps_any="linux_videodev2_h sys_videoio_h"
1972 vfwcap_indev_deps="capCreateCaptureWindow vfwcap_defines"
1973 vfwcap_indev_extralibs="-lavicap32"
1974 x11grab_indev_deps="x11grab XShmCreateImage"
1975
1976 # protocols
1977 ffrtmpcrypt_protocol_deps="!librtmp_protocol"
1978 ffrtmpcrypt_protocol_deps_any="gcrypt nettle openssl"
1979 ffrtmpcrypt_protocol_select="tcp_protocol"
1980 ffrtmphttp_protocol_deps="!librtmp_protocol"
1981 ffrtmphttp_protocol_select="http_protocol"
1982 gopher_protocol_select="network"
1983 httpproxy_protocol_select="tcp_protocol"
1984 http_protocol_select="tcp_protocol"
1985 https_protocol_select="tls_protocol"
1986 librtmp_protocol_deps="librtmp"
1987 librtmpe_protocol_deps="librtmp"
1988 librtmps_protocol_deps="librtmp"
1989 librtmpt_protocol_deps="librtmp"
1990 librtmpte_protocol_deps="librtmp"
1991 mmsh_protocol_select="http_protocol"
1992 mmst_protocol_select="network"
1993 rtmp_protocol_deps="!librtmp_protocol"
1994 rtmp_protocol_select="tcp_protocol"
1995 rtmpe_protocol_select="ffrtmpcrypt_protocol"
1996 rtmps_protocol_deps="!librtmp_protocol"
1997 rtmps_protocol_select="tls_protocol"
1998 rtmpt_protocol_select="ffrtmphttp_protocol"
1999 rtmpte_protocol_select="ffrtmpcrypt_protocol ffrtmphttp_protocol"
2000 rtmpts_protocol_select="ffrtmphttp_protocol https_protocol"
2001 rtp_protocol_select="udp_protocol"
2002 sctp_protocol_deps="struct_sctp_event_subscribe"
2003 sctp_protocol_select="network"
2004 srtp_protocol_select="rtp_protocol"
2005 tcp_protocol_select="network"
2006 tls_protocol_deps_any="openssl gnutls"
2007 tls_protocol_select="tcp_protocol"
2008 udp_protocol_select="network"
2009 unix_protocol_deps="sys_un_h"
2010 unix_protocol_select="network"
2011
2012 # filters
2013 blackframe_filter_deps="gpl"
2014 boxblur_filter_deps="gpl"
2015 cropdetect_filter_deps="gpl"
2016 delogo_filter_deps="gpl"
2017 drawtext_filter_deps="libfreetype"
2018 frei0r_filter_deps="frei0r dlopen strtok_r"
2019 frei0r_filter_extralibs='$ldl'
2020 frei0r_src_filter_deps="frei0r dlopen strtok_r"
2021 frei0r_src_filter_extralibs='$ldl'
2022 hqdn3d_filter_deps="gpl"
2023 interlace_filter_deps="gpl"
2024 resample_filter_deps="avresample"
2025 ocv_filter_deps="libopencv"
2026 scale_filter_deps="swscale"
2027
2028 # examples
2029 avcodec_example_deps="avcodec avutil"
2030 metadata_example_deps="avformat avutil"
2031 output_example_deps="avcodec avformat avutil swscale"
2032 transcode_aac_example_deps="avcodec avformat avresample"
2033
2034 # libraries
2035 avcodec_deps="avutil"
2036 avdevice_deps="avutil avcodec avformat"
2037 avfilter_deps="avutil"
2038 avformat_deps="avutil avcodec"
2039 avresample_deps="avutil"
2040 swscale_deps="avutil"
2041
2042 # programs
2043 avconv_deps="avcodec avfilter avformat avresample swscale"
2044 avconv_select="aformat_filter anull_filter asyncts_filter atrim_filter format_filter
2045                fps_filter null_filter resample_filter scale_filter
2046                setpts_filter trim_filter"
2047 avplay_deps="avcodec avformat avresample swscale sdl"
2048 avplay_libs='$sdl_libs'
2049 avplay_select="rdft"
2050 avprobe_deps="avcodec avformat"
2051 avserver_deps="avformat fork !shared"
2052 avserver_select="ffm_muxer rtp_protocol rtsp_demuxer"
2053
2054 # documentation
2055 pod2man_deps="doc"
2056 texi2html_deps="doc"
2057
2058 # default parameters
2059
2060 logfile="config.log"
2061
2062 # installation paths
2063 prefix_default="/usr/local"
2064 bindir_default='${prefix}/bin'
2065 datadir_default='${prefix}/share/avconv'
2066 docdir_default='${prefix}/share/doc/libav'
2067 incdir_default='${prefix}/include'
2068 libdir_default='${prefix}/lib'
2069 mandir_default='${prefix}/share/man'
2070 shlibdir_default="$libdir_default"
2071
2072 # toolchain
2073 ar_default="ar"
2074 cc_default="gcc"
2075 host_cc_default="gcc"
2076 cp_f="cp -f"
2077 ln_s="ln -s -f"
2078 nm_default="nm -g"
2079 objformat="elf"
2080 pkg_config_default=pkg-config
2081 ranlib="ranlib"
2082 strip="strip"
2083 yasmexe="yasm"
2084
2085 nogas=":"
2086
2087 # machine
2088 arch_default=$(uname -m)
2089 cpu="generic"
2090
2091 # OS
2092 target_os_default=$(tolower $(uname -s))
2093 host_os=$target_os_default
2094
2095 # configurable options
2096 enable $EXAMPLE_LIST $LIBRARY_LIST $PROGRAM_LIST
2097
2098 enable asm
2099 enable debug
2100 enable doc
2101 enable optimizations
2102 enable safe_bitstream_reader
2103 enable static
2104 enable swscale_alpha
2105
2106 # By default, enable only those hwaccels that have no external dependencies.
2107 enable dxva2 vdpau
2108
2109 # build settings
2110 SHFLAGS='-shared -Wl,-soname,$$(@F)'
2111 LIBPREF="lib"
2112 LIBSUF=".a"
2113 FULLNAME='$(NAME)$(BUILDSUF)'
2114 LIBNAME='$(LIBPREF)$(FULLNAME)$(LIBSUF)'
2115 SLIBPREF="lib"
2116 SLIBSUF=".so"
2117 SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF)'
2118 SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
2119 SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
2120 LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
2121 SLIB_INSTALL_NAME='$(SLIBNAME_WITH_VERSION)'
2122 SLIB_INSTALL_LINKS='$(SLIBNAME_WITH_MAJOR) $(SLIBNAME)'
2123
2124 asflags_filter=echo
2125 cflags_filter=echo
2126 ldflags_filter=echo
2127
2128 AS_C='-c'
2129 AS_O='-o $@'
2130 CC_C='-c'
2131 CC_E='-E -o $@'
2132 CC_O='-o $@'
2133 LD_O='-o $@'
2134 LD_LIB='-l%'
2135 LD_PATH='-L'
2136 HOSTCC_C='-c'
2137 HOSTCC_E='-E -o $@'
2138 HOSTCC_O='-o $@'
2139 HOSTLD_O='-o $@'
2140
2141 host_libs='-lm'
2142 host_cflags_filter=echo
2143 host_ldflags_filter=echo
2144
2145 target_path='$(CURDIR)'
2146
2147 # since the object filename is not given with the -MM flag, the compiler
2148 # is only able to print the basename, and we must add the path ourselves
2149 DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< | sed -e "/^\#.*/d" -e "s,^[[:space:]]*$(*F)\\.o,$(@D)/$(*F).o," > $(@:.o=.d)'
2150 DEPFLAGS='-MM'
2151
2152 # find source path
2153 if test -f configure; then
2154     source_path=.
2155 else
2156     source_path=$(cd $(dirname "$0"); pwd)
2157     echo "$source_path" | grep -q '[[:blank:]]' &&
2158         die "Out of tree builds are impossible with whitespace in source path."
2159     test -e "$source_path/config.h" &&
2160         die "Out of tree builds are impossible with config.h in source dir."
2161 fi
2162
2163 for v in "$@"; do
2164     r=${v#*=}
2165     l=${v%"$r"}
2166     r=$(sh_quote "$r")
2167     LIBAV_CONFIGURATION="${LIBAV_CONFIGURATION# } ${l}${r}"
2168 done
2169
2170 find_things(){
2171     thing=$1
2172     pattern=$2
2173     file=$source_path/$3
2174     sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" "$file"
2175 }
2176
2177 ENCODER_LIST=$(find_things  encoder  ENC      libavcodec/allcodecs.c)
2178 DECODER_LIST=$(find_things  decoder  DEC      libavcodec/allcodecs.c)
2179 HWACCEL_LIST=$(find_things  hwaccel  HWACCEL  libavcodec/allcodecs.c)
2180 PARSER_LIST=$(find_things   parser   PARSER   libavcodec/allcodecs.c)
2181 BSF_LIST=$(find_things      bsf      BSF      libavcodec/allcodecs.c)
2182 MUXER_LIST=$(find_things    muxer    _MUX     libavformat/allformats.c)
2183 DEMUXER_LIST=$(find_things  demuxer  DEMUX    libavformat/allformats.c)
2184 OUTDEV_LIST=$(find_things   outdev   OUTDEV   libavdevice/alldevices.c)
2185 INDEV_LIST=$(find_things    indev    _IN      libavdevice/alldevices.c)
2186 PROTOCOL_LIST=$(find_things protocol PROTOCOL libavformat/allformats.c)
2187 FILTER_LIST=$(find_things   filter   FILTER   libavfilter/allfilters.c)
2188
2189 ALL_COMPONENTS="
2190     $BSF_LIST
2191     $DECODER_LIST
2192     $DEMUXER_LIST
2193     $ENCODER_LIST
2194     $FILTER_LIST
2195     $HWACCEL_LIST
2196     $INDEV_LIST
2197     $MUXER_LIST
2198     $OUTDEV_LIST
2199     $PARSER_LIST
2200     $PROTOCOL_LIST
2201 "
2202
2203 for n in $COMPONENT_LIST; do
2204     v=$(toupper ${n%s})_LIST
2205     eval enable \$$v
2206     eval ${n}_if_any="\$$v"
2207 done
2208
2209 enable $ARCH_EXT_LIST
2210
2211 die_unknown(){
2212     echo "Unknown option \"$1\"."
2213     echo "See $0 --help for available options."
2214     exit 1
2215 }
2216
2217 print_3_columns() {
2218     cat | tr ' ' '\n' | sort | pr -r -3 -t
2219 }
2220
2221 show_list() {
2222     suffix=_$1
2223     shift
2224     echo $* | sed s/$suffix//g | print_3_columns
2225     exit 0
2226 }
2227
2228 rand_list(){
2229     IFS=', '
2230     set -- $*
2231     unset IFS
2232     for thing; do
2233         comp=${thing%:*}
2234         prob=${thing#$comp}
2235         prob=${prob#:}
2236         is_in ${comp} $COMPONENT_LIST && eval comp=\$$(toupper ${comp%s})_LIST
2237         echo "prob ${prob:-0.5}"
2238         printf '%s\n' $comp
2239     done
2240 }
2241
2242 do_random(){
2243     action=$1
2244     shift
2245     random_seed=$(awk "BEGIN { srand($random_seed); print srand() }")
2246     $action $(rand_list "$@" | awk "BEGIN { srand($random_seed) } \$1 == \"prob\" { prob = \$2; next } rand() < prob { print }")
2247 }
2248
2249 for opt do
2250     optval="${opt#*=}"
2251     case "$opt" in
2252         --extra-ldflags=*)
2253             add_ldflags $optval
2254         ;;
2255         --extra-libs=*)
2256             add_extralibs $optval
2257         ;;
2258         --disable-devices)
2259             disable $INDEV_LIST $OUTDEV_LIST
2260         ;;
2261         --enable-debug=*)
2262             debuglevel="$optval"
2263         ;;
2264         --disable-programs)
2265             disable $PROGRAM_LIST
2266         ;;
2267         --disable-everything)
2268             map 'eval unset \${$(toupper ${v%s})_LIST}' $COMPONENT_LIST
2269         ;;
2270         --disable-all)
2271             map 'eval unset \${$(toupper ${v%s})_LIST}' $COMPONENT_LIST
2272             disable $LIBRARY_LIST $PROGRAM_LIST doc
2273         ;;
2274         --enable-random|--disable-random)
2275             action=${opt%%-random}
2276             do_random ${action#--} $COMPONENT_LIST
2277         ;;
2278         --enable-random=*|--disable-random=*)
2279             action=${opt%%-random=*}
2280             do_random ${action#--} $optval
2281         ;;
2282         --enable-*=*|--disable-*=*)
2283             eval $(echo "${opt%%=*}" | sed 's/--/action=/;s/-/ thing=/')
2284             is_in "${thing}s" $COMPONENT_LIST || die_unknown "$opt"
2285             eval list=\$$(toupper $thing)_LIST
2286             name=$(echo "${optval}" | sed "s/,/_${thing}|/g")_${thing}
2287             $action $(filter "$name" $list)
2288         ;;
2289         --enable-?*|--disable-?*)
2290             eval $(echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g')
2291             if is_in $option $COMPONENT_LIST; then
2292                 test $action = disable && action=unset
2293                 eval $action \$$(toupper ${option%s})_LIST
2294             elif is_in $option $CMDLINE_SELECT; then
2295                 $action $option
2296             else
2297                 die_unknown $opt
2298             fi
2299         ;;
2300         --list-*)
2301             NAME="${opt#--list-}"
2302             is_in $NAME $COMPONENT_LIST || die_unknown $opt
2303             NAME=${NAME%s}
2304             eval show_list $NAME \$$(toupper $NAME)_LIST
2305         ;;
2306         --help|-h) show_help
2307         ;;
2308         *)
2309             optname="${opt%%=*}"
2310             optname="${optname#--}"
2311             optname=$(echo "$optname" | sed 's/-/_/g')
2312             if is_in $optname $CMDLINE_SET; then
2313                 eval $optname='$optval'
2314             elif is_in $optname $CMDLINE_APPEND; then
2315                 append $optname "$optval"
2316             else
2317                 die_unknown $opt
2318             fi
2319         ;;
2320     esac
2321 done
2322
2323 disabled logging && logfile=/dev/null
2324
2325 echo "# $0 $LIBAV_CONFIGURATION" > $logfile
2326 set >> $logfile
2327
2328 test -n "$cross_prefix" && enable cross_compile
2329
2330 if enabled cross_compile; then
2331     test -n "$arch" && test -n "$target_os" ||
2332         die "Must specify target arch and OS when cross-compiling"
2333 fi
2334
2335 ar_default="${cross_prefix}${ar_default}"
2336 cc_default="${cross_prefix}${cc_default}"
2337 nm_default="${cross_prefix}${nm_default}"
2338 pkg_config_default="${cross_prefix}${pkg_config_default}"
2339 ranlib="${cross_prefix}${ranlib}"
2340 strip="${cross_prefix}${strip}"
2341
2342 sysinclude_default="${sysroot}/usr/include"
2343
2344 case "$toolchain" in
2345     clang-asan)
2346         cc_default="clang"
2347         add_cflags  -fsanitize=address
2348         add_ldflags -fsanitize=address
2349     ;;
2350     clang-tsan)
2351         cc_default="clang"
2352         add_cflags  -fsanitize=thread -pie
2353         add_ldflags -fsanitize=thread -pie
2354     ;;
2355     clang-usan)
2356         cc_default="clang"
2357         add_cflags  -fsanitize=undefined
2358         add_ldflags -fsanitize=undefined
2359     ;;
2360     gcc-asan)
2361         cc_default="gcc"
2362         add_cflags  -fsanitize=address
2363         add_ldflags -fsanitize=address
2364     ;;
2365     gcc-tsan)
2366         cc_default="gcc"
2367         add_cflags  -fsanitize=thread -pie -fPIC
2368         add_ldflags -fsanitize=thread -pie -fPIC
2369     ;;
2370     gcc-usan)
2371         cc_default="gcc"
2372         add_cflags  -fsanitize=undefined
2373         add_ldflags -fsanitize=undefined
2374     ;;
2375     valgrind-massif)
2376         target_exec_default="valgrind"
2377         target_exec_args="--alloc-fn=av_malloc --alloc-fn=av_mallocz"
2378     ;;
2379     valgrind-memcheck)
2380         target_exec_default="valgrind"
2381         target_exec_args="--track-origins=yes --leak-check=full"
2382     ;;
2383     msvc)
2384         # Check whether the current MSVC version needs the C99 converter.
2385         # From MSVC 2013 (compiler major version 18) onwards, it does actually
2386         # support enough of C99 to build libav. Default to the new
2387         # behaviour if the regexp was unable to match anything, since this
2388         # successfully parses the version number of existing supported
2389         # versions that require the converter (MSVC 2010 and 2012).
2390         cl_major_ver=$(cl 2>&1 | sed -n 's/.*Version \([[:digit:]]\{1,\}\)\..*/\1/p')
2391         if [ -z "$cl_major_ver" ] || [ $cl_major_ver -ge 18 ]; then
2392             cc_default="cl"
2393         else
2394             cc_default="c99wrap cl"
2395         fi
2396         ld_default="link"
2397         nm_default="dumpbin -symbols"
2398         ar_default="lib"
2399         target_os_default="win32"
2400         # Use a relative path for TMPDIR. This makes sure all the
2401         # ffconf temp files are written with a relative path, avoiding
2402         # issues with msys/win32 path conversion for MSVC parameters
2403         # such as -Fo<file> or -out:<file>.
2404         TMPDIR=.
2405     ;;
2406     icl)
2407         cc_default="icl"
2408         ld_default="xilink"
2409         nm_default="dumpbin -symbols"
2410         ar_default="xilib"
2411         target_os_default="win32"
2412         TMPDIR=.
2413     ;;
2414     gcov)
2415         add_cflags  -fprofile-arcs -ftest-coverage
2416         add_ldflags -fprofile-arcs -ftest-coverage
2417     ;;
2418     hardened)
2419         add_cflags -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protector-all
2420         add_ldflags -Wl,-z,relro -Wl,-z,now
2421     ;;
2422     ?*)
2423         die "Unknown toolchain $toolchain"
2424     ;;
2425 esac
2426
2427 set_default arch cc pkg_config sysinclude target_exec target_os
2428 enabled cross_compile || host_cc_default=$cc
2429 set_default host_cc
2430
2431 if ! $pkg_config --version >/dev/null 2>&1; then
2432     warn "$pkg_config not found, library detection may fail."
2433     pkg_config=false
2434 fi
2435
2436 exesuf() {
2437     case $1 in
2438         mingw32*|win32|win64|cygwin*|*-dos|freedos|opendos|os/2*|symbian) echo .exe ;;
2439     esac
2440 }
2441
2442 EXESUF=$(exesuf $target_os)
2443 HOSTEXESUF=$(exesuf $host_os)
2444
2445 # set temporary file name
2446 : ${TMPDIR:=$TEMPDIR}
2447 : ${TMPDIR:=$TMP}
2448 : ${TMPDIR:=/tmp}
2449
2450 if ! check_cmd mktemp -u XXXXXX; then
2451     # simple replacement for missing mktemp
2452     # NOT SAFE FOR GENERAL USE
2453     mktemp(){
2454         echo "${2%%XXX*}.${HOSTNAME}.${UID}.$$"
2455     }
2456 fi
2457
2458 tmpfile(){
2459     tmp=$(mktemp -u "${TMPDIR}/ffconf.XXXXXXXX")$2 &&
2460         (set -C; exec > $tmp) 2>/dev/null ||
2461         die "Unable to create temporary file in $TMPDIR."
2462     append TMPFILES $tmp
2463     eval $1=$tmp
2464 }
2465
2466 trap 'rm -f -- $TMPFILES' EXIT
2467
2468 tmpfile TMPASM .asm
2469 tmpfile TMPC   .c
2470 tmpfile TMPE   $EXESUF
2471 tmpfile TMPH   .h
2472 tmpfile TMPO   .o
2473 tmpfile TMPS   .S
2474 tmpfile TMPSH  .sh
2475 tmpfile TMPV   .ver
2476
2477 unset -f mktemp
2478
2479 chmod +x $TMPE
2480
2481 # make sure we can execute files in $TMPDIR
2482 cat > $TMPSH 2>> $logfile <<EOF
2483 #! /bin/sh
2484 EOF
2485 chmod +x $TMPSH >> $logfile 2>&1
2486 if ! $TMPSH >> $logfile 2>&1; then
2487     cat <<EOF
2488 Unable to create and execute files in $TMPDIR.  Set the TMPDIR environment
2489 variable to another directory and make sure that it is not mounted noexec.
2490 EOF
2491     die "Sanity test failed."
2492 fi
2493
2494 ccc_flags(){
2495     for flag; do
2496         case $flag in
2497             -std=c99)           echo -c99                       ;;
2498             -mcpu=*)            echo -arch ${flag#*=}           ;;
2499             -mieee)             echo -ieee                      ;;
2500             -O*|-fast)          echo $flag                      ;;
2501             -fno-math-errno)    echo -assume nomath_errno       ;;
2502             -g)                 echo -g3                        ;;
2503             -Wall)              echo -msg_enable level2         ;;
2504             -Wno-pointer-sign)  echo -msg_disable ptrmismatch1  ;;
2505             -Wl,*)              echo $flag                      ;;
2506             -f*|-W*)                                            ;;
2507             *)                  echo $flag                      ;;
2508         esac
2509    done
2510 }
2511
2512 cparser_flags(){
2513     for flag; do
2514         case $flag in
2515             -Wno-switch)             echo -Wno-switch-enum ;;
2516             -Wno-format-zero-length) ;;
2517             -Wdisabled-optimization) ;;
2518             -Wno-pointer-sign)       echo -Wno-other ;;
2519             *)                       echo $flag ;;
2520         esac
2521     done
2522 }
2523
2524 msvc_common_flags(){
2525     for flag; do
2526         case $flag in
2527             # In addition to specifying certain flags under the compiler
2528             # specific filters, they must be specified here as well or else the
2529             # generic catch all at the bottom will print the original flag.
2530             -Wall)                ;;
2531             -std=c99)             ;;
2532             # Common flags
2533             -fomit-frame-pointer) ;;
2534             -g)                   echo -Z7 ;;
2535             -fno-math-errno)      ;;
2536             -fno-common)          ;;
2537             -fno-signed-zeros)    ;;
2538             -fPIC)                ;;
2539             -mthumb)              ;;
2540             -march=*)             ;;
2541             -lz)                  echo zlib.lib ;;
2542             -lavifil32)           echo vfw32.lib ;;
2543             -lavicap32)           echo vfw32.lib user32.lib ;;
2544             -l*)                  echo ${flag#-l}.lib ;;
2545             *)                    echo $flag ;;
2546         esac
2547     done
2548 }
2549
2550 msvc_flags(){
2551     msvc_common_flags "$@"
2552     for flag; do
2553         case $flag in
2554             -Wall)                echo -W4 -wd4244 -wd4127 -wd4018 -wd4389     \
2555                                        -wd4146 -wd4057 -wd4204 -wd4706 -wd4305 \
2556                                        -wd4152 -wd4324 -we4013 -wd4100 -wd4214 \
2557                                        -wd4273 ;;
2558         esac
2559     done
2560 }
2561
2562 icl_flags(){
2563     msvc_common_flags "$@"
2564     for flag; do
2565         case $flag in
2566             # Despite what Intel's documentation says -Wall, which is supported
2567             # on Windows, does enable remarks so disable them here.
2568             -Wall)                echo $flag -Qdiag-disable:remark ;;
2569             -std=c99)             echo -Qstd=c99 ;;
2570         esac
2571     done
2572 }
2573
2574 pgi_flags(){
2575     for flag; do
2576         case $flag in
2577             -flto)                echo -Mipa=fast,libopt,libinline,vestigial ;;
2578             -fomit-frame-pointer) echo -Mnoframe ;;
2579             -g)                   echo -gopt ;;
2580             *)                    echo $flag ;;
2581         esac
2582     done
2583 }
2584
2585 suncc_flags(){
2586     for flag; do
2587         case $flag in
2588             -march=*|-mcpu=*)
2589                 case "${flag#*=}" in
2590                     native)                   echo -xtarget=native       ;;
2591                     v9|niagara)               echo -xarch=sparc          ;;
2592                     ultrasparc)               echo -xarch=sparcvis       ;;
2593                     ultrasparc3|niagara2)     echo -xarch=sparcvis2      ;;
2594                     i586|pentium)             echo -xchip=pentium        ;;
2595                     i686|pentiumpro|pentium2) echo -xtarget=pentium_pro  ;;
2596                     pentium3*|c3-2)           echo -xtarget=pentium3     ;;
2597                     pentium-m)          echo -xarch=sse2 -xchip=pentium3 ;;
2598                     pentium4*)          echo -xtarget=pentium4           ;;
2599                     prescott|nocona)    echo -xarch=sse3 -xchip=pentium4 ;;
2600                     *-sse3)             echo -xarch=sse3                 ;;
2601                     core2)              echo -xarch=ssse3 -xchip=core2   ;;
2602                     corei7)           echo -xarch=sse4_2 -xchip=nehalem  ;;
2603                     corei7-avx)       echo -xarch=avx -xchip=sandybridge ;;
2604                     amdfam10|barcelona|bdver*) echo -xarch=sse4_1        ;;
2605                     athlon-4|athlon-[mx]p)     echo -xarch=ssea          ;;
2606                     k8|opteron|athlon64|athlon-fx)
2607                                                echo -xarch=sse2a         ;;
2608                     athlon*)                   echo -xarch=pentium_proa  ;;
2609                 esac
2610                 ;;
2611             -std=c99)             echo -xc99              ;;
2612             -fomit-frame-pointer) echo -xregs=frameptr    ;;
2613             -fPIC)                echo -KPIC -xcode=pic32 ;;
2614             -W*,*)                echo $flag              ;;
2615             -f*-*|-W*|-mimpure-text)                      ;;
2616             -shared)              echo -G                 ;;
2617             *)                    echo $flag              ;;
2618         esac
2619     done
2620 }
2621
2622 tms470_flags(){
2623     for flag; do
2624         case $flag in
2625             -march=*|-mcpu=*)
2626                 case "${flag#*=}" in
2627                     armv7-a|cortex-a*)      echo -mv=7a8 ;;
2628                     armv7-r|cortex-r*)      echo -mv=7r4 ;;
2629                     armv7-m|cortex-m*)      echo -mv=7m3 ;;
2630                     armv6*|arm11*)          echo -mv=6   ;;
2631                     armv5*e|arm[79]*e*|arm9[24]6*|arm96*|arm102[26])
2632                                             echo -mv=5e  ;;
2633                     armv4*|arm7*|arm9[24]*) echo -mv=4   ;;
2634                 esac
2635                 ;;
2636             -mfpu=neon)     echo --float_support=vfpv3 --neon ;;
2637             -mfpu=vfp)      echo --float_support=vfpv2        ;;
2638             -mfpu=vfpv3)    echo --float_support=vfpv3        ;;
2639             -mfpu=vfpv3-d16) echo --float_support=vfpv3d16    ;;
2640             -msoft-float)   echo --float_support=vfplib       ;;
2641             -O[0-3]|-mf=*)  echo $flag                        ;;
2642             -g)             echo -g -mn                       ;;
2643             -pds=*)         echo $flag                        ;;
2644             -D*|-I*)        echo $flag                        ;;
2645             --gcc|--abi=*)  echo $flag                        ;;
2646             -me)            echo $flag                        ;;
2647         esac
2648     done
2649 }
2650
2651 probe_cc(){
2652     pfx=$1
2653     _cc=$2
2654
2655     unset _type _ident _cc_c _cc_e _cc_o _flags _cflags
2656     unset _ld_o _ldflags _ld_lib _ld_path
2657     unset _depflags _DEPCMD _DEPFLAGS
2658     _flags_filter=echo
2659
2660     if $_cc -v 2>&1 | grep -q '^gcc.*LLVM'; then
2661         _type=llvm_gcc
2662         gcc_extra_ver=$(expr "$($_cc --version | head -n1)" : '.*\((.*)\)')
2663         _ident="llvm-gcc $($_cc -dumpversion) $gcc_extra_ver"
2664         _depflags='-MMD -MF $(@:.o=.d) -MT $@'
2665         _cflags_speed='-O3'
2666         _cflags_size='-Os'
2667     elif $_cc -v 2>&1 | grep -qi ^gcc; then
2668         _type=gcc
2669         gcc_version=$($_cc --version | head -n1)
2670         gcc_basever=$($_cc -dumpversion)
2671         gcc_pkg_ver=$(expr "$gcc_version" : '[^ ]* \(([^)]*)\)')
2672         gcc_ext_ver=$(expr "$gcc_version" : ".*$gcc_pkg_ver $gcc_basever \\(.*\\)")
2673         _ident=$(cleanws "gcc $gcc_basever $gcc_pkg_ver $gcc_ext_ver")
2674         if ! $_cc -dumpversion | grep -q '^2\.'; then
2675             _depflags='-MMD -MF $(@:.o=.d) -MT $@'
2676         fi
2677         _cflags_speed='-O3'
2678         _cflags_size='-Os'
2679     elif $_cc --version 2>/dev/null | grep -q ^icc; then
2680         _type=icc
2681         _ident=$($_cc --version | head -n1)
2682         _depflags='-MMD'
2683         _cflags_speed='-O3'
2684         _cflags_size='-Os'
2685         _cflags_noopt='-O1'
2686     elif $_cc -v 2>&1 | grep -q xlc; then
2687         _type=xlc
2688         _ident=$($_cc -qversion 2>/dev/null | head -n1)
2689         _cflags_speed='-O5'
2690         _cflags_size='-O5 -qcompact'
2691     elif $_cc -V 2>/dev/null | grep -q Compaq; then
2692         _type=ccc
2693         _ident=$($_cc -V | head -n1 | cut -d' ' -f1-3)
2694         _DEPFLAGS='-M'
2695         _cflags_speed='-fast'
2696         _cflags_size='-O1'
2697         _flags_filter=ccc_flags
2698     elif $_cc --vsn 2>/dev/null | grep -q "ARM C/C++ Compiler"; then
2699         test -d "$sysroot" || die "No valid sysroot specified."
2700         _type=armcc
2701         _ident=$($_cc --vsn | head -n1)
2702         armcc_conf="$PWD/armcc.conf"
2703         $_cc --arm_linux_configure                 \
2704              --arm_linux_config_file="$armcc_conf" \
2705              --configure_sysroot="$sysroot"        \
2706              --configure_cpp_headers="$sysinclude" >>$logfile 2>&1 ||
2707              die "Error creating armcc configuration file."
2708         $_cc --vsn | grep -q RVCT && armcc_opt=rvct || armcc_opt=armcc
2709         _flags="--arm_linux_config_file=$armcc_conf --translate_gcc"
2710         as_default="${cross_prefix}gcc"
2711         _depflags='-MMD'
2712         _cflags_speed='-O3'
2713         _cflags_size='-Os'
2714     elif $_cc -version 2>/dev/null | grep -Eq 'TMS470|TI ARM'; then
2715         _type=tms470
2716         _ident=$($_cc -version | head -n1 | tr -s ' ')
2717         _flags='--gcc --abi=eabi -me'
2718         _cc_e='-ppl -fe=$@'
2719         _cc_o='-fe=$@'
2720         _depflags='-ppa -ppd=$(@:.o=.d)'
2721         _cflags_speed='-O3 -mf=5'
2722         _cflags_size='-O3 -mf=2'
2723         _flags_filter=tms470_flags
2724     elif $_cc -v 2>&1 | grep -q clang; then
2725         _type=clang
2726         _ident=$($_cc --version | head -n1)
2727         _depflags='-MMD -MF $(@:.o=.d) -MT $@'
2728         _cflags_speed='-O3'
2729         _cflags_size='-Os'
2730     elif $_cc -V 2>&1 | grep -q Sun; then
2731         _type=suncc
2732         _ident=$($_cc -V 2>&1 | head -n1 | cut -d' ' -f 2-)
2733         _DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< | sed -e "1s,^.*: ,$@: ," -e "\$$!s,\$$, \\\," -e "1!s,^.*: , ," > $(@:.o=.d)'
2734         _DEPFLAGS='-xM1 -xc99'
2735         _ldflags='-std=c99'
2736         _cflags_speed='-O5'
2737         _cflags_size='-O5 -xspace'
2738         _flags_filter=suncc_flags
2739     elif $_cc -v 2>&1 | grep -q 'PathScale\|Path64'; then
2740         _type=pathscale
2741         _ident=$($_cc -v 2>&1 | head -n1 | tr -d :)
2742         _depflags='-MMD -MF $(@:.o=.d) -MT $@'
2743         _cflags_speed='-O2'
2744         _cflags_size='-Os'
2745         _flags_filter='filter_out -Wdisabled-optimization'
2746     elif $_cc -v 2>&1 | grep -q Open64; then
2747         _type=open64
2748         _ident=$($_cc -v 2>&1 | head -n1 | tr -d :)
2749         _depflags='-MMD -MF $(@:.o=.d) -MT $@'
2750         _cflags_speed='-O2'
2751         _cflags_size='-Os'
2752         _flags_filter='filter_out -Wdisabled-optimization|-Wtype-limits|-fno-signed-zeros'
2753     elif $_cc -V 2>&1 | grep -q Portland; then
2754         _type=pgi
2755         _ident="PGI $($_cc -V 2>&1 | awk '/^pgcc/ { print $2; exit }')"
2756         opt_common='-alias=ansi -Mdse -Mlre -Mpre'
2757         _cflags_speed="-O3 -Mautoinline -Munroll=c:4 $opt_common"
2758         _cflags_size="-O2 -Munroll=c:1 $opt_common"
2759         _cflags_noopt="-O1"
2760         _flags_filter=pgi_flags
2761     elif $_cc 2>&1 | grep -q Microsoft; then
2762         _type=msvc
2763         _ident=$($cc 2>&1 | head -n1)
2764         _DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< 2>&1 | awk '\''/including/ { sub(/^.*file: */, ""); gsub(/\\/, "/"); if (!match($$0, / /)) print "$@:", $$0 }'\'' > $(@:.o=.d)'
2765         _DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -showIncludes -Zs'
2766         _cflags_speed="-O2"
2767         _cflags_size="-O1"
2768         if $_cc 2>&1 | grep -q Linker; then
2769             _ld_o='-out:$@'
2770         else
2771             _ld_o='-Fe$@'
2772         fi
2773         _cc_o='-Fo$@'
2774         _cc_e='-P -Fi$@'
2775         _flags_filter=msvc_flags
2776         _ld_lib='lib%.a'
2777         _ld_path='-libpath:'
2778         _flags='-nologo'
2779         _cflags='-D_USE_MATH_DEFINES -D_CRT_SECURE_NO_WARNINGS -Dinline=__inline -FIstdlib.h -Dstrtoll=_strtoi64'
2780         if [ $pfx = hostcc ]; then
2781             append _cflags -Dsnprintf=_snprintf
2782         fi
2783     elif $_cc 2>&1 | grep -q Intel; then
2784         _type=icl
2785         _ident=$($cc 2>&1 | head -n1)
2786         _depflags='-QMMD -QMF$(@:.o=.d) -QMT$@'
2787         # Not only is O3 broken on 13.x+ but it is slower on all previous
2788         # versions (tested) as well.
2789         _cflags_speed="-O2"
2790         _cflags_size="-O1 -Oi" # -O1 without -Oi miscompiles stuff
2791         if $_cc 2>&1 | grep -q Linker; then
2792             _ld_o='-out:$@'
2793         else
2794             _ld_o='-Fe$@'
2795         fi
2796         _cc_o='-Fo$@'
2797         _cc_e='-P'
2798         _flags_filter=icl_flags
2799         _ld_lib='lib%.a'
2800         _ld_path='-libpath:'
2801         # -Qdiag-error to make icl error when seeing certain unknown arguments
2802         _flags='-nologo -Qdiag-error:4044,10157'
2803         # -Qvec- -Qsimd- to prevent miscompilation, -GS for consistency
2804         # with MSVC which enables it by default.
2805         _cflags='-D_USE_MATH_DEFINES -FIstdlib.h -Dstrtoll=_strtoi64 -Qms0 -Qvec- -Qsimd- -GS'
2806         if [ $pfx = hostcc ]; then
2807             append _cflags -Dsnprintf=_snprintf
2808         fi
2809     elif $_cc --version 2>/dev/null | grep -q ^cparser; then
2810         _type=cparser
2811         _ident=$($_cc --version | head -n1)
2812         _depflags='-MMD'
2813         _cflags_speed='-O4'
2814         _cflags_size='-O2'
2815         _flags_filter=cparser_flags
2816     fi
2817
2818     eval ${pfx}_type=\$_type
2819     eval ${pfx}_ident=\$_ident
2820 }
2821
2822 set_ccvars(){
2823     eval ${1}_C=\${_cc_c-\${${1}_C}}
2824     eval ${1}_E=\${_cc_e-\${${1}_E}}
2825     eval ${1}_O=\${_cc_o-\${${1}_O}}
2826
2827     if [ -n "$_depflags" ]; then
2828         eval ${1}_DEPFLAGS=\$_depflags
2829     else
2830         eval ${1}DEP=\${_DEPCMD:-\$DEPCMD}
2831         eval ${1}DEP_FLAGS=\${_DEPFLAGS:-\$DEPFLAGS}
2832         eval DEP${1}FLAGS=\$_flags
2833     fi
2834 }
2835
2836 probe_cc cc "$cc"
2837 cflags_filter=$_flags_filter
2838 cflags_speed=$_cflags_speed
2839 cflags_size=$_cflags_size
2840 cflags_noopt=$_cflags_noopt
2841 add_cflags $_flags $_cflags
2842 cc_ldflags=$_ldflags
2843 set_ccvars CC
2844
2845 probe_cc hostcc "$host_cc"
2846 host_cflags_filter=$_flags_filter
2847 add_host_cflags  $_flags $_cflags
2848 set_ccvars HOSTCC
2849
2850 test -n "$cc_type" && enable $cc_type ||
2851     warn "Unknown C compiler $cc, unable to select optimal CFLAGS"
2852
2853 : ${as_default:=$cc}
2854 : ${dep_cc_default:=$cc}
2855 : ${ld_default:=$cc}
2856 : ${host_ld_default:=$host_cc}
2857 set_default ar as dep_cc ld host_ld
2858
2859 probe_cc as "$as"
2860 asflags_filter=$_flags_filter
2861 add_asflags $_flags $_cflags
2862 set_ccvars AS
2863
2864 probe_cc ld "$ld"
2865 ldflags_filter=$_flags_filter
2866 add_ldflags $_flags $_ldflags
2867 test "$cc_type" != "$ld_type" && add_ldflags $cc_ldflags
2868 LD_O=${_ld_o-$LD_O}
2869 LD_LIB=${_ld_lib-$LD_LIB}
2870 LD_PATH=${_ld_path-$LD_PATH}
2871
2872 probe_cc hostld "$host_ld"
2873 host_ldflags_filter=$_flags_filter
2874 add_host_ldflags $_flags $_ldflags
2875 HOSTLD_O=${_ld_o-$HOSTLD_O}
2876
2877 if [ -z "$CC_DEPFLAGS" ] && [ "$dep_cc" != "$cc" ]; then
2878     probe_cc depcc "$dep_cc"
2879     CCDEP=${_DEPCMD:-$DEPCMD}
2880     CCDEP_FLAGS=${_DEPFLAGS:=$DEPFLAGS}
2881     DEPCCFLAGS=$_flags
2882 fi
2883
2884 if $ar 2>&1 | grep -q Microsoft; then
2885     arflags="-nologo"
2886     ar_o='-out:$@'
2887 elif $ar 2>&1 | grep -q 'Texas Instruments'; then
2888     arflags="rq"
2889     ar_o='$@'
2890 elif $ar 2>&1 | grep -q 'Usage: ar.*-X.*any'; then
2891     arflags='-Xany -r -c'
2892     ar_o='$@'
2893 else
2894     arflags="rc"
2895     ar_o='$@'
2896 fi
2897
2898 add_cflags $extra_cflags
2899 add_asflags $extra_cflags
2900
2901 if test -n "$sysroot"; then
2902     case "$cc_type" in
2903         gcc|llvm_gcc|clang)
2904             add_cppflags --sysroot="$sysroot"
2905             add_ldflags --sysroot="$sysroot"
2906         ;;
2907         tms470)
2908             add_cppflags -I"$sysinclude"
2909             add_ldflags  --sysroot="$sysroot"
2910         ;;
2911     esac
2912 fi
2913
2914 if test "$cpu" = host; then
2915     enabled cross_compile &&
2916         die "--cpu=host makes no sense when cross-compiling."
2917
2918     case "$cc_type" in
2919         gcc|llvm_gcc)
2920             check_native(){
2921                 $cc $1=native -v -c -o $TMPO $TMPC >$TMPE 2>&1 || return
2922                 sed -n "/cc1.*$1=/{
2923                             s/.*$1=\\([^ ]*\\).*/\\1/
2924                             p
2925                             q
2926                         }" $TMPE
2927             }
2928             cpu=$(check_native -march || check_native -mcpu)
2929         ;;
2930     esac
2931
2932     test "${cpu:-host}" = host &&
2933         die "--cpu=host not supported with compiler $cc"
2934 fi
2935
2936 # Deal with common $arch aliases
2937 case "$arch" in
2938     aarch64|arm64)
2939         arch="aarch64"
2940     ;;
2941     arm*)
2942         arch="arm"
2943     ;;
2944     mips*|IP*)
2945         arch="mips"
2946     ;;
2947     parisc*|hppa*)
2948         arch="parisc"
2949     ;;
2950     "Power Macintosh"|ppc*|powerpc*)
2951         arch="ppc"
2952     ;;
2953     s390|s390x)
2954         arch="s390"
2955     ;;
2956     sh4|sh)
2957         arch="sh4"
2958     ;;
2959     sun4u|sparc*)
2960         arch="sparc"
2961     ;;
2962     tilegx|tile-gx)
2963         arch="tilegx"
2964     ;;
2965     i[3-6]86|i86pc|BePC|x86pc|x86_64|amd64)
2966         arch="x86"
2967     ;;
2968 esac
2969
2970 is_in $arch $ARCH_LIST || warn "unknown architecture $arch"
2971 enable $arch
2972
2973 # Add processor-specific flags
2974 if enabled aarch64; then
2975
2976     case $cpu in
2977         armv*)
2978             cpuflags="-march=$cpu"
2979         ;;
2980         *)
2981             cpuflags="-mcpu=$cpu"
2982         ;;
2983     esac
2984
2985 elif enabled alpha; then
2986
2987     cpuflags="-mcpu=$cpu"
2988
2989 elif enabled arm; then
2990
2991     check_arm_arch() {
2992         check_cpp_condition stddef.h \
2993             "defined __ARM_ARCH_${1}__ || defined __TARGET_ARCH_${2:-$1}" \
2994             $cpuflags
2995     }
2996
2997     probe_arm_arch() {
2998         if   check_arm_arch 4;        then echo armv4;
2999         elif check_arm_arch 4T;       then echo armv4t;
3000         elif check_arm_arch 5;        then echo armv5;
3001         elif check_arm_arch 5E;       then echo armv5e;
3002         elif check_arm_arch 5T;       then echo armv5t;
3003         elif check_arm_arch 5TE;      then echo armv5te;
3004         elif check_arm_arch 5TEJ;     then echo armv5te;
3005         elif check_arm_arch 6;        then echo armv6;
3006         elif check_arm_arch 6J;       then echo armv6j;
3007         elif check_arm_arch 6K;       then echo armv6k;
3008         elif check_arm_arch 6Z;       then echo armv6z;
3009         elif check_arm_arch 6ZK;      then echo armv6zk;
3010         elif check_arm_arch 6T2;      then echo armv6t2;
3011         elif check_arm_arch 7;        then echo armv7;
3012         elif check_arm_arch 7A  7_A;  then echo armv7-a;
3013         elif check_arm_arch 7R  7_R;  then echo armv7-r;
3014         elif check_arm_arch 7M  7_M;  then echo armv7-m;
3015         elif check_arm_arch 7EM 7E_M; then echo armv7-m;
3016         elif check_arm_arch 8A  8_A;  then echo armv8-a;
3017         fi
3018     }
3019
3020     [ "$cpu" = generic ] && cpu=$(probe_arm_arch)
3021
3022     case $cpu in
3023         armv*)
3024             cpuflags="-march=$cpu"
3025             subarch=$(echo $cpu | sed 's/[^a-z0-9]//g')
3026         ;;
3027         *)
3028             cpuflags="-mcpu=$cpu"
3029             case $cpu in
3030                 cortex-a*)                               subarch=armv7a  ;;
3031                 cortex-r*)                               subarch=armv7r  ;;
3032                 cortex-m*)                 enable thumb; subarch=armv7m  ;;
3033                 arm11*)                                  subarch=armv6   ;;
3034                 arm[79]*e*|arm9[24]6*|arm96*|arm102[26]) subarch=armv5te ;;
3035                 armv4*|arm7*|arm9[24]*)                  subarch=armv4   ;;
3036                 *)                             subarch=$(probe_arm_arch) ;;
3037             esac
3038         ;;
3039     esac
3040
3041     case "$subarch" in
3042         armv5t*)    enable fast_clz                ;;
3043         armv[6-8]*) enable fast_clz fast_unaligned ;;
3044     esac
3045
3046 elif enabled avr32; then
3047
3048     case $cpu in
3049         ap7[02]0[0-2])
3050             subarch="avr32_ap"
3051             cpuflags="-mpart=$cpu"
3052         ;;
3053         ap)
3054             subarch="avr32_ap"
3055             cpuflags="-march=$cpu"
3056         ;;
3057         uc3[ab]*)
3058             subarch="avr32_uc"
3059             cpuflags="-mcpu=$cpu"
3060         ;;
3061         uc)
3062             subarch="avr32_uc"
3063             cpuflags="-march=$cpu"
3064         ;;
3065     esac
3066
3067 elif enabled bfin; then
3068
3069     cpuflags="-mcpu=$cpu"
3070
3071 elif enabled mips; then
3072
3073     cpuflags="-march=$cpu"
3074
3075 elif enabled ppc; then
3076
3077     case $(tolower $cpu) in
3078         601|ppc601|powerpc601)
3079             cpuflags="-mcpu=601"
3080             disable altivec
3081         ;;
3082         603*|ppc603*|powerpc603*)
3083             cpuflags="-mcpu=603"
3084             disable altivec
3085         ;;
3086         604*|ppc604*|powerpc604*)
3087             cpuflags="-mcpu=604"
3088             disable altivec
3089         ;;
3090         g3|75*|ppc75*|powerpc75*)
3091             cpuflags="-mcpu=750"
3092             disable altivec
3093         ;;
3094         g4|745*|ppc745*|powerpc745*)
3095             cpuflags="-mcpu=7450"
3096         ;;
3097         74*|ppc74*|powerpc74*)
3098             cpuflags="-mcpu=7400"
3099         ;;
3100         g5|970|ppc970|powerpc970)
3101             cpuflags="-mcpu=970"
3102         ;;
3103         power[3-7]*)
3104             cpuflags="-mcpu=$cpu"
3105         ;;
3106         cell)
3107             cpuflags="-mcpu=cell"
3108             enable ldbrx
3109         ;;
3110         e500mc)
3111             cpuflags="-mcpu=e500mc"
3112             disable altivec
3113         ;;
3114         e500v2)
3115             cpuflags="-mcpu=8548 -mhard-float -mfloat-gprs=double"
3116             disable altivec
3117         ;;
3118         e500)
3119             cpuflags="-mcpu=8540 -mhard-float"
3120             disable altivec
3121         ;;
3122     esac
3123
3124 elif enabled sparc; then
3125
3126     case $cpu in
3127         cypress|f93[04]|tsc701|sparcl*|supersparc|hypersparc|niagara|v[789])
3128             cpuflags="-mcpu=$cpu"
3129             disable vis
3130         ;;
3131         ultrasparc*|niagara[234])
3132             cpuflags="-mcpu=$cpu"
3133         ;;
3134     esac
3135
3136 elif enabled x86; then
3137
3138     case $cpu in
3139         i[345]86|pentium)
3140             cpuflags="-march=$cpu"
3141             disable mmx
3142         ;;
3143         # targets that do NOT support nopl and conditional mov (cmov)
3144         pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
3145             cpuflags="-march=$cpu"
3146             disable i686
3147         ;;
3148         # targets that do support nopl and conditional mov (cmov)
3149         i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64*|k8*|opteron*|athlon-fx|core2|corei7*|amdfam10|barcelona|atom|bdver*)
3150             cpuflags="-march=$cpu"
3151             enable i686
3152             enable fast_cmov
3153         ;;
3154         # targets that do support conditional mov but on which it's slow
3155         pentium4|pentium4m|prescott|nocona)
3156             cpuflags="-march=$cpu"
3157             enable i686
3158             disable fast_cmov
3159         ;;
3160     esac
3161
3162 fi
3163
3164 if [ "$cpu" != generic ]; then
3165     add_cflags  $cpuflags
3166     add_asflags $cpuflags
3167 fi
3168
3169 # compiler sanity check
3170 check_exec <<EOF
3171 int main(void){ return 0; }
3172 EOF
3173 if test "$?" != 0; then
3174     echo "$cc is unable to create an executable file."
3175     if test -z "$cross_prefix" && ! enabled cross_compile ; then
3176         echo "If $cc is a cross-compiler, use the --enable-cross-compile option."
3177         echo "Only do this if you know what cross compiling means."
3178     fi
3179     die "C compiler test failed."
3180 fi
3181
3182 add_cppflags -D_ISOC99_SOURCE
3183 check_cflags -std=c99
3184 check_cc -D_FILE_OFFSET_BITS=64 <<EOF && add_cppflags -D_FILE_OFFSET_BITS=64
3185 #include <stdlib.h>
3186 EOF
3187 check_cc -D_LARGEFILE_SOURCE <<EOF && add_cppflags -D_LARGEFILE_SOURCE
3188 #include <stdlib.h>
3189 EOF
3190
3191 add_host_cppflags -D_ISOC99_SOURCE
3192 check_host_cflags -std=c99
3193 check_host_cflags -Wall
3194 check_host_cflags -O3
3195
3196 check_64bit(){
3197     arch32=$1
3198     arch64=$2
3199     expr=$3
3200     check_code cc "" "int test[2*($expr) - 1]" &&
3201         subarch=$arch64 || subarch=$arch32
3202 }
3203
3204 case "$arch" in
3205     aarch64|alpha|ia64)
3206         spic=$shared
3207     ;;
3208     mips)
3209         check_64bit mips mips64 '_MIPS_SIM > 1'
3210         spic=$shared
3211     ;;
3212     parisc)
3213         check_64bit parisc parisc64 'sizeof(void *) > 4'
3214         spic=$shared
3215     ;;
3216     ppc)
3217         check_64bit ppc ppc64 'sizeof(void *) > 4'
3218         spic=$shared
3219     ;;
3220     sparc)
3221         check_64bit sparc sparc64 'sizeof(void *) > 4'
3222         spic=$shared
3223     ;;
3224     x86)
3225         check_64bit x86_32 x86_64 'sizeof(void *) > 4'
3226         if test "$subarch" = "x86_64"; then
3227             spic=$shared
3228         fi
3229     ;;
3230 esac
3231
3232 enable $subarch
3233 enabled spic && enable_weak pic
3234
3235 # OS specific
3236 case $target_os in
3237     aix)
3238         SHFLAGS=-shared
3239         add_cppflags '-I\$(SRC_PATH)/compat/aix'
3240         enabled shared && add_ldflags -Wl,-brtl
3241         ;;
3242     haiku)
3243         prefix_default="/boot/common"
3244         network_extralibs="-lnetwork"
3245         host_libs=
3246         ;;
3247     sunos)
3248         SHFLAGS='-shared -Wl,-h,$$(@F)'
3249         enabled x86 && SHFLAGS="-mimpure-text $SHFLAGS"
3250         network_extralibs="-lsocket -lnsl"
3251         # When using suncc to build, the Solaris linker will mark
3252         # an executable with each instruction set encountered by
3253         # the Solaris assembler.  As our libraries contain their own
3254         # guards for processor-specific code, instead suppress
3255         # generation of the HWCAPS ELF section on Solaris x86 only.
3256         enabled_all suncc x86 &&
3257             echo "hwcap_1 = OVERRIDE;" > mapfile &&
3258             add_ldflags -Wl,-M,mapfile
3259         nm_default='nm -P -g'
3260         ;;
3261     netbsd)
3262         disable symver
3263         oss_indev_extralibs="-lossaudio"
3264         oss_outdev_extralibs="-lossaudio"
3265         ;;
3266     openbsd|bitrig)
3267         disable symver
3268         SHFLAGS='-shared'
3269         SLIB_INSTALL_NAME='$(SLIBNAME).$(LIBMAJOR).$(LIBMINOR)'
3270         SLIB_INSTALL_LINKS=
3271         oss_indev_extralibs="-lossaudio"
3272         oss_outdev_extralibs="-lossaudio"
3273         ;;
3274     dragonfly)
3275         disable symver
3276         ;;
3277     freebsd)
3278         ;;
3279     bsd/os)
3280         add_extralibs -lpoll -lgnugetopt
3281         ;;
3282     darwin)
3283         gas="gas-preprocessor.pl $cc"
3284         enabled ppc && add_asflags -force_cpusubtype_ALL
3285         SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR),-current_version,$(LIBVERSION),-compatibility_version,$(LIBMAJOR)'
3286         enabled x86_32 && append SHFLAGS -Wl,-read_only_relocs,suppress
3287         add_ldflags -Wl,-dynamic,-search_paths_first
3288         SLIBSUF=".dylib"
3289         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME).$(LIBVERSION)$(SLIBSUF)'
3290         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME).$(LIBMAJOR)$(SLIBSUF)'
3291         objformat="macho"
3292         enabled x86_64 && objformat="macho64"
3293         enabled_any pic shared ||
3294             { check_cflags -mdynamic-no-pic && add_asflags -mdynamic-no-pic; }
3295         ;;
3296     mingw32*)
3297         if test $target_os = "mingw32ce"; then
3298             disable network
3299         else
3300             target_os=mingw32
3301         fi
3302         LIBTARGET=i386
3303         if enabled x86_64; then
3304             LIBTARGET="i386:x86-64"
3305         elif enabled arm; then
3306             LIBTARGET=arm-wince
3307         fi
3308         check_ldflags -Wl,--nxcompat
3309         check_ldflags -Wl,--dynamicbase
3310         shlibdir_default="$bindir_default"
3311         SLIBPREF=""
3312         SLIBSUF=".dll"
3313         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
3314         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
3315         SLIB_EXTRA_CMD=-'sed -e "s/ @[^ ]*//" $$(@:$(SLIBSUF)=.orig.def) > $$(@:$(SLIBSUF)=.def); $(DLLTOOL) -m $(LIBTARGET) -d $$(@:$(SLIBSUF)=.def) -l $(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib) -D $(SLIBNAME_WITH_MAJOR)'
3316         SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
3317         SLIB_INSTALL_LINKS=
3318         SLIB_INSTALL_EXTRA_SHLIB='$(SLIBNAME:$(SLIBSUF)=.lib)'
3319         SLIB_INSTALL_EXTRA_LIB='lib$(SLIBNAME:$(SLIBSUF)=.dll.a) $(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.def)'
3320         SHFLAGS='-shared -Wl,--output-def,$$(@:$(SLIBSUF)=.orig.def) -Wl,--out-implib,$(SUBDIR)lib$(SLIBNAME:$(SLIBSUF)=.dll.a) -Wl,--enable-runtime-pseudo-reloc -Wl,--enable-auto-image-base'
3321         objformat="win32"
3322         dlltool="${cross_prefix}dlltool"
3323         ranlib=:
3324         enable dos_paths
3325         ;;
3326     win32|win64)
3327         disable symver
3328         if enabled shared; then
3329             # Link to the import library instead of the normal static library
3330             # for shared libs.
3331             LD_LIB='%.lib'
3332             # Cannot build both shared and static libs with MSVC or icl.
3333             disable static
3334         fi
3335         shlibdir_default="$bindir_default"
3336         SLIBPREF=""
3337         SLIBSUF=".dll"
3338         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
3339         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
3340         SLIB_CREATE_DEF_CMD='$(SRC_PATH)/compat/windows/makedef $(SUBDIR)lib$(NAME).ver $(OBJS) > $$(@:$(SLIBSUF)=.def)'
3341         SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
3342         SLIB_INSTALL_LINKS=
3343         SLIB_INSTALL_EXTRA_SHLIB='$(SLIBNAME:$(SLIBSUF)=.lib)'
3344         SLIB_INSTALL_EXTRA_LIB='$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.def)'
3345         SHFLAGS='-dll -def:$$(@:$(SLIBSUF)=.def) -implib:$(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib)'
3346         objformat="win32"
3347         ranlib=:
3348         enable dos_paths
3349         ;;
3350     cygwin*)
3351         target_os=cygwin
3352         shlibdir_default="$bindir_default"
3353         SLIBPREF="cyg"
3354         SLIBSUF=".dll"
3355         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
3356         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
3357         SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
3358         SLIB_INSTALL_LINKS=
3359         SLIB_INSTALL_EXTRA_LIB='lib$(FULLNAME).dll.a'
3360         SHFLAGS='-shared -Wl,--out-implib,$(SUBDIR)lib$(FULLNAME).dll.a'
3361         objformat="win32"
3362         enable dos_paths
3363         ;;
3364     *-dos|freedos|opendos)
3365         network_extralibs="-lsocket"
3366         objformat="coff"
3367         enable dos_paths
3368         add_cppflags -U__STRICT_ANSI__
3369         ;;
3370     linux)
3371         enable dv1394
3372         ;;
3373     irix*)
3374         target_os=irix
3375         ranlib="echo ignoring ranlib"
3376         ;;
3377     os/2*)
3378         ln_s="cp -f"
3379         objformat="aout"
3380         add_cppflags -D_GNU_SOURCE
3381         add_ldflags -Zomf -Zbin-files -Zargs-wild -Zmap
3382         SHFLAGS='$(SUBDIR)$(NAME).def -Zdll -Zomf'
3383         LIBSUF="_s.a"
3384         SLIBPREF=""
3385         SLIBSUF=".dll"
3386         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
3387         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(shell echo $(NAME) | cut -c1-6)$(LIBMAJOR)$(SLIBSUF)'
3388         SLIB_CREATE_DEF_CMD='echo LIBRARY $(SLIBNAME_WITH_MAJOR) INITINSTANCE TERMINSTANCE > $(SUBDIR)$(NAME).def; \
3389             echo PROTMODE >> $(SUBDIR)$(NAME).def; \
3390             echo CODE PRELOAD MOVEABLE DISCARDABLE >> $(SUBDIR)$(NAME).def; \
3391             echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $(SUBDIR)$(NAME).def; \
3392             echo EXPORTS >> $(SUBDIR)$(NAME).def; \
3393             emxexp -o $(OBJS) >> $(SUBDIR)$(NAME).def'
3394         SLIB_EXTRA_CMD='emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(NAME).def; \
3395             emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib $(SUBDIR)$(NAME).def;'
3396         SLIB_INSTALL_EXTRA_LIB='$(LIBPREF)$(NAME)_dll.a $(LIBPREF)$(NAME)_dll.lib'
3397         enable dos_paths
3398         ;;
3399     gnu/kfreebsd)
3400         add_cppflags -D_BSD_SOURCE
3401         ;;
3402     gnu)
3403         ;;
3404     qnx)
3405         add_cppflags -D_QNX_SOURCE
3406         network_extralibs="-lsocket"
3407         ;;
3408     symbian)
3409         SLIBSUF=".dll"
3410         enable dos_paths
3411         add_cflags --include=$sysinclude/gcce/gcce.h -fvisibility=default
3412         add_cppflags -D__GCCE__ -D__SYMBIAN32__ -DSYMBIAN_OE_POSIX_SIGNALS
3413         add_ldflags -Wl,--target1-abs,--no-undefined \
3414                     -Wl,-Ttext,0x80000,-Tdata,0x1000000 -shared \
3415                     -Wl,--entry=_E32Startup -Wl,-u,_E32Startup
3416         add_extralibs -l:eexe.lib -l:usrt2_2.lib -l:dfpaeabi.dso \
3417                       -l:drtaeabi.dso -l:scppnwdl.dso -lsupc++ -lgcc \
3418                       -l:libc.dso -l:libm.dso -l:euser.dso -l:libcrt0.lib
3419         ;;
3420     osf1)
3421         add_cppflags -D_OSF_SOURCE -D_POSIX_PII -D_REENTRANT
3422         ;;
3423     minix)
3424         ;;
3425     plan9)
3426         add_cppflags -D_C99_SNPRINTF_EXTENSION  \
3427                      -D_REENTRANT_SOURCE        \
3428                      -D_RESEARCH_SOURCE         \
3429                      -DFD_SETSIZE=96            \
3430                      -DHAVE_SOCK_OPTS
3431         add_compat strtod.o strtod=avpriv_strtod
3432         network_extralibs='-lbsd'
3433         exeobjs=compat/plan9/main.o
3434         disable avserver
3435         cp_f='cp'
3436         ;;
3437     none)
3438         ;;
3439     *)
3440         die "Unknown OS '$target_os'."
3441         ;;
3442 esac
3443
3444 # determine libc flavour
3445
3446 probe_libc(){
3447     pfx=$1
3448     pfx_no_=${pfx%_}
3449     # uclibc defines __GLIBC__, so it needs to be checked before glibc.
3450     if check_${pfx}cpp_condition features.h "defined __UCLIBC__"; then
3451         eval ${pfx}libc_type=uclibc
3452         add_${pfx}cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
3453     elif check_${pfx}cpp_condition features.h "defined __GLIBC__"; then
3454         eval ${pfx}libc_type=glibc
3455         add_${pfx}cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
3456     # MinGW headers can be installed on Cygwin, so check for newlib first.
3457     elif check_${pfx}cpp_condition newlib.h "defined _NEWLIB_VERSION"; then
3458         eval ${pfx}libc_type=newlib
3459         add_${pfx}cppflags -U__STRICT_ANSI__
3460     # MinGW64 is backwards compatible with MinGW32, so check for it first.
3461     elif check_${pfx}cpp_condition _mingw.h "defined __MINGW64_VERSION_MAJOR"; then
3462         eval ${pfx}libc_type=mingw64
3463         add_${pfx}cppflags -U__STRICT_ANSI__ -D__USE_MINGW_ANSI_STDIO=1
3464         eval test \$${pfx_no_}cc_type = "gcc" &&
3465             add_${pfx}cppflags -D__printf__=__gnu_printf__
3466     elif check_${pfx}cpp_condition _mingw.h "defined __MINGW_VERSION"  ||
3467          check_${pfx}cpp_condition _mingw.h "defined __MINGW32_VERSION"; then
3468         eval ${pfx}libc_type=mingw32
3469         check_${pfx}cpp_condition _mingw.h "__MINGW32_MAJOR_VERSION > 3 || \
3470             (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" ||
3471             die "ERROR: MinGW32 runtime version must be >= 3.15."
3472         add_${pfx}cppflags -U__STRICT_ANSI__ -D__USE_MINGW_ANSI_STDIO=1
3473         eval test \$${pfx_no_}cc_type = "gcc" &&
3474             add_${pfx}cppflags -D__printf__=__gnu_printf__
3475     elif check_${pfx}cpp_condition crtversion.h "defined _VC_CRT_MAJOR_VERSION"; then
3476         eval ${pfx}libc_type=msvcrt
3477         # The MSVC 2010 headers (Win 7.0 SDK) set _WIN32_WINNT to
3478         # 0x601 by default unless something else is set by the user.
3479         # This can easily lead to us detecting functions only present
3480         # in such new versions and producing binaries requiring windows 7.0.
3481         # Therefore explicitly set the default to XP unless the user has
3482         # set something else on the command line.
3483         check_${pfx}cpp_condition stdlib.h "defined(_WIN32_WINNT)" ||
3484             add_${pfx}cppflags -D_WIN32_WINNT=0x0502
3485     elif check_${pfx}cpp_condition stddef.h "defined __KLIBC__"; then
3486         eval ${pfx}libc_type=klibc
3487     elif check_${pfx}cpp_condition sys/cdefs.h "defined __BIONIC__"; then
3488         eval ${pfx}libc_type=bionic
3489     elif check_${pfx}cpp_condition sys/brand.h "defined LABELED_BRAND_NAME"; then
3490         eval ${pfx}libc_type=solaris
3491         add_${pfx}cppflags -D__EXTENSIONS__ -D_XOPEN_SOURCE=600
3492     fi
3493 }
3494
3495 probe_libc
3496 test -n "$libc_type" && enable libc_$libc_type
3497 probe_libc host_
3498 test -n "$host_libc_type" && enable host_libc_$host_libc_type
3499
3500 case $libc_type in
3501     bionic)
3502         add_compat strtod.o strtod=avpriv_strtod
3503         ;;
3504     msvcrt)
3505         add_compat strtod.o strtod=avpriv_strtod
3506         add_compat msvcrt/snprintf.o snprintf=avpriv_snprintf   \
3507                                      _snprintf=avpriv_snprintf  \
3508                                      vsnprintf=avpriv_vsnprintf
3509         ;;
3510 esac
3511
3512 # hacks for compiler/libc/os combinations
3513
3514 if enabled_all tms470 libc_glibc; then
3515     CPPFLAGS="-I${source_path}/compat/tms470 ${CPPFLAGS}"
3516     add_cppflags -D__USER_LABEL_PREFIX__=
3517     add_cppflags -D__builtin_memset=memset
3518     add_cppflags -D__gnuc_va_list=va_list -D_VA_LIST_DEFINED
3519     add_cflags   -pds=48    # incompatible redefinition of macro
3520 fi
3521
3522 if enabled_all ccc libc_glibc; then
3523     add_ldflags -Wl,-z,now  # calls to libots crash without this
3524 fi
3525
3526 esc(){
3527     echo "$*" | sed 's/%/%25/g;s/:/%3a/g'
3528 }
3529
3530 echo "config:$arch:$subarch:$cpu:$target_os:$(esc $cc_ident):$(esc $LIBAV_CONFIGURATION)" >config.fate
3531
3532 check_cpp_condition stdlib.h "defined(__PIC__) || defined(__pic__) || defined(PIC)" && enable_weak pic
3533
3534 set_default $PATHS_LIST
3535 set_default nm
3536
3537 # we need to build at least one lib type
3538 if ! enabled_any static shared; then
3539     cat <<EOF
3540 At least one library type must be built.
3541 Specify --enable-static to build the static libraries or --enable-shared to
3542 build the shared libraries as well. To only build the shared libraries specify
3543 --disable-static in addition to --enable-shared.
3544 EOF
3545     exit 1;
3546 fi
3547
3548 die_license_disabled() {
3549     enabled $1 || { enabled $2 && die "$2 is $1 and --enable-$1 is not specified."; }
3550 }
3551
3552 die_license_disabled gpl libcdio
3553 die_license_disabled gpl libx264
3554 die_license_disabled gpl libx265
3555 die_license_disabled gpl libxavs
3556 die_license_disabled gpl libxvid
3557 die_license_disabled gpl x11grab
3558
3559 die_license_disabled nonfree libfaac
3560 die_license_disabled nonfree libfdk_aac
3561 die_license_disabled nonfree openssl
3562
3563 die_license_disabled version3 libopencore_amrnb
3564 die_license_disabled version3 libopencore_amrwb
3565 die_license_disabled version3 libvo_aacenc
3566 die_license_disabled version3 libvo_amrwbenc
3567
3568 enabled version3 && { enabled gpl && enable gplv3 || enable lgplv3; }
3569
3570 disabled optimizations || check_cflags -fomit-frame-pointer
3571
3572 enable_weak_pic() {
3573     disabled pic && return
3574     enable pic
3575     add_cppflags -DPIC
3576     case "$target_os" in
3577     mingw*|cygwin*)
3578         ;;
3579     *)
3580         add_cflags -fPIC
3581         ;;
3582     esac
3583     add_asflags  -fPIC
3584 }
3585
3586 enabled pic && enable_weak_pic
3587
3588 check_cc <<EOF || die "Symbol mangling check failed."
3589 int ff_extern;
3590 EOF
3591 sym=$($nm $TMPO | awk '/ff_extern/{ print substr($0, match($0, /[^ \t]*ff_extern/)) }')
3592 extern_prefix=${sym%%ff_extern*}
3593
3594 check_cc <<EOF && enable_weak inline_asm
3595 void foo(void) { __asm__ volatile ("" ::); }
3596 EOF
3597
3598 _restrict=
3599 for restrict_keyword in restrict __restrict__ __restrict; do
3600     check_cc <<EOF && _restrict=$restrict_keyword && break
3601 void foo(char * $restrict_keyword p);
3602 EOF
3603 done
3604
3605 check_cc <<EOF && enable pragma_deprecated
3606 void foo(void) { _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") }
3607 EOF
3608
3609 check_cc <<EOF && enable attribute_packed
3610 struct { int x; } __attribute__((packed)) x;
3611 EOF
3612
3613 check_cc <<EOF && enable attribute_may_alias
3614 union { int x; } __attribute__((may_alias)) x;
3615 EOF
3616
3617 check_cc <<EOF || die "endian test failed"
3618 unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
3619 EOF
3620 od -t x1 $TMPO | grep -q '42 *49 *47 *45' && enable bigendian
3621
3622 check_inline_asm inline_asm_labels '"1:\n"'
3623
3624 if enabled aarch64; then
3625     # internal assembler in clang 3.3 does not support this instruction
3626     enabled neon && check_insn neon 'ext   v0.8B, v0.8B, v1.8B, #1'
3627     enabled vfp  && check_insn vfp  'fmadd d0,    d0,    d1,    d2'
3628
3629     map 'enabled_any ${v}_external ${v}_inline || disable $v' $ARCH_EXT_LIST_ARM
3630
3631 elif enabled alpha; then
3632
3633     check_cflags -mieee
3634
3635 elif enabled arm; then
3636
3637     check_cpp_condition stddef.h "defined __thumb__" && enable_weak thumb
3638     enabled thumb && check_cflags -mthumb || check_cflags -marm
3639     nogas=die
3640
3641     if     check_cpp_condition stddef.h "defined __ARM_PCS_VFP"; then
3642         enable vfp_args
3643     elif ! check_cpp_condition stddef.h "defined __ARM_PCS || defined __SOFTFP__"; then
3644         case "${cross_prefix:-$cc}" in
3645             *hardfloat*)         enable vfp_args;   fpabi=vfp ;;
3646             *) check_ld <<EOF && enable vfp_args && fpabi=vfp || fpabi=soft ;;
3647 __asm__ (".eabi_attribute 28, 1");
3648 int main(void) { return 0; }
3649 EOF
3650         esac
3651         warn "Compiler does not indicate floating-point ABI, guessing $fpabi."
3652     fi
3653
3654     enabled armv5te && check_insn armv5te 'qadd r0, r0, r0'
3655     enabled armv6   && check_insn armv6   'sadd16 r0, r0, r0'
3656     enabled armv6t2 && check_insn armv6t2 'movt r0, #0'
3657     enabled neon    && check_insn neon    'vadd.i16 q0, q0, q0'
3658     enabled vfp     && check_insn vfp     'fadds s0, s0, s0'
3659     enabled vfpv3   && check_insn vfpv3   'vmov.f32 s0, #1.0'
3660
3661     [ $target_os = linux ] ||
3662         map 'enabled_any ${v}_external ${v}_inline || disable $v' \
3663             $ARCH_EXT_LIST_ARM
3664
3665     check_inline_asm asm_mod_q '"add r0, %Q0, %R0" :: "r"((long long)0)'
3666     check_inline_asm asm_mod_y '"vmul.i32 d0, d0, %y0" :: "x"(0)'
3667
3668     [ $target_os != win32 ] && enabled_all armv6t2 shared !pic && enable_weak_pic
3669
3670 elif enabled mips; then
3671
3672     check_inline_asm loongson '"dmult.g $1, $2, $3"'
3673
3674 elif enabled parisc; then
3675
3676     if enabled gcc; then
3677         case $($cc -dumpversion) in
3678             4.[3-8].*) check_cflags -fno-optimize-sibling-calls ;;
3679         esac
3680     fi
3681
3682 elif enabled ppc; then
3683
3684     enable local_aligned_8 local_aligned_16
3685
3686     check_inline_asm dcbzl     '"dcbzl 0, %0" :: "r"(0)'
3687     check_inline_asm ibm_asm   '"add 0, 0, 0"'
3688     check_inline_asm ppc4xx    '"maclhw r10, r11, r12"'
3689     check_inline_asm xform_asm '"lwzx %1, %y0" :: "Z"(*(int*)0), "r"(0)'
3690
3691     # AltiVec flags: The FSF version of GCC differs from the Apple version
3692     if enabled altivec; then
3693         nogas=warn
3694         check_cflags -maltivec -mabi=altivec &&
3695         { check_header altivec.h && inc_altivec_h="#include <altivec.h>" ; } ||
3696         check_cflags -faltivec
3697
3698         # check if our compiler supports Motorola AltiVec C API
3699         check_cc <<EOF || disable altivec
3700 $inc_altivec_h
3701 int main(void) {
3702     vector signed int v1 = (vector signed int) { 0 };
3703     vector signed int v2 = (vector signed int) { 1 };
3704     v1 = vec_add(v1, v2);
3705     return 0;
3706 }
3707 EOF
3708
3709         enabled altivec || warn "Altivec disabled, possibly missing --cpu flag"
3710     fi
3711
3712 elif enabled sparc; then
3713
3714     enabled vis && check_inline_asm vis '"pdist %f0, %f0, %f0"'
3715
3716 elif enabled x86; then
3717
3718     check_builtin rdtsc    intrin.h   "__rdtsc()"
3719     check_builtin mm_empty mmintrin.h "_mm_empty()"
3720
3721     enable local_aligned_8 local_aligned_16
3722
3723     # check whether EBP is available on x86
3724     # As 'i' is stored on the stack, this program will crash
3725     # if the base pointer is used to access it because the
3726     # base pointer is cleared in the inline assembly code.
3727     check_exec_crash <<EOF && enable ebp_available
3728 volatile int i=0;
3729 __asm__ volatile ("xorl %%ebp, %%ebp" ::: "%ebp");
3730 return i;
3731 EOF
3732
3733     # check whether EBX is available on x86
3734     check_inline_asm ebx_available '""::"b"(0)' &&
3735         check_inline_asm ebx_available '"":::"%ebx"'
3736
3737     # check whether xmm clobbers are supported
3738     check_inline_asm xmm_clobbers '"":::"%xmm0"'
3739
3740     # check whether binutils is new enough to compile SSSE3/MMXEXT
3741     enabled ssse3  && check_inline_asm ssse3_inline  '"pabsw %xmm0, %xmm0"'
3742     enabled mmxext && check_inline_asm mmxext_inline '"pmaxub %mm0, %mm1"'
3743
3744     if ! disabled_any asm mmx yasm; then
3745         if check_cmd $yasmexe --version; then
3746             enabled x86_64 && yasm_extra="-m amd64"
3747             yasm_debug="-g dwarf2"
3748         elif check_cmd nasm -v; then
3749             yasmexe=nasm
3750             yasm_debug="-g -F dwarf"
3751             enabled x86_64 && test "$objformat" = elf && objformat=elf64
3752         fi
3753
3754         YASMFLAGS="-f $objformat $yasm_extra"
3755         enabled pic               && append YASMFLAGS "-DPIC"
3756         test -n "$extern_prefix"  && append YASMFLAGS "-DPREFIX"
3757         case "$objformat" in
3758             elf*) enabled debug && append YASMFLAGS $yasm_debug ;;
3759         esac
3760
3761         check_yasm "movbe ecx, [5]" && enable yasm ||
3762             die "yasm/nasm not found or too old. Use --disable-yasm for a crippled build."
3763         check_yasm "vpmacsdd xmm0, xmm1, xmm2, xmm3" || disable xop_external
3764         check_yasm "vfmaddps ymm0, ymm1, ymm2, ymm3" || disable fma4_external
3765         check_yasm "CPU amdnop" || disable cpunop
3766     fi
3767
3768     case "$cpu" in
3769         athlon*|opteron*|k8*|pentium|pentium-mmx|prescott|nocona|atom|geode)
3770             disable fast_clz
3771         ;;
3772     esac
3773
3774 fi
3775
3776 if enabled asm; then
3777     as=${gas:=$as}
3778     check_as <<EOF && enable gnu_as || \
3779         $nogas "GNU assembler not found, install gas-preprocessor"
3780 .macro m n
3781 \n: .int 0
3782 .endm
3783 m x
3784 EOF
3785 fi
3786
3787 check_ldflags -Wl,--as-needed
3788
3789 if check_func dlopen; then
3790     ldl=
3791 elif check_func dlopen -ldl; then
3792     ldl=-ldl
3793 fi
3794
3795 if ! disabled network; then
3796     check_type "sys/types.h sys/socket.h" socklen_t
3797     check_type netdb.h "struct addrinfo"
3798     check_type netinet/in.h "struct group_source_req" -D_BSD_SOURCE
3799     check_type netinet/in.h "struct ip_mreq_source" -D_BSD_SOURCE
3800     check_type netinet/in.h "struct ipv6_mreq" -D_DARWIN_C_SOURCE
3801     check_type netinet/in.h "struct sockaddr_in6"
3802     check_type poll.h "struct pollfd"
3803     check_type "sys/types.h sys/socket.h" "struct sockaddr_storage"
3804     check_struct "sys/types.h sys/socket.h" "struct sockaddr" sa_len
3805     check_type netinet/sctp.h "struct sctp_event_subscribe"
3806     check_func getaddrinfo $network_extralibs
3807     check_func getservbyport $network_extralibs
3808     check_func inet_aton $network_extralibs
3809     # Prefer arpa/inet.h over winsock2
3810     if check_header arpa/inet.h ; then
3811         check_func closesocket
3812     elif check_header winsock2.h ; then
3813         check_func_headers winsock2.h closesocket -lws2 &&
3814             network_extralibs="-lws2" ||
3815         { check_func_headers winsock2.h closesocket -lws2_32 &&
3816             network_extralibs="-lws2_32"; } || disable winsock2_h network
3817         check_func_headers ws2tcpip.h getaddrinfo $network_extralibs
3818         check_type ws2tcpip.h socklen_t
3819         check_type ws2tcpip.h "struct addrinfo"
3820         check_type ws2tcpip.h "struct group_source_req"
3821         check_type ws2tcpip.h "struct ip_mreq_source"
3822         check_type ws2tcpip.h "struct ipv6_mreq"
3823         check_type winsock2.h "struct pollfd"
3824         check_type ws2tcpip.h "struct sockaddr_in6"
3825         check_type ws2tcpip.h "struct sockaddr_storage"
3826         check_struct winsock2.h "struct sockaddr" sa_len
3827     else
3828         disable network
3829     fi
3830 fi
3831
3832 # Solaris has nanosleep in -lrt, OpenSolaris no longer needs that
3833 check_func nanosleep || { check_func nanosleep -lrt && add_extralibs -lrt; }
3834
3835 check_func  fcntl
3836 check_func  fork
3837 check_func_headers stdlib.h getenv
3838 check_func  gethrtime
3839 check_func  getopt
3840 check_func  getrusage
3841 check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss
3842 check_func  gettimeofday
3843 check_func  isatty
3844 check_func  localtime_r
3845 check_func  ${malloc_prefix}memalign            && enable memalign
3846 check_func  mkstemp
3847 check_func  mmap
3848 check_func  mprotect
3849 check_func  ${malloc_prefix}posix_memalign      && enable posix_memalign
3850 check_func_headers malloc.h _aligned_malloc     && enable aligned_malloc
3851 check_func  setrlimit
3852 check_func  strerror_r
3853 check_func  strptime
3854 check_func  strtok_r
3855 check_func  sched_getaffinity
3856 check_builtin sync_val_compare_and_swap "" "int *ptr; int oldval, newval; __sync_val_compare_and_swap(ptr, oldval, newval)"
3857 check_builtin machine_rw_barrier mbarrier.h "__machine_rw_barrier()"
3858 check_builtin atomic_cas_ptr atomic.h "void **ptr; void *oldval, *newval; atomic_cas_ptr(ptr, oldval, newval)"
3859 check_builtin MemoryBarrier windows.h "MemoryBarrier()"
3860 check_func  sysconf
3861 check_func  sysctl
3862 check_func  usleep
3863 check_func_headers io.h setmode
3864 check_lib2 "windows.h shellapi.h" CommandLineToArgvW -lshell32
3865 check_lib2 "windows.h wincrypt.h" CryptGenRandom -ladvapi32
3866 check_lib2 "windows.h psapi.h" GetProcessMemoryInfo -lpsapi
3867 check_func_headers windows.h GetProcessAffinityMask
3868 check_func_headers windows.h GetProcessTimes
3869 check_func_headers windows.h GetSystemTimeAsFileTime
3870 check_func_headers windows.h MapViewOfFile
3871 check_func_headers windows.h SetConsoleTextAttribute
3872 check_func_headers windows.h Sleep
3873 check_func_headers windows.h VirtualAlloc
3874
3875 check_header direct.h
3876 check_header dlfcn.h
3877 check_header dxva.h
3878 check_header dxva2api.h
3879 check_header io.h
3880 check_header malloc.h
3881 check_header poll.h
3882 check_header sys/mman.h
3883 check_header sys/param.h
3884 check_header sys/resource.h
3885 check_header sys/select.h
3886 check_header sys/time.h
3887 check_header sys/un.h
3888 check_header unistd.h
3889 check_header vdpau/vdpau.h
3890 check_header vdpau/vdpau_x11.h
3891 check_header VideoDecodeAcceleration/VDADecoder.h
3892 check_header windows.h
3893 check_header X11/extensions/XvMClib.h
3894
3895 if ! disabled w32threads && ! enabled pthreads; then
3896     check_func_headers "windows.h process.h" _beginthreadex &&
3897         enable w32threads || disable w32threads
3898 fi
3899
3900 # check for some common methods of building with pthread support
3901 # do this before the optional library checks as some of them require pthreads
3902 if ! disabled pthreads && ! enabled w32threads; then
3903     enable pthreads
3904     if check_func pthread_join -pthread; then
3905         add_cflags -pthread
3906         add_extralibs -pthread
3907     elif check_func pthread_join -pthreads; then
3908         add_cflags -pthreads
3909         add_extralibs -pthreads
3910     elif check_func pthread_join -lpthreadGC2; then
3911         add_extralibs -lpthreadGC2
3912     elif check_lib pthread.h pthread_join -lpthread; then
3913         :
3914     elif ! check_func pthread_join; then
3915         disable pthreads
3916     fi
3917 fi
3918
3919 for thread in $THREADS_LIST; do
3920     if enabled $thread; then
3921         test -n "$thread_type" &&
3922             die "ERROR: Only one thread type must be selected." ||
3923             thread_type="$thread"
3924     fi
3925 done
3926
3927 disabled  zlib || check_lib   zlib.h      zlibVersion -lz   || disable  zlib
3928 disabled bzlib || check_lib2 bzlib.h BZ2_bzlibVersion -lbz2 || disable bzlib
3929
3930 check_lib math.h sin -lm && LIBM="-lm"
3931 enabled vaapi && require vaapi va/va.h vaInitialize -lva
3932
3933 atan2f_args=2
3934 ldexpf_args=2
3935 powf_args=2
3936
3937 for func in $MATH_FUNCS; do
3938     eval check_mathfunc $func \${${func}_args:-1}
3939 done
3940
3941 # these are off by default, so fail if requested and not available
3942 enabled avisynth          && { { check_header "avisynth/avisynth_c.h" && check_lib2 "windows.h" LoadLibrary; } ||
3943                                { check_header "avxsynth/avxsynth_c.h" && check_lib2 "dlfcn.h" dlopen -ldl; } ||
3944                                die "ERROR: LoadLibrary/dlopen not found, or avisynth header not found"; }
3945 enabled frei0r            && { check_header frei0r.h || die "ERROR: frei0r.h header not found"; }
3946 enabled gnutls            && require_pkg_config gnutls gnutls/gnutls.h gnutls_global_init
3947 enabled libfaac           && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
3948 enabled libfdk_aac        && require libfdk_aac fdk-aac/aacenc_lib.h aacEncOpen -lfdk-aac
3949 enabled libfreetype       && require_pkg_config freetype2 "ft2build.h FT_FREETYPE_H" FT_Init_FreeType
3950 enabled libgsm            && { for gsm_hdr in "gsm.h" "gsm/gsm.h"; do
3951                                    check_lib "${gsm_hdr}" gsm_create -lgsm && break;
3952                                done || die "ERROR: libgsm not found"; }
3953 enabled libilbc           && require libilbc ilbc.h WebRtcIlbcfix_InitDecode -lilbc
3954 enabled libmp3lame        && require "libmp3lame >= 3.98.3" lame/lame.h lame_set_VBR_quality -lmp3lame
3955 enabled libopencore_amrnb && require libopencore_amrnb opencore-amrnb/interf_dec.h Decoder_Interface_init -lopencore-amrnb
3956 enabled libopencore_amrwb && require libopencore_amrwb opencore-amrwb/dec_if.h D_IF_init -lopencore-amrwb
3957 enabled libopencv         && require_pkg_config opencv opencv/cv.h cvCreateImageHeader
3958 enabled libopenjpeg       && require libopenjpeg openjpeg.h opj_version -lopenjpeg
3959 enabled libopus           && require_pkg_config opus opus_multistream.h opus_multistream_decoder_create
3960 enabled libpulse          && require_pkg_config libpulse-simple pulse/simple.h pa_simple_new
3961 enabled librtmp           && require_pkg_config librtmp librtmp/rtmp.h RTMP_Socket
3962 enabled libschroedinger   && require_pkg_config schroedinger-1.0 schroedinger/schro.h schro_init
3963 enabled libspeex          && require libspeex speex/speex.h speex_decoder_init -lspeex
3964 enabled libtheora         && require libtheora theora/theoraenc.h th_info_init -ltheoraenc -ltheoradec -logg
3965 enabled libvo_aacenc      && require libvo_aacenc vo-aacenc/voAAC.h voGetAACEncAPI -lvo-aacenc
3966 enabled libvo_amrwbenc    && require libvo_amrwbenc vo-amrwbenc/enc_if.h E_IF_init -lvo-amrwbenc
3967 enabled libvorbis         && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
3968 enabled libvpx            && {
3969     enabled libvpx_vp8_decoder && { check_lib2 "vpx/vpx_decoder.h vpx/vp8dx.h" vpx_codec_dec_init_ver -lvpx ||
3970                                     die "ERROR: libvpx decoder version must be >=0.9.1"; }
3971     enabled libvpx_vp8_encoder && { check_lib2 "vpx/vpx_encoder.h vpx/vp8cx.h" "vpx_codec_enc_init_ver VPX_CQ" -lvpx ||
3972                                     die "ERROR: libvpx encoder version must be >=0.9.6"; }
3973     enabled libvpx_vp9_decoder && { check_lib2 "vpx/vpx_decoder.h vpx/vp8dx.h" "vpx_codec_vp9_dx" -lvpx || disable libvpx_vp9_decoder; }
3974     enabled libvpx_vp9_encoder && { check_lib2 "vpx/vpx_encoder.h vpx/vp8cx.h" "vpx_codec_vp9_cx" -lvpx || disable libvpx_vp9_encoder; } }
3975 enabled libwavpack        && require libwavpack wavpack/wavpack.h WavpackOpenFileOutput  -lwavpack
3976 enabled libwebp           && require_pkg_config libwebp webp/encode.h WebPGetEncoderVersion
3977 enabled libx264           && require libx264 x264.h x264_encoder_encode -lx264 &&
3978                              { check_cpp_condition x264.h "X264_BUILD >= 118" ||
3979                                die "ERROR: libx264 version must be >= 0.118."; }
3980 enabled libx265           && require_pkg_config x265 x265.h x265_encoder_encode &&
3981                              { check_cpp_condition x265.h "X265_BUILD >= 5" ||
3982                                die "ERROR: libx265 version must be >= 5."; }
3983 enabled libxavs           && require libxavs xavs.h xavs_encoder_encode -lxavs
3984 enabled libxvid           && require libxvid xvid.h xvid_global -lxvidcore
3985 enabled openssl           && { check_lib openssl/ssl.h SSL_library_init -lssl -lcrypto ||
3986                                check_lib openssl/ssl.h SSL_library_init -lssl32 -leay32 ||
3987                                check_lib openssl/ssl.h SSL_library_init -lssl -lcrypto -lws2_32 -lgdi32 ||
3988                                die "ERROR: openssl not found"; }
3989
3990 if enabled gnutls; then
3991     { check_lib nettle/bignum.h nettle_mpz_get_str_256 -lnettle -lhogweed -lgmp && enable nettle; } ||
3992     { check_lib gcrypt.h gcry_mpi_new -lgcrypt && enable gcrypt; }
3993 fi
3994
3995 # libdc1394 check
3996 if enabled libdc1394; then
3997     { check_lib dc1394/dc1394.h dc1394_new -ldc1394 -lraw1394 &&
3998         enable libdc1394_2; } ||
3999     { check_lib libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394 &&
4000         enable libdc1394_1; } ||
4001     die "ERROR: No version of libdc1394 found "
4002 fi
4003
4004 if check_pkg_config sdl SDL_events.h SDL_PollEvent; then
4005     check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x010201" $sdl_cflags &&
4006     check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) < 0x010300" $sdl_cflags &&
4007     enable sdl
4008 fi
4009
4010 pod2man --help     > /dev/null 2>&1 && enable pod2man   || disable pod2man
4011 texi2html -version > /dev/null 2>&1 && enable texi2html || disable texi2html
4012
4013 check_header linux/fb.h
4014 check_header linux/videodev2.h
4015 check_struct linux/videodev2.h "struct v4l2_frmivalenum" discrete
4016
4017 check_header sys/videoio.h
4018
4019 check_func_headers "windows.h vfw.h" capCreateCaptureWindow "$vfwcap_indev_extralibs"
4020 # check that WM_CAP_DRIVER_CONNECT is defined to the proper value
4021 # w32api 3.12 had it defined wrong
4022 check_cpp_condition vfw.h "WM_CAP_DRIVER_CONNECT > WM_USER" && enable vfwcap_defines
4023
4024 # check for ioctl_meteor.h, ioctl_bt848.h and alternatives
4025 { check_header dev/bktr/ioctl_meteor.h &&
4026   check_header dev/bktr/ioctl_bt848.h; } ||
4027 { check_header machine/ioctl_meteor.h &&
4028   check_header machine/ioctl_bt848.h; } ||
4029 { check_header dev/video/meteor/ioctl_meteor.h &&
4030   check_header dev/video/bktr/ioctl_bt848.h; } ||
4031 check_header dev/ic/bt8xx.h
4032
4033 check_header sndio.h
4034 check_header sys/soundcard.h
4035 check_header soundcard.h
4036
4037 enabled_any alsa_indev alsa_outdev &&
4038     check_lib2 alsa/asoundlib.h snd_pcm_htimestamp -lasound
4039
4040 enabled jack_indev && check_lib2 jack/jack.h jack_client_open -ljack &&
4041     check_func jack_port_get_latency_range -ljack
4042
4043 enabled_any sndio_indev sndio_outdev && check_lib2 sndio.h sio_open -lsndio
4044
4045 if enabled libcdio; then
4046     check_lib2 "cdio/cdda.h cdio/paranoia.h" cdio_cddap_open -lcdio_paranoia -lcdio_cdda -lcdio ||
4047     check_lib2 "cdio/paranoia/cdda.h cdio/paranoia/paranoia.h" cdio_cddap_open -lcdio_paranoia -lcdio_cdda -lcdio
4048 fi
4049
4050 check_lib X11/Xlib.h XOpenDisplay -lX11 && enable xlib
4051
4052 enabled x11grab                                           &&
4053 require Xext X11/extensions/XShm.h XShmCreateImage -lXext &&
4054 require Xfixes X11/extensions/Xfixes.h XFixesGetCursorImage -lXfixes &&
4055 { enabled xlib || die "ERROR: Xlib not found"; }
4056
4057 enabled vdpau &&
4058     check_cpp_condition vdpau/vdpau.h "defined VDP_DECODER_PROFILE_MPEG4_PART2_ASP" ||
4059     disable vdpau
4060
4061 enabled vdpau && enabled xlib &&
4062     check_func_headers "vdpau/vdpau.h vdpau/vdpau_x11.h" vdp_device_create_x11 -lvdpau &&
4063     prepend avconv_libs $($ldflags_filter "-lvdpau") &&
4064     enable vdpau_x11
4065
4066 enabled debug && add_cflags -g"$debuglevel" && add_asflags -g"$debuglevel"
4067
4068 # add some useful compiler flags if supported
4069 check_cflags -Wdeclaration-after-statement
4070 check_cflags -Wall
4071 check_cflags -Wdisabled-optimization
4072 check_cflags -Wpointer-arith
4073 check_cflags -Wredundant-decls
4074 check_cflags -Wcast-qual
4075 check_cflags -Wwrite-strings
4076 check_cflags -Wtype-limits
4077 check_cflags -Wundef
4078 check_cflags -Wmissing-prototypes
4079 check_cflags -Wstrict-prototypes
4080 enabled extra_warnings && check_cflags -Winline
4081
4082 check_disable_warning(){
4083     warning_flag=-W${1#-Wno-}
4084     test_cflags $warning_flag && add_cflags $1
4085 }
4086
4087 check_disable_warning -Wno-parentheses
4088 check_disable_warning -Wno-switch
4089 check_disable_warning -Wno-format-zero-length
4090 check_disable_warning -Wno-pointer-sign
4091
4092 # add some linker flags
4093 check_ldflags -Wl,--warn-common
4094 check_ldflags -Wl,-rpath-link=libswscale:libavfilter:libavdevice:libavformat:libavcodec:libavutil:libavresample
4095 test_ldflags -Wl,-Bsymbolic && append SHFLAGS -Wl,-Bsymbolic
4096
4097 # add some strip flags
4098 # -wN '..@*' is more selective than -x, but not available everywhere.
4099 check_stripflags -wN \'..@*\' || check_stripflags -x || strip='true'
4100
4101 enabled neon_clobber_test &&
4102     check_ldflags -Wl,--wrap,avcodec_open2              \
4103                   -Wl,--wrap,avcodec_decode_audio4      \
4104                   -Wl,--wrap,avcodec_decode_video2      \
4105                   -Wl,--wrap,avcodec_decode_subtitle2   \
4106                   -Wl,--wrap,avcodec_encode_audio2      \
4107                   -Wl,--wrap,avcodec_encode_video2      \
4108                   -Wl,--wrap,avcodec_encode_subtitle    \
4109                   -Wl,--wrap,avresample_convert ||
4110     disable neon_clobber_test
4111
4112 enabled xmm_clobber_test &&
4113     check_ldflags -Wl,--wrap,avcodec_open2              \
4114                   -Wl,--wrap,avcodec_decode_audio4      \
4115                   -Wl,--wrap,avcodec_decode_video2      \
4116                   -Wl,--wrap,avcodec_decode_subtitle2   \
4117                   -Wl,--wrap,avcodec_encode_audio2      \
4118                   -Wl,--wrap,avcodec_encode_video2      \
4119                   -Wl,--wrap,avcodec_encode_subtitle    \
4120                   -Wl,--wrap,avresample_convert         \
4121                   -Wl,--wrap,sws_scale ||
4122     disable xmm_clobber_test
4123
4124 echo "X{};" > $TMPV
4125 if test_ldflags -Wl,--version-script,$TMPV; then
4126     append SHFLAGS '-Wl,--version-script,\$(SUBDIR)lib\$(NAME).ver'
4127     check_cc <<EOF && enable symver_asm_label
4128 void ff_foo(void) __asm__ ("av_foo@VERSION");
4129 void ff_foo(void) { ${inline_asm+__asm__($quotes);} }
4130 EOF
4131     check_cc <<EOF && enable symver_gnu_asm
4132 __asm__(".symver ff_foo,av_foo@VERSION");
4133 void ff_foo(void) {}
4134 EOF
4135 fi
4136
4137 if [ -z "$optflags" ]; then
4138     if enabled small; then
4139         optflags=$cflags_size
4140     elif enabled optimizations; then
4141         optflags=$cflags_speed
4142     else
4143         optflags=$cflags_noopt
4144     fi
4145 fi
4146
4147 check_optflags(){
4148     check_cflags "$@"
4149     enabled lto && check_ldflags "$@"
4150 }
4151
4152
4153 if enabled lto; then
4154     test "$cc_type" != "$ld_type" && die "LTO requires same compiler and linker"
4155     check_cflags  -flto
4156     check_ldflags -flto $cpuflags
4157 fi
4158
4159 check_optflags $optflags
4160 check_optflags -fno-math-errno
4161 check_optflags -fno-signed-zeros
4162
4163 if enabled icc; then
4164     # Just warnings, no remarks
4165     check_cflags -w1
4166     # -wd: Disable following warnings
4167     # 144, 167, 556: -Wno-pointer-sign
4168     # 1292: attribute "foo" ignored
4169     # 1419: external declaration in primary source file
4170     # 10006: ignoring unknown option -fno-signed-zeros
4171     # 10148: ignoring unknown option -Wno-parentheses
4172     # 10156: ignoring option '-W'; no argument required
4173     check_cflags -wd144,167,556,1292,1419,10006,10148,10156
4174     # 11030: Warning unknown option --as-needed
4175     # 10156: ignoring option '-export'; no argument required
4176     check_ldflags -wd10156,11030
4177     # icc 11.0 and 11.1 work with ebp_available, but don't pass the test
4178     enable ebp_available
4179     if enabled x86_32; then
4180         icc_version=$($cc -dumpversion)
4181         test ${icc_version%%.*} -ge 11 &&
4182             check_cflags -falign-stack=maintain-16-byte ||
4183             disable aligned_stack
4184     fi
4185 elif enabled ccc; then
4186     # disable some annoying warnings
4187     add_cflags -msg_disable bitnotint
4188     add_cflags -msg_disable mixfuncvoid
4189     add_cflags -msg_disable nonstandcast
4190     add_cflags -msg_disable unsupieee
4191 elif enabled gcc; then
4192     check_optflags -fno-tree-vectorize
4193     check_cflags -Werror=implicit-function-declaration
4194     check_cflags -Werror=missing-prototypes
4195     check_cflags -Werror=return-type
4196     check_cflags -Werror=declaration-after-statement
4197     check_cflags -Werror=vla
4198     enabled extra_warnings || check_disable_warning -Wno-maybe-uninitialized
4199 elif enabled llvm_gcc; then
4200     check_cflags -mllvm -stack-alignment=16
4201 elif enabled clang; then
4202     check_cflags -mllvm -stack-alignment=16
4203     check_cflags -Qunused-arguments
4204     check_cflags -Werror=implicit-function-declaration
4205     check_cflags -Werror=missing-prototypes
4206     check_cflags -Werror=return-type
4207 elif enabled cparser; then
4208     add_cflags -Wno-missing-variable-declarations
4209     add_cflags -Wno-empty-statement
4210 elif enabled armcc; then
4211     # 2523: use of inline assembler is deprecated
4212     add_cflags -W${armcc_opt},--diag_suppress=2523
4213     add_cflags -W${armcc_opt},--diag_suppress=1207
4214     add_cflags -W${armcc_opt},--diag_suppress=1293 # assignment in condition
4215     add_cflags -W${armcc_opt},--diag_suppress=3343 # hardfp compat
4216     add_cflags -W${armcc_opt},--diag_suppress=167  # pointer sign
4217     add_cflags -W${armcc_opt},--diag_suppress=513  # pointer sign
4218 elif enabled tms470; then
4219     add_cflags -pds=824 -pds=837
4220     disable inline_asm
4221 elif enabled pathscale; then
4222     add_cflags -fstrict-overflow -OPT:wrap_around_unsafe_opt=OFF
4223 elif enabled_any msvc icl; then
4224     enabled x86_32 && disable aligned_stack
4225     enabled_all x86_32 debug && add_cflags -Oy-
4226     enabled debug && add_ldflags -debug
4227     enable pragma_deprecated
4228     if enabled icl; then
4229         # -Qansi-alias is basically -fstrict-aliasing, but does not work
4230         # (correctly) on icl 13.x.
4231         check_cpp_condition "windows.h" "__ICL < 1300 || __ICL >= 1400" &&
4232             add_cflags -Qansi-alias
4233         # icl will pass the inline asm tests but inline asm is currently
4234         # not supported (build will fail)
4235         disable inline_asm
4236     fi
4237 fi
4238
4239 case $as_type in
4240     clang)
4241         add_asflags -Qunused-arguments
4242     ;;
4243 esac
4244
4245 case $ld_type in
4246     clang)
4247         check_ldflags -Qunused-arguments
4248     ;;
4249 esac
4250
4251 case $target_os in
4252     osf1)
4253         enabled ccc && add_ldflags '-Wl,-expect_unresolved,*'
4254     ;;
4255     plan9)
4256         add_cppflags -Dmain=plan9_main
4257     ;;
4258 esac
4259
4260 enabled asm || { arch=c; disable $ARCH_LIST $ARCH_EXT_LIST; }
4261
4262 check_deps $CONFIG_LIST       \
4263            $CONFIG_EXTRA      \
4264            $HAVE_LIST         \
4265            $ALL_COMPONENTS    \
4266
4267 ! enabled_any memalign posix_memalign aligned_malloc &&
4268     enabled_any $need_memalign && enable memalign_hack
4269
4270 echo "install prefix            $prefix"
4271 echo "source path               $source_path"
4272 echo "C compiler                $cc"
4273 echo "C library                 $libc_type"
4274 if test "$host_cc" != "$cc"; then
4275     echo "host C compiler           $host_cc"
4276     echo "host C library            $host_libc_type"
4277 fi
4278 echo "ARCH                      $arch ($cpu)"
4279 if test "$build_suffix" != ""; then
4280     echo "build suffix              $build_suffix"
4281 fi
4282 if test "$extra_version" != ""; then
4283     echo "version string suffix     $extra_version"
4284 fi
4285 echo "big-endian                ${bigendian-no}"
4286 echo "runtime cpu detection     ${runtime_cpudetect-no}"
4287 if enabled x86; then
4288     echo "${yasmexe}                      ${yasm-no}"
4289     echo "MMX enabled               ${mmx-no}"
4290     echo "MMXEXT enabled            ${mmxext-no}"
4291     echo "3DNow! enabled            ${amd3dnow-no}"
4292     echo "3DNow! extended enabled   ${amd3dnowext-no}"
4293     echo "SSE enabled               ${sse-no}"
4294     echo "SSSE3 enabled             ${ssse3-no}"
4295     echo "AVX enabled               ${avx-no}"
4296     echo "XOP enabled               ${xop-no}"
4297     echo "FMA4 enabled              ${fma4-no}"
4298     echo "i686 features enabled     ${i686-no}"
4299     echo "CMOV is fast              ${fast_cmov-no}"
4300     echo "EBX available             ${ebx_available-no}"
4301     echo "EBP available             ${ebp_available-no}"
4302 fi
4303 if enabled aarch64; then
4304     echo "NEON enabled              ${neon-no}"
4305     echo "VFP enabled               ${vfp-no}"
4306 fi
4307 if enabled arm; then
4308     echo "ARMv5TE enabled           ${armv5te-no}"
4309     echo "ARMv6 enabled             ${armv6-no}"
4310     echo "ARMv6T2 enabled           ${armv6t2-no}"
4311     echo "VFP enabled               ${vfp-no}"
4312     echo "NEON enabled              ${neon-no}"
4313 fi
4314 if enabled ppc; then
4315     echo "AltiVec enabled           ${altivec-no}"
4316     echo "PPC 4xx optimizations     ${ppc4xx-no}"
4317     echo "dcbzl available           ${dcbzl-no}"
4318 fi
4319 if enabled sparc; then
4320     echo "VIS enabled               ${vis-no}"
4321 fi
4322 echo "debug symbols             ${debug-no}"
4323 echo "optimize for size         ${small-no}"
4324 echo "optimizations             ${optimizations-no}"
4325 echo "static                    ${static-no}"
4326 echo "shared                    ${shared-no}"
4327 echo "new filter support        ${avfilter-no}"
4328 echo "network support           ${network-no}"
4329 echo "threading support         ${thread_type-no}"
4330 echo "safe bitstream reader     ${safe_bitstream_reader-no}"
4331 echo "SDL support               ${sdl-no}"
4332 test -n "$random_seed" &&
4333     echo "random seed               ${random_seed}"
4334 echo
4335
4336 echo "External libraries:"
4337 print_enabled '' $EXTERNAL_LIBRARY_LIST | print_3_columns
4338 echo
4339
4340 for type in decoder encoder hwaccel parser demuxer muxer protocol filter bsf indev outdev; do
4341     echo "Enabled ${type}s:"
4342     eval list=\$$(toupper $type)_LIST
4343     print_enabled '_*' $list | print_3_columns
4344     echo
4345 done
4346
4347 license="LGPL version 2.1 or later"
4348 if enabled nonfree; then
4349     license="nonfree and unredistributable"
4350 elif enabled gplv3; then
4351     license="GPL version 3 or later"
4352 elif enabled lgplv3; then
4353     license="LGPL version 3 or later"
4354 elif enabled gpl; then
4355     license="GPL version 2 or later"
4356 fi
4357
4358 echo "License: $license"
4359
4360 echo "Creating config.mak and config.h..."
4361
4362 test -e Makefile || echo "include $source_path/Makefile" > Makefile
4363
4364 config_files="$TMPH config.mak"
4365
4366 cat > config.mak <<EOF
4367 # Automatically generated by configure - do not modify!
4368 LIBAV_CONFIGURATION=$LIBAV_CONFIGURATION
4369 prefix=$prefix
4370 LIBDIR=\$(DESTDIR)$libdir
4371 SHLIBDIR=\$(DESTDIR)$shlibdir
4372 INCDIR=\$(DESTDIR)$incdir
4373 BINDIR=\$(DESTDIR)$bindir
4374 DATADIR=\$(DESTDIR)$datadir
4375 DOCDIR=\$(DESTDIR)$docdir
4376 MANDIR=\$(DESTDIR)$mandir
4377 SRC_PATH=$source_path
4378 CC_IDENT=$cc_ident
4379 ARCH=$arch
4380 CC=$cc
4381 AS=$as
4382 LD=$ld
4383 DEPCC=$dep_cc
4384 DEPCCFLAGS=$DEPCCFLAGS \$(CPPFLAGS)
4385 DEPAS=$as
4386 DEPASFLAGS=$DEPASFLAGS \$(CPPFLAGS)
4387 YASM=$yasmexe
4388 DEPYASM=$yasmexe
4389 AR=$ar
4390 ARFLAGS=$arflags
4391 AR_O=$ar_o
4392 RANLIB=$ranlib
4393 STRIP=$strip
4394 LN_S=$ln_s
4395 CPPFLAGS=$CPPFLAGS
4396 CFLAGS=$CFLAGS
4397 ASFLAGS=$ASFLAGS
4398 AS_C=$AS_C
4399 AS_O=$AS_O
4400 CC_C=$CC_C
4401 CC_E=$CC_E
4402 CC_O=$CC_O
4403 LD_O=$LD_O
4404 LD_LIB=$LD_LIB
4405 LD_PATH=$LD_PATH
4406 DLLTOOL=$dlltool
4407 LDFLAGS=$LDFLAGS
4408 SHFLAGS=$(echo $($ldflags_filter $SHFLAGS))
4409 STRIPFLAGS=$STRIPFLAGS
4410 YASMFLAGS=$YASMFLAGS
4411 BUILDSUF=$build_suffix
4412 FULLNAME=$FULLNAME
4413 LIBPREF=$LIBPREF
4414 LIBSUF=$LIBSUF
4415 LIBNAME=$LIBNAME
4416 SLIBPREF=$SLIBPREF
4417 SLIBSUF=$SLIBSUF
4418 EXESUF=$EXESUF
4419 EXTRA_VERSION=$extra_version
4420 CCDEP=$CCDEP
4421 CCDEP_FLAGS=$CCDEP_FLAGS
4422 ASDEP=$ASDEP
4423 ASDEP_FLAGS=$ASDEP_FLAGS
4424 CC_DEPFLAGS=$CC_DEPFLAGS
4425 AS_DEPFLAGS=$AS_DEPFLAGS
4426 HOSTCC=$host_cc
4427 HOSTLD=$host_ld
4428 HOSTCFLAGS=$host_cflags
4429 HOSTCPPFLAGS=$host_cppflags
4430 HOSTEXESUF=$HOSTEXESUF
4431 HOSTLDFLAGS=$host_ldflags
4432 HOSTLIBS=$host_libs
4433 DEPHOSTCC=$host_cc
4434 DEPHOSTCCFLAGS=$DEPHOSTCCFLAGS \$(HOSTCCFLAGS)
4435 HOSTCCDEP=$HOSTCCDEP
4436 HOSTCCDEP_FLAGS=$HOSTCCDEP_FLAGS
4437 HOSTCC_DEPFLAGS=$HOSTCC_DEPFLAGS
4438 HOSTCC_C=$HOSTCC_C
4439 HOSTCC_O=$HOSTCC_O
4440 HOSTLD_O=$HOSTLD_O
4441 TARGET_EXEC=$target_exec $target_exec_args
4442 TARGET_PATH=$target_path
4443 TARGET_SAMPLES=${target_samples:-\$(SAMPLES)}
4444 CFLAGS-avplay=$sdl_cflags
4445 ZLIB=$($ldflags_filter -lz)
4446 LIB_INSTALL_EXTRA_CMD=$LIB_INSTALL_EXTRA_CMD
4447 EXTRALIBS=$extralibs
4448 COMPAT_OBJS=$compat_objs
4449 EXEOBJS=$exeobjs
4450 INSTALL=install
4451 LIBTARGET=${LIBTARGET}
4452 SLIBNAME=${SLIBNAME}
4453 SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}
4454 SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}
4455 SLIB_CREATE_DEF_CMD=${SLIB_CREATE_DEF_CMD}
4456 SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}
4457 SLIB_INSTALL_NAME=${SLIB_INSTALL_NAME}
4458 SLIB_INSTALL_LINKS=${SLIB_INSTALL_LINKS}
4459 SLIB_INSTALL_EXTRA_LIB=${SLIB_INSTALL_EXTRA_LIB}
4460 SLIB_INSTALL_EXTRA_SHLIB=${SLIB_INSTALL_EXTRA_SHLIB}
4461 SAMPLES:=${samples:-\$(LIBAV_SAMPLES)}
4462 EOF
4463
4464 get_version(){
4465     lcname=lib${1}
4466     name=$(toupper $lcname)
4467     file=$source_path/$lcname/version.h
4468     eval $(awk "/#define ${name}_VERSION_M/ { print \$2 \"=\" \$3 }" "$file")
4469     eval ${name}_VERSION=\$${name}_VERSION_MAJOR.\$${name}_VERSION_MINOR.\$${name}_VERSION_MICRO
4470     eval echo "${lcname}_VERSION=\$${name}_VERSION" >> config.mak
4471     eval echo "${lcname}_VERSION_MAJOR=\$${name}_VERSION_MAJOR" >> config.mak
4472     eval echo "${lcname}_VERSION_MINOR=\$${name}_VERSION_MINOR" >> config.mak
4473 }
4474
4475 map 'get_version $v' $LIBRARY_LIST
4476
4477 print_program_libs(){
4478     eval "program_libs=\$${1}_libs"
4479     eval echo "LIBS-${1}=${program_libs}" >> config.mak
4480 }
4481
4482 map 'print_program_libs $v' $PROGRAM_LIST
4483
4484 cat > $TMPH <<EOF
4485 /* Automatically generated by configure - do not modify! */
4486 #ifndef LIBAV_CONFIG_H
4487 #define LIBAV_CONFIG_H
4488 #define LIBAV_CONFIGURATION "$(c_escape $LIBAV_CONFIGURATION)"
4489 #define LIBAV_LICENSE "$(c_escape $license)"
4490 #define AVCONV_DATADIR "$(eval c_escape $datadir)"
4491 #define CC_IDENT "$(c_escape ${cc_ident:-Unknown compiler})"
4492 #define restrict $_restrict
4493 #define EXTERN_PREFIX "${extern_prefix}"
4494 #define EXTERN_ASM ${extern_prefix}
4495 #define SLIBSUF "$SLIBSUF"
4496 EOF
4497
4498 test -n "$malloc_prefix" &&
4499     echo "#define MALLOC_PREFIX $malloc_prefix" >>$TMPH
4500
4501 if enabled yasm; then
4502     append config_files $TMPASM
4503     printf '' >$TMPASM
4504 fi
4505
4506 enabled getenv || echo "#define getenv(x) NULL" >> $TMPH
4507
4508 print_config ARCH_   "$config_files" $ARCH_LIST
4509 print_config HAVE_   "$config_files" $HAVE_LIST
4510 print_config CONFIG_ "$config_files" $CONFIG_LIST       \
4511                                      $CONFIG_EXTRA      \
4512                                      $ALL_COMPONENTS    \
4513
4514 echo "#endif /* LIBAV_CONFIG_H */" >> $TMPH
4515
4516 # Do not overwrite an unchanged config.h to avoid superfluous rebuilds.
4517 cp_if_changed $TMPH config.h
4518 touch .config
4519
4520 enabled yasm && cp_if_changed $TMPASM config.asm
4521
4522 cat > $TMPH <<EOF
4523 /* Generated by ffconf */
4524 #ifndef AVUTIL_AVCONFIG_H
4525 #define AVUTIL_AVCONFIG_H
4526 EOF
4527
4528 print_config AV_HAVE_ $TMPH $HAVE_LIST_PUB
4529
4530 echo "#endif /* AVUTIL_AVCONFIG_H */" >> $TMPH
4531
4532 cp_if_changed $TMPH libavutil/avconfig.h
4533
4534 test -n "$WARNINGS" && printf "\n$WARNINGS"
4535
4536 # build pkg-config files
4537
4538 pkgconfig_generate(){
4539     name=$1
4540     shortname=${name#lib}${build_suffix}
4541     comment=$2
4542     version=$3
4543     libs=$4
4544     requires=$5
4545     enabled ${name#lib} || return 0
4546     mkdir -p $name
4547     cat <<EOF > $name/$name.pc
4548 prefix=$prefix
4549 exec_prefix=\${prefix}
4550 libdir=$libdir
4551 includedir=$incdir
4552
4553 Name: $name
4554 Description: $comment
4555 Version: $version
4556 Requires: $(enabled shared || echo $requires)
4557 Requires.private: $(enabled shared && echo $requires)
4558 Conflicts:
4559 Libs: -L\${libdir} -l${shortname} $(enabled shared || echo $libs)
4560 Libs.private: $(enabled shared && echo $libs)
4561 Cflags: -I\${includedir}
4562 EOF
4563     cat <<EOF > $name/$name-uninstalled.pc
4564 prefix=
4565 exec_prefix=
4566 libdir=\${pcfiledir}
4567 includedir=${source_path}
4568
4569 Name: $name
4570 Description: $comment
4571 Version: $version
4572 Requires: $requires
4573 Conflicts:
4574 Libs: \${libdir}/${LIBPREF}${shortname}${LIBSUF} $libs
4575 Cflags: -I\${includedir}
4576 EOF
4577 }
4578
4579 lavfi_libs="libavutil = $LIBAVUTIL_VERSION"
4580 enabled movie_filter    && prepend lavfi_libs "libavformat >= $LIBAVFORMAT_VERSION, libavcodec >= $LIBAVCODEC_VERSION,"
4581 enabled resample_filter && prepend lavfi_libs "libavresample >= $LIBAVRESAMPLE_VERSION,"
4582 enabled scale_filter    && prepend lavfi_libs "libswscale >= $LIBSWSCALE_VERSION,"
4583
4584 pkgconfig_generate libavutil     "Libav utility library"          "$LIBAVUTIL_VERSION"     "$LIBM"
4585 pkgconfig_generate libavcodec    "Libav codec library"            "$LIBAVCODEC_VERSION"    "$extralibs" "libavutil = $LIBAVUTIL_VERSION"
4586 pkgconfig_generate libavformat   "Libav container format library" "$LIBAVFORMAT_VERSION"   "$extralibs" "libavcodec = $LIBAVCODEC_VERSION"
4587 pkgconfig_generate libavdevice   "Libav device handling library"  "$LIBAVDEVICE_VERSION"   "$extralibs" "libavformat = $LIBAVFORMAT_VERSION"
4588 pkgconfig_generate libavfilter   "Libav video filtering library"  "$LIBAVFILTER_VERSION"   "$extralibs" "$lavfi_libs"
4589 pkgconfig_generate libavresample "Libav audio resampling library" "$LIBAVRESAMPLE_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION"
4590 pkgconfig_generate libswscale    "Libav image rescaling library"  "$LIBSWSCALE_VERSION"    "$LIBM"      "libavutil = $LIBAVUTIL_VERSION"