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