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