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