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