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