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