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