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