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