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