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