Imported Upstream version 6.1
[platform/upstream/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   --disable-pthreads       disable pthreads [autodetect]
136   --disable-w32threads     disable Win32 threads [autodetect]
137   --disable-os2threads     disable OS/2 threads [autodetect]
138   --disable-network        disable network support [no]
139   --disable-dwt            disable DWT code
140   --disable-error-resilience disable error resilience code
141   --disable-lsp            disable LSP code
142   --disable-faan           disable floating point AAN (I)DCT code
143   --disable-pixelutils     disable pixel utils in libavutil
144
145 Individual component options:
146   --disable-everything     disable all components listed below
147   --disable-encoder=NAME   disable encoder NAME
148   --enable-encoder=NAME    enable encoder NAME
149   --disable-encoders       disable all encoders
150   --disable-decoder=NAME   disable decoder NAME
151   --enable-decoder=NAME    enable decoder NAME
152   --disable-decoders       disable all decoders
153   --disable-hwaccel=NAME   disable hwaccel NAME
154   --enable-hwaccel=NAME    enable hwaccel NAME
155   --disable-hwaccels       disable all hwaccels
156   --disable-muxer=NAME     disable muxer NAME
157   --enable-muxer=NAME      enable muxer NAME
158   --disable-muxers         disable all muxers
159   --disable-demuxer=NAME   disable demuxer NAME
160   --enable-demuxer=NAME    enable demuxer NAME
161   --disable-demuxers       disable all demuxers
162   --enable-parser=NAME     enable parser NAME
163   --disable-parser=NAME    disable parser NAME
164   --disable-parsers        disable all parsers
165   --enable-bsf=NAME        enable bitstream filter NAME
166   --disable-bsf=NAME       disable bitstream filter NAME
167   --disable-bsfs           disable all bitstream filters
168   --enable-protocol=NAME   enable protocol NAME
169   --disable-protocol=NAME  disable protocol NAME
170   --disable-protocols      disable all protocols
171   --enable-indev=NAME      enable input device NAME
172   --disable-indev=NAME     disable input device NAME
173   --disable-indevs         disable input devices
174   --enable-outdev=NAME     enable output device NAME
175   --disable-outdev=NAME    disable output device NAME
176   --disable-outdevs        disable output devices
177   --disable-devices        disable all devices
178   --enable-filter=NAME     enable filter NAME
179   --disable-filter=NAME    disable filter NAME
180   --disable-filters        disable all filters
181
182 External library support:
183
184   Using any of the following switches will allow FFmpeg to link to the
185   corresponding external library. All the components depending on that library
186   will become enabled, if all their other dependencies are met and they are not
187   explicitly disabled. E.g. --enable-libopus will enable linking to
188   libopus and allow the libopus encoder to be built, unless it is
189   specifically disabled with --disable-encoder=libopus.
190
191   Note that only the system libraries are auto-detected. All the other external
192   libraries must be explicitly enabled.
193
194   Also note that the following help text describes the purpose of the libraries
195   themselves, not all their features will necessarily be usable by FFmpeg.
196
197   --disable-alsa           disable ALSA support [autodetect]
198   --disable-appkit         disable Apple AppKit framework [autodetect]
199   --disable-avfoundation   disable Apple AVFoundation framework [autodetect]
200   --enable-avisynth        enable reading of AviSynth script files [no]
201   --disable-bzlib          disable bzlib [autodetect]
202   --disable-coreimage      disable Apple CoreImage framework [autodetect]
203   --enable-chromaprint     enable audio fingerprinting with chromaprint [no]
204   --enable-frei0r          enable frei0r video filtering [no]
205   --enable-gcrypt          enable gcrypt, needed for rtmp(t)e support
206                            if openssl, librtmp or gmp is not used [no]
207   --enable-gmp             enable gmp, needed for rtmp(t)e support
208                            if openssl or librtmp is not used [no]
209   --enable-gnutls          enable gnutls, needed for https support
210                            if openssl, libtls or mbedtls is not used [no]
211   --disable-iconv          disable iconv [autodetect]
212   --enable-jni             enable JNI support [no]
213   --enable-ladspa          enable LADSPA audio filtering [no]
214   --enable-lcms2           enable ICC profile support via LittleCMS 2 [no]
215   --enable-libaom          enable AV1 video encoding/decoding via libaom [no]
216   --enable-libaribb24      enable ARIB text and caption decoding via libaribb24 [no]
217   --enable-libaribcaption  enable ARIB text and caption decoding via libaribcaption [no]
218   --enable-libass          enable libass subtitles rendering,
219                            needed for subtitles and ass filter [no]
220   --enable-libbluray       enable BluRay reading using libbluray [no]
221   --enable-libbs2b         enable bs2b DSP library [no]
222   --enable-libcaca         enable textual display using libcaca [no]
223   --enable-libcelt         enable CELT decoding via libcelt [no]
224   --enable-libcdio         enable audio CD grabbing with libcdio [no]
225   --enable-libcodec2       enable codec2 en/decoding using libcodec2 [no]
226   --enable-libdav1d        enable AV1 decoding via libdav1d [no]
227   --enable-libdavs2        enable AVS2 decoding via libdavs2 [no]
228   --enable-libdc1394       enable IIDC-1394 grabbing using libdc1394
229                            and libraw1394 [no]
230   --enable-libfdk-aac      enable AAC de/encoding via libfdk-aac [no]
231   --enable-libflite        enable flite (voice synthesis) support via libflite [no]
232   --enable-libfontconfig   enable libfontconfig, useful for drawtext filter [no]
233   --enable-libfreetype     enable libfreetype, needed for drawtext filter [no]
234   --enable-libfribidi      enable libfribidi, improves drawtext filter [no]
235   --enable-libharfbuzz     enable libharfbuzz, needed for drawtext filter [no]
236   --enable-libglslang      enable GLSL->SPIRV compilation via libglslang [no]
237   --enable-libgme          enable Game Music Emu via libgme [no]
238   --enable-libgsm          enable GSM de/encoding via libgsm [no]
239   --enable-libiec61883     enable iec61883 via libiec61883 [no]
240   --enable-libilbc         enable iLBC de/encoding via libilbc [no]
241   --enable-libjack         enable JACK audio sound server [no]
242   --enable-libjxl          enable JPEG XL de/encoding via libjxl [no]
243   --enable-libklvanc       enable Kernel Labs VANC processing [no]
244   --enable-libkvazaar      enable HEVC encoding via libkvazaar [no]
245   --enable-liblensfun      enable lensfun lens correction [no]
246   --enable-libmodplug      enable ModPlug via libmodplug [no]
247   --enable-libmp3lame      enable MP3 encoding via libmp3lame [no]
248   --enable-libopencore-amrnb enable AMR-NB de/encoding via libopencore-amrnb [no]
249   --enable-libopencore-amrwb enable AMR-WB decoding via libopencore-amrwb [no]
250   --enable-libopencv       enable video filtering via libopencv [no]
251   --enable-libopenh264     enable H.264 encoding via OpenH264 [no]
252   --enable-libopenjpeg     enable JPEG 2000 de/encoding via OpenJPEG [no]
253   --enable-libopenmpt      enable decoding tracked files via libopenmpt [no]
254   --enable-libopenvino     enable OpenVINO as a DNN module backend
255                            for DNN based filters like dnn_processing [no]
256   --enable-libopus         enable Opus de/encoding via libopus [no]
257   --enable-libplacebo      enable libplacebo library [no]
258   --enable-libpulse        enable Pulseaudio input via libpulse [no]
259   --enable-librabbitmq     enable RabbitMQ library [no]
260   --enable-librav1e        enable AV1 encoding via rav1e [no]
261   --enable-librist         enable RIST via librist [no]
262   --enable-librsvg         enable SVG rasterization via librsvg [no]
263   --enable-librubberband   enable rubberband needed for rubberband filter [no]
264   --enable-librtmp         enable RTMP[E] support via librtmp [no]
265   --enable-libshaderc      enable GLSL->SPIRV compilation via libshaderc [no]
266   --enable-libshine        enable fixed-point MP3 encoding via libshine [no]
267   --enable-libsmbclient    enable Samba protocol via libsmbclient [no]
268   --enable-libsnappy       enable Snappy compression, needed for hap encoding [no]
269   --enable-libsoxr         enable Include libsoxr resampling [no]
270   --enable-libspeex        enable Speex de/encoding via libspeex [no]
271   --enable-libsrt          enable Haivision SRT protocol via libsrt [no]
272   --enable-libssh          enable SFTP protocol via libssh [no]
273   --enable-libsvtav1       enable AV1 encoding via SVT [no]
274   --enable-libtensorflow   enable TensorFlow as a DNN module backend
275                            for DNN based filters like sr [no]
276   --enable-libtesseract    enable Tesseract, needed for ocr filter [no]
277   --enable-libtheora       enable Theora encoding via libtheora [no]
278   --enable-libtls          enable LibreSSL (via libtls), needed for https support
279                            if openssl, gnutls or mbedtls is not used [no]
280   --enable-libtwolame      enable MP2 encoding via libtwolame [no]
281   --enable-libuavs3d       enable AVS3 decoding via libuavs3d [no]
282   --enable-libv4l2         enable libv4l2/v4l-utils [no]
283   --enable-libvidstab      enable video stabilization using vid.stab [no]
284   --enable-libvmaf         enable vmaf filter via libvmaf [no]
285   --enable-libvo-amrwbenc  enable AMR-WB encoding via libvo-amrwbenc [no]
286   --enable-libvorbis       enable Vorbis en/decoding via libvorbis,
287                            native implementation exists [no]
288   --enable-libvpx          enable VP8 and VP9 de/encoding via libvpx [no]
289   --enable-libwebp         enable WebP encoding via libwebp [no]
290   --enable-libx264         enable H.264 encoding via x264 [no]
291   --enable-libx265         enable HEVC encoding via x265 [no]
292   --enable-libxavs         enable AVS encoding via xavs [no]
293   --enable-libxavs2        enable AVS2 encoding via xavs2 [no]
294   --enable-libxcb          enable X11 grabbing using XCB [autodetect]
295   --enable-libxcb-shm      enable X11 grabbing shm communication [autodetect]
296   --enable-libxcb-xfixes   enable X11 grabbing mouse rendering [autodetect]
297   --enable-libxcb-shape    enable X11 grabbing shape rendering [autodetect]
298   --enable-libxvid         enable Xvid encoding via xvidcore,
299                            native MPEG-4/Xvid encoder exists [no]
300   --enable-libxml2         enable XML parsing using the C library libxml2, needed
301                            for dash and imf demuxing support [no]
302   --enable-libzimg         enable z.lib, needed for zscale filter [no]
303   --enable-libzmq          enable message passing via libzmq [no]
304   --enable-libzvbi         enable teletext support via libzvbi [no]
305   --enable-lv2             enable LV2 audio filtering [no]
306   --disable-lzma           disable lzma [autodetect]
307   --enable-decklink        enable Blackmagic DeckLink I/O support [no]
308   --enable-mbedtls         enable mbedTLS, needed for https support
309                            if openssl, gnutls or libtls is not used [no]
310   --enable-mediacodec      enable Android MediaCodec support [no]
311   --enable-mediafoundation enable encoding via MediaFoundation [auto]
312   --disable-metal          disable Apple Metal framework [autodetect]
313   --enable-libmysofa       enable libmysofa, needed for sofalizer filter [no]
314   --enable-openal          enable OpenAL 1.1 capture support [no]
315   --enable-opencl          enable OpenCL processing [no]
316   --enable-opengl          enable OpenGL rendering [no]
317   --enable-openssl         enable openssl, needed for https support
318                            if gnutls, libtls or mbedtls is not used [no]
319   --enable-pocketsphinx    enable PocketSphinx, needed for asr filter [no]
320   --disable-sndio          disable sndio support [autodetect]
321   --disable-schannel       disable SChannel SSP, needed for TLS support on
322                            Windows if openssl and gnutls are not used [autodetect]
323   --disable-sdl2           disable sdl2 [autodetect]
324   --disable-securetransport disable Secure Transport, needed for TLS support
325                            on OSX if openssl and gnutls are not used [autodetect]
326   --enable-vapoursynth     enable VapourSynth demuxer [no]
327   --disable-xlib           disable xlib [autodetect]
328   --disable-zlib           disable zlib [autodetect]
329
330   The following libraries provide various hardware acceleration features:
331   --disable-amf            disable AMF video encoding code [autodetect]
332   --disable-audiotoolbox   disable Apple AudioToolbox code [autodetect]
333   --enable-cuda-nvcc       enable Nvidia CUDA compiler [no]
334   --disable-cuda-llvm      disable CUDA compilation using clang [autodetect]
335   --disable-cuvid          disable Nvidia CUVID support [autodetect]
336   --disable-d3d11va        disable Microsoft Direct3D 11 video acceleration code [autodetect]
337   --disable-dxva2          disable Microsoft DirectX 9 video acceleration code [autodetect]
338   --disable-ffnvcodec      disable dynamically linked Nvidia code [autodetect]
339   --enable-libdrm          enable DRM code (Linux) [no]
340   --enable-libmfx          enable Intel MediaSDK (AKA Quick Sync Video) code via libmfx [no]
341   --enable-libvpl          enable Intel oneVPL code via libvpl if libmfx is not used [no]
342   --enable-libnpp          enable Nvidia Performance Primitives-based code [no]
343   --enable-mmal            enable Broadcom Multi-Media Abstraction Layer (Raspberry Pi) via MMAL [no]
344   --disable-nvdec          disable Nvidia video decoding acceleration (via hwaccel) [autodetect]
345   --disable-nvenc          disable Nvidia video encoding code [autodetect]
346   --enable-omx             enable OpenMAX IL code [no]
347   --enable-omx-rpi         enable OpenMAX IL code for Raspberry Pi [no]
348   --enable-rkmpp           enable Rockchip Media Process Platform code [no]
349   --disable-v4l2-m2m       disable V4L2 mem2mem code [autodetect]
350   --disable-vaapi          disable Video Acceleration API (mainly Unix/Intel) code [autodetect]
351   --disable-vdpau          disable Nvidia Video Decode and Presentation API for Unix code [autodetect]
352   --disable-videotoolbox   disable VideoToolbox code [autodetect]
353   --disable-vulkan         disable Vulkan code [autodetect]
354
355 Toolchain options:
356   --arch=ARCH              select architecture [$arch]
357   --cpu=CPU                select the minimum required CPU (affects
358                            instruction selection, may crash on older CPUs)
359   --cross-prefix=PREFIX    use PREFIX for compilation tools [$cross_prefix]
360   --progs-suffix=SUFFIX    program name suffix []
361   --enable-cross-compile   assume a cross-compiler is used
362   --sysroot=PATH           root of cross-build tree
363   --sysinclude=PATH        location of cross-build system headers
364   --target-os=OS           compiler targets OS [$target_os]
365   --target-exec=CMD        command to run executables on target
366   --target-path=DIR        path to view of build directory on target
367   --target-samples=DIR     path to samples directory on target
368   --tempprefix=PATH        force fixed dir/prefix instead of mktemp for checks
369   --toolchain=NAME         set tool defaults according to NAME
370                            (gcc-asan, clang-asan, gcc-msan, clang-msan,
371                            gcc-tsan, clang-tsan, gcc-usan, clang-usan,
372                            valgrind-massif, valgrind-memcheck,
373                            msvc, icl, gcov, llvm-cov, hardened)
374   --nm=NM                  use nm tool NM [$nm_default]
375   --ar=AR                  use archive tool AR [$ar_default]
376   --as=AS                  use assembler AS [$as_default]
377   --ln_s=LN_S              use symbolic link tool LN_S [$ln_s_default]
378   --strip=STRIP            use strip tool STRIP [$strip_default]
379   --windres=WINDRES        use windows resource compiler WINDRES [$windres_default]
380   --x86asmexe=EXE          use nasm-compatible assembler EXE [$x86asmexe_default]
381   --cc=CC                  use C compiler CC [$cc_default]
382   --cxx=CXX                use C compiler CXX [$cxx_default]
383   --objcc=OCC              use ObjC compiler OCC [$cc_default]
384   --dep-cc=DEPCC           use dependency generator DEPCC [$cc_default]
385   --nvcc=NVCC              use Nvidia CUDA compiler NVCC or clang [$nvcc_default]
386   --ld=LD                  use linker LD [$ld_default]
387   --metalcc=METALCC        use metal compiler METALCC [$metalcc_default]
388   --metallib=METALLIB      use metal linker METALLIB [$metallib_default]
389   --pkg-config=PKGCONFIG   use pkg-config tool PKGCONFIG [$pkg_config_default]
390   --pkg-config-flags=FLAGS pass additional flags to pkgconf []
391   --ranlib=RANLIB          use ranlib RANLIB [$ranlib_default]
392   --doxygen=DOXYGEN        use DOXYGEN to generate API doc [$doxygen_default]
393   --host-cc=HOSTCC         use host C compiler HOSTCC
394   --host-cflags=HCFLAGS    use HCFLAGS when compiling for host
395   --host-cppflags=HCPPFLAGS use HCPPFLAGS when compiling for host
396   --host-ld=HOSTLD         use host linker HOSTLD
397   --host-ldflags=HLDFLAGS  use HLDFLAGS when linking for host
398   --host-extralibs=HLIBS   use libs HLIBS when linking for host
399   --host-os=OS             compiler host OS [$target_os]
400   --extra-cflags=ECFLAGS   add ECFLAGS to CFLAGS [$CFLAGS]
401   --extra-cxxflags=ECFLAGS add ECFLAGS to CXXFLAGS [$CXXFLAGS]
402   --extra-objcflags=FLAGS  add FLAGS to OBJCFLAGS [$CFLAGS]
403   --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]
404   --extra-ldexeflags=ELDFLAGS add ELDFLAGS to LDEXEFLAGS [$LDEXEFLAGS]
405   --extra-ldsoflags=ELDFLAGS add ELDFLAGS to LDSOFLAGS [$LDSOFLAGS]
406   --extra-libs=ELIBS       add ELIBS [$ELIBS]
407   --extra-version=STRING   version string suffix []
408   --optflags=OPTFLAGS      override optimization-related compiler flags
409   --nvccflags=NVCCFLAGS    override nvcc flags [$nvccflags_default]
410   --build-suffix=SUFFIX    library name suffix []
411   --enable-pic             build position-independent code
412   --enable-thumb           compile for Thumb instruction set
413   --enable-lto[=arg]       use link-time optimization
414   --env="ENV=override"     override the environment variables
415
416 Advanced options (experts only):
417   --malloc-prefix=PREFIX   prefix malloc and related names with PREFIX
418   --custom-allocator=NAME  use a supported custom allocator
419   --disable-symver         disable symbol versioning
420   --enable-hardcoded-tables use hardcoded tables instead of runtime generation
421   --disable-safe-bitstream-reader
422                            disable buffer boundary checking in bitreaders
423                            (faster, but may crash)
424   --sws-max-filter-size=N  the max filter size swscale uses [$sws_max_filter_size_default]
425
426 Optimization options (experts only):
427   --disable-asm            disable all assembly optimizations
428   --disable-altivec        disable AltiVec optimizations
429   --disable-vsx            disable VSX optimizations
430   --disable-power8         disable POWER8 optimizations
431   --disable-amd3dnow       disable 3DNow! optimizations
432   --disable-amd3dnowext    disable 3DNow! extended optimizations
433   --disable-mmx            disable MMX optimizations
434   --disable-mmxext         disable MMXEXT optimizations
435   --disable-sse            disable SSE optimizations
436   --disable-sse2           disable SSE2 optimizations
437   --disable-sse3           disable SSE3 optimizations
438   --disable-ssse3          disable SSSE3 optimizations
439   --disable-sse4           disable SSE4 optimizations
440   --disable-sse42          disable SSE4.2 optimizations
441   --disable-avx            disable AVX optimizations
442   --disable-xop            disable XOP optimizations
443   --disable-fma3           disable FMA3 optimizations
444   --disable-fma4           disable FMA4 optimizations
445   --disable-avx2           disable AVX2 optimizations
446   --disable-avx512         disable AVX-512 optimizations
447   --disable-avx512icl      disable AVX-512ICL optimizations
448   --disable-aesni          disable AESNI optimizations
449   --disable-armv5te        disable armv5te optimizations
450   --disable-armv6          disable armv6 optimizations
451   --disable-armv6t2        disable armv6t2 optimizations
452   --disable-vfp            disable VFP optimizations
453   --disable-neon           disable NEON optimizations
454   --disable-dotprod        disable DOTPROD optimizations
455   --disable-i8mm           disable I8MM optimizations
456   --disable-inline-asm     disable use of inline assembly
457   --disable-x86asm         disable use of standalone x86 assembly
458   --disable-mipsdsp        disable MIPS DSP ASE R1 optimizations
459   --disable-mipsdspr2      disable MIPS DSP ASE R2 optimizations
460   --disable-msa            disable MSA optimizations
461   --disable-mipsfpu        disable floating point MIPS optimizations
462   --disable-mmi            disable Loongson MMI optimizations
463   --disable-lsx            disable Loongson LSX optimizations
464   --disable-lasx           disable Loongson LASX optimizations
465   --disable-rvv            disable RISC-V Vector optimizations
466   --disable-fast-unaligned consider unaligned accesses slow
467
468 Developer options (useful when working on FFmpeg itself):
469   --disable-debug          disable debugging symbols
470   --enable-debug=LEVEL     set the debug level [$debuglevel]
471   --disable-optimizations  disable compiler optimizations
472   --enable-extra-warnings  enable more compiler warnings
473   --disable-stripping      disable stripping of executables and shared libraries
474   --assert-level=level     0(default), 1 or 2, amount of assertion testing,
475                            2 causes a slowdown at runtime.
476   --enable-memory-poisoning fill heap uninitialized allocated space with arbitrary data
477   --valgrind=VALGRIND      run "make fate" tests through valgrind to detect memory
478                            leaks and errors, using the specified valgrind binary.
479                            Cannot be combined with --target-exec
480   --enable-ftrapv          Trap arithmetic overflows
481   --samples=PATH           location of test samples for FATE, if not set use
482                            \$FATE_SAMPLES at make invocation time.
483   --enable-neon-clobber-test check NEON registers for clobbering (should be
484                            used only for debugging purposes)
485   --enable-xmm-clobber-test check XMM registers for clobbering (Win64-only;
486                            should be used only for debugging purposes)
487   --enable-random          randomly enable/disable components
488   --disable-random
489   --enable-random=LIST     randomly enable/disable specific components or
490   --disable-random=LIST    component groups. LIST is a comma-separated list
491                            of NAME[:PROB] entries where NAME is a component
492                            (group) and PROB the probability associated with
493                            NAME (default 0.5).
494   --random-seed=VALUE      seed value for --enable/disable-random
495   --disable-valgrind-backtrace do not print a backtrace under Valgrind
496                            (only applies to --disable-optimizations builds)
497   --enable-ossfuzz         Enable building fuzzer tool
498   --libfuzzer=PATH         path to libfuzzer
499   --ignore-tests=TESTS     comma-separated list (without "fate-" prefix
500                            in the name) of tests whose result is ignored
501   --enable-linux-perf      enable Linux Performance Monitor API
502   --enable-macos-kperf     enable macOS kperf (private) API
503   --disable-large-tests    disable tests that use a large amount of memory
504   --disable-ptx-compression don't compress CUDA PTX code even when possible
505
506 NOTE: Object files are built at the place where configure is launched.
507 EOF
508   exit 0
509 }
510
511 if test -t 1 && which tput >/dev/null 2>&1; then
512     ncolors=$(tput colors)
513     if test -n "$ncolors" && test $ncolors -ge 8; then
514         bold_color=$(tput bold)
515         warn_color=$(tput setaf 3)
516         error_color=$(tput setaf 1)
517         reset_color=$(tput sgr0)
518     fi
519     # 72 used instead of 80 since that's the default of pr
520     ncols=$(tput cols)
521 fi
522 : ${ncols:=72}
523
524 log(){
525     echo "$@" >> $logfile
526 }
527
528 log_file(){
529     log BEGIN "$1"
530     log_file_i=1
531     while IFS= read -r log_file_line; do
532         printf '%5d\t%s\n' "$log_file_i" "$log_file_line"
533         log_file_i=$(($log_file_i+1))
534     done < "$1" >> "$logfile"
535     log END "$1"
536 }
537
538 warn(){
539     log "WARNING: $*"
540     WARNINGS="${WARNINGS}WARNING: $*\n"
541 }
542
543 die(){
544     log "$@"
545     echo "$error_color$bold_color$@$reset_color"
546     cat <<EOF
547
548 If you think configure made a mistake, make sure you are using the latest
549 version from Git.  If the latest version fails, report the problem to the
550 ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.libera.chat.
551 EOF
552     if disabled logging; then
553         cat <<EOF
554 Rerun configure with logging enabled (do not use --disable-logging), and
555 include the log this produces with your report.
556 EOF
557     else
558         cat <<EOF
559 Include the log file "$logfile" produced by configure as this will help
560 solve the problem.
561 EOF
562     fi
563     exit 1
564 }
565
566 # Avoid locale weirdness, besides we really just want to translate ASCII.
567 toupper(){
568     echo "$@" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
569 }
570
571 tolower(){
572     echo "$@" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
573 }
574
575 c_escape(){
576     echo "$*" | sed 's/["\\]/\\\0/g'
577 }
578
579 sh_quote(){
580     v=$(echo "$1" | sed "s/'/'\\\\''/g")
581     test "x$v" = "x${v#*[!A-Za-z0-9_/.+-]}" || v="'$v'"
582     echo "$v"
583 }
584
585 cleanws(){
586     echo "$@" | sed 's/^ *//;s/[[:space:]][[:space:]]*/ /g;s/ *$//'
587 }
588
589 filter(){
590     pat=$1
591     shift
592     for v; do
593         eval "case '$v' in $pat) printf '%s ' '$v' ;; esac"
594     done
595 }
596
597 filter_out(){
598     pat=$1
599     shift
600     for v; do
601         eval "case '$v' in $pat) ;; *) printf '%s ' '$v' ;; esac"
602     done
603 }
604
605 map(){
606     m=$1
607     shift
608     for v; do eval $m; done
609 }
610
611 add_suffix(){
612     suffix=$1
613     shift
614     for v; do echo ${v}${suffix}; done
615 }
616
617 remove_suffix(){
618     suffix=$1
619     shift
620     for v; do echo ${v%$suffix}; done
621 }
622
623 set_all(){
624     value=$1
625     shift
626     for var in $*; do
627         eval $var=$value
628     done
629 }
630
631 set_weak(){
632     value=$1
633     shift
634     for var; do
635         eval : \${$var:=$value}
636     done
637 }
638
639 sanitize_var_name(){
640     echo $@ | sed 's/[^A-Za-z0-9_]/_/g'
641 }
642
643 set_sanitized(){
644     var=$1
645     shift
646     eval $(sanitize_var_name "$var")='$*'
647 }
648
649 get_sanitized(){
650     eval echo \$$(sanitize_var_name "$1")
651 }
652
653 pushvar(){
654     for pvar in $*; do
655         eval level=\${${pvar}_level:=0}
656         eval ${pvar}_${level}="\$$pvar"
657         eval ${pvar}_level=$(($level+1))
658     done
659 }
660
661 popvar(){
662     for pvar in $*; do
663         eval level=\${${pvar}_level:-0}
664         test $level = 0 && continue
665         eval level=$(($level-1))
666         eval $pvar="\${${pvar}_${level}}"
667         eval ${pvar}_level=$level
668         eval unset ${pvar}_${level}
669     done
670 }
671
672 request(){
673     for var in $*; do
674         eval ${var}_requested=yes
675         eval $var=
676     done
677 }
678
679 warn_if_gets_disabled(){
680     for var in $*; do
681         WARN_IF_GETS_DISABLED_LIST="$WARN_IF_GETS_DISABLED_LIST $var"
682     done
683 }
684
685 enable(){
686     set_all yes $*
687 }
688
689 disable(){
690     set_all no $*
691 }
692
693 disable_with_reason(){
694     disable $1
695     eval "${1}_disable_reason=\"$2\""
696     if requested $1; then
697         die "ERROR: $1 requested, but $2"
698     fi
699 }
700
701 enable_weak(){
702     set_weak yes $*
703 }
704
705 disable_weak(){
706     set_weak no $*
707 }
708
709 enable_sanitized(){
710     for var; do
711         enable $(sanitize_var_name $var)
712     done
713 }
714
715 disable_sanitized(){
716     for var; do
717         disable $(sanitize_var_name $var)
718     done
719 }
720
721 do_enable_deep(){
722     for var; do
723         enabled $var && continue
724         set -- $var
725         eval enable_deep \$${var}_select
726         var=$1
727         eval enable_deep_weak \$${var}_suggest
728     done
729 }
730
731 enable_deep(){
732     do_enable_deep $*
733     enable $*
734 }
735
736 enable_deep_weak(){
737     for var; do
738         disabled $var && continue
739         set -- $var
740         do_enable_deep $var
741         var=$1
742         enable_weak $var
743     done
744 }
745
746 requested(){
747     test "${1#!}" = "$1" && op="=" || op="!="
748     eval test "x\$${1#!}_requested" $op "xyes"
749 }
750
751 enabled(){
752     test "${1#!}" = "$1" && op="=" || op="!="
753     eval test "x\$${1#!}" $op "xyes"
754 }
755
756 disabled(){
757     test "${1#!}" = "$1" && op="=" || op="!="
758     eval test "x\$${1#!}" $op "xno"
759 }
760
761 enabled_all(){
762     for opt; do
763         enabled $opt || return 1
764     done
765 }
766
767 disabled_all(){
768     for opt; do
769         disabled $opt || return 1
770     done
771 }
772
773 enabled_any(){
774     for opt; do
775         enabled $opt && return 0
776     done
777 }
778
779 disabled_any(){
780     for opt; do
781         disabled $opt && return 0
782     done
783     return 1
784 }
785
786 set_default(){
787     for opt; do
788         eval : \${$opt:=\$${opt}_default}
789     done
790 }
791
792 is_in(){
793     value=$1
794     shift
795     for var in $*; do
796         [ $var = $value ] && return 0
797     done
798     return 1
799 }
800
801 # The cfg loop is very hot (several thousands iterations), and in bash also
802 # potentialy quite slow. Try to abort the iterations early, preferably without
803 # calling functions. 70%+ of the time cfg is already done or without deps.
804 check_deps(){
805     for cfg; do
806         eval [ x\$${cfg}_checking = xdone ] && continue
807         eval [ x\$${cfg}_checking = xinprogress ] && die "Circular dependency for $cfg."
808
809         eval "
810         dep_all=\$${cfg}_deps
811         dep_any=\$${cfg}_deps_any
812         dep_con=\$${cfg}_conflict
813         dep_sel=\$${cfg}_select
814         dep_sgs=\$${cfg}_suggest
815         dep_ifa=\$${cfg}_if
816         dep_ifn=\$${cfg}_if_any
817         "
818
819         # most of the time here $cfg has no deps - avoid costly no-op work
820         if [ "$dep_all$dep_any$dep_con$dep_sel$dep_sgs$dep_ifa$dep_ifn" ]; then
821             eval ${cfg}_checking=inprogress
822
823             set -- $cfg "$dep_all" "$dep_any" "$dep_con" "$dep_sel" "$dep_sgs" "$dep_ifa" "$dep_ifn"
824             check_deps $dep_all $dep_any $dep_con $dep_sel $dep_sgs $dep_ifa $dep_ifn
825             cfg=$1; dep_all=$2; dep_any=$3; dep_con=$4; dep_sel=$5 dep_sgs=$6; dep_ifa=$7; dep_ifn=$8
826
827             [ -n "$dep_ifa" ] && { enabled_all $dep_ifa && enable_weak $cfg; }
828             [ -n "$dep_ifn" ] && { enabled_any $dep_ifn && enable_weak $cfg; }
829             enabled_all  $dep_all || { disable_with_reason $cfg "not all dependencies are satisfied: $dep_all"; }
830             enabled_any  $dep_any || { disable_with_reason $cfg "not any dependency is satisfied: $dep_any"; }
831             disabled_all $dep_con || { disable_with_reason $cfg "some conflicting dependencies are unsatisfied: $dep_con"; }
832             disabled_any $dep_sel && { disable_with_reason $cfg "some selected dependency is unsatisfied: $dep_sel"; }
833
834             enabled $cfg && enable_deep_weak $dep_sel $dep_sgs
835
836             for dep in $dep_all $dep_any $dep_sel $dep_sgs; do
837                 # filter out library deps, these do not belong in extralibs
838                 is_in $dep $LIBRARY_LIST && continue
839                 enabled $dep && eval append ${cfg}_extralibs ${dep}_extralibs
840             done
841         fi
842
843         eval ${cfg}_checking=done
844     done
845 }
846
847 print_config(){
848     pfx=$1
849     files=$2
850     shift 2
851     map 'eval echo "$v \${$v:-no}"' "$@" |
852     awk "BEGIN { split(\"$files\", files) }
853         {
854             c = \"$pfx\" toupper(\$1);
855             v = \$2;
856             sub(/yes/, 1, v);
857             sub(/no/,  0, v);
858             for (f in files) {
859                 file = files[f];
860                 if (file ~ /\\.h\$/) {
861                     printf(\"#define %s %d\\n\", c, v) >>file;
862                 } else if (file ~ /\\.asm\$/) {
863                     printf(\"%%define %s %d\\n\", c, v) >>file;
864                 } else if (file ~ /\\.mak\$/) {
865                     n = -v ? \"\" : \"!\";
866                     printf(\"%s%s=yes\\n\", n, c) >>file;
867                 } else if (file ~ /\\.texi\$/) {
868                     pre = -v ? \"\" : \"@c \";
869                     yesno = \$2;
870                     c2 = tolower(c);
871                     gsub(/_/, \"-\", c2);
872                     printf(\"%s@set %s %s\\n\", pre, c2, yesno) >>file;
873                 }
874             }
875         }"
876 }
877
878 print_enabled(){
879     suf=$1
880     shift
881     for v; do
882         enabled $v && printf "%s\n" ${v%$suf}
883     done
884 }
885
886 append(){
887     var=$1
888     shift
889     eval "$var=\"\$$var $*\""
890 }
891
892 prepend(){
893     var=$1
894     shift
895     eval "$var=\"$* \$$var\""
896 }
897
898 reverse () {
899     eval '
900         reverse_out=
901         for v in $'$1'; do
902             reverse_out="$v $reverse_out"
903         done
904         '$1'=$reverse_out
905     '
906 }
907
908 # keeps the last occurence of each non-unique item
909 unique(){
910     unique_out=
911     eval unique_in=\$$1
912     reverse unique_in
913     for v in $unique_in; do
914         # " $unique_out" +space such that every item is surrounded with spaces
915         case " $unique_out" in *" $v "*) continue; esac  # already in list
916         unique_out="$unique_out$v "
917     done
918     reverse unique_out
919     eval $1=\$unique_out
920 }
921
922 resolve(){
923     resolve_out=
924     eval resolve_in=\$$1
925     for v in $resolve_in; do
926         eval 'resolve_out="$resolve_out$'$v' "'
927     done
928     eval $1=\$resolve_out
929 }
930
931 add_cppflags(){
932     append CPPFLAGS "$@"
933 }
934
935 add_cflags(){
936     append CFLAGS $($cflags_filter "$@")
937 }
938
939 add_cflags_headers(){
940     append CFLAGS_HEADERS $($cflags_filter "$@")
941 }
942
943 add_cxxflags(){
944     append CXXFLAGS $($cflags_filter "$@")
945 }
946
947 add_objcflags(){
948     append OBJCFLAGS $($objcflags_filter "$@")
949 }
950
951 add_asflags(){
952     append ASFLAGS $($asflags_filter "$@")
953 }
954
955 add_ldflags(){
956     append LDFLAGS $($ldflags_filter "$@")
957 }
958
959 add_ldexeflags(){
960     append LDEXEFLAGS $($ldflags_filter "$@")
961 }
962
963 add_ldsoflags(){
964     append LDSOFLAGS $($ldflags_filter "$@")
965 }
966
967 add_extralibs(){
968     prepend extralibs $($ldflags_filter "$@")
969 }
970
971 add_stripflags(){
972     append ASMSTRIPFLAGS "$@"
973 }
974
975 add_host_cppflags(){
976     append host_cppflags "$@"
977 }
978
979 add_host_cflags(){
980     append host_cflags $($host_cflags_filter "$@")
981 }
982
983 add_host_ldflags(){
984     append host_ldflags $($host_ldflags_filter "$@")
985 }
986
987 add_compat(){
988     append compat_objs $1
989     shift
990     map 'add_cppflags -D$v' "$@"
991 }
992
993 test_cmd(){
994     log "$@"
995     "$@" >> $logfile 2>&1
996 }
997
998 test_stat(){
999     log test_stat "$@"
1000     stat "$1" >> $logfile 2>&1
1001 }
1002
1003 cc_e(){
1004     eval printf '%s\\n' $CC_E
1005 }
1006
1007 cc_o(){
1008     eval printf '%s\\n' $CC_O
1009 }
1010
1011 as_o(){
1012     eval printf '%s\\n' $AS_O
1013 }
1014
1015 x86asm_o(){
1016     eval printf '%s\\n' $X86ASM_O
1017 }
1018
1019 ld_o(){
1020     eval printf '%s\\n' $LD_O
1021 }
1022
1023 hostcc_e(){
1024     eval printf '%s\\n' $HOSTCC_E
1025 }
1026
1027 hostcc_o(){
1028     eval printf '%s\\n' $HOSTCC_O
1029 }
1030
1031 nvcc_o(){
1032     eval printf '%s\\n' $NVCC_O
1033 }
1034
1035 test_cc(){
1036     log test_cc "$@"
1037     cat > $TMPC
1038     log_file $TMPC
1039     test_cmd $cc $CPPFLAGS $CFLAGS "$@" $CC_C $(cc_o $TMPO) $TMPC
1040 }
1041
1042 test_cxx(){
1043     log test_cxx "$@"
1044     cat > $TMPCPP
1045     log_file $TMPCPP
1046     test_cmd $cxx $CPPFLAGS $CFLAGS $CXXFLAGS "$@" $CXX_C -o $TMPO $TMPCPP
1047 }
1048
1049 test_objcc(){
1050     log test_objcc "$@"
1051     cat > $TMPM
1052     log_file $TMPM
1053     test_cmd $objcc -Werror=missing-prototypes $CPPFLAGS $CFLAGS $OBJCFLAGS "$@" $OBJCC_C $(cc_o $TMPO) $TMPM
1054 }
1055
1056 test_nvcc(){
1057     log test_nvcc "$@"
1058     cat > $TMPCU
1059     log_file $TMPCU
1060     tmpcu_=$TMPCU
1061     tmpo_=$TMPO
1062     [ -x "$(command -v cygpath)" ] && tmpcu_=$(cygpath -m $tmpcu_) && tmpo_=$(cygpath -m $tmpo_)
1063     test_cmd $nvcc $nvccflags "$@" $NVCC_C $(nvcc_o $tmpo_) $tmpcu_
1064 }
1065
1066 check_nvcc() {
1067     log check_nvcc "$@"
1068     name=$1
1069     shift 1
1070     disabled $name && return
1071     disable $name
1072     test_nvcc "$@" <<EOF && enable $name
1073 extern "C" {
1074     __global__ void hello(unsigned char *data) {}
1075 }
1076 EOF
1077 }
1078
1079 test_cpp(){
1080     log test_cpp "$@"
1081     cat > $TMPC
1082     log_file $TMPC
1083     test_cmd $cc $CPPFLAGS $CFLAGS "$@" $(cc_e $TMPO) $TMPC
1084 }
1085
1086 test_as(){
1087     log test_as "$@"
1088     cat > $TMPS
1089     log_file $TMPS
1090     test_cmd $as $CPPFLAGS $ASFLAGS "$@" $AS_C $(as_o $TMPO) $TMPS
1091 }
1092
1093 test_x86asm(){
1094     log test_x86asm "$@"
1095     echo "$1" > $TMPASM
1096     log_file $TMPASM
1097     shift
1098     test_cmd $x86asmexe $X86ASMFLAGS -Werror "$@" $(x86asm_o $TMPO) $TMPASM
1099 }
1100
1101 check_cmd(){
1102     log check_cmd "$@"
1103     cmd=$1
1104     disabled $cmd && return
1105     disable $cmd
1106     test_cmd $@ && enable $cmd
1107 }
1108
1109 check_as(){
1110     log check_as "$@"
1111     name=$1
1112     code=$2
1113     shift 2
1114     disable $name
1115     test_as $@ <<EOF && enable $name
1116 $code
1117 EOF
1118 }
1119
1120 check_inline_asm(){
1121     log check_inline_asm "$@"
1122     name="$1"
1123     code="$2"
1124     shift 2
1125     disable $name
1126     test_cc "$@" <<EOF && enable $name
1127 void foo(void){ __asm__ volatile($code); }
1128 EOF
1129 }
1130
1131 check_inline_asm_flags(){
1132     log check_inline_asm_flags "$@"
1133     name="$1"
1134     code="$2"
1135     flags=''
1136     shift 2
1137     while [ "$1" != "" ]; do
1138       append flags $1
1139       shift
1140     done;
1141     disable $name
1142     cat > $TMPC <<EOF
1143 void foo(void){ __asm__ volatile($code); }
1144 EOF
1145     log_file $TMPC
1146     test_cmd $cc $CPPFLAGS $CFLAGS $flags "$@" $CC_C $(cc_o $TMPO) $TMPC &&
1147     enable $name && add_cflags $flags && add_asflags $flags && add_ldflags $flags
1148 }
1149
1150 check_insn(){
1151     log check_insn "$@"
1152     check_inline_asm ${1}_inline "\"$2\""
1153     check_as ${1}_external "$2"
1154 }
1155
1156 check_arch_level(){
1157     log check_arch_level "$@"
1158     level="$1"
1159     check_as tested_arch_level ".arch $level"
1160     enabled tested_arch_level && as_arch_level="$level"
1161 }
1162
1163 check_archext_insn(){
1164     log check_archext_insn "$@"
1165     feature="$1"
1166     instr="$2"
1167     # Check if the assembly is accepted in inline assembly.
1168     check_inline_asm ${feature}_inline "\"$instr\""
1169     # We don't check if the instruction is supported out of the box by the
1170     # external assembler (we don't try to set ${feature}_external) as we don't
1171     # need to use these instructions in non-runtime detected codepaths.
1172
1173     disable $feature
1174
1175     enabled as_arch_directive && arch_directive=".arch $as_arch_level" || arch_directive=""
1176
1177     # Test if the assembler supports the .arch_extension $feature directive.
1178     arch_extension_directive=".arch_extension $feature"
1179     test_as <<EOF && enable as_archext_${feature}_directive || arch_extension_directive=""
1180 $arch_directive
1181 $arch_extension_directive
1182 EOF
1183
1184     # Test if we can assemble the instruction after potential .arch and
1185     # .arch_extension directives.
1186     test_as <<EOF && enable ${feature}
1187 $arch_directive
1188 $arch_extension_directive
1189 $instr
1190 EOF
1191 }
1192
1193 check_x86asm(){
1194     log check_x86asm "$@"
1195     name=$1
1196     shift
1197     disable $name
1198     test_x86asm "$@" && enable $name
1199 }
1200
1201 test_ld(){
1202     log test_ld "$@"
1203     type=$1
1204     shift 1
1205     flags=$(filter_out '-l*|*.so' $@)
1206     libs=$(filter '-l*|*.so' $@)
1207     test_$type $($cflags_filter $flags) || return
1208     flags=$($ldflags_filter $flags)
1209     libs=$($ldflags_filter $libs)
1210     test_cmd $ld $LDFLAGS $LDEXEFLAGS $flags $(ld_o $TMPE) $TMPO $libs $extralibs
1211 }
1212
1213 check_ld(){
1214     log check_ld "$@"
1215     type=$1
1216     name=$2
1217     shift 2
1218     disable $name
1219     test_ld $type $@ && enable $name
1220 }
1221
1222 print_include(){
1223     hdr=$1
1224     test "${hdr%.h}" = "${hdr}" &&
1225         echo "#include $hdr"    ||
1226         echo "#include <$hdr>"
1227 }
1228
1229 test_code(){
1230     log test_code "$@"
1231     check=$1
1232     headers=$2
1233     code=$3
1234     shift 3
1235     {
1236         for hdr in $headers; do
1237             print_include $hdr
1238         done
1239         echo "int main(void) { $code; return 0; }"
1240     } | test_$check "$@"
1241 }
1242
1243 check_cppflags(){
1244     log check_cppflags "$@"
1245     test_cpp "$@" <<EOF && append CPPFLAGS "$@"
1246 #include <stdlib.h>
1247 EOF
1248 }
1249
1250 test_cflags(){
1251     log test_cflags "$@"
1252     set -- $($cflags_filter "$@")
1253     test_cc "$@" <<EOF
1254 int x;
1255 EOF
1256 }
1257
1258 check_cflags(){
1259     log check_cflags "$@"
1260     test_cflags "$@" && add_cflags "$@"
1261 }
1262
1263 check_cxxflags(){
1264     log check_cxxflags "$@"
1265     set -- $($cflags_filter "$@")
1266     test_cxx "$@" <<EOF && append CXXFLAGS "$@"
1267 int x;
1268 EOF
1269 }
1270
1271 test_objcflags(){
1272     log test_objcflags "$@"
1273     set -- $($objcflags_filter "$@")
1274     test_objcc "$@" <<EOF
1275 int x;
1276 EOF
1277 }
1278
1279 check_objcflags(){
1280     log check_objcflags "$@"
1281     test_objcflags "$@" && add_objcflags "$@"
1282 }
1283
1284 test_ldflags(){
1285     log test_ldflags "$@"
1286     set -- $($ldflags_filter "$@")
1287     test_ld "cc" "$@" <<EOF
1288 int main(void){ return 0; }
1289 EOF
1290 }
1291
1292 check_ldflags(){
1293     log check_ldflags "$@"
1294     test_ldflags "$@" && add_ldflags "$@"
1295 }
1296
1297 test_stripflags(){
1298     log test_stripflags "$@"
1299     # call test_cc to get a fresh TMPO
1300     test_cc <<EOF
1301 int main(void) { return 0; }
1302 EOF
1303     test_cmd $strip $ASMSTRIPFLAGS "$@" $TMPO
1304 }
1305
1306 check_stripflags(){
1307     log check_stripflags "$@"
1308     test_stripflags "$@" && add_stripflags "$@"
1309 }
1310
1311 check_headers(){
1312     log check_headers "$@"
1313     headers=$1
1314     shift
1315     disable_sanitized $headers
1316     {
1317         for hdr in $headers; do
1318             print_include $hdr
1319         done
1320         echo "int x;"
1321     } | test_cpp "$@" && enable_sanitized $headers
1322 }
1323
1324 check_header_objcc(){
1325     log check_header_objcc "$@"
1326     rm -f -- "$TMPO"
1327     header=$1
1328     shift
1329     disable_sanitized $header
1330     {
1331        echo "#include <$header>"
1332        echo "int main(void) { return 0; }"
1333     } | test_objcc && test_stat "$TMPO" && enable_sanitized $header
1334 }
1335
1336 check_apple_framework(){
1337     log check_apple_framework "$@"
1338     framework="$1"
1339     name="$(tolower $framework)"
1340     header="${framework}/${framework}.h"
1341     disable $name
1342     check_header_objcc $header &&
1343         enable $name && eval ${name}_extralibs='"-framework $framework"'
1344 }
1345
1346 check_func(){
1347     log check_func "$@"
1348     func=$1
1349     shift
1350     disable $func
1351     test_ld "cc" "$@" <<EOF && enable $func
1352 extern int $func();
1353 int main(void){ $func(); }
1354 EOF
1355 }
1356
1357 check_mathfunc(){
1358     log check_mathfunc "$@"
1359     func=$1
1360     narg=$2
1361     shift 2
1362     test $narg = 2 && args="f, g" || args="f"
1363     disable $func
1364     test_ld "cc" "$@" <<EOF && enable $func
1365 #include <math.h>
1366 float foo(float f, float g) { return $func($args); }
1367 int main(void){ return (int) foo; }
1368 EOF
1369 }
1370
1371 check_func_headers(){
1372     log check_func_headers "$@"
1373     headers=$1
1374     funcs=$2
1375     shift 2
1376     {
1377         for hdr in $headers; do
1378             print_include $hdr
1379         done
1380         echo "#include <stdint.h>"
1381         for func in $funcs; do
1382             echo "long check_$func(void) { return (long) $func; }"
1383         done
1384         echo "int main(void) { int ret = 0;"
1385         # LTO could optimize out the test functions without this
1386         for func in $funcs; do
1387             echo " ret |= ((intptr_t)check_$func) & 0xFFFF;"
1388         done
1389         echo "return ret; }"
1390     } | test_ld "cc" "$@" && enable $funcs && enable_sanitized $headers
1391 }
1392
1393 check_class_headers_cpp(){
1394     log check_class_headers_cpp "$@"
1395     headers=$1
1396     classes=$2
1397     shift 2
1398     {
1399         for hdr in $headers; do
1400             echo "#include <$hdr>"
1401         done
1402         echo "int main(void) { "
1403         i=1
1404         for class in $classes; do
1405             echo "$class obj$i;"
1406             i=$(expr $i + 1)
1407         done
1408         echo "return 0; }"
1409     } | test_ld "cxx" "$@" && enable $funcs && enable_sanitized $headers
1410 }
1411
1412 test_cpp_condition(){
1413     log test_cpp_condition "$@"
1414     header=$1
1415     condition=$2
1416     shift 2
1417     test_cpp "$@" <<EOF
1418 #include <$header>
1419 #if !($condition)
1420 #error "unsatisfied condition: $condition"
1421 #endif
1422 EOF
1423 }
1424
1425 check_cpp_condition(){
1426     log check_cpp_condition "$@"
1427     name=$1
1428     shift 1
1429     disable $name
1430     test_cpp_condition "$@" && enable $name
1431 }
1432
1433 test_cflags_cc(){
1434     log test_cflags_cc "$@"
1435     flags=$1
1436     header=$2
1437     condition=$3
1438     shift 3
1439     set -- $($cflags_filter "$flags")
1440     test_cc "$@" <<EOF
1441 #include <$header>
1442 #if !($condition)
1443 #error "unsatisfied condition: $condition"
1444 #endif
1445 EOF
1446 }
1447
1448 check_lib(){
1449     log check_lib "$@"
1450     name="$1"
1451     headers="$2"
1452     funcs="$3"
1453     shift 3
1454     disable $name
1455     check_func_headers "$headers" "$funcs" "$@" &&
1456         enable $name && eval ${name}_extralibs="\$@"
1457 }
1458
1459 check_lib_cpp(){
1460     log check_lib_cpp "$@"
1461     name="$1"
1462     headers="$2"
1463     classes="$3"
1464     shift 3
1465     disable $name
1466     check_class_headers_cpp "$headers" "$classes" "$@" &&
1467         enable $name && eval ${name}_extralibs="\$@"
1468 }
1469
1470 test_pkg_config(){
1471     log test_pkg_config "$@"
1472     name="$1"
1473     pkg_version="$2"
1474     pkg="${2%% *}"
1475     headers="$3"
1476     funcs="$4"
1477     shift 4
1478     disable $name
1479     test_cmd $pkg_config --exists --print-errors $pkg_version || return
1480     pkg_cflags=$($pkg_config --cflags $pkg_config_flags $pkg)
1481     pkg_libs=$($pkg_config --libs $pkg_config_flags $pkg)
1482     pkg_incdir=$($pkg_config --variable=includedir $pkg_config_flags $pkg)
1483     check_func_headers "$headers" "$funcs" $pkg_cflags $pkg_libs "$@" &&
1484         enable $name &&
1485         set_sanitized "${name}_cflags"    $pkg_cflags &&
1486         set_sanitized "${name}_incdir"    $pkg_incdir &&
1487         set_sanitized "${name}_extralibs" $pkg_libs
1488 }
1489
1490 test_pkg_config_cpp(){
1491     log test_pkg_config_cpp "$@"
1492     name="$1"
1493     pkg_version="$2"
1494     pkg="${2%% *}"
1495     headers="$3"
1496     cond="$4"
1497     shift 4
1498     disable $name
1499     test_cmd $pkg_config --exists --print-errors $pkg_version || return
1500     pkg_cflags=$($pkg_config --cflags $pkg_config_flags $pkg)
1501     pkg_incdir=$($pkg_config --variable=includedir $pkg_config_flags $pkg)
1502     pkg_incflags=$($pkg_config --cflags-only-I $pkg_config_flags $pkg)
1503     test_cpp_condition "$pkg_incdir/$headers" "$cond" "$@" &&
1504         enable $name &&
1505         set_sanitized "${name}_cflags" $pkg_cflags &&
1506         set_sanitized "${name}_incdir" $pkg_incdir &&
1507         set_sanitized "${name}_incflags" $pkg_incflags
1508 }
1509
1510 check_pkg_config(){
1511     log check_pkg_config "$@"
1512     name="$1"
1513     test_pkg_config "$@" &&
1514         eval add_cflags \$${name}_cflags
1515 }
1516
1517 check_pkg_config_cpp(){
1518     log check_pkg_config_cpp "$@"
1519     name="$1"
1520     test_pkg_config_cpp "$@" &&
1521         eval add_cflags \$${name}_cflags
1522 }
1523
1524 check_pkg_config_header_only(){
1525     log check_pkg_config_cpp "$@"
1526     name="$1"
1527     test_pkg_config_cpp "$@" &&
1528         eval add_cflags \$${name}_incflags
1529 }
1530
1531 test_exec(){
1532     test_ld "cc" "$@" && { enabled cross_compile || $TMPE >> $logfile 2>&1; }
1533 }
1534
1535 check_exec_crash(){
1536     log check_exec_crash "$@"
1537     code=$(cat)
1538
1539     # exit() is not async signal safe.  _Exit (C99) and _exit (POSIX)
1540     # are safe but may not be available everywhere.  Thus we use
1541     # raise(SIGTERM) instead.  The check is run in a subshell so we
1542     # can redirect the "Terminated" message from the shell.  SIGBUS
1543     # is not defined by standard C so it is used conditionally.
1544
1545     (test_exec "$@") >> $logfile 2>&1 <<EOF
1546 #include <signal.h>
1547 static void sighandler(int sig){
1548     raise(SIGTERM);
1549 }
1550 int foo(void){
1551     $code
1552 }
1553 int (*func_ptr)(void) = foo;
1554 int main(void){
1555     signal(SIGILL, sighandler);
1556     signal(SIGFPE, sighandler);
1557     signal(SIGSEGV, sighandler);
1558 #ifdef SIGBUS
1559     signal(SIGBUS, sighandler);
1560 #endif
1561     return func_ptr();
1562 }
1563 EOF
1564 }
1565
1566 check_type(){
1567     log check_type "$@"
1568     headers=$1
1569     type=$2
1570     shift 2
1571     disable_sanitized "$type"
1572     test_code cc "$headers" "$type v" "$@" && enable_sanitized "$type"
1573 }
1574
1575 check_struct(){
1576     log check_struct "$@"
1577     headers=$1
1578     struct=$2
1579     member=$3
1580     shift 3
1581     disable_sanitized "${struct}_${member}"
1582     test_code cc "$headers" "const void *p = &(($struct *)0)->$member" "$@" &&
1583         enable_sanitized "${struct}_${member}"
1584 }
1585
1586 check_builtin(){
1587     log check_builtin "$@"
1588     name=$1
1589     headers=$2
1590     builtin=$3
1591     shift 3
1592     disable "$name"
1593     test_code ld "$headers" "$builtin" "cc" "$@" && enable "$name"
1594 }
1595
1596 check_compile_assert(){
1597     log check_compile_assert "$@"
1598     name=$1
1599     headers=$2
1600     condition=$3
1601     shift 3
1602     disable "$name"
1603     test_code cc "$headers" "char c[2 * !!($condition) - 1]" "$@" && enable "$name"
1604 }
1605
1606 check_cc(){
1607     log check_cc "$@"
1608     name=$1
1609     shift
1610     disable "$name"
1611     test_code cc "$@" && enable "$name"
1612 }
1613
1614 require(){
1615     log require "$@"
1616     name_version="$1"
1617     name="${1%% *}"
1618     shift
1619     check_lib $name "$@" || die "ERROR: $name_version not found"
1620 }
1621
1622 require_cc(){
1623     log require_cc "$@"
1624     name="$1"
1625     check_cc "$@" || die "ERROR: $name failed"
1626 }
1627
1628 require_cpp(){
1629     log require_cpp "$@"
1630     name_version="$1"
1631     name="${1%% *}"
1632     shift
1633     check_lib_cpp "$name" "$@" || die "ERROR: $name_version not found"
1634 }
1635
1636 require_headers(){
1637     log require_headers "$@"
1638     headers="$1"
1639     check_headers "$@" || die "ERROR: $headers not found"
1640 }
1641
1642 require_cpp_condition(){
1643     log require_cpp_condition "$@"
1644     condition="$3"
1645     check_cpp_condition "$@" || die "ERROR: $condition not satisfied"
1646 }
1647
1648 require_pkg_config(){
1649     log require_pkg_config "$@"
1650     pkg_version="$2"
1651     check_pkg_config "$@" || die "ERROR: $pkg_version not found using pkg-config$pkg_config_fail_message"
1652 }
1653
1654 require_pkg_config_cpp(){
1655     log require_pkg_config_cpp "$@"
1656     pkg_version="$2"
1657     check_pkg_config_cpp "$@" || die "ERROR: $pkg_version not found using pkg-config$pkg_config_fail_message"
1658 }
1659
1660 test_host_cc(){
1661     log test_host_cc "$@"
1662     cat > $TMPC
1663     log_file $TMPC
1664     test_cmd $host_cc $host_cflags "$@" $HOSTCC_C $(hostcc_o $TMPO) $TMPC
1665 }
1666
1667 test_host_cpp(){
1668     log test_host_cpp "$@"
1669     cat > $TMPC
1670     log_file $TMPC
1671     test_cmd $host_cc $host_cppflags $host_cflags "$@" $(hostcc_e $TMPO) $TMPC
1672 }
1673
1674 check_host_cppflags(){
1675     log check_host_cppflags "$@"
1676     test_host_cpp "$@" <<EOF && append host_cppflags "$@"
1677 #include <stdlib.h>
1678 EOF
1679 }
1680
1681 check_host_cflags(){
1682     log check_host_cflags "$@"
1683     set -- $($host_cflags_filter "$@")
1684     test_host_cc "$@" <<EOF && append host_cflags "$@"
1685 int x;
1686 EOF
1687 }
1688
1689 test_host_cpp_condition(){
1690     log test_host_cpp_condition "$@"
1691     header=$1
1692     condition=$2
1693     shift 2
1694     test_host_cpp "$@" <<EOF
1695 #include <$header>
1696 #if !($condition)
1697 #error "unsatisfied condition: $condition"
1698 #endif
1699 EOF
1700 }
1701
1702 check_host_cpp_condition(){
1703     log check_host_cpp_condition "$@"
1704     name=$1
1705     shift 1
1706     disable $name
1707     test_host_cpp_condition "$@" && enable $name
1708 }
1709
1710 cp_if_changed(){
1711     cmp -s "$1" "$2" && { test "$quiet" != "yes" && echo "$2 is unchanged"; } && return
1712     mkdir -p "$(dirname $2)"
1713     cp -f "$1" "$2"
1714 }
1715
1716 # CONFIG_LIST contains configurable options, while HAVE_LIST is for
1717 # system-dependent things.
1718
1719 AVCODEC_COMPONENTS="
1720     bsfs
1721     decoders
1722     encoders
1723     hwaccels
1724     parsers
1725 "
1726
1727 AVDEVICE_COMPONENTS="
1728     indevs
1729     outdevs
1730 "
1731
1732 AVFILTER_COMPONENTS="
1733     filters
1734 "
1735
1736 AVFORMAT_COMPONENTS="
1737     demuxers
1738     muxers
1739     protocols
1740 "
1741
1742 COMPONENT_LIST="
1743     $AVCODEC_COMPONENTS
1744     $AVDEVICE_COMPONENTS
1745     $AVFILTER_COMPONENTS
1746     $AVFORMAT_COMPONENTS
1747 "
1748
1749 EXAMPLE_LIST="
1750     avio_http_serve_files_example
1751     avio_list_dir_example
1752     avio_read_callback_example
1753     decode_audio_example
1754     decode_filter_audio_example
1755     decode_filter_video_example
1756     decode_video_example
1757     demux_decode_example
1758     encode_audio_example
1759     encode_video_example
1760     extract_mvs_example
1761     filter_audio_example
1762     hw_decode_example
1763     mux_example
1764     qsv_decode_example
1765     remux_example
1766     resample_audio_example
1767     scale_video_example
1768     show_metadata_example
1769     transcode_aac_example
1770     transcode_example
1771     vaapi_encode_example
1772     vaapi_transcode_example
1773     qsv_transcode_example
1774 "
1775
1776 EXTERNAL_AUTODETECT_LIBRARY_LIST="
1777     alsa
1778     appkit
1779     avfoundation
1780     bzlib
1781     coreimage
1782     iconv
1783     libxcb
1784     libxcb_shm
1785     libxcb_shape
1786     libxcb_xfixes
1787     lzma
1788     mediafoundation
1789     metal
1790     schannel
1791     sdl2
1792     securetransport
1793     sndio
1794     xlib
1795     zlib
1796 "
1797
1798 EXTERNAL_LIBRARY_GPL_LIST="
1799     avisynth
1800     frei0r
1801     libcdio
1802     libdavs2
1803     librubberband
1804     libvidstab
1805     libx264
1806     libx265
1807     libxavs
1808     libxavs2
1809     libxvid
1810 "
1811
1812 EXTERNAL_LIBRARY_NONFREE_LIST="
1813     decklink
1814     libfdk_aac
1815     libtls
1816 "
1817
1818 EXTERNAL_LIBRARY_VERSION3_LIST="
1819     gmp
1820     libaribb24
1821     liblensfun
1822     libopencore_amrnb
1823     libopencore_amrwb
1824     libvo_amrwbenc
1825     mbedtls
1826     rkmpp
1827 "
1828
1829 EXTERNAL_LIBRARY_GPLV3_LIST="
1830     libsmbclient
1831 "
1832
1833 EXTERNAL_LIBRARY_LIST="
1834     $EXTERNAL_LIBRARY_GPL_LIST
1835     $EXTERNAL_LIBRARY_NONFREE_LIST
1836     $EXTERNAL_LIBRARY_VERSION3_LIST
1837     $EXTERNAL_LIBRARY_GPLV3_LIST
1838     chromaprint
1839     gcrypt
1840     gnutls
1841     jni
1842     ladspa
1843     lcms2
1844     libaom
1845     libaribcaption
1846     libass
1847     libbluray
1848     libbs2b
1849     libcaca
1850     libcelt
1851     libcodec2
1852     libdav1d
1853     libdc1394
1854     libdrm
1855     libflite
1856     libfontconfig
1857     libfreetype
1858     libfribidi
1859     libharfbuzz
1860     libglslang
1861     libgme
1862     libgsm
1863     libiec61883
1864     libilbc
1865     libjack
1866     libjxl
1867     libklvanc
1868     libkvazaar
1869     libmodplug
1870     libmp3lame
1871     libmysofa
1872     libopencv
1873     libopenh264
1874     libopenjpeg
1875     libopenmpt
1876     libopenvino
1877     libopus
1878     libplacebo
1879     libpulse
1880     librabbitmq
1881     librav1e
1882     librist
1883     librsvg
1884     librtmp
1885     libshaderc
1886     libshine
1887     libsmbclient
1888     libsnappy
1889     libsoxr
1890     libspeex
1891     libsrt
1892     libssh
1893     libsvtav1
1894     libtensorflow
1895     libtesseract
1896     libtheora
1897     libtwolame
1898     libuavs3d
1899     libv4l2
1900     libvmaf
1901     libvorbis
1902     libvpx
1903     libwebp
1904     libxml2
1905     libzimg
1906     libzmq
1907     libzvbi
1908     lv2
1909     mediacodec
1910     openal
1911     opengl
1912     openssl
1913     pocketsphinx
1914     vapoursynth
1915 "
1916
1917 HWACCEL_AUTODETECT_LIBRARY_LIST="
1918     amf
1919     audiotoolbox
1920     crystalhd
1921     cuda
1922     cuda_llvm
1923     cuvid
1924     d3d11va
1925     dxva2
1926     ffnvcodec
1927     nvdec
1928     nvenc
1929     vaapi
1930     vdpau
1931     videotoolbox
1932     vulkan
1933     v4l2_m2m
1934 "
1935
1936 # catchall list of things that require external libs to link
1937 EXTRALIBS_LIST="
1938     cpu_init
1939     cws2fws
1940 "
1941
1942 HWACCEL_LIBRARY_NONFREE_LIST="
1943     cuda_nvcc
1944     cuda_sdk
1945     libnpp
1946 "
1947
1948 HWACCEL_LIBRARY_LIST="
1949     $HWACCEL_LIBRARY_NONFREE_LIST
1950     libmfx
1951     libvpl
1952     mmal
1953     omx
1954     opencl
1955 "
1956
1957 DOCUMENT_LIST="
1958     doc
1959     htmlpages
1960     manpages
1961     podpages
1962     txtpages
1963 "
1964
1965 FEATURE_LIST="
1966     ftrapv
1967     gray
1968     hardcoded_tables
1969     omx_rpi
1970     runtime_cpudetect
1971     safe_bitstream_reader
1972     shared
1973     small
1974     static
1975     swscale_alpha
1976 "
1977
1978 # this list should be kept in linking order
1979 LIBRARY_LIST="
1980     avdevice
1981     avfilter
1982     swscale
1983     postproc
1984     avformat
1985     avcodec
1986     swresample
1987     avutil
1988 "
1989
1990 LICENSE_LIST="
1991     gpl
1992     nonfree
1993     version3
1994 "
1995
1996 PROGRAM_LIST="
1997     ffplay
1998     ffprobe
1999     ffmpeg
2000 "
2001
2002 SUBSYSTEM_LIST="
2003     dwt
2004     error_resilience
2005     faan
2006     fast_unaligned
2007     lsp
2008     pixelutils
2009     network
2010 "
2011
2012 # COMPONENT_LIST needs to come last to ensure correct dependency checking
2013 CONFIG_LIST="
2014     $DOCUMENT_LIST
2015     $EXAMPLE_LIST
2016     $EXTERNAL_LIBRARY_LIST
2017     $EXTERNAL_AUTODETECT_LIBRARY_LIST
2018     $HWACCEL_LIBRARY_LIST
2019     $HWACCEL_AUTODETECT_LIBRARY_LIST
2020     $FEATURE_LIST
2021     $LICENSE_LIST
2022     $LIBRARY_LIST
2023     $PROGRAM_LIST
2024     $SUBSYSTEM_LIST
2025     autodetect
2026     fontconfig
2027     large_tests
2028     linux_perf
2029     macos_kperf
2030     memory_poisoning
2031     neon_clobber_test
2032     ossfuzz
2033     pic
2034     ptx_compression
2035     thumb
2036     valgrind_backtrace
2037     xmm_clobber_test
2038     $COMPONENT_LIST
2039 "
2040
2041 THREADS_LIST="
2042     pthreads
2043     os2threads
2044     w32threads
2045 "
2046
2047 ATOMICS_LIST="
2048     atomics_gcc
2049     atomics_suncc
2050     atomics_win32
2051 "
2052
2053 AUTODETECT_LIBS="
2054     $EXTERNAL_AUTODETECT_LIBRARY_LIST
2055     $HWACCEL_AUTODETECT_LIBRARY_LIST
2056     $THREADS_LIST
2057 "
2058
2059 ARCH_LIST="
2060     aarch64
2061     alpha
2062     arm
2063     avr32
2064     avr32_ap
2065     avr32_uc
2066     bfin
2067     ia64
2068     loongarch
2069     loongarch32
2070     loongarch64
2071     m68k
2072     mips
2073     mips64
2074     parisc
2075     ppc
2076     ppc64
2077     riscv
2078     s390
2079     sh4
2080     sparc
2081     sparc64
2082     tilegx
2083     tilepro
2084     x86
2085     x86_32
2086     x86_64
2087 "
2088
2089 ARCH_EXT_LIST_ARM="
2090     armv5te
2091     armv6
2092     armv6t2
2093     armv8
2094     dotprod
2095     i8mm
2096     neon
2097     vfp
2098     vfpv3
2099     setend
2100 "
2101
2102 ARCH_EXT_LIST_MIPS="
2103     mipsfpu
2104     mips32r2
2105     mips32r5
2106     mips64r2
2107     mips32r6
2108     mips64r6
2109     mipsdsp
2110     mipsdspr2
2111     msa
2112 "
2113
2114 ARCH_EXT_LIST_LOONGSON="
2115     loongson2
2116     loongson3
2117     mmi
2118     lsx
2119     lasx
2120 "
2121
2122 ARCH_EXT_LIST_X86_SIMD="
2123     aesni
2124     amd3dnow
2125     amd3dnowext
2126     avx
2127     avx2
2128     avx512
2129     avx512icl
2130     fma3
2131     fma4
2132     mmx
2133     mmxext
2134     sse
2135     sse2
2136     sse3
2137     sse4
2138     sse42
2139     ssse3
2140     xop
2141 "
2142
2143 ARCH_EXT_LIST_PPC="
2144     altivec
2145     dcbzl
2146     ldbrx
2147     power8
2148     ppc4xx
2149     vsx
2150 "
2151
2152 ARCH_EXT_LIST_RISCV="
2153     rvv
2154 "
2155
2156 ARCH_EXT_LIST_X86="
2157     $ARCH_EXT_LIST_X86_SIMD
2158     cpunop
2159     i686
2160 "
2161
2162 ARCH_EXT_LIST="
2163     $ARCH_EXT_LIST_ARM
2164     $ARCH_EXT_LIST_PPC
2165     $ARCH_EXT_LIST_RISCV
2166     $ARCH_EXT_LIST_X86
2167     $ARCH_EXT_LIST_MIPS
2168     $ARCH_EXT_LIST_LOONGSON
2169 "
2170
2171 ARCH_FEATURES="
2172     aligned_stack
2173     fast_64bit
2174     fast_clz
2175     fast_cmov
2176     fast_float16
2177     local_aligned
2178     simd_align_16
2179     simd_align_32
2180     simd_align_64
2181 "
2182
2183 BUILTIN_LIST="
2184     atomic_cas_ptr
2185     machine_rw_barrier
2186     MemoryBarrier
2187     mm_empty
2188     rdtsc
2189     sem_timedwait
2190     sync_val_compare_and_swap
2191 "
2192 HAVE_LIST_CMDLINE="
2193     inline_asm
2194     symver
2195     x86asm
2196 "
2197
2198 HAVE_LIST_PUB="
2199     bigendian
2200     fast_unaligned
2201 "
2202
2203 HEADERS_LIST="
2204     arpa_inet_h
2205     asm_types_h
2206     cdio_paranoia_h
2207     cdio_paranoia_paranoia_h
2208     cuda_h
2209     dispatch_dispatch_h
2210     dev_bktr_ioctl_bt848_h
2211     dev_bktr_ioctl_meteor_h
2212     dev_ic_bt8xx_h
2213     dev_video_bktr_ioctl_bt848_h
2214     dev_video_meteor_ioctl_meteor_h
2215     direct_h
2216     dirent_h
2217     dxgidebug_h
2218     dxva_h
2219     ES2_gl_h
2220     gsm_h
2221     io_h
2222     linux_dma_buf_h
2223     linux_perf_event_h
2224     machine_ioctl_bt848_h
2225     machine_ioctl_meteor_h
2226     malloc_h
2227     opencv2_core_core_c_h
2228     OpenGL_gl3_h
2229     poll_h
2230     sys_param_h
2231     sys_resource_h
2232     sys_select_h
2233     sys_soundcard_h
2234     sys_time_h
2235     sys_un_h
2236     sys_videoio_h
2237     termios_h
2238     udplite_h
2239     unistd_h
2240     valgrind_valgrind_h
2241     windows_h
2242     winsock2_h
2243 "
2244
2245 INTRINSICS_LIST="
2246     intrinsics_neon
2247 "
2248
2249 MATH_FUNCS="
2250     atanf
2251     atan2f
2252     cbrt
2253     cbrtf
2254     copysign
2255     cosf
2256     erf
2257     exp2
2258     exp2f
2259     expf
2260     hypot
2261     isfinite
2262     isinf
2263     isnan
2264     ldexpf
2265     llrint
2266     llrintf
2267     log2
2268     log2f
2269     log10f
2270     lrint
2271     lrintf
2272     powf
2273     rint
2274     round
2275     roundf
2276     sinf
2277     trunc
2278     truncf
2279 "
2280
2281 SYSTEM_FEATURES="
2282     dos_paths
2283     libc_msvcrt
2284     MMAL_PARAMETER_VIDEO_MAX_NUM_CALLBACKS
2285     section_data_rel_ro
2286     threads
2287     uwp
2288     winrt
2289 "
2290
2291 SYSTEM_FUNCS="
2292     access
2293     aligned_malloc
2294     arc4random_buf
2295     clock_gettime
2296     closesocket
2297     CommandLineToArgvW
2298     fcntl
2299     getaddrinfo
2300     getauxval
2301     getenv
2302     gethrtime
2303     getopt
2304     GetModuleHandle
2305     GetProcessAffinityMask
2306     GetProcessMemoryInfo
2307     GetProcessTimes
2308     getrusage
2309     GetStdHandle
2310     GetSystemTimeAsFileTime
2311     gettimeofday
2312     glob
2313     glXGetProcAddress
2314     gmtime_r
2315     inet_aton
2316     isatty
2317     kbhit
2318     localtime_r
2319     lstat
2320     lzo1x_999_compress
2321     mach_absolute_time
2322     MapViewOfFile
2323     memalign
2324     mkstemp
2325     mmap
2326     mprotect
2327     nanosleep
2328     PeekNamedPipe
2329     posix_memalign
2330     prctl
2331     pthread_cancel
2332     sched_getaffinity
2333     SecItemImport
2334     SetConsoleTextAttribute
2335     SetConsoleCtrlHandler
2336     SetDllDirectory
2337     setmode
2338     setrlimit
2339     Sleep
2340     strerror_r
2341     sysconf
2342     sysctl
2343     sysctlbyname
2344     usleep
2345     UTGetOSTypeFromString
2346     VirtualAlloc
2347     wglGetProcAddress
2348 "
2349
2350 SYSTEM_LIBRARIES="
2351     bcrypt
2352     vaapi_drm
2353     vaapi_x11
2354     vaapi_win32
2355     vdpau_x11
2356 "
2357
2358 TOOLCHAIN_FEATURES="
2359     as_arch_directive
2360     as_archext_dotprod_directive
2361     as_archext_i8mm_directive
2362     as_dn_directive
2363     as_fpu_directive
2364     as_func
2365     as_object_arch
2366     asm_mod_q
2367     blocks_extension
2368     ebp_available
2369     ebx_available
2370     gnu_as
2371     gnu_windres
2372     ibm_asm
2373     inline_asm_direct_symbol_refs
2374     inline_asm_labels
2375     inline_asm_nonlocal_labels
2376     pragma_deprecated
2377     rsync_contimeout
2378     symver_asm_label
2379     symver_gnu_asm
2380     vfp_args
2381     xform_asm
2382     xmm_clobbers
2383 "
2384
2385 TYPES_LIST="
2386     DPI_AWARENESS_CONTEXT
2387     IDXGIOutput5
2388     kCMVideoCodecType_HEVC
2389     kCMVideoCodecType_HEVCWithAlpha
2390     kCMVideoCodecType_VP9
2391     kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange
2392     kCVPixelFormatType_422YpCbCr8BiPlanarVideoRange
2393     kCVPixelFormatType_422YpCbCr10BiPlanarVideoRange
2394     kCVPixelFormatType_422YpCbCr16BiPlanarVideoRange
2395     kCVPixelFormatType_444YpCbCr8BiPlanarVideoRange
2396     kCVPixelFormatType_444YpCbCr10BiPlanarVideoRange
2397     kCVPixelFormatType_444YpCbCr16BiPlanarVideoRange
2398     kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ
2399     kCVImageBufferTransferFunction_ITU_R_2100_HLG
2400     kCVImageBufferTransferFunction_Linear
2401     kCVImageBufferYCbCrMatrix_ITU_R_2020
2402     kCVImageBufferColorPrimaries_ITU_R_2020
2403     kCVImageBufferTransferFunction_ITU_R_2020
2404     kCVImageBufferTransferFunction_SMPTE_ST_428_1
2405     socklen_t
2406     struct_addrinfo
2407     struct_group_source_req
2408     struct_ip_mreq_source
2409     struct_ipv6_mreq
2410     struct_msghdr_msg_flags
2411     struct_pollfd
2412     struct_rusage_ru_maxrss
2413     struct_sctp_event_subscribe
2414     struct_sockaddr_in6
2415     struct_sockaddr_sa_len
2416     struct_sockaddr_storage
2417     struct_stat_st_mtim_tv_nsec
2418     struct_v4l2_frmivalenum_discrete
2419 "
2420
2421 HAVE_LIST="
2422     $ARCH_EXT_LIST
2423     $(add_suffix _external $ARCH_EXT_LIST)
2424     $(add_suffix _inline   $ARCH_EXT_LIST)
2425     $ARCH_FEATURES
2426     $BUILTIN_LIST
2427     $HAVE_LIST_CMDLINE
2428     $HAVE_LIST_PUB
2429     $HEADERS_LIST
2430     $INTRINSICS_LIST
2431     $MATH_FUNCS
2432     $SYSTEM_FEATURES
2433     $SYSTEM_FUNCS
2434     $SYSTEM_LIBRARIES
2435     $THREADS_LIST
2436     $TOOLCHAIN_FEATURES
2437     $TYPES_LIST
2438     gzip
2439     libdrm_getfb2
2440     makeinfo
2441     makeinfo_html
2442     opencl_d3d11
2443     opencl_drm_arm
2444     opencl_drm_beignet
2445     opencl_dxva2
2446     opencl_vaapi_beignet
2447     opencl_vaapi_intel_media
2448     perl
2449     pod2man
2450     texi2html
2451     xmllint
2452     zlib_gzip
2453     openvino2
2454 "
2455
2456 # options emitted with CONFIG_ prefix but not available on the command line
2457 CONFIG_EXTRA="
2458     aandcttables
2459     ac3dsp
2460     adts_header
2461     atsc_a53
2462     audio_frame_queue
2463     audiodsp
2464     blockdsp
2465     bswapdsp
2466     cabac
2467     cbs
2468     cbs_av1
2469     cbs_h264
2470     cbs_h265
2471     cbs_h266
2472     cbs_jpeg
2473     cbs_mpeg2
2474     cbs_vp9
2475     deflate_wrapper
2476     dirac_parse
2477     dnn
2478     dovi_rpu
2479     dvprofile
2480     evcparse
2481     exif
2482     faandct
2483     faanidct
2484     fdctdsp
2485     fmtconvert
2486     frame_thread_encoder
2487     g722dsp
2488     golomb
2489     gplv3
2490     h263dsp
2491     h264chroma
2492     h264dsp
2493     h264parse
2494     h264pred
2495     h264qpel
2496     h264_sei
2497     hevcparse
2498     hevc_sei
2499     hpeldsp
2500     huffman
2501     huffyuvdsp
2502     huffyuvencdsp
2503     idctdsp
2504     iirfilter
2505     inflate_wrapper
2506     intrax8
2507     iso_media
2508     ividsp
2509     jpegtables
2510     lgplv3
2511     libx262
2512     llauddsp
2513     llviddsp
2514     llvidencdsp
2515     lpc
2516     lzf
2517     me_cmp
2518     mpeg_er
2519     mpegaudio
2520     mpegaudiodsp
2521     mpegaudioheader
2522     mpeg4audio
2523     mpegvideo
2524     mpegvideodec
2525     mpegvideoenc
2526     msmpeg4dec
2527     msmpeg4enc
2528     mss34dsp
2529     pixblockdsp
2530     qpeldsp
2531     qsv
2532     qsvdec
2533     qsvenc
2534     qsvvpp
2535     rangecoder
2536     riffdec
2537     riffenc
2538     rtpdec
2539     rtpenc_chain
2540     rv34dsp
2541     scene_sad
2542     sinewin
2543     snappy
2544     srtp
2545     startcode
2546     texturedsp
2547     texturedspenc
2548     tpeldsp
2549     vaapi_1
2550     vaapi_encode
2551     vc1dsp
2552     videodsp
2553     vp3dsp
2554     vp56dsp
2555     vp8dsp
2556     wma_freqs
2557     wmv2dsp
2558 "
2559
2560 CMDLINE_SELECT="
2561     $ARCH_EXT_LIST
2562     $CONFIG_LIST
2563     $HAVE_LIST_CMDLINE
2564     $THREADS_LIST
2565     asm
2566     cross_compile
2567     debug
2568     extra_warnings
2569     logging
2570     optimizations
2571     rpath
2572     stripping
2573 "
2574
2575 PATHS_LIST="
2576     bindir
2577     datadir
2578     docdir
2579     incdir
2580     libdir
2581     mandir
2582     pkgconfigdir
2583     prefix
2584     shlibdir
2585     install_name_dir
2586 "
2587
2588 CMDLINE_SET="
2589     $PATHS_LIST
2590     ar
2591     arch
2592     as
2593     assert_level
2594     build_suffix
2595     cc
2596     objcc
2597     cpu
2598     cross_prefix
2599     custom_allocator
2600     cxx
2601     dep_cc
2602     doxygen
2603     env
2604     extra_version
2605     gas
2606     host_cc
2607     host_cflags
2608     host_extralibs
2609     host_ld
2610     host_ldflags
2611     host_os
2612     ignore_tests
2613     install
2614     ld
2615     ln_s
2616     logfile
2617     malloc_prefix
2618     metalcc
2619     metallib
2620     nm
2621     optflags
2622     nvcc
2623     nvccflags
2624     pkg_config
2625     pkg_config_flags
2626     progs_suffix
2627     random_seed
2628     ranlib
2629     samples
2630     strip
2631     sws_max_filter_size
2632     sysinclude
2633     sysroot
2634     target_exec
2635     target_os
2636     target_path
2637     target_samples
2638     tempprefix
2639     toolchain
2640     valgrind
2641     windres
2642     x86asmexe
2643 "
2644
2645 CMDLINE_APPEND="
2646     extra_cflags
2647     extra_cxxflags
2648     extra_objcflags
2649     host_cppflags
2650 "
2651
2652 # code dependency declarations
2653
2654 # architecture extensions
2655
2656 armv5te_deps="arm"
2657 armv6_deps="arm"
2658 armv6t2_deps="arm"
2659 armv8_deps="aarch64"
2660 neon_deps_any="aarch64 arm"
2661 intrinsics_neon_deps="neon"
2662 vfp_deps="arm"
2663 vfpv3_deps="vfp"
2664 setend_deps="arm"
2665 dotprod_deps="aarch64 neon"
2666 i8mm_deps="aarch64 neon"
2667
2668 map 'eval ${v}_inline_deps=inline_asm' $ARCH_EXT_LIST_ARM
2669
2670 altivec_deps="ppc"
2671 dcbzl_deps="ppc"
2672 ldbrx_deps="ppc"
2673 ppc4xx_deps="ppc"
2674 vsx_deps="altivec"
2675 power8_deps="vsx"
2676
2677 rvv_deps="riscv"
2678
2679 loongson2_deps="mips"
2680 loongson3_deps="mips"
2681 mmi_deps_any="loongson2 loongson3"
2682 lsx_deps="loongarch"
2683 lasx_deps="lsx"
2684
2685 mips32r2_deps="mips"
2686 mips32r5_deps="mips"
2687 mips32r6_deps="mips"
2688 mips64r2_deps="mips"
2689 mips64r6_deps="mips"
2690 mipsfpu_deps="mips"
2691 mipsdsp_deps="mips"
2692 mipsdspr2_deps="mips"
2693 msa_deps="mipsfpu"
2694
2695 cpunop_deps="i686"
2696 x86_64_select="i686"
2697 x86_64_suggest="fast_cmov"
2698
2699 amd3dnow_deps="mmx"
2700 amd3dnowext_deps="amd3dnow"
2701 i686_deps="x86"
2702 mmx_deps="x86"
2703 mmxext_deps="mmx"
2704 sse_deps="mmxext"
2705 sse2_deps="sse"
2706 sse3_deps="sse2"
2707 ssse3_deps="sse3"
2708 sse4_deps="ssse3"
2709 sse42_deps="sse4"
2710 aesni_deps="sse42"
2711 avx_deps="sse42"
2712 xop_deps="avx"
2713 fma3_deps="avx"
2714 fma4_deps="avx"
2715 avx2_deps="avx"
2716 avx512_deps="avx2"
2717 avx512icl_deps="avx512"
2718
2719 mmx_external_deps="x86asm"
2720 mmx_inline_deps="inline_asm x86"
2721 mmx_suggest="mmx_external mmx_inline"
2722
2723 for ext in $(filter_out mmx $ARCH_EXT_LIST_X86_SIMD); do
2724     eval dep=\$${ext}_deps
2725     eval ${ext}_external_deps='"${dep}_external"'
2726     eval ${ext}_inline_deps='"${dep}_inline"'
2727     eval ${ext}_suggest='"${ext}_external ${ext}_inline"'
2728 done
2729
2730 aligned_stack_if_any="aarch64 ppc x86"
2731 fast_64bit_if_any="aarch64 alpha ia64 mips64 parisc64 ppc64 riscv64 sparc64 x86_64"
2732 fast_clz_if_any="aarch64 alpha avr32 mips ppc x86"
2733 fast_unaligned_if_any="aarch64 ppc x86"
2734 simd_align_16_if_any="altivec neon sse"
2735 simd_align_32_if_any="avx"
2736 simd_align_64_if_any="avx512"
2737
2738 # system capabilities
2739 linux_perf_deps="linux_perf_event_h"
2740 symver_if_any="symver_asm_label symver_gnu_asm"
2741 valgrind_backtrace_conflict="optimizations"
2742 valgrind_backtrace_deps="valgrind_valgrind_h"
2743
2744 # threading support
2745 atomics_gcc_if="sync_val_compare_and_swap"
2746 atomics_suncc_if="atomic_cas_ptr machine_rw_barrier"
2747 atomics_win32_if="MemoryBarrier"
2748 atomics_native_if_any="$ATOMICS_LIST"
2749 w32threads_deps="atomics_native"
2750 threads_if_any="$THREADS_LIST"
2751
2752 # subsystems
2753 cbs_av1_select="cbs"
2754 cbs_h264_select="cbs"
2755 cbs_h265_select="cbs"
2756 cbs_h266_select="cbs"
2757 cbs_jpeg_select="cbs"
2758 cbs_mpeg2_select="cbs"
2759 cbs_vp9_select="cbs"
2760 deflate_wrapper_deps="zlib"
2761 dirac_parse_select="golomb"
2762 dovi_rpu_select="golomb"
2763 dnn_suggest="libtensorflow libopenvino"
2764 dnn_deps="avformat swscale"
2765 error_resilience_select="me_cmp"
2766 evcparse_select="golomb"
2767 faandct_deps="faan"
2768 faandct_select="fdctdsp"
2769 faanidct_deps="faan"
2770 faanidct_select="idctdsp"
2771 h264dsp_select="startcode"
2772 h264_sei_select="atsc_a53 golomb"
2773 hevcparse_select="golomb"
2774 hevc_sei_select="atsc_a53 golomb"
2775 frame_thread_encoder_deps="encoders threads"
2776 inflate_wrapper_deps="zlib"
2777 intrax8_select="blockdsp wmv2dsp"
2778 iso_media_select="mpeg4audio"
2779 me_cmp_select="idctdsp"
2780 mpeg_er_select="error_resilience"
2781 mpegaudio_select="mpegaudiodsp mpegaudioheader"
2782 mpegvideo_select="blockdsp hpeldsp idctdsp videodsp"
2783 mpegvideodec_select="h264chroma mpegvideo mpeg_er"
2784 mpegvideoenc_select="aandcttables fdctdsp me_cmp mpegvideo pixblockdsp"
2785 msmpeg4dec_select="h263_decoder"
2786 msmpeg4enc_select="h263_encoder"
2787 vc1dsp_select="h264chroma qpeldsp startcode"
2788
2789 # decoders / encoders
2790 aac_decoder_select="adts_header mpeg4audio sinewin"
2791 aac_fixed_decoder_select="adts_header mpeg4audio"
2792 aac_encoder_select="audio_frame_queue iirfilter lpc sinewin"
2793 aac_latm_decoder_select="aac_decoder aac_latm_parser"
2794 ac3_decoder_select="ac3_parser ac3dsp bswapdsp fmtconvert"
2795 ac3_fixed_decoder_select="ac3_parser ac3dsp bswapdsp"
2796 ac3_encoder_select="ac3dsp audiodsp me_cmp"
2797 ac3_fixed_encoder_select="ac3dsp audiodsp me_cmp"
2798 acelp_kelvin_decoder_select="audiodsp"
2799 adpcm_g722_decoder_select="g722dsp"
2800 adpcm_g722_encoder_select="g722dsp"
2801 agm_decoder_select="idctdsp"
2802 aic_decoder_select="golomb idctdsp"
2803 alac_encoder_select="lpc"
2804 als_decoder_select="bswapdsp mpeg4audio"
2805 amrnb_decoder_select="lsp"
2806 amrwb_decoder_select="lsp"
2807 amv_decoder_select="sp5x_decoder exif"
2808 amv_encoder_select="jpegtables mpegvideoenc"
2809 ape_decoder_select="bswapdsp llauddsp"
2810 apng_decoder_select="inflate_wrapper"
2811 apng_encoder_select="deflate_wrapper llvidencdsp"
2812 aptx_encoder_select="audio_frame_queue"
2813 aptx_hd_encoder_select="audio_frame_queue"
2814 asv1_decoder_select="blockdsp bswapdsp idctdsp"
2815 asv1_encoder_select="aandcttables bswapdsp fdctdsp pixblockdsp"
2816 asv2_decoder_select="blockdsp bswapdsp idctdsp"
2817 asv2_encoder_select="aandcttables bswapdsp fdctdsp pixblockdsp"
2818 atrac1_decoder_select="sinewin"
2819 av1_decoder_select="cbs_av1 atsc_a53"
2820 bink_decoder_select="blockdsp hpeldsp"
2821 binkaudio_dct_decoder_select="wma_freqs"
2822 binkaudio_rdft_decoder_select="wma_freqs"
2823 cavs_decoder_select="blockdsp golomb h264chroma idctdsp qpeldsp videodsp"
2824 clearvideo_decoder_select="idctdsp"
2825 cllc_decoder_select="bswapdsp"
2826 comfortnoise_encoder_select="lpc"
2827 cook_decoder_select="audiodsp sinewin"
2828 cri_decoder_select="mjpeg_decoder"
2829 cscd_decoder_suggest="zlib"
2830 dds_decoder_select="texturedsp"
2831 dirac_decoder_select="dirac_parse dwt golomb videodsp mpegvideoenc"
2832 dnxhd_decoder_select="blockdsp idctdsp"
2833 dnxhd_encoder_select="blockdsp fdctdsp idctdsp mpegvideoenc pixblockdsp videodsp"
2834 dvvideo_decoder_select="dvprofile idctdsp"
2835 dvvideo_encoder_select="dvprofile fdctdsp me_cmp pixblockdsp"
2836 dxa_decoder_deps="zlib"
2837 dxv_decoder_select="lzf texturedsp"
2838 eac3_decoder_select="ac3_decoder"
2839 eac3_encoder_select="ac3_encoder"
2840 eamad_decoder_select="aandcttables blockdsp bswapdsp"
2841 eatgq_decoder_select="aandcttables"
2842 eatqi_decoder_select="aandcttables blockdsp bswapdsp"
2843 exr_decoder_deps="zlib"
2844 exr_encoder_deps="zlib"
2845 ffv1_decoder_select="rangecoder"
2846 ffv1_encoder_select="rangecoder"
2847 ffvhuff_decoder_select="huffyuv_decoder"
2848 ffvhuff_encoder_select="huffyuv_encoder"
2849 fic_decoder_select="golomb"
2850 flac_encoder_select="bswapdsp lpc"
2851 flashsv2_decoder_select="inflate_wrapper"
2852 flashsv2_encoder_select="deflate_wrapper"
2853 flashsv_decoder_select="inflate_wrapper"
2854 flashsv_encoder_deps="zlib"
2855 flv_decoder_select="h263_decoder"
2856 flv_encoder_select="h263_encoder"
2857 fourxm_decoder_select="blockdsp bswapdsp"
2858 fraps_decoder_select="bswapdsp huffman"
2859 g2m_decoder_deps="zlib"
2860 g2m_decoder_select="blockdsp idctdsp jpegtables"
2861 g729_decoder_select="audiodsp"
2862 h261_decoder_select="mpegvideodec"
2863 h261_encoder_select="mpegvideoenc"
2864 h263_decoder_select="h263_parser h263dsp mpegvideodec qpeldsp"
2865 h263_encoder_select="h263dsp mpegvideoenc"
2866 h263i_decoder_select="h263_decoder"
2867 h263p_decoder_select="h263_decoder"
2868 h263p_encoder_select="h263_encoder"
2869 h264_decoder_select="cabac golomb h264chroma h264dsp h264parse h264pred h264qpel h264_sei videodsp"
2870 h264_decoder_suggest="error_resilience"
2871 hap_decoder_select="snappy texturedsp"
2872 hap_encoder_deps="libsnappy"
2873 hap_encoder_select="texturedspenc"
2874 hevc_decoder_select="bswapdsp cabac dovi_rpu golomb hevcparse hevc_sei videodsp"
2875 huffyuv_decoder_select="bswapdsp huffyuvdsp llviddsp"
2876 huffyuv_encoder_select="bswapdsp huffman huffyuvencdsp llvidencdsp"
2877 hymt_decoder_select="huffyuv_decoder"
2878 iac_decoder_select="imc_decoder"
2879 imc_decoder_select="bswapdsp sinewin"
2880 imm4_decoder_select="bswapdsp idctdsp"
2881 imm5_decoder_select="h264_decoder hevc_decoder"
2882 indeo3_decoder_select="hpeldsp"
2883 indeo4_decoder_select="ividsp"
2884 indeo5_decoder_select="ividsp"
2885 interplay_video_decoder_select="hpeldsp"
2886 ipu_decoder_select="mpegvideodec"
2887 jpegls_decoder_select="mjpeg_decoder"
2888 jv_decoder_select="blockdsp"
2889 lagarith_decoder_select="llviddsp"
2890 ljpeg_encoder_select="jpegtables"
2891 lscr_decoder_select="inflate_wrapper"
2892 magicyuv_decoder_select="llviddsp"
2893 magicyuv_encoder_select="llvidencdsp"
2894 mdec_decoder_select="blockdsp bswapdsp idctdsp"
2895 media100_decoder_select="media100_to_mjpegb_bsf mjpegb_decoder"
2896 metasound_decoder_select="lsp sinewin"
2897 mimic_decoder_select="blockdsp bswapdsp hpeldsp idctdsp"
2898 mjpeg_decoder_select="blockdsp hpeldsp exif idctdsp jpegtables"
2899 mjpeg_encoder_select="jpegtables mpegvideoenc"
2900 mjpegb_decoder_select="mjpeg_decoder"
2901 mlp_decoder_select="mlp_parser"
2902 mlp_encoder_select="lpc audio_frame_queue"
2903 mobiclip_decoder_select="bswapdsp golomb"
2904 motionpixels_decoder_select="bswapdsp"
2905 mp1_decoder_select="mpegaudio"
2906 mp1float_decoder_select="mpegaudio"
2907 mp2_decoder_select="mpegaudio"
2908 mp2float_decoder_select="mpegaudio"
2909 mp3_decoder_select="mpegaudio"
2910 mp3adu_decoder_select="mpegaudio"
2911 mp3adufloat_decoder_select="mpegaudio"
2912 mp3float_decoder_select="mpegaudio"
2913 mp3on4_decoder_select="mpegaudio mpeg4audio"
2914 mp3on4float_decoder_select="mpegaudio mpeg4audio"
2915 mpc7_decoder_select="bswapdsp mpegaudiodsp"
2916 mpc8_decoder_select="mpegaudiodsp"
2917 mpegvideo_decoder_select="mpegvideodec"
2918 mpeg1video_decoder_select="mpegvideodec"
2919 mpeg1video_encoder_select="mpegvideoenc"
2920 mpeg2video_decoder_select="mpegvideodec"
2921 mpeg2video_encoder_select="mpegvideoenc"
2922 mpeg4_decoder_select="h263_decoder mpeg4video_parser"
2923 mpeg4_encoder_select="h263_encoder qpeldsp"
2924 msa1_decoder_select="mss34dsp"
2925 mscc_decoder_select="inflate_wrapper"
2926 msmpeg4v1_decoder_select="msmpeg4dec"
2927 msmpeg4v2_decoder_select="msmpeg4dec"
2928 msmpeg4v2_encoder_select="msmpeg4enc"
2929 msmpeg4v3_decoder_select="msmpeg4dec"
2930 msmpeg4v3_encoder_select="msmpeg4enc"
2931 mss2_decoder_select="mpegvideodec qpeldsp vc1_decoder"
2932 mts2_decoder_select="jpegtables mss34dsp"
2933 mv30_decoder_select="aandcttables blockdsp"
2934 mvha_decoder_select="inflate_wrapper llviddsp"
2935 mwsc_decoder_select="inflate_wrapper"
2936 mxpeg_decoder_select="mjpeg_decoder"
2937 nellymoser_decoder_select="sinewin"
2938 nellymoser_encoder_select="audio_frame_queue sinewin"
2939 notchlc_decoder_select="lzf"
2940 nuv_decoder_select="idctdsp"
2941 opus_decoder_deps="swresample"
2942 opus_encoder_select="audio_frame_queue"
2943 pdv_decoder_deps="zlib"
2944 png_decoder_select="inflate_wrapper"
2945 png_encoder_select="deflate_wrapper llvidencdsp"
2946 prores_decoder_select="blockdsp idctdsp"
2947 prores_encoder_select="fdctdsp"
2948 prores_aw_encoder_select="fdctdsp"
2949 prores_ks_encoder_select="fdctdsp"
2950 qcelp_decoder_select="lsp"
2951 qdm2_decoder_select="mpegaudiodsp"
2952 ra_144_decoder_select="audiodsp"
2953 ra_144_encoder_select="audio_frame_queue lpc audiodsp"
2954 ralf_decoder_select="golomb"
2955 rasc_decoder_select="inflate_wrapper"
2956 rawvideo_decoder_select="bswapdsp"
2957 rscc_decoder_deps="zlib"
2958 rtv1_decoder_select="texturedsp"
2959 rv10_decoder_select="h263_decoder"
2960 rv10_encoder_select="h263_encoder"
2961 rv20_decoder_select="h263_decoder"
2962 rv20_encoder_select="h263_encoder"
2963 rv30_decoder_select="golomb h264pred h264qpel mpegvideodec rv34dsp"
2964 rv40_decoder_select="golomb h264pred h264qpel mpegvideodec rv34dsp"
2965 screenpresso_decoder_deps="zlib"
2966 shorten_decoder_select="bswapdsp"
2967 sipr_decoder_select="lsp"
2968 smvjpeg_decoder_select="mjpeg_decoder"
2969 snow_decoder_select="dwt h264qpel rangecoder videodsp"
2970 snow_encoder_select="dwt h264qpel hpeldsp me_cmp mpegvideoenc rangecoder videodsp"
2971 sonic_decoder_select="golomb rangecoder"
2972 sonic_encoder_select="golomb rangecoder"
2973 sonic_ls_encoder_select="golomb rangecoder"
2974 sp5x_decoder_select="mjpeg_decoder"
2975 speedhq_decoder_select="blockdsp idctdsp"
2976 speedhq_encoder_select="mpegvideoenc"
2977 srgc_decoder_select="inflate_wrapper"
2978 svq1_decoder_select="hpeldsp"
2979 svq1_encoder_select="hpeldsp me_cmp mpegvideoenc"
2980 svq3_decoder_select="golomb h264dsp h264parse h264pred hpeldsp tpeldsp videodsp"
2981 svq3_decoder_suggest="zlib"
2982 tak_decoder_select="audiodsp"
2983 tdsc_decoder_deps="zlib"
2984 tdsc_decoder_select="mjpeg_decoder"
2985 theora_decoder_select="vp3_decoder"
2986 thp_decoder_select="mjpeg_decoder"
2987 tiff_decoder_select="mjpeg_decoder"
2988 tiff_decoder_suggest="zlib lzma"
2989 tiff_encoder_suggest="zlib"
2990 truehd_decoder_select="mlp_parser"
2991 truehd_encoder_select="lpc audio_frame_queue"
2992 truemotion2_decoder_select="bswapdsp"
2993 truespeech_decoder_select="bswapdsp"
2994 tscc_decoder_select="inflate_wrapper"
2995 twinvq_decoder_select="lsp sinewin"
2996 txd_decoder_select="texturedsp"
2997 utvideo_decoder_select="bswapdsp llviddsp"
2998 utvideo_encoder_select="bswapdsp huffman llvidencdsp"
2999 vble_decoder_select="llviddsp"
3000 vbn_decoder_select="texturedsp"
3001 vbn_encoder_select="texturedspenc"
3002 vmix_decoder_select="idctdsp"
3003 vc1_decoder_select="blockdsp h264qpel intrax8 mpegvideodec qpeldsp vc1dsp"
3004 vc1image_decoder_select="vc1_decoder"
3005 vorbis_encoder_select="audio_frame_queue"
3006 vp3_decoder_select="hpeldsp vp3dsp videodsp"
3007 vp4_decoder_select="vp3_decoder"
3008 vp5_decoder_select="h264chroma hpeldsp videodsp vp3dsp vp56dsp"
3009 vp6_decoder_select="h264chroma hpeldsp huffman videodsp vp3dsp vp56dsp"
3010 vp6a_decoder_select="vp6_decoder"
3011 vp6f_decoder_select="vp6_decoder"
3012 vp7_decoder_select="h264pred videodsp vp8dsp"
3013 vp8_decoder_select="h264pred videodsp vp8dsp"
3014 vp9_decoder_select="videodsp vp9_parser vp9_superframe_split_bsf"
3015 wcmv_decoder_select="inflate_wrapper"
3016 webp_decoder_select="vp8_decoder exif"
3017 wmalossless_decoder_select="llauddsp"
3018 wmapro_decoder_select="sinewin wma_freqs"
3019 wmav1_decoder_select="sinewin wma_freqs"
3020 wmav1_encoder_select="sinewin wma_freqs"
3021 wmav2_decoder_select="sinewin wma_freqs"
3022 wmav2_encoder_select="sinewin wma_freqs"
3023 wmavoice_decoder_select="lsp sinewin"
3024 wmv1_decoder_select="msmpeg4dec"
3025 wmv1_encoder_select="msmpeg4enc"
3026 wmv2_decoder_select="blockdsp error_resilience idctdsp intrax8 msmpeg4dec videodsp wmv2dsp"
3027 wmv2_encoder_select="msmpeg4enc wmv2dsp"
3028 wmv3_decoder_select="vc1_decoder"
3029 wmv3image_decoder_select="wmv3_decoder"
3030 xma1_decoder_select="wmapro_decoder"
3031 xma2_decoder_select="wmapro_decoder"
3032 ylc_decoder_select="bswapdsp"
3033 zerocodec_decoder_select="inflate_wrapper"
3034 zlib_decoder_select="inflate_wrapper"
3035 zlib_encoder_select="deflate_wrapper"
3036 zmbv_decoder_select="inflate_wrapper"
3037 zmbv_encoder_select="deflate_wrapper"
3038
3039 # hardware accelerators
3040 crystalhd_deps="libcrystalhd_libcrystalhd_if_h"
3041 cuda_deps="ffnvcodec"
3042 cuvid_deps="ffnvcodec"
3043 d3d11va_deps="dxva_h ID3D11VideoDecoder ID3D11VideoContext"
3044 dxva2_deps="dxva2api_h DXVA2_ConfigPictureDecode ole32 user32"
3045 ffnvcodec_deps_any="libdl LoadLibrary"
3046 mediacodec_deps="android"
3047 nvdec_deps="ffnvcodec"
3048 vaapi_x11_deps="xlib_x11"
3049 videotoolbox_hwaccel_deps="videotoolbox pthreads"
3050 videotoolbox_hwaccel_extralibs="-framework QuartzCore"
3051 vulkan_deps_any="libdl LoadLibrary"
3052
3053 av1_d3d11va_hwaccel_deps="d3d11va DXVA_PicParams_AV1"
3054 av1_d3d11va_hwaccel_select="av1_decoder"
3055 av1_d3d11va2_hwaccel_deps="d3d11va DXVA_PicParams_AV1"
3056 av1_d3d11va2_hwaccel_select="av1_decoder"
3057 av1_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_AV1"
3058 av1_dxva2_hwaccel_select="av1_decoder"
3059 av1_nvdec_hwaccel_deps="nvdec CUVIDAV1PICPARAMS"
3060 av1_nvdec_hwaccel_select="av1_decoder"
3061 av1_vaapi_hwaccel_deps="vaapi VADecPictureParameterBufferAV1_bit_depth_idx"
3062 av1_vaapi_hwaccel_select="av1_decoder"
3063 av1_vdpau_hwaccel_deps="vdpau VdpPictureInfoAV1"
3064 av1_vdpau_hwaccel_select="av1_decoder"
3065 av1_vulkan_hwaccel_deps="vulkan"
3066 av1_vulkan_hwaccel_select="av1_decoder"
3067 h263_vaapi_hwaccel_deps="vaapi"
3068 h263_vaapi_hwaccel_select="h263_decoder"
3069 h263_videotoolbox_hwaccel_deps="videotoolbox"
3070 h263_videotoolbox_hwaccel_select="h263_decoder"
3071 h264_d3d11va_hwaccel_deps="d3d11va"
3072 h264_d3d11va_hwaccel_select="h264_decoder"
3073 h264_d3d11va2_hwaccel_deps="d3d11va"
3074 h264_d3d11va2_hwaccel_select="h264_decoder"
3075 h264_dxva2_hwaccel_deps="dxva2"
3076 h264_dxva2_hwaccel_select="h264_decoder"
3077 h264_nvdec_hwaccel_deps="nvdec"
3078 h264_nvdec_hwaccel_select="h264_decoder"
3079 h264_vaapi_hwaccel_deps="vaapi"
3080 h264_vaapi_hwaccel_select="h264_decoder"
3081 h264_vdpau_hwaccel_deps="vdpau"
3082 h264_vdpau_hwaccel_select="h264_decoder"
3083 h264_videotoolbox_hwaccel_deps="videotoolbox"
3084 h264_videotoolbox_hwaccel_select="h264_decoder"
3085 h264_vulkan_hwaccel_deps="vulkan"
3086 h264_vulkan_hwaccel_select="h264_decoder"
3087 hevc_d3d11va_hwaccel_deps="d3d11va DXVA_PicParams_HEVC"
3088 hevc_d3d11va_hwaccel_select="hevc_decoder"
3089 hevc_d3d11va2_hwaccel_deps="d3d11va DXVA_PicParams_HEVC"
3090 hevc_d3d11va2_hwaccel_select="hevc_decoder"
3091 hevc_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_HEVC"
3092 hevc_dxva2_hwaccel_select="hevc_decoder"
3093 hevc_nvdec_hwaccel_deps="nvdec"
3094 hevc_nvdec_hwaccel_select="hevc_decoder"
3095 hevc_vaapi_hwaccel_deps="vaapi VAPictureParameterBufferHEVC"
3096 hevc_vaapi_hwaccel_select="hevc_decoder"
3097 hevc_vdpau_hwaccel_deps="vdpau VdpPictureInfoHEVC"
3098 hevc_vdpau_hwaccel_select="hevc_decoder"
3099 hevc_videotoolbox_hwaccel_deps="videotoolbox"
3100 hevc_videotoolbox_hwaccel_select="hevc_decoder"
3101 hevc_vulkan_hwaccel_deps="vulkan"
3102 hevc_vulkan_hwaccel_select="hevc_decoder"
3103 mjpeg_nvdec_hwaccel_deps="nvdec"
3104 mjpeg_nvdec_hwaccel_select="mjpeg_decoder"
3105 mjpeg_vaapi_hwaccel_deps="vaapi"
3106 mjpeg_vaapi_hwaccel_select="mjpeg_decoder"
3107 mpeg1_nvdec_hwaccel_deps="nvdec"
3108 mpeg1_nvdec_hwaccel_select="mpeg1video_decoder"
3109 mpeg1_vdpau_hwaccel_deps="vdpau"
3110 mpeg1_vdpau_hwaccel_select="mpeg1video_decoder"
3111 mpeg1_videotoolbox_hwaccel_deps="videotoolbox"
3112 mpeg1_videotoolbox_hwaccel_select="mpeg1video_decoder"
3113 mpeg2_d3d11va_hwaccel_deps="d3d11va"
3114 mpeg2_d3d11va_hwaccel_select="mpeg2video_decoder"
3115 mpeg2_d3d11va2_hwaccel_deps="d3d11va"
3116 mpeg2_d3d11va2_hwaccel_select="mpeg2video_decoder"
3117 mpeg2_dxva2_hwaccel_deps="dxva2"
3118 mpeg2_dxva2_hwaccel_select="mpeg2video_decoder"
3119 mpeg2_nvdec_hwaccel_deps="nvdec"
3120 mpeg2_nvdec_hwaccel_select="mpeg2video_decoder"
3121 mpeg2_vaapi_hwaccel_deps="vaapi"
3122 mpeg2_vaapi_hwaccel_select="mpeg2video_decoder"
3123 mpeg2_vdpau_hwaccel_deps="vdpau"
3124 mpeg2_vdpau_hwaccel_select="mpeg2video_decoder"
3125 mpeg2_videotoolbox_hwaccel_deps="videotoolbox"
3126 mpeg2_videotoolbox_hwaccel_select="mpeg2video_decoder"
3127 mpeg4_nvdec_hwaccel_deps="nvdec"
3128 mpeg4_nvdec_hwaccel_select="mpeg4_decoder"
3129 mpeg4_vaapi_hwaccel_deps="vaapi"
3130 mpeg4_vaapi_hwaccel_select="mpeg4_decoder"
3131 mpeg4_vdpau_hwaccel_deps="vdpau"
3132 mpeg4_vdpau_hwaccel_select="mpeg4_decoder"
3133 mpeg4_videotoolbox_hwaccel_deps="videotoolbox"
3134 mpeg4_videotoolbox_hwaccel_select="mpeg4_decoder"
3135 prores_videotoolbox_hwaccel_deps="videotoolbox"
3136 prores_videotoolbox_hwaccel_select="prores_decoder"
3137 vc1_d3d11va_hwaccel_deps="d3d11va"
3138 vc1_d3d11va_hwaccel_select="vc1_decoder"
3139 vc1_d3d11va2_hwaccel_deps="d3d11va"
3140 vc1_d3d11va2_hwaccel_select="vc1_decoder"
3141 vc1_dxva2_hwaccel_deps="dxva2"
3142 vc1_dxva2_hwaccel_select="vc1_decoder"
3143 vc1_nvdec_hwaccel_deps="nvdec"
3144 vc1_nvdec_hwaccel_select="vc1_decoder"
3145 vc1_vaapi_hwaccel_deps="vaapi"
3146 vc1_vaapi_hwaccel_select="vc1_decoder"
3147 vc1_vdpau_hwaccel_deps="vdpau"
3148 vc1_vdpau_hwaccel_select="vc1_decoder"
3149 vp8_nvdec_hwaccel_deps="nvdec"
3150 vp8_nvdec_hwaccel_select="vp8_decoder"
3151 vp8_vaapi_hwaccel_deps="vaapi"
3152 vp8_vaapi_hwaccel_select="vp8_decoder"
3153 vp9_d3d11va_hwaccel_deps="d3d11va DXVA_PicParams_VP9"
3154 vp9_d3d11va_hwaccel_select="vp9_decoder"
3155 vp9_d3d11va2_hwaccel_deps="d3d11va DXVA_PicParams_VP9"
3156 vp9_d3d11va2_hwaccel_select="vp9_decoder"
3157 vp9_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_VP9"
3158 vp9_dxva2_hwaccel_select="vp9_decoder"
3159 vp9_nvdec_hwaccel_deps="nvdec"
3160 vp9_nvdec_hwaccel_select="vp9_decoder"
3161 vp9_vaapi_hwaccel_deps="vaapi VADecPictureParameterBufferVP9_bit_depth"
3162 vp9_vaapi_hwaccel_select="vp9_decoder"
3163 vp9_vdpau_hwaccel_deps="vdpau VdpPictureInfoVP9"
3164 vp9_vdpau_hwaccel_select="vp9_decoder"
3165 vp9_videotoolbox_hwaccel_deps="videotoolbox"
3166 vp9_videotoolbox_hwaccel_select="vp9_decoder"
3167 wmv3_d3d11va_hwaccel_select="vc1_d3d11va_hwaccel"
3168 wmv3_d3d11va2_hwaccel_select="vc1_d3d11va2_hwaccel"
3169 wmv3_dxva2_hwaccel_select="vc1_dxva2_hwaccel"
3170 wmv3_nvdec_hwaccel_select="vc1_nvdec_hwaccel"
3171 wmv3_vaapi_hwaccel_select="vc1_vaapi_hwaccel"
3172 wmv3_vdpau_hwaccel_select="vc1_vdpau_hwaccel"
3173
3174 # hardware-accelerated codecs
3175 mediafoundation_deps="mftransform_h MFCreateAlignedMemoryBuffer"
3176 omx_deps="libdl pthreads"
3177 omx_rpi_select="omx"
3178 qsv_deps="libmfx"
3179 qsvdec_select="qsv"
3180 qsvenc_select="qsv"
3181 qsvvpp_select="qsv"
3182 vaapi_encode_deps="vaapi"
3183 v4l2_m2m_deps="linux_videodev2_h sem_timedwait"
3184
3185 bilateral_cuda_filter_deps="ffnvcodec"
3186 bilateral_cuda_filter_deps_any="cuda_nvcc cuda_llvm"
3187 chromakey_cuda_filter_deps="ffnvcodec"
3188 chromakey_cuda_filter_deps_any="cuda_nvcc cuda_llvm"
3189 colorspace_cuda_filter_deps="ffnvcodec"
3190 colorspace_cuda_filter_deps_any="cuda_nvcc cuda_llvm"
3191 hwupload_cuda_filter_deps="ffnvcodec"
3192 scale_npp_filter_deps="ffnvcodec libnpp"
3193 scale2ref_npp_filter_deps="ffnvcodec libnpp"
3194 scale_cuda_filter_deps="ffnvcodec"
3195 scale_cuda_filter_deps_any="cuda_nvcc cuda_llvm"
3196 thumbnail_cuda_filter_deps="ffnvcodec"
3197 thumbnail_cuda_filter_deps_any="cuda_nvcc cuda_llvm"
3198 transpose_npp_filter_deps="ffnvcodec libnpp"
3199 overlay_cuda_filter_deps="ffnvcodec"
3200 overlay_cuda_filter_deps_any="cuda_nvcc cuda_llvm"
3201 sharpen_npp_filter_deps="ffnvcodec libnpp"
3202
3203 ddagrab_filter_deps="d3d11va IDXGIOutput1 DXGI_OUTDUPL_FRAME_INFO"
3204
3205 amf_deps_any="libdl LoadLibrary"
3206 nvenc_deps="ffnvcodec"
3207 nvenc_deps_any="libdl LoadLibrary"
3208
3209 aac_mf_encoder_deps="mediafoundation"
3210 ac3_mf_encoder_deps="mediafoundation"
3211 av1_cuvid_decoder_deps="cuvid CUVIDAV1PICPARAMS"
3212 av1_mediacodec_decoder_deps="mediacodec"
3213 av1_mediacodec_encoder_deps="mediacodec"
3214 av1_nvenc_encoder_deps="nvenc NV_ENC_PIC_PARAMS_AV1"
3215 av1_nvenc_encoder_select="atsc_a53"
3216 h263_v4l2m2m_decoder_deps="v4l2_m2m h263_v4l2_m2m"
3217 h263_v4l2m2m_encoder_deps="v4l2_m2m h263_v4l2_m2m"
3218 h264_amf_encoder_deps="amf"
3219 h264_crystalhd_decoder_select="crystalhd h264_mp4toannexb_bsf h264_parser"
3220 h264_cuvid_decoder_deps="cuvid"
3221 h264_cuvid_decoder_select="h264_mp4toannexb_bsf"
3222 h264_mediacodec_decoder_deps="mediacodec"
3223 h264_mediacodec_decoder_select="h264_mp4toannexb_bsf h264_parser"
3224 h264_mediacodec_encoder_deps="mediacodec"
3225 h264_mediacodec_encoder_select="h264_metadata"
3226 h264_mf_encoder_deps="mediafoundation"
3227 h264_mmal_decoder_deps="mmal"
3228 h264_nvenc_encoder_deps="nvenc"
3229 h264_nvenc_encoder_select="atsc_a53"
3230 h264_omx_encoder_deps="omx"
3231 h264_qsv_decoder_select="h264_mp4toannexb_bsf qsvdec"
3232 h264_qsv_encoder_select="atsc_a53 qsvenc"
3233 h264_rkmpp_decoder_deps="rkmpp"
3234 h264_rkmpp_decoder_select="h264_mp4toannexb_bsf"
3235 h264_vaapi_encoder_select="atsc_a53 cbs_h264 vaapi_encode"
3236 h264_v4l2m2m_decoder_deps="v4l2_m2m h264_v4l2_m2m"
3237 h264_v4l2m2m_decoder_select="h264_mp4toannexb_bsf"
3238 h264_v4l2m2m_encoder_deps="v4l2_m2m h264_v4l2_m2m"
3239 hevc_amf_encoder_deps="amf"
3240 hevc_cuvid_decoder_deps="cuvid"
3241 hevc_cuvid_decoder_select="hevc_mp4toannexb_bsf"
3242 hevc_mediacodec_decoder_deps="mediacodec"
3243 hevc_mediacodec_decoder_select="hevc_mp4toannexb_bsf hevc_parser"
3244 hevc_mediacodec_encoder_deps="mediacodec"
3245 hevc_mediacodec_encoder_select="hevc_metadata"
3246 hevc_mf_encoder_deps="mediafoundation"
3247 hevc_nvenc_encoder_deps="nvenc"
3248 hevc_nvenc_encoder_select="atsc_a53"
3249 hevc_qsv_decoder_select="hevc_mp4toannexb_bsf qsvdec"
3250 hevc_qsv_encoder_select="hevcparse qsvenc"
3251 hevc_rkmpp_decoder_deps="rkmpp"
3252 hevc_rkmpp_decoder_select="hevc_mp4toannexb_bsf"
3253 hevc_vaapi_encoder_deps="VAEncPictureParameterBufferHEVC"
3254 hevc_vaapi_encoder_select="atsc_a53 cbs_h265 vaapi_encode"
3255 hevc_v4l2m2m_decoder_deps="v4l2_m2m hevc_v4l2_m2m"
3256 hevc_v4l2m2m_decoder_select="hevc_mp4toannexb_bsf"
3257 hevc_v4l2m2m_encoder_deps="v4l2_m2m hevc_v4l2_m2m"
3258 mjpeg_cuvid_decoder_deps="cuvid"
3259 mjpeg_qsv_decoder_select="qsvdec"
3260 mjpeg_qsv_encoder_deps="libmfx"
3261 mjpeg_qsv_encoder_select="qsvenc"
3262 mjpeg_vaapi_encoder_deps="VAEncPictureParameterBufferJPEG"
3263 mjpeg_vaapi_encoder_select="cbs_jpeg jpegtables vaapi_encode"
3264 mp3_mf_encoder_deps="mediafoundation"
3265 mpeg1_cuvid_decoder_deps="cuvid"
3266 mpeg1_v4l2m2m_decoder_deps="v4l2_m2m mpeg1_v4l2_m2m"
3267 mpeg2_crystalhd_decoder_select="crystalhd"
3268 mpeg2_cuvid_decoder_deps="cuvid"
3269 mpeg2_mmal_decoder_deps="mmal"
3270 mpeg2_mediacodec_decoder_deps="mediacodec"
3271 mpeg2_qsv_decoder_select="qsvdec"
3272 mpeg2_qsv_encoder_select="qsvenc"
3273 mpeg2_vaapi_encoder_select="cbs_mpeg2 vaapi_encode"
3274 mpeg2_v4l2m2m_decoder_deps="v4l2_m2m mpeg2_v4l2_m2m"
3275 mpeg4_crystalhd_decoder_select="crystalhd"
3276 mpeg4_cuvid_decoder_deps="cuvid"
3277 mpeg4_mediacodec_decoder_deps="mediacodec"
3278 mpeg4_mediacodec_encoder_deps="mediacodec"
3279 mpeg4_mmal_decoder_deps="mmal"
3280 mpeg4_omx_encoder_deps="omx"
3281 mpeg4_v4l2m2m_decoder_deps="v4l2_m2m mpeg4_v4l2_m2m"
3282 mpeg4_v4l2m2m_encoder_deps="v4l2_m2m mpeg4_v4l2_m2m"
3283 msmpeg4_crystalhd_decoder_select="crystalhd"
3284 vc1_crystalhd_decoder_select="crystalhd"
3285 vc1_cuvid_decoder_deps="cuvid"
3286 vc1_mmal_decoder_deps="mmal"
3287 vc1_qsv_decoder_select="qsvdec"
3288 vc1_v4l2m2m_decoder_deps="v4l2_m2m vc1_v4l2_m2m"
3289 vp8_cuvid_decoder_deps="cuvid"
3290 vp8_mediacodec_decoder_deps="mediacodec"
3291 vp8_mediacodec_encoder_deps="mediacodec"
3292 vp8_qsv_decoder_select="qsvdec"
3293 vp8_rkmpp_decoder_deps="rkmpp"
3294 vp8_vaapi_encoder_deps="VAEncPictureParameterBufferVP8"
3295 vp8_vaapi_encoder_select="vaapi_encode"
3296 vp8_v4l2m2m_decoder_deps="v4l2_m2m vp8_v4l2_m2m"
3297 vp8_v4l2m2m_encoder_deps="v4l2_m2m vp8_v4l2_m2m"
3298 vp9_cuvid_decoder_deps="cuvid"
3299 vp9_mediacodec_decoder_deps="mediacodec"
3300 vp9_mediacodec_encoder_deps="mediacodec"
3301 vp9_qsv_decoder_select="qsvdec"
3302 vp9_rkmpp_decoder_deps="rkmpp"
3303 vp9_vaapi_encoder_deps="VAEncPictureParameterBufferVP9"
3304 vp9_vaapi_encoder_select="vaapi_encode"
3305 vp9_qsv_encoder_deps="libmfx MFX_CODEC_VP9"
3306 vp9_qsv_encoder_select="qsvenc"
3307 vp9_v4l2m2m_decoder_deps="v4l2_m2m vp9_v4l2_m2m"
3308 wmv3_crystalhd_decoder_select="crystalhd"
3309 av1_qsv_decoder_select="qsvdec"
3310 av1_qsv_encoder_select="qsvenc"
3311 av1_qsv_encoder_deps="libvpl"
3312 av1_amf_encoder_deps="amf"
3313 av1_vaapi_encoder_deps="VAEncPictureParameterBufferAV1"
3314 av1_vaapi_encoder_select="cbs_av1 vaapi_encode"
3315
3316 # parsers
3317 aac_parser_select="adts_header mpeg4audio"
3318 av1_parser_select="cbs_av1"
3319 evc_parser_select="evcparse"
3320 h264_parser_select="golomb h264dsp h264parse h264_sei"
3321 hevc_parser_select="hevcparse hevc_sei"
3322 mpegaudio_parser_select="mpegaudioheader"
3323 mpeg4video_parser_select="h263dsp mpegvideodec qpeldsp"
3324 vc1_parser_select="vc1dsp"
3325 vvc_parser_select="cbs_h266"
3326
3327 # bitstream_filters
3328 aac_adtstoasc_bsf_select="adts_header mpeg4audio"
3329 av1_frame_merge_bsf_select="cbs_av1"
3330 av1_frame_split_bsf_select="cbs_av1"
3331 av1_metadata_bsf_select="cbs_av1"
3332 dts2pts_bsf_select="cbs_h264 h264parse"
3333 eac3_core_bsf_select="ac3_parser"
3334 evc_frame_merge_bsf_select="evcparse"
3335 filter_units_bsf_select="cbs"
3336 h264_metadata_bsf_deps="const_nan"
3337 h264_metadata_bsf_select="cbs_h264"
3338 h264_redundant_pps_bsf_select="cbs_h264"
3339 hevc_metadata_bsf_select="cbs_h265"
3340 mjpeg2jpeg_bsf_select="jpegtables"
3341 mpeg2_metadata_bsf_select="cbs_mpeg2"
3342 trace_headers_bsf_select="cbs"
3343 vp9_metadata_bsf_select="cbs_vp9"
3344 vvc_metadata_bsf_select="cbs_h266"
3345
3346 # external libraries
3347 aac_at_decoder_deps="audiotoolbox"
3348 aac_at_decoder_select="aac_adtstoasc_bsf"
3349 ac3_at_decoder_deps="audiotoolbox"
3350 ac3_at_decoder_select="ac3_parser"
3351 adpcm_ima_qt_at_decoder_deps="audiotoolbox"
3352 alac_at_decoder_deps="audiotoolbox"
3353 amr_nb_at_decoder_deps="audiotoolbox"
3354 avisynth_deps_any="libdl LoadLibrary"
3355 avisynth_demuxer_deps="avisynth"
3356 avisynth_demuxer_select="riffdec"
3357 eac3_at_decoder_deps="audiotoolbox"
3358 eac3_at_decoder_select="ac3_parser"
3359 gsm_ms_at_decoder_deps="audiotoolbox"
3360 ilbc_at_decoder_deps="audiotoolbox"
3361 mp1_at_decoder_deps="audiotoolbox"
3362 mp2_at_decoder_deps="audiotoolbox"
3363 mp3_at_decoder_deps="audiotoolbox"
3364 mp1_at_decoder_select="mpegaudioheader"
3365 mp2_at_decoder_select="mpegaudioheader"
3366 mp3_at_decoder_select="mpegaudioheader"
3367 pcm_alaw_at_decoder_deps="audiotoolbox"
3368 pcm_mulaw_at_decoder_deps="audiotoolbox"
3369 qdmc_at_decoder_deps="audiotoolbox"
3370 qdm2_at_decoder_deps="audiotoolbox"
3371 aac_at_encoder_deps="audiotoolbox"
3372 aac_at_encoder_select="audio_frame_queue"
3373 alac_at_encoder_deps="audiotoolbox"
3374 alac_at_encoder_select="audio_frame_queue"
3375 ilbc_at_encoder_deps="audiotoolbox"
3376 ilbc_at_encoder_select="audio_frame_queue"
3377 pcm_alaw_at_encoder_deps="audiotoolbox"
3378 pcm_alaw_at_encoder_select="audio_frame_queue"
3379 pcm_mulaw_at_encoder_deps="audiotoolbox"
3380 pcm_mulaw_at_encoder_select="audio_frame_queue"
3381 chromaprint_muxer_deps="chromaprint"
3382 h264_videotoolbox_encoder_deps="pthreads"
3383 h264_videotoolbox_encoder_select="atsc_a53 videotoolbox_encoder"
3384 hevc_videotoolbox_encoder_deps="pthreads"
3385 hevc_videotoolbox_encoder_select="atsc_a53 videotoolbox_encoder"
3386 prores_videotoolbox_encoder_deps="pthreads"
3387 prores_videotoolbox_encoder_select="videotoolbox_encoder"
3388 libaom_av1_decoder_deps="libaom"
3389 libaom_av1_encoder_deps="libaom"
3390 libaom_av1_encoder_select="extract_extradata_bsf"
3391 libaribb24_decoder_deps="libaribb24"
3392 libaribcaption_decoder_deps="libaribcaption"
3393 libcelt_decoder_deps="libcelt"
3394 libcodec2_decoder_deps="libcodec2"
3395 libcodec2_encoder_deps="libcodec2"
3396 libdav1d_decoder_deps="libdav1d"
3397 libdav1d_decoder_select="atsc_a53"
3398 libdavs2_decoder_deps="libdavs2"
3399 libdavs2_decoder_select="avs2_parser"
3400 libfdk_aac_decoder_deps="libfdk_aac"
3401 libfdk_aac_encoder_deps="libfdk_aac"
3402 libfdk_aac_encoder_select="audio_frame_queue"
3403 libgme_demuxer_deps="libgme"
3404 libgsm_decoder_deps="libgsm"
3405 libgsm_encoder_deps="libgsm"
3406 libgsm_ms_decoder_deps="libgsm"
3407 libgsm_ms_encoder_deps="libgsm"
3408 libilbc_decoder_deps="libilbc"
3409 libilbc_encoder_deps="libilbc"
3410 libjxl_decoder_deps="libjxl libjxl_threads"
3411 libjxl_encoder_deps="libjxl libjxl_threads"
3412 libkvazaar_encoder_deps="libkvazaar"
3413 libmodplug_demuxer_deps="libmodplug"
3414 libmp3lame_encoder_deps="libmp3lame"
3415 libmp3lame_encoder_select="audio_frame_queue mpegaudioheader"
3416 libopencore_amrnb_decoder_deps="libopencore_amrnb"
3417 libopencore_amrnb_encoder_deps="libopencore_amrnb"
3418 libopencore_amrnb_encoder_select="audio_frame_queue"
3419 libopencore_amrwb_decoder_deps="libopencore_amrwb"
3420 libopenh264_decoder_deps="libopenh264"
3421 libopenh264_decoder_select="h264_mp4toannexb_bsf"
3422 libopenh264_encoder_deps="libopenh264"
3423 libopenjpeg_encoder_deps="libopenjpeg"
3424 libopenmpt_demuxer_deps="libopenmpt"
3425 libopus_decoder_deps="libopus"
3426 libopus_encoder_deps="libopus"
3427 libopus_encoder_select="audio_frame_queue"
3428 librav1e_encoder_deps="librav1e"
3429 librsvg_decoder_deps="librsvg"
3430 libshine_encoder_deps="libshine"
3431 libshine_encoder_select="audio_frame_queue mpegaudioheader"
3432 libspeex_decoder_deps="libspeex"
3433 libspeex_encoder_deps="libspeex"
3434 libspeex_encoder_select="audio_frame_queue"
3435 libsvtav1_encoder_deps="libsvtav1"
3436 libtheora_encoder_deps="libtheora"
3437 libtwolame_encoder_deps="libtwolame"
3438 libuavs3d_decoder_deps="libuavs3d"
3439 libvo_amrwbenc_encoder_deps="libvo_amrwbenc"
3440 libvorbis_decoder_deps="libvorbis"
3441 libvorbis_encoder_deps="libvorbis libvorbisenc"
3442 libvorbis_encoder_select="audio_frame_queue"
3443 libvpx_vp8_decoder_deps="libvpx"
3444 libvpx_vp8_encoder_deps="libvpx"
3445 libvpx_vp9_decoder_deps="libvpx"
3446 libvpx_vp9_encoder_deps="libvpx"
3447 libwebp_encoder_deps="libwebp"
3448 libwebp_anim_encoder_deps="libwebp"
3449 libx262_encoder_deps="libx262"
3450 libx264_encoder_deps="libx264"
3451 libx264_encoder_select="atsc_a53"
3452 libx264rgb_encoder_deps="libx264"
3453 libx264rgb_encoder_select="libx264_encoder"
3454 libx265_encoder_deps="libx265"
3455 libx265_encoder_select="atsc_a53"
3456 libxavs_encoder_deps="libxavs"
3457 libxavs2_encoder_deps="libxavs2"
3458 libxvid_encoder_deps="libxvid"
3459 libzvbi_teletext_decoder_deps="libzvbi"
3460 vapoursynth_demuxer_deps="vapoursynth"
3461 videotoolbox_suggest="coreservices"
3462 videotoolbox_deps="corefoundation coremedia corevideo"
3463 videotoolbox_encoder_deps="videotoolbox VTCompressionSessionPrepareToEncodeFrames"
3464
3465 # demuxers / muxers
3466 ac3_demuxer_select="ac3_parser"
3467 act_demuxer_select="riffdec"
3468 adts_muxer_select="mpeg4audio"
3469 aiff_muxer_select="iso_media"
3470 amv_muxer_select="riffenc"
3471 asf_demuxer_select="riffdec"
3472 asf_o_demuxer_select="riffdec"
3473 asf_muxer_select="riffenc"
3474 asf_stream_muxer_select="asf_muxer"
3475 av1_demuxer_select="av1_frame_merge_bsf av1_parser"
3476 avi_demuxer_select="riffdec exif"
3477 avi_muxer_select="riffenc"
3478 avif_muxer_select="mov_muxer"
3479 caf_demuxer_select="iso_media"
3480 caf_muxer_select="iso_media"
3481 dash_muxer_select="mp4_muxer"
3482 dash_demuxer_deps="libxml2"
3483 dirac_demuxer_select="dirac_parser"
3484 dts_demuxer_select="dca_parser"
3485 dtshd_demuxer_select="dca_parser"
3486 dv_demuxer_select="dvprofile"
3487 dv_muxer_select="dvprofile"
3488 dxa_demuxer_select="riffdec"
3489 eac3_demuxer_select="ac3_parser"
3490 evc_demuxer_select="evc_frame_merge_bsf evc_parser"
3491 f4v_muxer_select="mov_muxer"
3492 fifo_muxer_deps="threads"
3493 flac_demuxer_select="flac_parser"
3494 flv_muxer_select="aac_adtstoasc_bsf"
3495 gxf_muxer_select="pcm_rechunk_bsf"
3496 hds_muxer_select="flv_muxer"
3497 hls_demuxer_select="adts_header ac3_parser mov_demuxer mpegts_demuxer"
3498 hls_muxer_select="mov_muxer mpegts_muxer"
3499 image2_alias_pix_demuxer_select="image2_demuxer"
3500 image2_brender_pix_demuxer_select="image2_demuxer"
3501 imf_demuxer_deps="libxml2"
3502 imf_demuxer_select="mxf_demuxer"
3503 ipod_muxer_select="mov_muxer"
3504 ismv_muxer_select="mov_muxer"
3505 ivf_muxer_select="av1_metadata_bsf vp9_superframe_bsf"
3506 latm_muxer_select="aac_adtstoasc_bsf mpeg4audio"
3507 matroska_audio_muxer_select="matroska_muxer"
3508 matroska_demuxer_select="riffdec"
3509 matroska_demuxer_suggest="bzlib zlib"
3510 matroska_muxer_select="mpeg4audio riffenc aac_adtstoasc_bsf pgs_frame_merge_bsf vp9_superframe_bsf"
3511 mlp_demuxer_select="mlp_parser"
3512 mmf_muxer_select="riffenc"
3513 mov_demuxer_select="iso_media riffdec"
3514 mov_demuxer_suggest="zlib"
3515 mov_muxer_select="iso_media riffenc rtpenc_chain vp9_superframe_bsf aac_adtstoasc_bsf ac3_parser"
3516 mp3_demuxer_select="mpegaudio_parser"
3517 mp3_muxer_select="mpegaudioheader"
3518 mp4_muxer_select="mov_muxer"
3519 mpegts_demuxer_select="iso_media"
3520 mpegts_muxer_select="ac3_parser adts_muxer latm_muxer h264_mp4toannexb_bsf hevc_mp4toannexb_bsf"
3521 mpegtsraw_demuxer_select="mpegts_demuxer"
3522 mxf_muxer_select="pcm_rechunk_bsf rangecoder"
3523 mxf_d10_muxer_select="mxf_muxer"
3524 mxf_opatom_muxer_select="mxf_muxer"
3525 nut_muxer_select="riffenc"
3526 nuv_demuxer_select="riffdec"
3527 obu_demuxer_select="av1_frame_merge_bsf av1_parser"
3528 obu_muxer_select="av1_metadata_bsf"
3529 oga_muxer_select="ogg_muxer"
3530 ogg_demuxer_select="dirac_parse"
3531 ogv_muxer_select="ogg_muxer"
3532 opus_muxer_select="ogg_muxer"
3533 psp_muxer_select="mov_muxer"
3534 rtp_demuxer_select="sdp_demuxer"
3535 rtp_mpegts_muxer_select="mpegts_muxer rtp_muxer"
3536 rtpdec_select="asf_demuxer mov_demuxer mpegts_demuxer rm_demuxer rtp_protocol srtp"
3537 rtsp_demuxer_select="http_protocol rtpdec"
3538 rtsp_muxer_select="rtp_muxer http_protocol rtp_protocol rtpenc_chain"
3539 sap_demuxer_select="sdp_demuxer"
3540 sap_muxer_select="rtp_muxer rtp_protocol rtpenc_chain"
3541 sdp_demuxer_select="rtpdec"
3542 smoothstreaming_muxer_select="ismv_muxer"
3543 spdif_demuxer_select="adts_header"
3544 spdif_muxer_select="adts_header"
3545 spx_muxer_select="ogg_muxer"
3546 swf_demuxer_suggest="zlib"
3547 tak_demuxer_select="tak_parser"
3548 truehd_demuxer_select="mlp_parser"
3549 tg2_muxer_select="mov_muxer"
3550 tgp_muxer_select="mov_muxer"
3551 vobsub_demuxer_select="mpegps_demuxer"
3552 w64_demuxer_select="wav_demuxer"
3553 w64_muxer_select="wav_muxer"
3554 wav_demuxer_select="riffdec"
3555 wav_muxer_select="riffenc"
3556 webm_chunk_muxer_select="webm_muxer"
3557 webm_dash_manifest_demuxer_select="matroska_demuxer"
3558 wtv_demuxer_select="mpegts_demuxer riffdec"
3559 wtv_muxer_select="mpegts_muxer riffenc"
3560 xmv_demuxer_select="riffdec"
3561 xwma_demuxer_select="riffdec"
3562
3563 # indevs / outdevs
3564 android_camera_indev_deps="android camera2ndk mediandk pthreads"
3565 alsa_indev_deps="alsa"
3566 alsa_outdev_deps="alsa"
3567 avfoundation_indev_deps="avfoundation corevideo coremedia pthreads"
3568 avfoundation_indev_suggest="coregraphics applicationservices"
3569 avfoundation_indev_extralibs="-framework Foundation"
3570 audiotoolbox_outdev_deps="audiotoolbox pthreads"
3571 audiotoolbox_outdev_extralibs="-framework AudioToolbox -framework CoreAudio"
3572 bktr_indev_deps_any="dev_bktr_ioctl_bt848_h machine_ioctl_bt848_h dev_video_bktr_ioctl_bt848_h dev_ic_bt8xx_h"
3573 caca_outdev_deps="libcaca"
3574 decklink_deps_any="libdl LoadLibrary"
3575 decklink_indev_deps="decklink threads"
3576 decklink_indev_extralibs="-lstdc++"
3577 decklink_indev_suggest="libzvbi"
3578 decklink_outdev_deps="decklink threads"
3579 decklink_outdev_suggest="libklvanc"
3580 decklink_outdev_extralibs="-lstdc++"
3581 dshow_indev_deps="IBaseFilter"
3582 dshow_indev_extralibs="-lpsapi -lole32 -lstrmiids -luuid -loleaut32 -lshlwapi"
3583 fbdev_indev_deps="linux_fb_h"
3584 fbdev_outdev_deps="linux_fb_h"
3585 gdigrab_indev_deps="CreateDIBSection"
3586 gdigrab_indev_extralibs="-lgdi32"
3587 gdigrab_indev_select="bmp_decoder"
3588 iec61883_indev_deps="libiec61883"
3589 iec61883_indev_select="dv_demuxer"
3590 jack_indev_deps="libjack"
3591 jack_indev_deps_any="sem_timedwait dispatch_dispatch_h"
3592 kmsgrab_indev_deps="libdrm"
3593 lavfi_indev_deps="avfilter"
3594 libcdio_indev_deps="libcdio"
3595 libdc1394_indev_deps="libdc1394"
3596 openal_indev_deps="openal"
3597 opengl_outdev_deps="opengl"
3598 opengl_outdev_suggest="sdl2"
3599 oss_indev_deps_any="sys_soundcard_h"
3600 oss_outdev_deps_any="sys_soundcard_h"
3601 pulse_indev_deps="libpulse"
3602 pulse_outdev_deps="libpulse"
3603 sdl2_outdev_deps="sdl2"
3604 sndio_indev_deps="sndio"
3605 sndio_outdev_deps="sndio"
3606 v4l2_indev_deps_any="linux_videodev2_h sys_videoio_h"
3607 v4l2_indev_suggest="libv4l2"
3608 v4l2_outdev_deps_any="linux_videodev2_h sys_videoio_h"
3609 v4l2_outdev_suggest="libv4l2"
3610 vfwcap_indev_deps="vfw32 vfwcap_defines"
3611 xcbgrab_indev_deps="libxcb"
3612 xcbgrab_indev_suggest="libxcb_shm libxcb_shape libxcb_xfixes"
3613 xv_outdev_deps="xlib_xv xlib_x11 xlib_xext"
3614
3615 # protocols
3616 async_protocol_deps="threads"
3617 bluray_protocol_deps="libbluray"
3618 ffrtmpcrypt_protocol_conflict="librtmp_protocol"
3619 ffrtmpcrypt_protocol_deps_any="gcrypt gmp openssl mbedtls"
3620 ffrtmpcrypt_protocol_select="tcp_protocol"
3621 ffrtmphttp_protocol_conflict="librtmp_protocol"
3622 ffrtmphttp_protocol_select="http_protocol"
3623 ftp_protocol_select="tcp_protocol"
3624 gopher_protocol_select="tcp_protocol"
3625 gophers_protocol_select="tls_protocol"
3626 http_protocol_select="tcp_protocol"
3627 http_protocol_suggest="zlib"
3628 httpproxy_protocol_select="tcp_protocol"
3629 httpproxy_protocol_suggest="zlib"
3630 https_protocol_select="tls_protocol"
3631 https_protocol_suggest="zlib"
3632 icecast_protocol_select="http_protocol"
3633 mmsh_protocol_select="http_protocol"
3634 mmst_protocol_select="network"
3635 rtmp_protocol_conflict="librtmp_protocol"
3636 rtmp_protocol_select="tcp_protocol"
3637 rtmp_protocol_suggest="zlib"
3638 rtmpe_protocol_select="ffrtmpcrypt_protocol"
3639 rtmpe_protocol_suggest="zlib"
3640 rtmps_protocol_conflict="librtmp_protocol"
3641 rtmps_protocol_select="tls_protocol"
3642 rtmps_protocol_suggest="zlib"
3643 rtmpt_protocol_select="ffrtmphttp_protocol"
3644 rtmpt_protocol_suggest="zlib"
3645 rtmpte_protocol_select="ffrtmpcrypt_protocol ffrtmphttp_protocol"
3646 rtmpte_protocol_suggest="zlib"
3647 rtmpts_protocol_select="ffrtmphttp_protocol https_protocol"
3648 rtmpts_protocol_suggest="zlib"
3649 rtp_protocol_select="udp_protocol"
3650 schannel_conflict="openssl gnutls libtls mbedtls"
3651 sctp_protocol_deps="struct_sctp_event_subscribe struct_msghdr_msg_flags"
3652 sctp_protocol_select="network"
3653 securetransport_conflict="openssl gnutls libtls mbedtls"
3654 srtp_protocol_select="rtp_protocol srtp"
3655 tcp_protocol_select="network"
3656 tls_protocol_deps_any="gnutls openssl schannel securetransport libtls mbedtls"
3657 tls_protocol_select="tcp_protocol"
3658 udp_protocol_select="network"
3659 udplite_protocol_select="network"
3660 unix_protocol_deps="sys_un_h"
3661 unix_protocol_select="network"
3662 ipfs_gateway_protocol_select="https_protocol"
3663 ipns_gateway_protocol_select="https_protocol"
3664
3665 # external library protocols
3666 libamqp_protocol_deps="librabbitmq"
3667 libamqp_protocol_select="network"
3668 librist_protocol_deps="librist"
3669 librist_protocol_select="network"
3670 librtmp_protocol_deps="librtmp"
3671 librtmpe_protocol_deps="librtmp"
3672 librtmps_protocol_deps="librtmp"
3673 librtmpt_protocol_deps="librtmp"
3674 librtmpte_protocol_deps="librtmp"
3675 libsmbclient_protocol_deps="libsmbclient gplv3"
3676 libsrt_protocol_deps="libsrt"
3677 libsrt_protocol_select="network"
3678 libssh_protocol_deps="libssh"
3679 libtls_conflict="openssl gnutls mbedtls"
3680 libzmq_protocol_deps="libzmq"
3681 libzmq_protocol_select="network"
3682
3683 # filters
3684 ametadata_filter_deps="avformat"
3685 amovie_filter_deps="avcodec avformat"
3686 aresample_filter_deps="swresample"
3687 asr_filter_deps="pocketsphinx"
3688 ass_filter_deps="libass"
3689 avgblur_opencl_filter_deps="opencl"
3690 avgblur_vulkan_filter_deps="vulkan spirv_compiler"
3691 azmq_filter_deps="libzmq"
3692 blackframe_filter_deps="gpl"
3693 blend_vulkan_filter_deps="vulkan spirv_compiler"
3694 boxblur_filter_deps="gpl"
3695 boxblur_opencl_filter_deps="opencl gpl"
3696 bs2b_filter_deps="libbs2b"
3697 bwdif_cuda_filter_deps="ffnvcodec"
3698 bwdif_cuda_filter_deps_any="cuda_nvcc cuda_llvm"
3699 bwdif_vulkan_filter_deps="vulkan spirv_compiler"
3700 chromaber_vulkan_filter_deps="vulkan spirv_compiler"
3701 color_vulkan_filter_deps="vulkan spirv_compiler"
3702 colorkey_opencl_filter_deps="opencl"
3703 colormatrix_filter_deps="gpl"
3704 convolution_opencl_filter_deps="opencl"
3705 coreimage_filter_deps="coreimage appkit"
3706 coreimage_filter_extralibs="-framework OpenGL"
3707 coreimagesrc_filter_deps="coreimage appkit"
3708 coreimagesrc_filter_extralibs="-framework OpenGL"
3709 cover_rect_filter_deps="avcodec avformat gpl"
3710 cropdetect_filter_deps="gpl"
3711 deinterlace_qsv_filter_deps="libmfx"
3712 deinterlace_qsv_filter_select="qsvvpp"
3713 deinterlace_vaapi_filter_deps="vaapi"
3714 delogo_filter_deps="gpl"
3715 denoise_vaapi_filter_deps="vaapi"
3716 derain_filter_select="dnn"
3717 deshake_filter_select="pixelutils"
3718 deshake_opencl_filter_deps="opencl"
3719 dilation_opencl_filter_deps="opencl"
3720 dnn_classify_filter_select="dnn"
3721 dnn_detect_filter_select="dnn"
3722 dnn_processing_filter_select="dnn"
3723 drawtext_filter_deps="libfreetype libharfbuzz"
3724 drawtext_filter_suggest="libfontconfig libfribidi"
3725 elbg_filter_deps="avcodec"
3726 eq_filter_deps="gpl"
3727 erosion_opencl_filter_deps="opencl"
3728 find_rect_filter_deps="avcodec avformat gpl"
3729 flip_vulkan_filter_deps="vulkan spirv_compiler"
3730 flite_filter_deps="libflite threads"
3731 framerate_filter_select="scene_sad"
3732 freezedetect_filter_select="scene_sad"
3733 frei0r_deps_any="libdl LoadLibrary"
3734 frei0r_filter_deps="frei0r"
3735 frei0r_src_filter_deps="frei0r"
3736 fspp_filter_deps="gpl"
3737 gblur_vulkan_filter_deps="vulkan spirv_compiler"
3738 hflip_vulkan_filter_deps="vulkan spirv_compiler"
3739 histeq_filter_deps="gpl"
3740 hqdn3d_filter_deps="gpl"
3741 iccdetect_filter_deps="lcms2"
3742 iccgen_filter_deps="lcms2"
3743 interlace_filter_deps="gpl"
3744 kerndeint_filter_deps="gpl"
3745 ladspa_filter_deps="ladspa libdl"
3746 lensfun_filter_deps="liblensfun version3"
3747 libplacebo_filter_deps="libplacebo vulkan"
3748 lv2_filter_deps="lv2"
3749 mcdeint_filter_deps="avcodec gpl"
3750 metadata_filter_deps="avformat"
3751 movie_filter_deps="avcodec avformat"
3752 mpdecimate_filter_deps="gpl"
3753 mpdecimate_filter_select="pixelutils"
3754 minterpolate_filter_select="scene_sad"
3755 mptestsrc_filter_deps="gpl"
3756 negate_filter_deps="lut_filter"
3757 nlmeans_opencl_filter_deps="opencl"
3758 nlmeans_vulkan_filter_deps="vulkan spirv_compiler"
3759 nnedi_filter_deps="gpl"
3760 ocr_filter_deps="libtesseract"
3761 ocv_filter_deps="libopencv"
3762 openclsrc_filter_deps="opencl"
3763 overlay_opencl_filter_deps="opencl"
3764 overlay_qsv_filter_deps="libmfx"
3765 overlay_qsv_filter_select="qsvvpp"
3766 overlay_vaapi_filter_deps="vaapi VAProcPipelineCaps_blend_flags"
3767 overlay_vulkan_filter_deps="vulkan spirv_compiler"
3768 owdenoise_filter_deps="gpl"
3769 pad_opencl_filter_deps="opencl"
3770 pan_filter_deps="swresample"
3771 perspective_filter_deps="gpl"
3772 phase_filter_deps="gpl"
3773 pp7_filter_deps="gpl"
3774 pp_filter_deps="gpl postproc"
3775 prewitt_opencl_filter_deps="opencl"
3776 procamp_vaapi_filter_deps="vaapi"
3777 program_opencl_filter_deps="opencl"
3778 pullup_filter_deps="gpl"
3779 remap_opencl_filter_deps="opencl"
3780 removelogo_filter_deps="avcodec avformat swscale"
3781 repeatfields_filter_deps="gpl"
3782 roberts_opencl_filter_deps="opencl"
3783 rubberband_filter_deps="librubberband"
3784 sab_filter_deps="gpl swscale"
3785 scale2ref_filter_deps="swscale"
3786 scale_filter_deps="swscale"
3787 scale_qsv_filter_deps="libmfx"
3788 scale_qsv_filter_select="qsvvpp"
3789 scdet_filter_select="scene_sad"
3790 select_filter_select="scene_sad"
3791 sharpness_vaapi_filter_deps="vaapi"
3792 showcqt_filter_deps="avformat swscale"
3793 showcqt_filter_suggest="libfontconfig libfreetype"
3794 signature_filter_deps="gpl avcodec avformat"
3795 smartblur_filter_deps="gpl swscale"
3796 sobel_opencl_filter_deps="opencl"
3797 sofalizer_filter_deps="libmysofa"
3798 spp_filter_deps="gpl avcodec"
3799 spp_filter_select="idctdsp fdctdsp me_cmp pixblockdsp"
3800 sr_filter_deps="avformat swscale"
3801 sr_filter_select="dnn"
3802 stereo3d_filter_deps="gpl"
3803 subtitles_filter_deps="avformat avcodec libass"
3804 super2xsai_filter_deps="gpl"
3805 pixfmts_super2xsai_test_deps="super2xsai_filter"
3806 tinterlace_filter_deps="gpl"
3807 tinterlace_merge_test_deps="tinterlace_filter"
3808 tinterlace_pad_test_deps="tinterlace_filter"
3809 tonemap_filter_deps="const_nan"
3810 tonemap_vaapi_filter_deps="vaapi VAProcFilterParameterBufferHDRToneMapping"
3811 tonemap_opencl_filter_deps="opencl const_nan"
3812 transpose_opencl_filter_deps="opencl"
3813 transpose_vaapi_filter_deps="vaapi VAProcPipelineCaps_rotation_flags"
3814 transpose_vt_filter_deps="videotoolbox VTPixelRotationSessionCreate"
3815 transpose_vulkan_filter_deps="vulkan spirv_compiler"
3816 unsharp_opencl_filter_deps="opencl"
3817 uspp_filter_deps="gpl avcodec"
3818 vaguedenoiser_filter_deps="gpl"
3819 vflip_vulkan_filter_deps="vulkan spirv_compiler"
3820 vidstabdetect_filter_deps="libvidstab"
3821 vidstabtransform_filter_deps="libvidstab"
3822 libvmaf_filter_deps="libvmaf"
3823 libvmaf_cuda_filter_deps="libvmaf libvmaf_cuda ffnvcodec"
3824 zmq_filter_deps="libzmq"
3825 zoompan_filter_deps="swscale"
3826 zscale_filter_deps="libzimg const_nan"
3827 scale_vaapi_filter_deps="vaapi"
3828 scale_vt_filter_deps="videotoolbox"
3829 scale_vulkan_filter_deps="vulkan spirv_compiler"
3830 vpp_qsv_filter_deps="libmfx"
3831 vpp_qsv_filter_select="qsvvpp"
3832 xfade_opencl_filter_deps="opencl"
3833 xfade_vulkan_filter_deps="vulkan spirv_compiler"
3834 yadif_cuda_filter_deps="ffnvcodec"
3835 yadif_cuda_filter_deps_any="cuda_nvcc cuda_llvm"
3836 yadif_videotoolbox_filter_deps="metal corevideo videotoolbox"
3837 hstack_vaapi_filter_deps="vaapi_1"
3838 vstack_vaapi_filter_deps="vaapi_1"
3839 xstack_vaapi_filter_deps="vaapi_1"
3840 hstack_qsv_filter_deps="libmfx"
3841 hstack_qsv_filter_select="qsvvpp"
3842 vstack_qsv_filter_deps="libmfx"
3843 vstack_qsv_filter_select="qsvvpp"
3844 xstack_qsv_filter_deps="libmfx"
3845 xstack_qsv_filter_select="qsvvpp"
3846
3847 # examples
3848 avio_http_serve_files_deps="avformat avutil fork"
3849 avio_list_dir_deps="avformat avutil"
3850 avio_read_callback_deps="avformat avcodec avutil"
3851 decode_audio_example_deps="avcodec avutil"
3852 decode_filter_audio_example_deps="avfilter avcodec avformat avutil"
3853 decode_filter_video_example_deps="avfilter avcodec avformat avutil"
3854 decode_video_example_deps="avcodec avutil"
3855 demux_decode_example_deps="avcodec avformat avutil"
3856 encode_audio_example_deps="avcodec avutil"
3857 encode_video_example_deps="avcodec avutil"
3858 extract_mvs_example_deps="avcodec avformat avutil"
3859 filter_audio_example_deps="avfilter avutil"
3860 hw_decode_example_deps="avcodec avformat avutil"
3861 mux_example_deps="avcodec avformat avutil swscale"
3862 qsv_decode_example_deps="avcodec avutil libmfx h264_qsv_decoder"
3863 remux_example_deps="avcodec avformat avutil"
3864 resample_audio_example_deps="avutil swresample"
3865 scale_video_example_deps="avutil swscale"
3866 show_metadata_example_deps="avformat avutil"
3867 transcode_aac_example_deps="avcodec avformat swresample"
3868 transcode_example_deps="avfilter avcodec avformat avutil"
3869 vaapi_encode_example_deps="avcodec avutil h264_vaapi_encoder"
3870 vaapi_transcode_example_deps="avcodec avformat avutil h264_vaapi_encoder"
3871 qsv_transcode_example_deps="avcodec avformat avutil h264_qsv_encoder"
3872
3873 # EXTRALIBS_LIST
3874 cpu_init_extralibs="pthreads_extralibs"
3875 cws2fws_extralibs="zlib_extralibs"
3876
3877 # libraries, in any order
3878 avcodec_deps="avutil"
3879 avcodec_suggest="libm stdatomic"
3880 avdevice_deps="avformat avcodec avutil"
3881 avdevice_suggest="libm stdatomic"
3882 avfilter_deps="avutil"
3883 avfilter_suggest="libm stdatomic"
3884 avformat_deps="avcodec avutil"
3885 avformat_suggest="libm network zlib stdatomic"
3886 avutil_suggest="clock_gettime ffnvcodec gcrypt libm libdrm libmfx opencl openssl user32 vaapi vulkan videotoolbox corefoundation corevideo coremedia bcrypt stdatomic"
3887 postproc_deps="avutil gpl"
3888 postproc_suggest="libm stdatomic"
3889 swresample_deps="avutil"
3890 swresample_suggest="libm libsoxr stdatomic"
3891 swscale_deps="avutil"
3892 swscale_suggest="libm stdatomic"
3893
3894 avcodec_extralibs="pthreads_extralibs iconv_extralibs dxva2_extralibs lcms2_extralibs"
3895 avfilter_extralibs="pthreads_extralibs"
3896 avutil_extralibs="d3d11va_extralibs mediacodec_extralibs nanosleep_extralibs pthreads_extralibs vaapi_drm_extralibs vaapi_x11_extralibs vaapi_win32_extralibs vdpau_x11_extralibs"
3897
3898 # programs
3899 ffmpeg_deps="avcodec avfilter avformat threads"
3900 ffmpeg_select="aformat_filter anull_filter atrim_filter format_filter
3901                hflip_filter null_filter
3902                transpose_filter trim_filter vflip_filter"
3903 ffmpeg_suggest="ole32 psapi shell32"
3904 ffplay_deps="avcodec avformat avfilter swscale swresample sdl2"
3905 ffplay_select="crop_filter transpose_filter hflip_filter vflip_filter rotate_filter"
3906 ffplay_suggest="shell32"
3907 ffprobe_deps="avcodec avformat"
3908 ffprobe_suggest="shell32"
3909
3910 # documentation
3911 podpages_deps="perl"
3912 manpages_deps="perl pod2man"
3913 htmlpages_deps="perl"
3914 htmlpages_deps_any="makeinfo_html texi2html"
3915 txtpages_deps="perl makeinfo"
3916 doc_deps_any="manpages htmlpages podpages txtpages"
3917
3918 # default parameters
3919
3920 logfile="ffbuild/config.log"
3921
3922 # installation paths
3923 prefix_default="/usr/local"
3924 bindir_default='${prefix}/bin'
3925 datadir_default='${prefix}/share/ffmpeg'
3926 docdir_default='${prefix}/share/doc/ffmpeg'
3927 incdir_default='${prefix}/include'
3928 libdir_default='${prefix}/lib'
3929 mandir_default='${prefix}/share/man'
3930
3931 # toolchain
3932 ar_default="ar"
3933 cc_default="gcc"
3934 cxx_default="g++"
3935 host_cc_default="gcc"
3936 doxygen_default="doxygen"
3937 install="install"
3938 ln_s_default="ln -s -f"
3939 metalcc_default="xcrun -sdk macosx metal"
3940 metallib_default="xcrun -sdk macosx metallib"
3941 nm_default="nm -g"
3942 pkg_config_default=pkg-config
3943 ranlib_default="ranlib"
3944 strip_default="strip"
3945 version_script='--version-script'
3946 objformat="elf32"
3947 x86asmexe_default="nasm"
3948 windres_default="windres"
3949 striptype="direct"
3950
3951 # OS
3952 target_os_default=$(tolower $(uname -s))
3953 host_os=$target_os_default
3954
3955 # machine
3956 if test "$target_os_default" = aix; then
3957     arch_default=$(uname -p)
3958     strip_default="strip -X32_64"
3959     nm_default="nm -g -X32_64"
3960 else
3961     arch_default=$(uname -m)
3962 fi
3963 cpu="generic"
3964 intrinsics="none"
3965
3966 # configurable options
3967 enable $PROGRAM_LIST
3968 enable $DOCUMENT_LIST
3969 enable $EXAMPLE_LIST
3970 enable $LIBRARY_LIST
3971 enable stripping
3972
3973 enable asm
3974 enable debug
3975 enable doc
3976 enable faan faandct faanidct
3977 enable large_tests
3978 enable optimizations
3979 enable ptx_compression
3980 enable runtime_cpudetect
3981 enable safe_bitstream_reader
3982 enable static
3983 enable swscale_alpha
3984 enable valgrind_backtrace
3985
3986 sws_max_filter_size_default=256
3987 set_default sws_max_filter_size
3988
3989 # internal components are enabled by default
3990 enable $EXTRALIBS_LIST
3991
3992 # Avoid external, non-system, libraries getting enabled by dependency resolution
3993 disable $EXTERNAL_LIBRARY_LIST $HWACCEL_LIBRARY_LIST
3994
3995 # build settings
3996 SHFLAGS='-shared -Wl,-soname,$$(@F)'
3997 LIBPREF="lib"
3998 LIBSUF=".a"
3999 FULLNAME='$(NAME)$(BUILDSUF)'
4000 LIBNAME='$(LIBPREF)$(FULLNAME)$(LIBSUF)'
4001 SLIBPREF="lib"
4002 SLIBSUF=".so"
4003 SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF)'
4004 SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
4005 SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
4006 LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
4007 SLIB_INSTALL_NAME='$(SLIBNAME_WITH_VERSION)'
4008 SLIB_INSTALL_LINKS='$(SLIBNAME_WITH_MAJOR) $(SLIBNAME)'
4009 VERSION_SCRIPT_POSTPROCESS_CMD="cat"
4010
4011 asflags_filter=echo
4012 cflags_filter=echo
4013 ldflags_filter=echo
4014
4015 AS_C='-c'
4016 AS_O='-o $@'
4017 CC_C='-c'
4018 CC_E='-E -o $@'
4019 CC_O='-o $@'
4020 CXX_C='-c'
4021 CXX_O='-o $@'
4022 OBJCC_C='-c'
4023 OBJCC_E='-E -o $@'
4024 OBJCC_O='-o $@'
4025 X86ASM_O='-o $@'
4026 LD_O='-o $@'
4027 LD_LIB='-l%'
4028 LD_PATH='-L'
4029 HOSTCC_C='-c'
4030 HOSTCC_E='-E -o $@'
4031 HOSTCC_O='-o $@'
4032 HOSTLD_O='-o $@'
4033 NVCC_C='-c'
4034 NVCC_O='-o $@'
4035
4036 host_extralibs='-lm'
4037 host_cflags_filter=echo
4038 host_ldflags_filter=echo
4039
4040 target_path='$(CURDIR)'
4041
4042 # since the object filename is not given with the -MM flag, the compiler
4043 # is only able to print the basename, and we must add the path ourselves
4044 DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< 2>/dev/null | sed -e "/^\#.*/d" -e "s,^[[:space:]]*$(@F),$(@D)/$(@F)," > $(@:.o=.d)'
4045 DEPFLAGS='-MM'
4046
4047 mkdir -p ffbuild
4048
4049 # find source path
4050 if test -f configure; then
4051     source_path=.
4052 elif test -f src/configure; then
4053     source_path=src
4054 else
4055     source_path=$(cd $(dirname "$0"); pwd)
4056     case "$source_path" in
4057         *[[:blank:]]*) die "Out of tree builds are impossible with whitespace in source path." ;;
4058     esac
4059     test -e "$source_path/config.h" &&
4060         die "Out of tree builds are impossible with config.h in source dir."
4061 fi
4062
4063 for v in "$@"; do
4064     r=${v#*=}
4065     l=${v%"$r"}
4066     r=$(sh_quote "$r")
4067     FFMPEG_CONFIGURATION="${FFMPEG_CONFIGURATION# } ${l}${r}"
4068 done
4069
4070 find_things_extern(){
4071     thing=$1
4072     pattern=$2
4073     file=$source_path/$3
4074     out=${4:-$thing}
4075     sed -n "s/^[^#]*extern.*$pattern *ff_\([^ ]*\)_$thing;/\1_$out/p" "$file"
4076 }
4077
4078 find_filters_extern(){
4079     file=$source_path/$1
4080     sed -n 's/^extern const AVFilter ff_[avfsinkrc]\{2,5\}_\([[:alnum:]_]\{1,\}\);/\1_filter/p' $file
4081 }
4082
4083 FILTER_LIST=$(find_filters_extern libavfilter/allfilters.c)
4084 OUTDEV_LIST=$(find_things_extern muxer FFOutputFormat libavdevice/alldevices.c outdev)
4085 INDEV_LIST=$(find_things_extern demuxer AVInputFormat libavdevice/alldevices.c indev)
4086 MUXER_LIST=$(find_things_extern muxer FFOutputFormat libavformat/allformats.c)
4087 DEMUXER_LIST=$(find_things_extern demuxer AVInputFormat libavformat/allformats.c)
4088 ENCODER_LIST=$(find_things_extern encoder FFCodec libavcodec/allcodecs.c)
4089 DECODER_LIST=$(find_things_extern decoder FFCodec libavcodec/allcodecs.c)
4090 CODEC_LIST="
4091     $ENCODER_LIST
4092     $DECODER_LIST
4093 "
4094 PARSER_LIST=$(find_things_extern parser AVCodecParser libavcodec/parsers.c)
4095 BSF_LIST=$(find_things_extern bsf FFBitStreamFilter libavcodec/bitstream_filters.c)
4096 HWACCEL_LIST=$(find_things_extern hwaccel FFHWAccel libavcodec/hwaccels.h)
4097 PROTOCOL_LIST=$(find_things_extern protocol URLProtocol libavformat/protocols.c)
4098
4099 AVCODEC_COMPONENTS_LIST="
4100     $BSF_LIST
4101     $DECODER_LIST
4102     $ENCODER_LIST
4103     $HWACCEL_LIST
4104     $PARSER_LIST
4105 "
4106
4107 AVDEVICE_COMPONENTS_LIST="
4108     $INDEV_LIST
4109     $OUTDEV_LIST
4110 "
4111
4112 AVFILTER_COMPONENTS_LIST="
4113     $FILTER_LIST
4114 "
4115
4116 AVFORMAT_COMPONENTS_LIST="
4117     $DEMUXER_LIST
4118     $MUXER_LIST
4119     $PROTOCOL_LIST
4120 "
4121
4122 ALL_COMPONENTS="
4123     $AVCODEC_COMPONENTS_LIST
4124     $AVDEVICE_COMPONENTS_LIST
4125     $AVFILTER_COMPONENTS_LIST
4126     $AVFORMAT_COMPONENTS_LIST
4127 "
4128
4129 for n in $COMPONENT_LIST; do
4130     v=$(toupper ${n%s})_LIST
4131     eval enable \$$v
4132     eval ${n}_if_any="\$$v"
4133 done
4134
4135 enable $ARCH_EXT_LIST
4136
4137 die_unknown(){
4138     echo "Unknown option \"$1\"."
4139     echo "See $0 --help for available options."
4140     exit 1
4141 }
4142
4143 print_in_columns() {
4144     tr ' ' '\n' | sort | tr '\r\n' '  ' | awk -v col_width=24 -v width="$ncols" '
4145     {
4146         num_cols = width > col_width ? int(width / col_width) : 1;
4147         num_rows = int((NF + num_cols-1) / num_cols);
4148         y = x = 1;
4149         for (y = 1; y <= num_rows; y++) {
4150             i = y;
4151             for (x = 1; x <= num_cols; x++) {
4152                 if (i <= NF) {
4153                   line = sprintf("%s%-" col_width "s", line, $i);
4154                 }
4155                 i = i + num_rows;
4156             }
4157             print line; line = "";
4158         }
4159     }' | sed 's/ *$//'
4160 }
4161
4162 show_list() {
4163     suffix=_$1
4164     shift
4165     echo $* | sed s/$suffix//g | print_in_columns
4166     exit 0
4167 }
4168
4169 rand_list(){
4170     IFS=', '
4171     set -- $*
4172     unset IFS
4173     for thing; do
4174         comp=${thing%:*}
4175         prob=${thing#$comp}
4176         prob=${prob#:}
4177         is_in ${comp} $COMPONENT_LIST && eval comp=\$$(toupper ${comp%s})_LIST
4178         echo "prob ${prob:-0.5}"
4179         printf '%s\n' $comp
4180     done
4181 }
4182
4183 do_random(){
4184     action=$1
4185     shift
4186     random_seed=$(awk "BEGIN { srand($random_seed); print srand() }")
4187     $action $(rand_list "$@" | awk "BEGIN { srand($random_seed) } \$1 == \"prob\" { prob = \$2; next } rand() < prob { print }")
4188 }
4189
4190 for opt do
4191     optval="${opt#*=}"
4192     case "$opt" in
4193         --extra-ldflags=*)
4194             add_ldflags $optval
4195         ;;
4196         --extra-ldexeflags=*)
4197             add_ldexeflags $optval
4198         ;;
4199         --extra-ldsoflags=*)
4200             add_ldsoflags $optval
4201         ;;
4202         --extra-ldlibflags=*)
4203             warn "The --extra-ldlibflags option is only provided for compatibility and will be\n"\
4204                  "removed in the future. Use --extra-ldsoflags instead."
4205             add_ldsoflags $optval
4206         ;;
4207         --extra-libs=*)
4208             add_extralibs $optval
4209         ;;
4210         --disable-devices)
4211             disable $INDEV_LIST $OUTDEV_LIST
4212         ;;
4213         --enable-debug=*)
4214             debuglevel="$optval"
4215         ;;
4216         --disable-programs)
4217             disable $PROGRAM_LIST
4218         ;;
4219         --disable-everything)
4220             map 'eval unset \${$(toupper ${v%s})_LIST}' $COMPONENT_LIST
4221         ;;
4222         --disable-all)
4223             map 'eval unset \${$(toupper ${v%s})_LIST}' $COMPONENT_LIST
4224             disable $LIBRARY_LIST $PROGRAM_LIST doc
4225             enable avutil
4226         ;;
4227         --enable-random|--disable-random)
4228             action=${opt%%-random}
4229             do_random ${action#--} $COMPONENT_LIST
4230         ;;
4231         --enable-random=*|--disable-random=*)
4232             action=${opt%%-random=*}
4233             do_random ${action#--} $optval
4234         ;;
4235         --enable-sdl)
4236             enable sdl2
4237         ;;
4238         --enable-lto*)
4239             lto=-f${opt#--enable-}
4240         ;;
4241         --enable-*=*|--disable-*=*)
4242             eval $(echo "${opt%%=*}" | sed 's/--/action=/;s/-/ thing=/')
4243             is_in "${thing}s" $COMPONENT_LIST || die_unknown "$opt"
4244             eval list=\$$(toupper $thing)_LIST
4245             name=$(echo "${optval}" | sed "s/,/_${thing}|/g")_${thing}
4246             list=$(filter "$name" $list)
4247             [ "$list" = "" ] && warn "Option $opt did not match anything"
4248             test $action = enable && warn_if_gets_disabled $list
4249             $action $list
4250         ;;
4251         --enable-yasm|--disable-yasm)
4252             warn "The ${opt} option is only provided for compatibility and will be\n"\
4253                  "removed in the future. Use --enable-x86asm / --disable-x86asm instead."
4254             test $opt = --enable-yasm && x86asm=yes || x86asm=no
4255         ;;
4256         --yasmexe=*)
4257             warn "The --yasmexe option is only provided for compatibility and will be\n"\
4258                  "removed in the future. Use --x86asmexe instead."
4259             x86asmexe="$optval"
4260         ;;
4261         --enable-?*|--disable-?*)
4262             eval $(echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g')
4263             if is_in $option $COMPONENT_LIST; then
4264                 test $action = disable && action=unset
4265                 eval $action \$$(toupper ${option%s})_LIST
4266             elif is_in $option $CMDLINE_SELECT; then
4267                 $action $option
4268             else
4269                 die_unknown $opt
4270             fi
4271         ;;
4272         --list-*)
4273             NAME="${opt#--list-}"
4274             is_in $NAME $COMPONENT_LIST || die_unknown $opt
4275             NAME=${NAME%s}
4276             eval show_list $NAME \$$(toupper $NAME)_LIST
4277         ;;
4278         --help|-h) show_help
4279         ;;
4280         --quiet|-q) quiet=yes
4281         ;;
4282         --fatal-warnings) enable fatal_warnings
4283         ;;
4284         --libfuzzer=*)
4285             libfuzzer_path="$optval"
4286         ;;
4287         *)
4288             optname="${opt%%=*}"
4289             optname="${optname#--}"
4290             optname=$(echo "$optname" | sed 's/-/_/g')
4291             if is_in $optname $CMDLINE_SET; then
4292                 eval $optname='$optval'
4293             elif is_in $optname $CMDLINE_APPEND; then
4294                 append $optname "$optval"
4295             else
4296                 die_unknown $opt
4297             fi
4298         ;;
4299     esac
4300 done
4301
4302 for e in $env; do
4303     eval "export $e"
4304 done
4305
4306 if disabled autodetect; then
4307
4308     # Unless iconv is explicitely disabled by the user, we still want to probe
4309     # for the iconv from the libc.
4310     disabled iconv || enable libc_iconv
4311
4312     disable_weak $EXTERNAL_AUTODETECT_LIBRARY_LIST
4313     disable_weak $HWACCEL_AUTODETECT_LIBRARY_LIST
4314 fi
4315 # Mark specifically enabled, but normally autodetected libraries as requested.
4316 for lib in $AUTODETECT_LIBS; do
4317     enabled $lib && request $lib
4318 done
4319 #TODO: switch to $AUTODETECT_LIBS when $THREADS_LIST is supported the same way
4320 enable_weak $EXTERNAL_AUTODETECT_LIBRARY_LIST
4321 enable_weak $HWACCEL_AUTODETECT_LIBRARY_LIST
4322
4323 disabled logging && logfile=/dev/null
4324
4325 # command line configuration sanity checks
4326
4327 # we need to build at least one lib type
4328 if ! enabled_any static shared; then
4329     cat <<EOF
4330 At least one library type must be built.
4331 Specify --enable-static to build the static libraries or --enable-shared to
4332 build the shared libraries as well. To only build the shared libraries specify
4333 --disable-static in addition to --enable-shared.
4334 EOF
4335     exit 1
4336 fi
4337
4338 die_license_disabled() {
4339     enabled $1 || { enabled $v && die "$v is $1 and --enable-$1 is not specified."; }
4340 }
4341
4342 die_license_disabled_gpl() {
4343     enabled $1 || { enabled $v && die "$v is incompatible with the gpl and --enable-$1 is not specified."; }
4344 }
4345
4346 map "die_license_disabled gpl"      $EXTERNAL_LIBRARY_GPL_LIST $EXTERNAL_LIBRARY_GPLV3_LIST
4347 map "die_license_disabled version3" $EXTERNAL_LIBRARY_VERSION3_LIST $EXTERNAL_LIBRARY_GPLV3_LIST
4348
4349 enabled gpl && map "die_license_disabled_gpl nonfree" $EXTERNAL_LIBRARY_NONFREE_LIST
4350 map "die_license_disabled nonfree" $HWACCEL_LIBRARY_NONFREE_LIST
4351
4352 enabled version3 && { enabled gpl && enable gplv3 || enable lgplv3; }
4353
4354 if enabled nonfree; then
4355     license="nonfree and unredistributable"
4356 elif enabled gplv3; then
4357     license="GPL version 3 or later"
4358 elif enabled lgplv3; then
4359     license="LGPL version 3 or later"
4360 elif enabled gpl; then
4361     license="GPL version 2 or later"
4362 else
4363     license="LGPL version 2.1 or later"
4364 fi
4365
4366 enabled_all gnutls openssl &&
4367     die "GnuTLS and OpenSSL must not be enabled at the same time."
4368
4369 enabled_all gnutls mbedtls &&
4370     die "GnuTLS and mbedTLS must not be enabled at the same time."
4371
4372 enabled_all openssl mbedtls &&
4373     die "OpenSSL and mbedTLS must not be enabled at the same time."
4374
4375 # Disable all the library-specific components if the library itself
4376 # is disabled, see AVCODEC_LIST and following _LIST variables.
4377
4378 disable_components(){
4379     disabled ${1} && disable $(
4380         eval components="\$$(toupper ${1})_COMPONENTS"
4381         map 'eval echo \${$(toupper ${v%s})_LIST}' $components
4382     )
4383 }
4384
4385 map 'disable_components $v' $LIBRARY_LIST
4386
4387 echo "# $0 $FFMPEG_CONFIGURATION" > $logfile
4388 set >> $logfile
4389
4390 test -n "$valgrind" && toolchain="valgrind-memcheck"
4391
4392 enabled ossfuzz && ! echo $CFLAGS | grep -q -- "-fsanitize="  && ! echo $CFLAGS | grep -q -- "-fcoverage-mapping" &&{
4393     add_cflags  -fsanitize=address,undefined -fsanitize-coverage=trace-pc-guard,trace-cmp -fno-omit-frame-pointer
4394     add_ldflags -fsanitize=address,undefined -fsanitize-coverage=trace-pc-guard,trace-cmp
4395 }
4396
4397 case "$toolchain" in
4398     *-asan)
4399         cc_default="${toolchain%-asan}"
4400         add_cflags  -fsanitize=address
4401         add_ldflags -fsanitize=address
4402     ;;
4403     *-lsan)
4404         cc_default="${toolchain%-lsan}"
4405         add_cflags  -fsanitize=leak
4406         add_ldflags -fsanitize=leak
4407     ;;
4408     *-msan)
4409         cc_default="${toolchain%-msan}"
4410         add_cflags  -fsanitize=memory -fsanitize-memory-track-origins
4411         add_ldflags -fsanitize=memory
4412     ;;
4413     *-tsan)
4414         cc_default="${toolchain%-tsan}"
4415         add_cflags  -fsanitize=thread
4416         add_ldflags -fsanitize=thread
4417         case "$toolchain" in
4418             gcc-tsan)
4419                 add_cflags  -fPIC
4420                 add_ldflags -fPIC
4421                 ;;
4422         esac
4423     ;;
4424     *-usan)
4425         cc_default="${toolchain%-usan}"
4426         add_cflags  -fsanitize=undefined
4427         add_ldflags -fsanitize=undefined
4428     ;;
4429     valgrind-*)
4430         target_exec_default="valgrind"
4431         case "$toolchain" in
4432             valgrind-massif)
4433                 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"
4434                 ;;
4435             valgrind-memcheck)
4436                 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"
4437                 ;;
4438         esac
4439     ;;
4440     msvc)
4441         cl_major_ver=$(cl.exe 2>&1 | sed -n 's/.*Version \([[:digit:]]\{1,\}\)\..*/\1/p')
4442         if [ -z "$cl_major_ver" ] || [ $cl_major_ver -ge 18 ]; then
4443             cc_default="cl.exe"
4444             cxx_default="cl.exe"
4445         else
4446             die "Unsupported MSVC version (2013 or newer required)"
4447         fi
4448         ld_default="$source_path/compat/windows/mslink"
4449         windres_default="$source_path/compat/windows/mswindres"
4450         nm_default="dumpbin.exe -symbols"
4451         ar_default="lib.exe"
4452         case "${arch:-$arch_default}" in
4453         aarch64|arm64)
4454             as_default="armasm64.exe"
4455             ;;
4456         arm*)
4457             as_default="armasm.exe"
4458             ;;
4459         esac
4460         target_os_default="win32"
4461         # Use a relative path for TMPDIR. This makes sure all the
4462         # ffconf temp files are written with a relative path, avoiding
4463         # issues with msys/win32 path conversion for MSVC parameters
4464         # such as -Fo<file> or -out:<file>.
4465         TMPDIR=.
4466     ;;
4467     icl)
4468         cc_default="icl"
4469         ld_default="xilink"
4470         nm_default="dumpbin -symbols"
4471         ar_default="xilib"
4472         target_os_default="win32"
4473         TMPDIR=.
4474     ;;
4475     gcov)
4476         add_cflags  -fprofile-arcs -ftest-coverage
4477         add_ldflags -fprofile-arcs -ftest-coverage
4478     ;;
4479     llvm-cov)
4480         add_cflags -fprofile-arcs -ftest-coverage
4481         add_ldflags --coverage
4482     ;;
4483     hardened)
4484         add_cppflags -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2
4485         add_cflags   -fno-strict-overflow -fstack-protector-all
4486         add_ldflags  -Wl,-z,relro -Wl,-z,now
4487         add_cflags   -fPIE
4488         add_ldexeflags -fPIE -pie
4489     ;;
4490     ?*)
4491         die "Unknown toolchain $toolchain"
4492     ;;
4493 esac
4494
4495 if test -n "$cross_prefix"; then
4496     test -n "$arch" && test -n "$target_os" ||
4497         die "Must specify target arch (--arch) and OS (--target-os) when cross-compiling"
4498     enable cross_compile
4499 fi
4500
4501 set_default target_os
4502 if test "$target_os" = android; then
4503     cc_default="clang"
4504 fi
4505
4506 ar_default="${cross_prefix}${ar_default}"
4507 cc_default="${cross_prefix}${cc_default}"
4508 cxx_default="${cross_prefix}${cxx_default}"
4509 nm_default="${cross_prefix}${nm_default}"
4510 pkg_config_default="${cross_prefix}${pkg_config_default}"
4511 ranlib_default="${cross_prefix}${ranlib_default}"
4512 strip_default="${cross_prefix}${strip_default}"
4513 windres_default="${cross_prefix}${windres_default}"
4514
4515 sysinclude_default="${sysroot}/usr/include"
4516
4517 if enabled cuda_sdk; then
4518     warn "Option --enable-cuda-sdk is deprecated. Use --enable-cuda-nvcc instead."
4519     enable cuda_nvcc
4520 fi
4521
4522 if enabled cuda_nvcc; then
4523     nvcc_default="nvcc"
4524     nvccflags_default="-gencode arch=compute_30,code=sm_30 -O2"
4525 else
4526     nvcc_default="clang"
4527     nvccflags_default="--cuda-gpu-arch=sm_30 -O2"
4528     NVCC_C=""
4529 fi
4530
4531 set_default nvcc
4532
4533 if enabled cuda_nvcc; then
4534     if $nvcc $nvccflags_default 2>&1 | grep -qi unsupported; then
4535         nvccflags_default="-gencode arch=compute_60,code=sm_60 -O2"
4536     fi
4537 fi
4538
4539 set_default arch cc cxx doxygen pkg_config ranlib strip sysinclude \
4540     target_exec x86asmexe metalcc metallib
4541 enabled cross_compile || host_cc_default=$cc
4542 set_default host_cc
4543
4544 if ${ranlib} 2>&1 | grep -q "\-D "; then
4545     ranlib="${ranlib} -D"
4546 fi
4547
4548 pkg_config_fail_message=""
4549 if ! $pkg_config --version >/dev/null 2>&1; then
4550     warn "$pkg_config not found, library detection may fail."
4551     pkg_config=false
4552 elif is_in -static $cc $LDFLAGS && ! is_in --static $pkg_config $pkg_config_flags; then
4553     pkg_config_fail_message="
4554 Note: When building a static binary, add --pkg-config-flags=\"--static\"."
4555 fi
4556
4557 if test $doxygen != $doxygen_default && \
4558   ! $doxygen --version >/dev/null 2>&1; then
4559     warn "Specified doxygen \"$doxygen\" not found, API documentation will fail to build."
4560 fi
4561
4562 exesuf() {
4563     case $1 in
4564         mingw32*|mingw64*|msys*|win32|win64|cygwin*|*-dos|freedos|opendos|os/2*|symbian) echo .exe ;;
4565     esac
4566 }
4567
4568 EXESUF=$(exesuf $target_os)
4569 HOSTEXESUF=$(exesuf $host_os)
4570
4571 # set temporary file name
4572 : ${TMPDIR:=$TEMPDIR}
4573 : ${TMPDIR:=$TMP}
4574 : ${TMPDIR:=/tmp}
4575
4576 if [ -n "$tempprefix" ] ; then
4577     mktemp(){
4578         tmpname="$tempprefix.${HOSTNAME}.${UID}"
4579         echo "$tmpname"
4580         mkdir "$tmpname"
4581     }
4582 elif ! test_cmd mktemp -u XXXXXX; then
4583     # simple replacement for missing mktemp
4584     # NOT SAFE FOR GENERAL USE
4585     mktemp(){
4586         tmpname="${2%%XXX*}.${HOSTNAME}.${UID}.$$"
4587         echo "$tmpname"
4588         mkdir "$tmpname"
4589     }
4590 fi
4591
4592 FFTMPDIR=$(mktemp -d "${TMPDIR}/ffconf.XXXXXXXX" 2> /dev/null) ||
4593     die "Unable to create temporary directory in $TMPDIR."
4594
4595 tmpfile(){
4596     tmp="${FFTMPDIR}/test"$2
4597     (set -C; exec > $tmp) 2> /dev/null ||
4598         die "Unable to create temporary file in $FFTMPDIR."
4599     eval $1=$tmp
4600 }
4601
4602 trap 'rm -rf -- "$FFTMPDIR"' EXIT
4603 trap 'exit 2' INT
4604
4605 tmpfile TMPASM .asm
4606 tmpfile TMPC   .c
4607 tmpfile TMPCPP .cpp
4608 tmpfile TMPE   $EXESUF
4609 tmpfile TMPH   .h
4610 tmpfile TMPM   .m
4611 tmpfile TMPCU  .cu
4612 tmpfile TMPO   .o
4613 tmpfile TMPS   .S
4614 tmpfile TMPSH  .sh
4615 tmpfile TMPV   .ver
4616
4617 unset -f mktemp
4618
4619 chmod +x $TMPE
4620
4621 # make sure we can execute files in $TMPDIR
4622 cat > $TMPSH 2>> $logfile <<EOF
4623 #! /bin/sh
4624 EOF
4625 chmod +x $TMPSH >> $logfile 2>&1
4626 if ! $TMPSH >> $logfile 2>&1; then
4627     cat <<EOF
4628 Unable to create and execute files in $TMPDIR.  Set the TMPDIR environment
4629 variable to another directory and make sure that it is not mounted noexec.
4630 EOF
4631     die "Sanity test failed."
4632 fi
4633
4634 armasm_flags(){
4635     for flag; do
4636         case $flag in
4637             # Filter out MSVC cl.exe options from cflags that shouldn't
4638             # be passed to gas-preprocessor
4639             -M[TD]*)                                            ;;
4640             *)                  echo $flag                      ;;
4641         esac
4642    done
4643 }
4644
4645 cparser_flags(){
4646     for flag; do
4647         case $flag in
4648             -Wno-switch)             echo -Wno-switch-enum ;;
4649             -Wno-format-zero-length) ;;
4650             -Wdisabled-optimization) ;;
4651             -Wno-pointer-sign)       echo -Wno-other ;;
4652             *)                       echo $flag ;;
4653         esac
4654     done
4655 }
4656
4657 msvc_common_flags(){
4658     for flag; do
4659         case $flag in
4660             # In addition to specifying certain flags under the compiler
4661             # specific filters, they must be specified here as well or else the
4662             # generic catch all at the bottom will print the original flag.
4663             -Wall)                ;;
4664             -Wextra)              ;;
4665             -std=c*)              ;;
4666             # Common flags
4667             -fomit-frame-pointer) ;;
4668             -g)                   echo -Z7 ;;
4669             -fno-math-errno)      ;;
4670             -fno-common)          ;;
4671             -fno-signed-zeros)    ;;
4672             -fPIC)                ;;
4673             -mthumb)              ;;
4674             -march=*)             ;;
4675             -lz)                  echo zlib.lib ;;
4676             -lx264)               echo libx264.lib ;;
4677             -lstdc++)             ;;
4678             -l*)                  echo ${flag#-l}.lib ;;
4679             -LARGEADDRESSAWARE)   echo $flag ;;
4680             -L*)                  echo -libpath:${flag#-L} ;;
4681             -Wl,*)                ;;
4682             *)                    echo $flag ;;
4683         esac
4684     done
4685 }
4686
4687 msvc_flags(){
4688     msvc_common_flags "$@"
4689     for flag; do
4690         case $flag in
4691             -Wall)                echo -W3 -wd4018 -wd4146 -wd4244 -wd4305     \
4692                                        -wd4554 ;;
4693             -Wextra)              echo -W4 -wd4244 -wd4127 -wd4018 -wd4389     \
4694                                        -wd4146 -wd4057 -wd4204 -wd4706 -wd4305 \
4695                                        -wd4152 -wd4324 -we4013 -wd4100 -wd4214 \
4696                                        -wd4307 \
4697                                        -wd4273 -wd4554 -wd4701 -wd4703 ;;
4698         esac
4699     done
4700 }
4701
4702 icl_flags(){
4703     msvc_common_flags "$@"
4704     for flag; do
4705         case $flag in
4706             # Despite what Intel's documentation says -Wall, which is supported
4707             # on Windows, does enable remarks so disable them here.
4708             -Wall)                echo $flag -Qdiag-disable:remark ;;
4709             -std=c99)             echo -Qstd=c99 ;;
4710             -flto*)               echo -ipo ;;
4711         esac
4712     done
4713 }
4714
4715 icc_flags(){
4716     for flag; do
4717         case $flag in
4718             -flto*)               echo -ipo ;;
4719             *)                    echo $flag ;;
4720         esac
4721     done
4722 }
4723
4724 suncc_flags(){
4725     for flag; do
4726         case $flag in
4727             -march=*|-mcpu=*)
4728                 case "${flag#*=}" in
4729                     native)                   echo -xtarget=native       ;;
4730                     v9|niagara)               echo -xarch=sparc          ;;
4731                     ultrasparc)               echo -xarch=sparcvis       ;;
4732                     ultrasparc3|niagara2)     echo -xarch=sparcvis2      ;;
4733                     i586|pentium)             echo -xchip=pentium        ;;
4734                     i686|pentiumpro|pentium2) echo -xtarget=pentium_pro  ;;
4735                     pentium3*|c3-2)           echo -xtarget=pentium3     ;;
4736                     pentium-m)          echo -xarch=sse2 -xchip=pentium3 ;;
4737                     pentium4*)          echo -xtarget=pentium4           ;;
4738                     prescott|nocona)    echo -xarch=sse3 -xchip=pentium4 ;;
4739                     *-sse3)             echo -xarch=sse3                 ;;
4740                     core2)              echo -xarch=ssse3 -xchip=core2   ;;
4741                     bonnell)                   echo -xarch=ssse3         ;;
4742                     corei7|nehalem)            echo -xtarget=nehalem     ;;
4743                     westmere)                  echo -xtarget=westmere    ;;
4744                     silvermont)                echo -xarch=sse4_2        ;;
4745                     corei7-avx|sandybridge)    echo -xtarget=sandybridge ;;
4746                     core-avx*|ivybridge|haswell|broadwell|skylake*|knl)
4747                                                echo -xarch=avx           ;;
4748                     amdfam10|barcelona)        echo -xtarget=barcelona   ;;
4749                     btver1)                    echo -xarch=amdsse4a      ;;
4750                     btver2|bdver*|znver*)      echo -xarch=avx           ;;
4751                     athlon-4|athlon-[mx]p)     echo -xarch=ssea          ;;
4752                     k8|opteron|athlon64|athlon-fx)
4753                                                echo -xarch=sse2a         ;;
4754                     athlon*)                   echo -xarch=pentium_proa  ;;
4755                 esac
4756                 ;;
4757             -std=c99)             echo -xc99              ;;
4758             -fomit-frame-pointer) echo -xregs=frameptr    ;;
4759             -fPIC)                echo -KPIC -xcode=pic32 ;;
4760             -W*,*)                echo $flag              ;;
4761             -f*-*|-W*|-mimpure-text)                      ;;
4762             -shared)              echo -G                 ;;
4763             *)                    echo $flag              ;;
4764         esac
4765     done
4766 }
4767
4768 probe_cc(){
4769     pfx=$1
4770     _cc=$2
4771     first=$3
4772
4773     unset _type _ident _cc_c _cc_e _cc_o _flags _cflags
4774     unset _ld_o _ldflags _ld_lib _ld_path
4775     unset _depflags _DEPCMD _DEPFLAGS
4776     _flags_filter=echo
4777
4778     if $_cc --version 2>&1 | grep -q '^GNU assembler'; then
4779         true # no-op to avoid reading stdin in following checks
4780     elif $_cc -v 2>&1 | grep -q '^gcc.*LLVM'; then
4781         _type=llvm_gcc
4782         gcc_extra_ver=$(expr "$($_cc --version 2>/dev/null | head -n1)" : '.*\((.*)\)')
4783         _ident="llvm-gcc $($_cc -dumpversion 2>/dev/null) $gcc_extra_ver"
4784         _depflags='-MMD -MF $(@:.o=.d) -MT $@'
4785         _cflags_speed='-O3'
4786         _cflags_size='-Os'
4787     elif $_cc -v 2>&1 | grep -qi ^gcc; then
4788         _type=gcc
4789         gcc_version=$($_cc --version | head -n1)
4790         gcc_basever=$($_cc -dumpversion)
4791         gcc_pkg_ver=$(expr "$gcc_version" : '[^ ]* \(([^)]*)\)')
4792         gcc_ext_ver=$(expr "$gcc_version" : ".*$gcc_pkg_ver $gcc_basever \\(.*\\)")
4793         _ident=$(cleanws "gcc $gcc_basever $gcc_pkg_ver $gcc_ext_ver")
4794         case $gcc_basever in
4795             2) ;;
4796             2.*) ;;
4797             *) _depflags='-MMD -MF $(@:.o=.d) -MT $@' ;;
4798         esac
4799         if [ "$first" = true ]; then
4800             case $gcc_basever in
4801                 4.2*)
4802                 warn "gcc 4.2 is outdated and may miscompile FFmpeg. Please use a newer compiler." ;;
4803             esac
4804         fi
4805         _cflags_speed='-O3'
4806         _cflags_size='-Os'
4807     elif $_cc --version 2>/dev/null | grep -q ^icc; then
4808         _type=icc
4809         _ident=$($_cc --version | head -n1)
4810         _depflags='-MMD'
4811         _cflags_speed='-O3'
4812         _cflags_size='-Os'
4813         _cflags_noopt='-O1'
4814         _flags_filter=icc_flags
4815     elif $_cc -v 2>&1 | grep -q xlc; then
4816         _type=xlc
4817         _ident=$($_cc -qversion 2>/dev/null | head -n1)
4818         _cflags_speed='-O5'
4819         _cflags_size='-O5 -qcompact'
4820     elif $_cc --vsn 2>/dev/null | grep -Eq "ARM (C/C\+\+ )?Compiler"; then
4821         test -d "$sysroot" || die "No valid sysroot specified."
4822         _type=armcc
4823         _ident=$($_cc --vsn | grep -i build | head -n1 | sed 's/.*: //')
4824         armcc_conf="$PWD/armcc.conf"
4825         $_cc --arm_linux_configure                 \
4826              --arm_linux_config_file="$armcc_conf" \
4827              --configure_sysroot="$sysroot"        \
4828              --configure_cpp_headers="$sysinclude" >>$logfile 2>&1 ||
4829              die "Error creating armcc configuration file."
4830         $_cc --vsn | grep -q RVCT && armcc_opt=rvct || armcc_opt=armcc
4831         _flags="--arm_linux_config_file=$armcc_conf --translate_gcc"
4832         as_default="${cross_prefix}gcc"
4833         _depflags='-MMD'
4834         _cflags_speed='-O3'
4835         _cflags_size='-Os'
4836     elif $_cc -v 2>&1 | grep -q clang && ! $_cc -? > /dev/null 2>&1; then
4837         _type=clang
4838         _ident=$($_cc --version 2>/dev/null | head -n1)
4839         _depflags='-MMD -MF $(@:.o=.d) -MT $@'
4840         _cflags_speed='-O3'
4841         _cflags_size='-Oz'
4842     elif $_cc -V 2>&1 | grep -q Sun; then
4843         _type=suncc
4844         _ident=$($_cc -V 2>&1 | head -n1 | cut -d' ' -f 2-)
4845         _DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< | sed -e "1s,^.*: ,$@: ," -e "\$$!s,\$$, \\\," -e "1!s,^.*: , ," > $(@:.o=.d)'
4846         _DEPFLAGS='-xM1 -xc99'
4847         _ldflags='-std=c99'
4848         _cflags_speed='-O5'
4849         _cflags_size='-O5 -xspace'
4850         _flags_filter=suncc_flags
4851     elif $_cc -v 2>&1 | grep -q 'PathScale\|Path64'; then
4852         _type=pathscale
4853         _ident=$($_cc -v 2>&1 | head -n1 | tr -d :)
4854         _depflags='-MMD -MF $(@:.o=.d) -MT $@'
4855         _cflags_speed='-O2'
4856         _cflags_size='-Os'
4857         _flags_filter='filter_out -Wdisabled-optimization'
4858     elif $_cc -v 2>&1 | grep -q Open64; then
4859         _type=open64
4860         _ident=$($_cc -v 2>&1 | head -n1 | tr -d :)
4861         _depflags='-MMD -MF $(@:.o=.d) -MT $@'
4862         _cflags_speed='-O2'
4863         _cflags_size='-Os'
4864         _flags_filter='filter_out -Wdisabled-optimization|-Wtype-limits|-fno-signed-zeros'
4865     elif $_cc 2>&1 | grep -q 'Microsoft.*ARM.*Assembler'; then
4866         _type=armasm
4867         _ident=$($_cc | head -n1)
4868         # 4509: "This form of conditional instruction is deprecated"
4869         _flags="-nologo -ignore 4509"
4870         _flags_filter=armasm_flags
4871     elif $_cc 2>&1 | grep -q Intel; then
4872         _type=icl
4873         _ident=$($_cc 2>&1 | head -n1)
4874         _depflags='-QMMD -QMF$(@:.o=.d) -QMT$@'
4875         # Not only is O3 broken on 13.x+ but it is slower on all previous
4876         # versions (tested) as well.
4877         _cflags_speed="-O2"
4878         _cflags_size="-O1 -Oi" # -O1 without -Oi miscompiles stuff
4879         if $_cc 2>&1 | grep -q Linker; then
4880             _ld_o='-out:$@'
4881         else
4882             _ld_o='-Fe$@'
4883         fi
4884         _cc_o='-Fo$@'
4885         _cc_e='-P'
4886         _flags_filter=icl_flags
4887         _ld_lib='lib%.a'
4888         _ld_path='-libpath:'
4889         # -Qdiag-error to make icl error when seeing certain unknown arguments
4890         _flags='-nologo -Qdiag-error:4044,10157'
4891         # -Qvec- -Qsimd- to prevent miscompilation, -GS, fp:precise for consistency
4892         # with MSVC which enables it by default.
4893         _cflags='-Qms0 -Qvec- -Qsimd- -GS -fp:precise'
4894         disable stripping
4895     elif $_cc -? 2>/dev/null | grep -q 'LLVM.*Linker'; then
4896         # lld can emulate multiple different linkers; in ms link.exe mode,
4897         # the -? parameter gives the help output which contains an identifyable
4898         # string, while it gives an error in other modes.
4899         _type=lld-link
4900         # The link.exe mode doesn't have a switch for getting the version,
4901         # but we can force it back to gnu mode and get the version from there.
4902         _ident=$($_cc -flavor gnu --version 2>/dev/null)
4903         _ld_o='-out:$@'
4904         _flags_filter=msvc_flags
4905         _ld_lib='lib%.a'
4906         _ld_path='-libpath:'
4907     elif $_cc -nologo- 2>&1 | grep -q Microsoft || { $_cc -v 2>&1 | grep -q clang && $_cc -? > /dev/null 2>&1; }; then
4908         _type=msvc
4909         if $_cc -nologo- 2>&1 | grep -q Microsoft; then
4910             _ident=$($_cc 2>&1 | head -n1 | tr -d '\r')
4911         else
4912             _ident=$($_cc --version 2>/dev/null | head -n1 | tr -d '\r')
4913         fi
4914         _DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< 2>&1 | awk '\''/including/ { sub(/^.*file: */, ""); gsub(/\\/, "/"); if (!match($$0, / /)) print "$@:", $$0 }'\'' > $(@:.o=.d)'
4915         _DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -showIncludes -Zs'
4916         _cflags_speed="-O2"
4917         _cflags_size="-O1"
4918         _cflags_noopt="-O1"
4919         if $_cc -nologo- 2>&1 | grep -q Linker; then
4920             _ld_o='-out:$@'
4921         else
4922             _ld_o='-Fe$@'
4923         fi
4924         _cc_o='-Fo$@'
4925         _cc_e='-P -Fi$@'
4926         _flags_filter=msvc_flags
4927         _ld_lib='lib%.a'
4928         _ld_path='-libpath:'
4929         _flags='-nologo'
4930         disable stripping
4931     elif $_cc --version 2>/dev/null | grep -q ^cparser; then
4932         _type=cparser
4933         _ident=$($_cc --version | head -n1)
4934         _depflags='-MMD'
4935         _cflags_speed='-O4'
4936         _cflags_size='-O2'
4937         _flags_filter=cparser_flags
4938     fi
4939
4940     eval ${pfx}_type=\$_type
4941     eval ${pfx}_ident=\$_ident
4942 }
4943
4944 set_ccvars(){
4945     eval ${1}_C=\${_cc_c-\${${1}_C}}
4946     eval ${1}_E=\${_cc_e-\${${1}_E}}
4947     eval ${1}_O=\${_cc_o-\${${1}_O}}
4948
4949     if [ -n "$_depflags" ]; then
4950         eval ${1}_DEPFLAGS=\$_depflags
4951     else
4952         eval ${1}DEP=\${_DEPCMD:-\$DEPCMD}
4953         eval ${1}DEP_FLAGS=\${_DEPFLAGS:-\$DEPFLAGS}
4954         eval DEP${1}FLAGS=\$_flags
4955     fi
4956 }
4957
4958 probe_cc cc "$cc" "true"
4959 cflags_filter=$_flags_filter
4960 cflags_speed=$_cflags_speed
4961 cflags_size=$_cflags_size
4962 cflags_noopt=$_cflags_noopt
4963 add_cflags $_flags $_cflags
4964 cc_ldflags=$_ldflags
4965 set_ccvars CC
4966 set_ccvars CXX
4967
4968 probe_cc hostcc "$host_cc"
4969 host_cflags_filter=$_flags_filter
4970 host_cflags_speed=$_cflags_speed
4971 add_host_cflags  $_flags $_cflags
4972 set_ccvars HOSTCC
4973
4974 test -n "$cc_type" && enable $cc_type ||
4975     warn "Unknown C compiler $cc, unable to select optimal CFLAGS"
4976
4977 : ${as_default:=$cc}
4978 : ${objcc_default:=$cc}
4979 : ${dep_cc_default:=$cc}
4980 : ${ld_default:=$cc}
4981 : ${host_ld_default:=$host_cc}
4982 set_default ar as objcc dep_cc ld ln_s host_ld windres
4983
4984 probe_cc as "$as"
4985 asflags_filter=$_flags_filter
4986 add_asflags $_flags $_cflags
4987 set_ccvars AS
4988
4989 probe_cc objcc "$objcc"
4990 objcflags_filter=$_flags_filter
4991 add_objcflags $_flags $_cflags
4992 set_ccvars OBJC
4993
4994 probe_cc ld "$ld"
4995 ldflags_filter=$_flags_filter
4996 add_ldflags $_flags $_ldflags
4997 test "$cc_type" != "$ld_type" && add_ldflags $cc_ldflags
4998 LD_O=${_ld_o-$LD_O}
4999 LD_LIB=${_ld_lib-$LD_LIB}
5000 LD_PATH=${_ld_path-$LD_PATH}
5001
5002 probe_cc hostld "$host_ld"
5003 host_ldflags_filter=$_flags_filter
5004 add_host_ldflags $_flags $_ldflags
5005 HOSTLD_O=${_ld_o-$HOSTLD_O}
5006
5007 if [ -z "$CC_DEPFLAGS" ] && [ "$dep_cc" != "$cc" ]; then
5008     probe_cc depcc "$dep_cc"
5009     CCDEP=${_DEPCMD:-$DEPCMD}
5010     CCDEP_FLAGS=${_DEPFLAGS:=$DEPFLAGS}
5011     DEPCCFLAGS=$_flags
5012 fi
5013
5014 if $ar 2>&1 | grep -q Microsoft; then
5015     arflags="-nologo"
5016     ar_o='-out:$@'
5017 elif $ar 2>&1 | grep -q "\[D\] "; then
5018     arflags="rcD"
5019     ar_o='$@'
5020 else
5021     arflags="rc"
5022     ar_o='$@'
5023 fi
5024
5025 add_cflags $extra_cflags
5026 add_cxxflags $extra_cxxflags
5027 add_objcflags $extra_objcflags
5028 add_asflags $extra_cflags
5029
5030 if test -n "$sysroot"; then
5031     case "$cc_type" in
5032         gcc|llvm_gcc|clang)
5033             add_cppflags --sysroot="$sysroot"
5034             add_ldflags --sysroot="$sysroot"
5035         ;;
5036     esac
5037 fi
5038
5039 if test "$cpu" = host; then
5040     enabled cross_compile &&
5041         warn "--cpu=host makes no sense when cross-compiling."
5042
5043     case "$cc_type" in
5044         gcc|llvm_gcc)
5045             check_native(){
5046                 $cc $1=native -v -c -o $TMPO $TMPC >$TMPE 2>&1 || return
5047                 sed -n "/cc1.*$1=/{
5048                             s/.*$1=\\([^ ]*\\).*/\\1/
5049                             p
5050                             q
5051                         }" $TMPE
5052             }
5053             cpu=$(check_native -march || check_native -mcpu)
5054         ;;
5055         clang)
5056             check_native(){
5057                 $cc $1=native -v -c -o $TMPO $TMPC >$TMPE 2>&1 || return
5058                 sed -n "/cc1.*-target-cpu /{
5059                             s/.*-target-cpu \\([^ ]*\\).*/\\1/
5060                             p
5061                             q
5062                         }" $TMPE
5063             }
5064             cpu=$(check_native -march)
5065         ;;
5066     esac
5067
5068     test "${cpu:-host}" = host &&
5069         die "--cpu=host not supported with compiler $cc"
5070 fi
5071
5072 # Deal with common $arch aliases
5073 case "$arch" in
5074     aarch64|arm64)
5075         arch="aarch64"
5076     ;;
5077     arm*|iPad*|iPhone*)
5078         arch="arm"
5079     ;;
5080     loongarch*)
5081         arch="loongarch"
5082     ;;
5083     mips*|IP*)
5084         case "$arch" in
5085         *el)
5086             add_cppflags -EL
5087             add_ldflags -EL
5088         ;;
5089         *eb)
5090             add_cppflags -EB
5091             add_ldflags -EB
5092         ;;
5093         esac
5094         arch="mips"
5095     ;;
5096     parisc*|hppa*)
5097         arch="parisc"
5098     ;;
5099     "Power Macintosh"|ppc*|powerpc*)
5100         arch="ppc"
5101     ;;
5102     riscv*)
5103         arch="riscv"
5104     ;;
5105     s390|s390x)
5106         arch="s390"
5107     ;;
5108     sh4|sh)
5109         arch="sh4"
5110     ;;
5111     sun4*|sparc*)
5112         arch="sparc"
5113     ;;
5114     tilegx|tile-gx)
5115         arch="tilegx"
5116     ;;
5117     i[3-6]86*|i86pc|BePC|x86pc|x86_64|x86_32|amd64)
5118         arch="x86"
5119     ;;
5120 esac
5121
5122 is_in $arch $ARCH_LIST || warn "unknown architecture $arch"
5123 enable $arch
5124
5125 # Add processor-specific flags
5126 if enabled aarch64; then
5127
5128     case $cpu in
5129         armv*)
5130             cpuflags="-march=$cpu"
5131         ;;
5132         *)
5133             cpuflags="-mcpu=$cpu"
5134         ;;
5135     esac
5136
5137 elif enabled alpha; then
5138
5139     cpuflags="-mcpu=$cpu"
5140
5141 elif enabled arm; then
5142
5143     check_arm_arch() {
5144         test_cpp_condition stddef.h \
5145             "defined __ARM_ARCH_${1}__ || defined __TARGET_ARCH_${2:-$1}" \
5146             $cpuflags
5147     }
5148
5149     probe_arm_arch() {
5150         if   check_arm_arch 4;        then echo armv4
5151         elif check_arm_arch 4T;       then echo armv4t
5152         elif check_arm_arch 5;        then echo armv5
5153         elif check_arm_arch 5E;       then echo armv5e
5154         elif check_arm_arch 5T;       then echo armv5t
5155         elif check_arm_arch 5TE;      then echo armv5te
5156         elif check_arm_arch 5TEJ;     then echo armv5te
5157         elif check_arm_arch 6;        then echo armv6
5158         elif check_arm_arch 6J;       then echo armv6j
5159         elif check_arm_arch 6K;       then echo armv6k
5160         elif check_arm_arch 6Z;       then echo armv6z
5161         elif check_arm_arch 6KZ;      then echo armv6zk
5162         elif check_arm_arch 6ZK;      then echo armv6zk
5163         elif check_arm_arch 6T2;      then echo armv6t2
5164         elif check_arm_arch 7;        then echo armv7
5165         elif check_arm_arch 7A  7_A;  then echo armv7-a
5166         elif check_arm_arch 7S;       then echo armv7-a
5167         elif check_arm_arch 7R  7_R;  then echo armv7-r
5168         elif check_arm_arch 7M  7_M;  then echo armv7-m
5169         elif check_arm_arch 7EM 7E_M; then echo armv7-m
5170         elif check_arm_arch 8A  8_A;  then echo armv8-a
5171         fi
5172     }
5173
5174
5175     case $cpu in
5176         generic)
5177             subarch=$(probe_arm_arch | sed 's/[^a-z0-9]//g')
5178         ;;
5179         armv*)
5180             cpuflags="-march=$cpu"
5181             subarch=$(echo $cpu | sed 's/[^a-z0-9]//g')
5182         ;;
5183         *)
5184             cpuflags="-mcpu=$cpu"
5185             case $cpu in
5186                 cortex-a*)                               subarch=armv7a  ;;
5187                 cortex-r*)                               subarch=armv7r  ;;
5188                 cortex-m*)                 enable thumb; subarch=armv7m  ;;
5189                 arm11*)                                  subarch=armv6   ;;
5190                 arm[79]*e*|arm9[24]6*|arm96*|arm102[26]) subarch=armv5te ;;
5191                 armv4*|arm7*|arm9[24]*)                  subarch=armv4   ;;
5192                 *)                             subarch=$(probe_arm_arch) ;;
5193             esac
5194         ;;
5195     esac
5196
5197     case "$subarch" in
5198         armv5t*)    enable fast_clz                ;;
5199         armv[6-8]*)
5200             enable fast_clz
5201             disabled fast_unaligned || enable fast_unaligned
5202             ;;
5203     esac
5204
5205     test_cflags -mfp16-format=ieee && add_cflags -mfp16-format=ieee
5206
5207 elif enabled avr32; then
5208
5209     case $cpu in
5210         ap7[02]0[0-2])
5211             subarch="avr32_ap"
5212             cpuflags="-mpart=$cpu"
5213         ;;
5214         ap)
5215             subarch="avr32_ap"
5216             cpuflags="-march=$cpu"
5217         ;;
5218         uc3[ab]*)
5219             subarch="avr32_uc"
5220             cpuflags="-mcpu=$cpu"
5221         ;;
5222         uc)
5223             subarch="avr32_uc"
5224             cpuflags="-march=$cpu"
5225         ;;
5226     esac
5227
5228 elif enabled bfin; then
5229
5230     cpuflags="-mcpu=$cpu"
5231
5232 elif enabled loongarch; then
5233
5234     enable local_aligned
5235     enable simd_align_32
5236     enable fast_64bit
5237     enable fast_clz
5238     enable fast_unaligned
5239     case $cpu in
5240         la464)
5241             cpuflags="-march=$cpu"
5242         ;;
5243     esac
5244 elif enabled mips; then
5245
5246     if [ "$cpu" != "generic" ]; then
5247         disable mips32r2
5248         disable mips32r5
5249         disable mips64r2
5250         disable mips32r6
5251         disable mips64r6
5252         disable loongson2
5253         disable loongson3
5254         disable mipsdsp
5255         disable mipsdspr2
5256
5257         cpuflags="-march=$cpu"
5258
5259         case $cpu in
5260             # General ISA levels
5261             mips1|mips3)
5262             ;;
5263             mips32r2)
5264                 enable mips32r2
5265             ;;
5266             mips32r5)
5267                 enable mips32r2
5268                 enable mips32r5
5269             ;;
5270             mips64r2|mips64r5)
5271                 enable mips64r2
5272                 enable loongson3
5273             ;;
5274             # Cores from MIPS(MTI)
5275             24kc)
5276                 disable mipsfpu
5277                 enable mips32r2
5278             ;;
5279             24kf*|24kec|34kc|74Kc|1004kc)
5280                 enable mips32r2
5281             ;;
5282             24kef*|34kf*|1004kf*)
5283                 enable mipsdsp
5284                 enable mips32r2
5285             ;;
5286             p5600)
5287                 enable mips32r2
5288                 enable mips32r5
5289                 check_cflags "-mtune=p5600" && check_cflags "-msched-weight -mload-store-pairs -funroll-loops"
5290             ;;
5291             i6400)
5292                 enable mips64r6
5293                 check_cflags "-mtune=i6400 -mabi=64" && check_cflags "-msched-weight -mload-store-pairs -funroll-loops" && check_ldflags "-mabi=64"
5294             ;;
5295             p6600)
5296                 enable mips64r6
5297                 check_cflags "-mtune=p6600 -mabi=64" && check_cflags "-msched-weight -mload-store-pairs -funroll-loops" && check_ldflags "-mabi=64"
5298             ;;
5299             # Cores from Loongson
5300             loongson2e|loongson2f|loongson3*)
5301                 enable local_aligned
5302                 enable simd_align_16
5303                 enable fast_64bit
5304                 enable fast_clz
5305                 enable fast_cmov
5306                 enable fast_unaligned
5307                 disable aligned_stack
5308                 # When gcc version less than 5.3.0, add -fno-expensive-optimizations flag.
5309                 if test "$cc_type" = "gcc"; then
5310                     case $gcc_basever in
5311                         2|2.*|3.*|4.*|5.0|5.1|5.2)
5312                         expensive_optimization_flag="-fno-expensive-optimizations"
5313                         ;;
5314                         *)
5315                         expensive_optimization_flag=""
5316                         ;;
5317                     esac
5318                 fi
5319
5320                 case $cpu in
5321                     loongson3*)
5322                         enable loongson3
5323                         cpuflags="-march=loongson3a -mhard-float $expensive_optimization_flag"
5324                     ;;
5325                     loongson2e)
5326                         enable loongson2
5327                         cpuflags="-march=loongson2e -mhard-float $expensive_optimization_flag"
5328                     ;;
5329                     loongson2f)
5330                         enable loongson2
5331                         cpuflags="-march=loongson2f -mhard-float $expensive_optimization_flag"
5332                     ;;
5333                 esac
5334             ;;
5335             *)
5336                 warn "unknown MIPS CPU"
5337             ;;
5338         esac
5339
5340     else
5341         disable mipsdsp
5342         disable mipsdspr2
5343         # Disable DSP stuff for generic CPU, it can't be detected at runtime.
5344         warn 'generic cpu selected'
5345     fi
5346
5347 elif enabled ppc; then
5348
5349     disable ldbrx
5350
5351     case $(tolower $cpu) in
5352         601|ppc601|powerpc601)
5353             cpuflags="-mcpu=601"
5354             disable altivec
5355         ;;
5356         603*|ppc603*|powerpc603*)
5357             cpuflags="-mcpu=603"
5358             disable altivec
5359         ;;
5360         604*|ppc604*|powerpc604*)
5361             cpuflags="-mcpu=604"
5362             disable altivec
5363         ;;
5364         g3|75*|ppc75*|powerpc75*)
5365             cpuflags="-mcpu=750"
5366             disable altivec
5367         ;;
5368         g4|745*|ppc745*|powerpc745*)
5369             cpuflags="-mcpu=7450"
5370             disable vsx
5371         ;;
5372         74*|ppc74*|powerpc74*)
5373             cpuflags="-mcpu=7400"
5374             disable vsx
5375         ;;
5376         g5|970|ppc970|powerpc970)
5377             cpuflags="-mcpu=970"
5378             disable vsx
5379         ;;
5380         power[3-6]*)
5381             cpuflags="-mcpu=$cpu"
5382             disable vsx
5383         ;;
5384         power[7-8]*)
5385             cpuflags="-mcpu=$cpu"
5386         ;;
5387         cell)
5388             cpuflags="-mcpu=cell"
5389             enable ldbrx
5390             disable vsx
5391         ;;
5392         e500mc)
5393             cpuflags="-mcpu=e500mc"
5394             disable altivec
5395         ;;
5396         e500v2)
5397             cpuflags="-mcpu=8548 -mhard-float -mfloat-gprs=double"
5398             disable altivec
5399             disable dcbzl
5400         ;;
5401         e500)
5402             cpuflags="-mcpu=8540 -mhard-float"
5403             disable altivec
5404             disable dcbzl
5405         ;;
5406     esac
5407
5408 elif enabled riscv; then
5409
5410     if test_cpp_condition stddef.h "__riscv_zbb"; then
5411         enable fast_clz
5412     fi
5413
5414 elif enabled sparc; then
5415
5416     case $cpu in
5417         cypress|f93[04]|tsc701|sparcl*|supersparc|hypersparc|niagara|v[789])
5418             cpuflags="-mcpu=$cpu"
5419         ;;
5420         ultrasparc*|niagara[234])
5421             cpuflags="-mcpu=$cpu"
5422         ;;
5423     esac
5424
5425 elif enabled x86; then
5426
5427     case $cpu in
5428         i[345]86|pentium)
5429             cpuflags="-march=$cpu"
5430             disable i686
5431             disable mmx
5432         ;;
5433         # targets that do NOT support nopl and conditional mov (cmov)
5434         pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
5435             cpuflags="-march=$cpu"
5436             disable i686
5437         ;;
5438         # targets that do support conditional mov but on which it's slow
5439         pentium4|pentium4m|prescott|nocona)
5440             cpuflags="-march=$cpu"
5441             enable i686
5442             disable fast_cmov
5443         ;;
5444         # everything else should support nopl and conditional mov (cmov)
5445         *)
5446             cpuflags="-march=$cpu"
5447             enable i686
5448             enable fast_cmov
5449         ;;
5450     esac
5451
5452 fi
5453
5454 if [ "$cpu" != generic ]; then
5455     add_cflags  $cpuflags
5456     add_asflags $cpuflags
5457     test "$cc_type" = "$ld_type" && add_ldflags $cpuflags
5458 fi
5459
5460 # compiler sanity check
5461 test_exec <<EOF
5462 int main(void){ return 0; }
5463 EOF
5464 if test "$?" != 0; then
5465     echo "$cc is unable to create an executable file."
5466     if test -z "$cross_prefix" && ! enabled cross_compile ; then
5467         echo "If $cc is a cross-compiler, use the --enable-cross-compile option."
5468         echo "Only do this if you know what cross compiling means."
5469     fi
5470     die "C compiler test failed."
5471 fi
5472
5473 add_cppflags -D_ISOC99_SOURCE
5474 add_cxxflags -D__STDC_CONSTANT_MACROS
5475 check_cxxflags -std=c++11 || check_cxxflags -std=c++0x
5476
5477 # some compilers silently accept -std=c11, so we also need to check that the
5478 # version macro is defined properly
5479 test_cflags_cc -std=c11 ctype.h "__STDC_VERSION__ >= 201112L" &&
5480     add_cflags -std=c11 ||
5481     check_cflags -std=c99
5482
5483 check_cppflags -D_FILE_OFFSET_BITS=64
5484 check_cppflags -D_LARGEFILE_SOURCE
5485
5486 add_host_cppflags -D_ISOC99_SOURCE
5487 check_host_cflags -std=c99
5488 check_host_cflags -Wall
5489 check_host_cflags $host_cflags_speed
5490
5491 check_64bit(){
5492     arch32=$1
5493     arch64=$2
5494     expr=${3:-'sizeof(void *) > 4'}
5495     test_code cc "" "int test[2*($expr) - 1]" &&
5496         subarch=$arch64 || subarch=$arch32
5497     enable $subarch
5498 }
5499
5500 case "$arch" in
5501     aarch64|alpha|ia64)
5502         enabled shared && enable_weak pic
5503     ;;
5504     loongarch)
5505         check_64bit loongarch32 loongarch64
5506         enabled loongarch64 && disable loongarch32
5507         enabled shared && enable_weak pic
5508     ;;
5509     mips)
5510         check_64bit mips mips64 '_MIPS_SIM > 1'
5511         enabled shared && enable_weak pic
5512     ;;
5513     parisc)
5514         check_64bit parisc parisc64
5515         enabled shared && enable_weak pic
5516     ;;
5517     ppc)
5518         check_64bit ppc ppc64
5519         enabled shared && enable_weak pic
5520     ;;
5521     riscv)
5522         check_64bit riscv32 riscv64
5523         enabled shared && enable_weak pic
5524     ;;
5525     s390)
5526         check_64bit s390 s390x
5527         enabled shared && enable_weak pic
5528     ;;
5529     sparc)
5530         check_64bit sparc sparc64
5531         enabled shared && enable_weak pic
5532     ;;
5533     x86)
5534         check_64bit x86_32 x86_64
5535         # Treat x32 as x64 for now. Note it also needs pic if shared
5536         test "$subarch" = "x86_32" && test_cpp_condition stddef.h 'defined(__x86_64__)' &&
5537             subarch=x86_64 && enable x86_64 && disable x86_32
5538         if enabled x86_64; then
5539             enabled shared && enable_weak pic
5540             objformat=elf64
5541         fi
5542     ;;
5543 esac
5544
5545 # OS specific
5546 case $target_os in
5547     aix)
5548         SHFLAGS=-shared
5549         add_cppflags '-I\$(SRC_PATH)/compat/aix'
5550         enabled shared && add_ldflags -Wl,-brtl
5551         arflags='-Xany -r -c'
5552         striptype=""
5553         ;;
5554     android)
5555         disable symver
5556         enable section_data_rel_ro
5557         add_cflags -fPIE
5558         add_ldexeflags -fPIE -pie
5559         SLIB_INSTALL_NAME='$(SLIBNAME)'
5560         SLIB_INSTALL_LINKS=
5561         SHFLAGS='-shared -Wl,-soname,$(SLIBNAME)'
5562         ;;
5563     haiku)
5564         prefix_default="/boot/common"
5565         network_extralibs="-lnetwork"
5566         host_extralibs=
5567         ;;
5568     sunos)
5569         SHFLAGS='-shared -Wl,-h,$$(@F)'
5570         enabled x86 && append SHFLAGS -mimpure-text
5571         network_extralibs="-lsocket -lnsl"
5572         add_cppflags -D__EXTENSIONS__
5573         # When using suncc to build, the Solaris linker will mark
5574         # an executable with each instruction set encountered by
5575         # the Solaris assembler.  As our libraries contain their own
5576         # guards for processor-specific code, instead suppress
5577         # generation of the HWCAPS ELF section on Solaris x86 only.
5578         enabled_all suncc x86 &&
5579             echo "hwcap_1 = OVERRIDE;" > mapfile &&
5580             add_ldflags -Wl,-M,mapfile
5581         nm_default='nm -P -g'
5582         striptype=""
5583         version_script='-M'
5584         VERSION_SCRIPT_POSTPROCESS_CMD='perl $(SRC_PATH)/compat/solaris/make_sunver.pl - $(OBJS)'
5585         ;;
5586     netbsd)
5587         disable symver
5588         oss_indev_extralibs="-lossaudio"
5589         oss_outdev_extralibs="-lossaudio"
5590         enabled gcc || check_ldflags -Wl,-zmuldefs
5591         ;;
5592     openbsd|bitrig)
5593         disable symver
5594         enable section_data_rel_ro
5595         striptype=""
5596         SHFLAGS='-shared'
5597         SLIB_INSTALL_NAME='$(SLIBNAME).$(LIBMAJOR).$(LIBMINOR)'
5598         SLIB_INSTALL_LINKS=
5599         oss_indev_extralibs="-lossaudio"
5600         oss_outdev_extralibs="-lossaudio"
5601         ;;
5602     dragonfly)
5603         disable symver
5604         ;;
5605     freebsd)
5606         ;;
5607     bsd/os)
5608         add_extralibs -lpoll -lgnugetopt
5609         strip="strip -d"
5610         ;;
5611     darwin)
5612         enabled ppc && add_asflags -force_cpusubtype_ALL
5613         install_name_dir_default='$(SHLIBDIR)'
5614         SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(INSTALL_NAME_DIR)/$(SLIBNAME_WITH_MAJOR),-current_version,$(LIBVERSION),-compatibility_version,$(LIBMAJOR)'
5615         enabled x86_32 && append SHFLAGS -Wl,-read_only_relocs,suppress
5616         strip="${strip} -x"
5617         add_ldflags -Wl,-dynamic,-search_paths_first
5618         check_cflags -Werror=partial-availability
5619         SLIBSUF=".dylib"
5620         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME).$(LIBVERSION)$(SLIBSUF)'
5621         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME).$(LIBMAJOR)$(SLIBSUF)'
5622         enabled x86_64 && objformat="macho64" || objformat="macho32"
5623         enabled_any pic shared x86_64 ||
5624             { check_cflags -mdynamic-no-pic && add_asflags -mdynamic-no-pic; }
5625         check_headers dispatch/dispatch.h &&
5626             add_cppflags '-I\$(SRC_PATH)/compat/dispatch_semaphore'
5627         if test -n "$sysroot"; then
5628             is_in -isysroot $cc $CPPFLAGS $CFLAGS || check_cppflags -isysroot $sysroot
5629             is_in -isysroot $ld $LDFLAGS          || check_ldflags  -isysroot $sysroot
5630         fi
5631         version_script='-exported_symbols_list'
5632         VERSION_SCRIPT_POSTPROCESS_CMD='tr " " "\n" | sed -n /global:/,/local:/p | grep ";" | tr ";" "\n" | sed -E "s/(.+)/_\1/g" | sed -E "s/(.+[^*])$$$$/\1*/"'
5633         # Workaround for Xcode 11 -fstack-check bug
5634         if enabled clang; then
5635             clang_version=$($cc -dumpversion)
5636             test ${clang_version%%.*} -eq 11 && add_cflags -fno-stack-check
5637         fi
5638         ;;
5639     msys*)
5640         die "Native MSYS builds are discouraged, please use the MINGW environment."
5641         ;;
5642     mingw32*|mingw64*)
5643         target_os=mingw32
5644         LIBTARGET=i386
5645         if enabled x86_64; then
5646             LIBTARGET="i386:x86-64"
5647         elif enabled arm; then
5648             LIBTARGET="arm"
5649         elif enabled aarch64; then
5650             LIBTARGET="arm64"
5651         fi
5652         if enabled shared; then
5653             # Cannot build both shared and static libs when using dllimport.
5654             disable static
5655         fi
5656         ! enabled small && test_cmd $windres --version && enable gnu_windres
5657         enabled x86_32 && check_ldflags -Wl,--large-address-aware
5658         add_cppflags -DWIN32_LEAN_AND_MEAN
5659         shlibdir_default="$bindir_default"
5660         SLIBPREF=""
5661         SLIBSUF=".dll"
5662         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
5663         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
5664         if test_cmd lib.exe -list; then
5665             SLIB_EXTRA_CMD=-'lib.exe -nologo -machine:$(LIBTARGET) -def:$$(@:$(SLIBSUF)=.def) -out:$(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib)'
5666             if enabled x86_64; then
5667                 LIBTARGET=x64
5668             fi
5669         else
5670             SLIB_EXTRA_CMD=-'$(DLLTOOL) -m $(LIBTARGET) -d $$(@:$(SLIBSUF)=.def) -l $(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib) -D $(SLIBNAME_WITH_MAJOR)'
5671         fi
5672         SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
5673         SLIB_INSTALL_LINKS=
5674         SLIB_INSTALL_EXTRA_SHLIB='$(SLIBNAME:$(SLIBSUF)=.lib)'
5675         SLIB_INSTALL_EXTRA_LIB='lib$(SLIBNAME:$(SLIBSUF)=.dll.a) $(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.def)'
5676         SLIB_CREATE_DEF_CMD='EXTERN_PREFIX="$(EXTERN_PREFIX)" AR="$(AR_CMD)" NM="$(NM_CMD)" $(SRC_PATH)/compat/windows/makedef $(SUBDIR)lib$(NAME).ver $(OBJS) > $$(@:$(SLIBSUF)=.def)'
5677         SHFLAGS='-shared -Wl,--out-implib,$(SUBDIR)lib$(SLIBNAME:$(SLIBSUF)=.dll.a) -Wl,--disable-auto-image-base $$(@:$(SLIBSUF)=.def)'
5678         enabled x86_64 && objformat="win64" || objformat="win32"
5679         dlltool="${cross_prefix}dlltool"
5680         ranlib=:
5681         enable dos_paths
5682         check_ldflags -Wl,--nxcompat,--dynamicbase
5683         # Lets work around some stupidity in binutils.
5684         # ld will strip relocations from executables even though we need them
5685         # for dynamicbase (ASLR).  Using -pie does retain the reloc section
5686         # however ld then forgets what the entry point should be (oops) so we
5687         # have to manually (re)set it.
5688         if enabled x86_32; then
5689             disabled debug && add_ldexeflags -Wl,--pic-executable,-e,_mainCRTStartup
5690         elif enabled x86_64; then
5691             disabled debug && add_ldexeflags -Wl,--pic-executable,-e,mainCRTStartup
5692             check_ldflags -Wl,--high-entropy-va # binutils 2.25
5693             # Set image base >4GB for extra entropy with HEASLR
5694             add_ldexeflags -Wl,--image-base,0x140000000
5695             append SHFLAGS -Wl,--image-base,0x180000000
5696         fi
5697         ;;
5698     win32|win64)
5699         disable symver
5700         if enabled shared; then
5701             # Link to the import library instead of the normal static library
5702             # for shared libs.
5703             LD_LIB='%.lib'
5704             # Cannot build both shared and static libs with MSVC or icl.
5705             disable static
5706         fi
5707         ! enabled small && test_cmd $windres --version && enable gnu_windres
5708         enabled x86_32 && check_ldflags -LARGEADDRESSAWARE
5709         add_cppflags -DWIN32_LEAN_AND_MEAN
5710         shlibdir_default="$bindir_default"
5711         SLIBPREF=""
5712         SLIBSUF=".dll"
5713         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
5714         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
5715         SLIB_CREATE_DEF_CMD='EXTERN_PREFIX="$(EXTERN_PREFIX)" $(SRC_PATH)/compat/windows/makedef $(SUBDIR)lib$(NAME).ver $(OBJS) > $$(@:$(SLIBSUF)=.def)'
5716         SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
5717         SLIB_INSTALL_LINKS=
5718         SLIB_INSTALL_EXTRA_SHLIB='$(SLIBNAME:$(SLIBSUF)=.lib)'
5719         SLIB_INSTALL_EXTRA_LIB='$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.def)'
5720         SHFLAGS='-dll -def:$$(@:$(SLIBSUF)=.def) -implib:$(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib)'
5721         enabled x86_64 && objformat="win64" || objformat="win32"
5722         ranlib=:
5723         enable dos_paths
5724         ;;
5725     cygwin*)
5726         target_os=cygwin
5727         shlibdir_default="$bindir_default"
5728         SLIBPREF="cyg"
5729         SLIBSUF=".dll"
5730         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
5731         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
5732         SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
5733         SLIB_INSTALL_LINKS=
5734         SLIB_INSTALL_EXTRA_LIB='lib$(FULLNAME).dll.a'
5735         SHFLAGS='-shared -Wl,--out-implib,$(SUBDIR)lib$(FULLNAME).dll.a'
5736         enabled x86_64 && objformat="win64" || objformat="win32"
5737         enable dos_paths
5738         ! enabled small && test_cmd $windres --version && enable gnu_windres
5739         add_cppflags -DWIN32_LEAN_AND_MEAN
5740         add_cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
5741         ;;
5742     *-dos|freedos|opendos)
5743         network_extralibs="-lsocket"
5744         objformat="coff"
5745         enable dos_paths
5746         ;;
5747     linux)
5748         enable section_data_rel_ro
5749         enabled_any arm aarch64 && enable_weak linux_perf
5750         ;;
5751     irix*)
5752         target_os=irix
5753         ranlib="echo ignoring ranlib"
5754         ;;
5755     os/2*)
5756         strip="lxlite -CS"
5757         striptype=""
5758         objformat="aout"
5759         add_cppflags -D_GNU_SOURCE
5760         add_ldflags -Zomf -Zbin-files -Zargs-wild -Zhigh-mem -Zmap
5761         SHFLAGS='$(SUBDIR)$(NAME).def -Zdll -Zomf'
5762         LIBSUF="_s.a"
5763         SLIBPREF=""
5764         SLIBSUF=".dll"
5765         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
5766         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(shell echo $(FULLNAME) | cut -c1-6)$(LIBMAJOR)$(SLIBSUF)'
5767         SLIB_CREATE_DEF_CMD='echo LIBRARY $(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=) INITINSTANCE TERMINSTANCE > $(SUBDIR)$(FULLNAME).def; \
5768             echo CODE PRELOAD MOVEABLE DISCARDABLE >> $(SUBDIR)$(FULLNAME).def; \
5769             echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $(SUBDIR)$(FULLNAME).def; \
5770             echo EXPORTS >> $(SUBDIR)$(FULLNAME).def; \
5771             emxexp $(OBJS) >> $(SUBDIR)$(FULLNAME).def'
5772         SLIB_EXTRA_CMD='emximp -o $(SUBDIR)$(LIBPREF)$(FULLNAME)_dll.a $(SUBDIR)$(FULLNAME).def; \
5773             emximp -o $(SUBDIR)$(LIBPREF)$(FULLNAME)_dll.lib $(SUBDIR)$(FULLNAME).def;'
5774         SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
5775         SLIB_INSTALL_LINKS=
5776         SLIB_INSTALL_EXTRA_LIB='$(LIBPREF)$(FULLNAME)_dll.a $(LIBPREF)$(FULLNAME)_dll.lib'
5777         enable dos_paths
5778         enable_weak os2threads
5779         ;;
5780     gnu/kfreebsd)
5781         add_cppflags -D_BSD_SOURCE
5782         ;;
5783     gnu)
5784         ;;
5785     qnx)
5786         add_cppflags -D_QNX_SOURCE
5787         network_extralibs="-lsocket"
5788         ;;
5789     symbian)
5790         SLIBSUF=".dll"
5791         enable dos_paths
5792         add_cflags --include=$sysinclude/gcce/gcce.h -fvisibility=default
5793         add_cppflags -D__GCCE__ -D__SYMBIAN32__ -DSYMBIAN_OE_POSIX_SIGNALS
5794         add_ldflags -Wl,--target1-abs,--no-undefined \
5795                     -Wl,-Ttext,0x80000,-Tdata,0x1000000 -shared \
5796                     -Wl,--entry=_E32Startup -Wl,-u,_E32Startup
5797         add_extralibs -l:eexe.lib -l:usrt2_2.lib -l:dfpaeabi.dso \
5798                       -l:drtaeabi.dso -l:scppnwdl.dso -lsupc++ -lgcc \
5799                       -l:libc.dso -l:libm.dso -l:euser.dso -l:libcrt0.lib
5800         ;;
5801     minix)
5802         ;;
5803     none)
5804         ;;
5805     *)
5806         die "Unknown OS '$target_os'."
5807         ;;
5808 esac
5809
5810 # test if creating links works
5811 link_dest=$(mktemp -u $TMPDIR/dest_XXXXXXXX)
5812 link_name=$(mktemp -u $TMPDIR/name_XXXXXXXX)
5813 mkdir "$link_dest"
5814 $ln_s "$link_dest" "$link_name"
5815 touch "$link_dest/test_file"
5816 if [ "$source_path" != "." ] && [ "$source_path" != "src" ] && ([ ! -d src ] || [ -L src ]) && [ -e "$link_name/test_file" ]; then
5817     # create link to source path
5818     [ -e src ] && rm src
5819     $ln_s "$source_path" src
5820     source_link=src
5821 else
5822     # creating directory links doesn't work
5823     # fall back to using the full source path
5824     source_link="$source_path"
5825 fi
5826 # cleanup
5827 rm -r "$link_dest"
5828 rm -r "$link_name"
5829
5830 # determine libc flavour
5831
5832 probe_libc(){
5833     pfx=$1
5834     pfx_no_=${pfx%_}
5835     # uclibc defines __GLIBC__, so it needs to be checked before glibc.
5836     if test_${pfx}cpp_condition features.h "defined __UCLIBC__"; then
5837         eval ${pfx}libc_type=uclibc
5838         add_${pfx}cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
5839     elif test_${pfx}cpp_condition features.h "defined __GLIBC__"; then
5840         eval ${pfx}libc_type=glibc
5841         add_${pfx}cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
5842     # MinGW headers can be installed on Cygwin, so check for newlib first.
5843     elif test_${pfx}cpp_condition newlib.h "defined _NEWLIB_VERSION"; then
5844         eval ${pfx}libc_type=newlib
5845         add_${pfx}cppflags -U__STRICT_ANSI__ -D_XOPEN_SOURCE=600
5846     # MinGW64 is backwards compatible with MinGW32, so check for it first.
5847     elif test_${pfx}cpp_condition _mingw.h "defined __MINGW64_VERSION_MAJOR"; then
5848         eval ${pfx}libc_type=mingw64
5849         if test_${pfx}cpp_condition _mingw.h "__MINGW64_VERSION_MAJOR < 3"; then
5850             add_compat msvcrt/snprintf.o
5851             add_cflags "-include $source_path/compat/msvcrt/snprintf.h"
5852         fi
5853         add_${pfx}cppflags -U__STRICT_ANSI__ -D__USE_MINGW_ANSI_STDIO=1
5854         eval test \$${pfx_no_}cc_type = "gcc" &&
5855             add_${pfx}cppflags -D__printf__=__gnu_printf__
5856         test_${pfx}cpp_condition windows.h "!defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0600" &&
5857             add_${pfx}cppflags -D_WIN32_WINNT=0x0600
5858         add_${pfx}cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
5859     elif test_${pfx}cpp_condition _mingw.h "defined __MINGW_VERSION"  ||
5860          test_${pfx}cpp_condition _mingw.h "defined __MINGW32_VERSION"; then
5861         eval ${pfx}libc_type=mingw32
5862         test_${pfx}cpp_condition _mingw.h "__MINGW32_MAJOR_VERSION > 3 || \
5863             (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" ||
5864             die "ERROR: MinGW32 runtime version must be >= 3.15."
5865         add_${pfx}cppflags -U__STRICT_ANSI__ -D__USE_MINGW_ANSI_STDIO=1
5866         test_${pfx}cpp_condition _mingw.h "__MSVCRT_VERSION__ < 0x0700" &&
5867             add_${pfx}cppflags -D__MSVCRT_VERSION__=0x0700
5868         test_${pfx}cpp_condition windows.h "!defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0600" &&
5869             add_${pfx}cppflags -D_WIN32_WINNT=0x0600
5870         eval test \$${pfx_no_}cc_type = "gcc" &&
5871             add_${pfx}cppflags -D__printf__=__gnu_printf__
5872         add_${pfx}cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
5873     elif test_${pfx}cpp_condition crtversion.h "defined _VC_CRT_MAJOR_VERSION"; then
5874         eval ${pfx}libc_type=msvcrt
5875         if test_${pfx}cpp_condition crtversion.h "_VC_CRT_MAJOR_VERSION < 14"; then
5876             if [ "$pfx" = host_ ]; then
5877                 add_host_cppflags -Dsnprintf=_snprintf
5878             else
5879                 add_compat strtod.o strtod=avpriv_strtod
5880                 add_compat msvcrt/snprintf.o snprintf=avpriv_snprintf   \
5881                                              _snprintf=avpriv_snprintf  \
5882                                              vsnprintf=avpriv_vsnprintf
5883             fi
5884         fi
5885         add_${pfx}cppflags -D_USE_MATH_DEFINES -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS
5886         # The MSVC 2010 headers (Win 7.0 SDK) set _WIN32_WINNT to
5887         # 0x601 by default unless something else is set by the user.
5888         # This can easily lead to us detecting functions only present
5889         # in such new versions and producing binaries requiring windows 7.0.
5890         # Therefore explicitly set the default to Vista unless the user has
5891         # set something else on the command line.
5892         # Don't do this if WINAPI_FAMILY is set and is set to a non-desktop
5893         # family. For these cases, configure is free to use any functions
5894         # found in the SDK headers by default. (Alternatively, we could force
5895         # _WIN32_WINNT to 0x0602 in that case.)
5896         test_${pfx}cpp_condition stdlib.h "defined(_WIN32_WINNT)" ||
5897             { test_${pfx}cpp <<EOF && add_${pfx}cppflags -D_WIN32_WINNT=0x0600; }
5898 #ifdef WINAPI_FAMILY
5899 #include <winapifamily.h>
5900 #if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
5901 #error not desktop
5902 #endif
5903 #endif
5904 EOF
5905         if [ "$pfx" = "" ]; then
5906             check_func strtoll || add_cflags -Dstrtoll=_strtoi64
5907             check_func strtoull || add_cflags -Dstrtoull=_strtoui64
5908         fi
5909     elif test_${pfx}cpp_condition stddef.h "defined __KLIBC__"; then
5910         eval ${pfx}libc_type=klibc
5911     elif test_${pfx}cpp_condition sys/cdefs.h "defined __BIONIC__"; then
5912         eval ${pfx}libc_type=bionic
5913     elif test_${pfx}cpp_condition sys/brand.h "defined LABELED_BRAND_NAME"; then
5914         eval ${pfx}libc_type=solaris
5915         add_${pfx}cppflags -D__EXTENSIONS__ -D_XOPEN_SOURCE=600
5916     elif test_${pfx}cpp_condition sys/version.h "defined __DJGPP__"; then
5917         eval ${pfx}libc_type=djgpp
5918         add_cppflags -U__STRICT_ANSI__
5919         add_cflags "-include $source_path/compat/djgpp/math.h"
5920         add_compat djgpp/math.o
5921     fi
5922     test_${pfx}cc <<EOF
5923 #include <time.h>
5924 void *v = localtime_r;
5925 EOF
5926 test "$?" != 0 && test_${pfx}cc -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 <<EOF && add_${pfx}cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
5927 #include <time.h>
5928 void *v = localtime_r;
5929 EOF
5930
5931     eval test -n "\${${pfx}libc_type}" && enable ${pfx}libc_${libc_type}
5932 }
5933
5934 probe_libc
5935 probe_libc host_
5936
5937 # hacks for compiler/libc/os combinations
5938
5939 case $libc_type in
5940     bionic)
5941         add_compat strtod.o strtod=avpriv_strtod
5942         ;;
5943 esac
5944
5945 check_compile_assert flt_lim "float.h limits.h" "DBL_MAX == (double)DBL_MAX" ||
5946     add_cppflags '-I\$(SRC_PATH)/compat/float'
5947
5948 test_cpp_condition stdlib.h "defined(__PIC__) || defined(__pic__) || defined(PIC)" && enable_weak pic
5949
5950 set_default libdir
5951 : ${shlibdir_default:="$libdir"}
5952 : ${pkgconfigdir_default:="$libdir/pkgconfig"}
5953
5954 set_default $PATHS_LIST
5955 set_default nm
5956
5957 disabled optimizations || enabled ossfuzz || check_cflags -fomit-frame-pointer
5958
5959 enable_weak_pic() {
5960     disabled pic && return
5961     enable pic
5962     add_cppflags -DPIC
5963     case "$target_os" in
5964     mingw*|cygwin*|win*)
5965         ;;
5966     *)
5967         add_cflags -fPIC
5968         add_asflags -fPIC
5969         ;;
5970     esac
5971 }
5972
5973 enabled pic && enable_weak_pic
5974
5975 test_cc <<EOF || die "Symbol mangling check failed."
5976 int ff_extern;
5977 EOF
5978 sym=$($nm $TMPO | awk '/ff_extern/{ print substr($0, match($0, /[^ \t]*ff_extern/)) }')
5979 extern_prefix=${sym%%ff_extern*}
5980
5981 ! disabled inline_asm && check_inline_asm inline_asm '"" ::'
5982
5983 for restrict_keyword in restrict __restrict__ __restrict ""; do
5984     test_code cc "" "char * $restrict_keyword p" && break
5985 done
5986
5987 check_cc pragma_deprecated "" '_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")'
5988
5989 # The global variable ensures the bits appear unchanged in the object file.
5990 test_cc <<EOF || die "endian test failed"
5991 unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
5992 EOF
5993 od -t x1 $TMPO | grep -q '42 *49 *47 *45' && enable bigendian
5994
5995 check_cc const_nan math.h "struct { double d; } static const bar[] = { { NAN } }"
5996
5997 if ! enabled ppc64 || enabled bigendian; then
5998     disable vsx
5999 fi
6000
6001 check_gas() {
6002     log "check_gas using '$as' as AS"
6003     # :vararg is used on aarch64, arm and ppc altivec
6004     check_as vararg "
6005 .macro m n, y:vararg=0
6006 \n: .int \y
6007 .endm
6008 m x" || return 1
6009     # .altmacro is only used in arm asm
6010     ! enabled arm || check_as gnu_as ".altmacro"
6011 }
6012
6013 if enabled_any arm aarch64 || enabled_all ppc altivec && enabled asm; then
6014     nogas=:
6015     enabled_any arm aarch64 && nogas=die
6016     enabled_all ppc altivec && [ $target_os_default != aix ] && nogas=warn
6017     as_noop=-v
6018
6019     case $as_type in
6020         arm*) gaspp_as_type=armasm; as_noop=-h ;;
6021         gcc)  gaspp_as_type=gas ;;
6022         *)    gaspp_as_type=$as_type ;;
6023     esac
6024
6025     [ $target_os = "darwin" ] && gaspp_as_type="apple-$gaspp_as_type"
6026
6027     test "${as#*gas-preprocessor.pl}" != "$as" ||
6028     test_cmd gas-preprocessor.pl -arch $arch -as-type $gaspp_as_type -- ${as:=$cc} $as_noop &&
6029         gas="${gas:=gas-preprocessor.pl} -arch $arch -as-type $gaspp_as_type -- ${as:=$cc}"
6030
6031     if ! check_gas ; then
6032         as=${gas:=$as}
6033         check_gas || \
6034             $nogas "GNU assembler not found, install/update gas-preprocessor"
6035     fi
6036
6037     check_as as_func ".func test
6038                       .endfunc"
6039 fi
6040
6041 check_inline_asm inline_asm_labels '"1:\n"'
6042
6043 check_inline_asm inline_asm_nonlocal_labels '"Label:\n"'
6044
6045 if enabled aarch64; then
6046     as_arch_level="armv8-a"
6047     check_as as_arch_directive ".arch $as_arch_level"
6048     enabled as_arch_directive && check_arch_level armv8.2-a
6049
6050     enabled armv8 && check_insn armv8 'prfm   pldl1strm, [x0]'
6051     # internal assembler in clang 3.3 does not support this instruction
6052     enabled neon && check_insn neon 'ext   v0.8B, v0.8B, v1.8B, #1'
6053
6054     archext_list="dotprod i8mm"
6055     enabled dotprod && check_archext_insn dotprod 'udot v0.4s, v0.16b, v0.16b'
6056     enabled i8mm    && check_archext_insn i8mm    'usdot v0.4s, v0.16b, v0.16b'
6057
6058     # Disable the main feature (e.g. HAVE_NEON) if neither inline nor external
6059     # assembly support the feature out of the box. Skip this for the features
6060     # checked with check_archext_insn above, as that function takes care of
6061     # updating all the variables as necessary.
6062     for v in $ARCH_EXT_LIST_ARM; do
6063         is_in $v $archext_list && continue
6064         enabled_any ${v}_external ${v}_inline || disable $v
6065     done
6066
6067 elif enabled alpha; then
6068
6069     check_cflags -mieee
6070
6071 elif enabled arm; then
6072
6073     enabled msvc && check_cpp_condition thumb stddef.h "defined _M_ARMT"
6074     test_cpp_condition stddef.h "defined __thumb__" && test_cc <<EOF && enable_weak thumb
6075 float func(float a, float b){ return a+b; }
6076 EOF
6077     enabled thumb && check_cflags -mthumb || check_cflags -marm
6078
6079     if check_cpp_condition vfp_args stddef.h "defined __ARM_PCS_VFP"; then
6080         :
6081     elif check_cpp_condition vfp_args stddef.h "defined _M_ARM_FP && _M_ARM_FP >= 30"; then
6082         :
6083     elif ! test_cpp_condition stddef.h "defined __ARM_PCS || defined __SOFTFP__" && [ $target_os != darwin ]; then
6084         case "${cross_prefix:-$cc}" in
6085             *hardfloat*) enable vfp_args; fpabi=vfp ;;
6086             *) check_ld "cc" vfp_args <<EOF && fpabi=vfp || fpabi=soft ;;
6087 __asm__ (".eabi_attribute 28, 1");
6088 int main(void) { return 0; }
6089 EOF
6090         esac
6091         warn "Compiler does not indicate floating-point ABI, guessing $fpabi."
6092     fi
6093
6094     # Test for various instruction sets, testing support both in inline and
6095     # external assembly. This sets the ${v}_inline or ${v}_external flags
6096     # if the instruction can be used unconditionally in either inline or
6097     # external assembly. This means that if the ${v}_external feature is set,
6098     # that feature can be used unconditionally in various support macros
6099     # anywhere in external assembly, in any function.
6100     enabled armv5te && check_insn armv5te 'qadd r0, r0, r0'
6101     enabled armv6   && check_insn armv6   'sadd16 r0, r0, r0'
6102     enabled armv6t2 && check_insn armv6t2 'movt r0, #0'
6103     enabled neon    && check_insn neon    'vadd.i16 q0, q0, q0'
6104     enabled vfp     && check_insn vfp     'fadds s0, s0, s0'
6105     enabled vfpv3   && check_insn vfpv3   'vmov.f32 s0, #1.0'
6106     enabled setend  && check_insn setend  'setend be'
6107
6108     # If neither inline nor external assembly can use the feature by default,
6109     # disable the main unsuffixed feature (e.g. HAVE_NEON).
6110     #
6111     # For targets that support runtime CPU feature detection, don't disable
6112     # the main feature flag - there we assume that all supported toolchains
6113     # can assemble code for all instruction set features (e.g. NEON) with
6114     # suitable assembly flags (such as ".fpu neon"); we don't check
6115     # specifically that they really do.
6116     [ $target_os = linux ] || [ $target_os = android ] ||
6117         map 'enabled_any ${v}_external ${v}_inline || disable $v' \
6118             $ARCH_EXT_LIST_ARM
6119
6120     check_inline_asm asm_mod_q '"add r0, %Q0, %R0" :: "r"((long long)0)'
6121
6122     check_as as_arch_directive ".arch armv7-a"
6123     check_as as_dn_directive   "ra .dn d0.i16"
6124     check_as as_fpu_directive  ".fpu neon"
6125
6126     # llvm's integrated assembler supports .object_arch from llvm 3.5
6127     [ "$objformat" = elf32 ] || [ "$objformat" = elf64 ] &&
6128         check_as as_object_arch ".object_arch armv4"
6129
6130     # MS armasm fails to assemble our PIC constructs
6131     [ $target_os != win32 ] && enabled_all armv6t2 shared !pic && enable_weak_pic
6132
6133 elif enabled mips; then
6134
6135     # Check toolchain ISA level
6136     if enabled mips64; then
6137         enabled mips64r6 && check_inline_asm mips64r6 '"dlsa $0, $0, $0, 1"' &&
6138             disable mips64r2
6139
6140         enabled mips64r2 && check_inline_asm mips64r2 '"dext $0, $0, 0, 1"'
6141
6142         disable mips32r6 && disable mips32r5 && disable mips32r2
6143     else
6144         enabled mips32r6 && check_inline_asm mips32r6 '"aui $0, $0, 0"' &&
6145             disable mips32r5 && disable mips32r2
6146
6147         enabled mips32r5 && check_inline_asm mips32r5 '"eretnc"'
6148         enabled mips32r2 && check_inline_asm mips32r2 '"ext $0, $0, 0, 1"'
6149
6150         disable mips64r6 && disable mips64r5 && disable mips64r2
6151     fi
6152
6153     enabled mipsfpu && check_inline_asm mipsfpu '"cvt.d.l $f0, $f2"'
6154     enabled mipsfpu && (enabled mips32r5 || enabled mips32r6 || enabled mips64r6) && check_inline_asm_flags mipsfpu '"cvt.d.l $f0, $f1"' '-mfp64'
6155
6156     enabled mipsdsp && check_inline_asm_flags mipsdsp '"addu.qb $t0, $t1, $t2"' '-mdsp'
6157     enabled mipsdspr2 && check_inline_asm_flags mipsdspr2 '"absq_s.qb $t0, $t1"' '-mdspr2'
6158
6159     # MSA can be detected at runtime so we supply extra flags here
6160     enabled mipsfpu && enabled msa && check_inline_asm msa '"addvi.b $w0, $w1, 1"' '-mmsa' && append MSAFLAGS '-mmsa'
6161
6162     # loongson2 have no switch cflag so we can only probe toolchain ability
6163     enabled loongson2 && check_inline_asm loongson2 '"dmult.g $8, $9, $10"' && disable loongson3
6164
6165     # loongson3 is paired with MMI
6166     enabled loongson3 && check_inline_asm loongson3 '"gsldxc1 $f0, 0($2, $3)"' '-mloongson-ext' && append MMIFLAGS '-mloongson-ext'
6167
6168     # MMI can be detected at runtime too
6169     enabled mmi && check_inline_asm mmi '"pxor $f0, $f0, $f0"' '-mloongson-mmi' && append MMIFLAGS '-mloongson-mmi'
6170
6171     if enabled bigendian && enabled msa; then
6172         disable msa
6173     fi
6174
6175 elif enabled parisc; then
6176
6177     if enabled gcc; then
6178         case $($cc -dumpversion) in
6179             4.[3-9].*) check_cflags -fno-optimize-sibling-calls ;;
6180         esac
6181     fi
6182
6183 elif enabled ppc; then
6184
6185     enable local_aligned
6186
6187     check_inline_asm dcbzl     '"dcbzl 0, %0" :: "r"(0)'
6188     check_inline_asm ibm_asm   '"add 0, 0, 0"'
6189     check_inline_asm ppc4xx    '"maclhw r10, r11, r12"'
6190     check_inline_asm xform_asm '"lwzx %1, %y0" :: "Z"(*(int*)0), "r"(0)'
6191
6192     if enabled altivec; then
6193         check_cflags -maltivec -mabi=altivec
6194
6195         # check if our compiler supports Motorola AltiVec C API
6196         check_cc altivec altivec.h "vector signed int v1 = (vector signed int) { 0 };
6197                                     vector signed int v2 = (vector signed int) { 1 };
6198                                     v1 = vec_add(v1, v2);"
6199
6200         enabled altivec || warn "Altivec disabled, possibly missing --cpu flag"
6201     fi
6202
6203     if enabled vsx; then
6204         check_cflags -mvsx &&
6205         check_cc vsx altivec.h "int v[4] = { 0 };
6206                                 vector signed int v1 = vec_vsx_ld(0, v);"
6207     fi
6208
6209     if enabled power8; then
6210         check_cpp_condition power8 "altivec.h" "defined(_ARCH_PWR8)"
6211     fi
6212
6213 elif enabled riscv; then
6214
6215     enabled rvv && check_inline_asm rvv '".option arch, +v\nvsetivli zero, 0, e8, m1, ta, ma"'
6216
6217 elif enabled x86; then
6218
6219     check_builtin rdtsc    intrin.h   "__rdtsc()"
6220     check_builtin mm_empty mmintrin.h "_mm_empty()"
6221
6222     enable local_aligned
6223
6224     # check whether EBP is available on x86
6225     # As 'i' is stored on the stack, this program will crash
6226     # if the base pointer is used to access it because the
6227     # base pointer is cleared in the inline assembly code.
6228     check_exec_crash <<EOF && enable ebp_available
6229 volatile int i=0;
6230 __asm__ volatile ("xorl %%ebp, %%ebp" ::: "%ebp");
6231 return i;
6232 EOF
6233
6234     # check whether EBX is available on x86
6235     check_inline_asm ebx_available '""::"b"(0)' &&
6236         check_inline_asm ebx_available '"":::"%ebx"'
6237
6238     # check whether xmm clobbers are supported
6239     check_inline_asm xmm_clobbers '"":::"%xmm0"'
6240
6241     check_inline_asm inline_asm_direct_symbol_refs '"movl '$extern_prefix'test, %eax"' ||
6242         check_inline_asm inline_asm_direct_symbol_refs '"movl '$extern_prefix'test(%rip), %eax"'
6243
6244     # check whether binutils is new enough to compile SSSE3/MMXEXT
6245     enabled ssse3  && check_inline_asm ssse3_inline  '"pabsw %xmm0, %xmm0"'
6246     enabled mmxext && check_inline_asm mmxext_inline '"pmaxub %mm0, %mm1"'
6247
6248     probe_x86asm(){
6249         x86asmexe_probe=$1
6250         if test_cmd $x86asmexe_probe -v; then
6251             x86asmexe=$x86asmexe_probe
6252             x86asm_type=nasm
6253             x86asm_debug="-g -F dwarf"
6254             X86ASMDEP=
6255             X86ASM_DEPFLAGS='-MD $(@:.o=.d)'
6256         elif test_cmd $x86asmexe_probe --version; then
6257             x86asmexe=$x86asmexe_probe
6258             x86asm_type=yasm
6259             x86asm_debug="-g dwarf2"
6260             X86ASMDEP='$(DEPX86ASM) $(X86ASMFLAGS) -M $(X86ASM_O) $< > $(@:.o=.d)'
6261             X86ASM_DEPFLAGS=
6262         fi
6263         check_x86asm x86asm "movbe ecx, [5]"
6264     }
6265
6266     if ! disabled_any asm mmx x86asm; then
6267         disable x86asm
6268         for program in $x86asmexe nasm yasm; do
6269             probe_x86asm $program && break
6270         done
6271         disabled x86asm && die "nasm/yasm not found or too old. Use --disable-x86asm for a crippled build."
6272         X86ASMFLAGS="-f $objformat"
6273         enabled pic               && append X86ASMFLAGS "-DPIC"
6274         test -n "$extern_prefix"  && append X86ASMFLAGS "-DPREFIX"
6275         case "$objformat" in
6276             elf*) enabled debug && append X86ASMFLAGS $x86asm_debug ;;
6277         esac
6278
6279         enabled avx512    && check_x86asm avx512_external    "vmovdqa32 [eax]{k1}{z}, zmm0"
6280         enabled avx512icl && check_x86asm avx512icl_external "vpdpwssds zmm31{k1}{z}, zmm29, zmm28"
6281         enabled avx2      && check_x86asm avx2_external      "vextracti128 xmm0, ymm0, 0"
6282         enabled xop       && check_x86asm xop_external       "vpmacsdd xmm0, xmm1, xmm2, xmm3"
6283         enabled fma4      && check_x86asm fma4_external      "vfmaddps ymm0, ymm1, ymm2, ymm3"
6284         check_x86asm cpunop          "CPU amdnop"
6285     fi
6286
6287     case "$cpu" in
6288         athlon*|opteron*|k8*|pentium|pentium-mmx|prescott|nocona|atom|geode)
6289             disable fast_clz
6290         ;;
6291     esac
6292
6293 elif enabled loongarch; then
6294     enabled lsx && check_inline_asm lsx '"vadd.b $vr0, $vr1, $vr2"' '-mlsx' && append LSXFLAGS '-mlsx'
6295     enabled lasx && check_inline_asm lasx '"xvadd.b $xr0, $xr1, $xr2"' '-mlasx' && append LASXFLAGS '-mlasx'
6296 fi
6297
6298 check_cc intrinsics_neon arm_neon.h "int16x8_t test = vdupq_n_s16(0)"
6299
6300 check_ldflags -Wl,--as-needed
6301 check_ldflags -Wl,-z,noexecstack
6302
6303 if ! disabled network; then
6304     check_func getaddrinfo $network_extralibs
6305     check_func inet_aton $network_extralibs
6306
6307     check_type netdb.h "struct addrinfo"
6308     check_type netinet/in.h "struct group_source_req" -D_BSD_SOURCE
6309     check_type netinet/in.h "struct ip_mreq_source" -D_BSD_SOURCE
6310     check_type netinet/in.h "struct ipv6_mreq" -D_DARWIN_C_SOURCE
6311     check_type poll.h "struct pollfd"
6312     check_type netinet/sctp.h "struct sctp_event_subscribe"
6313     check_struct "sys/socket.h" "struct msghdr" msg_flags
6314     check_struct "sys/types.h sys/socket.h" "struct sockaddr" sa_len
6315     check_type netinet/in.h "struct sockaddr_in6"
6316     check_type "sys/types.h sys/socket.h" "struct sockaddr_storage"
6317     check_type "sys/types.h sys/socket.h" socklen_t
6318
6319     # Prefer arpa/inet.h over winsock2
6320     if check_headers arpa/inet.h ; then
6321         check_func closesocket
6322     elif check_headers winsock2.h ; then
6323         check_func_headers winsock2.h closesocket -lws2 &&
6324             network_extralibs="-lws2" ||
6325         { check_func_headers winsock2.h closesocket -lws2_32 &&
6326             network_extralibs="-lws2_32"; } || disable winsock2_h network
6327         check_func_headers ws2tcpip.h getaddrinfo $network_extralibs
6328
6329         check_type ws2tcpip.h socklen_t
6330         check_type ws2tcpip.h "struct addrinfo"
6331         check_type ws2tcpip.h "struct group_source_req"
6332         check_type ws2tcpip.h "struct ip_mreq_source"
6333         check_type ws2tcpip.h "struct ipv6_mreq"
6334         check_type winsock2.h "struct pollfd"
6335         check_struct winsock2.h "struct sockaddr" sa_len
6336         check_type ws2tcpip.h "struct sockaddr_in6"
6337         check_type ws2tcpip.h "struct sockaddr_storage"
6338     else
6339         disable network
6340     fi
6341 fi
6342
6343 check_builtin atomic_cas_ptr atomic.h "void **ptr; void *oldval, *newval; atomic_cas_ptr(ptr, oldval, newval)"
6344 check_builtin machine_rw_barrier mbarrier.h "__machine_rw_barrier()"
6345 check_builtin MemoryBarrier windows.h "MemoryBarrier()"
6346 check_builtin sync_val_compare_and_swap "" "int *ptr; int oldval, newval; __sync_val_compare_and_swap(ptr, oldval, newval)"
6347 check_builtin gmtime_r time.h "time_t *time; struct tm *tm; gmtime_r(time, tm)"
6348 check_builtin localtime_r time.h "time_t *time; struct tm *tm; localtime_r(time, tm)"
6349
6350 check_builtin float16 "" "_Float16 f16var"
6351 if enabled float16; then
6352     if enabled x86; then
6353         test_cpp_condition stddef.h "defined(__F16C__)" && enable fast_float16
6354     elif enabled arm || enabled aarch64; then
6355         enable fast_float16
6356     fi
6357 fi
6358
6359 case "$custom_allocator" in
6360     "")
6361     ;;
6362     jemalloc)
6363         test -n "$malloc_prefix" ||
6364             malloc_prefix=$($pkg_config --variable=jemalloc_prefix $pkg_config_flags jemalloc 2>/dev/null)
6365         require_pkg_config custom_allocator jemalloc jemalloc/jemalloc.h ${malloc_prefix}malloc
6366     ;;
6367     tcmalloc)
6368         require_pkg_config custom_allocator libtcmalloc gperftools/tcmalloc.h tc_malloc
6369         malloc_prefix=tc_
6370     ;;
6371     *)
6372         require_pkg_config custom_allocator "$custom_allocator" stdlib.h malloc
6373     ;;
6374 esac
6375
6376 if test -n "$custom_allocator"; then
6377     add_extralibs "$custom_allocator_extralibs"
6378 fi
6379
6380 check_func_headers malloc.h _aligned_malloc     && enable aligned_malloc
6381 check_func  ${malloc_prefix}memalign            && enable memalign
6382 check_func  ${malloc_prefix}posix_memalign      && enable posix_memalign
6383
6384 check_func  access
6385 check_func_headers stdlib.h arc4random_buf
6386 check_lib   clock_gettime time.h clock_gettime || check_lib clock_gettime time.h clock_gettime -lrt
6387 check_func  fcntl
6388 check_func  fork
6389 check_func  gethrtime
6390 check_func  getopt
6391 check_func  getrusage
6392 check_func  gettimeofday
6393 check_func  isatty
6394 check_func  mkstemp
6395 check_func  mmap
6396 check_func  mprotect
6397 # Solaris has nanosleep in -lrt, OpenSolaris no longer needs that
6398 check_func_headers time.h nanosleep || check_lib nanosleep time.h nanosleep -lrt
6399 check_func_headers sys/prctl.h prctl
6400 check_func  sched_getaffinity
6401 check_func  setrlimit
6402 check_struct "sys/stat.h" "struct stat" st_mtim.tv_nsec -D_BSD_SOURCE
6403 check_func  strerror_r
6404 check_func  sysconf
6405 check_func  sysctl
6406 check_func  usleep
6407
6408 check_func_headers conio.h kbhit
6409 check_func_headers io.h setmode
6410 check_func_headers lzo/lzo1x.h lzo1x_999_compress
6411 check_func_headers mach/mach_time.h mach_absolute_time
6412 check_func_headers stdlib.h getenv
6413 check_func_headers sys/stat.h lstat
6414 check_func_headers sys/auxv.h getauxval
6415 check_func_headers sys/sysctl.h sysctlbyname
6416
6417 check_func_headers windows.h GetModuleHandle
6418 check_func_headers windows.h GetProcessAffinityMask
6419 check_func_headers windows.h GetProcessTimes
6420 check_func_headers windows.h GetStdHandle
6421 check_func_headers windows.h GetSystemTimeAsFileTime
6422 check_func_headers windows.h LoadLibrary
6423 check_func_headers windows.h MapViewOfFile
6424 check_func_headers windows.h PeekNamedPipe
6425 check_func_headers windows.h SetConsoleTextAttribute
6426 check_func_headers windows.h SetConsoleCtrlHandler
6427 check_func_headers windows.h SetDllDirectory
6428 check_func_headers windows.h Sleep
6429 check_func_headers windows.h VirtualAlloc
6430 check_func_headers glob.h glob
6431
6432 if enabled xlib; then
6433     check_pkg_config xlib_x11 x11 "X11/Xlib.h" XPending ||
6434     check_lib xlib_x11 "X11/Xlib.h" XPending -lX11 ||
6435         disable xlib
6436
6437     check_pkg_config xlib_xext xext "X11/Xlib.h X11/extensions/XShm.h" XShmAttach ||
6438     check_lib xlib_xext "X11/Xlib.h X11/extensions/XShm.h" XShmAttach -lXext ||
6439         disable xlib
6440
6441     check_pkg_config xlib_xv xv "X11/Xlib.h X11/extensions/Xvlib.h" XvGetPortAttribute ||
6442     check_lib xlib_xv "X11/Xlib.h X11/extensions/Xvlib.h" XvGetPortAttribute -lXv ||
6443         disable xlib
6444 fi
6445
6446 check_headers direct.h
6447 check_headers dirent.h
6448 check_headers dxgidebug.h
6449 check_headers dxva.h
6450 check_headers dxva2api.h -D_WIN32_WINNT=0x0600
6451 check_headers io.h
6452 enabled libdrm &&
6453     check_headers linux/dma-buf.h
6454
6455 check_headers linux/perf_event.h
6456 check_headers libcrystalhd/libcrystalhd_if.h
6457 check_headers malloc.h
6458 check_headers mftransform.h
6459 check_headers net/udplite.h
6460 check_headers poll.h
6461 check_headers sys/param.h
6462 check_headers sys/resource.h
6463 check_headers sys/select.h
6464 check_headers sys/time.h
6465 check_headers sys/un.h
6466 check_headers termios.h
6467 check_headers unistd.h
6468 check_headers valgrind/valgrind.h
6469 check_func_headers VideoToolbox/VTCompressionSession.h VTCompressionSessionPrepareToEncodeFrames -framework VideoToolbox
6470 check_func_headers VideoToolbox/VideoToolbox.h VTPixelRotationSessionCreate -framework VideoToolbox
6471 check_headers windows.h
6472 check_headers asm/types.h
6473
6474 # it seems there are versions of clang in some distros that try to use the
6475 # gcc headers, which explodes for stdatomic
6476 # so we also check that atomics actually work here
6477 #
6478 # some configurations also require linking to libatomic, so try
6479 # both with -latomic and without
6480 for LATOMIC in "-latomic" ""; do
6481     check_builtin stdatomic stdatomic.h                                                 \
6482         "atomic_int foo, bar = ATOMIC_VAR_INIT(-1); atomic_store(&foo, 0); foo += bar"  \
6483         $LATOMIC && eval stdatomic_extralibs="\$LATOMIC" && break
6484 done
6485
6486 check_lib advapi32 "windows.h"            RegCloseKey          -ladvapi32
6487 check_lib bcrypt   "windows.h bcrypt.h"   BCryptGenRandom      -lbcrypt &&
6488     check_cpp_condition bcrypt bcrypt.h "defined BCRYPT_RNG_ALGORITHM"
6489 check_lib ole32    "windows.h objbase.h"  CoTaskMemFree        -lole32
6490 check_lib shell32  "windows.h shellapi.h" CommandLineToArgvW   -lshell32
6491 check_lib psapi    "windows.h psapi.h"    GetProcessMemoryInfo -lpsapi
6492
6493 check_lib android android/native_window.h ANativeWindow_acquire -landroid
6494 check_lib mediandk "stdint.h media/NdkImage.h" AImage_delete -lmediandk
6495 check_lib camera2ndk "stdbool.h stdint.h camera/NdkCameraManager.h" ACameraManager_create -lcamera2ndk
6496
6497 enabled appkit       && check_apple_framework AppKit
6498 enabled audiotoolbox && check_apple_framework AudioToolbox
6499 enabled avfoundation && check_apple_framework AVFoundation
6500 enabled coreimage    && check_apple_framework CoreImage
6501 enabled metal        && check_apple_framework Metal
6502 enabled videotoolbox && check_apple_framework VideoToolbox
6503
6504 check_apple_framework CoreFoundation
6505 check_apple_framework CoreMedia
6506 check_apple_framework CoreVideo
6507 check_apple_framework CoreAudio
6508
6509 enabled avfoundation && {
6510     disable coregraphics applicationservices
6511     check_lib coregraphics        CoreGraphics/CoreGraphics.h               CGGetActiveDisplayList "-framework CoreGraphics" ||
6512     check_lib applicationservices ApplicationServices/ApplicationServices.h CGGetActiveDisplayList "-framework ApplicationServices"; }
6513
6514 enabled videotoolbox && {
6515     check_lib coreservices CoreServices/CoreServices.h UTGetOSTypeFromString "-framework CoreServices"
6516     check_func_headers CoreMedia/CMFormatDescription.h kCMVideoCodecType_HEVC "-framework CoreMedia"
6517     check_func_headers CoreMedia/CMFormatDescription.h kCMVideoCodecType_HEVCWithAlpha "-framework CoreMedia"
6518     check_func_headers CoreMedia/CMFormatDescription.h kCMVideoCodecType_VP9 "-framework CoreMedia"
6519     check_func_headers CoreVideo/CVPixelBuffer.h kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange "-framework CoreVideo"
6520     check_func_headers CoreVideo/CVPixelBuffer.h kCVPixelFormatType_422YpCbCr8BiPlanarVideoRange "-framework CoreVideo"
6521     check_func_headers CoreVideo/CVPixelBuffer.h kCVPixelFormatType_422YpCbCr10BiPlanarVideoRange "-framework CoreVideo"
6522     check_func_headers CoreVideo/CVPixelBuffer.h kCVPixelFormatType_422YpCbCr16BiPlanarVideoRange "-framework CoreVideo"
6523     check_func_headers CoreVideo/CVPixelBuffer.h kCVPixelFormatType_444YpCbCr8BiPlanarVideoRange "-framework CoreVideo"
6524     check_func_headers CoreVideo/CVPixelBuffer.h kCVPixelFormatType_444YpCbCr10BiPlanarVideoRange "-framework CoreVideo"
6525     check_func_headers CoreVideo/CVPixelBuffer.h kCVPixelFormatType_444YpCbCr16BiPlanarVideoRange "-framework CoreVideo"
6526     check_func_headers CoreVideo/CVImageBuffer.h kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ "-framework CoreVideo"
6527     check_func_headers CoreVideo/CVImageBuffer.h kCVImageBufferTransferFunction_ITU_R_2100_HLG "-framework CoreVideo"
6528     check_func_headers CoreVideo/CVImageBuffer.h kCVImageBufferTransferFunction_Linear "-framework CoreVideo"
6529     check_func_headers CoreVideo/CVImageBuffer.h kCVImageBufferYCbCrMatrix_ITU_R_2020 "-framework CoreVideo"
6530     check_func_headers CoreVideo/CVImageBuffer.h kCVImageBufferColorPrimaries_ITU_R_2020 "-framework CoreVideo"
6531     check_func_headers CoreVideo/CVImageBuffer.h kCVImageBufferTransferFunction_ITU_R_2020 "-framework CoreVideo"
6532     check_func_headers CoreVideo/CVImageBuffer.h kCVImageBufferTransferFunction_SMPTE_ST_428_1 "-framework CoreVideo"
6533 }
6534
6535 enabled metal && test_cmd $metalcc -v || disable metal
6536
6537 check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss
6538
6539 check_type "windows.h dxva.h" "DXVA_PicParams_AV1" -DWINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP -D_CRT_BUILD_DESKTOP_APP=0
6540 check_type "windows.h dxva.h" "DXVA_PicParams_HEVC" -DWINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP -D_CRT_BUILD_DESKTOP_APP=0
6541 check_type "windows.h dxva.h" "DXVA_PicParams_VP9" -DWINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP -D_CRT_BUILD_DESKTOP_APP=0
6542 check_type "windows.h dxgi1_2.h" "DXGI_OUTDUPL_FRAME_INFO"
6543 check_type "windows.h dxgi1_2.h" "IDXGIOutput1"
6544 check_type "windows.h dxgi1_5.h" "IDXGIOutput5"
6545 check_type "windows.h d3d11.h" "ID3D11VideoDecoder"
6546 check_type "windows.h d3d11.h" "ID3D11VideoContext"
6547 check_type "windows.h" "DPI_AWARENESS_CONTEXT" -D_WIN32_WINNT=0x0A00
6548 check_type "d3d9.h dxva2api.h" DXVA2_ConfigPictureDecode -D_WIN32_WINNT=0x0602
6549 check_func_headers mfapi.h MFCreateAlignedMemoryBuffer -lmfplat
6550
6551 check_type "vdpau/vdpau.h" "VdpPictureInfoHEVC"
6552 check_type "vdpau/vdpau.h" "VdpPictureInfoVP9"
6553 check_type "vdpau/vdpau.h" "VdpPictureInfoAV1"
6554
6555 if [ -z "$nvccflags" ]; then
6556     nvccflags=$nvccflags_default
6557 fi
6558
6559 nvccflags="$nvccflags -std=c++11"
6560
6561 if enabled x86_64 || enabled ppc64 || enabled aarch64; then
6562     nvccflags="$nvccflags -m64"
6563 else
6564     nvccflags="$nvccflags -m32"
6565 fi
6566
6567 if enabled cuda_nvcc; then
6568     nvccflags="$nvccflags -ptx"
6569 else
6570     nvccflags="$nvccflags -S -nocudalib -nocudainc --cuda-device-only -Wno-c++11-narrowing -include ${source_link}/compat/cuda/cuda_runtime.h"
6571     check_nvcc cuda_llvm
6572 fi
6573
6574 if ! disabled ffnvcodec; then
6575     ffnv_hdr_list="ffnvcodec/nvEncodeAPI.h ffnvcodec/dynlink_cuda.h ffnvcodec/dynlink_cuviddec.h ffnvcodec/dynlink_nvcuvid.h"
6576     check_pkg_config ffnvcodec "ffnvcodec >= 12.1.14.0" "$ffnv_hdr_list" "" || \
6577       check_pkg_config ffnvcodec "ffnvcodec >= 12.0.16.1 ffnvcodec < 12.1" "$ffnv_hdr_list" "" || \
6578       check_pkg_config ffnvcodec "ffnvcodec >= 11.1.5.3 ffnvcodec < 12.0" "$ffnv_hdr_list" "" || \
6579       check_pkg_config ffnvcodec "ffnvcodec >= 11.0.10.3 ffnvcodec < 11.1" "$ffnv_hdr_list" "" || \
6580       check_pkg_config ffnvcodec "ffnvcodec >= 8.1.24.15 ffnvcodec < 8.2" "$ffnv_hdr_list" ""
6581 fi
6582
6583 if enabled_all libglslang libshaderc; then
6584     die "ERROR: libshaderc and libglslang are mutually exclusive, if in doubt, disable libglslang"
6585 fi
6586
6587 check_cpp_condition winrt windows.h "!WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)"
6588
6589 if ! disabled w32threads && ! enabled pthreads; then
6590     check_func_headers "windows.h process.h" _beginthreadex &&
6591         check_type "windows.h" CONDITION_VARIABLE &&
6592         check_type "windows.h" INIT_ONCE &&
6593         enable w32threads || disable w32threads
6594     if ! enabled w32threads && enabled winrt; then
6595         check_func_headers "windows.h" CreateThread &&
6596             enable w32threads || disable w32threads
6597     fi
6598 fi
6599
6600 # check for some common methods of building with pthread support
6601 # do this before the optional library checks as some of them require pthreads
6602 if ! disabled pthreads && ! enabled w32threads && ! enabled os2threads; then
6603     if check_lib pthreads pthread.h pthread_join   -pthread &&
6604        check_lib pthreads pthread.h pthread_create -pthread; then
6605         add_cflags -pthread
6606     elif check_lib pthreads pthread.h pthread_join   -pthreads &&
6607          check_lib pthreads pthread.h pthread_create -pthreads; then
6608         add_cflags -pthreads
6609     elif check_lib pthreads pthread.h pthread_join   -ldl -pthread &&
6610          check_lib pthreads pthread.h pthread_create -ldl -pthread; then
6611         add_cflags -ldl -pthread
6612     elif check_lib pthreads pthread.h pthread_join   -lpthreadGC2 &&
6613          check_lib pthreads pthread.h pthread_create -lpthreadGC2; then
6614         :
6615     elif check_lib pthreads pthread.h pthread_join   -lpthread &&
6616          check_lib pthreads pthread.h pthread_create -lpthread; then
6617         :
6618     elif check_func pthread_join && check_func pthread_create; then
6619         enable pthreads
6620     fi
6621     check_cc pthreads "pthread.h" "static pthread_mutex_t atomic_lock = PTHREAD_MUTEX_INITIALIZER"
6622
6623     if enabled pthreads; then
6624         check_builtin sem_timedwait semaphore.h "sem_t *s; sem_init(s,0,0); sem_timedwait(s,0); sem_destroy(s)" $pthreads_extralibs
6625         check_func pthread_cancel $pthreads_extralibs
6626     fi
6627 fi
6628
6629 enabled  zlib && { check_pkg_config zlib zlib "zlib.h" zlibVersion ||
6630                    check_lib zlib   zlib.h      zlibVersion    -lz; }
6631 enabled bzlib && check_lib bzlib bzlib.h BZ2_bzlibVersion    -lbz2
6632 enabled  lzma && check_lib lzma   lzma.h lzma_version_number -llzma
6633
6634 enabled zlib && test_exec $zlib_extralibs <<EOF && enable zlib_gzip
6635 #include <zlib.h>
6636 int main(void) {
6637     if (zlibCompileFlags() & (1 << 17)) return 1;
6638     return 0;
6639 }
6640 EOF
6641
6642 [ -x "$(command -v gzip)" ] && enable gzip
6643
6644 enabled zlib_gzip && enabled gzip || disable ptx_compression
6645
6646 # On some systems dynamic loading requires no extra linker flags
6647 check_lib libdl dlfcn.h "dlopen dlsym" || check_lib libdl dlfcn.h "dlopen dlsym" -ldl
6648
6649 check_lib libm math.h sin -lm
6650
6651 atan2f_args=2
6652 copysign_args=2
6653 hypot_args=2
6654 ldexpf_args=2
6655 powf_args=2
6656
6657 for func in $MATH_FUNCS; do
6658     eval check_mathfunc $func \${${func}_args:-1} $libm_extralibs
6659 done
6660
6661 # these are off by default, so fail if requested and not available
6662 enabled avisynth          && { require_headers "avisynth/avisynth_c.h avisynth/avs/version.h" &&
6663                                { test_cpp_condition avisynth/avs/version.h "AVS_MAJOR_VER >= 3 && AVS_MINOR_VER >= 7 && AVS_BUGFIX_VER >= 3 || AVS_MAJOR_VER >= 3 && AVS_MINOR_VER > 7 || AVS_MAJOR_VER > 3" ||
6664                                  die "ERROR: AviSynth+ header version must be >= 3.7.3"; } }
6665 enabled cuda_nvcc         && { check_nvcc cuda_nvcc || die "ERROR: failed checking for nvcc."; }
6666 enabled chromaprint       && { check_pkg_config chromaprint libchromaprint "chromaprint.h" chromaprint_get_version ||
6667                                require chromaprint chromaprint.h chromaprint_get_version -lchromaprint; }
6668 enabled decklink          && { require_headers DeckLinkAPI.h &&
6669                                { test_cpp_condition DeckLinkAPIVersion.h "BLACKMAGIC_DECKLINK_API_VERSION >= 0x0a0b0000" || die "ERROR: Decklink API version must be >= 10.11"; } }
6670 enabled frei0r            && require_headers "frei0r.h"
6671 enabled gmp               && require gmp gmp.h mpz_export -lgmp
6672 enabled gnutls            && require_pkg_config gnutls gnutls gnutls/gnutls.h gnutls_global_init
6673 enabled jni               && { [ $target_os = "android" ] && check_headers jni.h && enabled pthreads || die "ERROR: jni not found"; }
6674 enabled ladspa            && require_headers "ladspa.h dlfcn.h"
6675 enabled lcms2             && require_pkg_config lcms2 "lcms2 >= 2.13" lcms2.h cmsCreateContext
6676 enabled libaom            && require_pkg_config libaom "aom >= 1.0.0" aom/aom_codec.h aom_codec_version
6677 enabled libaribb24        && { check_pkg_config libaribb24 "aribb24 > 1.0.3" "aribb24/aribb24.h" arib_instance_new ||
6678                                { enabled gpl && require_pkg_config libaribb24 aribb24 "aribb24/aribb24.h" arib_instance_new; } ||
6679                                die "ERROR: libaribb24 requires version higher than 1.0.3 or --enable-gpl."; }
6680 enabled libaribcaption    && require_pkg_config libaribcaption "libaribcaption >= 1.1.1" "aribcaption/aribcaption.h" aribcc_context_alloc
6681 enabled lv2               && require_pkg_config lv2 lilv-0 "lilv/lilv.h" lilv_world_new
6682 enabled libiec61883       && require libiec61883 libiec61883/iec61883.h iec61883_cmp_connect -lraw1394 -lavc1394 -lrom1394 -liec61883
6683 enabled libass            && require_pkg_config libass "libass >= 0.11.0" ass/ass.h ass_library_init
6684 enabled libbluray         && require_pkg_config libbluray libbluray libbluray/bluray.h bd_open
6685 enabled libbs2b           && require_pkg_config libbs2b libbs2b bs2b.h bs2b_open
6686 enabled libcelt           && require libcelt celt/celt.h celt_decode -lcelt0 &&
6687                              { check_lib libcelt celt/celt.h celt_decoder_create_custom -lcelt0 ||
6688                                die "ERROR: libcelt must be installed and version must be >= 0.11.0."; }
6689 enabled libcaca           && require_pkg_config libcaca caca caca.h caca_create_canvas
6690 enabled libcodec2         && require libcodec2 codec2/codec2.h codec2_create -lcodec2
6691 enabled libdav1d          && require_pkg_config libdav1d "dav1d >= 0.5.0" "dav1d/dav1d.h" dav1d_version
6692 enabled libdavs2          && require_pkg_config libdavs2 "davs2 >= 1.6.0" davs2.h davs2_decoder_open
6693 enabled libdc1394         && require_pkg_config libdc1394 libdc1394-2 dc1394/dc1394.h dc1394_new
6694 enabled libdrm            && require_pkg_config libdrm libdrm xf86drm.h drmGetVersion
6695 enabled libfdk_aac        && { check_pkg_config libfdk_aac fdk-aac "fdk-aac/aacenc_lib.h" aacEncOpen ||
6696                                { require libfdk_aac fdk-aac/aacenc_lib.h aacEncOpen -lfdk-aac &&
6697                                  warn "using libfdk without pkg-config"; } }
6698 flite_extralibs="-lflite_cmu_time_awb -lflite_cmu_us_awb -lflite_cmu_us_kal -lflite_cmu_us_kal16 -lflite_cmu_us_rms -lflite_cmu_us_slt -lflite_usenglish -lflite_cmulex -lflite"
6699 enabled libflite          && require libflite "flite/flite.h" flite_init $flite_extralibs
6700 enabled fontconfig        && enable libfontconfig
6701 enabled libfontconfig     && require_pkg_config libfontconfig fontconfig "fontconfig/fontconfig.h" FcInit
6702 enabled libfreetype       && require_pkg_config libfreetype freetype2 "ft2build.h FT_FREETYPE_H" FT_Init_FreeType
6703 enabled libfribidi        && require_pkg_config libfribidi fribidi fribidi.h fribidi_version_info
6704 enabled libharfbuzz       && require_pkg_config libharfbuzz harfbuzz hb.h hb_buffer_create
6705 enabled libglslang && { check_lib spirv_compiler glslang/Include/glslang_c_interface.h glslang_initialize_process \
6706                             -lglslang -lMachineIndependent -lOSDependent -lHLSL -lOGLCompiler -lGenericCodeGen \
6707                             -lSPVRemapper -lSPIRV -lSPIRV-Tools-opt -lSPIRV-Tools -lpthread -lstdc++ -lm ||
6708                         require spirv_compiler glslang/Include/glslang_c_interface.h glslang_initialize_process \
6709                             -lglslang -lOSDependent -lHLSL -lOGLCompiler \
6710                             -lSPVRemapper -lSPIRV -lSPIRV-Tools-opt -lSPIRV-Tools -lpthread -lstdc++ -lm; }
6711 enabled libgme            && { check_pkg_config libgme libgme gme/gme.h gme_new_emu ||
6712                                require libgme gme/gme.h gme_new_emu -lgme -lstdc++; }
6713 enabled libgsm            && { for gsm_hdr in "gsm.h" "gsm/gsm.h"; do
6714                                    check_lib libgsm "${gsm_hdr}" gsm_create -lgsm && break;
6715                                done || die "ERROR: libgsm not found"; }
6716 enabled libilbc           && require libilbc ilbc.h WebRtcIlbcfix_InitDecode -lilbc $pthreads_extralibs
6717 enabled libjxl            && require_pkg_config libjxl "libjxl >= 0.7.0" jxl/decode.h JxlDecoderVersion &&
6718                              require_pkg_config libjxl_threads "libjxl_threads >= 0.7.0" jxl/thread_parallel_runner.h JxlThreadParallelRunner
6719 enabled libklvanc         && require libklvanc libklvanc/vanc.h klvanc_context_create -lklvanc
6720 enabled libkvazaar        && require_pkg_config libkvazaar "kvazaar >= 2.0.0" kvazaar.h kvz_api_get
6721 enabled liblensfun        && require_pkg_config liblensfun lensfun lensfun.h lf_db_new
6722
6723 if enabled libmfx && enabled libvpl; then
6724    die "ERROR: can not use libmfx and libvpl together"
6725 # While it may appear that require is being used as a pkg-config
6726 # fallback for libmfx, it is actually being used to detect a different
6727 # installation route altogether.  If libmfx is installed via the Intel
6728 # Media SDK or Intel Media Server Studio, these don't come with
6729 # pkg-config support.  Instead, users should make sure that the build
6730 # can find the libraries and headers through other means.
6731 elif enabled libmfx; then
6732     { check_pkg_config libmfx "libmfx >= 1.28 libmfx < 2.0" "mfxvideo.h" MFXInit ||
6733 # Some old versions of libmfx have the following settings in libmfx.pc:
6734 #   includedir=/usr/include
6735 #   Cflags: -I${includedir}
6736 # So add -I${includedir}/mfx to CFLAGS
6737       { check_pkg_config libmfx "libmfx >= 1.28 libmfx < 2.0" "mfx/mfxvideo.h" MFXInit && add_cflags -I${libmfx_incdir}/mfx; } ||
6738       { require libmfx "mfxvideo.h mfxdefs.h" MFXInit "-llibmfx $advapi32_extralibs" &&
6739         { test_cpp_condition mfxdefs.h "MFX_VERSION >= 1028 && MFX_VERSION < 2000" || die "ERROR: libmfx version must be >= 1.28 and < 2.0"; }  &&
6740         warn "using libmfx without pkg-config"; } } &&
6741     warn "libmfx is deprecated. Please run configure with --enable-libvpl to use libvpl instead."
6742 elif enabled libvpl; then
6743 # Consider pkg-config only. The name of libmfx is still passed to check_pkg_config function for --enable-libvpl option
6744 # because QSV has dependency on libmfx, we can use the same dependency if using libmfx in this check. The package name
6745 # is extracted from "vpl >= 2.6"
6746     check_pkg_config libmfx "vpl >= 2.6" "mfxvideo.h mfxdispatcher.h" MFXLoad || \
6747             die "ERROR: libvpl >= 2.6 not found"
6748 fi
6749
6750 if enabled libmfx; then
6751    check_cc MFX_CODEC_VP9 "mfxdefs.h mfxstructures.h" "MFX_CODEC_VP9"
6752 fi
6753
6754 enabled libmodplug        && require_pkg_config libmodplug libmodplug libmodplug/modplug.h ModPlug_Load
6755 enabled libmp3lame        && require "libmp3lame >= 3.98.3" lame/lame.h lame_set_VBR_quality -lmp3lame $libm_extralibs
6756 enabled libmysofa         && { check_pkg_config libmysofa libmysofa mysofa.h mysofa_neighborhood_init_withstepdefine ||
6757                                require libmysofa mysofa.h mysofa_neighborhood_init_withstepdefine -lmysofa $zlib_extralibs; }
6758 enabled libnpp            && { check_lib libnpp npp.h nppGetLibVersion -lnppig -lnppicc -lnppc -lnppidei -lnppif ||
6759                                check_lib libnpp npp.h nppGetLibVersion -lnppi -lnppif -lnppc -lnppidei ||
6760                                die "ERROR: libnpp not found"; }
6761 enabled libopencore_amrnb && require libopencore_amrnb opencore-amrnb/interf_dec.h Decoder_Interface_init -lopencore-amrnb
6762 enabled libopencore_amrwb && require libopencore_amrwb opencore-amrwb/dec_if.h D_IF_init -lopencore-amrwb
6763 enabled libopencv         && { check_headers opencv2/core/core_c.h &&
6764                                { check_pkg_config libopencv opencv opencv2/core/core_c.h cvCreateImageHeader ||
6765                                  require libopencv opencv2/core/core_c.h cvCreateImageHeader -lopencv_core -lopencv_imgproc; } ||
6766                                require_pkg_config libopencv opencv opencv/cxcore.h cvCreateImageHeader; }
6767 enabled libopenh264       && require_pkg_config libopenh264 openh264 wels/codec_api.h WelsGetCodecVersion
6768 enabled libopenjpeg       && { check_pkg_config libopenjpeg "libopenjp2 >= 2.1.0" openjpeg.h opj_version ||
6769                                { require_pkg_config libopenjpeg "libopenjp2 >= 2.1.0" openjpeg.h opj_version -DOPJ_STATIC && add_cppflags -DOPJ_STATIC; } }
6770 enabled libopenmpt        && require_pkg_config libopenmpt "libopenmpt >= 0.2.6557" libopenmpt/libopenmpt.h openmpt_module_create -lstdc++ && append libopenmpt_extralibs "-lstdc++"
6771 enabled libopenvino       && { { check_pkg_config libopenvino openvino openvino/c/openvino.h ov_core_create && enable openvino2; } ||
6772                                 { check_pkg_config libopenvino openvino c_api/ie_c_api.h ie_c_api_version ||
6773                                   require libopenvino c_api/ie_c_api.h ie_c_api_version -linference_engine_c_api; } }
6774 enabled libopus           && {
6775     enabled libopus_decoder && {
6776         require_pkg_config libopus opus opus_multistream.h opus_multistream_decoder_create
6777     }
6778     enabled libopus_encoder && {
6779         require_pkg_config libopus opus opus_multistream.h opus_multistream_surround_encoder_create
6780     }
6781 }
6782 enabled libplacebo        && require_pkg_config libplacebo "libplacebo >= 4.192.0" libplacebo/vulkan.h pl_vulkan_create
6783 enabled libpulse          && require_pkg_config libpulse libpulse pulse/pulseaudio.h pa_context_new
6784 enabled librabbitmq       && require_pkg_config librabbitmq "librabbitmq >= 0.7.1" amqp.h amqp_new_connection
6785 enabled librav1e          && require_pkg_config librav1e "rav1e >= 0.5.0" rav1e.h rav1e_context_new
6786 enabled librist           && require_pkg_config librist "librist >= 0.2.7" librist/librist.h rist_receiver_create
6787 enabled librsvg           && require_pkg_config librsvg librsvg-2.0 librsvg-2.0/librsvg/rsvg.h rsvg_handle_new_from_data
6788 enabled librtmp           && require_pkg_config librtmp librtmp librtmp/rtmp.h RTMP_Socket
6789 enabled librubberband     && require_pkg_config librubberband "rubberband >= 1.8.1" rubberband/rubberband-c.h rubberband_new -lstdc++ && append librubberband_extralibs "-lstdc++"
6790 enabled libshaderc        && require_pkg_config spirv_compiler "shaderc >= 2019.1" shaderc/shaderc.h shaderc_compiler_initialize
6791 enabled libshine          && require_pkg_config libshine shine shine/layer3.h shine_encode_buffer
6792 enabled libsmbclient      && { check_pkg_config libsmbclient smbclient libsmbclient.h smbc_init ||
6793                                require libsmbclient libsmbclient.h smbc_init -lsmbclient; }
6794 enabled libsnappy         && require libsnappy snappy-c.h snappy_compress -lsnappy -lstdc++
6795 enabled libsoxr           && require libsoxr soxr.h soxr_create -lsoxr
6796 enabled libssh            && require_pkg_config libssh "libssh >= 0.6.0" libssh/sftp.h sftp_init
6797 enabled libspeex          && require_pkg_config libspeex speex speex/speex.h speex_decoder_init
6798 enabled libsrt            && require_pkg_config libsrt "srt >= 1.3.0" srt/srt.h srt_socket
6799 enabled libsvtav1         && require_pkg_config libsvtav1 "SvtAv1Enc >= 0.9.0" EbSvtAv1Enc.h svt_av1_enc_init_handle
6800 enabled libtensorflow     && require libtensorflow tensorflow/c/c_api.h TF_Version -ltensorflow
6801 enabled libtesseract      && require_pkg_config libtesseract tesseract tesseract/capi.h TessBaseAPICreate
6802 enabled libtheora         && require libtheora theora/theoraenc.h th_info_init -ltheoraenc -ltheoradec -logg
6803 enabled libtls            && require_pkg_config libtls libtls tls.h tls_configure
6804 enabled libtwolame        && require libtwolame twolame.h twolame_init -ltwolame &&
6805                              { check_lib libtwolame twolame.h twolame_encode_buffer_float32_interleaved -ltwolame ||
6806                                die "ERROR: libtwolame must be installed and version must be >= 0.3.10"; }
6807 enabled libuavs3d         && require_pkg_config libuavs3d "uavs3d >= 1.1.41" uavs3d.h uavs3d_decode
6808 enabled libv4l2           && require_pkg_config libv4l2 libv4l2 libv4l2.h v4l2_ioctl
6809 enabled libvidstab        && require_pkg_config libvidstab "vidstab >= 0.98" vid.stab/libvidstab.h vsMotionDetectInit
6810 enabled libvmaf           && require_pkg_config libvmaf "libvmaf >= 2.0.0" libvmaf.h vmaf_init
6811 enabled libvmaf           && check_pkg_config libvmaf_cuda "libvmaf >= 2.0.0" libvmaf_cuda.h vmaf_cuda_state_init
6812 enabled libvo_amrwbenc    && require libvo_amrwbenc vo-amrwbenc/enc_if.h E_IF_init -lvo-amrwbenc
6813 enabled libvorbis         && require_pkg_config libvorbis vorbis vorbis/codec.h vorbis_info_init &&
6814                              require_pkg_config libvorbisenc vorbisenc vorbis/vorbisenc.h vorbis_encode_init
6815
6816 enabled libvpx            && {
6817     enabled libvpx_vp8_decoder && {
6818         check_pkg_config libvpx_vp8_decoder "vpx >= 1.4.0" "vpx/vpx_decoder.h vpx/vp8dx.h" vpx_codec_vp8_dx ||
6819             check_lib libvpx_vp8_decoder "vpx/vpx_decoder.h vpx/vp8dx.h" "vpx_codec_vp8_dx VPX_IMG_FMT_HIGHBITDEPTH" "-lvpx $libm_extralibs $pthreads_extralibs"
6820     }
6821     enabled libvpx_vp8_encoder && {
6822         check_pkg_config libvpx_vp8_encoder "vpx >= 1.4.0" "vpx/vpx_encoder.h vpx/vp8cx.h" vpx_codec_vp8_cx ||
6823             check_lib libvpx_vp8_encoder "vpx/vpx_encoder.h vpx/vp8cx.h" "vpx_codec_vp8_cx VPX_IMG_FMT_HIGHBITDEPTH" "-lvpx $libm_extralibs $pthreads_extralibs"
6824     }
6825     enabled libvpx_vp9_decoder && {
6826         check_pkg_config libvpx_vp9_decoder "vpx >= 1.4.0" "vpx/vpx_decoder.h vpx/vp8dx.h" vpx_codec_vp9_dx ||
6827             check_lib libvpx_vp9_decoder "vpx/vpx_decoder.h vpx/vp8dx.h" "vpx_codec_vp9_dx VPX_IMG_FMT_HIGHBITDEPTH" "-lvpx $libm_extralibs $pthreads_extralibs"
6828     }
6829     enabled libvpx_vp9_encoder && {
6830         check_pkg_config libvpx_vp9_encoder "vpx >= 1.4.0" "vpx/vpx_encoder.h vpx/vp8cx.h" vpx_codec_vp9_cx ||
6831             check_lib libvpx_vp9_encoder "vpx/vpx_encoder.h vpx/vp8cx.h" "vpx_codec_vp9_cx VPX_IMG_FMT_HIGHBITDEPTH" "-lvpx $libm_extralibs $pthreads_extralibs"
6832     }
6833     if disabled_all libvpx_vp8_decoder libvpx_vp9_decoder libvpx_vp8_encoder libvpx_vp9_encoder; then
6834         die "libvpx enabled but no supported decoders found"
6835     fi
6836 }
6837
6838 enabled libwebp           && {
6839     enabled libwebp_encoder      && require_pkg_config libwebp "libwebp >= 0.2.0" webp/encode.h WebPGetEncoderVersion
6840     enabled libwebp_anim_encoder && check_pkg_config libwebp_anim_encoder "libwebpmux >= 0.4.0" webp/mux.h WebPAnimEncoderOptionsInit; }
6841 enabled libx264           && require_pkg_config libx264 x264 "stdint.h x264.h" x264_encoder_encode &&
6842                              require_cpp_condition libx264 x264.h "X264_BUILD >= 122" && {
6843                              [ "$toolchain" != "msvc" ] ||
6844                              require_cpp_condition libx264 x264.h "X264_BUILD >= 158"; } &&
6845                              check_cpp_condition libx262 x264.h "X264_MPEG2"
6846 enabled libx265           && require_pkg_config libx265 x265 x265.h x265_api_get &&
6847                              require_cpp_condition libx265 x265.h "X265_BUILD >= 89"
6848 enabled libxavs           && require libxavs "stdint.h xavs.h" xavs_encoder_encode "-lxavs $pthreads_extralibs $libm_extralibs"
6849 enabled libxavs2          && require_pkg_config libxavs2 "xavs2 >= 1.3.0" "stdint.h xavs2.h" xavs2_api_get
6850 enabled libxvid           && require libxvid xvid.h xvid_global -lxvidcore
6851 enabled libzimg           && require_pkg_config libzimg "zimg >= 2.7.0" zimg.h zimg_get_api_version
6852 enabled libzmq            && require_pkg_config libzmq "libzmq >= 4.2.1" zmq.h zmq_ctx_new
6853 enabled libzvbi           && require_pkg_config libzvbi zvbi-0.2 libzvbi.h vbi_decoder_new &&
6854                              { test_cpp_condition libzvbi.h "VBI_VERSION_MAJOR > 0 || VBI_VERSION_MINOR > 2 || VBI_VERSION_MINOR == 2 && VBI_VERSION_MICRO >= 28" ||
6855                                enabled gpl || die "ERROR: libzvbi requires version 0.2.28 or --enable-gpl."; }
6856 enabled libxml2           && require_pkg_config libxml2 libxml-2.0 libxml2/libxml/xmlversion.h xmlCheckVersion
6857 enabled mbedtls           && { check_pkg_config mbedtls mbedtls mbedtls/x509_crt.h mbedtls_x509_crt_init ||
6858                                check_pkg_config mbedtls mbedtls mbedtls/ssl.h mbedtls_ssl_init ||
6859                                check_lib mbedtls mbedtls/ssl.h mbedtls_ssl_init -lmbedtls -lmbedx509 -lmbedcrypto ||
6860                                die "ERROR: mbedTLS not found"; }
6861 enabled mediacodec        && { enabled jni || die "ERROR: mediacodec requires --enable-jni"; }
6862 enabled mmal              && { check_lib mmal interface/mmal/mmal.h mmal_port_connect -lmmal_core -lmmal_util -lmmal_vc_client -lbcm_host ||
6863                                { ! enabled cross_compile &&
6864                                  add_cflags -isystem/opt/vc/include/ -isystem/opt/vc/include/interface/vmcs_host/linux -isystem/opt/vc/include/interface/vcos/pthreads -fgnu89-inline &&
6865                                  add_ldflags -L/opt/vc/lib/ &&
6866                                  check_lib mmal interface/mmal/mmal.h mmal_port_connect -lmmal_core -lmmal_util -lmmal_vc_client -lbcm_host; } ||
6867                                die "ERROR: mmal not found" &&
6868                                check_func_headers interface/mmal/mmal.h "MMAL_PARAMETER_VIDEO_MAX_NUM_CALLBACKS"; }
6869 enabled openal            && { check_pkg_config openal "openal >= 1.1" "AL/al.h" alGetError ||
6870                                { for al_extralibs in "${OPENAL_LIBS}" "-lopenal" "-lOpenAL32"; do
6871                                check_lib openal 'AL/al.h' alGetError "${al_extralibs}" && break; done } ||
6872                                die "ERROR: openal not found"; } &&
6873                              { test_cpp_condition "AL/al.h" "defined(AL_VERSION_1_1)" ||
6874                                die "ERROR: openal must be installed and version must be 1.1 or compatible"; }
6875 enabled opencl            && { check_pkg_config opencl OpenCL CL/cl.h clEnqueueNDRangeKernel ||
6876                                check_lib opencl OpenCL/cl.h clEnqueueNDRangeKernel -Wl,-framework,OpenCL ||
6877                                check_lib opencl CL/cl.h clEnqueueNDRangeKernel -lOpenCL ||
6878                                die "ERROR: opencl not found"; } &&
6879                              { test_cpp_condition "OpenCL/cl.h" "defined(CL_VERSION_1_2)" ||
6880                                test_cpp_condition "CL/cl.h" "defined(CL_VERSION_1_2)" ||
6881                                die "ERROR: opencl must be installed and version must be 1.2 or compatible"; }
6882 enabled opengl            && { check_lib opengl GL/glx.h glXGetProcAddress "-lGL" ||
6883                                check_lib opengl windows.h wglGetProcAddress "-lopengl32 -lgdi32" ||
6884                                check_lib opengl OpenGL/gl3.h glGetError "-Wl,-framework,OpenGL" ||
6885                                check_lib opengl ES2/gl.h glGetError "-isysroot=${sysroot} -Wl,-framework,OpenGLES" ||
6886                                die "ERROR: opengl not found."
6887                              }
6888 enabled omx_rpi           && { test_code cc OMX_Core.h OMX_IndexConfigBrcmVideoRequestIFrame ||
6889                                { ! enabled cross_compile &&
6890                                  add_cflags -isystem/opt/vc/include/IL &&
6891                                  test_code cc OMX_Core.h OMX_IndexConfigBrcmVideoRequestIFrame; } ||
6892                                die "ERROR: OpenMAX IL headers from raspberrypi/firmware not found"; } &&
6893                              enable omx
6894 enabled omx               && require_headers OMX_Core.h
6895 enabled openssl           && { { check_pkg_config openssl "openssl >= 3.0.0" openssl/ssl.h OPENSSL_init_ssl &&
6896                                  { enabled gplv3 || ! enabled gpl || enabled nonfree || die "ERROR: OpenSSL >=3.0.0 requires --enable-version3"; }; } ||
6897                                { enabled gpl && ! enabled nonfree && die "ERROR: OpenSSL <3.0.0 is incompatible with the gpl"; } ||
6898                                check_pkg_config openssl openssl openssl/ssl.h OPENSSL_init_ssl ||
6899                                check_pkg_config openssl openssl openssl/ssl.h SSL_library_init ||
6900                                check_lib openssl openssl/ssl.h OPENSSL_init_ssl -lssl -lcrypto ||
6901                                check_lib openssl openssl/ssl.h SSL_library_init -lssl -lcrypto ||
6902                                check_lib openssl openssl/ssl.h SSL_library_init -lssl32 -leay32 ||
6903                                check_lib openssl openssl/ssl.h SSL_library_init -lssl -lcrypto -lws2_32 -lgdi32 ||
6904                                die "ERROR: openssl not found"; }
6905 enabled pocketsphinx      && require_pkg_config pocketsphinx pocketsphinx pocketsphinx/pocketsphinx.h ps_init
6906 enabled rkmpp             && { require_pkg_config rkmpp rockchip_mpp  rockchip/rk_mpi.h mpp_create &&
6907                                require_pkg_config rockchip_mpp "rockchip_mpp >= 1.3.7" rockchip/rk_mpi.h mpp_create &&
6908                                { enabled libdrm ||
6909                                  die "ERROR: rkmpp requires --enable-libdrm"; }
6910                              }
6911 enabled vapoursynth       && require_pkg_config vapoursynth "vapoursynth-script >= 42" VSScript.h vsscript_init
6912
6913
6914 if enabled gcrypt; then
6915     GCRYPT_CONFIG="${cross_prefix}libgcrypt-config"
6916     if "${GCRYPT_CONFIG}" --version > /dev/null 2>&1; then
6917         gcrypt_cflags=$("${GCRYPT_CONFIG}" --cflags)
6918         gcrypt_extralibs=$("${GCRYPT_CONFIG}" --libs)
6919         check_func_headers gcrypt.h gcry_mpi_new $gcrypt_cflags $gcrypt_extralibs ||
6920             die "ERROR: gcrypt not found"
6921         add_cflags $gcrypt_cflags
6922     else
6923         require gcrypt gcrypt.h gcry_mpi_new -lgcrypt
6924     fi
6925 fi
6926
6927 if enabled sdl2; then
6928     SDL2_CONFIG="${cross_prefix}sdl2-config"
6929     test_pkg_config sdl2 "sdl2 >= 2.0.1 sdl2 < 3.0.0" SDL_events.h SDL_PollEvent
6930     if disabled sdl2 && "${SDL2_CONFIG}" --version > /dev/null 2>&1; then
6931         sdl2_cflags=$("${SDL2_CONFIG}" --cflags)
6932         sdl2_extralibs=$("${SDL2_CONFIG}" --libs)
6933         test_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x020001" $sdl2_cflags &&
6934         test_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) < 0x030000" $sdl2_cflags &&
6935         check_func_headers SDL_events.h SDL_PollEvent $sdl2_extralibs $sdl2_cflags &&
6936             enable sdl2
6937     fi
6938     if test $target_os = "mingw32"; then
6939         sdl2_extralibs=$(filter_out '-mwindows' $sdl2_extralibs)
6940     fi
6941 fi
6942
6943 if enabled decklink; then
6944     case $target_os in
6945         mingw32*|mingw64*|win32|win64)
6946             decklink_outdev_extralibs="$decklink_outdev_extralibs -lole32 -loleaut32"
6947             decklink_indev_extralibs="$decklink_indev_extralibs -lole32 -loleaut32"
6948             ;;
6949     esac
6950 fi
6951
6952 enabled securetransport &&
6953     check_func SecIdentityCreate "-Wl,-framework,CoreFoundation -Wl,-framework,Security" &&
6954     check_lib securetransport "Security/SecureTransport.h Security/Security.h" "SSLCreateContext" "-Wl,-framework,CoreFoundation -Wl,-framework,Security" ||
6955         disable securetransport
6956
6957 enabled securetransport &&
6958     check_func SecItemImport "-Wl,-framework,CoreFoundation -Wl,-framework,Security"
6959
6960 enabled schannel &&
6961     check_func_headers "windows.h security.h" InitializeSecurityContext -DSECURITY_WIN32 -lsecur32 &&
6962     test_cpp_condition winerror.h "defined(SEC_I_CONTEXT_EXPIRED)" &&
6963     schannel_extralibs="-lsecur32" ||
6964         disable schannel
6965
6966 makeinfo --version > /dev/null 2>&1 && enable makeinfo  || disable makeinfo
6967 enabled makeinfo \
6968     && [ 0$(makeinfo --version | grep "texinfo" | sed 's/.*texinfo[^0-9]*\([0-9]*\)\..*/\1/') -ge 5 ] \
6969     && enable makeinfo_html || disable makeinfo_html
6970 disabled makeinfo_html && texi2html --help 2> /dev/null | grep -q 'init-file' && enable texi2html || disable texi2html
6971 perl -v            > /dev/null 2>&1 && enable perl      || disable perl
6972 pod2man --help     > /dev/null 2>&1 && enable pod2man   || disable pod2man
6973 rsync --help 2> /dev/null | grep -q 'contimeout' && enable rsync_contimeout || disable rsync_contimeout
6974 xmllint --version  > /dev/null 2>&1 && enable xmllint   || disable xmllint
6975
6976 # check V4L2 codecs available in the API
6977 if enabled v4l2_m2m; then
6978     check_headers linux/fb.h
6979     check_headers linux/videodev2.h
6980     test_code cc linux/videodev2.h "struct v4l2_frmsizeenum vfse; vfse.discrete.width = 0;" && enable_sanitized struct_v4l2_frmivalenum_discrete
6981     check_cc v4l2_m2m linux/videodev2.h "int i = V4L2_CAP_VIDEO_M2M_MPLANE | V4L2_CAP_VIDEO_M2M | V4L2_BUF_FLAG_LAST;"
6982     check_cc vc1_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_VC1_ANNEX_G;"
6983     check_cc mpeg1_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_MPEG1;"
6984     check_cc mpeg2_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_MPEG2;"
6985     check_cc mpeg4_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_MPEG4;"
6986     check_cc hevc_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_HEVC;"
6987     check_cc h263_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_H263;"
6988     check_cc h264_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_H264;"
6989     check_cc vp8_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_VP8;"
6990     check_cc vp9_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_VP9;"
6991 fi
6992
6993 check_headers sys/videoio.h
6994 test_code cc sys/videoio.h "struct v4l2_frmsizeenum vfse; vfse.discrete.width = 0;" && enable_sanitized struct_v4l2_frmivalenum_discrete
6995
6996 check_lib user32 "windows.h winuser.h" GetShellWindow -luser32
6997 check_lib vfw32 "windows.h vfw.h" capCreateCaptureWindow -lvfw32
6998 # check that WM_CAP_DRIVER_CONNECT is defined to the proper value
6999 # w32api 3.12 had it defined wrong
7000 check_cpp_condition vfwcap_defines vfw.h "WM_CAP_DRIVER_CONNECT > WM_USER"
7001
7002 check_type "dshow.h" IBaseFilter
7003
7004 # check for ioctl_meteor.h, ioctl_bt848.h and alternatives
7005 check_headers "dev/bktr/ioctl_meteor.h dev/bktr/ioctl_bt848.h"                   ||
7006     check_headers "machine/ioctl_meteor.h machine/ioctl_bt848.h"                 ||
7007     check_headers "dev/video/meteor/ioctl_meteor.h dev/video/bktr/ioctl_bt848.h" ||
7008     check_headers "dev/ic/bt8xx.h"
7009
7010 if check_struct sys/soundcard.h audio_buf_info bytes; then
7011     enable_sanitized sys/soundcard.h
7012 else
7013     test_cc -D__BSD_VISIBLE -D__XSI_VISIBLE <<EOF && add_cppflags -D__BSD_VISIBLE -D__XSI_VISIBLE && enable_sanitized sys/soundcard.h
7014     #include <sys/soundcard.h>
7015     audio_buf_info abc;
7016 EOF
7017 fi
7018
7019 enabled alsa && { check_pkg_config alsa alsa "alsa/asoundlib.h" snd_pcm_htimestamp ||
7020                   check_lib alsa alsa/asoundlib.h snd_pcm_htimestamp -lasound; }
7021
7022 enabled libjack &&
7023     require_pkg_config libjack jack jack/jack.h jack_port_get_latency_range
7024
7025 enabled sndio && check_pkg_config sndio sndio sndio.h sio_open
7026
7027 if enabled libcdio; then
7028     check_pkg_config libcdio libcdio_paranoia "cdio/cdda.h cdio/paranoia.h" cdio_cddap_open ||
7029     check_pkg_config libcdio libcdio_paranoia "cdio/paranoia/cdda.h cdio/paranoia/paranoia.h" cdio_cddap_open ||
7030     check_lib libcdio "cdio/cdda.h cdio/paranoia.h" cdio_cddap_open -lcdio_paranoia -lcdio_cdda -lcdio ||
7031     check_lib libcdio "cdio/paranoia/cdda.h cdio/paranoia/paranoia.h" cdio_cddap_open -lcdio_paranoia -lcdio_cdda -lcdio ||
7032     die "ERROR: No usable libcdio/cdparanoia found"
7033 fi
7034
7035 enabled libxcb && check_pkg_config libxcb "xcb >= 1.4" xcb/xcb.h xcb_connect ||
7036     disable libxcb_shm libxcb_shape libxcb_xfixes
7037
7038 if enabled libxcb; then
7039     enabled libxcb_shm    && check_pkg_config libxcb_shm    xcb-shm    xcb/shm.h    xcb_shm_attach
7040     enabled libxcb_shape  && check_pkg_config libxcb_shape  xcb-shape  xcb/shape.h  xcb_shape_get_rectangles
7041     enabled libxcb_xfixes && check_pkg_config libxcb_xfixes xcb-xfixes xcb/xfixes.h xcb_xfixes_get_cursor_image
7042 fi
7043
7044 check_func_headers "windows.h" CreateDIBSection "$gdigrab_indev_extralibs"
7045
7046 # d3d11va requires linking directly to dxgi and d3d11 if not building for
7047 # the desktop api partition
7048 test_cpp <<EOF && enable uwp && d3d11va_extralibs="-ldxgi -ld3d11"
7049 #ifdef WINAPI_FAMILY
7050 #include <winapifamily.h>
7051 #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
7052 #error desktop, not uwp
7053 #else
7054 // WINAPI_FAMILY_APP, WINAPI_FAMILY_PHONE_APP => UWP
7055 #endif
7056 #else
7057 #error no family set
7058 #endif
7059 EOF
7060
7061 # vaapi_win32 requires linking directly to dxgi if not building for
7062 # the desktop api partition
7063 test_cpp <<EOF && enable uwp && vaapi_win32_extralibs="-ldxgi"
7064 #ifdef WINAPI_FAMILY
7065 #include <winapifamily.h>
7066 #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
7067 #error desktop, not uwp
7068 #else
7069 // WINAPI_FAMILY_APP, WINAPI_FAMILY_PHONE_APP => UWP
7070 #endif
7071 #else
7072 #error no family set
7073 #endif
7074 EOF
7075
7076 # mediafoundation requires linking directly to mfplat if building for uwp target
7077 enabled uwp && mediafoundation_extralibs="-lmfplat -lmfuuid -lole32 -lstrmiids" || mediafoundation_extralibs="-lmfuuid -lole32 -lstrmiids"
7078
7079 enabled libdrm &&
7080     check_pkg_config libdrm_getfb2 libdrm "xf86drmMode.h" drmModeGetFB2
7081
7082 enabled vaapi &&
7083     check_pkg_config vaapi "libva >= 0.35.0" "va/va.h" vaInitialize
7084
7085 if enabled vaapi; then
7086     case $target_os in
7087         mingw32*|mingw64*|win32|win64)
7088             check_pkg_config vaapi_win32 "libva-win32" "va/va_win32.h" vaGetDisplayWin32
7089             ;;
7090         *)
7091             check_pkg_config vaapi_drm "libva-drm" "va/va_drm.h" vaGetDisplayDRM
7092             ;;
7093     esac
7094
7095     if enabled xlib_x11; then
7096         check_pkg_config vaapi_x11 "libva-x11" "va/va_x11.h" vaGetDisplay
7097     fi
7098
7099     check_cpp_condition vaapi_1 "va/va.h" "VA_CHECK_VERSION(1, 0, 0)"
7100
7101     check_type "va/va.h va/va_dec_hevc.h" "VAPictureParameterBufferHEVC"
7102     check_struct "va/va.h" "VADecPictureParameterBufferVP9" bit_depth
7103     check_struct "va/va.h" "VADecPictureParameterBufferAV1" bit_depth_idx
7104     check_type   "va/va.h va/va_vpp.h" "VAProcFilterParameterBufferHDRToneMapping"
7105     check_struct "va/va.h va/va_vpp.h" "VAProcPipelineCaps" rotation_flags
7106     check_struct "va/va.h va/va_vpp.h" "VAProcPipelineCaps" blend_flags
7107     check_type "va/va.h va/va_enc_hevc.h" "VAEncPictureParameterBufferHEVC"
7108     check_type "va/va.h va/va_enc_jpeg.h" "VAEncPictureParameterBufferJPEG"
7109     check_type "va/va.h va/va_enc_vp8.h"  "VAEncPictureParameterBufferVP8"
7110     check_type "va/va.h va/va_enc_vp9.h"  "VAEncPictureParameterBufferVP9"
7111     check_type "va/va.h va/va_enc_av1.h"  "VAEncPictureParameterBufferAV1"
7112 fi
7113
7114 if enabled_all opencl libdrm ; then
7115     check_type "CL/cl_intel.h" "clCreateImageFromFdINTEL_fn" &&
7116         enable opencl_drm_beignet
7117     check_func_headers "CL/cl_ext.h" clImportMemoryARM &&
7118         enable opencl_drm_arm
7119 fi
7120
7121 if enabled_all opencl vaapi ; then
7122     if enabled opencl_drm_beignet ; then
7123         enable opencl_vaapi_beignet
7124     else
7125         check_type "CL/cl.h CL/cl_va_api_media_sharing_intel.h" "clCreateFromVA_APIMediaSurfaceINTEL_fn" &&
7126             enable opencl_vaapi_intel_media
7127     fi
7128 fi
7129
7130 if enabled_all opencl dxva2 ; then
7131     check_type "CL/cl_dx9_media_sharing.h" cl_dx9_surface_info_khr &&
7132         enable opencl_dxva2
7133 fi
7134
7135 if enabled_all opencl d3d11va ; then
7136     check_type "CL/cl_d3d11.h" clGetDeviceIDsFromD3D11KHR_fn &&
7137         enable opencl_d3d11
7138 fi
7139
7140 enabled vdpau &&
7141     check_cpp_condition vdpau vdpau/vdpau.h "defined VDP_DECODER_PROFILE_MPEG4_PART2_ASP"
7142
7143 enabled vdpau &&
7144     check_lib vdpau_x11 "vdpau/vdpau.h vdpau/vdpau_x11.h" vdp_device_create_x11 -lvdpau -lX11
7145
7146 enabled crystalhd && check_lib crystalhd "stdint.h libcrystalhd/libcrystalhd_if.h" DtsCrystalHDVersion -lcrystalhd && \
7147     warn "CrystalHD support is deprecated and will be removed, please contact the developers if you are interested"   \
7148          "in maintaining it."
7149
7150 if enabled vulkan; then
7151     check_pkg_config_header_only vulkan "vulkan >= 1.3.255" "vulkan/vulkan.h" "defined VK_VERSION_1_3" ||
7152         check_cpp_condition vulkan "vulkan/vulkan.h" "defined(VK_VERSION_1_4) || (defined(VK_VERSION_1_3) && VK_HEADER_VERSION >= 255)"
7153 fi
7154
7155 if disabled vulkan; then
7156     disable libglslang libshaderc spirv_compiler
7157 fi
7158
7159 if enabled x86; then
7160     case $target_os in
7161         mingw32*|mingw64*|win32|win64|linux|cygwin*)
7162             ;;
7163         *)
7164             disable ffnvcodec cuvid nvdec nvenc
7165             ;;
7166     esac
7167 elif enabled_any aarch64 ppc64 && ! enabled bigendian; then
7168     case $target_os in
7169         linux)
7170             ;;
7171         *)
7172             disable ffnvcodec cuvid nvdec nvenc
7173             ;;
7174     esac
7175 else
7176     disable ffnvcodec cuvid nvdec nvenc
7177 fi
7178
7179 enabled ffnvcodec && enable cuda
7180
7181 enabled nvenc &&
7182     test_cc -I$source_path <<EOF || disable nvenc
7183 #include <ffnvcodec/nvEncodeAPI.h>
7184 NV_ENCODE_API_FUNCTION_LIST flist;
7185 void f(void) { struct { const GUID guid; } s[] = { { NV_ENC_CODEC_H264_GUID } }; }
7186 int main(void) { return 0; }
7187 EOF
7188
7189 if enabled nvenc; then
7190     check_type "ffnvcodec/nvEncodeAPI.h" "NV_ENC_PIC_PARAMS_AV1"
7191 fi
7192
7193 if enabled_any nvdec cuvid; then
7194     check_type "ffnvcodec/dynlink_cuda.h ffnvcodec/dynlink_cuviddec.h" "CUVIDAV1PICPARAMS"
7195 fi
7196
7197 enabled amf &&
7198     check_cpp_condition amf "AMF/core/Version.h" \
7199         "(AMF_VERSION_MAJOR << 48 | AMF_VERSION_MINOR << 32 | AMF_VERSION_RELEASE << 16 | AMF_VERSION_BUILD_NUM) >= 0x00010004001d0000"
7200
7201 # Funny iconv installations are not unusual, so check it after all flags have been set
7202 if enabled libc_iconv; then
7203     check_func_headers iconv.h iconv
7204 elif enabled iconv; then
7205     check_func_headers iconv.h iconv || check_lib iconv iconv.h iconv -liconv
7206 fi
7207
7208 enabled debug && add_cflags -g"$debuglevel" && add_asflags -g"$debuglevel"
7209
7210 # add some useful compiler flags if supported
7211 check_cflags -Wdeclaration-after-statement
7212 check_cflags -Wall
7213 check_cflags -Wdisabled-optimization
7214 check_cflags -Wpointer-arith
7215 check_cflags -Wredundant-decls
7216 check_cflags -Wwrite-strings
7217 check_cflags -Wtype-limits
7218 check_cflags -Wundef
7219 check_cflags -Wmissing-prototypes
7220 check_cflags -Wstrict-prototypes
7221 check_cflags -Wempty-body
7222
7223 if enabled extra_warnings; then
7224     check_cflags -Wcast-qual
7225     check_cflags -Wextra
7226     check_cflags -Wpedantic
7227 fi
7228
7229 check_disable_warning(){
7230     warning_flag=-W${1#-Wno-}
7231     test_cflags $unknown_warning_flags $warning_flag && add_cflags $1
7232 }
7233
7234 test_cflags -Werror=unused-command-line-argument &&
7235     append unknown_warning_flags "-Werror=unused-command-line-argument"
7236 test_cflags -Werror=unknown-warning-option &&
7237     append unknown_warning_flags "-Werror=unknown-warning-option"
7238
7239 check_disable_warning -Wno-parentheses
7240 check_disable_warning -Wno-switch
7241 check_disable_warning -Wno-format-zero-length
7242 check_disable_warning -Wno-pointer-sign
7243 check_disable_warning -Wno-unused-const-variable
7244 check_disable_warning -Wno-bool-operation
7245 check_disable_warning -Wno-char-subscripts
7246
7247 check_disable_warning_headers(){
7248     warning_flag=-W${1#-Wno-}
7249     test_cflags $warning_flag && add_cflags_headers $1
7250 }
7251
7252 check_disable_warning_headers -Wno-deprecated-declarations
7253 check_disable_warning_headers -Wno-unused-variable
7254
7255 test_cc <<EOF && enable blocks_extension
7256 void (^block)(void);
7257 EOF
7258
7259 # add some linker flags
7260 check_ldflags -Wl,--warn-common
7261 check_ldflags -Wl,-rpath-link=:libpostproc:libswresample:libswscale:libavfilter:libavdevice:libavformat:libavcodec:libavutil
7262 enabled rpath && add_ldexeflags -Wl,-rpath,$libdir && add_ldsoflags -Wl,-rpath,$libdir
7263 test_ldflags -Wl,-Bsymbolic && append SHFLAGS -Wl,-Bsymbolic
7264
7265 # add some strip flags
7266 check_stripflags -x
7267
7268 enabled neon_clobber_test &&
7269     check_ldflags -Wl,--wrap,avcodec_open2              \
7270                   -Wl,--wrap,avcodec_decode_subtitle2   \
7271                   -Wl,--wrap,avcodec_encode_subtitle    \
7272                   -Wl,--wrap,avcodec_send_packet        \
7273                   -Wl,--wrap,avcodec_receive_packet     \
7274                   -Wl,--wrap,avcodec_send_frame         \
7275                   -Wl,--wrap,avcodec_receive_frame      \
7276                   -Wl,--wrap,swr_convert        ||
7277     disable neon_clobber_test
7278
7279 enabled xmm_clobber_test &&
7280     check_ldflags -Wl,--wrap,avcodec_open2              \
7281                   -Wl,--wrap,avcodec_decode_subtitle2   \
7282                   -Wl,--wrap,avcodec_encode_subtitle    \
7283                   -Wl,--wrap,avcodec_send_packet        \
7284                   -Wl,--wrap,avcodec_receive_packet     \
7285                   -Wl,--wrap,avcodec_send_frame         \
7286                   -Wl,--wrap,avcodec_receive_frame      \
7287                   -Wl,--wrap,swr_convert                \
7288                   -Wl,--wrap,sws_scale ||
7289     disable xmm_clobber_test
7290
7291 check_ld "cc" proper_dce <<EOF
7292 extern const int array[512];
7293 static inline int func(void) { return array[0]; }
7294 int main(void) { return 0; }
7295 EOF
7296
7297 if enabled proper_dce; then
7298     echo "X { local: *; };" > $TMPV
7299     if test_ldflags -Wl,${version_script},$TMPV; then
7300         append SHFLAGS '-Wl,${version_script},\$(SUBDIR)lib\$(NAME).ver'
7301         quotes='""'
7302         test_cc <<EOF && enable symver_asm_label
7303 void ff_foo(void) __asm__ ("av_foo@VERSION");
7304 void ff_foo(void) { ${inline_asm+__asm__($quotes);} }
7305 EOF
7306         test_cc <<EOF && enable symver_gnu_asm
7307 __asm__(".symver ff_foo,av_foo@VERSION");
7308 void ff_foo(void) {}
7309 EOF
7310     fi
7311 fi
7312
7313 if [ -z "$optflags" ]; then
7314     if enabled small; then
7315         optflags=$cflags_size
7316     elif enabled optimizations; then
7317         optflags=$cflags_speed
7318     else
7319         optflags=$cflags_noopt
7320     fi
7321 fi
7322
7323 check_optflags(){
7324     check_cflags "$@"
7325     [ -n "$lto" ] && check_ldflags "$@"
7326 }
7327
7328 check_optflags $optflags
7329 check_optflags -fno-math-errno
7330 check_optflags -fno-signed-zeros
7331
7332 if [ -n "$lto" ]; then
7333     test "$cc_type" != "$ld_type" && die "LTO requires same compiler and linker"
7334     check_cflags  $lto
7335     check_ldflags $lto $cpuflags
7336     disable inline_asm_direct_symbol_refs
7337 fi
7338
7339 enabled ftrapv && check_cflags -ftrapv
7340
7341 test_cc -mno-red-zone <<EOF && noredzone_flags="-mno-red-zone"
7342 int x;
7343 EOF
7344
7345
7346 if enabled icc; then
7347     # Just warnings, no remarks
7348     check_cflags -w1
7349     # -wd: Disable following warnings
7350     # 144, 167, 556: -Wno-pointer-sign
7351     # 188: enumerated type mixed with another type
7352     # 1292: attribute "foo" ignored
7353     # 1419: external declaration in primary source file
7354     # 10006: ignoring unknown option -fno-signed-zeros
7355     # 10148: ignoring unknown option -Wno-parentheses
7356     # 10156: ignoring option '-W'; no argument required
7357     # 13200: No EMMS instruction before call to function
7358     # 13203: No EMMS instruction before return from function
7359     check_cflags -wd144,167,188,556,1292,1419,10006,10148,10156,13200,13203
7360     # 11030: Warning unknown option --as-needed
7361     # 10156: ignoring option '-export'; no argument required
7362     check_ldflags -wd10156,11030
7363     # icc 11.0 and 11.1 work with ebp_available, but don't pass the test
7364     enable ebp_available
7365     # The test above does not test linking
7366     [ -n "$lto" ] && disable symver_asm_label
7367     if enabled x86_32; then
7368         icc_version=$($cc -dumpversion)
7369         test ${icc_version%%.*} -ge 11 &&
7370             check_cflags -falign-stack=maintain-16-byte ||
7371             disable aligned_stack
7372     fi
7373 elif enabled gcc; then
7374     check_optflags -fno-tree-vectorize
7375     check_cflags -Werror=format-security
7376     check_cflags -Werror=implicit-function-declaration
7377     check_cflags -Werror=missing-prototypes
7378     check_cflags -Werror=return-type
7379     check_cflags -Werror=vla
7380     check_cflags -Wformat
7381     check_cflags -fdiagnostics-color=auto
7382     enabled extra_warnings || check_disable_warning -Wno-maybe-uninitialized
7383     if enabled x86_32; then
7384         case $target_os in
7385         *bsd*)
7386             # BSDs don't guarantee a 16 byte aligned stack, but we can
7387             # request GCC to try to maintain 16 byte alignment throughout
7388             # function calls. Library entry points that might call assembly
7389             # functions align the stack. (The parameter means 2^4 bytes.)
7390             check_cflags -mpreferred-stack-boundary=4
7391             ;;
7392         esac
7393     fi
7394 elif enabled llvm_gcc; then
7395     check_cflags -mllvm -stack-alignment=16
7396 elif enabled clang; then
7397     if enabled x86_32; then
7398         # Clang doesn't support maintaining alignment without assuming the
7399         # same alignment in every function. If 16 byte alignment would be
7400         # enabled, one would also have to either add attribute_align_arg on
7401         # every single entry point into the libraries or enable -mstackrealign
7402         # (doing stack realignment in every single function).
7403         case $target_os in
7404         mingw32|win32|*bsd*)
7405             disable aligned_stack
7406             ;;
7407         *)
7408             check_cflags -mllvm -stack-alignment=16
7409             check_cflags -mstack-alignment=16
7410             ;;
7411         esac
7412     else
7413         check_cflags -mllvm -stack-alignment=16
7414         check_cflags -mstack-alignment=16
7415     fi
7416     check_cflags -Qunused-arguments
7417     check_cflags -Werror=implicit-function-declaration
7418     check_cflags -Werror=missing-prototypes
7419     check_cflags -Werror=return-type
7420 elif enabled cparser; then
7421     add_cflags -Wno-missing-variable-declarations
7422     add_cflags -Wno-empty-statement
7423 elif enabled armcc; then
7424     add_cflags -W${armcc_opt},--diag_suppress=4343 # hardfp compat
7425     add_cflags -W${armcc_opt},--diag_suppress=3036 # using . as system include dir
7426     # 2523: use of inline assembly is deprecated
7427     add_cflags -W${armcc_opt},--diag_suppress=2523
7428     add_cflags -W${armcc_opt},--diag_suppress=1207
7429     add_cflags -W${armcc_opt},--diag_suppress=1293 # assignment in condition
7430     add_cflags -W${armcc_opt},--diag_suppress=3343 # hardfp compat
7431     add_cflags -W${armcc_opt},--diag_suppress=167  # pointer sign
7432     add_cflags -W${armcc_opt},--diag_suppress=513  # pointer sign
7433 elif enabled pathscale; then
7434     add_cflags -fstrict-overflow -OPT:wrap_around_unsafe_opt=OFF
7435     disable inline_asm
7436 elif enabled_any msvc icl; then
7437     enabled x86_32 && disable aligned_stack
7438     enabled_all x86_32 debug && add_cflags -Oy-
7439     enabled debug && add_ldflags -debug
7440     enable pragma_deprecated
7441     if enabled icl; then
7442         # -Qansi-alias is basically -fstrict-aliasing, but does not work
7443         # (correctly) on icl 13.x.
7444         test_cpp_condition "windows.h" "__ICL < 1300 || __ICL >= 1400" &&
7445             add_cflags -Qansi-alias
7446         # Some inline asm is not compilable in debug
7447         if enabled debug; then
7448             disable ebp_available
7449             disable ebx_available
7450         fi
7451     fi
7452     # msvcrt10 x64 incorrectly enables log2, only msvcrt12 (MSVC 2013) onwards actually has log2.
7453     check_cpp_condition log2 crtversion.h "_VC_CRT_MAJOR_VERSION >= 12"
7454     # The CRT headers contain __declspec(restrict) in a few places, but if redefining
7455     # restrict, this might break. MSVC 2010 and 2012 fail with __declspec(__restrict)
7456     # (as it ends up if the restrict redefine is done before including stdlib.h), while
7457     # MSVC 2013 and newer can handle it fine.
7458     # If this declspec fails, force including stdlib.h before the restrict redefinition
7459     # happens in config.h.
7460     if [ $restrict_keyword != restrict ]; then
7461         test_cc <<EOF || add_cflags -FIstdlib.h
7462 __declspec($restrict_keyword) void *foo(int);
7463 EOF
7464     fi
7465     # the new SSA optimzer in VS2015 U3 is mis-optimizing some parts of the code
7466     # Issue has been fixed in MSVC v19.00.24218.
7467     test_cpp_condition windows.h "_MSC_FULL_VER >= 190024218" ||
7468         check_cflags -d2SSAOptimizer-
7469     # enable utf-8 source processing on VS2015 U2 and newer
7470     test_cpp_condition windows.h "_MSC_FULL_VER >= 190023918" &&
7471         add_cflags -utf-8
7472 fi
7473
7474 for pfx in "" host_; do
7475     varname=${pfx%_}cc_type
7476     eval "type=\$$varname"
7477     if [ "$type" = "msvc" ]; then
7478         test_${pfx}cc <<EOF || add_${pfx}cflags -Dinline=__inline
7479 static inline int foo(int a) { return a; }
7480 EOF
7481     fi
7482 done
7483
7484 case $as_type in
7485     clang)
7486         add_asflags -Qunused-arguments
7487     ;;
7488 esac
7489
7490 case $ld_type in
7491     clang)
7492         check_ldflags -Qunused-arguments
7493     ;;
7494 esac
7495
7496 enable frame_thread_encoder
7497
7498 enabled asm || { arch=c; disable $ARCH_LIST $ARCH_EXT_LIST; }
7499
7500 check_deps $CONFIG_LIST       \
7501            $CONFIG_EXTRA      \
7502            $HAVE_LIST         \
7503            $ALL_COMPONENTS    \
7504
7505 enabled threads && ! enabled pthreads && ! enabled atomics_native && die "non pthread threading without atomics not supported, try adding --enable-pthreads or --cpu=i486 or higher if you are on x86"
7506
7507 case $target_os in
7508 haiku)
7509     disable memalign
7510     disable posix_memalign
7511     ;;
7512 *-dos|freedos|opendos)
7513     if test_cpp_condition sys/version.h "defined(__DJGPP__) && __DJGPP__ == 2 && __DJGPP_MINOR__ == 5"; then
7514         disable memalign
7515     fi
7516     ;;
7517 esac
7518
7519 flatten_extralibs(){
7520     nested_entries=
7521     list_name=$1
7522     eval list=\$${1}
7523     for entry in $list; do
7524         entry_copy=$entry
7525         resolve entry_copy
7526         flat_entries=
7527         for e in $entry_copy; do
7528             case $e in
7529                 *_extralibs) nested_entries="$nested_entries$e ";;
7530                           *) flat_entries="$flat_entries$e ";;
7531             esac
7532         done
7533         eval $entry="\$flat_entries"
7534     done
7535     append $list_name "$nested_entries"
7536
7537     resolve nested_entries
7538     if test -n "$(filter '*_extralibs' $nested_entries)"; then
7539         flatten_extralibs $list_name
7540     fi
7541 }
7542
7543 flatten_extralibs_wrapper(){
7544     list_name=$1
7545     flatten_extralibs $list_name
7546     unique $list_name
7547     resolve $list_name
7548     eval $list_name=\$\(\$ldflags_filter \$$list_name\)
7549     eval printf \''%s'\' \""\$$list_name"\"
7550 }
7551
7552 for linkunit in $LIBRARY_LIST; do
7553     unset current_extralibs
7554     eval components=\$$(toupper ${linkunit})_COMPONENTS_LIST
7555     for comp in ${components}; do
7556         enabled $comp || continue
7557         comp_extralibs="${comp}_extralibs"
7558         append current_extralibs $comp_extralibs
7559     done
7560     eval prepend ${linkunit}_extralibs $current_extralibs
7561 done
7562
7563 for linkunit in $LIBRARY_LIST $PROGRAM_LIST $EXTRALIBS_LIST; do
7564     eval ${linkunit}_extralibs=\$\(flatten_extralibs_wrapper ${linkunit}_extralibs\)
7565 done
7566
7567 map 'enabled $v && intrinsics=${v#intrinsics_}' $INTRINSICS_LIST
7568
7569 for thread in $THREADS_LIST; do
7570     if enabled $thread; then
7571         test -n "$thread_type" &&
7572             die "ERROR: Only one thread type must be selected." ||
7573             thread_type="$thread"
7574     fi
7575 done
7576
7577 if disabled stdatomic; then
7578     if enabled atomics_gcc; then
7579         add_cppflags '-I\$(SRC_PATH)/compat/atomics/gcc'
7580     elif enabled atomics_win32; then
7581         add_cppflags '-I\$(SRC_PATH)/compat/atomics/win32'
7582     elif enabled atomics_suncc; then
7583         add_cppflags '-I\$(SRC_PATH)/compat/atomics/suncc'
7584     elif enabled pthreads; then
7585         add_compat atomics/pthread/stdatomic.o
7586         add_cppflags '-I\$(SRC_PATH)/compat/atomics/pthread'
7587     else
7588         enabled threads && die "Threading is enabled, but no atomics are available"
7589         add_cppflags '-I\$(SRC_PATH)/compat/atomics/dummy'
7590     fi
7591 fi
7592
7593 # Check if requested libraries were found.
7594 for lib in $AUTODETECT_LIBS; do
7595     requested $lib && ! enabled $lib && die "ERROR: $lib requested but not found";
7596 done
7597
7598 enabled zlib && add_cppflags -DZLIB_CONST
7599
7600 # conditional library dependencies, in any order
7601 enabled amovie_filter       && prepend avfilter_deps "avformat avcodec"
7602 enabled aresample_filter    && prepend avfilter_deps "swresample"
7603 enabled cover_rect_filter   && prepend avfilter_deps "avformat avcodec"
7604 enabled ebur128_filter && enabled swresample && prepend avfilter_deps "swresample"
7605 enabled elbg_filter         && prepend avfilter_deps "avcodec"
7606 enabled find_rect_filter    && prepend avfilter_deps "avformat avcodec"
7607 enabled mcdeint_filter      && prepend avfilter_deps "avcodec"
7608 enabled movie_filter    && prepend avfilter_deps "avformat avcodec"
7609 enabled pan_filter          && prepend avfilter_deps "swresample"
7610 enabled pp_filter           && prepend avfilter_deps "postproc"
7611 enabled removelogo_filter   && prepend avfilter_deps "avformat avcodec swscale"
7612 enabled sab_filter          && prepend avfilter_deps "swscale"
7613 enabled scale_filter    && prepend avfilter_deps "swscale"
7614 enabled scale2ref_filter    && prepend avfilter_deps "swscale"
7615 enabled showcqt_filter      && prepend avfilter_deps "avformat swscale"
7616 enabled signature_filter    && prepend avfilter_deps "avcodec avformat"
7617 enabled smartblur_filter    && prepend avfilter_deps "swscale"
7618 enabled spp_filter          && prepend avfilter_deps "avcodec"
7619 enabled sr_filter           && prepend avfilter_deps "avformat swscale"
7620 enabled subtitles_filter    && prepend avfilter_deps "avformat avcodec"
7621 enabled uspp_filter         && prepend avfilter_deps "avcodec"
7622 enabled zoompan_filter      && prepend avfilter_deps "swscale"
7623
7624 enabled lavfi_indev         && prepend avdevice_deps "avfilter"
7625
7626 #FIXME
7627 enabled_any sdl2_outdev opengl_outdev && enabled sdl2 &&
7628     add_cflags $(filter_out '-Dmain=SDL_main' $sdl2_cflags)
7629
7630 enabled opus_decoder    && prepend avcodec_deps "swresample"
7631
7632 # reorder the items at var $1 to align with the items order at var $2 .
7633 # die if an item at $1 is not at $2 .
7634 reorder_by(){
7635     eval rb_in=\$$1
7636     eval rb_ordered=\$$2
7637
7638     for rb in $rb_in; do
7639         is_in $rb $rb_ordered || die "$rb at \$$1 is not at \$$2"
7640     done
7641
7642     rb_out=
7643     for rb in $rb_ordered; do
7644         is_in $rb $rb_in && rb_out="$rb_out$rb "
7645     done
7646     eval $1=\$rb_out
7647 }
7648
7649 # deps-expand fflib $1:  N x {append all expanded deps; unique}
7650 # within a set of N items, N expansions are enough to expose a cycle.
7651 expand_deps(){
7652     unique ${1}_deps  # required for the early break test.
7653     for dummy in $LIBRARY_LIST; do  # N iteratios
7654         eval deps=\$${1}_deps
7655         append ${1}_deps $(map 'eval echo \$${v}_deps' $deps)
7656         unique ${1}_deps
7657         eval '[ ${#deps} = ${#'${1}_deps'} ]' && break  # doesn't expand anymore
7658     done
7659
7660     eval is_in $1 \$${1}_deps && die "Dependency cycle at ${1}_deps"
7661     reorder_by ${1}_deps LIBRARY_LIST  # linking order is expected later
7662 }
7663
7664 #we have to remove gpl from the deps here as some code assumes all lib deps are libs
7665 postproc_deps="$(filter_out 'gpl' $postproc_deps)"
7666
7667 map 'expand_deps $v' $LIBRARY_LIST
7668
7669 if test "$quiet" != "yes"; then
7670
7671 echo "install prefix            $prefix"
7672 echo "source path               $source_path"
7673 echo "C compiler                $cc"
7674 echo "C library                 $libc_type"
7675 if test "$host_cc" != "$cc"; then
7676     echo "host C compiler           $host_cc"
7677     echo "host C library            $host_libc_type"
7678 fi
7679 echo "ARCH                      $arch ($cpu)"
7680 if test "$build_suffix" != ""; then
7681     echo "build suffix              $build_suffix"
7682 fi
7683 if test "$progs_suffix" != ""; then
7684     echo "progs suffix              $progs_suffix"
7685 fi
7686 if test "$extra_version" != ""; then
7687     echo "version string suffix     $extra_version"
7688 fi
7689 echo "big-endian                ${bigendian-no}"
7690 echo "runtime cpu detection     ${runtime_cpudetect-no}"
7691 if enabled x86; then
7692     echo "standalone assembly       ${x86asm-no}"
7693     echo "x86 assembler             ${x86asmexe}"
7694     echo "MMX enabled               ${mmx-no}"
7695     echo "MMXEXT enabled            ${mmxext-no}"
7696     echo "3DNow! enabled            ${amd3dnow-no}"
7697     echo "3DNow! extended enabled   ${amd3dnowext-no}"
7698     echo "SSE enabled               ${sse-no}"
7699     echo "SSSE3 enabled             ${ssse3-no}"
7700     echo "AESNI enabled             ${aesni-no}"
7701     echo "AVX enabled               ${avx-no}"
7702     echo "AVX2 enabled              ${avx2-no}"
7703     echo "AVX-512 enabled           ${avx512-no}"
7704     echo "AVX-512ICL enabled        ${avx512icl-no}"
7705     echo "XOP enabled               ${xop-no}"
7706     echo "FMA3 enabled              ${fma3-no}"
7707     echo "FMA4 enabled              ${fma4-no}"
7708     echo "i686 features enabled     ${i686-no}"
7709     echo "CMOV is fast              ${fast_cmov-no}"
7710     echo "EBX available             ${ebx_available-no}"
7711     echo "EBP available             ${ebp_available-no}"
7712 fi
7713 if enabled aarch64; then
7714     echo "NEON enabled              ${neon-no}"
7715     echo "DOTPROD enabled           ${dotprod-no}"
7716     echo "I8MM enabled              ${i8mm-no}"
7717 fi
7718 if enabled arm; then
7719     echo "ARMv5TE enabled           ${armv5te-no}"
7720     echo "ARMv6 enabled             ${armv6-no}"
7721     echo "ARMv6T2 enabled           ${armv6t2-no}"
7722     echo "VFP enabled               ${vfp-no}"
7723     echo "NEON enabled              ${neon-no}"
7724     echo "THUMB enabled             ${thumb-no}"
7725 fi
7726 if enabled mips; then
7727     echo "MIPS FPU enabled          ${mipsfpu-no}"
7728     echo "MIPS DSP R1 enabled       ${mipsdsp-no}"
7729     echo "MIPS DSP R2 enabled       ${mipsdspr2-no}"
7730     echo "MIPS MSA enabled          ${msa-no}"
7731     echo "LOONGSON MMI enabled      ${mmi-no}"
7732 fi
7733 if enabled ppc; then
7734     echo "AltiVec enabled           ${altivec-no}"
7735     echo "VSX enabled               ${vsx-no}"
7736     echo "POWER8 enabled            ${power8-no}"
7737     echo "PPC 4xx optimizations     ${ppc4xx-no}"
7738     echo "dcbzl available           ${dcbzl-no}"
7739 fi
7740 if enabled loongarch; then
7741     echo "LSX enabled               ${lsx-no}"
7742     echo "LASX enabled              ${lasx-no}"
7743 fi
7744 if enabled riscv; then
7745     echo "RISC-V Vector enabled     ${rvv-no}"
7746 fi
7747 echo "debug symbols             ${debug-no}"
7748 echo "strip symbols             ${stripping-no}"
7749 echo "optimize for size         ${small-no}"
7750 echo "optimizations             ${optimizations-no}"
7751 echo "static                    ${static-no}"
7752 echo "shared                    ${shared-no}"
7753 echo "postprocessing support    ${postproc-no}"
7754 echo "network support           ${network-no}"
7755 echo "threading support         ${thread_type-no}"
7756 echo "safe bitstream reader     ${safe_bitstream_reader-no}"
7757 echo "texi2html enabled         ${texi2html-no}"
7758 echo "perl enabled              ${perl-no}"
7759 echo "pod2man enabled           ${pod2man-no}"
7760 echo "makeinfo enabled          ${makeinfo-no}"
7761 echo "makeinfo supports HTML    ${makeinfo_html-no}"
7762 echo "xmllint enabled           ${xmllint-no}"
7763 test -n "$random_seed" &&
7764     echo "random seed               ${random_seed}"
7765 echo
7766
7767 echo "External libraries:"
7768 print_enabled '' $EXTERNAL_LIBRARY_LIST $EXTERNAL_AUTODETECT_LIBRARY_LIST | print_in_columns
7769 echo
7770
7771 echo "External libraries providing hardware acceleration:"
7772 print_enabled '' $HWACCEL_LIBRARY_LIST $HWACCEL_AUTODETECT_LIBRARY_LIST | print_in_columns
7773 echo
7774
7775 echo "Libraries:"
7776 print_enabled '' $LIBRARY_LIST | print_in_columns
7777 echo
7778
7779 echo "Programs:"
7780 print_enabled '' $PROGRAM_LIST | print_in_columns
7781 echo
7782
7783 for type in decoder encoder hwaccel parser demuxer muxer protocol filter bsf indev outdev; do
7784     echo "Enabled ${type}s:"
7785     eval list=\$$(toupper $type)_LIST
7786     print_enabled '_*' $list | print_in_columns
7787     echo
7788 done
7789
7790 if test -n "$ignore_tests"; then
7791     ignore_tests=$(echo $ignore_tests | tr ',' ' ')
7792     echo "Ignored FATE tests:"
7793     echo $ignore_tests | print_in_columns
7794     echo
7795 fi
7796
7797 echo "License: $license"
7798
7799 fi # test "$quiet" != "yes"
7800
7801 if test -n "$WARN_IF_GETS_DISABLED_LIST"; then
7802     for cfg in $WARN_IF_GETS_DISABLED_LIST; do
7803         if disabled $cfg; then
7804             varname=${cfg}_disable_reason
7805             eval "warn \"Disabled $cfg because \$$varname\""
7806         fi
7807     done
7808 fi
7809
7810 if test -n "$WARNINGS"; then
7811     printf "\n%s%s$WARNINGS%s" "$warn_color" "$bold_color" "$reset_color"
7812     enabled fatal_warnings && exit 1
7813 fi
7814
7815 test -e Makefile || echo "include $source_path/Makefile" > Makefile
7816
7817 esc(){
7818     echo "$*" | sed 's/%/%25/g;s/:/%3a/g'
7819 }
7820
7821 echo "config:$arch:$subarch:$cpu:$target_os:$(esc $cc_ident):$(esc $FFMPEG_CONFIGURATION)" > ffbuild/config.fate
7822
7823 enabled stripping || strip="echo skipping strip"
7824 enabled stripping || striptype=""
7825
7826 config_files="$TMPH ffbuild/config.mak doc/config.texi"
7827
7828 cat > ffbuild/config.mak <<EOF
7829 # Automatically generated by configure - do not modify!
7830 ifndef FFMPEG_CONFIG_MAK
7831 FFMPEG_CONFIG_MAK=1
7832 FFMPEG_CONFIGURATION=$FFMPEG_CONFIGURATION
7833 prefix=$prefix
7834 LIBDIR=\$(DESTDIR)$libdir
7835 SHLIBDIR=\$(DESTDIR)$shlibdir
7836 INCDIR=\$(DESTDIR)$incdir
7837 BINDIR=\$(DESTDIR)$bindir
7838 DATADIR=\$(DESTDIR)$datadir
7839 DOCDIR=\$(DESTDIR)$docdir
7840 MANDIR=\$(DESTDIR)$mandir
7841 PKGCONFIGDIR=\$(DESTDIR)$pkgconfigdir
7842 INSTALL_NAME_DIR=$install_name_dir
7843 SRC_PATH=$source_path
7844 SRC_LINK=$source_link
7845 ifndef MAIN_MAKEFILE
7846 SRC_PATH:=\$(SRC_PATH:.%=..%)
7847 endif
7848 CC_IDENT=$cc_ident
7849 ARCH=$arch
7850 INTRINSICS=$intrinsics
7851 EXTERN_PREFIX=$extern_prefix
7852 CC=$cc
7853 CXX=$cxx
7854 AS=$as
7855 OBJCC=$objcc
7856 LD=$ld
7857 DEPCC=$dep_cc
7858 DEPCCFLAGS=$DEPCCFLAGS \$(CPPFLAGS)
7859 DEPAS=$as
7860 DEPASFLAGS=$DEPASFLAGS \$(CPPFLAGS)
7861 X86ASM=$x86asmexe
7862 DEPX86ASM=$x86asmexe
7863 DEPX86ASMFLAGS=\$(X86ASMFLAGS)
7864 AR=$ar
7865 ARFLAGS=$arflags
7866 AR_O=$ar_o
7867 AR_CMD=$ar
7868 NM_CMD=$nm
7869 METALCC=$metalcc
7870 METALLIB=$metallib
7871 RANLIB=$ranlib
7872 STRIP=$strip
7873 STRIPTYPE=$striptype
7874 NVCC=$nvcc
7875 CP=cp -p
7876 LN_S=$ln_s
7877 CPPFLAGS=$CPPFLAGS
7878 CFLAGS=$CFLAGS
7879 CXXFLAGS=$CXXFLAGS
7880 OBJCCFLAGS=$OBJCFLAGS
7881 ASFLAGS=$ASFLAGS
7882 NVCCFLAGS=$nvccflags
7883 AS_C=$AS_C
7884 AS_O=$AS_O
7885 OBJCC_C=$OBJCC_C
7886 OBJCC_E=$OBJCC_E
7887 OBJCC_O=$OBJCC_O
7888 CC_C=$CC_C
7889 CC_E=$CC_E
7890 CC_O=$CC_O
7891 CXX_C=$CXX_C
7892 CXX_O=$CXX_O
7893 NVCC_C=$NVCC_C
7894 NVCC_O=$NVCC_O
7895 LD_O=$LD_O
7896 X86ASM_O=$X86ASM_O
7897 LD_LIB=$LD_LIB
7898 LD_PATH=$LD_PATH
7899 DLLTOOL=$dlltool
7900 WINDRES=$windres
7901 DOXYGEN=$doxygen
7902 LDFLAGS=$LDFLAGS
7903 LDEXEFLAGS=$LDEXEFLAGS
7904 LDSOFLAGS=$LDSOFLAGS
7905 SHFLAGS=$(echo $($ldflags_filter $SHFLAGS))
7906 ASMSTRIPFLAGS=$ASMSTRIPFLAGS
7907 X86ASMFLAGS=$X86ASMFLAGS
7908 MSAFLAGS=$MSAFLAGS
7909 MMIFLAGS=$MMIFLAGS
7910 LSXFLAGS=$LSXFLAGS
7911 LASXFLAGS=$LASXFLAGS
7912 BUILDSUF=$build_suffix
7913 PROGSSUF=$progs_suffix
7914 FULLNAME=$FULLNAME
7915 LIBPREF=$LIBPREF
7916 LIBSUF=$LIBSUF
7917 LIBNAME=$LIBNAME
7918 SLIBPREF=$SLIBPREF
7919 SLIBSUF=$SLIBSUF
7920 EXESUF=$EXESUF
7921 EXTRA_VERSION=$extra_version
7922 CCDEP=$CCDEP
7923 CXXDEP=$CXXDEP
7924 CCDEP_FLAGS=$CCDEP_FLAGS
7925 ASDEP=$ASDEP
7926 ASDEP_FLAGS=$ASDEP_FLAGS
7927 X86ASMDEP=$X86ASMDEP
7928 X86ASMDEP_FLAGS=$X86ASMDEP_FLAGS
7929 CC_DEPFLAGS=$CC_DEPFLAGS
7930 CXX_DEPFLAGS=$CXX_DEPFLAGS
7931 OBJCC_DEPFLAGS=$OBJC_DEPFLAGS
7932 AS_DEPFLAGS=$AS_DEPFLAGS
7933 X86ASM_DEPFLAGS=$X86ASM_DEPFLAGS
7934 HOSTCC=$host_cc
7935 HOSTLD=$host_ld
7936 HOSTCFLAGS=$host_cflags
7937 HOSTCPPFLAGS=$host_cppflags
7938 HOSTEXESUF=$HOSTEXESUF
7939 HOSTLDFLAGS=$host_ldflags
7940 HOSTEXTRALIBS=$host_extralibs
7941 DEPHOSTCC=$host_cc
7942 DEPHOSTCCFLAGS=$DEPHOSTCCFLAGS \$(HOSTCCFLAGS)
7943 HOSTCCDEP=$HOSTCCDEP
7944 HOSTCCDEP_FLAGS=$HOSTCCDEP_FLAGS
7945 HOSTCC_DEPFLAGS=$HOSTCC_DEPFLAGS
7946 HOSTCC_C=$HOSTCC_C
7947 HOSTCC_O=$HOSTCC_O
7948 HOSTLD_O=$HOSTLD_O
7949 TARGET_EXEC=$target_exec $target_exec_args
7950 TARGET_PATH=$target_path
7951 TARGET_SAMPLES=${target_samples:-\$(SAMPLES)}
7952 CFLAGS-ffplay=${sdl2_cflags}
7953 CFLAGS_HEADERS=$CFLAGS_HEADERS
7954 LIB_INSTALL_EXTRA_CMD=$LIB_INSTALL_EXTRA_CMD
7955 EXTRALIBS=$extralibs
7956 COMPAT_OBJS=$compat_objs
7957 INSTALL=$install
7958 LIBTARGET=${LIBTARGET}
7959 SLIBNAME=${SLIBNAME}
7960 SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}
7961 SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}
7962 SLIB_CREATE_DEF_CMD=${SLIB_CREATE_DEF_CMD}
7963 SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}
7964 SLIB_INSTALL_NAME=${SLIB_INSTALL_NAME}
7965 SLIB_INSTALL_LINKS=${SLIB_INSTALL_LINKS}
7966 SLIB_INSTALL_EXTRA_LIB=${SLIB_INSTALL_EXTRA_LIB}
7967 SLIB_INSTALL_EXTRA_SHLIB=${SLIB_INSTALL_EXTRA_SHLIB}
7968 VERSION_SCRIPT_POSTPROCESS_CMD=${VERSION_SCRIPT_POSTPROCESS_CMD}
7969 SAMPLES:=${samples:-\$(FATE_SAMPLES)}
7970 NOREDZONE_FLAGS=$noredzone_flags
7971 LIBFUZZER_PATH=$libfuzzer_path
7972 IGNORE_TESTS=$ignore_tests
7973 EOF
7974
7975 map 'eval echo "${v}_FFLIBS=\$${v}_deps" >> ffbuild/config.mak' $LIBRARY_LIST
7976
7977 for entry in $LIBRARY_LIST $PROGRAM_LIST $EXTRALIBS_LIST; do
7978     eval echo "EXTRALIBS-${entry}=\$${entry}_extralibs" >> ffbuild/config.mak
7979 done
7980
7981 cat > $TMPH <<EOF
7982 /* Automatically generated by configure - do not modify! */
7983 #ifndef FFMPEG_CONFIG_H
7984 #define FFMPEG_CONFIG_H
7985 #define FFMPEG_CONFIGURATION "$(c_escape $FFMPEG_CONFIGURATION)"
7986 #define FFMPEG_LICENSE "$(c_escape $license)"
7987 #define CONFIG_THIS_YEAR 2023
7988 #define FFMPEG_DATADIR "$(eval c_escape $datadir)"
7989 #define AVCONV_DATADIR "$(eval c_escape $datadir)"
7990 #define CC_IDENT "$(c_escape ${cc_ident:-Unknown compiler})"
7991 #define OS_NAME $target_os
7992 #define av_restrict $restrict_keyword
7993 #define EXTERN_PREFIX "${extern_prefix}"
7994 #define EXTERN_ASM ${extern_prefix}
7995 #define BUILDSUF "$build_suffix"
7996 #define SLIBSUF "$SLIBSUF"
7997 #define HAVE_MMX2 HAVE_MMXEXT
7998 #define SWS_MAX_FILTER_SIZE $sws_max_filter_size
7999 EOF
8000
8001 test -n "$assert_level" &&
8002     echo "#define ASSERT_LEVEL $assert_level" >>$TMPH
8003
8004 test -n "$malloc_prefix" &&
8005     echo "#define MALLOC_PREFIX $malloc_prefix" >>$TMPH
8006
8007 enabled aarch64 &&
8008     echo "#define AS_ARCH_LEVEL $as_arch_level" >>$TMPH
8009
8010 if enabled x86asm; then
8011     append config_files $TMPASM
8012     cat > $TMPASM <<EOF
8013 ; Automatically generated by configure - do not modify!
8014 EOF
8015 fi
8016
8017 enabled getenv || echo "#define getenv(x) NULL" >> $TMPH
8018
8019
8020 mkdir -p doc
8021 mkdir -p tests
8022 mkdir -p tests/api
8023 echo "@c auto-generated by configure - do not modify! " > doc/config.texi
8024
8025 print_config ARCH_   "$config_files" $ARCH_LIST
8026 print_config HAVE_   "$config_files" $HAVE_LIST
8027 print_config CONFIG_ "$config_files" $CONFIG_LIST       \
8028                                      $CONFIG_EXTRA      \
8029
8030 echo "#endif /* FFMPEG_CONFIG_H */" >> $TMPH
8031
8032 # Do not overwrite an unchanged config.h to avoid superfluous rebuilds.
8033 cp_if_changed $TMPH config.h
8034 touch ffbuild/.config
8035
8036 # Copy config.asm before printing ALL_COMPONENTS; that's not needed in assembly.
8037 enabled x86asm && cp_if_changed $TMPASM config.asm
8038
8039 # Reopen a new TMPH for config_components.h.
8040 cat > $TMPH <<EOF
8041 /* Automatically generated by configure - do not modify! */
8042 #ifndef FFMPEG_CONFIG_COMPONENTS_H
8043 #define FFMPEG_CONFIG_COMPONENTS_H
8044 EOF
8045
8046 print_config CONFIG_ "$config_files" $ALL_COMPONENTS
8047
8048 echo "#endif /* FFMPEG_CONFIG_COMPONENTS_H */" >> $TMPH
8049 echo "endif # FFMPEG_CONFIG_MAK" >> ffbuild/config.mak
8050
8051 cp_if_changed $TMPH config_components.h
8052
8053 cat > $TMPH <<EOF
8054 /* Generated by ffmpeg configure */
8055 #ifndef AVUTIL_AVCONFIG_H
8056 #define AVUTIL_AVCONFIG_H
8057 EOF
8058
8059 print_config AV_HAVE_ $TMPH $HAVE_LIST_PUB
8060
8061 echo "#endif /* AVUTIL_AVCONFIG_H */" >> $TMPH
8062
8063 cp_if_changed $TMPH libavutil/avconfig.h
8064
8065 # full_filter_name_foo=vf_foo
8066 # full_filter_name_bar=asrc_bar
8067 # ...
8068 eval "$(sed -n "s/^extern const AVFilter ff_\([avfsinkrc]\{2,5\}\)_\(.*\);/full_filter_name_\2=\1_\2/p" $source_path/libavfilter/allfilters.c)"
8069
8070 # generate the lists of enabled components
8071 print_enabled_components(){
8072     file=$1
8073     struct_name=$2
8074     name=$3
8075     shift 3
8076     echo "static const $struct_name * const $name[] = {" > $TMPH
8077     for c in $*; do
8078         if enabled $c; then
8079             case $name in
8080                 filter_list)
8081                     eval c=\$full_filter_name_${c%_filter}
8082                 ;;
8083                 indev_list)
8084                     c=${c%_indev}_demuxer
8085                 ;;
8086                 outdev_list)
8087                     c=${c%_outdev}_muxer
8088                 ;;
8089             esac
8090             printf "    &ff_%s,\n" $c >> $TMPH
8091         fi
8092     done
8093     if [ "$name" = "filter_list" ]; then
8094         for c in asrc_abuffer vsrc_buffer asink_abuffer vsink_buffer; do
8095             printf "    &ff_%s,\n" $c >> $TMPH
8096         done
8097     fi
8098     echo "    NULL };" >> $TMPH
8099     cp_if_changed $TMPH $file
8100 }
8101
8102 print_enabled_components libavfilter/filter_list.c AVFilter filter_list $FILTER_LIST
8103 print_enabled_components libavcodec/codec_list.c FFCodec codec_list $CODEC_LIST
8104 print_enabled_components libavcodec/parser_list.c AVCodecParser parser_list $PARSER_LIST
8105 print_enabled_components libavcodec/bsf_list.c FFBitStreamFilter bitstream_filters $BSF_LIST
8106 print_enabled_components libavformat/demuxer_list.c AVInputFormat demuxer_list $DEMUXER_LIST
8107 print_enabled_components libavformat/muxer_list.c FFOutputFormat muxer_list $MUXER_LIST
8108 print_enabled_components libavdevice/indev_list.c AVInputFormat indev_list $INDEV_LIST
8109 print_enabled_components libavdevice/outdev_list.c FFOutputFormat outdev_list $OUTDEV_LIST
8110 print_enabled_components libavformat/protocol_list.c URLProtocol url_protocols $PROTOCOL_LIST
8111
8112 # Settings for pkg-config files
8113
8114 cat > $TMPH <<EOF
8115 # Automatically generated by configure - do not modify!
8116 shared=$shared
8117 build_suffix=$build_suffix
8118 prefix=$prefix
8119 libdir=$libdir
8120 incdir=$incdir
8121 rpath=$(enabled rpath && echo "-Wl,-rpath,\${libdir}")
8122 source_path=${source_path}
8123 LIBPREF=${LIBPREF}
8124 LIBSUF=${LIBSUF}
8125 extralibs_avutil="$avutil_extralibs"
8126 extralibs_avcodec="$avcodec_extralibs"
8127 extralibs_avformat="$avformat_extralibs"
8128 extralibs_avdevice="$avdevice_extralibs"
8129 extralibs_avfilter="$avfilter_extralibs"
8130 extralibs_postproc="$postproc_extralibs"
8131 extralibs_swscale="$swscale_extralibs"
8132 extralibs_swresample="$swresample_extralibs"
8133 EOF
8134
8135 for lib in $LIBRARY_LIST; do
8136     lib_deps="$(eval echo \$${lib}_deps)"
8137     echo ${lib}_deps=\"$lib_deps\" >> $TMPH
8138 done
8139
8140 cp_if_changed $TMPH ffbuild/config.sh