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