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