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