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