]> git.sesse.net Git - ffmpeg/blob - configure
Merge commit 'a7e6fbd90e62d3320b1e26d8209fc0f55ee5b0be'
[ffmpeg] / 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-libtheora       enable Theora encoding via libtheora [no]
250   --enable-libtwolame      enable MP2 encoding via libtwolame [no]
251   --enable-libutvideo      enable Ut Video encoding and decoding via libutvideo [no]
252   --enable-libv4l2         enable libv4l2/v4l-utils [no]
253   --enable-libvidstab      enable video stabilization using vid.stab [no]
254   --enable-libvo-aacenc    enable AAC encoding via libvo-aacenc [no]
255   --enable-libvo-amrwbenc  enable AMR-WB encoding via libvo-amrwbenc [no]
256   --enable-libvorbis       enable Vorbis en/decoding via libvorbis,
257                            native implementation exists [no]
258   --enable-libvpx          enable VP8 and VP9 de/encoding via libvpx [no]
259   --enable-libwavpack      enable wavpack encoding via libwavpack [no]
260   --enable-libwebp         enable WebP encoding via libwebp [no]
261   --enable-libx264         enable H.264 encoding via x264 [no]
262   --enable-libx265         enable HEVC encoding via x265 [no]
263   --enable-libxavs         enable AVS encoding via xavs [no]
264   --enable-libxcb          enable X11 grabbing using XCB [autodetect]
265   --enable-libxcb-shm      enable X11 grabbing shm communication [autodetect]
266   --enable-libxcb-xfixes   enable X11 grabbing mouse rendering [autodetect]
267   --enable-libxcb-shape    enable X11 grabbing shape rendering [autodetect]
268   --enable-libxvid         enable Xvid encoding via xvidcore,
269                            native MPEG-4/Xvid encoder exists [no]
270   --enable-libzmq          enable message passing via libzmq [no]
271   --enable-libzvbi         enable teletext support via libzvbi [no]
272   --disable-lzma           disable lzma [autodetect]
273   --enable-decklink        enable Blackmagick DeckLink I/O support [no]
274   --enable-mmal            enable decoding via MMAL [no]
275   --enable-nvenc           enable NVIDIA NVENC support [no]
276   --enable-openal          enable OpenAL 1.1 capture support [no]
277   --enable-opencl          enable OpenCL code
278   --enable-opengl          enable OpenGL rendering [no]
279   --enable-openssl         enable openssl, needed for https support
280                            if gnutls is not used [no]
281   --disable-sdl            disable sdl [autodetect]
282   --disable-securetransport disable Secure Transport, needed for TLS support
283                            on OSX if openssl and gnutls are not used [autodetect]
284   --enable-x11grab         enable X11 grabbing (legacy) [no]
285   --disable-xlib           disable xlib [autodetect]
286   --disable-zlib           disable zlib [autodetect]
287
288 Toolchain options:
289   --arch=ARCH              select architecture [$arch]
290   --cpu=CPU                select the minimum required CPU (affects
291                            instruction selection, may crash on older CPUs)
292   --cross-prefix=PREFIX    use PREFIX for compilation tools [$cross_prefix]
293   --progs-suffix=SUFFIX    program name suffix []
294   --enable-cross-compile   assume a cross-compiler is used
295   --sysroot=PATH           root of cross-build tree
296   --sysinclude=PATH        location of cross-build system headers
297   --target-os=OS           compiler targets OS [$target_os]
298   --target-exec=CMD        command to run executables on target
299   --target-path=DIR        path to view of build directory on target
300   --target-samples=DIR     path to samples directory on target
301   --tempprefix=PATH        force fixed dir/prefix instead of mktemp for checks
302   --toolchain=NAME         set tool defaults according to NAME
303   --nm=NM                  use nm tool NM [$nm_default]
304   --ar=AR                  use archive tool AR [$ar_default]
305   --as=AS                  use assembler AS [$as_default]
306   --windres=WINDRES        use windows resource compiler WINDRES [$windres_default]
307   --yasmexe=EXE            use yasm-compatible assembler EXE [$yasmexe_default]
308   --cc=CC                  use C compiler CC [$cc_default]
309   --cxx=CXX                use C compiler CXX [$cxx_default]
310   --dep-cc=DEPCC           use dependency generator DEPCC [$cc_default]
311   --ld=LD                  use linker LD [$ld_default]
312   --pkg-config=PKGCONFIG   use pkg-config tool PKGCONFIG [$pkg_config_default]
313   --pkg-config-flags=FLAGS pass additional flags to pkgconf []
314   --ranlib=RANLIB          use ranlib RANLIB [$ranlib_default]
315   --doxygen=DOXYGEN        use DOXYGEN to generate API doc [$doxygen_default]
316   --host-cc=HOSTCC         use host C compiler HOSTCC
317   --host-cflags=HCFLAGS    use HCFLAGS when compiling for host
318   --host-cppflags=HCPPFLAGS use HCPPFLAGS when compiling for host
319   --host-ld=HOSTLD         use host linker HOSTLD
320   --host-ldflags=HLDFLAGS  use HLDFLAGS when linking for host
321   --host-libs=HLIBS        use libs HLIBS when linking for host
322   --host-os=OS             compiler host OS [$target_os]
323   --extra-cflags=ECFLAGS   add ECFLAGS to CFLAGS [$CFLAGS]
324   --extra-cxxflags=ECFLAGS add ECFLAGS to CXXFLAGS [$CXXFLAGS]
325   --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]
326   --extra-ldexeflags=ELDFLAGS add ELDFLAGS to LDEXEFLAGS [$LDEXEFLAGS]
327   --extra-ldlibflags=ELDFLAGS add ELDFLAGS to LDLIBFLAGS [$LDLIBFLAGS]
328   --extra-libs=ELIBS       add ELIBS [$ELIBS]
329   --extra-version=STRING   version string suffix []
330   --optflags=OPTFLAGS      override optimization-related compiler flags
331   --build-suffix=SUFFIX    library name suffix []
332   --enable-pic             build position-independent code
333   --enable-thumb           compile for Thumb instruction set
334   --enable-lto             use link-time optimization
335   --env="ENV=override"     override the environment variables
336
337 Advanced options (experts only):
338   --malloc-prefix=PREFIX   prefix malloc and related names with PREFIX
339   --disable-symver         disable symbol versioning
340   --enable-hardcoded-tables use hardcoded tables instead of runtime generation
341   --disable-safe-bitstream-reader
342                            disable buffer boundary checking in bitreaders
343                            (faster, but may crash)
344   --enable-memalign-hack   emulate memalign, interferes with memory debuggers
345   --sws-max-filter-size=N  the max filter size swscale uses [$sws_max_filter_size_default]
346
347 Optimization options (experts only):
348   --disable-asm            disable all assembly optimizations
349   --disable-altivec        disable AltiVec optimizations
350   --disable-vsx            disable VSX optimizations
351   --disable-power8         disable POWER8 optimizations
352   --disable-amd3dnow       disable 3DNow! optimizations
353   --disable-amd3dnowext    disable 3DNow! extended optimizations
354   --disable-mmx            disable MMX optimizations
355   --disable-mmxext         disable MMXEXT optimizations
356   --disable-sse            disable SSE optimizations
357   --disable-sse2           disable SSE2 optimizations
358   --disable-sse3           disable SSE3 optimizations
359   --disable-ssse3          disable SSSE3 optimizations
360   --disable-sse4           disable SSE4 optimizations
361   --disable-sse42          disable SSE4.2 optimizations
362   --disable-avx            disable AVX optimizations
363   --disable-xop            disable XOP optimizations
364   --disable-fma3           disable FMA3 optimizations
365   --disable-fma4           disable FMA4 optimizations
366   --disable-avx2           disable AVX2 optimizations
367   --disable-armv5te        disable armv5te optimizations
368   --disable-armv6          disable armv6 optimizations
369   --disable-armv6t2        disable armv6t2 optimizations
370   --disable-vfp            disable VFP optimizations
371   --disable-neon           disable NEON optimizations
372   --disable-inline-asm     disable use of inline assembly
373   --disable-yasm           disable use of nasm/yasm assembly
374   --disable-mips32r5       disable MIPS32R5 optimizations
375   --disable-mips64r6       disable MIPS64R6 optimizations
376   --disable-mipsdspr1      disable MIPS DSP ASE R1 optimizations
377   --disable-mipsdspr2      disable MIPS DSP ASE R2 optimizations
378   --disable-msa            disable MSA optimizations
379   --disable-mipsfpu        disable floating point MIPS optimizations
380   --disable-mmi            disable Loongson SIMD optimizations
381   --disable-fast-unaligned consider unaligned accesses slow
382
383 Developer options (useful when working on FFmpeg itself):
384   --disable-debug          disable debugging symbols
385   --enable-debug=LEVEL     set the debug level [$debuglevel]
386   --disable-optimizations  disable compiler optimizations
387   --enable-extra-warnings  enable more compiler warnings
388   --disable-stripping      disable stripping of executables and shared libraries
389   --assert-level=level     0(default), 1 or 2, amount of assertion testing,
390                            2 causes a slowdown at runtime.
391   --enable-memory-poisoning fill heap uninitialized allocated space with arbitrary data
392   --valgrind=VALGRIND      run "make fate" tests through valgrind to detect memory
393                            leaks and errors, using the specified valgrind binary.
394                            Cannot be combined with --target-exec
395   --enable-ftrapv          Trap arithmetic overflows
396   --samples=PATH           location of test samples for FATE, if not set use
397                            \$FATE_SAMPLES at make invocation time.
398   --enable-neon-clobber-test check NEON registers for clobbering (should be
399                            used only for debugging purposes)
400   --enable-xmm-clobber-test check XMM registers for clobbering (Win64-only;
401                            should be used only for debugging purposes)
402   --enable-random          randomly enable/disable components
403   --disable-random
404   --enable-random=LIST     randomly enable/disable specific components or
405   --disable-random=LIST    component groups. LIST is a comma-separated list
406                            of NAME[:PROB] entries where NAME is a component
407                            (group) and PROB the probability associated with
408                            NAME (default 0.5).
409   --random-seed=VALUE      seed value for --enable/disable-random
410   --disable-valgrind-backtrace do not print a backtrace under Valgrind
411                            (only applies to --disable-optimizations builds)
412
413 NOTE: Object files are built at the place where configure is launched.
414 EOF
415   exit 0
416 }
417
418 quotes='""'
419 if test -t 1 && which tput >/dev/null; then
420     ncolors=$(tput colors)
421     if test -n "$ncolors" && test $ncolors -ge 8; then
422         bold_color=$(tput bold)
423         warn_color=$(tput setaf 3)
424         reset_color=$(tput sgr0)
425     fi
426 fi
427
428 log(){
429     echo "$@" >> $logfile
430 }
431
432 log_file(){
433     log BEGIN $1
434     pr -n -t $1 >> $logfile
435     log END $1
436 }
437
438 echolog(){
439     log "$@"
440     echo "$@"
441 }
442
443 warn(){
444     log "WARNING: $*"
445     WARNINGS="${WARNINGS}WARNING: $*\n"
446 }
447
448 die(){
449     echolog "$@"
450     cat <<EOF
451
452 If you think configure made a mistake, make sure you are using the latest
453 version from Git.  If the latest version fails, report the problem to the
454 ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net.
455 EOF
456     if disabled logging; then
457         cat <<EOF
458 Rerun configure with logging enabled (do not use --disable-logging), and
459 include the log this produces with your report.
460 EOF
461     else
462         cat <<EOF
463 Include the log file "$logfile" produced by configure as this will help
464 solve the problem.
465 EOF
466     fi
467     exit 1
468 }
469
470 # Avoid locale weirdness, besides we really just want to translate ASCII.
471 toupper(){
472     echo "$@" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
473 }
474
475 tolower(){
476     echo "$@" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
477 }
478
479 c_escape(){
480     echo "$*" | sed 's/["\\]/\\\0/g'
481 }
482
483 sh_quote(){
484     v=$(echo "$1" | sed "s/'/'\\\\''/g")
485     test "x$v" = "x${v#*[!A-Za-z0-9_/.+-]}" || v="'$v'"
486     echo "$v"
487 }
488
489 cleanws(){
490     echo "$@" | sed 's/^ *//;s/[[:space:]][[:space:]]*/ /g;s/ *$//'
491 }
492
493 filter(){
494     pat=$1
495     shift
496     for v; do
497         eval "case $v in $pat) echo $v ;; esac"
498     done
499 }
500
501 filter_out(){
502     pat=$1
503     shift
504     for v; do
505         eval "case $v in $pat) ;; *) echo $v ;; esac"
506     done
507 }
508
509 map(){
510     m=$1
511     shift
512     for v; do eval $m; done
513 }
514
515 add_suffix(){
516     suffix=$1
517     shift
518     for v; do echo ${v}${suffix}; done
519 }
520
521 set_all(){
522     value=$1
523     shift
524     for var in $*; do
525         eval $var=$value
526     done
527 }
528
529 set_weak(){
530     value=$1
531     shift
532     for var; do
533         eval : \${$var:=$value}
534     done
535 }
536
537 sanitize_var_name(){
538     echo $@ | sed 's/[^A-Za-z0-9_]/_/g'
539 }
540
541 set_safe(){
542     var=$1
543     shift
544     eval $(sanitize_var_name "$var")='$*'
545 }
546
547 get_safe(){
548     eval echo \$$(sanitize_var_name "$1")
549 }
550
551 pushvar(){
552     for pvar in $*; do
553         eval level=\${${pvar}_level:=0}
554         eval ${pvar}_${level}="\$$pvar"
555         eval ${pvar}_level=$(($level+1))
556     done
557 }
558
559 popvar(){
560     for pvar in $*; do
561         eval level=\${${pvar}_level:-0}
562         test $level = 0 && continue
563         eval level=$(($level-1))
564         eval $pvar="\${${pvar}_${level}}"
565         eval ${pvar}_level=$level
566         eval unset ${pvar}_${level}
567     done
568 }
569
570 enable(){
571     set_all yes $*
572 }
573
574 disable(){
575     set_all no $*
576 }
577
578 enable_weak(){
579     set_weak yes $*
580 }
581
582 disable_weak(){
583     set_weak no $*
584 }
585
586 enable_safe(){
587     for var; do
588         enable $(echo "$var" | sed 's/[^A-Za-z0-9_]/_/g')
589     done
590 }
591
592 disable_safe(){
593     for var; do
594         disable $(echo "$var" | sed 's/[^A-Za-z0-9_]/_/g')
595     done
596 }
597
598 do_enable_deep(){
599     for var; do
600         enabled $var && continue
601         eval sel="\$${var}_select"
602         eval sgs="\$${var}_suggest"
603         pushvar var sgs
604         enable_deep $sel
605         popvar sgs
606         enable_deep_weak $sgs
607         popvar var
608     done
609 }
610
611 enable_deep(){
612     do_enable_deep $*
613     enable $*
614 }
615
616 enable_deep_weak(){
617     for var; do
618         disabled $var && continue
619         pushvar var
620         do_enable_deep $var
621         popvar var
622         enable_weak $var
623     done
624 }
625
626 enabled(){
627     test "${1#!}" = "$1" && op== || op=!=
628     eval test "x\$${1#!}" $op "xyes"
629 }
630
631 disabled(){
632     test "${1#!}" = "$1" && op== || op=!=
633     eval test "x\$${1#!}" $op "xno"
634 }
635
636 enabled_all(){
637     for opt; do
638         enabled $opt || return 1
639     done
640 }
641
642 disabled_all(){
643     for opt; do
644         disabled $opt || return 1
645     done
646 }
647
648 enabled_any(){
649     for opt; do
650         enabled $opt && return 0
651     done
652 }
653
654 disabled_any(){
655     for opt; do
656         disabled $opt && return 0
657     done
658     return 1
659 }
660
661 set_default(){
662     for opt; do
663         eval : \${$opt:=\$${opt}_default}
664     done
665 }
666
667 is_in(){
668     value=$1
669     shift
670     for var in $*; do
671         [ $var = $value ] && return 0
672     done
673     return 1
674 }
675
676 do_check_deps(){
677     for cfg; do
678         cfg="${cfg#!}"
679         enabled ${cfg}_checking && die "Circular dependency for $cfg."
680         disabled ${cfg}_checking && continue
681         enable ${cfg}_checking
682         append allopts $cfg
683
684         eval dep_all="\$${cfg}_deps"
685         eval dep_any="\$${cfg}_deps_any"
686         eval dep_sel="\$${cfg}_select"
687         eval dep_sgs="\$${cfg}_suggest"
688         eval dep_ifa="\$${cfg}_if"
689         eval dep_ifn="\$${cfg}_if_any"
690
691         pushvar cfg dep_all dep_any dep_sel dep_sgs dep_ifa dep_ifn
692         do_check_deps $dep_all $dep_any $dep_sel $dep_sgs $dep_ifa $dep_ifn
693         popvar cfg dep_all dep_any dep_sel dep_sgs dep_ifa dep_ifn
694
695         [ -n "$dep_ifa" ] && { enabled_all $dep_ifa && enable_weak $cfg; }
696         [ -n "$dep_ifn" ] && { enabled_any $dep_ifn && enable_weak $cfg; }
697         enabled_all  $dep_all || disable $cfg
698         enabled_any  $dep_any || disable $cfg
699         disabled_any $dep_sel && disable $cfg
700
701         if enabled $cfg; then
702             enable_deep $dep_sel
703             enable_deep_weak $dep_sgs
704         fi
705
706         disable ${cfg}_checking
707     done
708 }
709
710 check_deps(){
711     unset allopts
712
713     do_check_deps "$@"
714
715     for cfg in $allopts; do
716         enabled $cfg || continue
717         eval dep_extralibs="\$${cfg}_extralibs"
718         test -n "$dep_extralibs" && add_extralibs $dep_extralibs
719     done
720 }
721
722 print_config(){
723     pfx=$1
724     files=$2
725     shift 2
726     map 'eval echo "$v \${$v:-no}"' "$@" |
727     awk "BEGIN { split(\"$files\", files) }
728         {
729             c = \"$pfx\" toupper(\$1);
730             v = \$2;
731             sub(/yes/, 1, v);
732             sub(/no/,  0, v);
733             for (f in files) {
734                 file = files[f];
735                 if (file ~ /\\.h\$/) {
736                     printf(\"#define %s %d\\n\", c, v) >>file;
737                 } else if (file ~ /\\.asm\$/) {
738                     printf(\"%%define %s %d\\n\", c, v) >>file;
739                 } else if (file ~ /\\.mak\$/) {
740                     n = -v ? \"\" : \"!\";
741                     printf(\"%s%s=yes\\n\", n, c) >>file;
742                 } else if (file ~ /\\.texi\$/) {
743                     pre = -v ? \"\" : \"@c \";
744                     yesno = \$2;
745                     c2 = tolower(c);
746                     gsub(/_/, \"-\", c2);
747                     printf(\"%s@set %s %s\\n\", pre, c2, yesno) >>file;
748                 }
749             }
750         }"
751 }
752
753 print_enabled(){
754     suf=$1
755     shift
756     for v; do
757         enabled $v && printf "%s\n" ${v%$suf};
758     done
759 }
760
761 append(){
762     var=$1
763     shift
764     eval "$var=\"\$$var $*\""
765 }
766
767 prepend(){
768     var=$1
769     shift
770     eval "$var=\"$* \$$var\""
771 }
772
773 unique(){
774     var=$1
775     uniq_list=""
776     for tok in $(eval echo \$$var); do
777         uniq_list="$(filter_out $tok $uniq_list) $tok"
778     done
779     eval "$var=\"${uniq_list}\""
780 }
781
782 add_cppflags(){
783     append CPPFLAGS "$@"
784 }
785
786 add_cflags(){
787     append CFLAGS $($cflags_filter "$@")
788 }
789
790 add_cxxflags(){
791     append CXXFLAGS $($cflags_filter "$@")
792 }
793
794 add_asflags(){
795     append ASFLAGS $($asflags_filter "$@")
796 }
797
798 add_ldflags(){
799     append LDFLAGS $($ldflags_filter "$@")
800 }
801
802 add_ldexeflags(){
803     append LDEXEFLAGS $($ldflags_filter "$@")
804 }
805
806 add_ldlibflags(){
807     append LDLIBFLAGS $($ldflags_filter "$@")
808 }
809
810 add_stripflags(){
811     append ASMSTRIPFLAGS "$@"
812 }
813
814 add_extralibs(){
815     prepend extralibs $($ldflags_filter "$@")
816 }
817
818 add_host_cppflags(){
819     append host_cppflags "$@"
820 }
821
822 add_host_cflags(){
823     append host_cflags $($host_cflags_filter "$@")
824 }
825
826 add_host_ldflags(){
827     append host_ldflags $($host_ldflags_filter "$@")
828 }
829
830 add_compat(){
831     append compat_objs $1
832     shift
833     map 'add_cppflags -D$v' "$@"
834 }
835
836 check_cmd(){
837     log "$@"
838     "$@" >> $logfile 2>&1
839 }
840
841 check_stat(){
842     log check_stat "$@"
843     stat "$1" >> $logfile 2>&1
844 }
845
846 cc_o(){
847     eval printf '%s\\n' $CC_O
848 }
849
850 cc_e(){
851     eval printf '%s\\n' $CC_E
852 }
853
854 check_cc(){
855     log check_cc "$@"
856     cat > $TMPC
857     log_file $TMPC
858     check_cmd $cc $CPPFLAGS $CFLAGS "$@" $CC_C $(cc_o $TMPO) $TMPC
859 }
860
861 check_cxx(){
862     log check_cxx "$@"
863     cat > $TMPCPP
864     log_file $TMPCPP
865     check_cmd $cxx $CPPFLAGS $CFLAGS $CXXFLAGS "$@" $CXX_C -o $TMPO $TMPCPP
866 }
867
868 check_oc(){
869     log check_oc "$@"
870     cat > $TMPM
871     log_file $TMPM
872     check_cmd $cc -Werror=missing-prototypes $CPPFLAGS $CFLAGS "$@" $CC_C $(cc_o $TMPO) $TMPM
873 }
874
875 check_cpp(){
876     log check_cpp "$@"
877     cat > $TMPC
878     log_file $TMPC
879     check_cmd $cc $CPPFLAGS $CFLAGS "$@" $(cc_e $TMPO) $TMPC
880 }
881
882 as_o(){
883     eval printf '%s\\n' $AS_O
884 }
885
886 check_as(){
887     log check_as "$@"
888     cat > $TMPS
889     log_file $TMPS
890     check_cmd $as $CPPFLAGS $ASFLAGS "$@" $AS_C $(as_o $TMPO) $TMPS
891 }
892
893 check_inline_asm(){
894     log check_inline_asm "$@"
895     name="$1"
896     code="$2"
897     shift 2
898     disable $name
899     check_cc "$@" <<EOF && enable $name
900 void foo(void){ __asm__ volatile($code); }
901 EOF
902 }
903
904 check_insn(){
905     log check_insn "$@"
906     check_inline_asm ${1}_inline "\"$2\""
907     echo "$2" | check_as && enable ${1}_external || disable ${1}_external
908 }
909
910 check_yasm(){
911     log check_yasm "$@"
912     echo "$1" > $TMPS
913     log_file $TMPS
914     shift 1
915     check_cmd $yasmexe $YASMFLAGS -Werror "$@" -o $TMPO $TMPS
916 }
917
918 ld_o(){
919     eval printf '%s\\n' $LD_O
920 }
921
922 check_ld(){
923     log check_ld "$@"
924     type=$1
925     shift 1
926     flags=$(filter_out '-l*|*.so' $@)
927     libs=$(filter '-l*|*.so' $@)
928     check_$type $($cflags_filter $flags) || return
929     flags=$($ldflags_filter $flags)
930     libs=$($ldflags_filter $libs)
931     check_cmd $ld $LDFLAGS $flags $(ld_o $TMPE) $TMPO $libs $extralibs
932 }
933
934 print_include(){
935     hdr=$1
936     test "${hdr%.h}" = "${hdr}" &&
937         echo "#include $hdr"    ||
938         echo "#include <$hdr>"
939 }
940
941 check_code(){
942     log check_code "$@"
943     check=$1
944     headers=$2
945     code=$3
946     shift 3
947     {
948         for hdr in $headers; do
949             print_include $hdr
950         done
951         echo "int main(void) { $code; return 0; }"
952     } | check_$check "$@"
953 }
954
955 check_cppflags(){
956     log check_cppflags "$@"
957     check_cc "$@" <<EOF && append CPPFLAGS "$@"
958 int x;
959 EOF
960 }
961
962 test_cflags(){
963     log test_cflags "$@"
964     set -- $($cflags_filter "$@")
965     check_cc "$@" <<EOF
966 int x;
967 EOF
968 }
969
970 check_cflags(){
971     log check_cflags "$@"
972     test_cflags "$@" && add_cflags "$@"
973 }
974
975 check_cxxflags(){
976     log check_cxxflags "$@"
977     set -- $($cflags_filter "$@")
978     check_cxx "$@" <<EOF && append CXXFLAGS "$@"
979 int x;
980 EOF
981 }
982
983 test_ldflags(){
984     log test_ldflags "$@"
985     check_ld "cc" "$@" <<EOF
986 int main(void){ return 0; }
987 EOF
988 }
989
990 check_ldflags(){
991     log check_ldflags "$@"
992     test_ldflags "$@" && add_ldflags "$@"
993 }
994
995 test_stripflags(){
996     log test_stripflags "$@"
997     # call check_cc to get a fresh TMPO
998     check_cc <<EOF
999 int main(void) { return 0; }
1000 EOF
1001     check_cmd $strip $ASMSTRIPFLAGS "$@" $TMPO
1002 }
1003
1004 check_stripflags(){
1005     log check_stripflags "$@"
1006     test_stripflags "$@" && add_stripflags "$@"
1007 }
1008
1009 check_header(){
1010     log check_header "$@"
1011     header=$1
1012     shift
1013     disable_safe $header
1014     check_cpp "$@" <<EOF && enable_safe $header
1015 #include <$header>
1016 int x;
1017 EOF
1018 }
1019
1020 check_header_oc(){
1021     log check_header_oc "$@"
1022     rm -f -- "$TMPO"
1023     header=$1
1024     shift
1025     disable_safe $header
1026     {
1027        echo "#include <$header>"
1028        echo "int main(void) { return 0; }"
1029     } | check_oc && check_stat "$TMPO" && enable_safe $headers
1030 }
1031
1032 check_func(){
1033     log check_func "$@"
1034     func=$1
1035     shift
1036     disable $func
1037     check_ld "cc" "$@" <<EOF && enable $func
1038 extern int $func();
1039 int main(void){ $func(); }
1040 EOF
1041 }
1042
1043 check_mathfunc(){
1044     log check_mathfunc "$@"
1045     func=$1
1046     narg=$2
1047     shift 2
1048     test $narg = 2 && args="f, g" || args="f"
1049     disable $func
1050     check_ld "cc" "$@" <<EOF && enable $func
1051 #include <math.h>
1052 float foo(float f, float g) { return $func($args); }
1053 int main(void){ return (int) foo; }
1054 EOF
1055 }
1056
1057 check_func_headers(){
1058     log check_func_headers "$@"
1059     headers=$1
1060     funcs=$2
1061     shift 2
1062     {
1063         for hdr in $headers; do
1064             print_include $hdr
1065         done
1066         for func in $funcs; do
1067             echo "long check_$func(void) { return (long) $func; }"
1068         done
1069         echo "int main(void) { return 0; }"
1070     } | check_ld "cc" "$@" && enable $funcs && enable_safe $headers
1071 }
1072
1073 check_class_headers_cpp(){
1074     log check_class_headers_cpp "$@"
1075     headers=$1
1076     classes=$2
1077     shift 2
1078     {
1079         for hdr in $headers; do
1080             echo "#include <$hdr>"
1081         done
1082         echo "int main(void) { "
1083         i=1
1084         for class in $classes; do
1085             echo "$class obj$i;"
1086             i=$(expr $i + 1)
1087         done
1088         echo "return 0; }"
1089     } | check_ld "cxx" "$@" && enable $funcs && enable_safe $headers
1090 }
1091
1092 check_cpp_condition(){
1093     log check_cpp_condition "$@"
1094     header=$1
1095     condition=$2
1096     shift 2
1097     check_cpp "$@" <<EOF
1098 #include <$header>
1099 #if !($condition)
1100 #error "unsatisfied condition: $condition"
1101 #endif
1102 EOF
1103 }
1104
1105 check_lib(){
1106     log check_lib "$@"
1107     header="$1"
1108     func="$2"
1109     shift 2
1110     check_header $header && check_func $func "$@" && add_extralibs "$@"
1111 }
1112
1113 check_lib2(){
1114     log check_lib2 "$@"
1115     headers="$1"
1116     funcs="$2"
1117     shift 2
1118     check_func_headers "$headers" "$funcs" "$@" && add_extralibs "$@"
1119 }
1120
1121 check_lib_cpp(){
1122     log check_lib_cpp "$@"
1123     headers="$1"
1124     classes="$2"
1125     shift 2
1126     check_class_headers_cpp "$headers" "$classes" "$@" && add_extralibs "$@"
1127 }
1128
1129 check_pkg_config(){
1130     log check_pkg_config "$@"
1131     pkgandversion="$1"
1132     pkg="${1%% *}"
1133     headers="$2"
1134     funcs="$3"
1135     shift 3
1136     check_cmd $pkg_config --exists --print-errors $pkgandversion || return
1137     pkg_cflags=$($pkg_config --cflags $pkg_config_flags $pkg)
1138     pkg_libs=$($pkg_config --libs $pkg_config_flags $pkg)
1139     check_func_headers "$headers" "$funcs" $pkg_cflags $pkg_libs "$@" &&
1140         set_safe "${pkg}_cflags" $pkg_cflags   &&
1141         set_safe "${pkg}_libs"   $pkg_libs
1142 }
1143
1144 check_exec(){
1145     check_ld "cc" "$@" && { enabled cross_compile || $TMPE >> $logfile 2>&1; }
1146 }
1147
1148 check_exec_crash(){
1149     code=$(cat)
1150
1151     # exit() is not async signal safe.  _Exit (C99) and _exit (POSIX)
1152     # are safe but may not be available everywhere.  Thus we use
1153     # raise(SIGTERM) instead.  The check is run in a subshell so we
1154     # can redirect the "Terminated" message from the shell.  SIGBUS
1155     # is not defined by standard C so it is used conditionally.
1156
1157     (check_exec "$@") >> $logfile 2>&1 <<EOF
1158 #include <signal.h>
1159 static void sighandler(int sig){
1160     raise(SIGTERM);
1161 }
1162 int foo(void){
1163     $code
1164 }
1165 int (*func_ptr)(void) = foo;
1166 int main(void){
1167     signal(SIGILL, sighandler);
1168     signal(SIGFPE, sighandler);
1169     signal(SIGSEGV, sighandler);
1170 #ifdef SIGBUS
1171     signal(SIGBUS, sighandler);
1172 #endif
1173     return func_ptr();
1174 }
1175 EOF
1176 }
1177
1178 check_type(){
1179     log check_type "$@"
1180     headers=$1
1181     type=$2
1182     shift 2
1183     disable_safe "$type"
1184     check_code cc "$headers" "$type v" "$@" && enable_safe "$type"
1185 }
1186
1187 check_struct(){
1188     log check_struct "$@"
1189     headers=$1
1190     struct=$2
1191     member=$3
1192     shift 3
1193     disable_safe "${struct}_${member}"
1194     check_code cc "$headers" "const void *p = &(($struct *)0)->$member" "$@" &&
1195         enable_safe "${struct}_${member}"
1196 }
1197
1198 check_builtin(){
1199     log check_builtin "$@"
1200     name=$1
1201     headers=$2
1202     builtin=$3
1203     shift 3
1204     disable "$name"
1205     check_code ld "$headers" "$builtin" "cc" "$@" && enable "$name"
1206 }
1207
1208 check_compile_assert(){
1209     log check_compile_assert "$@"
1210     name=$1
1211     headers=$2
1212     condition=$3
1213     shift 3
1214     disable "$name"
1215     check_code cc "$headers" "char c[2 * !!($condition) - 1]" "$@" && enable "$name"
1216 }
1217
1218 require(){
1219     name="$1"
1220     header="$2"
1221     func="$3"
1222     shift 3
1223     check_lib $header $func "$@" || die "ERROR: $name not found"
1224 }
1225
1226 require2(){
1227     name="$1"
1228     headers="$2"
1229     func="$3"
1230     shift 3
1231     check_lib2 "$headers" $func "$@" || die "ERROR: $name not found"
1232 }
1233
1234 require_cpp(){
1235     name="$1"
1236     headers="$2"
1237     classes="$3"
1238     shift 3
1239     check_lib_cpp "$headers" "$classes" "$@" || die "ERROR: $name not found"
1240 }
1241
1242 use_pkg_config(){
1243     pkg="$1"
1244     check_pkg_config "$@" || return 1
1245     add_cflags    $(get_safe "${pkg}_cflags")
1246     add_extralibs $(get_safe "${pkg}_libs")
1247 }
1248
1249 require_pkg_config(){
1250     use_pkg_config "$@" || die "ERROR: $pkg not found using pkg-config$pkg_config_fail_message"
1251 }
1252
1253 require_libfreetype(){
1254     log require_libfreetype "$@"
1255     pkg="freetype2"
1256     check_cmd $pkg_config --exists --print-errors $pkg \
1257       || die "ERROR: $pkg not found"
1258     pkg_cflags=$($pkg_config --cflags $pkg_config_flags $pkg)
1259     pkg_libs=$($pkg_config --libs $pkg_config_flags $pkg)
1260     {
1261         echo "#include <ft2build.h>"
1262         echo "#include FT_FREETYPE_H"
1263         echo "long check_func(void) { return (long) FT_Init_FreeType; }"
1264         echo "int main(void) { return 0; }"
1265     } | check_ld "cc" $pkg_cflags $pkg_libs \
1266       && set_safe "${pkg}_cflags" $pkg_cflags \
1267       && set_safe "${pkg}_libs"   $pkg_libs \
1268       || die "ERROR: $pkg not found"
1269     add_cflags    $(get_safe "${pkg}_cflags")
1270     add_extralibs $(get_safe "${pkg}_libs")
1271 }
1272
1273 hostcc_e(){
1274     eval printf '%s\\n' $HOSTCC_E
1275 }
1276
1277 hostcc_o(){
1278     eval printf '%s\\n' $HOSTCC_O
1279 }
1280
1281 check_host_cc(){
1282     log check_host_cc "$@"
1283     cat > $TMPC
1284     log_file $TMPC
1285     check_cmd $host_cc $host_cflags "$@" $HOSTCC_C $(hostcc_o $TMPO) $TMPC
1286 }
1287
1288 check_host_cpp(){
1289     log check_host_cpp "$@"
1290     cat > $TMPC
1291     log_file $TMPC
1292     check_cmd $host_cc $host_cppflags $host_cflags "$@" $(hostcc_e $TMPO) $TMPC
1293 }
1294
1295 check_host_cppflags(){
1296     log check_host_cppflags "$@"
1297     check_host_cc "$@" <<EOF && append host_cppflags "$@"
1298 int x;
1299 EOF
1300 }
1301
1302 check_host_cflags(){
1303     log check_host_cflags "$@"
1304     set -- $($host_cflags_filter "$@")
1305     check_host_cc "$@" <<EOF && append host_cflags "$@"
1306 int x;
1307 EOF
1308 }
1309
1310 check_host_cpp_condition(){
1311     log check_host_cpp_condition "$@"
1312     header=$1
1313     condition=$2
1314     shift 2
1315     check_host_cpp "$@" <<EOF
1316 #include <$header>
1317 #if !($condition)
1318 #error "unsatisfied condition: $condition"
1319 #endif
1320 EOF
1321 }
1322
1323 cp_if_changed(){
1324     cmp -s "$1" "$2" && echo "$2 is unchanged" && return
1325     mkdir -p "$(dirname $2)"
1326     $cp_f "$1" "$2"
1327 }
1328
1329 # CONFIG_LIST contains configurable options, while HAVE_LIST is for
1330 # system-dependent things.
1331
1332 COMPONENT_LIST="
1333     bsfs
1334     decoders
1335     demuxers
1336     encoders
1337     filters
1338     hwaccels
1339     indevs
1340     muxers
1341     outdevs
1342     parsers
1343     protocols
1344 "
1345
1346 EXAMPLE_LIST="
1347     avio_reading_example
1348     avio_dir_cmd_example
1349     decoding_encoding_example
1350     demuxing_decoding_example
1351     extract_mvs_example
1352     filter_audio_example
1353     filtering_audio_example
1354     filtering_video_example
1355     metadata_example
1356     muxing_example
1357     qsvdec_example
1358     remuxing_example
1359     resampling_audio_example
1360     scaling_video_example
1361     transcode_aac_example
1362     transcoding_example
1363 "
1364
1365 EXTERNAL_LIBRARY_LIST="
1366     avisynth
1367     bzlib
1368     crystalhd
1369     decklink
1370     frei0r
1371     gnutls
1372     iconv
1373     ladspa
1374     libaacplus
1375     libass
1376     libbluray
1377     libbs2b
1378     libcaca
1379     libcdio
1380     libcelt
1381     libdc1394
1382     libdcadec
1383     libfaac
1384     libfdk_aac
1385     libflite
1386     libfontconfig
1387     libfreetype
1388     libfribidi
1389     libgme
1390     libgsm
1391     libiec61883
1392     libilbc
1393     libkvazaar
1394     libmfx
1395     libmodplug
1396     libmp3lame
1397     libnut
1398     libopencore_amrnb
1399     libopencore_amrwb
1400     libopencv
1401     libopenh264
1402     libopenjpeg
1403     libopus
1404     libpulse
1405     libquvi
1406     librtmp
1407     libschroedinger
1408     libshine
1409     libsmbclient
1410     libsnappy
1411     libsoxr
1412     libspeex
1413     libssh
1414     libstagefright_h264
1415     libtheora
1416     libtwolame
1417     libutvideo
1418     libv4l2
1419     libvidstab
1420     libvo_aacenc
1421     libvo_amrwbenc
1422     libvorbis
1423     libvpx
1424     libwavpack
1425     libwebp
1426     libx264
1427     libx265
1428     libxavs
1429     libxcb
1430     libxcb_shm
1431     libxcb_shape
1432     libxcb_xfixes
1433     libxvid
1434     libzmq
1435     libzvbi
1436     lzma
1437     mmal
1438     nvenc
1439     openal
1440     opencl
1441     opengl
1442     openssl
1443     sdl
1444     securetransport
1445     x11grab
1446     xlib
1447     zlib
1448 "
1449
1450 DOCUMENT_LIST="
1451     doc
1452     htmlpages
1453     manpages
1454     podpages
1455     txtpages
1456 "
1457
1458 FEATURE_LIST="
1459     ftrapv
1460     gray
1461     hardcoded_tables
1462     runtime_cpudetect
1463     safe_bitstream_reader
1464     shared
1465     small
1466     static
1467     swscale_alpha
1468 "
1469
1470 HWACCEL_LIST="
1471     d3d11va
1472     dxva2
1473     vaapi
1474     vda
1475     vdpau
1476     videotoolbox
1477     xvmc
1478 "
1479
1480 LIBRARY_LIST="
1481     avcodec
1482     avdevice
1483     avfilter
1484     avformat
1485     avresample
1486     avutil
1487     postproc
1488     swresample
1489     swscale
1490 "
1491
1492 LICENSE_LIST="
1493     gpl
1494     nonfree
1495     version3
1496 "
1497
1498 PROGRAM_LIST="
1499     ffplay
1500     ffprobe
1501     ffserver
1502     ffmpeg
1503 "
1504
1505 SUBSYSTEM_LIST="
1506     dct
1507     dwt
1508     error_resilience
1509     faan
1510     fast_unaligned
1511     fft
1512     lsp
1513     lzo
1514     mdct
1515     pixelutils
1516     network
1517     rdft
1518 "
1519
1520 CONFIG_LIST="
1521     $COMPONENT_LIST
1522     $DOCUMENT_LIST
1523     $EXAMPLE_LIST
1524     $EXTERNAL_LIBRARY_LIST
1525     $FEATURE_LIST
1526     $HWACCEL_LIST
1527     $LICENSE_LIST
1528     $LIBRARY_LIST
1529     $PROGRAM_LIST
1530     $SUBSYSTEM_LIST
1531     fontconfig
1532     incompatible_libav_abi
1533     memalign_hack
1534     memory_poisoning
1535     neon_clobber_test
1536     pic
1537     pod2man
1538     raise_major
1539     thumb
1540     valgrind_backtrace
1541     xmm_clobber_test
1542 "
1543
1544 THREADS_LIST="
1545     pthreads
1546     os2threads
1547     w32threads
1548 "
1549
1550 ATOMICS_LIST="
1551     atomics_gcc
1552     atomics_suncc
1553     atomics_win32
1554 "
1555
1556 ARCH_LIST="
1557     aarch64
1558     alpha
1559     arm
1560     avr32
1561     avr32_ap
1562     avr32_uc
1563     bfin
1564     ia64
1565     m68k
1566     mips
1567     mips64
1568     parisc
1569     ppc
1570     ppc64
1571     s390
1572     sh4
1573     sparc
1574     sparc64
1575     tilegx
1576     tilepro
1577     tomi
1578     x86
1579     x86_32
1580     x86_64
1581 "
1582
1583 ARCH_EXT_LIST_ARM="
1584     armv5te
1585     armv6
1586     armv6t2
1587     armv8
1588     neon
1589     vfp
1590     vfpv3
1591     setend
1592 "
1593
1594 ARCH_EXT_LIST_MIPS="
1595     mipsfpu
1596     mips32r2
1597     mips32r5
1598     mips64r6
1599     mipsdspr1
1600     mipsdspr2
1601     msa
1602 "
1603
1604 ARCH_EXT_LIST_LOONGSON="
1605     loongson2
1606     loongson3
1607     mmi
1608 "
1609
1610 ARCH_EXT_LIST_X86_SIMD="
1611     amd3dnow
1612     amd3dnowext
1613     avx
1614     avx2
1615     fma3
1616     fma4
1617     mmx
1618     mmxext
1619     sse
1620     sse2
1621     sse3
1622     sse4
1623     sse42
1624     ssse3
1625     xop
1626 "
1627
1628 ARCH_EXT_LIST_PPC="
1629     altivec
1630     dcbzl
1631     ldbrx
1632     power8
1633     ppc4xx
1634     vsx
1635 "
1636
1637 ARCH_EXT_LIST_X86="
1638     $ARCH_EXT_LIST_X86_SIMD
1639     cpunop
1640     i686
1641 "
1642
1643 ARCH_EXT_LIST="
1644     $ARCH_EXT_LIST_ARM
1645     $ARCH_EXT_LIST_PPC
1646     $ARCH_EXT_LIST_X86
1647     $ARCH_EXT_LIST_MIPS
1648     $ARCH_EXT_LIST_LOONGSON
1649 "
1650
1651 ARCH_FEATURES="
1652     aligned_stack
1653     fast_64bit
1654     fast_clz
1655     fast_cmov
1656     local_aligned_8
1657     local_aligned_16
1658     local_aligned_32
1659     simd_align_16
1660 "
1661
1662 BUILTIN_LIST="
1663     atomic_cas_ptr
1664     atomic_compare_exchange
1665     machine_rw_barrier
1666     MemoryBarrier
1667     mm_empty
1668     rdtsc
1669     sarestart
1670     sync_val_compare_and_swap
1671 "
1672 HAVE_LIST_CMDLINE="
1673     inline_asm
1674     symver
1675     yasm
1676 "
1677
1678 HAVE_LIST_PUB="
1679     bigendian
1680     fast_unaligned
1681     incompatible_libav_abi
1682 "
1683
1684 HEADERS_LIST="
1685     alsa_asoundlib_h
1686     altivec_h
1687     arpa_inet_h
1688     asm_types_h
1689     cdio_paranoia_h
1690     cdio_paranoia_paranoia_h
1691     dev_bktr_ioctl_bt848_h
1692     dev_bktr_ioctl_meteor_h
1693     dev_ic_bt8xx_h
1694     dev_video_bktr_ioctl_bt848_h
1695     dev_video_meteor_ioctl_meteor_h
1696     direct_h
1697     dirent_h
1698     dlfcn_h
1699     d3d11_h
1700     dxva_h
1701     ES2_gl_h
1702     gsm_h
1703     io_h
1704     mach_mach_time_h
1705     machine_ioctl_bt848_h
1706     machine_ioctl_meteor_h
1707     malloc_h
1708     openjpeg_1_5_openjpeg_h
1709     OpenGL_gl3_h
1710     poll_h
1711     sndio_h
1712     soundcard_h
1713     sys_mman_h
1714     sys_param_h
1715     sys_resource_h
1716     sys_select_h
1717     sys_soundcard_h
1718     sys_time_h
1719     sys_un_h
1720     sys_videoio_h
1721     termios_h
1722     udplite_h
1723     unistd_h
1724     valgrind_valgrind_h
1725     windows_h
1726     winsock2_h
1727 "
1728
1729 INTRINSICS_LIST="
1730     intrinsics_neon
1731 "
1732
1733 MATH_FUNCS="
1734     atanf
1735     atan2f
1736     cbrt
1737     cbrtf
1738     copysign
1739     cosf
1740     erf
1741     exp2
1742     exp2f
1743     expf
1744     isinf
1745     isnan
1746     ldexpf
1747     llrint
1748     llrintf
1749     log2
1750     log2f
1751     log10f
1752     lrint
1753     lrintf
1754     powf
1755     rint
1756     round
1757     roundf
1758     sinf
1759     trunc
1760     truncf
1761 "
1762
1763 SYSTEM_FUNCS="
1764     access
1765     aligned_malloc
1766     clock_gettime
1767     closesocket
1768     CommandLineToArgvW
1769     CoTaskMemFree
1770     CryptGenRandom
1771     dlopen
1772     fcntl
1773     flt_lim
1774     fork
1775     getaddrinfo
1776     gethrtime
1777     getopt
1778     GetProcessAffinityMask
1779     GetProcessMemoryInfo
1780     GetProcessTimes
1781     getrusage
1782     getservbyport
1783     GetSystemTimeAsFileTime
1784     gettimeofday
1785     glob
1786     glXGetProcAddress
1787     gmtime_r
1788     inet_aton
1789     isatty
1790     jack_port_get_latency_range
1791     kbhit
1792     localtime_r
1793     lstat
1794     lzo1x_999_compress
1795     mach_absolute_time
1796     MapViewOfFile
1797     memalign
1798     mkstemp
1799     mmap
1800     mprotect
1801     nanosleep
1802     PeekNamedPipe
1803     posix_memalign
1804     pthread_cancel
1805     sched_getaffinity
1806     SetConsoleTextAttribute
1807     SetConsoleCtrlHandler
1808     setmode
1809     setrlimit
1810     Sleep
1811     strerror_r
1812     sysconf
1813     sysctl
1814     usleep
1815     VirtualAlloc
1816     wglGetProcAddress
1817 "
1818
1819 TOOLCHAIN_FEATURES="
1820     as_dn_directive
1821     as_func
1822     as_object_arch
1823     asm_mod_q
1824     attribute_may_alias
1825     attribute_packed
1826     ebp_available
1827     ebx_available
1828     gnu_as
1829     gnu_windres
1830     ibm_asm
1831     inline_asm_labels
1832     inline_asm_nonlocal_labels
1833     inline_asm_direct_symbol_refs
1834     pragma_deprecated
1835     rsync_contimeout
1836     symver_asm_label
1837     symver_gnu_asm
1838     vfp_args
1839     xform_asm
1840     xmm_clobbers
1841 "
1842
1843 TYPES_LIST="
1844     CONDITION_VARIABLE_Ptr
1845     socklen_t
1846     struct_addrinfo
1847     struct_dcadec_exss_info_matrix_encoding
1848     struct_group_source_req
1849     struct_ip_mreq_source
1850     struct_ipv6_mreq
1851     struct_pollfd
1852     struct_rusage_ru_maxrss
1853     struct_sctp_event_subscribe
1854     struct_sockaddr_in6
1855     struct_sockaddr_sa_len
1856     struct_sockaddr_storage
1857     struct_stat_st_mtim_tv_nsec
1858     struct_v4l2_frmivalenum_discrete
1859 "
1860
1861 HAVE_LIST="
1862     $ARCH_EXT_LIST
1863     $(add_suffix _external $ARCH_EXT_LIST)
1864     $(add_suffix _inline   $ARCH_EXT_LIST)
1865     $ARCH_FEATURES
1866     $ATOMICS_LIST
1867     $BUILTIN_LIST
1868     $HAVE_LIST_CMDLINE
1869     $HAVE_LIST_PUB
1870     $HEADERS_LIST
1871     $INTRINSICS_LIST
1872     $MATH_FUNCS
1873     $SYSTEM_FUNCS
1874     $THREADS_LIST
1875     $TOOLCHAIN_FEATURES
1876     $TYPES_LIST
1877     atomics_native
1878     dos_paths
1879     dxva2api_cobj
1880     dxva2_lib
1881     libc_msvcrt
1882     libdc1394_1
1883     libdc1394_2
1884     makeinfo
1885     makeinfo_html
1886     perl
1887     pod2man
1888     sdl
1889     section_data_rel_ro
1890     texi2html
1891     threads
1892     vaapi_x11
1893     vdpau_x11
1894     xlib
1895 "
1896
1897 # options emitted with CONFIG_ prefix but not available on the command line
1898 CONFIG_EXTRA="
1899     aandcttables
1900     ac3dsp
1901     audio_frame_queue
1902     audiodsp
1903     blockdsp
1904     bswapdsp
1905     cabac
1906     dvprofile
1907     exif
1908     faandct
1909     faanidct
1910     fdctdsp
1911     flacdsp
1912     fmtconvert
1913     frame_thread_encoder
1914     g722dsp
1915     gcrypt
1916     gmp
1917     golomb
1918     gplv3
1919     h263dsp
1920     h264chroma
1921     h264dsp
1922     h264pred
1923     h264qpel
1924     hpeldsp
1925     huffman
1926     huffyuvdsp
1927     huffyuvencdsp
1928     idctdsp
1929     iirfilter
1930     imdct15
1931     intrax8
1932     ividsp
1933     jpegtables
1934     libx262
1935     lgplv3
1936     llauddsp
1937     llviddsp
1938     lpc
1939     lzf
1940     me_cmp
1941     mpeg_er
1942     mpegaudio
1943     mpegaudiodsp
1944     mpegvideo
1945     mpegvideoenc
1946     mss34dsp
1947     pixblockdsp
1948     qpeldsp
1949     qsv
1950     qsvdec
1951     qsvenc
1952     rangecoder
1953     riffdec
1954     riffenc
1955     rtpdec
1956     rtpenc_chain
1957     rv34dsp
1958     sinewin
1959     snappy
1960     startcode
1961     texturedsp
1962     texturedspenc
1963     tpeldsp
1964     videodsp
1965     vp3dsp
1966     vp56dsp
1967     vp8dsp
1968     wma_freqs
1969     wmv2dsp
1970 "
1971
1972 CMDLINE_SELECT="
1973     $ARCH_EXT_LIST
1974     $CONFIG_LIST
1975     $HAVE_LIST_CMDLINE
1976     $THREADS_LIST
1977     asm
1978     cross_compile
1979     debug
1980     extra_warnings
1981     logging
1982     lto
1983     optimizations
1984     rpath
1985     stripping
1986 "
1987
1988 PATHS_LIST="
1989     bindir
1990     datadir
1991     docdir
1992     incdir
1993     libdir
1994     mandir
1995     pkgconfigdir
1996     prefix
1997     shlibdir
1998 "
1999
2000 CMDLINE_SET="
2001     $PATHS_LIST
2002     ar
2003     arch
2004     as
2005     assert_level
2006     build_suffix
2007     cc
2008     cpu
2009     cross_prefix
2010     cxx
2011     dep_cc
2012     doxygen
2013     env
2014     extra_version
2015     gas
2016     host_cc
2017     host_cflags
2018     host_ld
2019     host_ldflags
2020     host_libs
2021     host_os
2022     install
2023     ld
2024     logfile
2025     malloc_prefix
2026     nm
2027     optflags
2028     pkg_config
2029     pkg_config_flags
2030     progs_suffix
2031     random_seed
2032     ranlib
2033     samples
2034     strip
2035     sws_max_filter_size
2036     sysinclude
2037     sysroot
2038     target_exec
2039     target_os
2040     target_path
2041     target_samples
2042     tempprefix
2043     toolchain
2044     valgrind
2045     yasmexe
2046 "
2047
2048 CMDLINE_APPEND="
2049     extra_cflags
2050     extra_cxxflags
2051     host_cppflags
2052 "
2053
2054 # code dependency declarations
2055
2056 # architecture extensions
2057
2058 armv5te_deps="arm"
2059 armv6_deps="arm"
2060 armv6t2_deps="arm"
2061 armv8_deps="aarch64"
2062 neon_deps_any="aarch64 arm"
2063 intrinsics_neon_deps="neon"
2064 vfp_deps_any="aarch64 arm"
2065 vfpv3_deps="vfp"
2066 setend_deps="arm"
2067
2068 map 'eval ${v}_inline_deps=inline_asm' $ARCH_EXT_LIST_ARM
2069
2070 mipsfpu_deps="mips"
2071 mipsdspr1_deps="mips"
2072 mipsdspr2_deps="mips"
2073 mips32r2_deps="mips"
2074 mips32r5_deps="mips"
2075 mips64r6_deps="mips"
2076 msa_deps="mips"
2077 mmi_deps="mips"
2078
2079 altivec_deps="ppc"
2080 dcbzl_deps="ppc"
2081 ldbrx_deps="ppc"
2082 ppc4xx_deps="ppc"
2083 vsx_deps="altivec"
2084 power8_deps="vsx"
2085
2086 cpunop_deps="i686"
2087 x86_64_select="i686"
2088 x86_64_suggest="fast_cmov"
2089
2090 amd3dnow_deps="mmx"
2091 amd3dnowext_deps="amd3dnow"
2092 i686_deps="x86"
2093 mmx_deps="x86"
2094 mmxext_deps="mmx"
2095 sse_deps="mmxext"
2096 sse2_deps="sse"
2097 sse3_deps="sse2"
2098 ssse3_deps="sse3"
2099 sse4_deps="ssse3"
2100 sse42_deps="sse4"
2101 avx_deps="sse42"
2102 xop_deps="avx"
2103 fma3_deps="avx"
2104 fma4_deps="avx"
2105 avx2_deps="avx"
2106
2107 mmx_external_deps="yasm"
2108 mmx_inline_deps="inline_asm"
2109 mmx_suggest="mmx_external mmx_inline"
2110
2111 for ext in $(filter_out mmx $ARCH_EXT_LIST_X86_SIMD); do
2112     eval dep=\$${ext}_deps
2113     eval ${ext}_external_deps='"${dep}_external"'
2114     eval ${ext}_inline_deps='"${dep}_inline"'
2115     eval ${ext}_suggest='"${ext}_external ${ext}_inline"'
2116 done
2117
2118 aligned_stack_if_any="aarch64 ppc x86"
2119 fast_64bit_if_any="aarch64 alpha ia64 mips64 parisc64 ppc64 sparc64 x86_64"
2120 fast_clz_if_any="aarch64 alpha avr32 mips ppc x86"
2121 fast_unaligned_if_any="aarch64 ppc x86"
2122 simd_align_16_if_any="altivec neon sse"
2123
2124 # system capabilities
2125 symver_if_any="symver_asm_label symver_gnu_asm"
2126 valgrind_backtrace_deps="!optimizations valgrind_valgrind_h"
2127
2128 # threading support
2129 atomics_gcc_if_any="sync_val_compare_and_swap atomic_compare_exchange"
2130 atomics_suncc_if="atomic_cas_ptr machine_rw_barrier"
2131 atomics_win32_if="MemoryBarrier"
2132 atomics_native_if_any="$ATOMICS_LIST"
2133 w32threads_deps="atomics_native"
2134 threads_if_any="$THREADS_LIST"
2135
2136 # subsystems
2137 dct_select="rdft"
2138 error_resilience_select="me_cmp"
2139 faandct_deps="faan fdctdsp"
2140 faanidct_deps="faan idctdsp"
2141 frame_thread_encoder_deps="encoders threads"
2142 intrax8_select="error_resilience"
2143 mdct_select="fft"
2144 rdft_select="fft"
2145 me_cmp_select="fdctdsp idctdsp pixblockdsp"
2146 mpeg_er_select="error_resilience"
2147 mpegaudio_select="mpegaudiodsp"
2148 mpegaudiodsp_select="dct"
2149 mpegvideo_select="blockdsp h264chroma hpeldsp idctdsp me_cmp mpeg_er videodsp"
2150 mpegvideoenc_select="me_cmp mpegvideo pixblockdsp qpeldsp"
2151 qsvdec_select="qsv"
2152 qsvenc_select="qsv"
2153
2154 # decoders / encoders
2155 aac_decoder_select="imdct15 mdct sinewin"
2156 aac_fixed_decoder_select="mdct sinewin"
2157 aac_encoder_select="audio_frame_queue iirfilter lpc mdct sinewin"
2158 aac_latm_decoder_select="aac_decoder aac_latm_parser"
2159 ac3_decoder_select="ac3_parser ac3dsp bswapdsp fmtconvert mdct"
2160 ac3_fixed_decoder_select="ac3_parser ac3dsp bswapdsp mdct"
2161 ac3_encoder_select="ac3dsp audiodsp mdct me_cmp"
2162 ac3_fixed_encoder_select="ac3dsp audiodsp mdct me_cmp"
2163 adpcm_g722_decoder_select="g722dsp"
2164 adpcm_g722_encoder_select="g722dsp"
2165 aic_decoder_select="golomb idctdsp"
2166 alac_encoder_select="lpc"
2167 als_decoder_select="bswapdsp"
2168 amrnb_decoder_select="lsp"
2169 amrwb_decoder_select="lsp"
2170 amv_decoder_select="sp5x_decoder exif"
2171 amv_encoder_select="aandcttables jpegtables mpegvideoenc"
2172 ape_decoder_select="bswapdsp llauddsp"
2173 apng_decoder_select="zlib"
2174 apng_encoder_select="huffyuvencdsp zlib"
2175 asv1_decoder_select="blockdsp bswapdsp idctdsp"
2176 asv1_encoder_select="bswapdsp fdctdsp pixblockdsp"
2177 asv2_decoder_select="blockdsp bswapdsp idctdsp"
2178 asv2_encoder_select="bswapdsp fdctdsp pixblockdsp"
2179 atrac1_decoder_select="mdct sinewin"
2180 atrac3_decoder_select="mdct"
2181 atrac3p_decoder_select="mdct sinewin"
2182 avrn_decoder_select="exif jpegtables"
2183 bink_decoder_select="blockdsp hpeldsp"
2184 binkaudio_dct_decoder_select="mdct rdft dct sinewin wma_freqs"
2185 binkaudio_rdft_decoder_select="mdct rdft sinewin wma_freqs"
2186 cavs_decoder_select="blockdsp golomb h264chroma idctdsp qpeldsp videodsp"
2187 cllc_decoder_select="bswapdsp"
2188 comfortnoise_encoder_select="lpc"
2189 cook_decoder_select="audiodsp mdct sinewin"
2190 cscd_decoder_select="lzo"
2191 cscd_decoder_suggest="zlib"
2192 dca_decoder_select="fmtconvert mdct"
2193 dds_decoder_select="texturedsp"
2194 dirac_decoder_select="dwt golomb videodsp mpegvideoenc"
2195 dnxhd_decoder_select="blockdsp idctdsp"
2196 dnxhd_encoder_select="aandcttables blockdsp fdctdsp idctdsp mpegvideoenc pixblockdsp"
2197 dvvideo_decoder_select="dvprofile idctdsp"
2198 dvvideo_encoder_select="dvprofile fdctdsp me_cmp pixblockdsp"
2199 dxa_decoder_select="zlib"
2200 dxv_decoder_select="lzf texturedsp"
2201 eac3_decoder_select="ac3_decoder"
2202 eac3_encoder_select="ac3_encoder"
2203 eamad_decoder_select="aandcttables blockdsp bswapdsp idctdsp mpegvideo"
2204 eatgq_decoder_select="aandcttables"
2205 eatqi_decoder_select="aandcttables blockdsp bswapdsp idctdsp mpeg1video_decoder"
2206 exr_decoder_select="zlib"
2207 ffv1_decoder_select="golomb rangecoder"
2208 ffv1_encoder_select="rangecoder"
2209 ffvhuff_decoder_select="huffyuv_decoder"
2210 ffvhuff_encoder_select="huffyuv_encoder"
2211 fic_decoder_select="golomb"
2212 flac_decoder_select="flacdsp golomb"
2213 flac_encoder_select="bswapdsp flacdsp golomb lpc"
2214 flashsv_decoder_select="zlib"
2215 flashsv_encoder_select="zlib"
2216 flashsv2_encoder_select="zlib"
2217 flashsv2_decoder_select="zlib"
2218 flv_decoder_select="h263_decoder"
2219 flv_encoder_select="h263_encoder"
2220 fourxm_decoder_select="blockdsp bswapdsp"
2221 fraps_decoder_select="bswapdsp huffman"
2222 g2m_decoder_select="blockdsp idctdsp jpegtables zlib"
2223 g729_decoder_select="audiodsp"
2224 h261_decoder_select="mpegvideo"
2225 h261_encoder_select="aandcttables mpegvideoenc"
2226 h263_decoder_select="h263_parser h263dsp mpegvideo qpeldsp"
2227 h263_encoder_select="aandcttables h263dsp mpegvideoenc"
2228 h263i_decoder_select="h263_decoder"
2229 h263p_decoder_select="h263_decoder"
2230 h263p_encoder_select="h263_encoder"
2231 h264_decoder_select="cabac golomb h264chroma h264dsp h264pred h264qpel startcode videodsp"
2232 h264_decoder_suggest="error_resilience"
2233 h264_qsv_decoder_deps="libmfx"
2234 h264_qsv_decoder_select="h264_mp4toannexb_bsf h264_parser qsvdec h264_qsv_hwaccel"
2235 h264_qsv_encoder_deps="libmfx"
2236 h264_qsv_encoder_select="qsvenc"
2237 hap_decoder_select="snappy texturedsp"
2238 hap_encoder_deps="libsnappy"
2239 hap_encoder_select="texturedspenc"
2240 hevc_decoder_select="bswapdsp cabac golomb videodsp"
2241 hevc_qsv_encoder_deps="libmfx"
2242 hevc_qsv_decoder_deps="libmfx"
2243 hevc_qsv_decoder_select="hevc_mp4toannexb_bsf hevc_parser qsvdec hevc_qsv_hwaccel"
2244 hevc_qsv_encoder_select="qsvenc"
2245 huffyuv_decoder_select="bswapdsp huffyuvdsp llviddsp"
2246 huffyuv_encoder_select="bswapdsp huffman huffyuvencdsp llviddsp"
2247 iac_decoder_select="imc_decoder"
2248 imc_decoder_select="bswapdsp fft mdct sinewin"
2249 indeo3_decoder_select="hpeldsp"
2250 indeo4_decoder_select="ividsp"
2251 indeo5_decoder_select="ividsp"
2252 interplay_video_decoder_select="hpeldsp"
2253 jpegls_decoder_select="golomb mjpeg_decoder"
2254 jpegls_encoder_select="golomb"
2255 jv_decoder_select="blockdsp"
2256 lagarith_decoder_select="huffyuvdsp"
2257 ljpeg_encoder_select="aandcttables idctdsp jpegtables"
2258 loco_decoder_select="golomb"
2259 mdec_decoder_select="blockdsp idctdsp mpegvideo"
2260 metasound_decoder_select="lsp mdct sinewin"
2261 mimic_decoder_select="blockdsp bswapdsp hpeldsp idctdsp"
2262 mjpeg_decoder_select="blockdsp hpeldsp exif idctdsp jpegtables"
2263 mjpeg_encoder_select="aandcttables jpegtables mpegvideoenc"
2264 mjpegb_decoder_select="mjpeg_decoder"
2265 mlp_decoder_select="mlp_parser"
2266 motionpixels_decoder_select="bswapdsp"
2267 mp1_decoder_select="mpegaudio"
2268 mp1float_decoder_select="mpegaudio"
2269 mp2_decoder_select="mpegaudio"
2270 mp2float_decoder_select="mpegaudio"
2271 mp3_decoder_select="mpegaudio"
2272 mp3adu_decoder_select="mpegaudio"
2273 mp3adufloat_decoder_select="mpegaudio"
2274 mp3float_decoder_select="mpegaudio"
2275 mp3on4_decoder_select="mpegaudio"
2276 mp3on4float_decoder_select="mpegaudio"
2277 mpc7_decoder_select="bswapdsp mpegaudiodsp"
2278 mpc8_decoder_select="mpegaudiodsp"
2279 mpeg_xvmc_decoder_deps="X11_extensions_XvMClib_h"
2280 mpeg_xvmc_decoder_select="mpeg2video_decoder"
2281 mpegvideo_decoder_select="mpegvideo"
2282 mpeg1video_decoder_select="mpegvideo"
2283 mpeg1video_encoder_select="aandcttables mpegvideoenc h263dsp"
2284 mpeg2video_decoder_select="mpegvideo"
2285 mpeg2video_encoder_select="aandcttables mpegvideoenc h263dsp"
2286 mpeg2_qsv_decoder_deps="libmfx"
2287 mpeg2_qsv_decoder_select="qsvdec mpeg2_qsv_hwaccel"
2288 mpeg2_qsv_encoder_deps="libmfx"
2289 mpeg2_qsv_encoder_select="qsvenc"
2290 mpeg4_decoder_select="h263_decoder mpeg4video_parser"
2291 mpeg4_encoder_select="h263_encoder"
2292 msa1_decoder_select="mss34dsp"
2293 msmpeg4v1_decoder_select="h263_decoder"
2294 msmpeg4v2_decoder_select="h263_decoder"
2295 msmpeg4v2_encoder_select="h263_encoder"
2296 msmpeg4v3_decoder_select="h263_decoder"
2297 msmpeg4v3_encoder_select="h263_encoder"
2298 mss2_decoder_select="vc1_decoder"
2299 mts2_decoder_select="mss34dsp"
2300 mxpeg_decoder_select="mjpeg_decoder"
2301 nellymoser_decoder_select="mdct sinewin"
2302 nellymoser_encoder_select="audio_frame_queue mdct sinewin"
2303 nuv_decoder_select="idctdsp lzo"
2304 on2avc_decoder_select="mdct"
2305 opus_decoder_deps="swresample"
2306 opus_decoder_select="imdct15"
2307 png_decoder_select="zlib"
2308 png_encoder_select="huffyuvencdsp zlib"
2309 prores_decoder_select="blockdsp idctdsp"
2310 prores_encoder_select="fdctdsp"
2311 qcelp_decoder_select="lsp"
2312 qdm2_decoder_select="mdct rdft mpegaudiodsp"
2313 ra_144_encoder_select="audio_frame_queue lpc audiodsp"
2314 ra_144_decoder_select="audiodsp"
2315 ralf_decoder_select="golomb"
2316 rawvideo_decoder_select="bswapdsp"
2317 rtjpeg_decoder_select="me_cmp"
2318 rv10_decoder_select="h263_decoder"
2319 rv10_encoder_select="h263_encoder"
2320 rv20_decoder_select="h263_decoder"
2321 rv20_encoder_select="h263_encoder"
2322 rv30_decoder_select="golomb h264pred h264qpel mpegvideo rv34dsp"
2323 rv40_decoder_select="golomb h264pred h264qpel mpegvideo rv34dsp"
2324 shorten_decoder_select="golomb"
2325 sipr_decoder_select="lsp"
2326 snow_decoder_select="dwt h264qpel hpeldsp me_cmp rangecoder videodsp"
2327 snow_encoder_select="aandcttables dwt h264qpel hpeldsp me_cmp mpegvideoenc rangecoder"
2328 sonic_decoder_select="golomb rangecoder"
2329 sonic_encoder_select="golomb rangecoder"
2330 sonic_ls_encoder_select="golomb rangecoder"
2331 sp5x_decoder_select="mjpeg_decoder"
2332 svq1_decoder_select="hpeldsp"
2333 svq1_encoder_select="aandcttables hpeldsp me_cmp mpegvideoenc"
2334 svq3_decoder_select="h264_decoder hpeldsp tpeldsp"
2335 svq3_decoder_suggest="zlib"
2336 tak_decoder_select="audiodsp"
2337 tdsc_decoder_select="zlib mjpeg_decoder"
2338 theora_decoder_select="vp3_decoder"
2339 thp_decoder_select="mjpeg_decoder"
2340 tiff_decoder_suggest="zlib lzma"
2341 tiff_encoder_suggest="zlib"
2342 truehd_decoder_select="mlp_parser"
2343 truemotion2_decoder_select="bswapdsp"
2344 truespeech_decoder_select="bswapdsp"
2345 tscc_decoder_select="zlib"
2346 twinvq_decoder_select="mdct lsp sinewin"
2347 txd_decoder_select="texturedsp"
2348 utvideo_decoder_select="bswapdsp"
2349 utvideo_encoder_select="bswapdsp huffman huffyuvencdsp"
2350 vble_decoder_select="huffyuvdsp"
2351 vc1_decoder_select="blockdsp h263_decoder h264qpel intrax8 qpeldsp startcode"
2352 vc1image_decoder_select="vc1_decoder"
2353 vc1_qsv_decoder_deps="libmfx"
2354 vc1_qsv_decoder_select="qsvdec vc1_qsv_hwaccel"
2355 vorbis_decoder_select="mdct"
2356 vorbis_encoder_select="mdct"
2357 vp3_decoder_select="hpeldsp vp3dsp videodsp"
2358 vp5_decoder_select="h264chroma hpeldsp videodsp vp3dsp vp56dsp"
2359 vp6_decoder_select="h264chroma hpeldsp huffman videodsp vp3dsp vp56dsp"
2360 vp6a_decoder_select="vp6_decoder"
2361 vp6f_decoder_select="vp6_decoder"
2362 vp7_decoder_select="h264pred videodsp vp8dsp"
2363 vp8_decoder_select="h264pred videodsp vp8dsp"
2364 vp9_decoder_select="videodsp vp9_parser"
2365 webp_decoder_select="vp8_decoder"
2366 wmalossless_decoder_select="llauddsp"
2367 wmapro_decoder_select="mdct sinewin wma_freqs"
2368 wmav1_decoder_select="mdct sinewin wma_freqs"
2369 wmav1_encoder_select="mdct sinewin wma_freqs"
2370 wmav2_decoder_select="mdct sinewin wma_freqs"
2371 wmav2_encoder_select="mdct sinewin wma_freqs"
2372 wmavoice_decoder_select="lsp rdft dct mdct sinewin"
2373 wmv1_decoder_select="h263_decoder"
2374 wmv1_encoder_select="h263_encoder"
2375 wmv2_decoder_select="blockdsp h263_decoder idctdsp intrax8 videodsp wmv2dsp"
2376 wmv2_encoder_select="h263_encoder wmv2dsp"
2377 wmv3_decoder_select="vc1_decoder"
2378 wmv3image_decoder_select="wmv3_decoder"
2379 zerocodec_decoder_select="zlib"
2380 zlib_decoder_select="zlib"
2381 zlib_encoder_select="zlib"
2382 zmbv_decoder_select="zlib"
2383 zmbv_encoder_select="zlib"
2384
2385 # hardware accelerators
2386 crystalhd_deps="libcrystalhd_libcrystalhd_if_h"
2387 d3d11va_deps="d3d11_h dxva_h ID3D11VideoDecoder"
2388 dxva2_deps="dxva2api_h DXVA2_ConfigPictureDecode"
2389 vaapi_deps="va_va_h"
2390 vda_deps="VideoDecodeAcceleration_VDADecoder_h pthreads CoreServices_CoreServices_h"
2391 vda_extralibs="-framework CoreFoundation -framework VideoDecodeAcceleration -framework QuartzCore -framework CoreServices"
2392 vdpau_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
2393 videotoolbox_deps="VideoToolbox_VideoToolbox_h pthreads CoreServices_CoreServices_h"
2394 videotoolbox_extralibs="-framework CoreFoundation -framework VideoToolbox -framework CoreMedia -framework QuartzCore -framework CoreServices"
2395 xvmc_deps="X11_extensions_XvMClib_h"
2396
2397 h263_vaapi_hwaccel_deps="vaapi"
2398 h263_vaapi_hwaccel_select="h263_decoder"
2399 h263_vdpau_hwaccel_deps="vdpau"
2400 h263_vdpau_hwaccel_select="h263_decoder"
2401 h263_videotoolbox_hwaccel_deps="videotoolbox"
2402 h263_videotoolbox_hwaccel_select="h263_decoder"
2403 h264_crystalhd_decoder_select="crystalhd h264_mp4toannexb_bsf h264_parser"
2404 h264_d3d11va_hwaccel_deps="d3d11va"
2405 h264_d3d11va_hwaccel_select="h264_decoder"
2406 h264_dxva2_hwaccel_deps="dxva2"
2407 h264_dxva2_hwaccel_select="h264_decoder"
2408 h264_mmal_decoder_deps="mmal"
2409 h264_mmal_hwaccel_deps="mmal"
2410 h264_mmal_decoder_select="h264_decoder"
2411 h264_mmal_encoder_deps="mmal"
2412 h264_qsv_hwaccel_deps="libmfx"
2413 h264_vaapi_hwaccel_deps="vaapi"
2414 h264_vaapi_hwaccel_select="h264_decoder"
2415 h264_vda_decoder_deps="vda"
2416 h264_vda_decoder_select="h264_decoder"
2417 h264_vda_hwaccel_deps="vda"
2418 h264_vda_hwaccel_select="h264_decoder"
2419 h264_vda_old_hwaccel_deps="vda"
2420 h264_vda_old_hwaccel_select="h264_decoder"
2421 h264_vdpau_decoder_deps="vdpau"
2422 h264_vdpau_decoder_select="h264_decoder"
2423 h264_vdpau_hwaccel_deps="vdpau"
2424 h264_vdpau_hwaccel_select="h264_decoder"
2425 h264_videotoolbox_hwaccel_deps="videotoolbox"
2426 h264_videotoolbox_hwaccel_select="h264_decoder"
2427 hevc_d3d11va_hwaccel_deps="d3d11va DXVA_PicParams_HEVC"
2428 hevc_d3d11va_hwaccel_select="hevc_decoder"
2429 hevc_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_HEVC"
2430 hevc_dxva2_hwaccel_select="hevc_decoder"
2431 hevc_qsv_hwaccel_deps="libmfx"
2432 hevc_vaapi_hwaccel_deps="vaapi VAPictureParameterBufferHEVC"
2433 hevc_vaapi_hwaccel_select="hevc_decoder"
2434 hevc_vdpau_hwaccel_deps="vdpau VdpPictureInfoHEVC"
2435 hevc_vdpau_hwaccel_select="hevc_decoder"
2436 mpeg_vdpau_decoder_deps="vdpau"
2437 mpeg_vdpau_decoder_select="mpeg2video_decoder"
2438 mpeg_xvmc_hwaccel_deps="xvmc"
2439 mpeg_xvmc_hwaccel_select="mpeg2video_decoder"
2440 mpeg1_vdpau_decoder_deps="vdpau"
2441 mpeg1_vdpau_decoder_select="mpeg1video_decoder"
2442 mpeg1_vdpau_hwaccel_deps="vdpau"
2443 mpeg1_vdpau_hwaccel_select="mpeg1video_decoder"
2444 mpeg1_videotoolbox_hwaccel_deps="videotoolbox"
2445 mpeg1_videotoolbox_hwaccel_select="mpeg1video_decoder"
2446 mpeg1_xvmc_hwaccel_deps="xvmc"
2447 mpeg1_xvmc_hwaccel_select="mpeg1video_decoder"
2448 mpeg2_crystalhd_decoder_select="crystalhd"
2449 mpeg2_d3d11va_hwaccel_deps="d3d11va"
2450 mpeg2_d3d11va_hwaccel_select="mpeg2video_decoder"
2451 mpeg2_dxva2_hwaccel_deps="dxva2"
2452 mpeg2_dxva2_hwaccel_select="mpeg2video_decoder"
2453 mpeg2_qsv_hwaccel_deps="libmfx"
2454 mpeg2_qsv_hwaccel_select="qsvdec_mpeg2"
2455 mpeg2_vaapi_hwaccel_deps="vaapi"
2456 mpeg2_vaapi_hwaccel_select="mpeg2video_decoder"
2457 mpeg2_vdpau_hwaccel_deps="vdpau"
2458 mpeg2_vdpau_hwaccel_select="mpeg2video_decoder"
2459 mpeg2_videotoolbox_hwaccel_deps="videotoolbox"
2460 mpeg2_videotoolbox_hwaccel_select="mpeg2video_decoder"
2461 mpeg2_xvmc_hwaccel_deps="xvmc"
2462 mpeg2_xvmc_hwaccel_select="mpeg2video_decoder"
2463 mpeg4_crystalhd_decoder_select="crystalhd"
2464 mpeg4_vaapi_hwaccel_deps="vaapi"
2465 mpeg4_vaapi_hwaccel_select="mpeg4_decoder"
2466 mpeg4_vdpau_decoder_deps="vdpau"
2467 mpeg4_vdpau_decoder_select="mpeg4_decoder"
2468 mpeg4_vdpau_hwaccel_deps="vdpau"
2469 mpeg4_vdpau_hwaccel_select="mpeg4_decoder"
2470 mpeg4_videotoolbox_hwaccel_deps="videotoolbox"
2471 mpeg4_videotoolbox_hwaccel_select="mpeg4_decoder"
2472 msmpeg4_crystalhd_decoder_select="crystalhd"
2473 vc1_crystalhd_decoder_select="crystalhd"
2474 vc1_d3d11va_hwaccel_deps="d3d11va"
2475 vc1_d3d11va_hwaccel_select="vc1_decoder"
2476 vc1_dxva2_hwaccel_deps="dxva2"
2477 vc1_dxva2_hwaccel_select="vc1_decoder"
2478 vc1_vaapi_hwaccel_deps="vaapi"
2479 vc1_vaapi_hwaccel_select="vc1_decoder"
2480 vc1_vdpau_decoder_deps="vdpau"
2481 vc1_vdpau_decoder_select="vc1_decoder"
2482 vc1_vdpau_hwaccel_deps="vdpau"
2483 vc1_vdpau_hwaccel_select="vc1_decoder"
2484 vc1_qsv_hwaccel_deps="libmfx"
2485 vc1_qsv_hwaccel_select="qsvdec_vc1"
2486 wmv3_crystalhd_decoder_select="crystalhd"
2487 wmv3_d3d11va_hwaccel_select="vc1_d3d11va_hwaccel"
2488 wmv3_dxva2_hwaccel_select="vc1_dxva2_hwaccel"
2489 wmv3_vaapi_hwaccel_select="vc1_vaapi_hwaccel"
2490 wmv3_vdpau_decoder_select="vc1_vdpau_decoder"
2491 wmv3_vdpau_hwaccel_select="vc1_vdpau_hwaccel"
2492
2493 # parsers
2494 h264_parser_select="h264_decoder"
2495 hevc_parser_select="golomb"
2496 mpegvideo_parser_select="mpegvideo"
2497 mpeg4video_parser_select="h263dsp mpegvideo qpeldsp"
2498 vc1_parser_select="mpegvideo startcode vc1_decoder"
2499
2500 # bitstream_filters
2501 mjpeg2jpeg_bsf_select="jpegtables"
2502
2503 # external libraries
2504 libaacplus_encoder_deps="libaacplus"
2505 libcelt_decoder_deps="libcelt"
2506 libdcadec_decoder_deps="libdcadec"
2507 libfaac_encoder_deps="libfaac"
2508 libfaac_encoder_select="audio_frame_queue"
2509 libfdk_aac_decoder_deps="libfdk_aac"
2510 libfdk_aac_encoder_deps="libfdk_aac"
2511 libfdk_aac_encoder_select="audio_frame_queue"
2512 libgme_demuxer_deps="libgme"
2513 libgsm_decoder_deps="libgsm"
2514 libgsm_encoder_deps="libgsm"
2515 libgsm_ms_decoder_deps="libgsm"
2516 libgsm_ms_encoder_deps="libgsm"
2517 libilbc_decoder_deps="libilbc"
2518 libilbc_encoder_deps="libilbc"
2519 libkvazaar_encoder_deps="libkvazaar"
2520 libmodplug_demuxer_deps="libmodplug"
2521 libmp3lame_encoder_deps="libmp3lame"
2522 libmp3lame_encoder_select="audio_frame_queue"
2523 libopencore_amrnb_decoder_deps="libopencore_amrnb"
2524 libopencore_amrnb_encoder_deps="libopencore_amrnb"
2525 libopencore_amrnb_encoder_select="audio_frame_queue"
2526 libopencore_amrwb_decoder_deps="libopencore_amrwb"
2527 libopenh264_encoder_deps="libopenh264"
2528 libopenjpeg_decoder_deps="libopenjpeg"
2529 libopenjpeg_encoder_deps="libopenjpeg"
2530 libopus_decoder_deps="libopus"
2531 libopus_encoder_deps="libopus"
2532 libopus_encoder_select="audio_frame_queue"
2533 libquvi_demuxer_deps="libquvi"
2534 libschroedinger_decoder_deps="libschroedinger"
2535 libschroedinger_encoder_deps="libschroedinger"
2536 libshine_encoder_deps="libshine"
2537 libshine_encoder_select="audio_frame_queue"
2538 libspeex_decoder_deps="libspeex"
2539 libspeex_encoder_deps="libspeex"
2540 libspeex_encoder_select="audio_frame_queue"
2541 libstagefright_h264_decoder_deps="libstagefright_h264"
2542 libtheora_encoder_deps="libtheora"
2543 libtwolame_encoder_deps="libtwolame"
2544 libvo_aacenc_encoder_deps="libvo_aacenc"
2545 libvo_aacenc_encoder_select="audio_frame_queue"
2546 libvo_amrwbenc_encoder_deps="libvo_amrwbenc"
2547 libvorbis_decoder_deps="libvorbis"
2548 libvorbis_encoder_deps="libvorbis"
2549 libvorbis_encoder_select="audio_frame_queue"
2550 libvpx_vp8_decoder_deps="libvpx"
2551 libvpx_vp8_encoder_deps="libvpx"
2552 libvpx_vp9_decoder_deps="libvpx"
2553 libvpx_vp9_encoder_deps="libvpx"
2554 libwavpack_encoder_deps="libwavpack"
2555 libwebp_encoder_deps="libwebp"
2556 libwebp_anim_encoder_deps="libwebp"
2557 libx262_encoder_deps="libx262"
2558 libx264_encoder_deps="libx264"
2559 libx264rgb_encoder_deps="libx264"
2560 libx264rgb_encoder_select="libx264_encoder"
2561 libx265_encoder_deps="libx265"
2562 libxavs_encoder_deps="libxavs"
2563 libxvid_encoder_deps="libxvid"
2564 libutvideo_decoder_deps="libutvideo"
2565 libutvideo_encoder_deps="libutvideo"
2566 libzvbi_teletext_decoder_deps="libzvbi"
2567 nvenc_encoder_deps="nvenc"
2568 nvenc_h264_encoder_deps="nvenc"
2569 nvenc_hevc_encoder_deps="nvenc"
2570
2571 # demuxers / muxers
2572 ac3_demuxer_select="ac3_parser"
2573 asf_demuxer_select="riffdec"
2574 asf_o_demuxer_select="riffdec"
2575 asf_muxer_select="riffenc"
2576 asf_stream_muxer_select="asf_muxer"
2577 avi_demuxer_select="riffdec exif"
2578 avi_muxer_select="riffenc"
2579 avisynth_demuxer_deps="avisynth"
2580 avisynth_demuxer_select="riffdec"
2581 caf_demuxer_select="riffdec"
2582 dash_muxer_select="mp4_muxer"
2583 dirac_demuxer_select="dirac_parser"
2584 dts_demuxer_select="dca_parser"
2585 dtshd_demuxer_select="dca_parser"
2586 dv_demuxer_select="dvprofile"
2587 dv_muxer_select="dvprofile"
2588 dxa_demuxer_select="riffdec"
2589 eac3_demuxer_select="ac3_parser"
2590 f4v_muxer_select="mov_muxer"
2591 flac_demuxer_select="flac_parser"
2592 hds_muxer_select="flv_muxer"
2593 hls_muxer_select="mpegts_muxer"
2594 image2_alias_pix_demuxer_select="image2_demuxer"
2595 image2_brender_pix_demuxer_select="image2_demuxer"
2596 ipod_muxer_select="mov_muxer"
2597 ismv_muxer_select="mov_muxer"
2598 libnut_demuxer_deps="libnut"
2599 libnut_muxer_deps="libnut"
2600 matroska_audio_muxer_select="matroska_muxer"
2601 matroska_demuxer_select="riffdec"
2602 matroska_demuxer_suggest="bzlib lzo zlib"
2603 matroska_muxer_select="riffenc"
2604 mmf_muxer_select="riffenc"
2605 mov_demuxer_select="riffdec"
2606 mov_demuxer_suggest="zlib"
2607 mov_muxer_select="riffenc rtpenc_chain"
2608 mp3_demuxer_select="mpegaudio_parser"
2609 mp4_muxer_select="mov_muxer"
2610 mpegts_muxer_select="adts_muxer latm_muxer"
2611 mpegtsraw_demuxer_select="mpegts_demuxer"
2612 mxf_d10_muxer_select="mxf_muxer"
2613 mxf_opatom_muxer_select="mxf_muxer"
2614 nut_muxer_select="riffenc"
2615 nuv_demuxer_select="riffdec"
2616 oga_muxer_select="ogg_muxer"
2617 ogg_demuxer_select="golomb"
2618 opus_muxer_select="ogg_muxer"
2619 psp_muxer_select="mov_muxer"
2620 rtp_demuxer_select="sdp_demuxer"
2621 rtpdec_select="asf_demuxer jpegtables mov_demuxer mpegts_demuxer rm_demuxer rtp_protocol"
2622 rtsp_demuxer_select="http_protocol rtpdec"
2623 rtsp_muxer_select="rtp_muxer http_protocol rtp_protocol rtpenc_chain"
2624 sap_demuxer_select="sdp_demuxer"
2625 sap_muxer_select="rtp_muxer rtp_protocol rtpenc_chain"
2626 sdp_demuxer_select="rtpdec"
2627 smoothstreaming_muxer_select="ismv_muxer"
2628 spdif_muxer_select="aac_parser"
2629 spx_muxer_select="ogg_muxer"
2630 tak_demuxer_select="tak_parser"
2631 tg2_muxer_select="mov_muxer"
2632 tgp_muxer_select="mov_muxer"
2633 vobsub_demuxer_select="mpegps_demuxer"
2634 w64_demuxer_select="wav_demuxer"
2635 w64_muxer_select="wav_muxer"
2636 wav_demuxer_select="riffdec"
2637 wav_muxer_select="riffenc"
2638 webm_muxer_select="riffenc"
2639 wtv_demuxer_select="riffdec"
2640 wtv_muxer_select="riffenc"
2641 xmv_demuxer_select="riffdec"
2642 xwma_demuxer_select="riffdec"
2643
2644 # indevs / outdevs
2645 alsa_indev_deps="alsa_asoundlib_h snd_pcm_htimestamp"
2646 alsa_outdev_deps="alsa_asoundlib_h"
2647 avfoundation_indev_extralibs="-framework CoreVideo -framework Foundation -framework AVFoundation -framework CoreMedia"
2648 avfoundation_indev_select="avfoundation"
2649 bktr_indev_deps_any="dev_bktr_ioctl_bt848_h machine_ioctl_bt848_h dev_video_bktr_ioctl_bt848_h dev_ic_bt8xx_h"
2650 caca_outdev_deps="libcaca"
2651 decklink_outdev_deps="decklink pthreads"
2652 decklink_outdev_extralibs="-lstdc++"
2653 decklink_indev_deps="decklink pthreads"
2654 decklink_indev_extralibs="-lstdc++"
2655 dshow_indev_deps="IBaseFilter"
2656 dshow_indev_extralibs="-lpsapi -lole32 -lstrmiids -luuid -loleaut32 -lshlwapi"
2657 dv1394_indev_deps="dv1394"
2658 dv1394_indev_select="dv_demuxer"
2659 fbdev_indev_deps="linux_fb_h"
2660 fbdev_outdev_deps="linux_fb_h"
2661 gdigrab_indev_deps="CreateDIBSection"
2662 gdigrab_indev_extralibs="-lgdi32"
2663 gdigrab_indev_select="bmp_decoder"
2664 iec61883_indev_deps="libiec61883"
2665 jack_indev_deps="jack_jack_h sem_timedwait"
2666 lavfi_indev_deps="avfilter"
2667 libcdio_indev_deps="libcdio"
2668 libdc1394_indev_deps="libdc1394"
2669 libv4l2_indev_deps="libv4l2"
2670 openal_indev_deps="openal"
2671 opengl_outdev_deps="opengl"
2672 oss_indev_deps_any="soundcard_h sys_soundcard_h"
2673 oss_outdev_deps_any="soundcard_h sys_soundcard_h"
2674 pulse_indev_deps="libpulse"
2675 pulse_outdev_deps="libpulse"
2676 qtkit_indev_extralibs="-framework QTKit -framework Foundation -framework QuartzCore"
2677 qtkit_indev_select="qtkit"
2678 sdl_outdev_deps="sdl"
2679 sndio_indev_deps="sndio_h"
2680 sndio_outdev_deps="sndio_h"
2681 v4l_indev_deps="linux_videodev_h"
2682 v4l2_indev_deps_any="linux_videodev2_h sys_videoio_h"
2683 v4l2_outdev_deps_any="linux_videodev2_h sys_videoio_h"
2684 vfwcap_indev_deps="capCreateCaptureWindow vfwcap_defines"
2685 vfwcap_indev_extralibs="-lavicap32"
2686 xv_outdev_deps="X11_extensions_Xvlib_h XvGetPortAttribute"
2687 xv_outdev_extralibs="-lXv -lX11 -lXext"
2688 x11grab_indev_deps="x11grab"
2689 x11grab_xcb_indev_deps="libxcb"
2690
2691 # protocols
2692 async_protocol_deps="pthreads"
2693 bluray_protocol_deps="libbluray"
2694 ffrtmpcrypt_protocol_deps="!librtmp_protocol"
2695 ffrtmpcrypt_protocol_deps_any="gcrypt gmp openssl"
2696 ffrtmpcrypt_protocol_select="tcp_protocol"
2697 ffrtmphttp_protocol_deps="!librtmp_protocol"
2698 ffrtmphttp_protocol_select="http_protocol"
2699 ftp_protocol_select="tcp_protocol"
2700 gopher_protocol_select="network"
2701 http_protocol_select="tcp_protocol"
2702 httpproxy_protocol_select="tcp_protocol"
2703 https_protocol_select="tls_protocol"
2704 icecast_protocol_select="http_protocol"
2705 librtmp_protocol_deps="librtmp"
2706 librtmpe_protocol_deps="librtmp"
2707 librtmps_protocol_deps="librtmp"
2708 librtmpt_protocol_deps="librtmp"
2709 librtmpte_protocol_deps="librtmp"
2710 libsmbclient_protocol_deps="libsmbclient gplv3"
2711 libssh_protocol_deps="libssh"
2712 mmsh_protocol_select="http_protocol"
2713 mmst_protocol_select="network"
2714 rtmp_protocol_deps="!librtmp_protocol"
2715 rtmp_protocol_select="tcp_protocol"
2716 rtmpe_protocol_select="ffrtmpcrypt_protocol"
2717 rtmps_protocol_deps="!librtmp_protocol"
2718 rtmps_protocol_select="tls_protocol"
2719 rtmpt_protocol_select="ffrtmphttp_protocol"
2720 rtmpte_protocol_select="ffrtmpcrypt_protocol ffrtmphttp_protocol"
2721 rtmpts_protocol_select="ffrtmphttp_protocol https_protocol"
2722 rtp_protocol_select="udp_protocol"
2723 sctp_protocol_deps="struct_sctp_event_subscribe"
2724 sctp_protocol_select="network"
2725 srtp_protocol_select="rtp_protocol"
2726 tcp_protocol_select="network"
2727 tls_gnutls_protocol_deps="gnutls !tls_securetransport_protocol"
2728 tls_gnutls_protocol_select="tcp_protocol"
2729 tls_openssl_protocol_deps="openssl !tls_securetransport_protocol !tls_gnutls_protocol"
2730 tls_openssl_protocol_select="tcp_protocol"
2731 tls_securetransport_protocol_deps="securetransport"
2732 tls_securetransport_protocol_select="tcp_protocol"
2733 tls_protocol_deps_any="tls_securetransport_protocol tls_gnutls_protocol tls_openssl_protocol"
2734 udp_protocol_select="network"
2735 udplite_protocol_select="network"
2736 unix_protocol_deps="sys_un_h"
2737 unix_protocol_select="network"
2738
2739 # filters
2740 amovie_filter_deps="avcodec avformat"
2741 aresample_filter_deps="swresample"
2742 ass_filter_deps="libass"
2743 asyncts_filter_deps="avresample"
2744 atempo_filter_deps="avcodec"
2745 atempo_filter_select="rdft"
2746 azmq_filter_deps="libzmq"
2747 blackframe_filter_deps="gpl"
2748 boxblur_filter_deps="gpl"
2749 bs2b_filter_deps="libbs2b"
2750 colormatrix_filter_deps="gpl"
2751 cover_rect_filter_deps="avcodec avformat gpl"
2752 cropdetect_filter_deps="gpl"
2753 delogo_filter_deps="gpl"
2754 deshake_filter_select="pixelutils"
2755 drawtext_filter_deps="libfreetype"
2756 dynaudnorm_filter_deps="copysign erf"
2757 ebur128_filter_deps="gpl"
2758 eq_filter_deps="gpl"
2759 fftfilt_filter_deps="avcodec"
2760 fftfilt_filter_select="rdft"
2761 flite_filter_deps="libflite"
2762 find_rect_filter_deps="avcodec avformat gpl"
2763 frei0r_filter_deps="frei0r dlopen"
2764 frei0r_src_filter_deps="frei0r dlopen"
2765 fspp_filter_deps="gpl"
2766 geq_filter_deps="gpl"
2767 histeq_filter_deps="gpl"
2768 hqdn3d_filter_deps="gpl"
2769 interlace_filter_deps="gpl"
2770 kerndeint_filter_deps="gpl"
2771 ladspa_filter_deps="ladspa dlopen"
2772 mcdeint_filter_deps="avcodec gpl"
2773 movie_filter_deps="avcodec avformat"
2774 mpdecimate_filter_deps="gpl"
2775 mpdecimate_filter_select="pixelutils"
2776 mptestsrc_filter_deps="gpl"
2777 negate_filter_deps="lut_filter"
2778 perspective_filter_deps="gpl"
2779 pp7_filter_deps="gpl"
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*|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
4072                 loongson3*)
4073                     cpuflags="-march=loongson3a -mhard-float -fno-expensive-optimizations"
4074                 ;;
4075                 loongson2e)
4076                     cpuflags="-march=loongson2e -mhard-float -fno-expensive-optimizations"
4077                 ;;
4078                 loongson2f)
4079                     cpuflags="-march=loongson2f -mhard-float -fno-expensive-optimizations"
4080                 ;;
4081             esac
4082         ;;
4083         generic)
4084             disable mips32r5
4085             disable mips64r6
4086             disable msa
4087         ;;
4088     esac
4089
4090 elif enabled ppc; then
4091
4092     disable ldbrx
4093
4094     case $(tolower $cpu) in
4095         601|ppc601|powerpc601)
4096             cpuflags="-mcpu=601"
4097             disable altivec
4098         ;;
4099         603*|ppc603*|powerpc603*)
4100             cpuflags="-mcpu=603"
4101             disable altivec
4102         ;;
4103         604*|ppc604*|powerpc604*)
4104             cpuflags="-mcpu=604"
4105             disable altivec
4106         ;;
4107         g3|75*|ppc75*|powerpc75*)
4108             cpuflags="-mcpu=750"
4109             disable altivec
4110         ;;
4111         g4|745*|ppc745*|powerpc745*)
4112             cpuflags="-mcpu=7450"
4113             disable vsx
4114         ;;
4115         74*|ppc74*|powerpc74*)
4116             cpuflags="-mcpu=7400"
4117             disable vsx
4118         ;;
4119         g5|970|ppc970|powerpc970)
4120             cpuflags="-mcpu=970"
4121             disable vsx
4122         ;;
4123         power[3-6]*)
4124             cpuflags="-mcpu=$cpu"
4125             disable vsx
4126         ;;
4127         power[7-8]*)
4128             cpuflags="-mcpu=$cpu"
4129         ;;
4130         cell)
4131             cpuflags="-mcpu=cell"
4132             enable ldbrx
4133             disable vsx
4134         ;;
4135         e500mc)
4136             cpuflags="-mcpu=e500mc"
4137             disable altivec
4138         ;;
4139         e500v2)
4140             cpuflags="-mcpu=8548 -mhard-float -mfloat-gprs=double"
4141             disable altivec
4142             disable dcbzl
4143         ;;
4144         e500)
4145             cpuflags="-mcpu=8540 -mhard-float"
4146             disable altivec
4147             disable dcbzl
4148         ;;
4149     esac
4150
4151 elif enabled sparc; then
4152
4153     case $cpu in
4154         cypress|f93[04]|tsc701|sparcl*|supersparc|hypersparc|niagara|v[789])
4155             cpuflags="-mcpu=$cpu"
4156         ;;
4157         ultrasparc*|niagara[234])
4158             cpuflags="-mcpu=$cpu"
4159         ;;
4160     esac
4161
4162 elif enabled x86; then
4163
4164     case $cpu in
4165         i[345]86|pentium)
4166             cpuflags="-march=$cpu"
4167             disable i686
4168             disable mmx
4169         ;;
4170         # targets that do NOT support nopl and conditional mov (cmov)
4171         pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
4172             cpuflags="-march=$cpu"
4173             disable i686
4174         ;;
4175         # targets that do support nopl and conditional mov (cmov)
4176         i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64*|k8*|opteron*|athlon-fx\
4177         |core*|atom|bonnell|nehalem|westmere|silvermont|sandybridge|ivybridge|haswell|broadwell|amdfam10|barcelona|b[dt]ver*)
4178             cpuflags="-march=$cpu"
4179             enable i686
4180             enable fast_cmov
4181         ;;
4182         # targets that do support conditional mov but on which it's slow
4183         pentium4|pentium4m|prescott|nocona)
4184             cpuflags="-march=$cpu"
4185             enable i686
4186             disable fast_cmov
4187         ;;
4188     esac
4189
4190 fi
4191
4192 if [ "$cpu" != generic ]; then
4193     add_cflags  $cpuflags
4194     add_asflags $cpuflags
4195 fi
4196
4197 # compiler sanity check
4198 check_exec <<EOF
4199 int main(void){ return 0; }
4200 EOF
4201 if test "$?" != 0; then
4202     echo "$cc is unable to create an executable file."
4203     if test -z "$cross_prefix" && ! enabled cross_compile ; then
4204         echo "If $cc is a cross-compiler, use the --enable-cross-compile option."
4205         echo "Only do this if you know what cross compiling means."
4206     fi
4207     die "C compiler test failed."
4208 fi
4209
4210 add_cppflags -D_ISOC99_SOURCE
4211 add_cxxflags -D__STDC_CONSTANT_MACROS
4212 check_cflags -std=c99
4213 check_cc -D_FILE_OFFSET_BITS=64 <<EOF && add_cppflags -D_FILE_OFFSET_BITS=64
4214 #include <stdlib.h>
4215 EOF
4216 check_cc -D_LARGEFILE_SOURCE <<EOF && add_cppflags -D_LARGEFILE_SOURCE
4217 #include <stdlib.h>
4218 EOF
4219
4220 add_host_cppflags -D_ISOC99_SOURCE
4221 check_host_cflags -std=c99
4222 check_host_cflags -Wall
4223 check_host_cflags -O3
4224
4225 check_64bit(){
4226     arch32=$1
4227     arch64=$2
4228     expr=$3
4229     check_code cc "" "int test[2*($expr) - 1]" &&
4230         subarch=$arch64 || subarch=$arch32
4231 }
4232
4233 case "$arch" in
4234     aarch64|alpha|ia64)
4235         spic=$shared
4236     ;;
4237     mips)
4238         check_64bit mips mips64 '_MIPS_SIM > 1'
4239         spic=$shared
4240     ;;
4241     parisc)
4242         check_64bit parisc parisc64 'sizeof(void *) > 4'
4243         spic=$shared
4244     ;;
4245     ppc)
4246         check_64bit ppc ppc64 'sizeof(void *) > 4'
4247         spic=$shared
4248     ;;
4249     s390)
4250         check_64bit s390 s390x 'sizeof(void *) > 4'
4251         spic=$shared
4252     ;;
4253     sparc)
4254         check_64bit sparc sparc64 'sizeof(void *) > 4'
4255         spic=$shared
4256     ;;
4257     x86)
4258         check_64bit x86_32 x86_64 'sizeof(void *) > 4'
4259         # Treat x32 as x64 for now. Note it also needs spic=$shared
4260         test "$subarch" = "x86_32" && check_cpp_condition stddef.h 'defined(__x86_64__)' &&
4261             subarch=x86_64
4262         if test "$subarch" = "x86_64"; then
4263             spic=$shared
4264         fi
4265     ;;
4266     ppc)
4267         check_cc <<EOF && subarch="ppc64"
4268         int test[(int)sizeof(char*) - 7];
4269 EOF
4270     ;;
4271 esac
4272
4273 enable $subarch
4274 enabled spic && enable_weak pic
4275
4276 # OS specific
4277 case $target_os in
4278     aix)
4279         SHFLAGS=-shared
4280         add_cppflags '-I\$(SRC_PATH)/compat/aix'
4281         enabled shared && add_ldflags -Wl,-brtl
4282         ;;
4283     android)
4284         disable symver
4285         enable section_data_rel_ro
4286         SLIB_INSTALL_NAME='$(SLIBNAME)'
4287         SLIB_INSTALL_LINKS=
4288         # soname not set on purpose
4289         SHFLAGS=-shared
4290         ;;
4291     haiku)
4292         prefix_default="/boot/common"
4293         network_extralibs="-lnetwork"
4294         host_libs=
4295         ;;
4296     sunos)
4297         SHFLAGS='-shared -Wl,-h,$$(@F)'
4298         enabled x86 && SHFLAGS="-mimpure-text $SHFLAGS"
4299         network_extralibs="-lsocket -lnsl"
4300         add_cppflags -D__EXTENSIONS__
4301         # When using suncc to build, the Solaris linker will mark
4302         # an executable with each instruction set encountered by
4303         # the Solaris assembler.  As our libraries contain their own
4304         # guards for processor-specific code, instead suppress
4305         # generation of the HWCAPS ELF section on Solaris x86 only.
4306         enabled_all suncc x86 &&
4307             echo "hwcap_1 = OVERRIDE;" > mapfile &&
4308             add_ldflags -Wl,-M,mapfile
4309         nm_default='nm -P -g'
4310         ;;
4311     netbsd)
4312         disable symver
4313         oss_indev_extralibs="-lossaudio"
4314         oss_outdev_extralibs="-lossaudio"
4315         enabled gcc || check_ldflags -Wl,-zmuldefs
4316         ;;
4317     openbsd|bitrig)
4318         disable symver
4319         SHFLAGS='-shared'
4320         SLIB_INSTALL_NAME='$(SLIBNAME).$(LIBMAJOR).$(LIBMINOR)'
4321         SLIB_INSTALL_LINKS=
4322         oss_indev_extralibs="-lossaudio"
4323         oss_outdev_extralibs="-lossaudio"
4324         ;;
4325     dragonfly)
4326         disable symver
4327         ;;
4328     freebsd)
4329         ;;
4330     bsd/os)
4331         add_extralibs -lpoll -lgnugetopt
4332         strip="strip -d"
4333         ;;
4334     darwin)
4335         enabled ppc && add_asflags -force_cpusubtype_ALL
4336         SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR),-current_version,$(LIBVERSION),-compatibility_version,$(LIBMAJOR)'
4337         enabled x86_32 && append SHFLAGS -Wl,-read_only_relocs,suppress
4338         strip="${strip} -x"
4339         add_ldflags -Wl,-dynamic,-search_paths_first
4340         SLIBSUF=".dylib"
4341         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME).$(LIBVERSION)$(SLIBSUF)'
4342         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME).$(LIBMAJOR)$(SLIBSUF)'
4343         objformat="macho"
4344         enabled x86_64 && objformat="macho64"
4345         enabled_any pic shared x86_64 ||
4346             { check_cflags -mdynamic-no-pic && add_asflags -mdynamic-no-pic; }
4347         ;;
4348     mingw32*)
4349         if test $target_os = "mingw32ce"; then
4350             disable network
4351         else
4352             target_os=mingw32
4353         fi
4354         decklink_outdev_extralibs="$decklink_outdev_extralibs -lole32 -loleaut32"
4355         decklink_indev_extralibs="$decklink_indev_extralibs -lole32 -loleaut32"
4356         LIBTARGET=i386
4357         if enabled x86_64; then
4358             LIBTARGET="i386:x86-64"
4359         elif enabled arm; then
4360             LIBTARGET=arm-wince
4361         fi
4362         enabled shared && ! enabled small && check_cmd $windres --version && enable gnu_windres
4363         check_ldflags -Wl,--nxcompat
4364         check_ldflags -Wl,--dynamicbase
4365         enabled x86_32 && check_ldflags -Wl,--large-address-aware
4366         shlibdir_default="$bindir_default"
4367         SLIBPREF=""
4368         SLIBSUF=".dll"
4369         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
4370         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
4371         dlltool="${cross_prefix}dlltool"
4372         if check_cmd lib.exe -list; then
4373             SLIB_EXTRA_CMD=-'sed -e "s/ @[^ ]*//" $$(@:$(SLIBSUF)=.orig.def) > $$(@:$(SLIBSUF)=.def); lib.exe /machine:$(LIBTARGET) /def:$$(@:$(SLIBSUF)=.def) /out:$(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib)'
4374             if enabled x86_64; then
4375                 LIBTARGET=x64
4376             fi
4377         elif check_cmd $dlltool --version; then
4378             SLIB_EXTRA_CMD=-'sed -e "s/ @[^ ]*//" $$(@:$(SLIBSUF)=.orig.def) > $$(@:$(SLIBSUF)=.def); $(DLLTOOL) -m $(LIBTARGET) -d $$(@:$(SLIBSUF)=.def) -l $(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib) -D $(SLIBNAME_WITH_MAJOR)'
4379         fi
4380         SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
4381         SLIB_INSTALL_LINKS=
4382         SLIB_INSTALL_EXTRA_SHLIB='$(SLIBNAME:$(SLIBSUF)=.lib)'
4383         SLIB_INSTALL_EXTRA_LIB='lib$(SLIBNAME:$(SLIBSUF)=.dll.a) $(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.def)'
4384         SHFLAGS='-shared -Wl,--output-def,$$(@:$(SLIBSUF)=.orig.def) -Wl,--out-implib,$(SUBDIR)lib$(SLIBNAME:$(SLIBSUF)=.dll.a) -Wl,--enable-runtime-pseudo-reloc -Wl,--enable-auto-image-base'
4385         objformat="win32"
4386         ranlib=:
4387         enable dos_paths
4388         ;;
4389     win32|win64)
4390         disable symver
4391         if enabled shared; then
4392             # Link to the import library instead of the normal static library
4393             # for shared libs.
4394             LD_LIB='%.lib'
4395             # Cannot build both shared and static libs with MSVC or icl.
4396             disable static
4397         fi
4398         enabled x86_32 && check_ldflags -LARGEADDRESSAWARE
4399         shlibdir_default="$bindir_default"
4400         SLIBPREF=""
4401         SLIBSUF=".dll"
4402         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
4403         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
4404         SLIB_CREATE_DEF_CMD='$(SRC_PATH)/compat/windows/makedef $(SUBDIR)lib$(NAME).ver $(OBJS) > $$(@:$(SLIBSUF)=.def)'
4405         SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
4406         SLIB_INSTALL_LINKS=
4407         SLIB_INSTALL_EXTRA_SHLIB='$(SLIBNAME:$(SLIBSUF)=.lib)'
4408         SLIB_INSTALL_EXTRA_LIB='$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.def)'
4409         SHFLAGS='-dll -def:$$(@:$(SLIBSUF)=.def) -implib:$(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib)'
4410         objformat="win32"
4411         ranlib=:
4412         enable dos_paths
4413         ;;
4414     cygwin*)
4415         target_os=cygwin
4416         shlibdir_default="$bindir_default"
4417         SLIBPREF="cyg"
4418         SLIBSUF=".dll"
4419         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
4420         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
4421         SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
4422         SLIB_INSTALL_LINKS=
4423         SLIB_INSTALL_EXTRA_LIB='lib$(FULLNAME).dll.a'
4424         SHFLAGS='-shared -Wl,--out-implib,$(SUBDIR)lib$(FULLNAME).dll.a'
4425         objformat="win32"
4426         enable dos_paths
4427         enabled shared && ! enabled small && check_cmd $windres --version && enable gnu_windres
4428         ;;
4429     *-dos|freedos|opendos)
4430         network_extralibs="-lsocket"
4431         objformat="coff"
4432         enable dos_paths
4433         add_cppflags -U__STRICT_ANSI__
4434         ;;
4435     linux)
4436         enable dv1394
4437         enable section_data_rel_ro
4438         ;;
4439     irix*)
4440         target_os=irix
4441         ranlib="echo ignoring ranlib"
4442         ;;
4443     os/2*)
4444         strip="lxlite -CS"
4445         ln_s="cp -f"
4446         objformat="aout"
4447         add_cppflags -D_GNU_SOURCE
4448         add_ldflags -Zomf -Zbin-files -Zargs-wild -Zmap
4449         SHFLAGS='$(SUBDIR)$(NAME).def -Zdll -Zomf'
4450         LIBSUF="_s.a"
4451         SLIBPREF=""
4452         SLIBSUF=".dll"
4453         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
4454         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(shell echo $(NAME) | cut -c1-6)$(LIBMAJOR)$(SLIBSUF)'
4455         SLIB_CREATE_DEF_CMD='echo LIBRARY $(SLIBNAME_WITH_MAJOR) INITINSTANCE TERMINSTANCE > $(SUBDIR)$(NAME).def; \
4456             echo CODE PRELOAD MOVEABLE DISCARDABLE >> $(SUBDIR)$(NAME).def; \
4457             echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $(SUBDIR)$(NAME).def; \
4458             echo EXPORTS >> $(SUBDIR)$(NAME).def; \
4459             emxexp $(OBJS) >> $(SUBDIR)$(NAME).def'
4460         SLIB_EXTRA_CMD='emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(NAME).def; \
4461             emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib $(SUBDIR)$(NAME).def;'
4462         SLIB_INSTALL_EXTRA_LIB='$(LIBPREF)$(NAME)_dll.a $(LIBPREF)$(NAME)_dll.lib'
4463         enable dos_paths
4464         enable_weak os2threads
4465         ;;
4466     gnu/kfreebsd)
4467         add_cppflags -D_BSD_SOURCE
4468         ;;
4469     gnu)
4470         ;;
4471     qnx)
4472         add_cppflags -D_QNX_SOURCE
4473         network_extralibs="-lsocket"
4474         ;;
4475     symbian)
4476         SLIBSUF=".dll"
4477         enable dos_paths
4478         add_cflags --include=$sysinclude/gcce/gcce.h -fvisibility=default
4479         add_cppflags -D__GCCE__ -D__SYMBIAN32__ -DSYMBIAN_OE_POSIX_SIGNALS
4480         add_ldflags -Wl,--target1-abs,--no-undefined \
4481                     -Wl,-Ttext,0x80000,-Tdata,0x1000000 -shared \
4482                     -Wl,--entry=_E32Startup -Wl,-u,_E32Startup
4483         add_extralibs -l:eexe.lib -l:usrt2_2.lib -l:dfpaeabi.dso \
4484                       -l:drtaeabi.dso -l:scppnwdl.dso -lsupc++ -lgcc \
4485                       -l:libc.dso -l:libm.dso -l:euser.dso -l:libcrt0.lib
4486         ;;
4487     osf1)
4488         add_cppflags -D_OSF_SOURCE -D_POSIX_PII -D_REENTRANT
4489         ;;
4490     minix)
4491         ;;
4492     plan9)
4493         add_cppflags -D_C99_SNPRINTF_EXTENSION  \
4494                      -D_REENTRANT_SOURCE        \
4495                      -D_RESEARCH_SOURCE         \
4496                      -DFD_SETSIZE=96            \
4497                      -DHAVE_SOCK_OPTS
4498         add_compat strtod.o strtod=avpriv_strtod
4499         network_extralibs='-lbsd'
4500         exeobjs=compat/plan9/main.o
4501         disable ffserver
4502         cp_f='cp'
4503         ;;
4504     none)
4505         ;;
4506     *)
4507         die "Unknown OS '$target_os'."
4508         ;;
4509 esac
4510
4511 # determine libc flavour
4512
4513 probe_libc(){
4514     pfx=$1
4515     pfx_no_=${pfx%_}
4516     # uclibc defines __GLIBC__, so it needs to be checked before glibc.
4517     if check_${pfx}cpp_condition features.h "defined __UCLIBC__"; then
4518         eval ${pfx}libc_type=uclibc
4519         add_${pfx}cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
4520     elif check_${pfx}cpp_condition features.h "defined __GLIBC__"; then
4521         eval ${pfx}libc_type=glibc
4522         add_${pfx}cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
4523     # MinGW headers can be installed on Cygwin, so check for newlib first.
4524     elif check_${pfx}cpp_condition newlib.h "defined _NEWLIB_VERSION"; then
4525         eval ${pfx}libc_type=newlib
4526         add_${pfx}cppflags -U__STRICT_ANSI__
4527     # MinGW64 is backwards compatible with MinGW32, so check for it first.
4528     elif check_${pfx}cpp_condition _mingw.h "defined __MINGW64_VERSION_MAJOR"; then
4529         eval ${pfx}libc_type=mingw64
4530         if check_${pfx}cpp_condition _mingw.h "__MINGW64_VERSION_MAJOR < 3"; then
4531             add_compat msvcrt/snprintf.o
4532             add_cflags "-include $source_path/compat/msvcrt/snprintf.h"
4533         fi
4534         add_${pfx}cppflags -U__STRICT_ANSI__ -D__USE_MINGW_ANSI_STDIO=1
4535         eval test \$${pfx_no_}cc_type = "gcc" &&
4536             add_${pfx}cppflags -D__printf__=__gnu_printf__
4537     elif check_${pfx}cpp_condition _mingw.h "defined __MINGW_VERSION"  ||
4538          check_${pfx}cpp_condition _mingw.h "defined __MINGW32_VERSION"; then
4539         eval ${pfx}libc_type=mingw32
4540         check_${pfx}cpp_condition _mingw.h "__MINGW32_MAJOR_VERSION > 3 || \
4541             (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" ||
4542             die "ERROR: MinGW32 runtime version must be >= 3.15."
4543         add_${pfx}cppflags -U__STRICT_ANSI__ -D__USE_MINGW_ANSI_STDIO=1
4544         eval test \$${pfx_no_}cc_type = "gcc" &&
4545             add_${pfx}cppflags -D__printf__=__gnu_printf__
4546     elif check_${pfx}cpp_condition crtversion.h "defined _VC_CRT_MAJOR_VERSION"; then
4547         eval ${pfx}libc_type=msvcrt
4548         if check_${pfx}cpp_condition crtversion.h "_VC_CRT_MAJOR_VERSION < 14"; then
4549             if [ "$pfx" = host_ ]; then
4550                 add_host_cppflags -Dsnprintf=_snprintf
4551             else
4552                 add_compat strtod.o strtod=avpriv_strtod
4553                 add_compat msvcrt/snprintf.o snprintf=avpriv_snprintf   \
4554                                              _snprintf=avpriv_snprintf  \
4555                                              vsnprintf=avpriv_vsnprintf
4556             fi
4557         fi
4558         # The MSVC 2010 headers (Win 7.0 SDK) set _WIN32_WINNT to
4559         # 0x601 by default unless something else is set by the user.
4560         # This can easily lead to us detecting functions only present
4561         # in such new versions and producing binaries requiring windows 7.0.
4562         # Therefore explicitly set the default to XP unless the user has
4563         # set something else on the command line.
4564         # Don't do this if WINAPI_FAMILY is set and is set to a non-desktop
4565         # family. For these cases, configure is free to use any functions
4566         # found in the SDK headers by default. (Alternatively, we could force
4567         # _WIN32_WINNT to 0x0602 in that case.)
4568         check_${pfx}cpp_condition stdlib.h "defined(_WIN32_WINNT)" ||
4569             { check_${pfx}cpp <<EOF && add_${pfx}cppflags -D_WIN32_WINNT=0x0502; }
4570 #ifdef WINAPI_FAMILY
4571 #include <winapifamily.h>
4572 #if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
4573 #error not desktop
4574 #endif
4575 #endif
4576 EOF
4577     elif check_${pfx}cpp_condition stddef.h "defined __KLIBC__"; then
4578         eval ${pfx}libc_type=klibc
4579     elif check_${pfx}cpp_condition sys/cdefs.h "defined __BIONIC__"; then
4580         eval ${pfx}libc_type=bionic
4581     elif check_${pfx}cpp_condition sys/brand.h "defined LABELED_BRAND_NAME"; then
4582         eval ${pfx}libc_type=solaris
4583         add_${pfx}cppflags -D__EXTENSIONS__ -D_XOPEN_SOURCE=600
4584     fi
4585     check_${pfx}cc <<EOF
4586 #include <time.h>
4587 void *v = localtime_r;
4588 EOF
4589 test "$?" != 0 && check_${pfx}cc -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 <<EOF && add_${pfx}cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
4590 #include <time.h>
4591 void *v = localtime_r;
4592 EOF
4593
4594 }
4595
4596 probe_libc
4597 test -n "$libc_type" && enable libc_$libc_type
4598 probe_libc host_
4599 test -n "$host_libc_type" && enable host_libc_$host_libc_type
4600
4601 case $libc_type in
4602     bionic)
4603         add_compat strtod.o strtod=avpriv_strtod
4604         ;;
4605 esac
4606
4607 # hacks for compiler/libc/os combinations
4608
4609 if enabled_all tms470 libc_glibc; then
4610     CPPFLAGS="-I${source_path}/compat/tms470 ${CPPFLAGS}"
4611     add_cppflags -D__USER_LABEL_PREFIX__=
4612     add_cppflags -D__builtin_memset=memset
4613     add_cppflags -D__gnuc_va_list=va_list -D_VA_LIST_DEFINED
4614     add_cflags   -pds=48    # incompatible redefinition of macro
4615 fi
4616
4617 if enabled_all ccc libc_glibc; then
4618     add_ldflags -Wl,-z,now  # calls to libots crash without this
4619 fi
4620
4621 check_compile_assert flt_lim "float.h limits.h" "DBL_MAX == (double)DBL_MAX" ||
4622     add_cppflags '-I\$(SRC_PATH)/compat/float'
4623
4624 esc(){
4625     echo "$*" | sed 's/%/%25/g;s/:/%3a/g'
4626 }
4627
4628 echo "config:$arch:$subarch:$cpu:$target_os:$(esc $cc_ident):$(esc $FFMPEG_CONFIGURATION)" >config.fate
4629
4630 check_cpp_condition stdlib.h "defined(__PIC__) || defined(__pic__) || defined(PIC)" && enable_weak pic
4631
4632 set_default libdir
4633 : ${shlibdir_default:="$libdir"}
4634 : ${pkgconfigdir_default:="$libdir/pkgconfig"}
4635
4636 set_default $PATHS_LIST
4637 set_default nm
4638
4639 # we need to build at least one lib type
4640 if ! enabled_any static shared; then
4641     cat <<EOF
4642 At least one library type must be built.
4643 Specify --enable-static to build the static libraries or --enable-shared to
4644 build the shared libraries as well. To only build the shared libraries specify
4645 --disable-static in addition to --enable-shared.
4646 EOF
4647     exit 1;
4648 fi
4649
4650 die_license_disabled() {
4651     enabled $1 || { enabled $2 && die "$2 is $1 and --enable-$1 is not specified."; }
4652 }
4653
4654 die_license_disabled_gpl() {
4655     enabled $1 || { enabled $2 && die "$2 is incompatible with the gpl and --enable-$1 is not specified."; }
4656 }
4657
4658 die_license_disabled gpl frei0r
4659 die_license_disabled gpl libcdio
4660 die_license_disabled gpl libsmbclient
4661 die_license_disabled gpl libutvideo
4662 die_license_disabled gpl libvidstab
4663 die_license_disabled gpl libx264
4664 die_license_disabled gpl libx265
4665 die_license_disabled gpl libxavs
4666 die_license_disabled gpl libxvid
4667 die_license_disabled gpl libzvbi
4668 die_license_disabled gpl x11grab
4669
4670 die_license_disabled nonfree libaacplus
4671 die_license_disabled nonfree libfaac
4672 die_license_disabled nonfree nvenc
4673 enabled gpl && die_license_disabled_gpl nonfree libfdk_aac
4674 enabled gpl && die_license_disabled_gpl nonfree openssl
4675
4676 die_license_disabled version3 libopencore_amrnb
4677 die_license_disabled version3 libopencore_amrwb
4678 die_license_disabled version3 libsmbclient
4679 die_license_disabled version3 libvo_aacenc
4680 die_license_disabled version3 libvo_amrwbenc
4681
4682 enabled version3 && { enabled gpl && enable gplv3 || enable lgplv3; }
4683
4684 disabled optimizations || check_cflags -fomit-frame-pointer
4685
4686 enable_weak_pic() {
4687     disabled pic && return
4688     enable pic
4689     add_cppflags -DPIC
4690     case "$target_os" in
4691     mingw*|cygwin*)
4692         ;;
4693     *)
4694         add_cflags -fPIC
4695         ;;
4696     esac
4697     add_asflags  -fPIC
4698 }
4699
4700 enabled pic && enable_weak_pic
4701
4702 check_cc <<EOF || die "Symbol mangling check failed."
4703 int ff_extern;
4704 EOF
4705 sym=$($nm $TMPO | awk '/ff_extern/{ print substr($0, match($0, /[^ \t]*ff_extern/)) }')
4706 extern_prefix=${sym%%ff_extern*}
4707
4708 check_cc <<EOF && enable_weak inline_asm
4709 void foo(void) { __asm__ volatile ("" ::); }
4710 EOF
4711
4712 _restrict=
4713 for restrict_keyword in restrict __restrict__ __restrict; do
4714     check_cc <<EOF && _restrict=$restrict_keyword && break
4715 void foo(char * $restrict_keyword p);
4716 EOF
4717 done
4718
4719 check_cc <<EOF && enable pragma_deprecated
4720 void foo(void) { _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") }
4721 EOF
4722
4723 check_cc <<EOF && enable attribute_packed
4724 struct { int x; } __attribute__((packed)) x;
4725 EOF
4726
4727 check_cc <<EOF && enable attribute_may_alias
4728 union { int x; } __attribute__((may_alias)) x;
4729 EOF
4730
4731 check_cc <<EOF || die "endian test failed"
4732 unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
4733 EOF
4734 od -t x1 $TMPO | grep -q '42 *49 *47 *45' && enable bigendian
4735
4736 if ! enabled ppc64 || enabled bigendian; then
4737     disable vsx
4738 fi
4739
4740 check_gas() {
4741     log "check_gas using '$as' as AS"
4742     # :vararg is used on aarch64, arm and ppc altivec
4743     check_as <<EOF || return 1
4744 .macro m n, y:vararg=0
4745 \n: .int \y
4746 .endm
4747 m x
4748 EOF
4749     # .altmacro is only used in arm asm
4750     ! enabled arm || check_as <<EOF || return 1
4751 .altmacro
4752 EOF
4753     enable gnu_as
4754     return 0
4755 }
4756
4757 if enabled_any arm aarch64 || enabled_all ppc altivec && enabled asm; then
4758     nogas=:
4759     enabled_any arm aarch64 && nogas=die
4760     enabled_all ppc altivec && [ $target_os_default != aix ] && nogas=warn
4761     as_noop=-v
4762
4763     case $as_type in
4764         arm*) gaspp_as_type=armasm; as_noop=-h ;;
4765         gcc)  gaspp_as_type=gas ;;
4766         *)    gaspp_as_type=$as_type ;;
4767     esac
4768
4769     [ $target_os = "darwin" ] && gaspp_as_type="apple-$gaspp_as_type"
4770
4771     test "${as#*gas-preprocessor.pl}" != "$as" ||
4772     check_cmd gas-preprocessor.pl -arch $arch -as-type $gaspp_as_type -- ${as:=$cc} $as_noop &&
4773         gas="${gas:=gas-preprocessor.pl} -arch $arch -as-type $gaspp_as_type -- ${as:=$cc}"
4774
4775     if ! check_gas ; then
4776         as=${gas:=$as}
4777         check_gas || \
4778             $nogas "GNU assembler not found, install/update gas-preprocessor"
4779     fi
4780
4781     check_as <<EOF && enable as_func
4782 .func test
4783 .endfunc
4784 EOF
4785 fi
4786
4787 check_inline_asm inline_asm_labels '"1:\n"'
4788
4789 check_inline_asm inline_asm_nonlocal_labels '"Label:\n"'
4790
4791 if enabled aarch64; then
4792     enabled armv8 && check_insn armv8 'prfm   pldl1strm, [x0]'
4793     # internal assembler in clang 3.3 does not support this instruction
4794     enabled neon && check_insn neon 'ext   v0.8B, v0.8B, v1.8B, #1'
4795     enabled vfp  && check_insn vfp  'fmadd d0,    d0,    d1,    d2'
4796
4797     map 'enabled_any ${v}_external ${v}_inline || disable $v' $ARCH_EXT_LIST_ARM
4798
4799 elif enabled alpha; then
4800
4801     check_cflags -mieee
4802
4803 elif enabled arm; then
4804
4805     enabled msvc && check_cpp_condition stddef.h "defined _M_ARMT" && enable thumb
4806
4807     check_cpp_condition stddef.h "defined __thumb__" && check_cc <<EOF && enable_weak thumb
4808 float func(float a, float b){ return a+b; }
4809 EOF
4810
4811     enabled thumb && check_cflags -mthumb || check_cflags -marm
4812
4813     if     check_cpp_condition stddef.h "defined __ARM_PCS_VFP"; then
4814         enable vfp_args
4815     elif check_cpp_condition stddef.h "defined _M_ARM_FP && _M_ARM_FP >= 30"; then
4816         enable vfp_args
4817     elif ! check_cpp_condition stddef.h "defined __ARM_PCS || defined __SOFTFP__" && [ $target_os != darwin ]; then
4818         case "${cross_prefix:-$cc}" in
4819             *hardfloat*)         enable vfp_args;   fpabi=vfp ;;
4820             *) check_ld "cc" <<EOF && enable vfp_args && fpabi=vfp || fpabi=soft ;;
4821 __asm__ (".eabi_attribute 28, 1");
4822 int main(void) { return 0; }
4823 EOF
4824         esac
4825         warn "Compiler does not indicate floating-point ABI, guessing $fpabi."
4826     fi
4827
4828     enabled armv5te && check_insn armv5te 'qadd r0, r0, r0'
4829     enabled armv6   && check_insn armv6   'sadd16 r0, r0, r0'
4830     enabled armv6t2 && check_insn armv6t2 'movt r0, #0'
4831     enabled neon    && check_insn neon    'vadd.i16 q0, q0, q0'
4832     enabled vfp     && check_insn vfp     'fadds s0, s0, s0'
4833     enabled vfpv3   && check_insn vfpv3   'vmov.f32 s0, #1.0'
4834     enabled setend  && check_insn setend  'setend be'
4835
4836     [ $target_os = linux ] || [ $target_os = android ] ||
4837         map 'enabled_any ${v}_external ${v}_inline || disable $v' \
4838             $ARCH_EXT_LIST_ARM
4839
4840     check_inline_asm asm_mod_q '"add r0, %Q0, %R0" :: "r"((long long)0)'
4841
4842     check_as <<EOF && enable as_dn_directive
4843 ra .dn d0.i16
4844 .unreq ra
4845 EOF
4846
4847     # llvm's integrated assembler supports .object_arch from llvm 3.5
4848     [ "$objformat" = elf ] && check_as <<EOF && enable as_object_arch
4849 .object_arch armv4
4850 EOF
4851
4852     [ $target_os != win32 ] && enabled_all armv6t2 shared !pic && enable_weak_pic
4853
4854 elif enabled mips; then
4855
4856     enabled loongson2 && check_inline_asm loongson2 '"dmult.g $8, $9, $10"'
4857     enabled loongson3 && check_inline_asm loongson3 '"gsldxc1 $f0, 0($2, $3)"'
4858     enabled mmi && check_inline_asm mmi '"punpcklhw $f0, $f0, $f0"'
4859
4860     # Enable minimum ISA based on selected options
4861     if enabled mips64 && (enabled mipsdspr1 || enabled mipsdspr2); then
4862         add_cflags "-mips64r2"
4863         add_asflags "-mips64r2"
4864     elif enabled mips64 && enabled mipsfpu && disabled loongson2 && disabled loongson3; then
4865         add_cflags "-mips64"
4866         add_asflags "-mips64"
4867     elif enabled mipsdspr1 || enabled mipsdspr2; then
4868         add_cflags "-mips32r2 -mfp32"
4869         add_asflags "-mips32r2 -mfp32"
4870     elif enabled mips32r5 || enabled mips64r6; then
4871         check_cflags "-mfp64"
4872         check_ldflags "-mfp64"
4873     fi
4874
4875     enabled mips32r5  && check_cflags "-mips32r5 -msched-weight -mload-store-pairs -funroll-loops" &&
4876      check_ldflags "-mips32r5" &&
4877      check_inline_asm mips32r5  '"ulw $t0, ($t1)"'
4878     enabled mips64r6  && check_cflags "-mips64r6 -msched-weight -mload-store-pairs -funroll-loops" &&
4879      check_ldflags "-mips64r6" &&
4880      check_inline_asm mips64r6  '"aui $t0, $t1, 1"'
4881     enabled mipsdspr1 && add_cflags "-mdsp" && add_asflags "-mdsp" &&
4882      check_inline_asm mipsdspr1 '"addu.qb $t0, $t1, $t2"'
4883     enabled mipsdspr2 && add_cflags "-mdspr2" && add_asflags "-mdspr2" &&
4884      check_inline_asm mipsdspr2 '"absq_s.qb $t0, $t1"'
4885     enabled mipsfpu   && add_cflags "-mhard-float" && add_asflags "-mhard-float" &&
4886      check_inline_asm mipsfpu   '"madd.d $f0, $f2, $f4, $f6"'
4887     enabled msa       && check_cflags "-mmsa" && check_ldflags "-mmsa" &&
4888      check_inline_asm msa       '"addvi.b $w0, $w1, 1"'
4889
4890     enabled mips32r5 && add_asflags "-mips32r5 -mfp64"
4891     enabled mips64r6 && add_asflags "-mips64r6 -mfp64"
4892     enabled msa && add_asflags "-mmsa"
4893
4894 elif enabled parisc; then
4895
4896     if enabled gcc; then
4897         case $($cc -dumpversion) in
4898             4.[3-9].*) check_cflags -fno-optimize-sibling-calls ;;
4899         esac
4900     fi
4901
4902 elif enabled ppc; then
4903
4904     enable local_aligned_8 local_aligned_16 local_aligned_32
4905
4906     check_inline_asm dcbzl     '"dcbzl 0, %0" :: "r"(0)'
4907     check_inline_asm ibm_asm   '"add 0, 0, 0"'
4908     check_inline_asm ppc4xx    '"maclhw r10, r11, r12"'
4909     check_inline_asm xform_asm '"lwzx %1, %y0" :: "Z"(*(int*)0), "r"(0)'
4910
4911     # AltiVec flags: The FSF version of GCC differs from the Apple version
4912     if enabled altivec; then
4913         check_cflags -maltivec -mabi=altivec &&
4914         { check_header altivec.h && inc_altivec_h="#include <altivec.h>" ; } ||
4915         check_cflags -faltivec
4916
4917         # check if our compiler supports Motorola AltiVec C API
4918         check_cc <<EOF || disable altivec
4919 $inc_altivec_h
4920 int main(void) {
4921     vector signed int v1 = (vector signed int) { 0 };
4922     vector signed int v2 = (vector signed int) { 1 };
4923     v1 = vec_add(v1, v2);
4924     return 0;
4925 }
4926 EOF
4927
4928         enabled altivec || warn "Altivec disabled, possibly missing --cpu flag"
4929     fi
4930
4931     if enabled vsx; then
4932         check_cflags -mvsx &&
4933         check_builtin vec_vsx_ld "altivec.h" "__builtin_vec_vsx_ld" || disable vsx
4934     fi
4935
4936     if enabled power8; then
4937         check_cpp_condition "altivec.h" "defined(_ARCH_PWR8)" || disable power8
4938     fi
4939
4940 elif enabled x86; then
4941
4942     check_builtin rdtsc    intrin.h   "__rdtsc()"
4943     check_builtin mm_empty mmintrin.h "_mm_empty()"
4944
4945     enable local_aligned_8 local_aligned_16 local_aligned_32
4946
4947     # check whether EBP is available on x86
4948     # As 'i' is stored on the stack, this program will crash
4949     # if the base pointer is used to access it because the
4950     # base pointer is cleared in the inline assembly code.
4951     check_exec_crash <<EOF && enable ebp_available
4952 volatile int i=0;
4953 __asm__ volatile ("xorl %%ebp, %%ebp" ::: "%ebp");
4954 return i;
4955 EOF
4956
4957     # check whether EBX is available on x86
4958     check_inline_asm ebx_available '""::"b"(0)' &&
4959         check_inline_asm ebx_available '"":::"%ebx"'
4960
4961     # check whether xmm clobbers are supported
4962     check_inline_asm xmm_clobbers '"":::"%xmm0"'
4963
4964     check_inline_asm inline_asm_direct_symbol_refs '"movl '$extern_prefix'test, %eax"' ||
4965         check_inline_asm inline_asm_direct_symbol_refs '"movl '$extern_prefix'test(%rip), %eax"'
4966
4967     # check whether binutils is new enough to compile SSSE3/MMXEXT
4968     enabled ssse3  && check_inline_asm ssse3_inline  '"pabsw %xmm0, %xmm0"'
4969     enabled mmxext && check_inline_asm mmxext_inline '"pmaxub %mm0, %mm1"'
4970
4971     if ! disabled_any asm mmx yasm; then
4972         if check_cmd $yasmexe --version; then
4973             enabled x86_64 && yasm_extra="-m amd64"
4974             yasm_debug="-g dwarf2"
4975         elif check_cmd nasm -v; then
4976             yasmexe=nasm
4977             yasm_debug="-g -F dwarf"
4978             if enabled x86_64; then
4979                 case "$objformat" in
4980                     elf)   objformat=elf64 ;;
4981                     win32) objformat=win64 ;;
4982                 esac
4983             fi
4984         fi
4985
4986         YASMFLAGS="-f $objformat $yasm_extra"
4987         enabled pic               && append YASMFLAGS "-DPIC"
4988         test -n "$extern_prefix"  && append YASMFLAGS "-DPREFIX"
4989         case "$objformat" in
4990             elf*) enabled debug && append YASMFLAGS $yasm_debug ;;
4991         esac
4992
4993         check_yasm "movbe ecx, [5]" && enable yasm ||
4994             die "yasm/nasm not found or too old. Use --disable-yasm for a crippled build."
4995         check_yasm "vextracti128 xmm0, ymm0, 0"      || disable avx2_external
4996         check_yasm "vpmacsdd xmm0, xmm1, xmm2, xmm3" || disable xop_external
4997         check_yasm "vfmaddps ymm0, ymm1, ymm2, ymm3" || disable fma4_external
4998         check_yasm "CPU amdnop" || disable cpunop
4999     fi
5000
5001     case "$cpu" in
5002         athlon*|opteron*|k8*|pentium|pentium-mmx|prescott|nocona|atom|geode)
5003             disable fast_clz
5004         ;;
5005     esac
5006
5007 fi
5008
5009 check_code cc arm_neon.h "int16x8_t test = vdupq_n_s16(0)" && enable intrinsics_neon
5010
5011 check_ldflags -Wl,--as-needed
5012 check_ldflags -Wl,-z,noexecstack
5013
5014 if check_func dlopen; then
5015     ldl=
5016 elif check_func dlopen -ldl; then
5017     ldl=-ldl
5018 fi
5019
5020 frei0r_filter_extralibs='$ldl'
5021 frei0r_src_filter_extralibs='$ldl'
5022 ladspa_filter_extralibs='$ldl'
5023 nvenc_encoder_extralibs='$ldl'
5024
5025 if ! disabled network; then
5026     check_func getaddrinfo $network_extralibs
5027     check_func getservbyport $network_extralibs
5028     check_func inet_aton $network_extralibs
5029
5030     check_type netdb.h "struct addrinfo"
5031     check_type netinet/in.h "struct group_source_req" -D_BSD_SOURCE
5032     check_type netinet/in.h "struct ip_mreq_source" -D_BSD_SOURCE
5033     check_type netinet/in.h "struct ipv6_mreq" -D_DARWIN_C_SOURCE
5034     check_type poll.h "struct pollfd"
5035     check_type netinet/sctp.h "struct sctp_event_subscribe"
5036     check_struct "sys/types.h sys/socket.h" "struct sockaddr" sa_len
5037     check_type netinet/in.h "struct sockaddr_in6"
5038     check_type "sys/types.h sys/socket.h" "struct sockaddr_storage"
5039     check_type "sys/types.h sys/socket.h" socklen_t
5040
5041     # Prefer arpa/inet.h over winsock2
5042     if check_header arpa/inet.h ; then
5043         check_func closesocket
5044     elif check_header winsock2.h ; then
5045         check_func_headers winsock2.h closesocket -lws2 &&
5046             network_extralibs="-lws2" ||
5047         { check_func_headers winsock2.h closesocket -lws2_32 &&
5048             network_extralibs="-lws2_32"; } || disable winsock2_h network
5049         check_func_headers ws2tcpip.h getaddrinfo $network_extralibs
5050
5051         check_type ws2tcpip.h socklen_t
5052         check_type ws2tcpip.h "struct addrinfo"
5053         check_type ws2tcpip.h "struct group_source_req"
5054         check_type ws2tcpip.h "struct ip_mreq_source"
5055         check_type ws2tcpip.h "struct ipv6_mreq"
5056         check_type winsock2.h "struct pollfd"
5057         check_struct winsock2.h "struct sockaddr" sa_len
5058         check_type ws2tcpip.h "struct sockaddr_in6"
5059         check_type ws2tcpip.h "struct sockaddr_storage"
5060     else
5061         disable network
5062     fi
5063 fi
5064
5065 check_builtin atomic_cas_ptr atomic.h "void **ptr; void *oldval, *newval; atomic_cas_ptr(ptr, oldval, newval)"
5066 check_builtin atomic_compare_exchange "" "int *ptr, *oldval; int newval; __atomic_compare_exchange_n(ptr, oldval, newval, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)"
5067 check_builtin machine_rw_barrier mbarrier.h "__machine_rw_barrier()"
5068 check_builtin MemoryBarrier windows.h "MemoryBarrier()"
5069 check_builtin sarestart signal.h "SA_RESTART"
5070 check_builtin sync_val_compare_and_swap "" "int *ptr; int oldval, newval; __sync_val_compare_and_swap(ptr, oldval, newval)"
5071 check_builtin gmtime_r time.h "time_t *time; struct tm *tm; gmtime_r(time, tm)"
5072 check_builtin localtime_r time.h "time_t *time; struct tm *tm; localtime_r(time, tm)"
5073
5074 check_func_headers malloc.h _aligned_malloc     && enable aligned_malloc
5075 check_func  ${malloc_prefix}memalign            && enable memalign
5076 check_func  ${malloc_prefix}posix_memalign      && enable posix_memalign
5077
5078 check_func  access
5079 check_func_headers time.h clock_gettime || { check_func_headers time.h clock_gettime -lrt && add_extralibs -lrt && LIBRT="-lrt"; }
5080 check_func  fcntl
5081 check_func  fork
5082 check_func  gethrtime
5083 check_func  getopt
5084 check_func  getrusage
5085 check_func  gettimeofday
5086 check_func  isatty
5087 check_func  mach_absolute_time
5088 check_func  mkstemp
5089 check_func  mmap
5090 check_func  mprotect
5091 # Solaris has nanosleep in -lrt, OpenSolaris no longer needs that
5092 check_func_headers time.h nanosleep || { check_func_headers time.h nanosleep -lrt && add_extralibs -lrt && LIBRT="-lrt"; }
5093 check_func  sched_getaffinity
5094 check_func  setrlimit
5095 check_struct "sys/stat.h" "struct stat" st_mtim.tv_nsec -D_BSD_SOURCE
5096 check_func  strerror_r
5097 check_func  sysconf
5098 check_func  sysctl
5099 check_func  usleep
5100
5101 check_func_headers conio.h kbhit
5102 check_func_headers io.h setmode
5103 check_func_headers lzo/lzo1x.h lzo1x_999_compress
5104 check_func_headers stdlib.h getenv
5105 check_func_headers sys/stat.h lstat
5106
5107 check_func_headers windows.h CoTaskMemFree -lole32
5108 check_func_headers windows.h GetProcessAffinityMask
5109 check_func_headers windows.h GetProcessTimes
5110 check_func_headers windows.h GetSystemTimeAsFileTime
5111 check_func_headers windows.h MapViewOfFile
5112 check_func_headers windows.h PeekNamedPipe
5113 check_func_headers windows.h SetConsoleTextAttribute
5114 check_func_headers windows.h SetConsoleCtrlHandler
5115 check_func_headers windows.h Sleep
5116 check_func_headers windows.h VirtualAlloc
5117 check_struct windows.h "CONDITION_VARIABLE" Ptr
5118 check_func_headers glob.h glob
5119 enabled xlib &&
5120     check_func_headers "X11/Xlib.h X11/extensions/Xvlib.h" XvGetPortAttribute -lXv -lX11 -lXext
5121
5122 check_header CoreServices/CoreServices.h
5123 check_header direct.h
5124 check_header dirent.h
5125 check_header dlfcn.h
5126 check_header d3d11.h
5127 check_header dxva.h
5128 check_header dxva2api.h -D_WIN32_WINNT=0x0600
5129 check_header io.h
5130 check_header libcrystalhd/libcrystalhd_if.h
5131 check_header mach/mach_time.h
5132 check_header malloc.h
5133 check_header net/udplite.h
5134 check_header poll.h
5135 check_header sys/mman.h
5136 check_header sys/param.h
5137 check_header sys/resource.h
5138 check_header sys/select.h
5139 check_header sys/time.h
5140 check_header sys/un.h
5141 check_header termios.h
5142 check_header unistd.h
5143 check_header valgrind/valgrind.h
5144 check_header vdpau/vdpau.h
5145 check_header vdpau/vdpau_x11.h
5146 check_header VideoDecodeAcceleration/VDADecoder.h
5147 check_header VideoToolbox/VideoToolbox.h
5148 check_header windows.h
5149 check_header X11/extensions/XvMClib.h
5150 check_header asm/types.h
5151
5152 check_lib2 "windows.h shellapi.h" CommandLineToArgvW -lshell32
5153 check_lib2 "windows.h wincrypt.h" CryptGenRandom -ladvapi32
5154 check_lib2 "windows.h psapi.h" GetProcessMemoryInfo -lpsapi
5155
5156 check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss
5157
5158 check_type "windows.h dxva.h" "DXVA_PicParams_HEVC" -DWINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP -D_CRT_BUILD_DESKTOP_APP=0
5159 check_type "windows.h d3d11.h" "ID3D11VideoDecoder"
5160 check_type "d3d9.h dxva2api.h" DXVA2_ConfigPictureDecode -D_WIN32_WINNT=0x0602
5161
5162 check_type "va/va.h" "VAPictureParameterBufferHEVC"
5163
5164 check_type "vdpau/vdpau.h" "VdpPictureInfoHEVC"
5165
5166 if ! disabled w32threads && ! enabled pthreads; then
5167     check_func_headers "windows.h process.h" _beginthreadex &&
5168         enable w32threads || disable w32threads
5169 fi
5170
5171 # check for some common methods of building with pthread support
5172 # do this before the optional library checks as some of them require pthreads
5173 if ! disabled pthreads && ! enabled w32threads && ! enabled os2threads; then
5174     enable pthreads
5175     if check_func pthread_join -pthread && check_func pthread_create -pthread; then
5176         add_cflags -pthread
5177         add_extralibs -pthread
5178     elif check_func pthread_join -pthreads && check_func pthread_create -pthreads; then
5179         add_cflags -pthreads
5180         add_extralibs -pthreads
5181     elif check_func pthread_join -ldl -pthread && check_func pthread_create -ldl -pthread; then
5182         add_cflags -ldl -pthread
5183         add_extralibs -ldl -pthread
5184     elif check_func pthread_join -lpthreadGC2 && check_func pthread_create -lpthreadGC2; then
5185         add_extralibs -lpthreadGC2
5186     elif check_lib pthread.h pthread_join -lpthread && check_lib pthread.h pthread_create -lpthread; then
5187         :
5188     elif ! check_func pthread_join && ! check_func pthread_create; then
5189         disable pthreads
5190     fi
5191     check_code cc "pthread.h" "static pthread_mutex_t atomic_lock = PTHREAD_MUTEX_INITIALIZER" || disable pthreads
5192 fi
5193
5194
5195 if enabled pthreads; then
5196   check_func pthread_cancel
5197 fi
5198
5199 disabled  zlib || check_lib   zlib.h      zlibVersion -lz   || disable  zlib
5200 disabled bzlib || check_lib2 bzlib.h BZ2_bzlibVersion -lbz2 || disable bzlib
5201 disabled  lzma || check_lib2  lzma.h lzma_version_number -llzma || disable lzma
5202
5203 check_lib math.h sin -lm && LIBM="-lm"
5204 disabled crystalhd || check_lib libcrystalhd/libcrystalhd_if.h DtsCrystalHDVersion -lcrystalhd || disable crystalhd
5205
5206 atan2f_args=2
5207 copysign_args=2
5208 ldexpf_args=2
5209 powf_args=2
5210
5211 for func in $MATH_FUNCS; do
5212     eval check_mathfunc $func \${${func}_args:-1}
5213 done
5214
5215 # these are off by default, so fail if requested and not available
5216 enabled avfoundation_indev && { check_header_oc AVFoundation/AVFoundation.h || disable avfoundation_indev; }
5217 enabled avfoundation_indev && { check_lib2 CoreGraphics/CoreGraphics.h CGGetActiveDisplayList -framework CoreGraphics ||
5218                                 check_lib2 ApplicationServices/ApplicationServices.h CGGetActiveDisplayList -framework ApplicationServices; }
5219 enabled avisynth          && { { check_lib2 "windows.h" LoadLibrary; } ||
5220                                { check_lib2 "dlfcn.h" dlopen -ldl; } ||
5221                                die "ERROR: LoadLibrary/dlopen not found for avisynth"; }
5222 enabled decklink          && { check_header DeckLinkAPI.h || die "ERROR: DeckLinkAPI.h header not found"; }
5223 enabled frei0r            && { check_header frei0r.h || die "ERROR: frei0r.h header not found"; }
5224 enabled gnutls            && require_pkg_config gnutls gnutls/gnutls.h gnutls_global_init
5225 enabled ladspa            && { check_header ladspa.h || die "ERROR: ladspa.h header not found"; }
5226 enabled libiec61883       && require libiec61883 libiec61883/iec61883.h iec61883_cmp_connect -lraw1394 -lavc1394 -lrom1394 -liec61883
5227 enabled libaacplus        && require "libaacplus >= 2.0.0" aacplus.h aacplusEncOpen -laacplus
5228 enabled libass            && require_pkg_config libass ass/ass.h ass_library_init
5229 enabled libbluray         && require_pkg_config libbluray libbluray/bluray.h bd_open
5230 enabled libbs2b           && require_pkg_config libbs2b bs2b.h bs2b_open
5231 enabled libcelt           && require libcelt celt/celt.h celt_decode -lcelt0 &&
5232                              { check_lib celt/celt.h celt_decoder_create_custom -lcelt0 ||
5233                                die "ERROR: libcelt must be installed and version must be >= 0.11.0."; }
5234 enabled libcaca           && require_pkg_config caca caca.h caca_create_canvas
5235 enabled libdcadec         && require_pkg_config dcadec libdcadec/dca_context.h dcadec_context_create &&
5236                              check_struct libdcadec/dca_context.h "struct dcadec_exss_info" matrix_encoding
5237 enabled libfaac           && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
5238 enabled libfdk_aac        && { use_pkg_config fdk-aac "fdk-aac/aacenc_lib.h" aacEncOpen ||
5239                                { require libfdk_aac fdk-aac/aacenc_lib.h aacEncOpen -lfdk-aac &&
5240                                  warn "using libfdk without pkg-config"; } }
5241 flite_libs="-lflite_cmu_time_awb -lflite_cmu_us_awb -lflite_cmu_us_kal -lflite_cmu_us_kal16 -lflite_cmu_us_rms -lflite_cmu_us_slt -lflite_usenglish -lflite_cmulex -lflite"
5242 enabled libflite          && require2 libflite "flite/flite.h" flite_init $flite_libs
5243 enabled fontconfig        && enable libfontconfig
5244 enabled libfontconfig     && require_pkg_config fontconfig "fontconfig/fontconfig.h" FcInit
5245 enabled libfreetype       && require_libfreetype
5246 enabled libfribidi        && require_pkg_config fribidi fribidi.h fribidi_version_info
5247 enabled libgme            && require  libgme gme/gme.h gme_new_emu -lgme -lstdc++
5248 enabled libgsm            && { for gsm_hdr in "gsm.h" "gsm/gsm.h"; do
5249                                    check_lib "${gsm_hdr}" gsm_create -lgsm && break;
5250                                done || die "ERROR: libgsm not found"; }
5251 enabled libilbc           && require libilbc ilbc.h WebRtcIlbcfix_InitDecode -lilbc
5252 enabled libkvazaar        && require_pkg_config kvazaar kvazaar.h kvz_api_get
5253 enabled libmfx            && require_pkg_config libmfx "mfx/mfxvideo.h" MFXInit
5254 enabled libmodplug        && require_pkg_config libmodplug libmodplug/modplug.h ModPlug_Load
5255 enabled libmp3lame        && require "libmp3lame >= 3.98.3" lame/lame.h lame_set_VBR_quality -lmp3lame
5256 enabled libnut            && require libnut libnut.h nut_demuxer_init -lnut
5257 enabled libopencore_amrnb && require libopencore_amrnb opencore-amrnb/interf_dec.h Decoder_Interface_init -lopencore-amrnb
5258 enabled libopencore_amrwb && require libopencore_amrwb opencore-amrwb/dec_if.h D_IF_init -lopencore-amrwb
5259 enabled libopencv         && require_pkg_config opencv opencv/cxcore.h cvCreateImageHeader
5260 enabled libopenh264       && require_pkg_config openh264 wels/codec_api.h WelsGetCodecVersion
5261 enabled libopenjpeg       && { check_lib openjpeg.h opj_version -lopenmj2 -DOPJ_STATIC ||
5262                                check_lib openjpeg-1.5/openjpeg.h opj_version -lopenjpeg -DOPJ_STATIC ||
5263                                check_lib openjpeg.h opj_version -lopenjpeg -DOPJ_STATIC ||
5264                                die "ERROR: libopenjpeg not found"; }
5265 enabled libopus           && require_pkg_config opus opus_multistream.h opus_multistream_decoder_create
5266 enabled libpulse          && require_pkg_config libpulse pulse/pulseaudio.h pa_context_new
5267 enabled libquvi           && require_pkg_config libquvi quvi/quvi.h quvi_init
5268 enabled librtmp           && require_pkg_config librtmp librtmp/rtmp.h RTMP_Socket
5269 enabled libschroedinger   && require_pkg_config schroedinger-1.0 schroedinger/schro.h schro_init
5270 enabled libshine          && require_pkg_config shine shine/layer3.h shine_encode_buffer
5271 enabled libsmbclient      && { use_pkg_config smbclient libsmbclient.h smbc_init ||
5272                                require smbclient libsmbclient.h smbc_init -lsmbclient; }
5273 enabled libsnappy         && require snappy snappy-c.h snappy_compress -lsnappy
5274 enabled libsoxr           && require libsoxr soxr.h soxr_create -lsoxr
5275 enabled libssh            && require_pkg_config libssh libssh/sftp.h sftp_init
5276 enabled libspeex          && require_pkg_config speex speex/speex.h speex_decoder_init -lspeex
5277 enabled libstagefright_h264 && require_cpp libstagefright_h264 "binder/ProcessState.h media/stagefright/MetaData.h
5278     media/stagefright/MediaBufferGroup.h media/stagefright/MediaDebug.h media/stagefright/MediaDefs.h
5279     media/stagefright/OMXClient.h media/stagefright/OMXCodec.h" android::OMXClient -lstagefright -lmedia -lutils -lbinder -lgnustl_static
5280 enabled libtheora         && require libtheora theora/theoraenc.h th_info_init -ltheoraenc -ltheoradec -logg
5281 enabled libtwolame        && require libtwolame twolame.h twolame_init -ltwolame &&
5282                              { check_lib twolame.h twolame_encode_buffer_float32_interleaved -ltwolame ||
5283                                die "ERROR: libtwolame must be installed and version must be >= 0.3.10"; }
5284 enabled libutvideo        && require_cpp utvideo "stdint.h stdlib.h utvideo/utvideo.h utvideo/Codec.h" 'CCodec*' -lutvideo -lstdc++
5285 enabled libv4l2           && require_pkg_config libv4l2 libv4l2.h v4l2_ioctl
5286 enabled libvidstab        && require_pkg_config "vidstab >= 0.98" vid.stab/libvidstab.h vsMotionDetectInit
5287 enabled libvo_aacenc      && require libvo_aacenc vo-aacenc/voAAC.h voGetAACEncAPI -lvo-aacenc
5288 enabled libvo_amrwbenc    && require libvo_amrwbenc vo-amrwbenc/enc_if.h E_IF_init -lvo-amrwbenc
5289 enabled libvorbis         && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
5290
5291 enabled libvpx            && {
5292     enabled libvpx_vp8_decoder && {
5293         use_pkg_config "vpx >= 0.9.1" "vpx/vpx_decoder.h vpx/vp8dx.h" vpx_codec_vp8_dx ||
5294             check_lib2 "vpx/vpx_decoder.h vpx/vp8dx.h" vpx_codec_dec_init_ver -lvpx ||
5295                 die "ERROR: libvpx decoder version must be >=0.9.1";
5296     }
5297     enabled libvpx_vp8_encoder && {
5298         use_pkg_config "vpx >= 0.9.7" "vpx/vpx_encoder.h vpx/vp8cx.h" vpx_codec_vp8_cx ||
5299             check_lib2 "vpx/vpx_encoder.h vpx/vp8cx.h" "vpx_codec_enc_init_ver VP8E_SET_MAX_INTRA_BITRATE_PCT" -lvpx ||
5300                 die "ERROR: libvpx encoder version must be >=0.9.7";
5301     }
5302     enabled libvpx_vp9_decoder && {
5303         use_pkg_config "vpx >= 1.3.0" "vpx/vpx_decoder.h vpx/vp8dx.h" vpx_codec_vp9_dx ||
5304             check_lib2 "vpx/vpx_decoder.h vpx/vp8dx.h" "vpx_codec_vp9_dx" -lvpx ||
5305                 disable libvpx_vp9_decoder;
5306     }
5307     enabled libvpx_vp9_encoder && {
5308         use_pkg_config "vpx >= 1.3.0" "vpx/vpx_encoder.h vpx/vp8cx.h" vpx_codec_vp9_cx ||
5309             check_lib2 "vpx/vpx_encoder.h vpx/vp8cx.h" "vpx_codec_vp9_cx VP9E_SET_AQ_MODE" -lvpx ||
5310                 disable libvpx_vp9_encoder;
5311     }
5312     if disabled_all libvpx_vp8_decoder libvpx_vp9_decoder libvpx_vp8_encoder libvpx_vp9_encoder; then
5313         die "libvpx enabled but no supported decoders found"
5314     fi
5315 }
5316
5317 enabled libwavpack        && require libwavpack wavpack/wavpack.h WavpackOpenFileOutput  -lwavpack
5318 enabled libwebp           && {
5319     enabled libwebp_encoder      && require_pkg_config "libwebp >= 0.2.0" webp/encode.h WebPGetEncoderVersion
5320     enabled libwebp_anim_encoder && { use_pkg_config "libwebpmux >= 0.4.0" webp/mux.h WebPAnimEncoderOptionsInit || disable libwebp_anim_encoder; } }
5321 enabled libx264           && { use_pkg_config x264 "stdint.h x264.h" x264_encoder_encode ||
5322                                { require libx264 x264.h x264_encoder_encode -lx264 &&
5323                                  warn "using libx264 without pkg-config"; } } &&
5324                              { check_cpp_condition x264.h "X264_BUILD >= 118" ||
5325                                die "ERROR: libx264 must be installed and version must be >= 0.118."; } &&
5326                              { check_cpp_condition x264.h "X264_MPEG2" &&
5327                                enable libx262; }
5328 enabled libx265           && require_pkg_config x265 x265.h x265_api_get &&
5329                              { check_cpp_condition x265.h "X265_BUILD >= 57" ||
5330                                die "ERROR: libx265 version must be >= 57."; }
5331 enabled libxavs           && require libxavs xavs.h xavs_encoder_encode -lxavs
5332 enabled libxvid           && require libxvid xvid.h xvid_global -lxvidcore
5333 enabled libzmq            && require_pkg_config libzmq zmq.h zmq_ctx_new
5334 enabled libzvbi           && require libzvbi libzvbi.h vbi_decoder_new -lzvbi
5335 enabled mmal              && { check_lib interface/mmal/mmal.h mmal_port_connect -lmmal_core -lmmal_util -lmmal_vc_client -lbcm_host ||
5336                                 { ! enabled cross_compile && {
5337                                     add_cflags -isystem/opt/vc/include/ -isystem/opt/vc/include/interface/vmcs_host/linux -isystem/opt/vc/include/interface/vcos/pthreads -fgnu89-inline ;
5338                                     add_extralibs -L/opt/vc/lib/ -lmmal_core -lmmal_util -lmmal_vc_client -lbcm_host ;
5339                                     check_lib interface/mmal/mmal.h mmal_port_connect ; }
5340                                 check_lib interface/mmal/mmal.h mmal_port_connect ; } ||
5341                                die "ERROR: mmal not found"; }
5342 enabled nvenc             && { check_header nvEncodeAPI.h || die "ERROR: nvEncodeAPI.h not found."; } &&
5343                              { check_cpp_condition nvEncodeAPI.h "NVENCAPI_MAJOR_VERSION >= 5" ||
5344                                die "ERROR: NVENC API version 4 or older is not supported"; } &&
5345                              { [ $target_os != cygwin ] || die "ERROR: NVENC is not supported on Cygwin currently."; }
5346 enabled openal            && { { for al_libs in "${OPENAL_LIBS}" "-lopenal" "-lOpenAL32"; do
5347                                check_lib 'AL/al.h' alGetError "${al_libs}" && break; done } ||
5348                                die "ERROR: openal not found"; } &&
5349                              { check_cpp_condition "AL/al.h" "defined(AL_VERSION_1_1)" ||
5350                                die "ERROR: openal must be installed and version must be 1.1 or compatible"; }
5351 enabled opencl            && { check_lib2 OpenCL/cl.h clEnqueueNDRangeKernel -Wl,-framework,OpenCL ||
5352                                check_lib2 CL/cl.h clEnqueueNDRangeKernel -lOpenCL ||
5353                                die "ERROR: opencl not found"; } &&
5354                              { check_cpp_condition "OpenCL/cl.h" "defined(CL_VERSION_1_2)" ||
5355                                check_cpp_condition "CL/cl.h" "defined(CL_VERSION_1_2)" ||
5356                                die "ERROR: opencl must be installed and version must be 1.2 or compatible"; }
5357 enabled opengl            && { check_lib GL/glx.h glXGetProcAddress "-lGL" ||
5358                                check_lib2 windows.h wglGetProcAddress "-lopengl32 -lgdi32" ||
5359                                check_lib2 OpenGL/gl3.h glGetError "-Wl,-framework,OpenGL" ||
5360                                check_lib2 ES2/gl.h glGetError "-isysroot=${sysroot} -Wl,-framework,OpenGLES" ||
5361                                die "ERROR: opengl not found."
5362                              }
5363 enabled openssl           && { check_lib openssl/ssl.h SSL_library_init -lssl -lcrypto ||
5364                                check_lib openssl/ssl.h SSL_library_init -lssl32 -leay32 ||
5365                                check_lib openssl/ssl.h SSL_library_init -lssl -lcrypto -lws2_32 -lgdi32 ||
5366                                die "ERROR: openssl not found"; }
5367 enabled qtkit_indev      && { check_header_oc QTKit/QTKit.h || disable qtkit_indev; }
5368
5369 if enabled gnutls; then
5370     { check_lib2 gmp.h mpz_export -lgmp && enable gmp; } ||
5371     { check_lib gcrypt.h gcry_mpi_new -lgcrypt && enable gcrypt; }
5372 fi
5373
5374 # libdc1394 check
5375 if enabled libdc1394; then
5376     { require_pkg_config libdc1394-2 dc1394/dc1394.h dc1394_new &&
5377         enable libdc1394_2; } ||
5378     { check_lib libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394 &&
5379         enable libdc1394_1; } ||
5380     die "ERROR: No version of libdc1394 found "
5381 fi
5382 if ! disabled sdl; then
5383     SDL_CONFIG="${cross_prefix}sdl-config"
5384     if check_pkg_config sdl SDL_events.h SDL_PollEvent; then
5385         check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x010201" $sdl_cflags &&
5386         check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) < 0x010300" $sdl_cflags &&
5387         enable sdl
5388     else
5389         if "${SDL_CONFIG}" --version > /dev/null 2>&1; then
5390             sdl_cflags=$("${SDL_CONFIG}" --cflags)
5391             sdl_libs=$("${SDL_CONFIG}" --libs)
5392             check_func_headers SDL_version.h SDL_Linked_Version $sdl_cflags $sdl_libs &&
5393             check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x010201" $sdl_cflags &&
5394             check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) < 0x010300" $sdl_cflags &&
5395             enable sdl
5396         elif enabled sdl ; then
5397             die "ERROR: SDL not found"
5398         else
5399             disable sdl
5400         fi
5401     fi
5402     if test $target_os = "mingw32"; then
5403         sdl_libs="$sdl_libs -mconsole"
5404     fi
5405 fi
5406 enabled sdl && add_cflags $sdl_cflags && add_extralibs $sdl_libs
5407
5408 disabled securetransport || { check_func SecIdentityCreate "-Wl,-framework,CoreFoundation -Wl,-framework,Security" &&
5409     check_lib2 "Security/SecureTransport.h Security/Security.h" "SSLCreateContext SecItemImport" "-Wl,-framework,CoreFoundation -Wl,-framework,Security" &&
5410     enable securetransport; }
5411
5412 makeinfo --version > /dev/null 2>&1 && enable makeinfo  || disable makeinfo
5413 enabled makeinfo \
5414     && [ 0$(makeinfo --version | grep "texinfo" | sed 's/.*texinfo[^0-9]*\([0-9]*\)\..*/\1/') -ge 5 ] \
5415     && enable makeinfo_html || disable makeinfo_html
5416 disabled makeinfo_html && texi2html --help 2> /dev/null | grep -q 'init-file' && enable texi2html || disable texi2html
5417 perl -v            > /dev/null 2>&1 && enable perl      || disable perl
5418 pod2man --help     > /dev/null 2>&1 && enable pod2man   || disable pod2man
5419 rsync --help 2> /dev/null | grep -q 'contimeout' && enable rsync_contimeout || disable rsync_contimeout
5420
5421 check_header linux/fb.h
5422 check_header linux/videodev.h
5423 check_header linux/videodev2.h
5424 check_code cc linux/videodev2.h "struct v4l2_frmsizeenum vfse; vfse.discrete.width = 0;" && enable_safe struct_v4l2_frmivalenum_discrete
5425
5426 check_header sys/videoio.h
5427 check_code cc sys/videoio.h "struct v4l2_frmsizeenum vfse; vfse.discrete.width = 0;" && enable_safe struct_v4l2_frmivalenum_discrete
5428
5429 check_func_headers "windows.h vfw.h" capCreateCaptureWindow "$vfwcap_indev_extralibs"
5430 # check that WM_CAP_DRIVER_CONNECT is defined to the proper value
5431 # w32api 3.12 had it defined wrong
5432 check_cpp_condition vfw.h "WM_CAP_DRIVER_CONNECT > WM_USER" && enable vfwcap_defines
5433
5434 check_type "dshow.h" IBaseFilter
5435
5436 # check for ioctl_meteor.h, ioctl_bt848.h and alternatives
5437 { check_header dev/bktr/ioctl_meteor.h &&
5438   check_header dev/bktr/ioctl_bt848.h; } ||
5439 { check_header machine/ioctl_meteor.h &&
5440   check_header machine/ioctl_bt848.h; } ||
5441 { check_header dev/video/meteor/ioctl_meteor.h &&
5442   check_header dev/video/bktr/ioctl_bt848.h; } ||
5443 check_header dev/ic/bt8xx.h
5444
5445 check_header sndio.h
5446 if check_struct sys/soundcard.h audio_buf_info bytes; then
5447     enable_safe sys/soundcard.h
5448 else
5449     check_cc -D__BSD_VISIBLE -D__XSI_VISIBLE <<EOF && add_cppflags -D__BSD_VISIBLE -D__XSI_VISIBLE && enable_safe sys/soundcard.h
5450     #include <sys/soundcard.h>
5451     audio_buf_info abc;
5452 EOF
5453 fi
5454 check_header soundcard.h
5455
5456 enabled_any alsa_indev alsa_outdev &&
5457     check_lib2 alsa/asoundlib.h snd_pcm_htimestamp -lasound
5458
5459 enabled jack_indev && check_lib2 jack/jack.h jack_client_open -ljack && check_func sem_timedwait &&
5460     check_func jack_port_get_latency_range -ljack
5461
5462 enabled_any sndio_indev sndio_outdev && check_lib2 sndio.h sio_open -lsndio
5463
5464 if enabled libcdio; then
5465     check_lib2 "cdio/cdda.h cdio/paranoia.h" cdio_cddap_open -lcdio_paranoia -lcdio_cdda -lcdio ||
5466     check_lib2 "cdio/paranoia/cdda.h cdio/paranoia/paranoia.h" cdio_cddap_open -lcdio_paranoia -lcdio_cdda -lcdio ||
5467     die "ERROR: No usable libcdio/cdparanoia found"
5468 fi
5469
5470 enabled xlib &&
5471     check_lib X11/Xlib.h XOpenDisplay -lX11 || disable xlib
5472
5473 if ! disabled libxcb; then
5474     check_pkg_config "xcb >= 1.4" xcb/xcb.h xcb_connect || {
5475         enabled libxcb && die "ERROR: libxcb >= 1.4 not found";
5476     } && disable x11grab && enable libxcb
5477
5478 if enabled libxcb; then
5479     disabled libxcb_shm || {
5480         check_pkg_config xcb-shm xcb/shm.h xcb_shm_attach || {
5481             enabled libxcb_shm && die "ERROR: libxcb_shm not found";
5482         } && check_header sys/shm.h && enable libxcb_shm; }
5483
5484     disabled libxcb_xfixes || {
5485         check_pkg_config xcb-xfixes xcb/xfixes.h xcb_xfixes_get_cursor_image || {
5486             enabled libxcb_xfixes && die "ERROR: libxcb_xfixes not found";
5487         } && enable libxcb_xfixes; }
5488
5489     disabled libxcb_shape || {
5490         check_pkg_config xcb-shape xcb/shape.h xcb_shape_get_rectangles || {
5491             enabled libxcb_shape && die "ERROR: libxcb_shape not found";
5492         } && enable libxcb_shape; }
5493
5494     add_cflags $xcb_cflags $xcb_shm_cflags $xcb_xfixes_cflags $xcb_shape_cflags
5495     add_extralibs $xcb_libs $xcb_shm_libs $xcb_xfixes_libs $xcb_shape_libs
5496 fi
5497 fi
5498
5499 if enabled x11grab; then
5500     enabled xlib || die "ERROR: Xlib not found"
5501     require Xext X11/extensions/XShm.h XShmCreateImage -lXext
5502     require Xfixes X11/extensions/Xfixes.h XFixesGetCursorImage -lXfixes
5503 fi
5504
5505 check_func_headers "windows.h" CreateDIBSection "$gdigrab_indev_extralibs"
5506
5507 enabled dxva2api_h &&
5508     check_cc <<EOF && enable dxva2api_cobj
5509 #define _WIN32_WINNT 0x0600
5510 #define COBJMACROS
5511 #include <windows.h>
5512 #include <d3d9.h>
5513 #include <dxva2api.h>
5514 int main(void) { IDirectXVideoDecoder *o = NULL; IDirectXVideoDecoder_Release(o); return 0; }
5515 EOF
5516
5517 enabled vaapi &&
5518     check_lib va/va.h vaInitialize -lva ||
5519     disable vaapi
5520
5521 enabled vaapi && enabled xlib &&
5522     check_lib2 "va/va.h va/va_x11.h" vaGetDisplay -lva -lva-x11 &&
5523     enable vaapi_x11
5524
5525 enabled vdpau &&
5526     check_cpp_condition vdpau/vdpau.h "defined VDP_DECODER_PROFILE_MPEG4_PART2_ASP" ||
5527     disable vdpau
5528
5529 enabled vdpau && enabled xlib &&
5530     check_func_headers "vdpau/vdpau.h vdpau/vdpau_x11.h" vdp_device_create_x11 -lvdpau &&
5531     prepend ffmpeg_libs $($ldflags_filter "-lvdpau") &&
5532     enable vdpau_x11
5533
5534 # Funny iconv installations are not unusual, so check it after all flags have been set
5535 disabled iconv || check_func_headers iconv.h iconv || check_lib2 iconv.h iconv -liconv || disable iconv
5536
5537 enabled debug && add_cflags -g"$debuglevel" && add_asflags -g"$debuglevel"
5538
5539 # add some useful compiler flags if supported
5540 check_cflags -Wdeclaration-after-statement
5541 check_cflags -Wall
5542 check_cflags -Wdisabled-optimization
5543 check_cflags -Wpointer-arith
5544 check_cflags -Wredundant-decls
5545 check_cflags -Wwrite-strings
5546 check_cflags -Wtype-limits
5547 check_cflags -Wundef
5548 check_cflags -Wmissing-prototypes
5549 check_cflags -Wno-pointer-to-int-cast
5550 check_cflags -Wstrict-prototypes
5551 check_cflags -Wempty-body
5552 enabled extra_warnings && check_cflags -Winline
5553
5554 check_disable_warning(){
5555     warning_flag=-W${1#-Wno-}
5556     test_cflags $warning_flag && add_cflags $1
5557 }
5558
5559 check_disable_warning -Wno-parentheses
5560 check_disable_warning -Wno-switch
5561 check_disable_warning -Wno-format-zero-length
5562 check_disable_warning -Wno-pointer-sign
5563
5564 # add some linker flags
5565 check_ldflags -Wl,--warn-common
5566 check_ldflags -Wl,-rpath-link=libpostproc:libswresample:libswscale:libavfilter:libavdevice:libavformat:libavcodec:libavutil:libavresample
5567 enabled rpath && add_ldexeflags -Wl,-rpath,$libdir
5568 enabled rpath && add_ldlibflags -Wl,-rpath,$libdir
5569 test_ldflags -Wl,-Bsymbolic && append SHFLAGS -Wl,-Bsymbolic
5570
5571 # add some strip flags
5572 # -wN '..@*' is more selective than -x, but not available everywhere.
5573 check_stripflags -wN \'..@*\' || check_stripflags -x
5574
5575 enabled neon_clobber_test &&
5576     check_ldflags -Wl,--wrap,avcodec_open2              \
5577                   -Wl,--wrap,avcodec_decode_audio4      \
5578                   -Wl,--wrap,avcodec_decode_video2      \
5579                   -Wl,--wrap,avcodec_decode_subtitle2   \
5580                   -Wl,--wrap,avcodec_encode_audio2      \
5581                   -Wl,--wrap,avcodec_encode_video2      \
5582                   -Wl,--wrap,avcodec_encode_subtitle    \
5583                   -Wl,--wrap,swr_convert                \
5584                   -Wl,--wrap,avresample_convert ||
5585     disable neon_clobber_test
5586
5587 enabled xmm_clobber_test &&
5588     check_ldflags -Wl,--wrap,avcodec_open2              \
5589                   -Wl,--wrap,avcodec_decode_audio4      \
5590                   -Wl,--wrap,avcodec_decode_video2      \
5591                   -Wl,--wrap,avcodec_decode_subtitle2   \
5592                   -Wl,--wrap,avcodec_encode_audio2      \
5593                   -Wl,--wrap,avcodec_encode_video2      \
5594                   -Wl,--wrap,avcodec_encode_subtitle    \
5595                   -Wl,--wrap,swr_convert                \
5596                   -Wl,--wrap,avresample_convert         \
5597                   -Wl,--wrap,sws_scale ||
5598     disable xmm_clobber_test
5599
5600 echo "X{};" > $TMPV
5601 if test_ldflags -Wl,--version-script,$TMPV; then
5602     append SHFLAGS '-Wl,--version-script,\$(SUBDIR)lib\$(NAME).ver'
5603     check_cc <<EOF && enable symver_asm_label
5604 void ff_foo(void) __asm__ ("av_foo@VERSION");
5605 void ff_foo(void) { ${inline_asm+__asm__($quotes);} }
5606 EOF
5607     check_cc <<EOF && enable symver_gnu_asm
5608 __asm__(".symver ff_foo,av_foo@VERSION");
5609 void ff_foo(void) {}
5610 EOF
5611 fi
5612
5613 if [ -z "$optflags" ]; then
5614     if enabled small; then
5615         optflags=$cflags_size
5616     elif enabled optimizations; then
5617         optflags=$cflags_speed
5618     else
5619         optflags=$cflags_noopt
5620     fi
5621 fi
5622
5623 check_optflags(){
5624     check_cflags "$@"
5625     enabled lto && check_ldflags "$@"
5626 }
5627
5628
5629 if enabled lto; then
5630     test "$cc_type" != "$ld_type" && die "LTO requires same compiler and linker"
5631     check_cflags  -flto
5632     check_ldflags -flto $cpuflags
5633     disable inline_asm_direct_symbol_refs
5634 fi
5635
5636 check_optflags $optflags
5637 check_optflags -fno-math-errno
5638 check_optflags -fno-signed-zeros
5639
5640 enabled ftrapv && check_cflags -ftrapv
5641
5642 check_cc -mno-red-zone <<EOF && noredzone_flags="-mno-red-zone"
5643 int x;
5644 EOF
5645
5646
5647 if enabled icc; then
5648     # Just warnings, no remarks
5649     check_cflags -w1
5650     # -wd: Disable following warnings
5651     # 144, 167, 556: -Wno-pointer-sign
5652     # 188: enumerated type mixed with another type
5653     # 1292: attribute "foo" ignored
5654     # 1419: external declaration in primary source file
5655     # 10006: ignoring unknown option -fno-signed-zeros
5656     # 10148: ignoring unknown option -Wno-parentheses
5657     # 10156: ignoring option '-W'; no argument required
5658     # 13200: No EMMS instruction before call to function
5659     # 13203: No EMMS instruction before return from function
5660     check_cflags -wd144,167,188,556,1292,1419,10006,10148,10156,13200,13203
5661     # 11030: Warning unknown option --as-needed
5662     # 10156: ignoring option '-export'; no argument required
5663     check_ldflags -wd10156,11030
5664     # icc 11.0 and 11.1 work with ebp_available, but don't pass the test
5665     enable ebp_available
5666     # The test above does not test linking
5667     enabled lto && disable symver_asm_label
5668     if enabled x86_32; then
5669         icc_version=$($cc -dumpversion)
5670         test ${icc_version%%.*} -ge 11 &&
5671             check_cflags -falign-stack=maintain-16-byte ||
5672             disable aligned_stack
5673     fi
5674 elif enabled ccc; then
5675     # disable some annoying warnings
5676     add_cflags -msg_disable bitnotint
5677     add_cflags -msg_disable mixfuncvoid
5678     add_cflags -msg_disable nonstandcast
5679     add_cflags -msg_disable unsupieee
5680 elif enabled gcc; then
5681     check_optflags -fno-tree-vectorize
5682     check_cflags -Werror=format-security
5683     check_cflags -Werror=implicit-function-declaration
5684     check_cflags -Werror=missing-prototypes
5685     check_cflags -Werror=return-type
5686     check_cflags -Werror=vla
5687     check_cflags -Wformat
5688     check_cflags -fdiagnostics-color=auto
5689     enabled extra_warnings || check_disable_warning -Wno-maybe-uninitialized
5690 elif enabled llvm_gcc; then
5691     check_cflags -mllvm -stack-alignment=16
5692 elif enabled clang; then
5693     check_cflags -mllvm -stack-alignment=16
5694     check_cflags -Qunused-arguments
5695     check_cflags -Werror=implicit-function-declaration
5696     check_cflags -Werror=missing-prototypes
5697     check_cflags -Werror=return-type
5698 elif enabled cparser; then
5699     add_cflags -Wno-missing-variable-declarations
5700     add_cflags -Wno-empty-statement
5701 elif enabled armcc; then
5702     add_cflags -W${armcc_opt},--diag_suppress=4343 # hardfp compat
5703     add_cflags -W${armcc_opt},--diag_suppress=3036 # using . as system include dir
5704     # 2523: use of inline assembly is deprecated
5705     add_cflags -W${armcc_opt},--diag_suppress=2523
5706     add_cflags -W${armcc_opt},--diag_suppress=1207
5707     add_cflags -W${armcc_opt},--diag_suppress=1293 # assignment in condition
5708     add_cflags -W${armcc_opt},--diag_suppress=3343 # hardfp compat
5709     add_cflags -W${armcc_opt},--diag_suppress=167  # pointer sign
5710     add_cflags -W${armcc_opt},--diag_suppress=513  # pointer sign
5711 elif enabled tms470; then
5712     add_cflags -pds=824 -pds=837
5713     disable inline_asm
5714 elif enabled pathscale; then
5715     add_cflags -fstrict-overflow -OPT:wrap_around_unsafe_opt=OFF
5716 elif enabled_any msvc icl; then
5717     enabled x86_32 && disable aligned_stack
5718     enabled_all x86_32 debug && add_cflags -Oy-
5719     enabled debug && add_ldflags -debug
5720     enable pragma_deprecated
5721     if enabled icl; then
5722         # -Qansi-alias is basically -fstrict-aliasing, but does not work
5723         # (correctly) on icl 13.x.
5724         check_cpp_condition "windows.h" "__ICL < 1300 || __ICL >= 1400" &&
5725             add_cflags -Qansi-alias
5726         # Some inline asm is not compilable in debug
5727         if enabled debug; then
5728             disable ebp_available
5729             disable ebx_available
5730         fi
5731     fi
5732     # msvcrt10 x64 incorrectly enables log2, only msvcrt12 (MSVC 2013) onwards actually has log2.
5733     check_cpp_condition crtversion.h "_VC_CRT_MAJOR_VERSION >= 12" || disable log2
5734     # The CRT headers contain __declspec(restrict) in a few places, but if redefining
5735     # restrict, this might break. MSVC 2010 and 2012 fail with __declspec(__restrict)
5736     # (as it ends up if the restrict redefine is done before including stdlib.h), while
5737     # MSVC 2013 and newer can handle it fine.
5738     # If this declspec fails, force including stdlib.h before the restrict redefinition
5739     # happens in config.h.
5740     if [ $_restrict != restrict ]; then
5741         check_cc <<EOF || add_cflags -FIstdlib.h
5742 __declspec($_restrict) void* foo(int);
5743 EOF
5744     fi
5745     check_func strtoll || add_cflags -Dstrtoll=_strtoi64
5746 fi
5747
5748 for pfx in "" host_; do
5749     varname=${pfx%_}cc_type
5750     eval "type=\$$varname"
5751     if [ $type = "msvc" ]; then
5752         check_${pfx}cc <<EOF || add_${pfx}cflags -Dinline=__inline
5753 static inline int foo(int a) { return a; }
5754 EOF
5755     fi
5756 done
5757
5758 case $as_type in
5759     clang)
5760         add_asflags -Qunused-arguments
5761     ;;
5762 esac
5763
5764 case $ld_type in
5765     clang)
5766         check_ldflags -Qunused-arguments
5767     ;;
5768 esac
5769
5770 case $target_os in
5771     osf1)
5772         enabled ccc && add_ldflags '-Wl,-expect_unresolved,*'
5773     ;;
5774     plan9)
5775         add_cppflags -Dmain=plan9_main
5776     ;;
5777 esac
5778
5779 enable frame_thread_encoder
5780
5781 enabled asm || { arch=c; disable $ARCH_LIST $ARCH_EXT_LIST; }
5782
5783 check_deps $CONFIG_LIST       \
5784            $CONFIG_EXTRA      \
5785            $HAVE_LIST         \
5786            $ALL_COMPONENTS    \
5787
5788 enabled threads && ! enabled pthreads && ! enabled atomics_native && die "non pthread threading without atomics not supported, try adding --enable-pthreads or --cpu=i486 or higher if you are on x86"
5789
5790
5791 if test $target_os = "haiku"; then
5792     disable memalign
5793     disable posix_memalign
5794 fi
5795
5796 enabled_all dxva2 dxva2api_cobj CoTaskMemFree &&
5797     prepend ffmpeg_libs $($ldflags_filter "-lole32" "-luser32") &&
5798     enable dxva2_lib
5799
5800 ! enabled_any memalign posix_memalign aligned_malloc &&
5801     enabled simd_align_16 && enable memalign_hack
5802
5803 # add_dep lib dep
5804 # -> enable ${lib}_deps_${dep}
5805 # -> add $dep to ${lib}_deps only once
5806 add_dep() {
5807     lib=$1
5808     dep=$2
5809     enabled "${lib}_deps_${dep}" && return 0
5810     enable  "${lib}_deps_${dep}"
5811     prepend "${lib}_deps" $dep
5812 }
5813
5814 # merge deps lib components
5815 # merge all ${component}_deps into ${lib}_deps and ${lib}_deps_*
5816 merge_deps() {
5817     lib=$1
5818     shift
5819     for comp in $*; do
5820         enabled $comp || continue
5821         eval "dep=\"\$${comp}_deps\""
5822         for d in $dep; do
5823             add_dep $lib $d
5824         done
5825     done
5826 }
5827
5828 merge_deps libavfilter $FILTER_LIST
5829
5830 map 'enabled $v && intrinsics=${v#intrinsics_}' $INTRINSICS_LIST
5831
5832 for thread in $THREADS_LIST; do
5833     if enabled $thread; then
5834         test -n "$thread_type" &&
5835             die "ERROR: Only one thread type must be selected." ||
5836             thread_type="$thread"
5837     fi
5838 done
5839
5840 enabled zlib && add_cppflags -DZLIB_CONST
5841
5842 # conditional library dependencies, in linking order
5843 enabled amovie_filter       && prepend avfilter_deps "avformat avcodec"
5844 enabled aresample_filter    && prepend avfilter_deps "swresample"
5845 enabled asyncts_filter      && prepend avfilter_deps "avresample"
5846 enabled atempo_filter       && prepend avfilter_deps "avcodec"
5847 enabled cover_rect_filter   && prepend avfilter_deps "avformat avcodec"
5848 enabled ebur128_filter && enabled swresample && prepend avfilter_deps "swresample"
5849 enabled elbg_filter         && prepend avfilter_deps "avcodec"
5850 enabled fftfilt_filter      && prepend avfilter_deps "avcodec"
5851 enabled find_rect_filter    && prepend avfilter_deps "avformat avcodec"
5852 enabled mcdeint_filter      && prepend avfilter_deps "avcodec"
5853 enabled movie_filter    && prepend avfilter_deps "avformat avcodec"
5854 enabled pan_filter          && prepend avfilter_deps "swresample"
5855 enabled pp_filter           && prepend avfilter_deps "postproc"
5856 enabled removelogo_filter   && prepend avfilter_deps "avformat avcodec swscale"
5857 enabled resample_filter && prepend avfilter_deps "avresample"
5858 enabled sab_filter          && prepend avfilter_deps "swscale"
5859 enabled scale_filter    && prepend avfilter_deps "swscale"
5860 enabled scale2ref_filter    && prepend avfilter_deps "swscale"
5861 enabled showspectrum_filter && prepend avfilter_deps "avcodec"
5862 enabled smartblur_filter    && prepend avfilter_deps "swscale"
5863 enabled subtitles_filter    && prepend avfilter_deps "avformat avcodec"
5864 enabled uspp_filter         && prepend avfilter_deps "avcodec"
5865
5866 enabled lavfi_indev         && prepend avdevice_deps "avfilter"
5867
5868 enabled opus_decoder    && prepend avcodec_deps "swresample"
5869
5870 expand_deps(){
5871     lib_deps=${1}_deps
5872     eval "deps=\$$lib_deps"
5873     append $lib_deps $(map 'eval echo \$${v}_deps' $deps)
5874     unique $lib_deps
5875 }
5876
5877 #we have to remove gpl from the deps here as some code assumes all lib deps are libs
5878 postproc_deps="$(filter_out 'gpl' $postproc_deps)"
5879
5880 map 'expand_deps $v' $LIBRARY_LIST
5881
5882 echo "install prefix            $prefix"
5883 echo "source path               $source_path"
5884 echo "C compiler                $cc"
5885 echo "C library                 $libc_type"
5886 if test "$host_cc" != "$cc"; then
5887     echo "host C compiler           $host_cc"
5888     echo "host C library            $host_libc_type"
5889 fi
5890 echo "ARCH                      $arch ($cpu)"
5891 if test "$build_suffix" != ""; then
5892     echo "build suffix              $build_suffix"
5893 fi
5894 if test "$progs_suffix" != ""; then
5895     echo "progs suffix              $progs_suffix"
5896 fi
5897 if test "$extra_version" != ""; then
5898     echo "version string suffix     $extra_version"
5899 fi
5900 echo "big-endian                ${bigendian-no}"
5901 echo "runtime cpu detection     ${runtime_cpudetect-no}"
5902 if enabled x86; then
5903     echo "${yasmexe}                      ${yasm-no}"
5904     echo "MMX enabled               ${mmx-no}"
5905     echo "MMXEXT enabled            ${mmxext-no}"
5906     echo "3DNow! enabled            ${amd3dnow-no}"
5907     echo "3DNow! extended enabled   ${amd3dnowext-no}"
5908     echo "SSE enabled               ${sse-no}"
5909     echo "SSSE3 enabled             ${ssse3-no}"
5910     echo "AVX enabled               ${avx-no}"
5911     echo "XOP enabled               ${xop-no}"
5912     echo "FMA3 enabled              ${fma3-no}"
5913     echo "FMA4 enabled              ${fma4-no}"
5914     echo "i686 features enabled     ${i686-no}"
5915     echo "CMOV is fast              ${fast_cmov-no}"
5916     echo "EBX available             ${ebx_available-no}"
5917     echo "EBP available             ${ebp_available-no}"
5918 fi
5919 if enabled aarch64; then
5920     echo "NEON enabled              ${neon-no}"
5921     echo "VFP enabled               ${vfp-no}"
5922 fi
5923 if enabled arm; then
5924     echo "ARMv5TE enabled           ${armv5te-no}"
5925     echo "ARMv6 enabled             ${armv6-no}"
5926     echo "ARMv6T2 enabled           ${armv6t2-no}"
5927     echo "VFP enabled               ${vfp-no}"
5928     echo "NEON enabled              ${neon-no}"
5929     echo "THUMB enabled             ${thumb-no}"
5930 fi
5931 if enabled mips; then
5932     echo "MIPS FPU enabled          ${mipsfpu-no}"
5933     echo "MIPS32R5 enabled          ${mips32r5-no}"
5934     echo "MIPS64R6 enabled          ${mips64r6-no}"
5935     echo "MIPS DSP R1 enabled       ${mipsdspr1-no}"
5936     echo "MIPS DSP R2 enabled       ${mipsdspr2-no}"
5937     echo "MIPS MSA enabled          ${msa-no}"
5938     echo "LOONGSON MMI enabled      ${mmi-no}"
5939 fi
5940 if enabled ppc; then
5941     echo "AltiVec enabled           ${altivec-no}"
5942     echo "VSX enabled               ${vsx-no}"
5943     echo "POWER8 enabled            ${power8-no}"
5944     echo "PPC 4xx optimizations     ${ppc4xx-no}"
5945     echo "dcbzl available           ${dcbzl-no}"
5946 fi
5947 echo "debug symbols             ${debug-no}"
5948 echo "strip symbols             ${stripping-no}"
5949 echo "optimize for size         ${small-no}"
5950 echo "optimizations             ${optimizations-no}"
5951 echo "static                    ${static-no}"
5952 echo "shared                    ${shared-no}"
5953 echo "postprocessing support    ${postproc-no}"
5954 echo "new filter support        ${avfilter-no}"
5955 echo "network support           ${network-no}"
5956 echo "threading support         ${thread_type-no}"
5957 echo "safe bitstream reader     ${safe_bitstream_reader-no}"
5958 echo "SDL support               ${sdl-no}"
5959 echo "opencl enabled            ${opencl-no}"
5960 echo "texi2html enabled         ${texi2html-no}"
5961 echo "perl enabled              ${perl-no}"
5962 echo "pod2man enabled           ${pod2man-no}"
5963 echo "makeinfo enabled          ${makeinfo-no}"
5964 echo "makeinfo supports HTML    ${makeinfo_html-no}"
5965 test -n "$random_seed" &&
5966     echo "random seed               ${random_seed}"
5967 echo
5968
5969 echo "Enabled programs:"
5970 print_enabled '' $PROGRAM_LIST | print_3_columns
5971 echo
5972
5973 echo "External libraries:"
5974 print_enabled '' $EXTERNAL_LIBRARY_LIST | print_3_columns
5975 echo
5976
5977 for type in decoder encoder hwaccel parser demuxer muxer protocol filter bsf indev outdev; do
5978     echo "Enabled ${type}s:"
5979     eval list=\$$(toupper $type)_LIST
5980     print_enabled '_*' $list | print_3_columns
5981     echo
5982 done
5983
5984 license="LGPL version 2.1 or later"
5985 if enabled nonfree; then
5986     license="nonfree and unredistributable"
5987 elif enabled gplv3; then
5988     license="GPL version 3 or later"
5989 elif enabled lgplv3; then
5990     license="LGPL version 3 or later"
5991 elif enabled gpl; then
5992     license="GPL version 2 or later"
5993 fi
5994
5995 echo "License: $license"
5996
5997 echo "Creating config.mak, config.h, and doc/config.texi..."
5998
5999 test -e Makefile || echo "include $source_path/Makefile" > Makefile
6000
6001 enabled stripping || strip="echo skipping strip"
6002
6003 config_files="$TMPH config.mak doc/config.texi"
6004
6005 cat > config.mak <<EOF
6006 # Automatically generated by configure - do not modify!
6007 ifndef FFMPEG_CONFIG_MAK
6008 FFMPEG_CONFIG_MAK=1
6009 FFMPEG_CONFIGURATION=$FFMPEG_CONFIGURATION
6010 prefix=$prefix
6011 LIBDIR=\$(DESTDIR)$libdir
6012 SHLIBDIR=\$(DESTDIR)$shlibdir
6013 INCDIR=\$(DESTDIR)$incdir
6014 BINDIR=\$(DESTDIR)$bindir
6015 DATADIR=\$(DESTDIR)$datadir
6016 DOCDIR=\$(DESTDIR)$docdir
6017 MANDIR=\$(DESTDIR)$mandir
6018 PKGCONFIGDIR=\$(DESTDIR)$pkgconfigdir
6019 SRC_PATH=$source_path
6020 ifndef MAIN_MAKEFILE
6021 SRC_PATH:=\$(SRC_PATH:.%=..%)
6022 endif
6023 CC_IDENT=$cc_ident
6024 ARCH=$arch
6025 INTRINSICS=$intrinsics
6026 CC=$cc
6027 CXX=$cxx
6028 AS=$as
6029 LD=$ld
6030 DEPCC=$dep_cc
6031 DEPCCFLAGS=$DEPCCFLAGS \$(CPPFLAGS)
6032 DEPAS=$as
6033 DEPASFLAGS=$DEPASFLAGS \$(CPPFLAGS)
6034 YASM=$yasmexe
6035 DEPYASM=$yasmexe
6036 AR=$ar
6037 ARFLAGS=$arflags
6038 AR_O=$ar_o
6039 RANLIB=$ranlib
6040 STRIP=$strip
6041 CP=cp -p
6042 LN_S=$ln_s
6043 CPPFLAGS=$CPPFLAGS
6044 CFLAGS=$CFLAGS
6045 CXXFLAGS=$CXXFLAGS
6046 ASFLAGS=$ASFLAGS
6047 AS_C=$AS_C
6048 AS_O=$AS_O
6049 CC_C=$CC_C
6050 CC_E=$CC_E
6051 CC_O=$CC_O
6052 CXX_C=$CXX_C
6053 CXX_O=$CXX_O
6054 LD_O=$LD_O
6055 LD_LIB=$LD_LIB
6056 LD_PATH=$LD_PATH
6057 DLLTOOL=$dlltool
6058 WINDRES=$windres
6059 DEPWINDRES=$dep_cc
6060 DOXYGEN=$doxygen
6061 LDFLAGS=$LDFLAGS
6062 LDEXEFLAGS=$LDEXEFLAGS
6063 LDLIBFLAGS=$LDLIBFLAGS
6064 SHFLAGS=$(echo $($ldflags_filter $SHFLAGS))
6065 ASMSTRIPFLAGS=$ASMSTRIPFLAGS
6066 YASMFLAGS=$YASMFLAGS
6067 BUILDSUF=$build_suffix
6068 PROGSSUF=$progs_suffix
6069 FULLNAME=$FULLNAME
6070 LIBPREF=$LIBPREF
6071 LIBSUF=$LIBSUF
6072 LIBNAME=$LIBNAME
6073 SLIBPREF=$SLIBPREF
6074 SLIBSUF=$SLIBSUF
6075 EXESUF=$EXESUF
6076 EXTRA_VERSION=$extra_version
6077 CCDEP=$CCDEP
6078 CXXDEP=$CXXDEP
6079 CCDEP_FLAGS=$CCDEP_FLAGS
6080 ASDEP=$ASDEP
6081 ASDEP_FLAGS=$ASDEP_FLAGS
6082 CC_DEPFLAGS=$CC_DEPFLAGS
6083 AS_DEPFLAGS=$AS_DEPFLAGS
6084 HOSTCC=$host_cc
6085 HOSTLD=$host_ld
6086 HOSTCFLAGS=$host_cflags
6087 HOSTCPPFLAGS=$host_cppflags
6088 HOSTEXESUF=$HOSTEXESUF
6089 HOSTLDFLAGS=$host_ldflags
6090 HOSTLIBS=$host_libs
6091 DEPHOSTCC=$host_cc
6092 DEPHOSTCCFLAGS=$DEPHOSTCCFLAGS \$(HOSTCCFLAGS)
6093 HOSTCCDEP=$HOSTCCDEP
6094 HOSTCCDEP_FLAGS=$HOSTCCDEP_FLAGS
6095 HOSTCC_DEPFLAGS=$HOSTCC_DEPFLAGS
6096 HOSTCC_C=$HOSTCC_C
6097 HOSTCC_O=$HOSTCC_O
6098 HOSTLD_O=$HOSTLD_O
6099 TARGET_EXEC=$target_exec $target_exec_args
6100 TARGET_PATH=$target_path
6101 TARGET_SAMPLES=${target_samples:-\$(SAMPLES)}
6102 CFLAGS-ffplay=$sdl_cflags
6103 ZLIB=$($ldflags_filter -lz)
6104 LIB_INSTALL_EXTRA_CMD=$LIB_INSTALL_EXTRA_CMD
6105 EXTRALIBS=$extralibs
6106 COMPAT_OBJS=$compat_objs
6107 EXEOBJS=$exeobjs
6108 INSTALL=$install
6109 LIBTARGET=${LIBTARGET}
6110 SLIBNAME=${SLIBNAME}
6111 SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}
6112 SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}
6113 SLIB_CREATE_DEF_CMD=${SLIB_CREATE_DEF_CMD}
6114 SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}
6115 SLIB_INSTALL_NAME=${SLIB_INSTALL_NAME}
6116 SLIB_INSTALL_LINKS=${SLIB_INSTALL_LINKS}
6117 SLIB_INSTALL_EXTRA_LIB=${SLIB_INSTALL_EXTRA_LIB}
6118 SLIB_INSTALL_EXTRA_SHLIB=${SLIB_INSTALL_EXTRA_SHLIB}
6119 SAMPLES:=${samples:-\$(FATE_SAMPLES)}
6120 NOREDZONE_FLAGS=$noredzone_flags
6121 EOF
6122
6123 get_version(){
6124     lcname=lib${1}
6125     name=$(toupper $lcname)
6126     file=$source_path/$lcname/version.h
6127     eval $(awk "/#define ${name}_VERSION_M/ { print \$2 \"=\" \$3 }" "$file")
6128     enabled raise_major && eval ${name}_VERSION_MAJOR=$((${name}_VERSION_MAJOR+100))
6129     eval ${name}_VERSION=\$${name}_VERSION_MAJOR.\$${name}_VERSION_MINOR.\$${name}_VERSION_MICRO
6130     eval echo "${lcname}_VERSION=\$${name}_VERSION" >> config.mak
6131     eval echo "${lcname}_VERSION_MAJOR=\$${name}_VERSION_MAJOR" >> config.mak
6132     eval echo "${lcname}_VERSION_MINOR=\$${name}_VERSION_MINOR" >> config.mak
6133 }
6134
6135 map 'get_version $v' $LIBRARY_LIST
6136
6137 map 'eval echo "${v}_FFLIBS=\$${v}_deps" >> config.mak' $LIBRARY_LIST
6138
6139 print_program_libs(){
6140     eval "program_libs=\$${1}_libs"
6141     eval echo "LIBS-${1}=${program_libs}" >> config.mak
6142 }
6143
6144 map 'print_program_libs $v' $PROGRAM_LIST
6145
6146 cat > $TMPH <<EOF
6147 /* Automatically generated by configure - do not modify! */
6148 #ifndef FFMPEG_CONFIG_H
6149 #define FFMPEG_CONFIG_H
6150 #define FFMPEG_CONFIGURATION "$(c_escape $FFMPEG_CONFIGURATION)"
6151 #define FFMPEG_LICENSE "$(c_escape $license)"
6152 #define CONFIG_THIS_YEAR 2015
6153 #define FFMPEG_DATADIR "$(eval c_escape $datadir)"
6154 #define AVCONV_DATADIR "$(eval c_escape $datadir)"
6155 #define CC_IDENT "$(c_escape ${cc_ident:-Unknown compiler})"
6156 #define av_restrict $_restrict
6157 #define EXTERN_PREFIX "${extern_prefix}"
6158 #define EXTERN_ASM ${extern_prefix}
6159 #define BUILDSUF "$build_suffix"
6160 #define SLIBSUF "$SLIBSUF"
6161 #define HAVE_MMX2 HAVE_MMXEXT
6162 #define SWS_MAX_FILTER_SIZE $sws_max_filter_size
6163 EOF
6164
6165 test -n "$assert_level" &&
6166     echo "#define ASSERT_LEVEL $assert_level" >>$TMPH
6167
6168 test -n "$malloc_prefix" &&
6169     echo "#define MALLOC_PREFIX $malloc_prefix" >>$TMPH
6170
6171 if enabled yasm; then
6172     append config_files $TMPASM
6173     printf '' >$TMPASM
6174 fi
6175
6176 enabled getenv || echo "#define getenv(x) NULL" >> $TMPH
6177
6178
6179 mkdir -p doc
6180 mkdir -p tests
6181 mkdir -p tests/api
6182 echo "@c auto-generated by configure" > doc/config.texi
6183
6184 print_config ARCH_   "$config_files" $ARCH_LIST
6185 print_config HAVE_   "$config_files" $HAVE_LIST
6186 print_config CONFIG_ "$config_files" $CONFIG_LIST       \
6187                                      $CONFIG_EXTRA      \
6188                                      $ALL_COMPONENTS    \
6189
6190 echo "#endif /* FFMPEG_CONFIG_H */" >> $TMPH
6191 echo "endif # FFMPEG_CONFIG_MAK" >> config.mak
6192
6193 # Do not overwrite an unchanged config.h to avoid superfluous rebuilds.
6194 cp_if_changed $TMPH config.h
6195 touch .config
6196
6197 enabled yasm && cp_if_changed $TMPASM config.asm
6198
6199 cat > $TMPH <<EOF
6200 /* Generated by ffconf */
6201 #ifndef AVUTIL_AVCONFIG_H
6202 #define AVUTIL_AVCONFIG_H
6203 EOF
6204
6205 print_config AV_HAVE_ $TMPH $HAVE_LIST_PUB
6206
6207 echo "#endif /* AVUTIL_AVCONFIG_H */" >> $TMPH
6208
6209 cp_if_changed $TMPH libavutil/avconfig.h
6210
6211 if test -n "$WARNINGS"; then
6212     printf "\n%s%s$WARNINGS%s" "$warn_color" "$bold_color" "$reset_color"
6213     enabled fatal_warnings && exit 1
6214 fi
6215
6216 # build pkg-config files
6217
6218 lib_version(){
6219     eval printf "\"lib${1}${build_suffix} >= \$LIB$(toupper ${1})_VERSION, \""
6220 }
6221
6222 pkgconfig_generate(){
6223     name=$1
6224     shortname=${name#lib}${build_suffix}
6225     comment=$2
6226     version=$3
6227     libs=$4
6228     requires=$(map 'lib_version $v' $(eval echo \$${name#lib}_deps))
6229     requires=${requires%, }
6230     enabled ${name#lib} || return 0
6231     mkdir -p $name
6232     cat <<EOF > $name/$name${build_suffix}.pc
6233 prefix=$prefix
6234 exec_prefix=\${prefix}
6235 libdir=$libdir
6236 includedir=$incdir
6237
6238 Name: $name
6239 Description: $comment
6240 Version: $version
6241 Requires: $(enabled shared || echo $requires)
6242 Requires.private: $(enabled shared && echo $requires)
6243 Conflicts:
6244 Libs: -L\${libdir} $(enabled rpath && echo "-Wl,-rpath,\${libdir}") -l${shortname} $(enabled shared || echo $libs)
6245 Libs.private: $(enabled shared && echo $libs)
6246 Cflags: -I\${includedir}
6247 EOF
6248
6249 mkdir -p doc/examples/pc-uninstalled
6250 includedir=${source_path}
6251 [ "$includedir" = . ] && includedir="\${pcfiledir}/../../.."
6252     cat <<EOF > doc/examples/pc-uninstalled/$name.pc
6253 prefix=
6254 exec_prefix=
6255 libdir=\${pcfiledir}/../../../$name
6256 includedir=${includedir}
6257
6258 Name: $name
6259 Description: $comment
6260 Version: $version
6261 Requires: $requires
6262 Conflicts:
6263 Libs: -L\${libdir} -Wl,-rpath,\${libdir} -l${shortname} $(enabled shared || echo $libs)
6264 Cflags: -I\${includedir}
6265 EOF
6266 }
6267
6268 pkgconfig_generate libavutil     "FFmpeg utility library"               "$LIBAVUTIL_VERSION"     "$LIBRT $LIBM"
6269 pkgconfig_generate libavcodec    "FFmpeg codec library"                 "$LIBAVCODEC_VERSION"    "$extralibs"
6270 pkgconfig_generate libavformat   "FFmpeg container format library"      "$LIBAVFORMAT_VERSION"   "$extralibs"
6271 pkgconfig_generate libavdevice   "FFmpeg device handling library"       "$LIBAVDEVICE_VERSION"   "$extralibs"
6272 pkgconfig_generate libavfilter   "FFmpeg audio/video filtering library" "$LIBAVFILTER_VERSION"   "$extralibs"
6273 pkgconfig_generate libpostproc   "FFmpeg postprocessing library"        "$LIBPOSTPROC_VERSION"   ""
6274 pkgconfig_generate libavresample "Libav audio resampling library"       "$LIBAVRESAMPLE_VERSION" "$LIBM"
6275 pkgconfig_generate libswscale    "FFmpeg image rescaling library"       "$LIBSWSCALE_VERSION"    "$LIBM"
6276 pkgconfig_generate libswresample "FFmpeg audio resampling library"      "$LIBSWRESAMPLE_VERSION" "$LIBM"