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