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