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