b900682d0e15256ea6d0ec16ab44ab12c1e9dd5e
[ffmpeg.git] / configure
1 #!/bin/sh
2 #
3 # Libav configure script
4 #
5 # Copyright (c) 2000-2002 Fabrice Bellard
6 # Copyright (c) 2005-2008 Diego Biurrun
7 # Copyright (c) 2005-2008 Mans Rullgard
8 #
9
10 # Prevent locale nonsense from breaking basic text processing.
11 LC_ALL=C
12 export LC_ALL
13
14 # make sure we are running under a compatible shell
15 # try to make this part work with most shells
16
17 try_exec(){
18     echo "Trying shell $1"
19     type "$1" > /dev/null 2>&1 && exec "$@"
20 }
21
22 unset foo
23 (: ${foo%%bar}) 2> /dev/null
24 E1="$?"
25
26 (: ${foo?}) 2> /dev/null
27 E2="$?"
28
29 if test "$E1" != 0 || test "$E2" = 0; then
30     echo "Broken shell detected.  Trying alternatives."
31     export FF_CONF_EXEC
32     if test "0$FF_CONF_EXEC" -lt 1; then
33         FF_CONF_EXEC=1
34         try_exec bash "$0" "$@"
35     fi
36     if test "0$FF_CONF_EXEC" -lt 2; then
37         FF_CONF_EXEC=2
38         try_exec ksh "$0" "$@"
39     fi
40     if test "0$FF_CONF_EXEC" -lt 3; then
41         FF_CONF_EXEC=3
42         try_exec /usr/xpg4/bin/sh "$0" "$@"
43     fi
44     echo "No compatible shell script interpreter found."
45     echo "This configure script requires a POSIX-compatible shell"
46     echo "such as bash or ksh."
47     echo "THIS IS NOT A BUG IN LIBAV, DO NOT REPORT IT AS SUCH."
48     echo "Instead, install a working POSIX-compatible shell."
49     echo "Disabling this configure test will create a broken Libav."
50     if test "$BASH_VERSION" = '2.04.0(1)-release'; then
51         echo "This bash version ($BASH_VERSION) is broken on your platform."
52         echo "Upgrade to a later version if available."
53     fi
54     exit 1
55 fi
56
57 test -d /usr/xpg4/bin && PATH=/usr/xpg4/bin:$PATH
58
59 show_help(){
60     cat <<EOF
61 Usage: configure [options]
62 Options: [defaults in brackets after descriptions]
63
64 Help options:
65   --help                   print this message
66   --quiet                  Suppress showing informative output
67   --list-decoders          show all available decoders
68   --list-encoders          show all available encoders
69   --list-hwaccels          show all available hardware accelerators
70   --list-demuxers          show all available demuxers
71   --list-muxers            show all available muxers
72   --list-parsers           show all available parsers
73   --list-protocols         show all available protocols
74   --list-bsfs              show all available bitstream filters
75   --list-indevs            show all available input devices
76   --list-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_inline_asm(){
807     log check_inline_asm "$@"
808     name="$1"
809     code="$2"
810     shift 2
811     disable $name
812     test_cc "$@" <<EOF && enable $name
813 void foo(void){ __asm__ volatile($code); }
814 EOF
815 }
816
817 check_insn(){
818     log check_insn "$@"
819     check_inline_asm ${1}_inline "$2"
820     echo "$2" | test_as && enable ${1}_external || disable ${1}_external
821 }
822
823 test_x86asm(){
824     log test_x86asm "$@"
825     echo "$1" > $TMPS
826     log_file $TMPS
827     shift 1
828     test_cmd $x86asmexe $X86ASMFLAGS "$@" -o $TMPO $TMPS
829 }
830
831 ld_o(){
832     eval printf '%s\\n' $LD_O
833 }
834
835 test_ld(){
836     log test_ld "$@"
837     flags=$(filter_out '-l*' "$@")
838     libs=$(filter '-l*' "$@")
839     test_cc $($cflags_filter $flags) || return
840     flags=$($ldflags_filter $flags)
841     libs=$($ldflags_filter $libs)
842     test_cmd $ld $LDFLAGS $flags $(ld_o $TMPE) $TMPO $libs $extralibs
843 }
844
845 print_include(){
846     hdr=$1
847     test "${hdr%.h}" = "${hdr}" &&
848         echo "#include $hdr"    ||
849         echo "#include <$hdr>"
850 }
851
852 test_code(){
853     log test_code "$@"
854     check=$1
855     headers=$2
856     code=$3
857     shift 3
858     {
859         for hdr in $headers; do
860             print_include $hdr
861         done
862         echo "int main(void) { $code; return 0; }"
863     } | test_$check "$@"
864 }
865
866 check_cppflags(){
867     log check_cppflags "$@"
868     test_cpp "$@" <<EOF && add_cppflags "$@"
869 #include <stdlib.h>;
870 EOF
871 }
872
873 test_cflags(){
874     log test_cflags "$@"
875     set -- $($cflags_filter "$@")
876     test_cc "$@" <<EOF
877 int x;
878 EOF
879 }
880
881 check_cflags(){
882     log check_cflags "$@"
883     test_cflags "$@" && add_cflags "$@"
884 }
885
886 test_objcflags(){
887     log test_objcflags "$@"
888     set -- $($objcflags_filter "$@")
889     test_objcc "$@" <<EOF
890 int x;
891 EOF
892 }
893
894 check_objcflags(){
895     log check_objcflags "$@"
896     test_objcflags "$@" && add_objcflags "$@"
897 }
898
899 test_ldflags(){
900     log test_ldflags "$@"
901     set -- $($ldflags_filter "$@")
902     test_ld "$@" <<EOF
903 int main(void){ return 0; }
904 EOF
905 }
906
907 check_ldflags(){
908     log check_ldflags "$@"
909     test_ldflags "$@" && add_ldflags "$@"
910 }
911
912 test_stripflags(){
913     log test_stripflags "$@"
914     # call test_cc to get a fresh TMPO
915     test_cc <<EOF
916 int main(void) { return 0; }
917 EOF
918     test_cmd $strip $STRIPFLAGS "$@" $TMPO
919 }
920
921 check_stripflags(){
922     log check_stripflags "$@"
923     test_stripflags "$@" && add_stripflags "$@"
924 }
925
926 check_header(){
927     log check_header "$@"
928     headers=$1
929     shift
930     disable_sanitized $headers
931     {
932         for hdr in $headers; do
933             print_include $hdr
934         done
935         echo "int x;"
936     } | test_cpp "$@" && enable_sanitized $headers
937 }
938
939 check_func(){
940     log check_func "$@"
941     func=$1
942     shift
943     disable $func
944     test_ld "$@" <<EOF && enable $func
945 extern int $func();
946 int main(void){ $func(); }
947 EOF
948 }
949
950 check_mathfunc(){
951     log check_mathfunc "$@"
952     func=$1
953     narg=$2
954     shift 2
955     test $narg = 2 && args="f, g" || args="f"
956     disable $func
957     test_ld "$@" <<EOF && enable $func
958 #include <math.h>
959 float foo(float f, float g) { return $func($args); }
960 int main(void){ return 0; }
961 EOF
962 }
963
964 check_func_headers(){
965     log check_func_headers "$@"
966     headers=$1
967     funcs=$2
968     shift 2
969     {
970         for hdr in $headers; do
971             print_include $hdr
972         done
973         for func in $funcs; do
974             echo "long check_$func(void) { return (long) $func; }"
975         done
976         echo "int main(void) { return 0; }"
977     } | test_ld "$@" && enable $funcs && enable_sanitized $headers
978 }
979
980 test_cpp_condition(){
981     log test_cpp_condition "$@"
982     header=$1
983     condition=$2
984     shift 2
985     test_cpp "$@" <<EOF
986 #include <$header>
987 #if !($condition)
988 #error "unsatisfied condition: $condition"
989 #endif
990 EOF
991 }
992
993 test_cflags_cpp(){
994     log test_cflags_cpp "$@"
995     flags=$1
996     condition=$2
997     shift 2
998     set -- $($cflags_filter "$flags")
999     test_cpp "$@" <<EOF
1000 #if !($condition)
1001 #error "unsatisfied condition: $condition"
1002 #endif
1003 EOF
1004 }
1005
1006 check_lib(){
1007     log check_lib "$@"
1008     name="$1"
1009     headers="$2"
1010     funcs="$3"
1011     shift 3
1012     disable $name
1013     check_func_headers "$headers" "$funcs" "$@" &&
1014         enable $name && eval ${name}_extralibs="\$@"
1015 }
1016
1017 test_pkg_config(){
1018     log test_pkg_config "$@"
1019     name="$1"
1020     pkg_version="$2"
1021     pkg="${2%% *}"
1022     headers="$3"
1023     funcs="$4"
1024     shift 4
1025     disable $name
1026     test_cmd $pkg_config --exists --print-errors $pkg_version || return
1027     pkg_cflags=$($pkg_config --cflags $pkg_config_flags $pkg)
1028     pkg_libs=$($pkg_config --libs $pkg_config_flags $pkg)
1029     check_func_headers "$headers" "$funcs" $pkg_cflags $pkg_libs "$@" &&
1030         enable $name &&
1031         set_sanitized "${name}_cflags"    $pkg_cflags &&
1032         set_sanitized "${name}_extralibs" $pkg_libs
1033 }
1034
1035 check_pkg_config(){
1036     log check_pkg_config "$@"
1037     name="$1"
1038     test_pkg_config "$@" &&
1039         eval add_cflags \$${name}_cflags
1040 }
1041
1042 test_exec(){
1043     log test_exec "$@"
1044     test_ld "$@" && { enabled cross_compile || $TMPE >> $logfile 2>&1; }
1045 }
1046
1047 check_exec_crash(){
1048     log check_exec_crash "$@"
1049     code=$(cat)
1050
1051     # exit() is not async signal safe.  _Exit (C99) and _exit (POSIX)
1052     # are safe but may not be available everywhere.  Thus we use
1053     # raise(SIGTERM) instead.  The check is run in a subshell so we
1054     # can redirect the "Terminated" message from the shell.  SIGBUS
1055     # is not defined by standard C so it is used conditionally.
1056
1057     (test_exec "$@") >> $logfile 2>&1 <<EOF
1058 #include <signal.h>
1059 static void sighandler(int sig){
1060     raise(SIGTERM);
1061 }
1062 int foo(void){
1063     $code
1064 }
1065 int (*func_ptr)(void) = foo;
1066 int main(void){
1067     signal(SIGILL, sighandler);
1068     signal(SIGFPE, sighandler);
1069     signal(SIGSEGV, sighandler);
1070 #ifdef SIGBUS
1071     signal(SIGBUS, sighandler);
1072 #endif
1073     return func_ptr();
1074 }
1075 EOF
1076 }
1077
1078 check_type(){
1079     log check_type "$@"
1080     headers=$1
1081     type=$2
1082     shift 2
1083     disable_sanitized "$type"
1084     test_code cc "$headers" "$type v" "$@" && enable_sanitized "$type"
1085 }
1086
1087 check_struct(){
1088     log check_struct "$@"
1089     headers=$1
1090     struct=$2
1091     member=$3
1092     shift 3
1093     disable_sanitized "${struct}_${member}"
1094     test_code cc "$headers" "const void *p = &(($struct *)0)->$member" "$@" &&
1095         enable_sanitized "${struct}_${member}"
1096 }
1097
1098 check_builtin(){
1099     log check_builtin "$@"
1100     name=$1
1101     shift
1102     disable "$name"
1103     test_code ld "$@" && enable "$name"
1104 }
1105
1106 check_compile_assert(){
1107     log check_compile_assert "$@"
1108     name=$1
1109     headers=$2
1110     condition=$3
1111     shift 3
1112     disable "$name"
1113     test_code cc "$headers" "char c[2 * !!($condition) - 1]" "$@" && enable "$name"
1114 }
1115
1116 require(){
1117     log require "$@"
1118     name_version="$1"
1119     name="${1%% *}"
1120     shift
1121     check_lib $name "$@" || die "ERROR: $name_version not found"
1122 }
1123
1124 require_header(){
1125     log require_header "$@"
1126     headers="$1"
1127     check_header "$@" || die "ERROR: $headers not found"
1128 }
1129
1130 require_cpp_condition(){
1131     log require_cpp_condition "$@"
1132     condition="$2"
1133     test_cpp_condition "$@" || die "ERROR: $condition not satisfied"
1134 }
1135
1136 require_pkg_config(){
1137     log require_pkg_config "$@"
1138     pkg_version="$2"
1139     check_pkg_config "$@" || die "ERROR: $pkg_version not found"
1140 }
1141
1142 hostcc_e(){
1143     eval printf '%s\\n' $HOSTCC_E
1144 }
1145
1146 hostcc_o(){
1147     eval printf '%s\\n' $HOSTCC_O
1148 }
1149
1150 test_host_cc(){
1151     log test_host_cc "$@"
1152     cat > $TMPC
1153     log_file $TMPC
1154     test_cmd $host_cc $host_cflags "$@" $HOSTCC_C $(hostcc_o $TMPO) $TMPC
1155 }
1156
1157 test_host_cpp(){
1158     log test_host_cpp "$@"
1159     cat > $TMPC
1160     log_file $TMPC
1161     test_cmd $host_cc $host_cppflags $host_cflags "$@" $(hostcc_e $TMPO) $TMPC
1162 }
1163
1164 check_host_cppflags(){
1165     log check_host_cppflags "$@"
1166     test_host_cpp "$@" <<EOF && append host_cppflags "$@"
1167 #include <stdlib.h>;
1168 EOF
1169 }
1170
1171 check_host_cflags(){
1172     log check_host_cflags "$@"
1173     set -- $($host_cflags_filter "$@")
1174     test_host_cc "$@" <<EOF && append host_cflags "$@"
1175 int x;
1176 EOF
1177 }
1178
1179 test_host_cpp_condition(){
1180     log test_host_cpp_condition "$@"
1181     header=$1
1182     condition=$2
1183     shift 2
1184     test_host_cpp "$@" <<EOF
1185 #include <$header>
1186 #if !($condition)
1187 #error "unsatisfied condition: $condition"
1188 #endif
1189 EOF
1190 }
1191
1192 cp_if_changed(){
1193     cmp -s "$1" "$2" && { test "$quiet" != "yes" && echo "$2 is unchanged"; } && return
1194     mkdir -p "$(dirname $2)"
1195     cp -f "$1" "$2"
1196 }
1197
1198 # CONFIG_LIST contains configurable options, while HAVE_LIST is for
1199 # system-dependent things.
1200
1201 AVCODEC_COMPONENTS="
1202     bsfs
1203     decoders
1204     encoders
1205     hwaccels
1206     parsers
1207 "
1208
1209 AVDEVICE_COMPONENTS="
1210     indevs
1211 "
1212 AVFILTER_COMPONENTS="
1213     filters
1214 "
1215 AVFORMAT_COMPONENTS="
1216     demuxers
1217     muxers
1218     protocols
1219 "
1220
1221 COMPONENT_LIST="
1222     $AVCODEC_COMPONENTS
1223     $AVDEVICE_COMPONENTS
1224     $AVFILTER_COMPONENTS
1225     $AVFORMAT_COMPONENTS
1226 "
1227
1228 EXAMPLE_LIST="
1229     decode_audio_example
1230     decode_video_example
1231     encode_audio_example
1232     encode_video_example
1233     filter_audio_example
1234     metadata_example
1235     output_example
1236     qsvdec_example
1237     transcode_aac_example
1238 "
1239
1240 # catchall list of things that require external libs to link
1241 EXTRALIBS_LIST="
1242     cpu_init
1243     cws2fws
1244 "
1245
1246 HWACCEL_LIBRARY_NONFREE_LIST="
1247     cuda
1248     cuvid
1249     libnpp
1250 "
1251 HWACCEL_LIBRARY_LIST="
1252     $HWACCEL_LIBRARY_NONFREE_LIST
1253     amf
1254     d3d11va
1255     dxva2
1256     libmfx
1257     mmal
1258     nvenc
1259     omx
1260     vaapi
1261     vda
1262     vdpau
1263 "
1264
1265 EXTERNAL_LIBRARY_GPL_LIST="
1266     libcdio
1267     libx264
1268     libx265
1269     libxavs
1270     libxvid
1271 "
1272
1273 EXTERNAL_LIBRARY_NONFREE_LIST="
1274     libfaac
1275     libfdk_aac
1276     openssl
1277 "
1278
1279 EXTERNAL_LIBRARY_VERSION3_LIST="
1280     libopencore_amrnb
1281     libopencore_amrwb
1282     libvo_aacenc
1283     libvo_amrwbenc
1284 "
1285
1286 EXTERNAL_LIBRARY_LIST="
1287     $EXTERNAL_LIBRARY_GPL_LIST
1288     $EXTERNAL_LIBRARY_NONFREE_LIST
1289     $EXTERNAL_LIBRARY_VERSION3_LIST
1290     avisynth
1291     avxsynth
1292     frei0r
1293     gnutls
1294     libbs2b
1295     libdc1394
1296     libdcadec
1297     libfontconfig
1298     libfreetype
1299     libgsm
1300     libhdcd
1301     libilbc
1302     libjack
1303     libkvazaar
1304     libmp3lame
1305     libopencv
1306     libopenh264
1307     libopenjpeg
1308     libopus
1309     libpulse
1310     librtmp
1311     libschroedinger
1312     libsnappy
1313     libspeex
1314     libtheora
1315     libtwolame
1316     libvorbis
1317     libvpx
1318     libwavpack
1319     libwebp
1320     libxcb
1321     libxcb_shm
1322     libxcb_xfixes
1323 "
1324
1325 SYSTEM_LIBRARY_LIST="
1326     bzlib
1327     zlib
1328 "
1329
1330 FEATURE_LIST="
1331     gray
1332     hardcoded_tables
1333     omx_rpi
1334     runtime_cpudetect
1335     safe_bitstream_reader
1336     shared
1337     small
1338     sram
1339     static
1340     swscale_alpha
1341 "
1342
1343 LIBRARY_LIST="
1344     avcodec
1345     avdevice
1346     avfilter
1347     avformat
1348     avresample
1349     avutil
1350     swscale
1351 "
1352
1353 LICENSE_LIST="
1354     gpl
1355     nonfree
1356     version3
1357 "
1358
1359 PROGRAM_LIST="
1360     avconv
1361     avplay
1362     avprobe
1363 "
1364
1365 SUBSYSTEM_LIST="
1366     dct
1367     doc
1368     error_resilience
1369     faan
1370     fft
1371     lsp
1372     lzo
1373     mdct
1374     network
1375     rdft
1376 "
1377
1378 # COMPONENT_LIST needs to come last to ensure correct dependency checking
1379 CONFIG_LIST="
1380     $EXAMPLE_LIST
1381     $EXTERNAL_LIBRARY_LIST
1382     $HWACCEL_LIBRARY_LIST
1383     $FEATURE_LIST
1384     $LICENSE_LIST
1385     $LIBRARY_LIST
1386     $PROGRAM_LIST
1387     $SUBSYSTEM_LIST
1388     $SYSTEM_LIBRARY_LIST
1389     neon_clobber_test
1390     pic
1391     pod2man
1392     texi2html
1393     thumb
1394     valgrind_backtrace
1395     xmm_clobber_test
1396     $COMPONENT_LIST
1397 "
1398
1399 THREADS_LIST="
1400     pthreads
1401     w32threads
1402 "
1403
1404 ATOMICS_LIST="
1405     atomics_gcc
1406     atomics_suncc
1407     atomics_win32
1408 "
1409
1410 ARCH_LIST="
1411     aarch64
1412     alpha
1413     arm
1414     avr32
1415     avr32_ap
1416     avr32_uc
1417     bfin
1418     ia64
1419     m68k
1420     mips
1421     mips64
1422     parisc
1423     ppc
1424     ppc64
1425     s390
1426     sh4
1427     sparc
1428     sparc64
1429     tilegx
1430     tilepro
1431     tomi
1432     x86
1433     x86_32
1434     x86_64
1435 "
1436
1437 ARCH_EXT_LIST_ARM="
1438     armv5te
1439     armv6
1440     armv6t2
1441     armv8
1442     neon
1443     vfp
1444     vfpv3
1445 "
1446
1447 ARCH_EXT_LIST_X86_SIMD="
1448     amd3dnow
1449     amd3dnowext
1450     avx
1451     avx2
1452     fma3
1453     fma4
1454     mmx
1455     mmxext
1456     sse
1457     sse2
1458     sse3
1459     sse4
1460     sse42
1461     ssse3
1462     xop
1463 "
1464
1465 ARCH_EXT_LIST_PPC="
1466     altivec
1467     dcbzl
1468     ldbrx
1469     power8
1470     ppc4xx
1471     vsx
1472 "
1473
1474 ARCH_EXT_LIST_X86="
1475     $ARCH_EXT_LIST_X86_SIMD
1476     cpunop
1477     i686
1478 "
1479
1480 ARCH_EXT_LIST_MIPS="
1481     loongson
1482     mips32r1
1483     mips64r1
1484     mips32r2
1485     mips64r2
1486     mips32r6
1487     mips64r6
1488 "
1489
1490 ARCH_EXT_LIST="
1491     $ARCH_EXT_LIST_ARM
1492     $ARCH_EXT_LIST_MIPS
1493     $ARCH_EXT_LIST_PPC
1494     $ARCH_EXT_LIST_X86
1495     vis
1496 "
1497
1498 ARCH_FEATURES="
1499     aligned_stack
1500     fast_64bit
1501     fast_clz
1502     fast_cmov
1503     local_aligned_8
1504     local_aligned_16
1505     local_aligned_32
1506     simd_align_16
1507     simd_align_32
1508 "
1509
1510 BUILTIN_LIST="
1511     atomic_cas_ptr
1512     machine_rw_barrier
1513     MemoryBarrier
1514     mm_empty
1515     rdtsc
1516     sem_timedwait
1517     sync_val_compare_and_swap
1518 "
1519 HAVE_LIST_CMDLINE="
1520     inline_asm
1521     symver
1522     x86asm
1523 "
1524
1525 HAVE_LIST_PUB="
1526     bigendian
1527     fast_unaligned
1528 "
1529
1530 HEADERS_LIST="
1531     AVFoundation_AVFoundation_h
1532     arpa_inet_h
1533     cdio_paranoia_h
1534     cdio_paranoia_paranoia_h
1535     dispatch_dispatch_h
1536     dev_bktr_ioctl_bt848_h
1537     dev_bktr_ioctl_meteor_h
1538     dev_ic_bt8xx_h
1539     dev_video_bktr_ioctl_bt848_h
1540     dev_video_meteor_ioctl_meteor_h
1541     direct_h
1542     dxgidebug_h
1543     dxva_h
1544     io_h
1545     machine_ioctl_bt848_h
1546     machine_ioctl_meteor_h
1547     malloc_h
1548     poll_h
1549     sys_param_h
1550     sys_resource_h
1551     sys_select_h
1552     sys_soundcard_h
1553     sys_time_h
1554     sys_un_h
1555     sys_videoio_h
1556     unistd_h
1557     valgrind_valgrind_h
1558     windows_h
1559     winsock2_h
1560 "
1561
1562 INTRINSICS_LIST="
1563     intrinsics_neon
1564 "
1565
1566 MATH_FUNCS="
1567     atanf
1568     atan2f
1569     cbrtf
1570     cosf
1571     exp2
1572     exp2f
1573     expf
1574     isinf
1575     isnan
1576     ldexpf
1577     llrint
1578     llrintf
1579     log2
1580     log2f
1581     log10f
1582     lrint
1583     lrintf
1584     powf
1585     rint
1586     round
1587     roundf
1588     sinf
1589     trunc
1590     truncf
1591 "
1592
1593 SYSTEM_FEATURES="
1594     dos_paths
1595     libc_msvcrt
1596     MMAL_PARAMETER_VIDEO_MAX_NUM_CALLBACKS
1597     section_data_rel_ro
1598     threads
1599     uwp
1600 "
1601
1602 SYSTEM_FUNCS="
1603     aligned_malloc
1604     clock_gettime
1605     closesocket
1606     CommandLineToArgvW
1607     fcntl
1608     getaddrinfo
1609     gethrtime
1610     getopt
1611     GetProcessAffinityMask
1612     GetProcessMemoryInfo
1613     GetProcessTimes
1614     getrusage
1615     GetSystemTimeAsFileTime
1616     gettimeofday
1617     gmtime_r
1618     inet_aton
1619     isatty
1620     localtime_r
1621     mach_absolute_time
1622     MapViewOfFile
1623     memalign
1624     mmap
1625     mprotect
1626     nanosleep
1627     posix_memalign
1628     sched_getaffinity
1629     SetConsoleTextAttribute
1630     setmode
1631     setrlimit
1632     Sleep
1633     strerror_r
1634     sysconf
1635     sysctl
1636     usleep
1637     VirtualAlloc
1638 "
1639
1640 SYSTEM_LIBRARIES="
1641     sdl
1642     vaapi_1
1643     vaapi_drm
1644     vaapi_x11
1645     vdpau_x11
1646     wincrypt
1647 "
1648
1649 TOOLCHAIN_FEATURES="
1650     as_arch_directive
1651     as_fpu_directive
1652     as_func
1653     as_object_arch
1654     asm_mod_q
1655     blocks_extension
1656     ebp_available
1657     ebx_available
1658     gnu_as
1659     ibm_asm
1660     inline_asm_labels
1661     pragma_deprecated
1662     symver_asm_label
1663     symver_gnu_asm
1664     vfp_args
1665     xform_asm
1666     xmm_clobbers
1667 "
1668
1669 TYPES_LIST="
1670     CONDITION_VARIABLE_Ptr
1671     CUVIDDECODECREATEINFO_bitDepthMinus8
1672     socklen_t
1673     struct_addrinfo
1674     struct_group_source_req
1675     struct_ip_mreq_source
1676     struct_ipv6_mreq
1677     struct_pollfd
1678     struct_rusage_ru_maxrss
1679     struct_sockaddr_in6
1680     struct_sockaddr_sa_len
1681     struct_sockaddr_storage
1682     struct_v4l2_frmivalenum_discrete
1683 "
1684
1685 HAVE_LIST="
1686     $ARCH_EXT_LIST
1687     $(add_suffix _external $ARCH_EXT_LIST)
1688     $(add_suffix _inline   $ARCH_EXT_LIST)
1689     $ARCH_FEATURES
1690     $BUILTIN_LIST
1691     $HAVE_LIST_CMDLINE
1692     $HAVE_LIST_PUB
1693     $HEADERS_LIST
1694     $INTRINSICS_LIST
1695     $MATH_FUNCS
1696     $SYSTEM_FEATURES
1697     $SYSTEM_FUNCS
1698     $SYSTEM_LIBRARIES
1699     $THREADS_LIST
1700     $TOOLCHAIN_FEATURES
1701     $TYPES_LIST
1702 "
1703
1704 # options emitted with CONFIG_ prefix but not available on the command line
1705 CONFIG_EXTRA="
1706     aandcttables
1707     ac3dsp
1708     adts_header
1709     audio_frame_queue
1710     audiodsp
1711     blockdsp
1712     bswapdsp
1713     cabac
1714     cbs
1715     cbs_h264
1716     cbs_h265
1717     cbs_mpeg2
1718     dirac_parse
1719     dvprofile
1720     faandct
1721     faanidct
1722     fdctdsp
1723     flacdsp
1724     fmtconvert
1725     g722dsp
1726     gmp
1727     golomb
1728     gplv3
1729     h263dsp
1730     h264chroma
1731     h264dsp
1732     h264parse
1733     h264pred
1734     h264qpel
1735     hevcparse
1736     hpeldsp
1737     huffman
1738     huffyuvdsp
1739     huffyuvencdsp
1740     idctdsp
1741     iirfilter
1742     imdct15
1743     intrax8
1744     iso_media
1745     ividsp
1746     jpegtables
1747     lgplv3
1748     libx262
1749     libxcb_shape
1750     lpc
1751     lzf
1752     me_cmp
1753     mpeg_er
1754     mpegaudio
1755     mpegaudiodsp
1756     mpegaudioheader
1757     mpegvideo
1758     mpegvideoenc
1759     mss34dsp
1760     pixblockdsp
1761     qpeldsp
1762     qsv
1763     qsvdec
1764     qsvenc
1765     qsvvpp
1766     rangecoder
1767     riffdec
1768     riffenc
1769     rtpdec
1770     rtpenc_chain
1771     rv34dsp
1772     sinewin
1773     snappy
1774     srtp
1775     startcode
1776     texturedsp
1777     texturedspenc
1778     tpeldsp
1779     vaapi_encode
1780     vc1dsp
1781     videodsp
1782     vp3dsp
1783     vp56dsp
1784     vp8dsp
1785     wma_freqs
1786     wmv2dsp
1787 "
1788
1789 CMDLINE_SELECT="
1790     $ARCH_EXT_LIST
1791     $CONFIG_LIST
1792     $HAVE_LIST_CMDLINE
1793     $THREADS_LIST
1794     asm
1795     cross_compile
1796     debug
1797     extra_warnings
1798     logging
1799     lto
1800     optimizations
1801     rpath
1802 "
1803
1804 PATHS_LIST="
1805     bindir
1806     datadir
1807     docdir
1808     incdir
1809     libdir
1810     mandir
1811     prefix
1812     shlibdir
1813 "
1814
1815 CMDLINE_SET="
1816     $PATHS_LIST
1817     ar
1818     arch
1819     as
1820     cc
1821     objcc
1822     cpu
1823     cross_prefix
1824     custom_allocator
1825     dep_cc
1826     env
1827     extra_version
1828     host_cc
1829     host_cflags
1830     host_extralibs
1831     host_ld
1832     host_ldflags
1833     host_os
1834     ignore_tests
1835     ld
1836     logfile
1837     malloc_prefix
1838     nm
1839     optflags
1840     pkg_config
1841     pkg_config_flags
1842     samples
1843     sysinclude
1844     sysroot
1845     target_exec
1846     target_os
1847     target_path
1848     target_samples
1849     toolchain
1850     x86asmexe
1851 "
1852
1853 CMDLINE_APPEND="
1854     extra_cflags
1855     extra_objcflags
1856     host_cppflags
1857 "
1858
1859 # code dependency declarations
1860
1861 # architecture extensions
1862
1863 armv5te_deps="arm"
1864 armv6_deps="arm"
1865 armv6t2_deps="arm"
1866 armv8_deps="aarch64"
1867 neon_deps_any="aarch64 arm"
1868 intrinsics_neon_deps="neon"
1869 vfp_deps_any="aarch64 arm"
1870 vfpv3_deps="vfp"
1871
1872 map 'eval ${v}_inline_deps=inline_asm' $ARCH_EXT_LIST_ARM
1873
1874 altivec_deps="ppc"
1875 dcbzl_deps="ppc"
1876 ldbrx_deps="ppc"
1877 ppc4xx_deps="ppc"
1878 vsx_deps="altivec"
1879 power8_deps="vsx"
1880
1881 loongson_deps="mips"
1882 mips32r1_deps="mips32"
1883 mips32r2_deps="mips32"
1884 mips32r6_deps="mips32"
1885 mips64r1_deps="mips64"
1886 mips64r2_deps="mips64"
1887 mips64r6_deps="mips64"
1888
1889 vis_deps="sparc"
1890
1891 cpunop_deps="i686"
1892 x86_64_select="i686"
1893 x86_64_suggest="fast_cmov"
1894
1895 amd3dnow_deps="mmx"
1896 amd3dnowext_deps="amd3dnow"
1897 i686_deps="x86"
1898 mmx_deps="x86"
1899 mmxext_deps="mmx"
1900 sse_deps="mmxext"
1901 sse2_deps="sse"
1902 sse3_deps="sse2"
1903 ssse3_deps="sse3"
1904 sse4_deps="ssse3"
1905 sse42_deps="sse4"
1906 avx_deps="sse42"
1907 xop_deps="avx"
1908 fma3_deps="avx"
1909 fma4_deps="avx"
1910 avx2_deps="avx"
1911
1912 mmx_external_deps="x86asm"
1913 mmx_inline_deps="inline_asm x86"
1914 mmx_suggest="mmx_external mmx_inline"
1915
1916 for ext in $(filter_out mmx $ARCH_EXT_LIST_X86_SIMD); do
1917     eval dep=\$${ext}_deps
1918     eval ${ext}_external_deps='"${dep}_external"'
1919     eval ${ext}_inline_deps='"${dep}_inline"'
1920     eval ${ext}_suggest='"${ext}_external ${ext}_inline"'
1921 done
1922
1923 aligned_stack_if_any="aarch64 ppc x86"
1924 fast_64bit_if_any="aarch64 alpha ia64 mips64 parisc64 ppc64 sparc64 x86_64"
1925 fast_clz_if_any="aarch64 alpha avr32 mips ppc x86"
1926 fast_unaligned_if_any="aarch64 ppc x86"
1927 simd_align_16_if_any="altivec neon sse"
1928 simd_align_32_if_any="avx"
1929
1930 # system capabilities
1931 symver_if_any="symver_asm_label symver_gnu_asm"
1932 valgrind_backtrace_conflict="optimizations"
1933 valgrind_backtrace_deps="valgrind_valgrind_h"
1934
1935 # threading support
1936 atomics_gcc_if="sync_val_compare_and_swap"
1937 atomics_suncc_if="atomic_cas_ptr machine_rw_barrier"
1938 atomics_win32_if="MemoryBarrier"
1939 atomics_native_if_any="$ATOMICS_LIST"
1940 w32threads_deps="atomics_native"
1941 threads_if_any="$THREADS_LIST"
1942
1943 # subsystems
1944 cbs_h264_select="cbs golomb"
1945 cbs_h265_select="cbs golomb"
1946 cbs_mpeg2_select="cbs"
1947 dct_select="rdft"
1948 dirac_parse_select="golomb"
1949 error_resilience_select="me_cmp"
1950 faandct_deps="faan"
1951 faandct_select="fdctdsp"
1952 faanidct_deps="faan"
1953 faanidct_select="idctdsp"
1954 h264dsp_select="startcode"
1955 hevcparse_select="golomb"
1956 intrax8_select="blockdsp idctdsp"
1957 mdct_select="fft"
1958 rdft_select="fft"
1959 me_cmp_select="fdctdsp idctdsp pixblockdsp"
1960 mpeg_er_select="error_resilience"
1961 mpegaudio_select="mpegaudiodsp mpegaudioheader"
1962 mpegaudiodsp_select="dct"
1963 mpegvideo_select="blockdsp hpeldsp idctdsp me_cmp mpeg_er videodsp"
1964 mpegvideoenc_select="me_cmp mpegvideo pixblockdsp qpeldsp"
1965 vc1dsp_select="h264chroma qpeldsp startcode"
1966
1967 # decoders / encoders
1968 aac_decoder_select="adts_header imdct15 mdct sinewin"
1969 aac_encoder_select="audio_frame_queue iirfilter mdct sinewin"
1970 aac_latm_decoder_select="aac_decoder aac_latm_parser"
1971 ac3_decoder_select="ac3_parser ac3dsp bswapdsp fmtconvert mdct"
1972 ac3_encoder_select="ac3dsp audiodsp mdct me_cmp"
1973 ac3_fixed_encoder_select="ac3dsp audiodsp mdct me_cmp"
1974 adpcm_g722_decoder_select="g722dsp"
1975 adpcm_g722_encoder_select="g722dsp"
1976 aic_decoder_select="golomb idctdsp"
1977 alac_encoder_select="lpc"
1978 als_decoder_select="bswapdsp"
1979 amrnb_decoder_select="lsp"
1980 amrwb_decoder_select="lsp"
1981 amv_decoder_select="sp5x_decoder"
1982 ape_decoder_select="bswapdsp"
1983 asv1_decoder_select="blockdsp bswapdsp idctdsp"
1984 asv1_encoder_select="bswapdsp fdctdsp pixblockdsp"
1985 asv2_decoder_select="blockdsp bswapdsp idctdsp"
1986 asv2_encoder_select="bswapdsp fdctdsp pixblockdsp"
1987 atrac1_decoder_select="mdct sinewin"
1988 atrac3_decoder_select="mdct"
1989 atrac3p_decoder_select="mdct sinewin"
1990 bink_decoder_select="blockdsp hpeldsp"
1991 binkaudio_dct_decoder_select="mdct rdft dct sinewin wma_freqs"
1992 binkaudio_rdft_decoder_select="mdct rdft sinewin wma_freqs"
1993 cavs_decoder_select="blockdsp golomb h264chroma idctdsp qpeldsp videodsp"
1994 clearvideo_decoder_select="idctdsp"
1995 cllc_decoder_select="bswapdsp"
1996 comfortnoise_encoder_select="lpc"
1997 cook_decoder_select="audiodsp mdct sinewin"
1998 cscd_decoder_select="lzo"
1999 cscd_decoder_suggest="zlib"
2000 dca_decoder_select="fmtconvert mdct"
2001 dds_decoder_select="texturedsp"
2002 dnxhd_decoder_select="blockdsp idctdsp"
2003 dnxhd_encoder_select="aandcttables blockdsp fdctdsp idctdsp mpegvideoenc pixblockdsp"
2004 dvvideo_decoder_select="dvprofile idctdsp"
2005 dvvideo_encoder_select="dvprofile fdctdsp me_cmp pixblockdsp"
2006 dxa_decoder_deps="zlib"
2007 dxv_decoder_select="lzf texturedsp"
2008 eac3_decoder_select="ac3_decoder"
2009 eac3_encoder_select="ac3_encoder"
2010 eamad_decoder_select="aandcttables blockdsp bswapdsp idctdsp mpegvideo"
2011 eatgq_decoder_select="aandcttables idctdsp"
2012 eatqi_decoder_select="aandcttables blockdsp bswapdsp idctdsp"
2013 exr_decoder_deps="zlib"
2014 ffv1_decoder_select="rangecoder"
2015 ffv1_encoder_select="rangecoder"
2016 ffvhuff_decoder_select="huffyuv_decoder"
2017 ffvhuff_encoder_select="huffyuv_encoder"
2018 fic_decoder_select="golomb"
2019 flac_decoder_select="flacdsp"
2020 flac_encoder_select="bswapdsp flacdsp lpc"
2021 flashsv_decoder_deps="zlib"
2022 flashsv_encoder_deps="zlib"
2023 flashsv2_decoder_deps="zlib"
2024 flv_decoder_select="h263_decoder"
2025 flv_encoder_select="h263_encoder"
2026 fourxm_decoder_select="blockdsp bswapdsp"
2027 fraps_decoder_select="bswapdsp huffman"
2028 g2m_decoder_deps="zlib"
2029 g2m_decoder_select="blockdsp idctdsp jpegtables"
2030 h261_decoder_select="mpeg_er mpegvideo"
2031 h261_encoder_select="aandcttables mpegvideoenc"
2032 h263_decoder_select="error_resilience h263_parser h263dsp mpeg_er mpegvideo qpeldsp"
2033 h263_encoder_select="aandcttables h263dsp mpegvideoenc"
2034 h263i_decoder_select="h263_decoder"
2035 h263p_encoder_select="h263_encoder"
2036 h264_decoder_select="cabac golomb h264chroma h264dsp h264parse h264pred h264qpel videodsp"
2037 h264_decoder_suggest="error_resilience"
2038 hap_decoder_select="snappy texturedsp"
2039 hap_encoder_deps="libsnappy"
2040 hap_encoder_select="texturedspenc"
2041 hevc_decoder_select="bswapdsp cabac hevcparse videodsp"
2042 huffyuv_decoder_select="bswapdsp huffyuvdsp"
2043 huffyuv_encoder_select="bswapdsp huffman huffyuvencdsp"
2044 iac_decoder_select="imc_decoder"
2045 imc_decoder_select="bswapdsp fft mdct sinewin"
2046 indeo3_decoder_select="hpeldsp"
2047 indeo4_decoder_select="ividsp"
2048 indeo5_decoder_select="ividsp"
2049 interplay_video_decoder_select="hpeldsp"
2050 jpegls_decoder_select="mjpeg_decoder"
2051 jv_decoder_select="blockdsp"
2052 lagarith_decoder_select="huffyuvdsp"
2053 ljpeg_encoder_select="aandcttables idctdsp jpegtables"
2054 magicyuv_decoder_select="huffyuvdsp"
2055 mdec_decoder_select="blockdsp idctdsp mpegvideo"
2056 metasound_decoder_select="lsp mdct sinewin"
2057 mimic_decoder_select="blockdsp bswapdsp hpeldsp idctdsp"
2058 mjpeg_decoder_select="blockdsp hpeldsp idctdsp jpegtables"
2059 mjpeg_encoder_select="aandcttables jpegtables mpegvideoenc"
2060 mjpegb_decoder_select="mjpeg_decoder"
2061 mlp_decoder_select="mlp_parser"
2062 motionpixels_decoder_select="bswapdsp"
2063 mp1_decoder_select="mpegaudio"
2064 mp1float_decoder_select="mpegaudio"
2065 mp2_decoder_select="mpegaudio"
2066 mp2float_decoder_select="mpegaudio"
2067 mp3_decoder_select="mpegaudio"
2068 mp3adu_decoder_select="mpegaudio"
2069 mp3adufloat_decoder_select="mpegaudio"
2070 mp3float_decoder_select="mpegaudio"
2071 mp3on4_decoder_select="mpegaudio"
2072 mp3on4float_decoder_select="mpegaudio"
2073 mpc7_decoder_select="bswapdsp mpegaudiodsp"
2074 mpc8_decoder_select="mpegaudiodsp"
2075 mpeg1video_decoder_select="error_resilience mpeg_er mpegvideo"
2076 mpeg1video_encoder_select="aandcttables mpegvideoenc"
2077 mpeg2video_decoder_select="error_resilience mpeg_er mpegvideo"
2078 mpeg2video_encoder_select="aandcttables mpegvideoenc"
2079 mpeg4_decoder_select="h263_decoder mpeg4video_parser"
2080 mpeg4_encoder_select="h263_encoder"
2081 msa1_decoder_select="mss34dsp"
2082 msmpeg4v1_decoder_select="h263_decoder"
2083 msmpeg4v2_decoder_select="h263_decoder"
2084 msmpeg4v2_encoder_select="h263_encoder"
2085 msmpeg4v3_decoder_select="h263_decoder"
2086 msmpeg4v3_encoder_select="h263_encoder"
2087 mss2_decoder_select="error_resilience mpeg_er mpegvideo qpeldsp vc1_decoder"
2088 mts2_decoder_select="mss34dsp"
2089 mxpeg_decoder_select="mjpeg_decoder"
2090 nellymoser_decoder_select="mdct sinewin"
2091 nellymoser_encoder_select="audio_frame_queue mdct sinewin"
2092 nuv_decoder_select="idctdsp lzo"
2093 on2avc_decoder_select="mdct"
2094 opus_decoder_deps="avresample"
2095 opus_decoder_select="imdct15"
2096 png_decoder_deps="zlib"
2097 png_encoder_deps="zlib"
2098 png_encoder_select="huffyuvencdsp"
2099 prores_decoder_select="idctdsp"
2100 prores_encoder_select="fdctdsp"
2101 qcelp_decoder_select="lsp"
2102 qdm2_decoder_select="mdct rdft mpegaudiodsp"
2103 ra_144_encoder_select="audio_frame_queue lpc"
2104 ralf_decoder_select="golomb"
2105 rscc_decoder_deps="zlib"
2106 rv10_decoder_select="error_resilience h263_decoder h263dsp mpeg_er"
2107 rv10_encoder_select="h263_encoder"
2108 rv20_decoder_select="error_resilience h263_decoder h263dsp mpeg_er"
2109 rv20_encoder_select="h263_encoder"
2110 rv30_decoder_select="error_resilience golomb h264chroma h264pred h264qpel mpeg_er mpegvideo rv34dsp videodsp"
2111 rv40_decoder_select="error_resilience golomb h264chroma h264pred h264qpel mpeg_er mpegvideo rv34dsp videodsp"
2112 screenpresso_decoder_deps="zlib"
2113 sipr_decoder_select="lsp"
2114 sp5x_decoder_select="mjpeg_decoder"
2115 svq1_decoder_select="hpeldsp"
2116 svq1_encoder_select="aandcttables hpeldsp me_cmp mpegvideoenc"
2117 svq3_decoder_select="golomb h264dsp h264parse h264pred hpeldsp tpeldsp videodsp"
2118 svq3_decoder_suggest="zlib"
2119 tak_decoder_select="audiodsp"
2120 tdsc_decoder_deps="zlib"
2121 tdsc_decoder_select="mjpeg_decoder"
2122 theora_decoder_select="vp3_decoder"
2123 thp_decoder_select="mjpeg_decoder"
2124 tiff_decoder_suggest="zlib"
2125 tiff_encoder_suggest="zlib"
2126 truehd_decoder_select="mlp_decoder"
2127 truemotion2_decoder_select="bswapdsp"
2128 truespeech_decoder_select="bswapdsp"
2129 tscc_decoder_deps="zlib"
2130 txd_decoder_select="texturedsp"
2131 twinvq_decoder_select="mdct lsp sinewin"
2132 utvideo_decoder_select="bswapdsp huffyuvdsp"
2133 utvideo_encoder_select="bswapdsp huffman huffyuvencdsp"
2134 vble_decoder_select="huffyuvdsp"
2135 vc1_decoder_select="blockdsp error_resilience h263_decoder h264qpel intrax8 mpeg_er mpegvideo vc1dsp"
2136 vc1image_decoder_select="vc1_decoder"
2137 vorbis_decoder_select="mdct"
2138 vorbis_encoder_select="mdct"
2139 vp3_decoder_select="hpeldsp vp3dsp videodsp"
2140 vp5_decoder_select="h264chroma hpeldsp videodsp vp3dsp vp56dsp"
2141 vp6_decoder_select="h264chroma hpeldsp huffman videodsp vp3dsp vp56dsp"
2142 vp6a_decoder_select="vp6_decoder"
2143 vp6f_decoder_select="vp6_decoder"
2144 vp7_decoder_select="h264pred videodsp vp8dsp"
2145 vp8_decoder_select="h264pred videodsp vp8dsp"
2146 vp9_decoder_select="videodsp vp9_superframe_split_bsf"
2147 webp_decoder_select="vp8_decoder"
2148 wmapro_decoder_select="mdct sinewin wma_freqs"
2149 wmav1_decoder_select="mdct sinewin wma_freqs"
2150 wmav1_encoder_select="mdct sinewin wma_freqs"
2151 wmav2_decoder_select="mdct sinewin wma_freqs"
2152 wmav2_encoder_select="mdct sinewin wma_freqs"
2153 wmavoice_decoder_select="lsp rdft dct mdct sinewin"
2154 wmv1_decoder_select="h263_decoder"
2155 wmv1_encoder_select="h263_encoder"
2156 wmv2_decoder_select="blockdsp error_resilience h263_decoder idctdsp intrax8 videodsp wmv2dsp"
2157 wmv2_encoder_select="h263_encoder wmv2dsp"
2158 wmv3_decoder_select="vc1_decoder"
2159 wmv3image_decoder_select="wmv3_decoder"
2160 zerocodec_decoder_deps="zlib"
2161 zlib_decoder_deps="zlib"
2162 zlib_encoder_deps="zlib"
2163 zmbv_decoder_deps="zlib"
2164 zmbv_encoder_deps="zlib"
2165
2166 # hardware accelerators
2167 d3d11va_deps="dxva_h ID3D11VideoDecoder"
2168 dxva2_deps="dxva2api_h DXVA2_ConfigPictureDecode ole32"
2169 vda_deps="VideoDecodeAcceleration_VDADecoder_h blocks_extension pthreads"
2170 vda_extralibs="-framework CoreFoundation -framework VideoDecodeAcceleration -framework QuartzCore"
2171
2172 h263_vaapi_hwaccel_deps="vaapi"
2173 h263_vaapi_hwaccel_select="h263_decoder"
2174 h264_cuvid_hwaccel_deps="cuvid CUVIDH264PICPARAMS"
2175 h264_cuvid_hwaccel_select="h264_decoder"
2176 h264_d3d11va_hwaccel_deps="d3d11va"
2177 h264_d3d11va_hwaccel_select="h264_decoder"
2178 h264_d3d11va2_hwaccel_deps="d3d11va"
2179 h264_d3d11va2_hwaccel_select="h264_decoder"
2180 h264_dxva2_hwaccel_deps="dxva2"
2181 h264_dxva2_hwaccel_select="h264_decoder"
2182 h264_vaapi_hwaccel_deps="vaapi"
2183 h264_vaapi_hwaccel_select="h264_decoder"
2184 h264_vda_hwaccel_deps="vda"
2185 h264_vda_hwaccel_select="h264_decoder"
2186 h264_vda_old_hwaccel_deps="vda"
2187 h264_vda_old_hwaccel_select="h264_decoder"
2188 h264_vdpau_hwaccel_deps="vdpau"
2189 h264_vdpau_hwaccel_select="h264_decoder"
2190 hevc_cuvid_hwaccel_deps="cuvid CUVIDHEVCPICPARAMS"
2191 hevc_cuvid_hwaccel_select="hevc_decoder"
2192 hevc_d3d11va_hwaccel_deps="d3d11va DXVA_PicParams_HEVC"
2193 hevc_d3d11va_hwaccel_select="hevc_decoder"
2194 hevc_d3d11va2_hwaccel_deps="d3d11va DXVA_PicParams_HEVC"
2195 hevc_d3d11va2_hwaccel_select="hevc_decoder"
2196 hevc_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_HEVC"
2197 hevc_dxva2_hwaccel_select="hevc_decoder"
2198 hevc_vaapi_hwaccel_deps="vaapi VAPictureParameterBufferHEVC"
2199 hevc_vaapi_hwaccel_select="hevc_decoder"
2200 hevc_vdpau_hwaccel_deps="vdpau VdpPictureInfoHEVC"
2201 hevc_vdpau_hwaccel_select="hevc_decoder"
2202 mpeg1_vdpau_hwaccel_deps="vdpau"
2203 mpeg1_vdpau_hwaccel_select="mpeg1video_decoder"
2204 mpeg2_d3d11va_hwaccel_deps="d3d11va"
2205 mpeg2_d3d11va_hwaccel_select="mpeg2video_decoder"
2206 mpeg2_d3d11va2_hwaccel_deps="d3d11va"
2207 mpeg2_d3d11va2_hwaccel_select="mpeg2video_decoder"
2208 mpeg2_dxva2_hwaccel_deps="dxva2"
2209 mpeg2_dxva2_hwaccel_select="mpeg2video_decoder"
2210 mpeg2_vaapi_hwaccel_deps="vaapi"
2211 mpeg2_vaapi_hwaccel_select="mpeg2video_decoder"
2212 mpeg2_vdpau_hwaccel_deps="vdpau"
2213 mpeg2_vdpau_hwaccel_select="mpeg2video_decoder"
2214 mpeg4_vaapi_hwaccel_deps="vaapi"
2215 mpeg4_vaapi_hwaccel_select="mpeg4_decoder"
2216 mpeg4_vdpau_hwaccel_deps="vdpau"
2217 mpeg4_vdpau_hwaccel_select="mpeg4_decoder"
2218 vc1_d3d11va_hwaccel_deps="d3d11va"
2219 vc1_d3d11va_hwaccel_select="vc1_decoder"
2220 vc1_d3d11va2_hwaccel_deps="d3d11va"
2221 vc1_d3d11va2_hwaccel_select="vc1_decoder"
2222 vc1_dxva2_hwaccel_deps="dxva2"
2223 vc1_dxva2_hwaccel_select="vc1_decoder"
2224 vc1_vaapi_hwaccel_deps="vaapi"
2225 vc1_vaapi_hwaccel_select="vc1_decoder"
2226 vc1_vdpau_hwaccel_deps="vdpau"
2227 vc1_vdpau_hwaccel_select="vc1_decoder"
2228 vp8_vaapi_hwaccel_deps="vaapi VAPictureParameterBufferVP8"
2229 vp8_vaapi_hwaccel_select="vp8_decoder"
2230 wmv3_d3d11va_hwaccel_select="vc1_d3d11va_hwaccel"
2231 wmv3_d3d11va2_hwaccel_select="vc1_d3d11va2_hwaccel"
2232 wmv3_dxva2_hwaccel_select="vc1_dxva2_hwaccel"
2233 wmv3_vaapi_hwaccel_select="vc1_vaapi_hwaccel"
2234 wmv3_vdpau_hwaccel_select="vc1_vdpau_hwaccel"
2235
2236 # hardware-accelerated codecs
2237 amf_deps_any="libdl LoadLibrary"
2238 nvenc_deps_any="libdl LoadLibrary"
2239 omx_deps="libdl pthreads"
2240 omx_rpi_select="omx"
2241 qsv_deps="libmfx"
2242 qsvdec_select="qsv"
2243 qsvenc_select="qsv"
2244 qsvvpp_select="qsv"
2245 vaapi_encode_deps="vaapi"
2246
2247 hwupload_cuda_filter_deps="cuda"
2248 scale_npp_filter_deps="cuda libnpp"
2249
2250 h264_amf_encoder_deps="amf"
2251 h264_mmal_decoder_deps="mmal"
2252 h264_nvenc_encoder_deps="nvenc"
2253 h264_omx_encoder_deps="omx"
2254 h264_qsv_decoder_select="h264_mp4toannexb_bsf h264_parser qsvdec"
2255 h264_qsv_encoder_select="qsvenc"
2256 h264_vaapi_encoder_deps="VAEncPictureParameterBufferH264"
2257 h264_vaapi_encoder_select="cbs_h264 vaapi_encode"
2258 hevc_amf_encoder_deps="amf"
2259 hevc_nvenc_encoder_deps="nvenc"
2260 hevc_qsv_decoder_select="hevc_mp4toannexb_bsf hevc_parser qsvdec"
2261 hevc_qsv_encoder_select="hevcparse qsvenc"
2262 hevc_vaapi_encoder_deps="VAEncPictureParameterBufferHEVC"
2263 hevc_vaapi_encoder_select="cbs_h265 vaapi_encode"
2264 mjpeg_qsv_encoder_deps="libmfx"
2265 mjpeg_qsv_encoder_select="qsvenc"
2266 mjpeg_vaapi_encoder_deps="VAEncPictureParameterBufferJPEG"
2267 mjpeg_vaapi_encoder_select="vaapi_encode jpegtables"
2268 mpeg2_mmal_decoder_deps="mmal"
2269 mpeg2_qsv_decoder_select="qsvdec mpegvideo_parser"
2270 mpeg2_qsv_encoder_select="qsvenc"
2271 mpeg2_vaapi_encoder_deps="VAEncPictureParameterBufferMPEG2"
2272 mpeg2_vaapi_encoder_select="cbs_mpeg2 vaapi_encode"
2273 mpeg4_omx_encoder_deps="omx"
2274 vc1_mmal_decoder_deps="mmal"
2275 vc1_qsv_decoder_select="qsvdec vc1_parser"
2276 vp8_qsv_decoder_select="qsvdec vp8_parser"
2277 vp8_vaapi_encoder_deps="VAEncPictureParameterBufferVP8"
2278 vp8_vaapi_encoder_select="vaapi_encode"
2279 vp9_vaapi_encoder_deps="VAEncPictureParameterBufferVP9"
2280 vp9_vaapi_encoder_select="vaapi_encode"
2281
2282 nvenc_h264_encoder_select="h264_nvenc_encoder"
2283 nvenc_hevc_encoder_select="hevc_nvenc_encoder"
2284
2285 # parsers
2286 aac_parser_select="adts_header"
2287 h264_parser_select="golomb h264dsp h264parse"
2288 hevc_parser_select="hevcparse"
2289 mpegaudio_parser_select="mpegaudioheader"
2290 mpegvideo_parser_select="mpegvideo"
2291 mpeg4video_parser_select="error_resilience h263dsp mpegvideo qpeldsp"
2292 vc1_parser_select="vc1dsp"
2293
2294 # bitstream_filters
2295 aac_adtstoasc_bsf_select="adts_header"
2296 h264_metadata_bsf_select="cbs_h264"
2297 h264_redundant_pps_bsf_select="cbs_h264"
2298 hevc_metadata_bsf_select="cbs_h265"
2299 mjpeg2jpeg_bsf_select="jpegtables"
2300 mpeg2_metadata_bsf_select="cbs_mpeg2"
2301 trace_headers_bsf_select="cbs_h264 cbs_h265 cbs_mpeg2"
2302
2303 # external libraries
2304 avisynth_deps="LoadLibrary"
2305 avxsynth_deps="libdl"
2306 avisynth_demuxer_deps_any="avisynth avxsynth"
2307 avisynth_demuxer_select="riffdec"
2308 libdcadec_decoder_deps="libdcadec"
2309 libfaac_encoder_deps="libfaac"
2310 libfaac_encoder_select="audio_frame_queue"
2311 libfdk_aac_decoder_deps="libfdk_aac"
2312 libfdk_aac_encoder_deps="libfdk_aac"
2313 libfdk_aac_encoder_select="audio_frame_queue"
2314 libgsm_decoder_deps="libgsm"
2315 libgsm_encoder_deps="libgsm"
2316 libgsm_ms_decoder_deps="libgsm"
2317 libgsm_ms_encoder_deps="libgsm"
2318 libilbc_decoder_deps="libilbc"
2319 libilbc_encoder_deps="libilbc"
2320 libkvazaar_encoder_deps="libkvazaar"
2321 libmp3lame_encoder_deps="libmp3lame"
2322 libmp3lame_encoder_select="audio_frame_queue mpegaudioheader"
2323 libopencore_amrnb_decoder_deps="libopencore_amrnb"
2324 libopencore_amrnb_encoder_deps="libopencore_amrnb"
2325 libopencore_amrnb_encoder_select="audio_frame_queue"
2326 libopencore_amrwb_decoder_deps="libopencore_amrwb"
2327 libopenh264_decoder_deps="libopenh264"
2328 libopenh264_decoder_select="h264_mp4toannexb_bsf"
2329 libopenh264_encoder_deps="libopenh264"
2330 libopenjpeg_decoder_deps="libopenjpeg"
2331 libopenjpeg_encoder_deps="libopenjpeg"
2332 libopus_decoder_deps="libopus"
2333 libopus_encoder_deps="libopus"
2334 libopus_encoder_select="audio_frame_queue"
2335 libschroedinger_decoder_deps="libschroedinger"
2336 libschroedinger_encoder_deps="libschroedinger"
2337 libspeex_decoder_deps="libspeex"
2338 libspeex_encoder_deps="libspeex"
2339 libspeex_encoder_select="audio_frame_queue"
2340 libtheora_encoder_deps="libtheora"
2341 libtwolame_encoder_deps="libtwolame"
2342 libvo_aacenc_encoder_deps="libvo_aacenc"
2343 libvo_aacenc_encoder_select="audio_frame_queue"
2344 libvo_amrwbenc_encoder_deps="libvo_amrwbenc"
2345 libvorbis_encoder_deps="libvorbis"
2346 libvorbis_encoder_select="audio_frame_queue"
2347 libvpx_vp8_decoder_deps="libvpx"
2348 libvpx_vp8_encoder_deps="libvpx"
2349 libvpx_vp9_decoder_deps="libvpx"
2350 libvpx_vp9_encoder_deps="libvpx"
2351 libwavpack_encoder_deps="libwavpack"
2352 libwavpack_encoder_select="audio_frame_queue"
2353 libwebp_encoder_deps="libwebp"
2354 libx262_encoder_deps="libx262"
2355 libx264_encoder_deps="libx264"
2356 libx265_encoder_deps="libx265"
2357 libxavs_encoder_deps="libxavs"
2358 libxvid_encoder_deps="libxvid mkstemp"
2359
2360 # demuxers / muxers
2361 ac3_demuxer_select="ac3_parser"
2362 asf_demuxer_select="riffdec"
2363 asf_muxer_select="riffenc"
2364 asf_stream_muxer_select="asf_muxer"
2365 avi_demuxer_select="iso_media riffdec"
2366 avi_muxer_select="riffenc"
2367 caf_demuxer_select="iso_media riffdec"
2368 dash_muxer_select="mp4_muxer"
2369 dirac_demuxer_select="dirac_parser"
2370 dv_demuxer_select="dvprofile"
2371 dv_muxer_select="dvprofile"
2372 dxa_demuxer_select="riffdec"
2373 eac3_demuxer_select="ac3_parser"
2374 f4v_muxer_select="mov_muxer"
2375 flac_demuxer_select="flac_parser"
2376 hds_muxer_select="flv_muxer"
2377 hls_muxer_select="mpegts_muxer"
2378 ipod_muxer_select="mov_muxer"
2379 ismv_muxer_select="mov_muxer"
2380 matroska_audio_muxer_select="matroska_muxer"
2381 matroska_demuxer_select="iso_media riffdec"
2382 matroska_demuxer_suggest="bzlib lzo zlib"
2383 matroska_muxer_select="iso_media riffenc"
2384 mmf_muxer_select="riffenc"
2385 mov_demuxer_select="iso_media riffdec"
2386 mov_demuxer_suggest="zlib"
2387 mov_muxer_select="iso_media riffenc rtpenc_chain"
2388 mp3_demuxer_select="mpegaudio_parser"
2389 mp3_muxer_select="mpegaudioheader"
2390 mp4_muxer_select="mov_muxer"
2391 mpegts_demuxer_select="iso_media"
2392 mpegts_muxer_select="adts_muxer latm_muxer"
2393 mpegtsraw_demuxer_select="mpegts_demuxer"
2394 mxf_d10_muxer_select="mxf_muxer"
2395 nut_muxer_select="riffenc"
2396 nuv_demuxer_select="riffdec"
2397 oga_muxer_select="ogg_muxer"
2398 ogg_demuxer_select="dirac_parse"
2399 opus_muxer_select="ogg_muxer"
2400 psp_muxer_select="mov_muxer"
2401 rtp_demuxer_select="sdp_demuxer"
2402 rtpdec_select="asf_demuxer jpegtables mov_demuxer mpegts_demuxer rm_demuxer rtp_protocol srtp"
2403 rtsp_demuxer_select="http_protocol rtpdec"
2404 rtsp_muxer_select="rtp_muxer http_protocol rtp_protocol rtpenc_chain"
2405 sap_demuxer_select="sdp_demuxer"
2406 sap_muxer_select="rtp_muxer rtp_protocol rtpenc_chain"
2407 sdp_demuxer_select="rtpdec"
2408 smoothstreaming_muxer_select="ismv_muxer"
2409 spdif_demuxer_select="adts_header"
2410 spdif_muxer_select="adts_header"
2411 spx_muxer_select="ogg_muxer"
2412 swf_demuxer_suggest="zlib"
2413 tak_demuxer_select="tak_parser"
2414 tg2_muxer_select="mov_muxer"
2415 tgp_muxer_select="mov_muxer"
2416 w64_demuxer_select="wav_demuxer"
2417 wav_demuxer_select="riffdec"
2418 wav_muxer_select="riffenc"
2419 webm_muxer_select="iso_media riffenc"
2420 wtv_demuxer_select="mpegts_demuxer riffdec"
2421 xmv_demuxer_select="riffdec"
2422 xwma_demuxer_select="riffdec"
2423
2424 # indevs
2425 alsa_indev_deps="alsa"
2426 avfoundation_indev_deps="AVFoundation_AVFoundation_h objc_arc pthreads"
2427 avfoundation_indev_extralibs="-framework Foundation -framework AVFoundation -framework CoreVideo -framework CoreMedia"
2428 bktr_indev_deps_any="dev_bktr_ioctl_bt848_h machine_ioctl_bt848_h dev_video_bktr_ioctl_bt848_h dev_ic_bt8xx_h"
2429 fbdev_indev_deps="linux_fb_h"
2430 jack_indev_deps="libjack"
2431 jack_indev_deps_any="sem_timedwait dispatch_dispatch_h"
2432 libcdio_indev_deps="libcdio"
2433 libdc1394_indev_deps="libdc1394"
2434 oss_indev_deps_any="sys_soundcard_h"
2435 pulse_indev_deps="libpulse"
2436 sndio_indev_deps="sndio"
2437 v4l2_indev_deps_any="linux_videodev2_h sys_videoio_h"
2438 vfwcap_indev_deps="vfw32 vfwcap_defines"
2439 xcbgrab_indev_deps="libxcb libxcb_shape"
2440 xcbgrab_indev_suggest="libxcb_shm libxcb_xfixes"
2441
2442 # protocols
2443 ffrtmpcrypt_protocol_conflict="librtmp_protocol"
2444 ffrtmpcrypt_protocol_deps_any="gmp openssl"
2445 ffrtmpcrypt_protocol_select="tcp_protocol"
2446 ffrtmphttp_protocol_conflict="librtmp_protocol"
2447 ffrtmphttp_protocol_select="http_protocol"
2448 gopher_protocol_select="network"
2449 http_protocol_select="tcp_protocol"
2450 http_protocol_suggest="zlib"
2451 httpproxy_protocol_select="tcp_protocol"
2452 httpproxy_protocol_suggest="zlib"
2453 https_protocol_select="tls_protocol"
2454 https_protocol_suggest="zlib"
2455 icecast_protocol_select="http_protocol"
2456 librtmp_protocol_deps="librtmp"
2457 librtmpe_protocol_deps="librtmp"
2458 librtmps_protocol_deps="librtmp"
2459 librtmpt_protocol_deps="librtmp"
2460 librtmpte_protocol_deps="librtmp"
2461 mmsh_protocol_select="http_protocol"
2462 mmst_protocol_select="network"
2463 rtmp_protocol_conflict="librtmp_protocol"
2464 rtmp_protocol_select="tcp_protocol"
2465 rtmp_protocol_suggest="zlib"
2466 rtmpe_protocol_select="ffrtmpcrypt_protocol"
2467 rtmpe_protocol_suggest="zlib"
2468 rtmps_protocol_conflict="librtmp_protocol"
2469 rtmps_protocol_select="tls_protocol"
2470 rtmps_protocol_suggest="zlib"
2471 rtmpt_protocol_select="ffrtmphttp_protocol"
2472 rtmpt_protocol_suggest="zlib"
2473 rtmpte_protocol_select="ffrtmpcrypt_protocol ffrtmphttp_protocol"
2474 rtmpte_protocol_suggest="zlib"
2475 rtmpts_protocol_select="ffrtmphttp_protocol https_protocol"
2476 rtmpts_protocol_suggest="zlib"
2477 rtp_protocol_select="udp_protocol"
2478 sctp_protocol_deps="struct_sctp_event_subscribe"
2479 sctp_protocol_select="network"
2480 srtp_protocol_select="rtp_protocol srtp"
2481 tcp_protocol_select="network"
2482 tls_protocol_deps_any="gnutls openssl"
2483 tls_protocol_select="tcp_protocol"
2484 udp_protocol_select="network"
2485 unix_protocol_deps="sys_un_h"
2486 unix_protocol_select="network"
2487
2488 # filters
2489 asyncts_filter_deps="avresample"
2490 blackframe_filter_deps="gpl"
2491 boxblur_filter_deps="gpl"
2492 bs2b_filter_deps="libbs2b"
2493 cropdetect_filter_deps="gpl"
2494 deinterlace_qsv_filter_deps="libmfx"
2495 deinterlace_vaapi_filter_deps="vaapi"
2496 delogo_filter_deps="gpl"
2497 drawtext_filter_deps="libfreetype"
2498 drawtext_filter_suggest="libfontconfig"
2499 frei0r_filter_deps="frei0r libdl"
2500 frei0r_src_filter_deps="frei0r libdl"
2501 hdcd_filter_deps="libhdcd"
2502 hqdn3d_filter_deps="gpl"
2503 interlace_filter_deps="gpl"
2504 movie_filter_deps="avcodec avformat"
2505 ocv_filter_deps="libopencv"
2506 overlay_qsv_filter_deps="libmfx"
2507 overlay_qsv_filter_select="qsvvpp"
2508 resample_filter_deps="avresample"
2509 scale_filter_deps="swscale"
2510 scale_qsv_filter_deps="libmfx"
2511 scale_vaapi_filter_deps="vaapi VAProcPipelineParameterBuffer"
2512 vpp_qsv_filter_deps="libmfx"
2513 vpp_qsv_filter_select="qsvvpp"
2514
2515 # examples
2516 decode_audio_example_deps="avcodec avutil"
2517 decode_video_example_deps="avcodec avutil"
2518 encode_audio_example_deps="avcodec avutil"
2519 encode_video_example_deps="avcodec avutil"
2520 filter_audio_example_deps="avfilter avutil"
2521 metadata_example_deps="avformat avutil"
2522 output_example_deps="avcodec avformat avresample avutil swscale"
2523 qsvdec_example_deps="avcodec avutil libmfx h264_qsv_decoder"
2524 transcode_aac_example_deps="avcodec avformat avresample"
2525
2526 # EXTRALIBS_LIST
2527 cpu_init_extralibs="pthreads_extralibs"
2528 cws2fws_extralibs="zlib_extralibs"
2529
2530 # libraries, in linking order
2531 avcodec_deps="avutil"
2532 avcodec_select="null_bsf"
2533 avdevice_deps="avformat avcodec avutil"
2534 avfilter_deps="avutil"
2535 avformat_deps="avcodec avutil"
2536 avformat_suggest="network"
2537 avresample_deps="avutil"
2538 swscale_deps="avutil"
2539
2540 avcodec_extralibs="pthreads_extralibs libm_extralibs"
2541 avdevice_extralibs="libm_extralibs"
2542 avformat_extralibs="libm_extralibs"
2543 avfilter_extralibs="pthreads_extralibs libm_extralibs"
2544 avresample_extralibs="libm_extralibs"
2545 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"
2546 swscale_extralibs="libm_extralibs"
2547
2548 # programs
2549 avconv_deps="avcodec avfilter avformat avresample swscale"
2550 avconv_select="aformat_filter anull_filter asyncts_filter atrim_filter format_filter
2551                fps_filter null_filter resample_filter scale_filter
2552                trim_filter"
2553 avconv_suggest="psapi shell32"
2554 avplay_deps="avcodec avfilter avformat avresample sdl"
2555 avplay_select="rdft format_filter transpose_filter hflip_filter vflip_filter"
2556 avplay_suggest="shell32"
2557 avprobe_deps="avcodec avformat"
2558 avprobe_suggest="shell32"
2559
2560 # documentation
2561 pod2man_deps="doc"
2562 texi2html_deps="doc"
2563
2564 # default parameters
2565
2566 logfile="avbuild/config.log"
2567
2568 # installation paths
2569 prefix_default="/usr/local"
2570 bindir_default='${prefix}/bin'
2571 datadir_default='${prefix}/share/avconv'
2572 docdir_default='${prefix}/share/doc/libav'
2573 incdir_default='${prefix}/include'
2574 libdir_default='${prefix}/lib'
2575 mandir_default='${prefix}/share/man'
2576 shlibdir_default="$libdir_default"
2577
2578 # toolchain
2579 ar_default="ar"
2580 cc_default="gcc"
2581 host_cc_default="gcc"
2582 x86asmexe_default="nasm"
2583 ln_s="ln -s -f"
2584 nm_default="nm -g"
2585 pkg_config_default=pkg-config
2586 ranlib="ranlib"
2587 strip="strip"
2588 version_script='--version-script'
2589 objformat="elf32"
2590
2591 # machine
2592 arch_default=$(uname -m)
2593 cpu="generic"
2594 intrinsics="none"
2595
2596 # OS
2597 target_os_default=$(tolower $(uname -s))
2598 host_os=$target_os_default
2599
2600 # configurable options
2601 enable $EXAMPLE_LIST $LIBRARY_LIST $PROGRAM_LIST
2602
2603 enable asm
2604 enable debug
2605 enable doc
2606 enable faan faandct faanidct
2607 enable optimizations
2608 enable safe_bitstream_reader
2609 enable static
2610 enable swscale_alpha
2611 enable valgrind_backtrace
2612
2613 # By default, enable only those hwaccels that have no external dependencies.
2614 enable d3d11va dxva2 vda vdpau
2615
2616 # internal components are enabled by default
2617 enable $EXTRALIBS_LIST
2618
2619 # Avoid external, non-system, libraries getting enabled by dependency resolution
2620 disable $EXTERNAL_LIBRARY_LIST
2621
2622 # build settings
2623 SHFLAGS='-shared -Wl,-soname,$$(@F)'
2624 LIBPREF="lib"
2625 LIBSUF=".a"
2626 LIBNAME='$(LIBPREF)$(NAME)$(LIBSUF)'
2627 SLIBPREF="lib"
2628 SLIBSUF=".so"
2629 SLIBNAME='$(SLIBPREF)$(NAME)$(SLIBSUF)'
2630 SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
2631 SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
2632 LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
2633 SLIB_INSTALL_NAME='$(SLIBNAME_WITH_VERSION)'
2634 SLIB_INSTALL_LINKS='$(SLIBNAME_WITH_MAJOR) $(SLIBNAME)'
2635 VERSION_SCRIPT_POSTPROCESS_CMD="cat"
2636
2637 asflags_filter=echo
2638 cflags_filter=echo
2639 ldflags_filter=echo
2640
2641 AS_C='-c'
2642 AS_O='-o $@'
2643 CC_C='-c'
2644 CC_E='-E -o $@'
2645 CC_O='-o $@'
2646 OBJCC_C='-c'
2647 OBJCC_E='-E -o $@'
2648 OBJCC_O='-o $@'
2649 X86ASM_O='-o $@'
2650 LD_O='-o $@'
2651 LD_LIB='-l%'
2652 LD_PATH='-L'
2653 HOSTCC_C='-c'
2654 HOSTCC_E='-E -o $@'
2655 HOSTCC_O='-o $@'
2656 HOSTLD_O='-o $@'
2657
2658 host_extralibs='-lm'
2659 host_cflags_filter=echo
2660 host_ldflags_filter=echo
2661
2662 target_path='$(CURDIR)'
2663
2664 # since the object filename is not given with the -MM flag, the compiler
2665 # is only able to print the basename, and we must add the path ourselves
2666 DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< | sed -e "/^\#.*/d" -e "s,^[[:space:]]*$(*F)\\.o,$(@D)/$(*F).o," > $(@:.o=.d)'
2667 DEPFLAGS='-MM'
2668
2669 mkdir -p avbuild
2670
2671 # find source path
2672 if test -f configure; then
2673     source_path=.
2674 else
2675     source_path=$(cd $(dirname "$0"); pwd)
2676     echo "$source_path" | grep -q '[[:blank:]]' &&
2677         die "Out of tree builds are impossible with whitespace in source path."
2678     test -e "$source_path/config.h" &&
2679         die "Out of tree builds are impossible with config.h in source dir."
2680 fi
2681
2682 for v in "$@"; do
2683     r=${v#*=}
2684     l=${v%"$r"}
2685     r=$(sh_quote "$r")
2686     LIBAV_CONFIGURATION="${LIBAV_CONFIGURATION# } ${l}${r}"
2687 done
2688
2689 find_things(){
2690     thing=$1
2691     pattern=$2
2692     file=$source_path/$3
2693     sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" "$file"
2694 }
2695
2696 ENCODER_LIST=$(find_things  encoder  ENC      libavcodec/allcodecs.c)
2697 DECODER_LIST=$(find_things  decoder  DEC      libavcodec/allcodecs.c)
2698 PARSER_LIST=$(find_things   parser   PARSER   libavcodec/allcodecs.c)
2699 MUXER_LIST=$(find_things    muxer    _MUX     libavformat/allformats.c)
2700 DEMUXER_LIST=$(find_things  demuxer  DEMUX    libavformat/allformats.c)
2701 INDEV_LIST=$(find_things    indev    _IN      libavdevice/alldevices.c)
2702 FILTER_LIST=$(find_things   filter   FILTER   libavfilter/allfilters.c)
2703
2704 find_things_extern(){
2705     thing=$1
2706     pattern=$2
2707     file=$source_path/$3
2708     sed -n "s/^[^#]*extern.*$pattern *ff_\([^ ]*\)_$thing;/\1_$thing/p" "$file"
2709 }
2710
2711 BSF_LIST=$(find_things_extern bsf AVBitStreamFilter libavcodec/bitstream_filters.c)
2712 HWACCEL_LIST=$(find_things_extern hwaccel AVHWAccel libavcodec/hwaccels.h)
2713 PROTOCOL_LIST=$(find_things_extern protocol URLProtocol libavformat/protocols.c)
2714
2715 AVCODEC_COMPONENTS_LIST="
2716     $BSF_LIST
2717     $DECODER_LIST
2718     $ENCODER_LIST
2719     $HWACCEL_LIST
2720     $PARSER_LIST
2721 "
2722
2723 AVDEVICE_COMPONENTS_LIST="
2724     $INDEV_LIST
2725 "
2726
2727 AVFILTER_COMPONENTS_LIST="
2728     $FILTER_LIST
2729 "
2730
2731 AVFORMAT_COMPONENTS_LIST="
2732     $DEMUXER_LIST
2733     $MUXER_LIST
2734     $PROTOCOL_LIST
2735 "
2736
2737 ALL_COMPONENTS="
2738     $AVCODEC_COMPONENTS_LIST
2739     $AVDEVICE_COMPONENTS_LIST
2740     $AVFILTER_COMPONENTS_LIST
2741     $AVFORMAT_COMPONENTS_LIST
2742 "
2743
2744 for n in $COMPONENT_LIST; do
2745     v=$(toupper ${n%s})_LIST
2746     eval enable \$$v
2747     eval ${n}_if_any="\$$v"
2748 done
2749
2750 enable $ARCH_EXT_LIST
2751
2752 die_unknown(){
2753     echo "Unknown option \"$1\"."
2754     echo "See $0 --help for available options."
2755     exit 1
2756 }
2757
2758 print_3_columns() {
2759     printf "%-25s %-25s %-25s\n" $(cat | tr ' ' '\n' | sort)
2760 }
2761
2762 show_list() {
2763     suffix=_$1
2764     shift
2765     echo $* | sed s/$suffix//g | print_3_columns
2766     exit 0
2767 }
2768
2769 for opt do
2770     optval="${opt#*=}"
2771     case "$opt" in
2772         --extra-ldflags=*)
2773             add_ldflags $optval
2774         ;;
2775         --extra-ldexeflags=*)
2776             add_ldexeflags $optval
2777         ;;
2778         --extra-ldsoflags=*)
2779             add_ldsoflags $optval
2780         ;;
2781         --extra-libs=*)
2782             add_extralibs $optval
2783         ;;
2784         --disable-devices)
2785             disable $INDEV_LIST
2786         ;;
2787         --enable-debug=*)
2788             debuglevel="$optval"
2789         ;;
2790         --disable-programs)
2791             disable $PROGRAM_LIST
2792         ;;
2793         --disable-everything)
2794             map 'eval unset \${$(toupper ${v%s})_LIST}' $COMPONENT_LIST
2795         ;;
2796         --disable-all)
2797             map 'eval unset \${$(toupper ${v%s})_LIST}' $COMPONENT_LIST
2798             disable $LIBRARY_LIST $PROGRAM_LIST doc
2799         ;;
2800         --enable-*=*|--disable-*=*)
2801             eval $(echo "${opt%%=*}" | sed 's/--/action=/;s/-/ thing=/')
2802             is_in "${thing}s" $COMPONENT_LIST || die_unknown "$opt"
2803             eval list=\$$(toupper $thing)_LIST
2804             name=$(echo "${optval}" | sed "s/,/_${thing}|/g")_${thing}
2805             $action $(filter "$name" $list)
2806         ;;
2807         --enable-yasm|--disable-yasm)
2808             warn "The ${opt} option is only provided for compatibility and will be\n"\
2809                  "removed in the future. Use --enable-x86asm / --disable-x86asm instead."
2810             test $opt = --enable-yasm && x86asm=yes || x86asm=no
2811         ;;
2812         --enable-?*|--disable-?*)
2813             eval $(echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g')
2814             if is_in $option $COMPONENT_LIST; then
2815                 test $action = disable && action=unset
2816                 eval $action \$$(toupper ${option%s})_LIST
2817             elif is_in $option $CMDLINE_SELECT; then
2818                 $action $option
2819             else
2820                 die_unknown $opt
2821             fi
2822         ;;
2823         --list-*)
2824             NAME="${opt#--list-}"
2825             is_in $NAME $COMPONENT_LIST || die_unknown $opt
2826             NAME=${NAME%s}
2827             eval show_list $NAME \$$(toupper $NAME)_LIST
2828         ;;
2829         --help|-h) show_help
2830         ;;
2831         --quiet|-q) quiet=yes
2832         ;;
2833         *)
2834             optname="${opt%%=*}"
2835             optname="${optname#--}"
2836             optname=$(echo "$optname" | sed 's/-/_/g')
2837             if is_in $optname $CMDLINE_SET; then
2838                 eval $optname='$optval'
2839             elif is_in $optname $CMDLINE_APPEND; then
2840                 append $optname "$optval"
2841             else
2842                 die_unknown $opt
2843             fi
2844         ;;
2845     esac
2846 done
2847
2848 for e in $env; do
2849     eval "export $e"
2850 done
2851
2852 disabled logging && logfile=/dev/null
2853
2854 # command line configuration sanity checks
2855
2856 # we need to build at least one lib type
2857 if ! enabled_any static shared; then
2858     cat <<EOF
2859 At least one library type must be built.
2860 Specify --enable-static to build the static libraries or --enable-shared to
2861 build the shared libraries as well. To only build the shared libraries specify
2862 --disable-static in addition to --enable-shared.
2863 EOF
2864     exit 1
2865 fi
2866
2867 # Die early if licensing-related configure options are incompatible.
2868 die_license_disabled() {
2869     enabled $1 || { enabled $v && die "$v is $1 and --enable-$1 is not specified."; }
2870 }
2871
2872 map "die_license_disabled gpl"      $EXTERNAL_LIBRARY_GPL_LIST
2873 map "die_license_disabled nonfree"  $EXTERNAL_LIBRARY_NONFREE_LIST $HWACCEL_LIBRARY_NONFREE_LIST
2874 map "die_license_disabled version3" $EXTERNAL_LIBRARY_VERSION3_LIST
2875
2876 enabled version3 && { enabled gpl && enable gplv3 || enable lgplv3; }
2877
2878 if enabled nonfree; then
2879     license="nonfree and unredistributable"
2880 elif enabled gplv3; then
2881     license="GPL version 3 or later"
2882 elif enabled lgplv3; then
2883     license="LGPL version 3 or later"
2884 elif enabled gpl; then
2885     license="GPL version 2 or later"
2886 else
2887     license="LGPL version 2.1 or later"
2888 fi
2889
2890 enabled_all gnutls openssl &&
2891     die "GnuTLS and OpenSSL must not be enabled at the same time."
2892
2893 # Disable all the library-specific components if the library itself
2894 # is disabled, see AVCODEC_LIST and following _LIST variables.
2895
2896 disable_components(){
2897     disabled ${1} && disable $(
2898         eval components="\$$(toupper ${1})_COMPONENTS"
2899         map 'eval echo \${$(toupper ${v%s})_LIST}' $components
2900     )
2901 }
2902
2903 map 'disable_components $v' $LIBRARY_LIST
2904
2905 echo "# $0 $LIBAV_CONFIGURATION" > $logfile
2906 set >> $logfile
2907
2908 case "$toolchain" in
2909     *-asan)
2910         cc_default="${toolchain%-asan}"
2911         add_cflags  -fsanitize=address
2912         add_ldflags -fsanitize=address
2913     ;;
2914     *-msan)
2915         cc_default="${toolchain%-msan}"
2916         add_cflags  -fsanitize=memory -fsanitize-memory-track-origins
2917         add_ldflags -fsanitize=memory
2918     ;;
2919     *-tsan)
2920         cc_default="${toolchain%-tsan}"
2921         add_cflags  -fsanitize=thread -fPIE
2922         add_ldflags -fsanitize=thread -pie
2923         case "$toolchain" in
2924             gcc-tsan)
2925                 add_cflags  -fPIC
2926                 add_ldflags -fPIC
2927                 ;;
2928         esac
2929     ;;
2930     *-usan)
2931         cc_default="${toolchain%-usan}"
2932         add_cflags  -fsanitize=undefined
2933         add_ldflags -fsanitize=undefined
2934         case "$toolchain" in
2935             clang-usan)
2936                 add_cflags -O1
2937                 ;;
2938         esac
2939     ;;
2940     valgrind-*)
2941         target_exec_default="valgrind"
2942         case "$toolchain" in
2943             valgrind-massif)
2944                 target_exec_args="--alloc-fn=av_malloc --alloc-fn=av_mallocz"
2945                 ;;
2946             valgrind-memcheck)
2947                 target_exec_args="--track-origins=yes --leak-check=full"
2948                 ;;
2949         esac
2950     ;;
2951     msvc)
2952         # Check whether the current MSVC version needs the C99 converter.
2953         # From MSVC 2013 (compiler major version 18) onwards, it does actually
2954         # support enough of C99 to build libav. Default to the new
2955         # behaviour if the regexp was unable to match anything, since this
2956         # successfully parses the version number of existing supported
2957         # versions that require the converter (MSVC 2010 and 2012).
2958         cl_major_ver=$(cl 2>&1 | sed -n 's/.*Version \([[:digit:]]\{1,\}\)\..*/\1/p')
2959         if [ -z "$cl_major_ver" ] || [ $cl_major_ver -ge 18 ]; then
2960             cc_default="cl"
2961         else
2962             cc_default="c99wrap cl"
2963         fi
2964         ld_default="$source_path/compat/windows/mslink"
2965         nm_default="dumpbin -symbols"
2966         ar_default="lib"
2967         case "$arch" in
2968         aarch64|arm64)
2969             as_default="armasm64"
2970             ;;
2971         arm*)
2972             as_default="armasm"
2973             ;;
2974         esac
2975         target_os_default="win32"
2976         # Use a relative path for TMPDIR. This makes sure all the
2977         # ffconf temp files are written with a relative path, avoiding
2978         # issues with msys/win32 path conversion for MSVC parameters
2979         # such as -Fo<file> or -out:<file>.
2980         TMPDIR=.
2981     ;;
2982     icl)
2983         cc_default="icl"
2984         ld_default="xilink"
2985         nm_default="dumpbin -symbols"
2986         ar_default="xilib"
2987         target_os_default="win32"
2988         TMPDIR=.
2989     ;;
2990     gcov)
2991         add_cflags  -fprofile-arcs -ftest-coverage
2992         add_ldflags -fprofile-arcs -ftest-coverage
2993     ;;
2994     llvm-cov)
2995         add_cflags -fprofile-arcs -ftest-coverage
2996         add_ldflags --coverage
2997     ;;
2998     hardened)
2999         add_cppflags -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2
3000         add_cflags   -fno-strict-overflow -fstack-protector-all
3001         add_ldflags  -Wl,-z,relro -Wl,-z,now
3002     ;;
3003     ?*)
3004         die "Unknown toolchain $toolchain"
3005     ;;
3006 esac
3007
3008 if test -n "$cross_prefix"; then
3009     test -n "$arch" && test -n "$target_os" ||
3010         die "Must specify target arch (--arch) and OS (--target-os) when cross-compiling"
3011     enable cross_compile
3012 fi
3013
3014 ar_default="${cross_prefix}${ar_default}"
3015 cc_default="${cross_prefix}${cc_default}"
3016 objcc_default="${cross_prefix}${objcc_default}"
3017 x86asmexe_default="${cross_prefix}${x86asmexe_default}"
3018 nm_default="${cross_prefix}${nm_default}"
3019 pkg_config_default="${cross_prefix}${pkg_config_default}"
3020 ranlib="${cross_prefix}${ranlib}"
3021 strip="${cross_prefix}${strip}"
3022
3023 sysinclude_default="${sysroot}/usr/include"
3024
3025 set_default arch cc pkg_config sysinclude target_exec target_os x86asmexe
3026 enabled cross_compile || host_cc_default=$cc
3027 set_default host_cc
3028
3029 if ! $pkg_config --version >/dev/null 2>&1; then
3030     warn "$pkg_config not found, library detection may fail."
3031     pkg_config=false
3032 fi
3033
3034 exesuf() {
3035     case $1 in
3036         mingw32*|mingw64*|win32|win64|cygwin*|*-dos|freedos|opendos|os/2*|symbian) echo .exe ;;
3037     esac
3038 }
3039
3040 EXESUF=$(exesuf $target_os)
3041 HOSTEXESUF=$(exesuf $host_os)
3042
3043 # set temporary file name
3044 : ${TMPDIR:=$TEMPDIR}
3045 : ${TMPDIR:=$TMP}
3046 : ${TMPDIR:=/tmp}
3047
3048 if ! test_cmd mktemp -u XXXXXX; then
3049     # simple replacement for missing mktemp
3050     # NOT SAFE FOR GENERAL USE
3051     mktemp(){
3052         tmpname="${2%%XXX*}.${HOSTNAME}.${UID}.$$"
3053         echo "$tmpname"
3054         mkdir "$tmpname"
3055     }
3056 fi
3057
3058 AVTMPDIR=$(mktemp -d "${TMPDIR}/avconf.XXXXXXXX" 2> /dev/null) ||
3059     die "Unable to create temporary directory in $TMPDIR."
3060
3061 tmpfile(){
3062     tmp="${AVTMPDIR}/test"$2
3063     (set -C; exec > $tmp) 2> /dev/null ||
3064         die "Unable to create temporary file in $AVTMPDIR."
3065     eval $1=$tmp
3066 }
3067
3068 trap 'rm -rf -- "$AVTMPDIR"' EXIT
3069 trap 'exit 2' INT
3070
3071 tmpfile TMPASM .asm
3072 tmpfile TMPC   .c
3073 tmpfile TMPE   $EXESUF
3074 tmpfile TMPH   .h
3075 tmpfile TMPO   .o
3076 tmpfile TMPS   .S
3077 tmpfile TMPSH  .sh
3078 tmpfile TMPV   .ver
3079
3080 unset -f mktemp
3081
3082 chmod +x $TMPE
3083
3084 # make sure we can execute files in $TMPDIR
3085 cat > $TMPSH 2>> $logfile <<EOF
3086 #! /bin/sh
3087 EOF
3088 chmod +x $TMPSH >> $logfile 2>&1
3089 if ! $TMPSH >> $logfile 2>&1; then
3090     cat <<EOF
3091 Unable to create and execute files in $TMPDIR.  Set the TMPDIR environment
3092 variable to another directory and make sure that it is not mounted noexec.
3093 EOF
3094     die "Sanity test failed."
3095 fi
3096
3097 armasm_flags(){
3098     for flag; do
3099         case $flag in
3100             # Filter out MSVC cl.exe options from cflags that shouldn't
3101             # be passed to gas-preprocessor
3102             -M[TD]*)                                            ;;
3103             *)                  echo $flag                      ;;
3104         esac
3105    done
3106 }
3107
3108 cparser_flags(){
3109     for flag; do
3110         case $flag in
3111             -Wno-switch)             echo -Wno-switch-enum ;;
3112             -Wno-format-zero-length) ;;
3113             -Wdisabled-optimization) ;;
3114             -Wno-pointer-sign)       echo -Wno-other ;;
3115             *)                       echo $flag ;;
3116         esac
3117     done
3118 }
3119
3120 msvc_common_flags(){
3121     for flag; do
3122         case $flag in
3123             # In addition to specifying certain flags under the compiler
3124             # specific filters, they must be specified here as well or else the
3125             # generic catch all at the bottom will print the original flag.
3126             -Wall)                ;;
3127             -Wextra)              ;;
3128             -std=c99)             ;;
3129             # Common flags
3130             -fomit-frame-pointer) ;;
3131             -g)                   echo -Z7 ;;
3132             -fno-math-errno)      ;;
3133             -fno-common)          ;;
3134             -fno-signed-zeros)    ;;
3135             -fPIC)                ;;
3136             -mthumb)              ;;
3137             -march=*)             ;;
3138             -lz)                  echo zlib.lib ;;
3139             -lx264)               echo libx264.lib ;;
3140             -l*)                  echo ${flag#-l}.lib ;;
3141             -L*)                  echo -libpath:${flag#-L} ;;
3142             *)                    echo $flag ;;
3143         esac
3144     done
3145 }
3146
3147 msvc_flags(){
3148     msvc_common_flags "$@"
3149     for flag; do
3150         case $flag in
3151             -Wall)                echo -W3 -wd4018 -wd4146 -wd4244 -wd4305     \
3152                                        -wd4554 ;;
3153             -Wextra)              echo -W4 -wd4244 -wd4127 -wd4018 -wd4389     \
3154                                        -wd4146 -wd4057 -wd4204 -wd4706 -wd4305 \
3155                                        -wd4152 -wd4324 -we4013 -wd4100 -wd4214 \
3156                                        -wd4273 -wd4554 -wd4701 -wd4703 ;;
3157         esac
3158     done
3159 }
3160
3161 icl_flags(){
3162     msvc_common_flags "$@"
3163     for flag; do
3164         case $flag in
3165             # Despite what Intel's documentation says -Wall, which is supported
3166             # on Windows, does enable remarks so disable them here.
3167             -Wall)                echo $flag -Qdiag-disable:remark ;;
3168             -std=c99)             echo -Qstd=c99 ;;
3169         esac
3170     done
3171 }
3172
3173 suncc_flags(){
3174     for flag; do
3175         case $flag in
3176             -march=*|-mcpu=*)
3177                 case "${flag#*=}" in
3178                     native)                   echo -xtarget=native       ;;
3179                     v9|niagara)               echo -xarch=sparc          ;;
3180                     ultrasparc)               echo -xarch=sparcvis       ;;
3181                     ultrasparc3|niagara2)     echo -xarch=sparcvis2      ;;
3182                     i586|pentium)             echo -xchip=pentium        ;;
3183                     i686|pentiumpro|pentium2) echo -xtarget=pentium_pro  ;;
3184                     pentium3*|c3-2)           echo -xtarget=pentium3     ;;
3185                     pentium-m)          echo -xarch=sse2 -xchip=pentium3 ;;
3186                     pentium4*)          echo -xtarget=pentium4           ;;
3187                     prescott|nocona)    echo -xarch=sse3 -xchip=pentium4 ;;
3188                     *-sse3)             echo -xarch=sse3                 ;;
3189                     core2)              echo -xarch=ssse3 -xchip=core2   ;;
3190                     corei7)           echo -xarch=sse4_2 -xchip=nehalem  ;;
3191                     corei7-avx)       echo -xarch=avx -xchip=sandybridge ;;
3192                     amdfam10|barcelona|bdver*) echo -xarch=sse4_1        ;;
3193                     athlon-4|athlon-[mx]p)     echo -xarch=ssea          ;;
3194                     k8|opteron|athlon64|athlon-fx)
3195                                                echo -xarch=sse2a         ;;
3196                     athlon*)                   echo -xarch=pentium_proa  ;;
3197                 esac
3198                 ;;
3199             -std=c99)             echo -xc99              ;;
3200             -fomit-frame-pointer) echo -xregs=frameptr    ;;
3201             -fPIC)                echo -KPIC -xcode=pic32 ;;
3202             -W*,*)                echo $flag              ;;
3203             -f*-*|-W*|-mimpure-text)                      ;;
3204             -shared)              echo -G                 ;;
3205             *)                    echo $flag              ;;
3206         esac
3207     done
3208 }
3209
3210 probe_cc(){
3211     pfx=$1
3212     _cc=$2
3213
3214     unset _type _ident _cc_c _cc_e _cc_o _flags _cflags
3215     unset _ld_o _ldflags _ld_lib _ld_path
3216     unset _depflags _DEPCMD _DEPFLAGS
3217     _flags_filter=echo
3218
3219     if $_cc -v 2>&1 | grep -q '^gcc.*LLVM'; then
3220         _type=llvm_gcc
3221         gcc_extra_ver=$(expr "$($_cc --version 2>/dev/null | head -n1)" : '.*\((.*)\)')
3222         _ident="llvm-gcc $($_cc -dumpversion 2>/dev/null) $gcc_extra_ver"
3223         _depflags='-MMD -MF $(@:.o=.d) -MT $@'
3224         _cflags_speed='-O3'
3225         _cflags_size='-Os'
3226     elif $_cc -v 2>&1 | grep -qi ^gcc; then
3227         _type=gcc
3228         gcc_version=$($_cc --version | head -n1)
3229         gcc_basever=$($_cc -dumpversion)
3230         gcc_pkg_ver=$(expr "$gcc_version" : '[^ ]* \(([^)]*)\)')
3231         gcc_ext_ver=$(expr "$gcc_version" : ".*$gcc_pkg_ver $gcc_basever \\(.*\\)")
3232         _ident=$(cleanws "gcc $gcc_basever $gcc_pkg_ver $gcc_ext_ver")
3233         if ! $_cc -dumpversion | grep -q '^2\.'; then
3234             _depflags='-MMD -MF $(@:.o=.d) -MT $@'
3235         fi
3236         _cflags_speed='-O3'
3237         _cflags_size='-Os'
3238     elif $_cc --version 2>/dev/null | grep -q ^icc; then
3239         _type=icc
3240         _ident=$($_cc --version | head -n1)
3241         _depflags='-MMD'
3242         _cflags_speed='-O3'
3243         _cflags_size='-Os'
3244         _cflags_noopt='-O1'
3245     elif $_cc -v 2>&1 | grep -q xlc; then
3246         _type=xlc
3247         _ident=$($_cc -qversion 2>/dev/null | head -n1)
3248         _cflags_speed='-O5'
3249         _cflags_size='-O5 -qcompact'
3250     elif $_cc --vsn 2>/dev/null | grep -Eq "ARM (C/C\+\+ )?Compiler"; then
3251         test -d "$sysroot" || die "No valid sysroot specified."
3252         _type=armcc
3253         _ident=$($_cc --vsn | grep -i build | head -n1 | sed 's/.*: //')
3254         armcc_conf="$PWD/armcc.conf"
3255         $_cc --arm_linux_configure                 \
3256              --arm_linux_config_file="$armcc_conf" \
3257              --configure_sysroot="$sysroot"        \
3258              --configure_cpp_headers="$sysinclude" >>$logfile 2>&1 ||
3259              die "Error creating armcc configuration file."
3260         $_cc --vsn | grep -q RVCT && armcc_opt=rvct || armcc_opt=armcc
3261         _flags="--arm_linux_config_file=$armcc_conf --translate_gcc"
3262         as_default="${cross_prefix}gcc"
3263         _depflags='-MMD'
3264         _cflags_speed='-O3'
3265         _cflags_size='-Os'
3266     elif $_cc -v 2>&1 | grep -q clang; then
3267         _type=clang
3268         _ident=$($_cc --version 2>/dev/null | head -n1)
3269         _depflags='-MMD -MF $(@:.o=.d) -MT $@'
3270         _cflags_speed='-O3'
3271         _cflags_size='-Os'
3272     elif $_cc -V 2>&1 | grep -q Sun; then
3273         _type=suncc
3274         _ident=$($_cc -V 2>&1 | head -n1 | cut -d' ' -f 2-)
3275         _DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< | sed -e "1s,^.*: ,$@: ," -e "\$$!s,\$$, \\\," -e "1!s,^.*: , ," > $(@:.o=.d)'
3276         _DEPFLAGS='-xM1 -xc99'
3277         _ldflags='-std=c99'
3278         _cflags_speed='-O5'
3279         _cflags_size='-O5 -xspace'
3280         _flags_filter=suncc_flags
3281     elif $_cc -v 2>&1 | grep -q 'PathScale\|Path64'; then
3282         _type=pathscale
3283         _ident=$($_cc -v 2>&1 | head -n1 | tr -d :)
3284         _depflags='-MMD -MF $(@:.o=.d) -MT $@'
3285         _cflags_speed='-O2'
3286         _cflags_size='-Os'
3287         _flags_filter='filter_out -Wdisabled-optimization'
3288     elif $_cc -v 2>&1 | grep -q Open64; then
3289         _type=open64
3290         _ident=$($_cc -v 2>&1 | head -n1 | tr -d :)
3291         _depflags='-MMD -MF $(@:.o=.d) -MT $@'
3292         _cflags_speed='-O2'
3293         _cflags_size='-Os'
3294         _flags_filter='filter_out -Wdisabled-optimization|-Wtype-limits|-fno-signed-zeros'
3295     elif $_cc 2>&1 | grep -q 'Microsoft.*ARM.*Assembler'; then
3296         _type=armasm
3297         _ident=$($_cc | head -n1)
3298         # 4509: "This form of conditional instruction is deprecated"
3299         _flags="-nologo -ignore 4509"
3300         _flags_filter=armasm_flags
3301     elif $_cc -nologo- 2>&1 | grep -q Microsoft; then
3302         _type=msvc
3303         _ident=$($_cc 2>&1 | head -n1)
3304         _DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< 2>&1 | awk '\''/including/ { sub(/^.*file: */, ""); gsub(/\\/, "/"); if (!match($$0, / /)) print "$@:", $$0 }'\'' > $(@:.o=.d)'
3305         _DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -showIncludes -Zs'
3306         _cflags_speed="-O2"
3307         _cflags_size="-O1"
3308         _cflags_noopt="-O1"
3309         if $_cc -nologo- 2>&1 | grep -q Linker; then
3310             _ld_o='-out:$@'
3311         else
3312             _ld_o='-Fe$@'
3313         fi
3314         _cc_o='-Fo$@'
3315         _cc_e='-P -Fi$@'
3316         _flags_filter=msvc_flags
3317         _ld_lib='lib%.a'
3318         _ld_path='-libpath:'
3319         _flags='-nologo'
3320     elif $_cc 2>&1 | grep -q Intel; then
3321         _type=icl
3322         _ident=$($_cc 2>&1 | head -n1)
3323         _depflags='-QMMD -QMF$(@:.o=.d) -QMT$@'
3324         # Not only is O3 broken on 13.x+ but it is slower on all previous
3325         # versions (tested) as well.
3326         _cflags_speed="-O2"
3327         _cflags_size="-O1 -Oi" # -O1 without -Oi miscompiles stuff
3328         if $_cc 2>&1 | grep -q Linker; then
3329             _ld_o='-out:$@'
3330         else
3331             _ld_o='-Fe$@'
3332         fi
3333         _cc_o='-Fo$@'
3334         _cc_e='-P'
3335         _flags_filter=icl_flags
3336         _ld_lib='lib%.a'
3337         _ld_path='-libpath:'
3338         # -Qdiag-error to make icl error when seeing certain unknown arguments
3339         _flags='-nologo -Qdiag-error:4044,10157'
3340         # -Qvec- -Qsimd- to prevent miscompilation, -GS for consistency
3341         # with MSVC which enables it by default.
3342         _cflags='-Qms0 -Qvec- -Qsimd- -GS'
3343     elif $_cc -? 2>/dev/null | grep -q 'LLVM.*Linker'; then
3344         # lld can emulate multiple different linkers; in ms link.exe mode,
3345         # the -? parameter gives the help output which contains an identifyable
3346         # string, while it gives an error in other modes.
3347         _type=lld-link
3348         # The link.exe mode doesn't have a switch for getting the version,
3349         # but we can force it back to gnu mode and get the version from there.
3350         _ident=$($_cc -flavor gnu --version 2>/dev/null)
3351         _ld_o='-out:$@'
3352         _flags_filter=msvc_flags
3353         _ld_lib='lib%.a'
3354         _ld_path='-libpath:'
3355     elif $_cc --version 2>/dev/null | grep -q ^cparser; then
3356         _type=cparser
3357         _ident=$($_cc --version | head -n1)
3358         _depflags='-MMD'
3359         _cflags_speed='-O4'
3360         _cflags_size='-O2'
3361         _flags_filter=cparser_flags
3362     fi
3363
3364     eval ${pfx}_type=\$_type
3365     eval ${pfx}_ident=\$_ident
3366 }
3367
3368 set_ccvars(){
3369     eval ${1}_C=\${_cc_c-\${${1}_C}}
3370     eval ${1}_E=\${_cc_e-\${${1}_E}}
3371     eval ${1}_O=\${_cc_o-\${${1}_O}}
3372
3373     if [ -n "$_depflags" ]; then
3374         eval ${1}_DEPFLAGS=\$_depflags
3375     else
3376         eval ${1}DEP=\${_DEPCMD:-\$DEPCMD}
3377         eval ${1}DEP_FLAGS=\${_DEPFLAGS:-\$DEPFLAGS}
3378         eval DEP${1}FLAGS=\$_flags
3379     fi
3380 }
3381
3382 probe_cc cc "$cc"
3383 cflags_filter=$_flags_filter
3384 cflags_speed=$_cflags_speed
3385 cflags_size=$_cflags_size
3386 cflags_noopt=$_cflags_noopt
3387 add_cflags $_flags $_cflags
3388 cc_ldflags=$_ldflags
3389 set_ccvars CC
3390
3391 probe_cc hostcc "$host_cc"
3392 host_cflags_filter=$_flags_filter
3393 host_cflags_speed=$_cflags_speed
3394 add_host_cflags  $_flags $_cflags
3395 set_ccvars HOSTCC
3396
3397 test -n "$cc_type" && enable $cc_type ||
3398     warn "Unknown C compiler $cc, unable to select optimal CFLAGS"
3399
3400 : ${as_default:=$cc}
3401 : ${objcc_default:=$cc}
3402 : ${dep_cc_default:=$cc}
3403 : ${ld_default:=$cc}
3404 : ${host_ld_default:=$host_cc}
3405 set_default ar as objcc dep_cc ld host_ld
3406
3407 probe_cc as "$as"
3408 asflags_filter=$_flags_filter
3409 add_asflags $_flags $_cflags
3410 set_ccvars AS
3411
3412 probe_cc objcc "$objcc"
3413 objcflags_filter=$_flags_filter
3414 add_objcflags $_flags $_cflags
3415 set_ccvars OBJC
3416
3417 probe_cc ld "$ld"
3418 ldflags_filter=$_flags_filter
3419 add_ldflags $_flags $_ldflags
3420 test "$cc_type" != "$ld_type" && add_ldflags $cc_ldflags
3421 LD_O=${_ld_o-$LD_O}
3422 LD_LIB=${_ld_lib-$LD_LIB}
3423 LD_PATH=${_ld_path-$LD_PATH}
3424
3425 probe_cc hostld "$host_ld"
3426 host_ldflags_filter=$_flags_filter
3427 add_host_ldflags $_flags $_ldflags
3428 HOSTLD_O=${_ld_o-$HOSTLD_O}
3429
3430 if [ -z "$CC_DEPFLAGS" ] && [ "$dep_cc" != "$cc" ]; then
3431     probe_cc depcc "$dep_cc"
3432     CCDEP=${_DEPCMD:-$DEPCMD}
3433     CCDEP_FLAGS=${_DEPFLAGS:=$DEPFLAGS}
3434     DEPCCFLAGS=$_flags
3435 fi
3436
3437 if $ar 2>&1 | grep -q Microsoft; then
3438     arflags="-nologo"
3439     ar_o='-out:$@'
3440 else
3441     arflags="rc"
3442     ar_o='$@'
3443 fi
3444
3445 add_cflags $extra_cflags
3446 add_objcflags $extra_objcflags
3447 add_asflags $extra_cflags
3448
3449 if test -n "$sysroot"; then
3450     case "$cc_type" in
3451         gcc|llvm_gcc|clang)
3452             add_cppflags --sysroot="$sysroot"
3453             add_ldflags --sysroot="$sysroot"
3454         ;;
3455     esac
3456 fi
3457
3458 if test "$cpu" = host; then
3459     enabled cross_compile &&
3460         die "--cpu=host makes no sense when cross-compiling."
3461
3462     case "$cc_type" in
3463         gcc|llvm_gcc)
3464             check_native(){
3465                 $cc $1=native -v -c -o $TMPO $TMPC >$TMPE 2>&1 || return
3466                 sed -n "/cc1.*$1=/{
3467                             s/.*$1=\\([^ ]*\\).*/\\1/
3468                             p
3469                             q
3470                         }" $TMPE
3471             }
3472             cpu=$(check_native -march || check_native -mcpu)
3473         ;;
3474     esac
3475
3476     test "${cpu:-host}" = host &&
3477         die "--cpu=host not supported with compiler $cc"
3478 fi
3479
3480 # Deal with common $arch aliases
3481 case "$arch" in
3482     aarch64|arm64)
3483         arch="aarch64"
3484     ;;
3485     arm*)
3486         arch="arm"
3487     ;;
3488     mips*|IP*)
3489         case "$arch" in
3490         *el)
3491             add_cppflags -EL
3492             add_ldflags -EL
3493         ;;
3494         *eb)
3495             add_cppflags -EB
3496             add_ldflags -EB
3497         ;;
3498         esac
3499         arch="mips"
3500     ;;
3501     parisc*|hppa*)
3502         arch="parisc"
3503     ;;
3504     "Power Macintosh"|ppc*|powerpc*)
3505         arch="ppc"
3506     ;;
3507     s390|s390x)
3508         arch="s390"
3509     ;;
3510     sh4|sh)
3511         arch="sh4"
3512     ;;
3513     sun4u|sparc*)
3514         arch="sparc"
3515     ;;
3516     tilegx|tile-gx)
3517         arch="tilegx"
3518     ;;
3519     i[3-6]86|i86pc|BePC|x86pc|x86_64|amd64)
3520         arch="x86"
3521     ;;
3522 esac
3523
3524 is_in $arch $ARCH_LIST || warn "unknown architecture $arch"
3525 enable $arch
3526
3527 # Add processor-specific flags
3528 if enabled aarch64; then
3529
3530     case $cpu in
3531         armv*)
3532             cpuflags="-march=$cpu"
3533         ;;
3534         *)
3535             cpuflags="-mcpu=$cpu"
3536         ;;
3537     esac
3538
3539 elif enabled alpha; then
3540
3541     cpuflags="-mcpu=$cpu"
3542
3543 elif enabled arm; then
3544
3545     check_arm_arch() {
3546         test_cpp_condition stddef.h \
3547             "defined __ARM_ARCH_${1}__ || defined __TARGET_ARCH_${2:-$1}" \
3548             $cpuflags
3549     }
3550
3551     probe_arm_arch() {
3552         if   check_arm_arch 4;        then echo armv4
3553         elif check_arm_arch 4T;       then echo armv4t
3554         elif check_arm_arch 5;        then echo armv5
3555         elif check_arm_arch 5E;       then echo armv5e
3556         elif check_arm_arch 5T;       then echo armv5t
3557         elif check_arm_arch 5TE;      then echo armv5te
3558         elif check_arm_arch 5TEJ;     then echo armv5te
3559         elif check_arm_arch 6;        then echo armv6
3560         elif check_arm_arch 6J;       then echo armv6j
3561         elif check_arm_arch 6K;       then echo armv6k
3562         elif check_arm_arch 6Z;       then echo armv6z
3563         elif check_arm_arch 6ZK;      then echo armv6zk
3564         elif check_arm_arch 6T2;      then echo armv6t2
3565         elif check_arm_arch 7;        then echo armv7
3566         elif check_arm_arch 7A  7_A;  then echo armv7-a
3567         elif check_arm_arch 7S;       then echo armv7-a
3568         elif check_arm_arch 7R  7_R;  then echo armv7-r
3569         elif check_arm_arch 7M  7_M;  then echo armv7-m
3570         elif check_arm_arch 7EM 7E_M; then echo armv7-m
3571         elif check_arm_arch 8A  8_A;  then echo armv8-a
3572         fi
3573     }
3574
3575     [ "$cpu" = generic ] && cpu=$(probe_arm_arch)
3576
3577     case $cpu in
3578         armv*)
3579             cpuflags="-march=$cpu"
3580             subarch=$(echo $cpu | sed 's/[^a-z0-9]//g')
3581         ;;
3582         *)
3583             cpuflags="-mcpu=$cpu"
3584             case $cpu in
3585                 cortex-a*)                               subarch=armv7a  ;;
3586                 cortex-r*)                               subarch=armv7r  ;;
3587                 cortex-m*)                 enable thumb; subarch=armv7m  ;;
3588                 arm11*)                                  subarch=armv6   ;;
3589                 arm[79]*e*|arm9[24]6*|arm96*|arm102[26]) subarch=armv5te ;;
3590                 armv4*|arm7*|arm9[24]*)                  subarch=armv4   ;;
3591                 *)                             subarch=$(probe_arm_arch) ;;
3592             esac
3593         ;;
3594     esac
3595
3596     case "$subarch" in
3597         armv5t*)    enable fast_clz                ;;
3598         armv[6-8]*) enable fast_clz fast_unaligned ;;
3599     esac
3600
3601 elif enabled avr32; then
3602
3603     case $cpu in
3604         ap7[02]0[0-2])
3605             subarch="avr32_ap"
3606             cpuflags="-mpart=$cpu"
3607         ;;
3608         ap)
3609             subarch="avr32_ap"
3610             cpuflags="-march=$cpu"
3611         ;;
3612         uc3[ab]*)
3613             subarch="avr32_uc"
3614             cpuflags="-mcpu=$cpu"
3615         ;;
3616         uc)
3617             subarch="avr32_uc"
3618             cpuflags="-march=$cpu"
3619         ;;
3620     esac
3621
3622 elif enabled bfin; then
3623
3624     cpuflags="-mcpu=$cpu"
3625
3626 elif enabled mips; then
3627
3628     cpuflags="-march=$cpu"
3629
3630 elif enabled ppc; then
3631
3632     disable ldbrx
3633
3634     case $(tolower $cpu) in
3635         601|ppc601|powerpc601)
3636             cpuflags="-mcpu=601"
3637             disable altivec
3638         ;;
3639         603*|ppc603*|powerpc603*)
3640             cpuflags="-mcpu=603"
3641             disable altivec
3642         ;;
3643         604*|ppc604*|powerpc604*)
3644             cpuflags="-mcpu=604"
3645             disable altivec
3646         ;;
3647         g3|75*|ppc75*|powerpc75*)
3648             cpuflags="-mcpu=750"
3649             disable altivec
3650         ;;
3651         g4|745*|ppc745*|powerpc745*)
3652             cpuflags="-mcpu=7450"
3653             disable vsx
3654         ;;
3655         74*|ppc74*|powerpc74*)
3656             cpuflags="-mcpu=7400"
3657             disable vsx
3658         ;;
3659         g5|970|ppc970|powerpc970)
3660             cpuflags="-mcpu=970"
3661             disable vsx
3662         ;;
3663         power[3-6]*)
3664             cpuflags="-mcpu=$cpu"
3665             disable vsx
3666         ;;
3667         power[7-8]*)
3668             cpuflags="-mcpu=$cpu"
3669             enable ldbrx
3670         ;;
3671         cell)
3672             cpuflags="-mcpu=cell"
3673             enable ldbrx
3674             disable vsx
3675         ;;
3676         e500mc)
3677             cpuflags="-mcpu=e500mc"
3678             disable altivec
3679         ;;
3680         e500v2)
3681             cpuflags="-mcpu=8548 -mhard-float -mfloat-gprs=double"
3682             disable altivec
3683             disable dcbzl
3684         ;;
3685         e500)
3686             cpuflags="-mcpu=8540 -mhard-float"
3687             disable altivec
3688             disable dcbzl
3689         ;;
3690     esac
3691
3692 elif enabled sparc; then
3693
3694     case $cpu in
3695         cypress|f93[04]|tsc701|sparcl*|supersparc|hypersparc|niagara|v[789])
3696             cpuflags="-mcpu=$cpu"
3697         ;;
3698         ultrasparc*|niagara[234])
3699             cpuflags="-mcpu=$cpu"
3700         ;;
3701     esac
3702
3703 elif enabled x86; then
3704
3705     case $cpu in
3706         i[345]86|pentium)
3707             cpuflags="-march=$cpu"
3708             disable i686
3709             disable mmx
3710         ;;
3711         # targets that do NOT support nopl and conditional mov (cmov)
3712         pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
3713             cpuflags="-march=$cpu"
3714             disable i686
3715         ;;
3716         # targets that do support nopl and conditional mov (cmov)
3717         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*)
3718             cpuflags="-march=$cpu"
3719             enable i686
3720             enable fast_cmov
3721         ;;
3722         # targets that do support conditional mov but on which it's slow
3723         pentium4|pentium4m|prescott|nocona)
3724             cpuflags="-march=$cpu"
3725             enable i686
3726             disable fast_cmov
3727         ;;
3728     esac
3729
3730 fi
3731
3732 if [ "$cpu" != generic ]; then
3733     add_cflags  $cpuflags
3734     add_asflags $cpuflags
3735     test "$cc_type" = "$ld_type" && add_ldflags $cpuflags
3736 fi
3737
3738 # compiler sanity check
3739 test_exec <<EOF
3740 int main(void){ return 0; }
3741 EOF
3742 if test "$?" != 0; then
3743     echo "$cc is unable to create an executable file."
3744     if test -z "$cross_prefix" && ! enabled cross_compile ; then
3745         echo "If $cc is a cross-compiler, use the --enable-cross-compile option."
3746         echo "Only do this if you know what cross compiling means."
3747     fi
3748     die "C compiler test failed."
3749 fi
3750
3751 add_cppflags -D_ISOC99_SOURCE
3752
3753 # some compilers silently accept -std=c11, so we also need to check that the
3754 # version macro is defined properly
3755 test_cpp_condition stdlib.h  "__STDC_VERSION__ >= 201112L" -std=c11 &&
3756     add_cflags -std=c11 ||
3757     check_cflags -std=c99
3758
3759 check_cppflags -D_FILE_OFFSET_BITS=64
3760 check_cppflags -D_LARGEFILE_SOURCE
3761
3762 add_host_cppflags -D_ISOC99_SOURCE
3763 check_host_cflags -std=c99
3764 check_host_cflags -Wall
3765 check_host_cflags $host_cflags_speed
3766
3767 check_64bit(){
3768     arch32=$1
3769     arch64=$2
3770     expr=${3:-'sizeof(void *) > 4'}
3771     test_code cc "" "int test[2*($expr) - 1]" &&
3772         subarch=$arch64 || subarch=$arch32
3773     enable $subarch
3774 }
3775
3776 case "$arch" in
3777     aarch64|alpha|ia64)
3778         enabled shared && enable_weak pic
3779     ;;
3780     mips)
3781         check_64bit mips mips64 '_MIPS_SIM > 1'
3782         enabled shared && enable_weak pic
3783     ;;
3784     parisc)
3785         check_64bit parisc parisc64
3786         enabled shared && enable_weak pic
3787     ;;
3788     ppc)
3789         check_64bit ppc ppc64
3790         enabled shared && enable_weak pic
3791     ;;
3792     s390)
3793         check_64bit s390 s390x
3794         enabled shared && enable_weak pic
3795     ;;
3796     sparc)
3797         check_64bit sparc sparc64
3798         enabled shared && enable_weak pic
3799     ;;
3800     x86)
3801         check_64bit x86_32 x86_64
3802         if enabled x86_64; then
3803             enabled shared && enable_weak pic
3804             objformat=elf64
3805         fi
3806     ;;
3807 esac
3808
3809 # OS specific
3810 case $target_os in
3811     aix)
3812         SHFLAGS=-shared
3813         add_cppflags '-I\$(SRC_PATH)/compat/aix'
3814         enabled shared && add_ldflags -Wl,-brtl
3815         arflags='-Xany -r -c'
3816         ;;
3817     android)
3818         disable symver
3819         enable section_data_rel_ro
3820         SLIB_INSTALL_NAME='$(SLIBNAME)'
3821         SLIB_INSTALL_LINKS=
3822         SHFLAGS='-shared -Wl,-soname,$(SLIBNAME)'
3823         ;;
3824     haiku)
3825         prefix_default="/boot/common"
3826         network_extralibs="-lnetwork"
3827         host_extralibs=
3828         ;;
3829     sunos)
3830         SHFLAGS='-shared -Wl,-h,$$(@F)'
3831         enabled x86 && append SHFLAGS -mimpure-text
3832         network_extralibs="-lsocket -lnsl"
3833         # When using suncc to build, the Solaris linker will mark
3834         # an executable with each instruction set encountered by
3835         # the Solaris assembler.  As our libraries contain their own
3836         # guards for processor-specific code, instead suppress
3837         # generation of the HWCAPS ELF section on Solaris x86 only.
3838         enabled_all suncc x86 &&
3839             echo "hwcap_1 = OVERRIDE;" > mapfile &&
3840             add_ldflags -Wl,-M,mapfile
3841         nm_default='nm -P -g'
3842         version_script='-M'
3843         VERSION_SCRIPT_POSTPROCESS_CMD='perl $(SRC_PATH)/compat/solaris/make_sunver.pl - $(OBJS)'
3844         ;;
3845     netbsd)
3846         disable symver
3847         oss_indev_extralibs="-lossaudio"
3848         ;;
3849     openbsd|bitrig)
3850         disable symver
3851         SHFLAGS='-shared'
3852         SLIB_INSTALL_NAME='$(SLIBNAME).$(LIBMAJOR).$(LIBMINOR)'
3853         SLIB_INSTALL_LINKS=
3854         oss_indev_extralibs="-lossaudio"
3855         ;;
3856     dragonfly)
3857         disable symver
3858         ;;
3859     freebsd)
3860         ;;
3861     bsd/os)
3862         add_extralibs -lpoll -lgnugetopt
3863         ;;
3864     darwin)
3865         enabled ppc && add_asflags -force_cpusubtype_ALL
3866         SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR),-current_version,$(LIBVERSION),-compatibility_version,$(LIBMAJOR)'
3867         enabled x86_32 && append SHFLAGS -Wl,-read_only_relocs,suppress
3868         add_ldflags -Wl,-dynamic,-search_paths_first
3869         check_cflags -Werror=partial-availability
3870         SLIBSUF=".dylib"
3871         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME).$(LIBVERSION)$(SLIBSUF)'
3872         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(NAME).$(LIBMAJOR)$(SLIBSUF)'
3873         enabled x86_64 && objformat="macho64" || objformat="macho32"
3874         enabled_any pic shared ||
3875             { check_cflags -mdynamic-no-pic && add_asflags -mdynamic-no-pic; }
3876         check_header dispatch/dispatch.h &&
3877             add_cppflags '-I\$(SRC_PATH)/compat/dispatch_semaphore'
3878         if test -n "$sysroot"; then
3879             is_in -isysroot $cc $CPPFLAGS $CFLAGS || check_cppflags -isysroot $sysroot
3880             is_in -isysroot $ld $LDFLAGS          || check_ldflags  -isysroot $sysroot
3881         fi
3882         ;;
3883     msys*)
3884         die "Native MSYS builds are discouraged, please use the MINGW environment."
3885         ;;
3886     mingw32*|mingw64*)
3887         target_os=mingw32
3888         LIBTARGET=i386
3889         if enabled x86_64; then
3890             LIBTARGET="i386:x86-64"
3891         elif enabled arm; then
3892             LIBTARGET="arm"
3893         elif enabled aarch64; then
3894             LIBTARGET="arm64"
3895         fi
3896         if enabled shared; then
3897             # Cannot build both shared and static libs when using dllimport.
3898             disable static
3899         fi
3900         check_ldflags -Wl,--nxcompat
3901         check_ldflags -Wl,--dynamicbase
3902         shlibdir_default="$bindir_default"
3903         SLIBPREF=""
3904         SLIBSUF=".dll"
3905         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
3906         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(NAME)-$(LIBMAJOR)$(SLIBSUF)'
3907         SLIB_EXTRA_CMD=-'$(DLLTOOL) -m $(LIBTARGET) -d $$(@:$(SLIBSUF)=.def) -l $(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib) -D $(SLIBNAME_WITH_MAJOR)'
3908         SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
3909         SLIB_INSTALL_LINKS=
3910         SLIB_INSTALL_EXTRA_SHLIB='$(SLIBNAME:$(SLIBSUF)=.lib)'
3911         SLIB_INSTALL_EXTRA_LIB='lib$(SLIBNAME:$(SLIBSUF)=.dll.a) $(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.def)'
3912         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)'
3913         SHFLAGS='-shared -Wl,--out-implib,$(SUBDIR)lib$(SLIBNAME:$(SLIBSUF)=.dll.a) -Wl,--enable-auto-image-base $$(@:$(SLIBSUF)=.def)'
3914         enabled x86_64 && objformat="win64" || objformat="win32"
3915         dlltool="${cross_prefix}dlltool"
3916         ranlib=:
3917         enable dos_paths
3918         ;;
3919     win32|win64)
3920         disable symver
3921         if enabled shared; then
3922             # Link to the import library instead of the normal static library
3923             # for shared libs.
3924             LD_LIB='%.lib'
3925             # Cannot build both shared and static libs with MSVC or icl.
3926             disable static
3927         fi
3928         shlibdir_default="$bindir_default"
3929         SLIBPREF=""
3930         SLIBSUF=".dll"
3931         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
3932         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(NAME)-$(LIBMAJOR)$(SLIBSUF)'
3933         SLIB_CREATE_DEF_CMD='EXTERN_PREFIX="$(EXTERN_PREFIX)" $(SRC_PATH)/compat/windows/makedef $(SUBDIR)lib$(NAME).ver $(OBJS) > $$(@:$(SLIBSUF)=.def)'
3934         SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
3935         SLIB_INSTALL_LINKS=
3936         SLIB_INSTALL_EXTRA_SHLIB='$(SLIBNAME:$(SLIBSUF)=.lib)'
3937         SLIB_INSTALL_EXTRA_LIB='$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.def)'
3938         SHFLAGS='-dll -def:$$(@:$(SLIBSUF)=.def) -implib:$(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib)'
3939         enabled x86_64 && objformat="win64" || objformat="win32"
3940         ranlib=:
3941         enable dos_paths
3942         ;;
3943     cygwin*)
3944         target_os=cygwin
3945         shlibdir_default="$bindir_default"
3946         SLIBPREF="cyg"
3947         SLIBSUF=".dll"
3948         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
3949         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(NAME)-$(LIBMAJOR)$(SLIBSUF)'
3950         SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
3951         SLIB_INSTALL_LINKS=
3952         SLIB_INSTALL_EXTRA_LIB='lib$(NAME).dll.a'
3953         SHFLAGS='-shared -Wl,--out-implib,$(SUBDIR)lib$(NAME).dll.a'
3954         enabled x86_64 && objformat="win64" || objformat="win32"
3955         enable dos_paths
3956         ;;
3957     *-dos|freedos|opendos)
3958         network_extralibs="-lsocket"
3959         objformat="coff"
3960         enable dos_paths
3961         add_cppflags -U__STRICT_ANSI__
3962         ;;
3963     linux)
3964         enable section_data_rel_ro
3965         ;;
3966     irix*)
3967         target_os=irix
3968         ranlib="echo ignoring ranlib"
3969         ;;
3970     os/2*)
3971         ln_s="cp -f"
3972         objformat="aout"
3973         add_cppflags -D_GNU_SOURCE
3974         add_ldflags -Zomf -Zbin-files -Zargs-wild -Zhigh-mem -Zmap
3975         SHFLAGS='$(SUBDIR)$(NAME).def -Zdll -Zomf'
3976         LIBSUF="_s.a"
3977         SLIBPREF=""
3978         SLIBSUF=".dll"
3979         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
3980         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(shell echo $(NAME) | cut -c1-6)$(LIBMAJOR)$(SLIBSUF)'
3981         SLIB_CREATE_DEF_CMD='echo LIBRARY $(SLIBNAME_WITH_MAJOR) INITINSTANCE TERMINSTANCE > $(SUBDIR)$(NAME).def; \
3982             echo CODE PRELOAD MOVEABLE DISCARDABLE >> $(SUBDIR)$(NAME).def; \
3983             echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $(SUBDIR)$(NAME).def; \
3984             echo EXPORTS >> $(SUBDIR)$(NAME).def; \
3985             emxexp $(OBJS) >> $(SUBDIR)$(NAME).def'
3986         SLIB_EXTRA_CMD='emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(NAME).def; \
3987             emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib $(SUBDIR)$(NAME).def;'
3988         SLIB_INSTALL_EXTRA_LIB='$(LIBPREF)$(NAME)_dll.a $(LIBPREF)$(NAME)_dll.lib'
3989         enable dos_paths
3990         ;;
3991     gnu/kfreebsd)
3992         add_cppflags -D_BSD_SOURCE
3993         ;;
3994     gnu)
3995         ;;
3996     qnx)
3997         add_cppflags -D_QNX_SOURCE
3998         network_extralibs="-lsocket"
3999         ;;
4000     symbian)
4001         SLIBSUF=".dll"
4002         enable dos_paths
4003         add_cflags --include=$sysinclude/gcce/gcce.h -fvisibility=default
4004         add_cppflags -D__GCCE__ -D__SYMBIAN32__ -DSYMBIAN_OE_POSIX_SIGNALS
4005         add_ldflags -Wl,--target1-abs,--no-undefined \
4006                     -Wl,-Ttext,0x80000,-Tdata,0x1000000 -shared \
4007                     -Wl,--entry=_E32Startup -Wl,-u,_E32Startup
4008         add_extralibs -l:eexe.lib -l:usrt2_2.lib -l:dfpaeabi.dso \
4009                       -l:drtaeabi.dso -l:scppnwdl.dso -lsupc++ -lgcc \
4010                       -l:libc.dso -l:libm.dso -l:euser.dso -l:libcrt0.lib
4011         ;;
4012     minix)
4013         ;;
4014     none)
4015         ;;
4016     *)
4017         die "Unknown OS '$target_os'."
4018         ;;
4019 esac
4020
4021 # determine libc flavour
4022
4023 probe_libc(){
4024     pfx=$1
4025     pfx_no_=${pfx%_}
4026     # uclibc defines __GLIBC__, so it needs to be checked before glibc.
4027     if test_${pfx}cpp_condition features.h "defined __UCLIBC__"; then
4028         eval ${pfx}libc_type=uclibc
4029         add_${pfx}cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
4030     elif test_${pfx}cpp_condition features.h "defined __GLIBC__"; then
4031         eval ${pfx}libc_type=glibc
4032         add_${pfx}cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
4033     # MinGW headers can be installed on Cygwin, so check for newlib first.
4034     elif test_${pfx}cpp_condition newlib.h "defined _NEWLIB_VERSION"; then
4035         eval ${pfx}libc_type=newlib
4036         add_${pfx}cppflags -U__STRICT_ANSI__ -D_XOPEN_SOURCE=600
4037     # MinGW64 is backwards compatible with MinGW32, so check for it first.
4038     elif test_${pfx}cpp_condition _mingw.h "defined __MINGW64_VERSION_MAJOR"; then
4039         eval ${pfx}libc_type=mingw64
4040         add_${pfx}cppflags -U__STRICT_ANSI__ -D__USE_MINGW_ANSI_STDIO=1
4041         eval test \$${pfx_no_}cc_type = "gcc" &&
4042             add_${pfx}cppflags -D__printf__=__gnu_printf__
4043     elif test_${pfx}cpp_condition _mingw.h "defined __MINGW_VERSION"  ||
4044          test_${pfx}cpp_condition _mingw.h "defined __MINGW32_VERSION"; then
4045         eval ${pfx}libc_type=mingw32
4046         test_${pfx}cpp_condition _mingw.h "__MINGW32_MAJOR_VERSION > 3 || \
4047             (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" ||
4048             die "ERROR: MinGW32 runtime version must be >= 3.15."
4049         add_${pfx}cppflags -U__STRICT_ANSI__ -D__USE_MINGW_ANSI_STDIO=1
4050         test_${pfx}cpp_condition _mingw.h "__MSVCRT_VERSION__ < 0x0700" &&
4051             add_${pfx}cppflags -D__MSVCRT_VERSION__=0x0700
4052         test_${pfx}cpp_condition windows.h "defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0502" &&
4053             add_${pfx}cppflags -D_WIN32_WINNT=0x0502
4054         eval test \$${pfx_no_}cc_type = "gcc" &&
4055             add_${pfx}cppflags -D__printf__=__gnu_printf__
4056     elif test_${pfx}cpp_condition crtversion.h "defined _VC_CRT_MAJOR_VERSION"; then
4057         eval ${pfx}libc_type=msvcrt
4058         if test_${pfx}cpp_condition crtversion.h "_VC_CRT_MAJOR_VERSION < 14"; then
4059             if [ "$pfx" = host_ ]; then
4060                 add_host_cppflags -Dsnprintf=_snprintf
4061             else
4062                 add_compat strtod.o strtod=avpriv_strtod
4063                 add_compat msvcrt/snprintf.o snprintf=avpriv_snprintf   \
4064                                              _snprintf=avpriv_snprintf  \
4065                                              vsnprintf=avpriv_vsnprintf
4066             fi
4067         fi
4068         add_${pfx}cppflags -D_USE_MATH_DEFINES -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS
4069         # The MSVC 2010 headers (Win 7.0 SDK) set _WIN32_WINNT to
4070         # 0x601 by default unless something else is set by the user.
4071         # This can easily lead to us detecting functions only present
4072         # in such new versions and producing binaries requiring windows 7.0.
4073         # Therefore explicitly set the default to XP unless the user has
4074         # set something else on the command line.
4075         # Don't do this if WINAPI_FAMILY is set and is set to a non-desktop
4076         # family. For these cases, configure is free to use any functions
4077         # found in the SDK headers by default. (Alternatively, we could force
4078         # _WIN32_WINNT to 0x0602 in that case.)
4079         test_${pfx}cpp_condition stdlib.h "defined(_WIN32_WINNT)" ||
4080             { test_${pfx}cpp <<EOF && add_${pfx}cppflags -D_WIN32_WINNT=0x0502; }
4081 #ifdef WINAPI_FAMILY
4082 #include <winapifamily.h>
4083 #if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
4084 #error not desktop
4085 #endif
4086 #endif
4087 EOF
4088         if [ "$pfx" = "" ]; then
4089             check_func strtoll || add_cflags -Dstrtoll=_strtoi64
4090         fi
4091     elif test_${pfx}cpp_condition stddef.h "defined __KLIBC__"; then
4092         eval ${pfx}libc_type=klibc
4093     elif test_${pfx}cpp_condition sys/cdefs.h "defined __BIONIC__"; then
4094         eval ${pfx}libc_type=bionic