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