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