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