aarch64: Add assembly support for -fsanitize=hwaddress tagged globals.
[libav.git] / configure
... / ...
CommitLineData
1#!/bin/sh
2#
3# Libav 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.
11LC_ALL=C
12export LC_ALL
13
14# make sure we are running under a compatible shell
15# try to make this part work with most shells
16
17try_exec(){
18 echo "Trying shell $1"
19 type "$1" > /dev/null 2>&1 && exec "$@"
20}
21
22unset foo
23(: ${foo%%bar}) 2> /dev/null
24E1="$?"
25
26(: ${foo?}) 2> /dev/null
27E2="$?"
28
29if 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 LIBAV, 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 Libav."
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
55fi
56
57test -d /usr/xpg4/bin && PATH=/usr/xpg4/bin:$PATH
58
59show_help(){
60 cat <<EOF
61Usage: configure [options]
62Options: [defaults in brackets after descriptions]
63
64Help options:
65 --help print this message
66 --quiet Suppress showing informative output
67 --list-decoders show all available decoders
68 --list-encoders show all available encoders
69 --list-hwaccels show all available hardware accelerators
70 --list-demuxers show all available demuxers
71 --list-muxers show all available muxers
72 --list-parsers show all available parsers
73 --list-protocols show all available protocols
74 --list-bsfs show all available bitstream filters
75 --list-indevs show all available input devices
76 --list-filters show all available filters
77
78Standard options:
79 --logfile=FILE log tests and output to FILE [avbuild/config.log]
80 --disable-logging do not log configure debug information
81 --prefix=PREFIX install in PREFIX [$prefix_default]
82 --bindir=DIR install binaries in DIR [PREFIX/bin]
83 --datadir=DIR install data files in DIR [PREFIX/share/avconv]
84 --docdir=DIR install documentation in DIR [PREFIX/share/doc/libav]
85 --libdir=DIR install libs in DIR [PREFIX/lib]
86 --shlibdir=DIR install shared libs in DIR [PREFIX/lib]
87 --incdir=DIR install includes in DIR [PREFIX/include]
88 --mandir=DIR install man page in DIR [PREFIX/share/man]
89 --enable-rpath use rpath when linking programs (USE WITH CARE)
90
91Licensing options:
92 --enable-gpl allow use of GPL code, the resulting libs
93 and binaries will be under GPL [no]
94 --enable-version3 upgrade (L)GPL to version 3 [no]
95 --enable-nonfree allow use of nonfree code, the resulting libs
96 and binaries will be unredistributable [no]
97
98Configuration options:
99 --disable-static do not build static libraries [no]
100 --enable-shared build shared libraries [no]
101 --enable-small optimize for size instead of speed
102 --enable-runtime-cpudetect detect CPU capabilities at runtime (bigger binary)
103 --enable-gray enable full grayscale support (slower color)
104 --disable-swscale-alpha disable alpha channel support in swscale
105 --disable-all disable building components, libraries and programs
106
107Program options:
108 --disable-programs do not build command line programs
109 --disable-avconv disable avconv build
110 --disable-avplay disable avplay build
111 --disable-avprobe disable avprobe build
112
113Component options:
114 --disable-doc do not build documentation
115 --disable-pod2man do not build manual pages
116 --disable-texi2html do not build HTML documentation
117 --disable-avdevice disable libavdevice build
118 --disable-avcodec disable libavcodec build
119 --disable-avformat disable libavformat build
120 --disable-avutil disable libavutil build
121 --disable-swscale disable libswscale build
122 --disable-avfilter disable video filter support [no]
123 --disable-avresample disable libavresample build [no]
124 --disable-pthreads disable pthreads [auto]
125 --disable-w32threads disable Win32 threads [auto]
126 --disable-network disable network support [no]
127 --disable-dct disable DCT code
128 --disable-error-resilience disable error resilience code
129 --disable-lsp disable LSP code
130 --disable-lzo disable LZO decoder code
131 --disable-mdct disable MDCT code
132 --disable-rdft disable RDFT code
133 --disable-fft disable FFT code
134 --disable-faan disable floating point AAN (I)DCT code
135
136Individual component options:
137 --disable-everything disable all components listed below
138 --disable-encoder=NAME disable encoder NAME
139 --enable-encoder=NAME enable encoder NAME
140 --disable-encoders disable all encoders
141 --disable-decoder=NAME disable decoder NAME
142 --enable-decoder=NAME enable decoder NAME
143 --disable-decoders disable all decoders
144 --disable-hwaccel=NAME disable hwaccel NAME
145 --enable-hwaccel=NAME enable hwaccel NAME
146 --disable-hwaccels disable all hwaccels
147 --disable-muxer=NAME disable muxer NAME
148 --enable-muxer=NAME enable muxer NAME
149 --disable-muxers disable all muxers
150 --disable-demuxer=NAME disable demuxer NAME
151 --enable-demuxer=NAME enable demuxer NAME
152 --disable-demuxers disable all demuxers
153 --enable-parser=NAME enable parser NAME
154 --disable-parser=NAME disable parser NAME
155 --disable-parsers disable all parsers
156 --enable-bsf=NAME enable bitstream filter NAME
157 --disable-bsf=NAME disable bitstream filter NAME
158 --disable-bsfs disable all bitstream filters
159 --enable-protocol=NAME enable protocol NAME
160 --disable-protocol=NAME disable protocol NAME
161 --disable-protocols disable all protocols
162 --enable-indev=NAME enable input device NAME
163 --disable-indev=NAME disable input device NAME
164 --disable-indevs disable input devices
165 --disable-devices disable all devices
166 --enable-filter=NAME enable filter NAME
167 --disable-filter=NAME disable filter NAME
168 --disable-filters disable all filters
169
170External library support:
171
172 Using any of the following switches will allow Libav to link to the
173 corresponding external library. All the components depending on that library
174 will become enabled, if all their other dependencies are met and they are not
175 explicitly disabled. E.g. --enable-libwavpack will enable linking to
176 libwavpack and allow the libwavpack encoder to be built, unless it is
177 specifically disabled with --disable-encoder=libwavpack.
178
179 Note that only the system libraries are auto-detected. All the other external
180 libraries must be explicitly enabled.
181
182 Also note that the following help text describes the purpose of the libraries
183 themselves, not all their features will necessarily be usable by Libav.
184
185 --enable-avisynth video frameserver
186 --enable-avxsynth Linux version of AviSynth
187 --enable-bzlib bzip2 compression [autodetect]
188 --enable-frei0r video filtering plugins
189 --enable-gnutls crypto
190 --enable-libaom AV1 video encoding/decoding
191 --enable-libbs2b Bauer stereophonic-to-binaural DSP
192 --enable-libcdio audio CD input
193 --enable-libdav1d AV1 video decoding
194 --enable-libdc1394 IEEE 1394/Firewire camera input
195 --enable-libdcadec DCA audio decoding
196 --enable-libfaac AAC audio encoding
197 --enable-libfdk-aac AAC audio encoding/decoding
198 --enable-libfontconfig font configuration and management
199 --enable-libfreetype font rendering
200 --enable-libgsm GSM audio encoding/decoding
201 --enable-libhdcd HDCD decoding filter
202 --enable-libilbc ILBC audio encoding/decoding
203 --enable-libjack JACK audio sound server
204 --enable-libkvazaar HEVC video encoding
205 --enable-libmp3lame MP3 audio encoding
206 --enable-libopencore-amrnb AMR-NB audio encoding/decoding
207 --enable-libopencore-amrwb AMR-WB audio decoding
208 --enable-libopencv computer vision
209 --enable-libopenh264 H.264 video encoding/decoding
210 --enable-libopenjpeg JPEG 2000 image encoding/decoding
211 --enable-libopus Opus audio encoding/decoding
212 --enable-libpulse Pulseaudio sound server
213 --enable-librtmp RTMP streaming
214 --enable-libschroedinger Dirac video encoding/decoding
215 --enable-libsnappy snappy compression
216 --enable-libspeex Speex audio encoding/decoding
217 --enable-libsrt Haivision SRT protocol
218 --enable-libtheora Theora video encoding/decoding
219 --enable-libtwolame MP2 audio encoding
220 --enable-libvo-aacenc AAC audio encoding
221 --enable-libvo-amrwbenc AMR-WB audio encoding
222 --enable-libvorbis Vorbis audio encoding/decoding
223 --enable-libvpx VP* video encoding/decoding
224 --enable-libwavpack Wavpack audio encoding/decoding
225 --enable-libwebp WebP image encoding/decoding
226 --enable-libx264 H.264 video encoding
227 --enable-libx265 HEVC video encoding
228 --enable-libxavs Chinese AVS video encoding
229 --enable-libxcb X window system protocol communication
230 --enable-libxcb-shm X11 shm communication [auto]
231 --enable-libxcb-xfixes X11 mouse rendering [auto]
232 --enable-libxvid MPEG-4 ASP video encoding
233 --enable-mbedtls crypto
234 --enable-openssl crypto
235 --enable-zlib compression [autodetect]
236
237 The following libraries provide various hardware acceleration features:
238 --enable-amf AMF video encoding code [auto]
239 --enable-cuda Nvidia CUDA (dynamically linked)
240 --enable-cuvid Nvidia CUVID video decode acceleration
241 --enable-d3d11va Microsoft Direct3D 11 video acceleration [auto]
242 --enable-dxva2 Microsoft DirectX 9 video acceleration [auto]
243 --enable-libmfx Intel MediaSDK (AKA Quick Sync Video)
244 --enable-libnpp Nvidia CUDA processing
245 --enable-mmal Broadcom Multi-Media Abstraction Layer (Raspberry Pi)
246 --enable-nvenc Nvidia video encoding
247 --enable-omx OpenMAX IL
248 --enable-omx-rpi OpenMAX IL for Raspberry Pi
249 --enable-vaapi Video Acceleration API (mainly Unix/Intel)
250 --enable-vda Apple Video Decode Acceleration [auto]
251 --enable-vdpau Nvidia Video Decode and Presentation API for Unix [auto]
252
253Toolchain options:
254 --arch=ARCH select architecture [$arch]
255 --cpu=CPU select the minimum required CPU (affects
256 instruction selection, may crash on older CPUs)
257 --cross-prefix=PREFIX use PREFIX for compilation tools [$cross_prefix]
258 --enable-cross-compile assume a cross-compiler is used
259 --sysroot=PATH root of cross-build tree
260 --sysinclude=PATH location of cross-build system headers
261 --target-os=OS compiler targets OS [$target_os]
262 --target-exec=CMD command to run executables on target
263 --target-path=DIR path to view of build directory on target
264 --target-samples=DIR path to samples directory on target
265 --toolchain=NAME set tool defaults according to NAME
266 (gcc-asan, clang-asan, gcc-msan, clang-msan,
267 gcc-tsan, clang-tsan, gcc-usan, clang-usan,
268 valgrind-massif, valgrind-memcheck,
269 msvc, icl, gcov, llvm-cov, hardened)
270 --nm=NM use nm tool
271 --ar=AR use archive tool AR [$ar_default]
272 --as=AS use assembler AS [$as_default]
273 --cc=CC use C compiler CC [$cc_default]
274 --objcc=OCC use ObjC compiler OCC [$cc_default]
275 --dep-cc=DEPCC use dependency generator DEPCC [$cc_default]
276 --ld=LD use linker LD
277 --x86asmexe=X86ASM use x86 assembler X86ASM
278 --pkg-config=PKGCONFIG use pkg-config tool PKGCONFIG [$pkg_config_default]
279 --pkg-config-flags=FLAGS pass additional flags to pkgconf []
280 --host-cc=HOSTCC use host C compiler HOSTCC
281 --host-cflags=HCFLAGS use HCFLAGS when compiling for host
282 --host-cppflags=HCPPFLAGS use HCPPFLAGS when compiling for host
283 --host-ld=HOSTLD use host linker HOSTLD
284 --host-ldflags=HLDFLAGS use HLDFLAGS when linking for host
285 --host-libs=HLIBS use libs HLIBS when linking for host
286 --host-os=OS compiler host OS [$target_os]
287 --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS [$CFLAGS]
288 --extra-objcflags=FLAGS add FLAGS to OBJCFLAGS [$CFLAGS]
289 --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]
290 --extra-ldexeflags=ELDFLAGS add ELDFLAGS to LDEXEFLAGS [$LDEXEFLAGS]
291 --extra-ldsoflags=ELDFLAGS add ELDFLAGS to LDSOFLAGS [$LDSOFLAGS]
292 --extra-libs=ELIBS add ELIBS [$ELIBS]
293 --extra-version=STRING version string suffix []
294 --optflags=OPTFLAGS override optimization-related compiler flags
295 --enable-pic build position-independent code
296 --enable-thumb compile for Thumb instruction set
297 --enable-lto use link-time optimization
298 --env="ENV=override" override the environment variables
299
300Advanced options (experts only):
301 --malloc-prefix=PREFIX prefix malloc and related names with PREFIX
302 --custom-allocator=NAME use a supported custom allocator
303 --disable-symver disable symbol versioning
304 --enable-hardcoded-tables use hardcoded tables instead of runtime generation
305 --disable-safe-bitstream-reader
306 disable buffer boundary checking in bitreaders
307 (faster, but may crash)
308 --enable-sram allow use of on-chip SRAM
309
310Optimization options (experts only):
311 --disable-asm disable all assembly optimizations
312 --disable-altivec disable AltiVec optimizations
313 --disable-vsx disable VSX optimizations
314 --disable-power8 disable POWER8 optimizations
315 --disable-amd3dnow disable 3DNow! optimizations
316 --disable-amd3dnowext disable 3DNow! extended optimizations
317 --disable-mmx disable MMX optimizations
318 --disable-mmxext disable MMXEXT optimizations
319 --disable-sse disable SSE optimizations
320 --disable-sse2 disable SSE2 optimizations
321 --disable-sse3 disable SSE3 optimizations
322 --disable-ssse3 disable SSSE3 optimizations
323 --disable-sse4 disable SSE4 optimizations
324 --disable-sse42 disable SSE4.2 optimizations
325 --disable-avx disable AVX optimizations
326 --disable-xop disable XOP optimizations
327 --disable-fma3 disable FMA3 optimizations
328 --disable-fma4 disable FMA4 optimizations
329 --disable-avx2 disable AVX2 optimizations
330 --disable-armv5te disable armv5te optimizations
331 --disable-armv6 disable armv6 optimizations
332 --disable-armv6t2 disable armv6t2 optimizations
333 --disable-vfp disable VFP optimizations
334 --disable-neon disable NEON optimizations
335 --disable-inline-asm disable use of inline assembly
336 --disable-x86asm disable use of standalone x86 assembly
337
338Developer options (useful when working on Libav itself):
339 --disable-debug disable debugging symbols
340 --enable-debug=LEVEL set the debug level [$debuglevel]
341 --disable-optimizations disable compiler optimizations
342 --enable-extra-warnings enable more compiler warnings
343 --samples=PATH location of test samples for FATE, if not set use
344 \$LIBAV_SAMPLES at make invocation time.
345 --enable-neon-clobber-test check NEON registers for clobbering (should be
346 used only for debugging purposes)
347 --enable-xmm-clobber-test check XMM registers for clobbering (Win64-only;
348 should be used only for debugging purposes)
349 --disable-valgrind-backtrace do not print a backtrace under Valgrind
350 (only applies to --disable-optimizations builds)
351 --ignore-tests=TESTS comma-separated list (without "fate-" prefix
352 in the name) of tests whose result is ignored
353
354NOTE: Object files are built at the place where configure is launched.
355EOF
356 exit 0
357}
358
359log(){
360 echo "$@" >> $logfile
361}
362
363log_file(){
364 log BEGIN $1
365 i=1
366 while read line; do
367 printf '%5s %s\n' "${i}" "${line}"
368 i=$(($i+1))
369 done < $1 >> $logfile
370 log END $1
371}
372
373echolog(){
374 log "$@"
375 echo "$@"
376}
377
378warn(){
379 log "WARNING: $*"
380 WARNINGS="${WARNINGS}WARNING: $*\n"
381}
382
383die(){
384 echolog "$@"
385 cat <<EOF
386
387If you think configure made a mistake, make sure you are using the latest
388version from Git. If the latest version fails, report the problem to the
389libav-tools@libav.org mailing list or IRC #libav on irc.freenode.net.
390EOF
391 if disabled logging; then
392 cat <<EOF
393Rerun configure with logging enabled (do not use --disable-logging), and
394include the log this produces with your report.
395EOF
396 else
397 cat <<EOF
398Include the log file "$logfile" produced by configure as this will help
399solving the problem.
400EOF
401 fi
402 exit 1
403}
404
405# Avoid locale weirdness, besides we really just want to translate ASCII.
406toupper(){
407 echo "$@" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
408}
409
410tolower(){
411 echo "$@" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
412}
413
414c_escape(){
415 echo "$*" | sed 's/["\\]/\\\0/g'
416}
417
418sh_quote(){
419 v=$(echo "$1" | sed "s/'/'\\\\''/g")
420 test "x$v" = "x${v#*[!A-Za-z0-9_/.+-]}" || v="'$v'"
421 echo "$v"
422}
423
424cleanws(){
425 echo "$@" | sed 's/^ *//;s/ */ /g;s/ *$//'
426}
427
428filter(){
429 pat=$1
430 shift
431 for v; do
432 eval "case '$v' in $pat) printf '%s ' '$v' ;; esac"
433 done
434}
435
436filter_out(){
437 pat=$1
438 shift
439 for v; do
440 eval "case '$v' in $pat) ;; *) printf '%s ' '$v' ;; esac"
441 done
442}
443
444map(){
445 m=$1
446 shift
447 for v; do eval $m; done
448}
449
450add_suffix(){
451 suffix=$1
452 shift
453 for v; do echo ${v}${suffix}; done
454}
455
456set_all(){
457 value=$1
458 shift
459 for var in $*; do
460 eval $var=$value
461 done
462}
463
464set_weak(){
465 value=$1
466 shift
467 for var; do
468 eval : \${$var:=$value}
469 done
470}
471
472sanitize_var_name(){
473 echo $@ | sed 's/[^A-Za-z0-9_]/_/g'
474}
475
476set_sanitized(){
477 var=$1
478 shift
479 eval $(sanitize_var_name "$var")='$*'
480}
481
482get_sanitized(){
483 eval echo \$$(sanitize_var_name "$1")
484}
485
486pushvar(){
487 for pvar in $*; do
488 eval level=\${${pvar}_level:=0}
489 eval ${pvar}_${level}="\$$pvar"
490 eval ${pvar}_level=$(($level+1))
491 done
492}
493
494popvar(){
495 for pvar in $*; do
496 eval level=\${${pvar}_level:-0}
497 test $level = 0 && continue
498 eval level=$(($level-1))
499 eval $pvar="\${${pvar}_${level}}"
500 eval ${pvar}_level=$level
501 eval unset ${pvar}_${level}
502 done
503}
504
505enable(){
506 set_all yes $*
507}
508
509disable(){
510 set_all no $*
511}
512
513enable_weak(){
514 set_weak yes $*
515}
516
517disable_weak(){
518 set_weak no $*
519}
520
521enable_sanitized(){
522 for var; do
523 enable $(sanitize_var_name $var)
524 done
525}
526
527disable_sanitized(){
528 for var; do
529 disable $(sanitize_var_name $var)
530 done
531}
532
533do_enable_deep(){
534 for var; do
535 enabled $var && continue
536 eval sel="\$${var}_select"
537 eval sgs="\$${var}_suggest"
538 pushvar var sgs
539 enable_deep $sel
540 popvar sgs
541 enable_deep_weak $sgs
542 popvar var
543 done
544}
545
546enable_deep(){
547 do_enable_deep $*
548 enable $*
549}
550
551enable_deep_weak(){
552 for var; do
553 disabled $var && continue
554 pushvar var
555 do_enable_deep $var
556 popvar var
557 enable_weak $var
558 done
559}
560
561enabled(){
562 test "${1#!}" = "$1" && op="=" || op="!="
563 eval test "x\$${1#!}" $op "xyes"
564}
565
566disabled(){
567 test "${1#!}" = "$1" && op="=" || op="!="
568 eval test "x\$${1#!}" $op "xno"
569}
570
571enabled_all(){
572 for opt; do
573 enabled $opt || return 1
574 done
575}
576
577disabled_all(){
578 for opt; do
579 disabled $opt || return 1
580 done
581}
582
583enabled_any(){
584 for opt; do
585 enabled $opt && return 0
586 done
587}
588
589disabled_any(){
590 for opt; do
591 disabled $opt && return 0
592 done
593 return 1
594}
595
596set_default(){
597 for opt; do
598 eval : \${$opt:=\$${opt}_default}
599 done
600}
601
602is_in(){
603 value=$1
604 shift
605 for var in $*; do
606 [ $var = $value ] && return 0
607 done
608 return 1
609}
610
611check_deps(){
612 for cfg; do
613 enabled ${cfg}_checking && die "Circular dependency for $cfg."
614 disabled ${cfg}_checking && continue
615 enable ${cfg}_checking
616
617 eval dep_all="\$${cfg}_deps"
618 eval dep_any="\$${cfg}_deps_any"
619 eval dep_con="\$${cfg}_conflict"
620 eval dep_sel="\$${cfg}_select"
621 eval dep_sgs="\$${cfg}_suggest"
622 eval dep_ifa="\$${cfg}_if"
623 eval dep_ifn="\$${cfg}_if_any"
624
625 pushvar cfg dep_all dep_any dep_con dep_sel dep_sgs dep_ifa dep_ifn
626 check_deps $dep_all $dep_any $dep_con $dep_sel $dep_sgs $dep_ifa $dep_ifn
627 popvar cfg dep_all dep_any dep_con dep_sel dep_sgs dep_ifa dep_ifn
628
629 [ -n "$dep_ifa" ] && { enabled_all $dep_ifa && enable_weak $cfg; }
630 [ -n "$dep_ifn" ] && { enabled_any $dep_ifn && enable_weak $cfg; }
631 enabled_all $dep_all || disable $cfg
632 enabled_any $dep_any || disable $cfg
633 disabled_all $dep_con || disable $cfg
634 disabled_any $dep_sel && disable $cfg
635
636 enabled $cfg && enable_deep_weak $dep_sel $dep_sgs
637
638 for dep in $dep_all $dep_any $dep_sel $dep_sgs; do
639 # filter out library deps, these do not belong in extralibs
640 is_in $dep $LIBRARY_LIST && continue
641 enabled $dep && eval append ${cfg}_extralibs ${dep}_extralibs
642 done
643
644 disable ${cfg}_checking
645 done
646}
647
648print_config(){
649 pfx=$1
650 files=$2
651 shift 2
652 map 'eval echo "$v \${$v:-no}"' "$@" |
653 awk "BEGIN { split(\"$files\", files) }
654 {
655 c = \"$pfx\" toupper(\$1);
656 v = \$2;
657 sub(/yes/, 1, v);
658 sub(/no/, 0, v);
659 for (f in files) {
660 file = files[f];
661 if (file ~ /\\.h\$/) {
662 printf(\"#define %s %d\\n\", c, v) >>file;
663 } else if (file ~ /\\.asm\$/) {
664 printf(\"%%define %s %d\\n\", c, v) >>file;
665 } else if (file ~ /\\.mak\$/) {
666 n = -v ? \"\" : \"!\";
667 printf(\"%s%s=yes\\n\", n, c) >>file;
668 }
669 }
670 }"
671}
672
673print_enabled(){
674 suf=$1
675 shift
676 for v; do
677 enabled $v && printf "%s\n" ${v%$suf}
678 done
679}
680
681append(){
682 var=$1
683 shift
684 eval "$var=\"\$$var $*\""
685}
686
687prepend(){
688 var=$1
689 shift
690 eval "$var=\"$* \$$var\""
691}
692
693unique(){
694 var=$1
695 uniq_list=""
696 for tok in $(eval echo \$$var); do
697 uniq_list="$(filter_out $tok $uniq_list) $tok"
698 done
699 eval "$var=\"${uniq_list}\""
700}
701
702resolve(){
703 var=$1
704 tmpvar=
705 for entry in $(eval echo \$$var); do
706 tmpvar="$tmpvar $(eval echo \$${entry})"
707 done
708 eval "$var=\"${tmpvar}\""
709}
710
711add_cppflags(){
712 append CPPFLAGS "$@"
713}
714
715add_cflags(){
716 append CFLAGS $($cflags_filter "$@")
717}
718
719add_cflags_headers(){
720 append CFLAGS_HEADERS $($cflags_filter "$@")
721}
722
723add_objcflags(){
724 append OBJCFLAGS $($objcflags_filter "$@")
725}
726
727add_asflags(){
728 append ASFLAGS $($asflags_filter "$@")
729}
730
731add_ldflags(){
732 append LDFLAGS $($ldflags_filter "$@")
733}
734
735add_ldexeflags(){
736 append LDEXEFLAGS $($ldflags_filter "$@")
737}
738
739add_ldsoflags(){
740 append LDSOFLAGS $($ldflags_filter "$@")
741}
742
743add_extralibs(){
744 prepend extralibs $($ldflags_filter "$@")
745}
746
747add_stripflags(){
748 append STRIPFLAGS "$@"
749}
750
751add_host_cppflags(){
752 append host_cppflags "$@"
753}
754
755add_host_cflags(){
756 append host_cflags $($host_cflags_filter "$@")
757}
758
759add_host_ldflags(){
760 append host_ldflags $($host_ldflags_filter "$@")
761}
762
763add_compat(){
764 append compat_objs $1
765 shift
766 map 'add_cppflags -D$v' "$@"
767}
768
769test_cmd(){
770 log "$@"
771 "$@" >> $logfile 2>&1
772}
773
774cc_e(){
775 eval printf '%s\\n' $CC_E
776}
777
778cc_o(){
779 eval printf '%s\\n' $CC_O
780}
781
782as_o(){
783 eval printf '%s\\n' $AS_O
784}
785
786x86asm_o(){
787 eval printf '%s\\n' $X86ASM_O
788}
789
790ld_o(){
791 eval printf '%s\\n' $LD_O
792}
793
794hostcc_e(){
795 eval printf '%s\\n' $HOSTCC_E
796}
797
798hostcc_o(){
799 eval printf '%s\\n' $HOSTCC_O
800}
801
802test_cc(){
803 log test_cc "$@"
804 cat > $TMPC
805 log_file $TMPC
806 test_cmd $cc $CPPFLAGS $CFLAGS "$@" $CC_C $(cc_o $TMPO) $TMPC
807}
808
809test_objcc(){
810 log test_objcc "$@"
811 cat > $TMPC
812 log_file $TMPC
813 test_cmd $objcc $CPPFLAGS $CFLAGS $OBJCFLAGS "$@" $OBJCC_C $(cc_o $TMPO) $TMPC
814}
815
816test_cpp(){
817 log test_cpp "$@"
818 cat > $TMPC
819 log_file $TMPC
820 test_cmd $cc $CPPFLAGS $CFLAGS "$@" $(cc_e $TMPO) $TMPC
821}
822
823test_as(){
824 log test_as "$@"
825 cat > $TMPS
826 log_file $TMPS
827 test_cmd $as $CPPFLAGS $ASFLAGS "$@" $AS_C $(as_o $TMPO) $TMPS
828}
829
830test_x86asm(){
831 log test_x86asm "$@"
832 echo "$1" > $TMPASM
833 log_file $TMPASM
834 shift
835 test_cmd $x86asmexe $X86ASMFLAGS "$@" $(x86asm_o $TMPO) $TMPASM
836}
837
838check_cmd(){
839 log check_cmd "$@"
840 cmd=$1
841 disabled $cmd && return
842 disable $cmd
843 test_cmd $@ && enable $cmd
844}
845
846check_as(){
847 log check_as "$@"
848 name=$1
849 code=$2
850 shift 2
851 disable $name
852 test_as $@ <<EOF && enable $name
853$code
854EOF
855}
856
857check_inline_asm(){
858 log check_inline_asm "$@"
859 name="$1"
860 code="$2"
861 shift 2
862 disable $name
863 test_cc "$@" <<EOF && enable $name
864void foo(void){ __asm__ volatile($code); }
865EOF
866}
867
868check_insn(){
869 log check_insn "$@"
870 check_inline_asm ${1}_inline "\"$2\""
871 check_as ${1}_external "$2"
872}
873
874check_x86asm(){
875 log check_x86asm "$@"
876 name=$1
877 shift
878 disable $name
879 test_x86asm "$@" && enable $name
880}
881
882test_ld(){
883 log test_ld "$@"
884 flags=$(filter_out '-l*' "$@")
885 libs=$(filter '-l*' "$@")
886 test_cc $($cflags_filter $flags) || return
887 flags=$($ldflags_filter $flags)
888 libs=$($ldflags_filter $libs)
889 test_cmd $ld $LDFLAGS $flags $(ld_o $TMPE) $TMPO $libs $extralibs
890}
891
892check_ld(){
893 log check_ld "$@"
894 name=$1
895 shift
896 disable $name
897 test_ld $@ && enable $name
898}
899
900print_include(){
901 hdr=$1
902 test "${hdr%.h}" = "${hdr}" &&
903 echo "#include $hdr" ||
904 echo "#include <$hdr>"
905}
906
907test_code(){
908 log test_code "$@"
909 check=$1
910 headers=$2
911 code=$3
912 shift 3
913 {
914 for hdr in $headers; do
915 print_include $hdr
916 done
917 echo "int main(void) { $code; return 0; }"
918 } | test_$check "$@"
919}
920
921check_cppflags(){
922 log check_cppflags "$@"
923 test_cpp "$@" <<EOF && add_cppflags "$@"
924#include <stdlib.h>;
925EOF
926}
927
928test_cflags(){
929 log test_cflags "$@"
930 set -- $($cflags_filter "$@")
931 test_cc "$@" <<EOF
932int x;
933EOF
934}
935
936check_cflags(){
937 log check_cflags "$@"
938 test_cflags "$@" && add_cflags "$@"
939}
940
941test_objcflags(){
942 log test_objcflags "$@"
943 set -- $($objcflags_filter "$@")
944 test_objcc "$@" <<EOF
945int x;
946EOF
947}
948
949check_objcflags(){
950 log check_objcflags "$@"
951 test_objcflags "$@" && add_objcflags "$@"
952}
953
954test_ldflags(){
955 log test_ldflags "$@"
956 set -- $($ldflags_filter "$@")
957 test_ld "$@" <<EOF
958int main(void){ return 0; }
959EOF
960}
961
962check_ldflags(){
963 log check_ldflags "$@"
964 test_ldflags "$@" && add_ldflags "$@"
965}
966
967test_stripflags(){
968 log test_stripflags "$@"
969 # call test_cc to get a fresh TMPO
970 test_cc <<EOF
971int main(void) { return 0; }
972EOF
973 test_cmd $strip $STRIPFLAGS "$@" $TMPO
974}
975
976check_stripflags(){
977 log check_stripflags "$@"
978 test_stripflags "$@" && add_stripflags "$@"
979}
980
981check_headers(){
982 log check_headers "$@"
983 headers=$1
984 shift
985 disable_sanitized $headers
986 {
987 for hdr in $headers; do
988 print_include $hdr
989 done
990 echo "int x;"
991 } | test_cpp "$@" && enable_sanitized $headers
992}
993
994check_func(){
995 log check_func "$@"
996 func=$1
997 shift
998 disable $func
999 test_ld "$@" <<EOF && enable $func
1000extern int $func();
1001int main(void){ $func(); }
1002EOF
1003}
1004
1005check_mathfunc(){
1006 log check_mathfunc "$@"
1007 func=$1
1008 narg=$2
1009 shift 2
1010 test $narg = 2 && args="f, g" || args="f"
1011 disable $func
1012 test_ld "$@" <<EOF && enable $func
1013#include <math.h>
1014float foo(float f, float g) { return $func($args); }
1015int main(void){ return 0; }
1016EOF
1017}
1018
1019check_func_headers(){
1020 log check_func_headers "$@"
1021 headers=$1
1022 funcs=$2
1023 shift 2
1024 {
1025 for hdr in $headers; do
1026 print_include $hdr
1027 done
1028 for func in $funcs; do
1029 echo "long check_$func(void) { return (long) $func; }"
1030 done
1031 echo "int main(void) { return 0; }"
1032 } | test_ld "$@" && enable $funcs && enable_sanitized $headers
1033}
1034
1035test_cpp_condition(){
1036 log test_cpp_condition "$@"
1037 header=$1
1038 condition=$2
1039 shift 2
1040 test_cpp "$@" <<EOF
1041#include <$header>
1042#if !($condition)
1043#error "unsatisfied condition: $condition"
1044#endif
1045EOF
1046}
1047
1048check_cpp_condition(){
1049 log check_cpp_condition "$@"
1050 name=$1
1051 shift 1
1052 disable $name
1053 test_cpp_condition "$@" && enable $name
1054}
1055
1056check_lib(){
1057 log check_lib "$@"
1058 name="$1"
1059 headers="$2"
1060 funcs="$3"
1061 shift 3
1062 disable $name
1063 check_func_headers "$headers" "$funcs" "$@" &&
1064 enable $name && eval ${name}_extralibs="\$@"
1065}
1066
1067test_pkg_config(){
1068 log test_pkg_config "$@"
1069 name="$1"
1070 pkg_version="$2"
1071 pkg="${2%% *}"
1072 headers="$3"
1073 funcs="$4"
1074 shift 4
1075 disable $name
1076 test_cmd $pkg_config --exists --print-errors $pkg_version || return
1077 pkg_cflags=$($pkg_config --cflags $pkg_config_flags $pkg)
1078 pkg_libs=$($pkg_config --libs $pkg_config_flags $pkg)
1079 check_func_headers "$headers" "$funcs" $pkg_cflags $pkg_libs "$@" &&
1080 enable $name &&
1081 set_sanitized "${name}_cflags" $pkg_cflags &&
1082 set_sanitized "${name}_extralibs" $pkg_libs
1083}
1084
1085check_pkg_config(){
1086 log check_pkg_config "$@"
1087 name="$1"
1088 test_pkg_config "$@" &&
1089 eval add_cflags \$${name}_cflags
1090}
1091
1092test_exec(){
1093 log test_exec "$@"
1094 test_ld "$@" && { enabled cross_compile || $TMPE >> $logfile 2>&1; }
1095}
1096
1097check_exec_crash(){
1098 log check_exec_crash "$@"
1099 code=$(cat)
1100
1101 # exit() is not async signal safe. _Exit (C99) and _exit (POSIX)
1102 # are safe but may not be available everywhere. Thus we use
1103 # raise(SIGTERM) instead. The check is run in a subshell so we
1104 # can redirect the "Terminated" message from the shell. SIGBUS
1105 # is not defined by standard C so it is used conditionally.
1106
1107 (test_exec "$@") >> $logfile 2>&1 <<EOF
1108#include <signal.h>
1109static void sighandler(int sig){
1110 raise(SIGTERM);
1111}
1112int foo(void){
1113 $code
1114}
1115int (*func_ptr)(void) = foo;
1116int main(void){
1117 signal(SIGILL, sighandler);
1118 signal(SIGFPE, sighandler);
1119 signal(SIGSEGV, sighandler);
1120#ifdef SIGBUS
1121 signal(SIGBUS, sighandler);
1122#endif
1123 return func_ptr();
1124}
1125EOF
1126}
1127
1128check_type(){
1129 log check_type "$@"
1130 headers=$1
1131 type=$2
1132 shift 2
1133 disable_sanitized "$type"
1134 test_code cc "$headers" "$type v" "$@" && enable_sanitized "$type"
1135}
1136
1137check_struct(){
1138 log check_struct "$@"
1139 headers=$1
1140 struct=$2
1141 member=$3
1142 shift 3
1143 disable_sanitized "${struct}_${member}"
1144 test_code cc "$headers" "const void *p = &(($struct *)0)->$member" "$@" &&
1145 enable_sanitized "${struct}_${member}"
1146}
1147
1148check_builtin(){
1149 log check_builtin "$@"
1150 name=$1
1151 shift
1152 disable "$name"
1153 test_code ld "$@" && enable "$name"
1154}
1155
1156check_compile_assert(){
1157 log check_compile_assert "$@"
1158 name=$1
1159 headers=$2
1160 condition=$3
1161 shift 3
1162 disable "$name"
1163 test_code cc "$headers" "char c[2 * !!($condition) - 1]" "$@" && enable "$name"
1164}
1165
1166check_cc(){
1167 log check_cc "$@"
1168 name=$1
1169 shift
1170 disable "$name"
1171 test_code cc "$@" && enable "$name"
1172}
1173
1174require(){
1175 log require "$@"
1176 name_version="$1"
1177 name="${1%% *}"
1178 shift
1179 check_lib $name "$@" || die "ERROR: $name_version not found"
1180}
1181
1182require_cc(){
1183 log require_cc "$@"
1184 name="$1"
1185 check_cc "$@" || die "ERROR: $name failed"
1186}
1187
1188require_headers(){
1189 log require_headers "$@"
1190 headers="$1"
1191 check_headers "$@" || die "ERROR: $headers not found"
1192}
1193
1194require_cpp_condition(){
1195 log require_cpp_condition "$@"
1196 condition="$2"
1197 check_cpp_condition "$@" || die "ERROR: $condition not satisfied"
1198}
1199
1200require_pkg_config(){
1201 log require_pkg_config "$@"
1202 pkg_version="$2"
1203 check_pkg_config "$@" || die "ERROR: $pkg_version not found"
1204}
1205
1206test_host_cc(){
1207 log test_host_cc "$@"
1208 cat > $TMPC
1209 log_file $TMPC
1210 test_cmd $host_cc $host_cflags "$@" $HOSTCC_C $(hostcc_o $TMPO) $TMPC
1211}
1212
1213test_host_cpp(){
1214 log test_host_cpp "$@"
1215 cat > $TMPC
1216 log_file $TMPC
1217 test_cmd $host_cc $host_cppflags $host_cflags "$@" $(hostcc_e $TMPO) $TMPC
1218}
1219
1220check_host_cppflags(){
1221 log check_host_cppflags "$@"
1222 test_host_cpp "$@" <<EOF && append host_cppflags "$@"
1223#include <stdlib.h>;
1224EOF
1225}
1226
1227check_host_cflags(){
1228 log check_host_cflags "$@"
1229 set -- $($host_cflags_filter "$@")
1230 test_host_cc "$@" <<EOF && append host_cflags "$@"
1231int x;
1232EOF
1233}
1234
1235test_host_cpp_condition(){
1236 log test_host_cpp_condition "$@"
1237 header=$1
1238 condition=$2
1239 shift 2
1240 test_host_cpp "$@" <<EOF
1241#include <$header>
1242#if !($condition)
1243#error "unsatisfied condition: $condition"
1244#endif
1245EOF
1246}
1247
1248check_host_cpp_condition(){
1249 log check_host_cpp_condition "$@"
1250 name=$1
1251 shift 1
1252 disable $name
1253 test_host_cpp_condition "$@" && enable $name
1254}
1255
1256cp_if_changed(){
1257 cmp -s "$1" "$2" && { test "$quiet" != "yes" && echo "$2 is unchanged"; } && return
1258 mkdir -p "$(dirname $2)"
1259 cp -f "$1" "$2"
1260}
1261
1262# CONFIG_LIST contains configurable options, while HAVE_LIST is for
1263# system-dependent things.
1264
1265AVCODEC_COMPONENTS="
1266 bsfs
1267 decoders
1268 encoders
1269 hwaccels
1270 parsers
1271"
1272
1273AVDEVICE_COMPONENTS="
1274 indevs
1275"
1276AVFILTER_COMPONENTS="
1277 filters
1278"
1279AVFORMAT_COMPONENTS="
1280 demuxers
1281 muxers
1282 protocols
1283"
1284
1285COMPONENT_LIST="
1286 $AVCODEC_COMPONENTS
1287 $AVDEVICE_COMPONENTS
1288 $AVFILTER_COMPONENTS
1289 $AVFORMAT_COMPONENTS
1290"
1291
1292EXAMPLE_LIST="
1293 decode_audio_example
1294 decode_video_example
1295 encode_audio_example
1296 encode_video_example
1297 filter_audio_example
1298 metadata_example
1299 output_example
1300 qsvdec_example
1301 transcode_aac_example
1302"
1303
1304# catchall list of things that require external libs to link
1305EXTRALIBS_LIST="
1306 cpu_init
1307 cws2fws
1308"
1309
1310HWACCEL_LIBRARY_NONFREE_LIST="
1311 cuda
1312 cuvid
1313 libnpp
1314"
1315HWACCEL_LIBRARY_LIST="
1316 $HWACCEL_LIBRARY_NONFREE_LIST
1317 amf
1318 d3d11va
1319 dxva2
1320 libmfx
1321 mmal
1322 nvenc
1323 omx
1324 vaapi
1325 vda
1326 vdpau
1327"
1328
1329EXTERNAL_LIBRARY_GPL_LIST="
1330 libcdio
1331 libx264
1332 libx265
1333 libxavs
1334 libxvid
1335"
1336
1337EXTERNAL_LIBRARY_NONFREE_LIST="
1338 libfaac
1339 libfdk_aac
1340 openssl
1341"
1342
1343EXTERNAL_LIBRARY_VERSION3_LIST="
1344 libopencore_amrnb
1345 libopencore_amrwb
1346 libvo_aacenc
1347 libvo_amrwbenc
1348 mbedtls
1349"
1350
1351EXTERNAL_LIBRARY_LIST="
1352 $EXTERNAL_LIBRARY_GPL_LIST
1353 $EXTERNAL_LIBRARY_NONFREE_LIST
1354 $EXTERNAL_LIBRARY_VERSION3_LIST
1355 avisynth
1356 avxsynth
1357 frei0r
1358 gnutls
1359 libaom
1360 libbs2b
1361 libdav1d
1362 libdc1394
1363 libdcadec
1364 libfontconfig
1365 libfreetype
1366 libgsm
1367 libhdcd
1368 libilbc
1369 libjack
1370 libkvazaar
1371 libmp3lame
1372 libopencv
1373 libopenh264
1374 libopenjpeg
1375 libopus
1376 libpulse
1377 librtmp
1378 libschroedinger
1379 libsnappy
1380 libspeex
1381 libsrt
1382 libtheora
1383 libtwolame
1384 libvorbis
1385 libvpx
1386 libwavpack
1387 libwebp
1388 libxcb
1389 libxcb_shm
1390 libxcb_xfixes
1391"
1392
1393SYSTEM_LIBRARY_LIST="
1394 bzlib
1395 zlib
1396"
1397
1398FEATURE_LIST="
1399 gray
1400 hardcoded_tables
1401 omx_rpi
1402 runtime_cpudetect
1403 safe_bitstream_reader
1404 shared
1405 small
1406 sram
1407 static
1408 swscale_alpha
1409"
1410
1411LIBRARY_LIST="
1412 avcodec
1413 avdevice
1414 avfilter
1415 avformat
1416 avresample
1417 avutil
1418 swscale
1419"
1420
1421LICENSE_LIST="
1422 gpl
1423 nonfree
1424 version3
1425"
1426
1427PROGRAM_LIST="
1428 avconv
1429 avplay
1430 avprobe
1431"
1432
1433SUBSYSTEM_LIST="
1434 dct
1435 doc
1436 error_resilience
1437 faan
1438 fft
1439 lsp
1440 lzo
1441 mdct
1442 network
1443 rdft
1444"
1445
1446# COMPONENT_LIST needs to come last to ensure correct dependency checking
1447CONFIG_LIST="
1448 $EXAMPLE_LIST
1449 $EXTERNAL_LIBRARY_LIST
1450 $HWACCEL_LIBRARY_LIST
1451 $FEATURE_LIST
1452 $LICENSE_LIST
1453 $LIBRARY_LIST
1454 $PROGRAM_LIST
1455 $SUBSYSTEM_LIST
1456 $SYSTEM_LIBRARY_LIST
1457 neon_clobber_test
1458 pic
1459 pod2man
1460 texi2html
1461 thumb
1462 valgrind_backtrace
1463 xmm_clobber_test
1464 $COMPONENT_LIST
1465"
1466
1467THREADS_LIST="
1468 pthreads
1469 w32threads
1470"
1471
1472ATOMICS_LIST="
1473 atomics_gcc
1474 atomics_suncc
1475 atomics_win32
1476"
1477
1478ARCH_LIST="
1479 aarch64
1480 alpha
1481 arm
1482 avr32
1483 avr32_ap
1484 avr32_uc
1485 bfin
1486 ia64
1487 m68k
1488 mips
1489 mips64
1490 parisc
1491 ppc
1492 ppc64
1493 s390
1494 sh4
1495 sparc
1496 sparc64
1497 tilegx
1498 tilepro
1499 tomi
1500 x86
1501 x86_32
1502 x86_64
1503"
1504
1505ARCH_EXT_LIST_ARM="
1506 armv5te
1507 armv6
1508 armv6t2
1509 armv8
1510 neon
1511 vfp
1512 vfpv3
1513"
1514
1515ARCH_EXT_LIST_X86_SIMD="
1516 amd3dnow
1517 amd3dnowext
1518 avx
1519 avx2
1520 fma3
1521 fma4
1522 mmx
1523 mmxext
1524 sse
1525 sse2
1526 sse3
1527 sse4
1528 sse42
1529 ssse3
1530 xop
1531"
1532
1533ARCH_EXT_LIST_PPC="
1534 altivec
1535 dcbzl
1536 ldbrx
1537 power8
1538 ppc4xx
1539 vsx
1540"
1541
1542ARCH_EXT_LIST_X86="
1543 $ARCH_EXT_LIST_X86_SIMD
1544 cpunop
1545 i686
1546"
1547
1548ARCH_EXT_LIST_MIPS="
1549 loongson
1550 mips32r1
1551 mips64r1
1552 mips32r2
1553 mips64r2
1554 mips32r6
1555 mips64r6
1556"
1557
1558ARCH_EXT_LIST="
1559 $ARCH_EXT_LIST_ARM
1560 $ARCH_EXT_LIST_MIPS
1561 $ARCH_EXT_LIST_PPC
1562 $ARCH_EXT_LIST_X86
1563 vis
1564"
1565
1566ARCH_FEATURES="
1567 aligned_stack
1568 fast_64bit
1569 fast_clz
1570 fast_cmov
1571 local_aligned_8
1572 local_aligned_16
1573 local_aligned_32
1574 simd_align_16
1575 simd_align_32
1576"
1577
1578BUILTIN_LIST="
1579 atomic_cas_ptr
1580 machine_rw_barrier
1581 MemoryBarrier
1582 mm_empty
1583 rdtsc
1584 sem_timedwait
1585 sync_val_compare_and_swap
1586"
1587HAVE_LIST_CMDLINE="
1588 inline_asm
1589 symver
1590 x86asm
1591"
1592
1593HAVE_LIST_PUB="
1594 bigendian
1595 fast_unaligned
1596"
1597
1598HEADERS_LIST="
1599 AVFoundation_AVFoundation_h
1600 arpa_inet_h
1601 cdio_paranoia_h
1602 cdio_paranoia_paranoia_h
1603 dispatch_dispatch_h
1604 dev_bktr_ioctl_bt848_h
1605 dev_bktr_ioctl_meteor_h
1606 dev_ic_bt8xx_h
1607 dev_video_bktr_ioctl_bt848_h
1608 dev_video_meteor_ioctl_meteor_h
1609 direct_h
1610 dxgidebug_h
1611 dxva_h
1612 io_h
1613 machine_ioctl_bt848_h
1614 machine_ioctl_meteor_h
1615 malloc_h
1616 poll_h
1617 sys_param_h
1618 sys_resource_h
1619 sys_select_h
1620 sys_soundcard_h
1621 sys_time_h
1622 sys_un_h
1623 sys_videoio_h
1624 unistd_h
1625 valgrind_valgrind_h
1626 windows_h
1627 winsock2_h
1628"
1629
1630INTRINSICS_LIST="
1631 intrinsics_neon
1632"
1633
1634MATH_FUNCS="
1635 atanf
1636 atan2f
1637 cbrtf
1638 cosf
1639 exp2
1640 exp2f
1641 expf
1642 isinf
1643 isnan
1644 ldexpf
1645 llrint
1646 llrintf
1647 log2
1648 log2f
1649 log10f
1650 lrint
1651 lrintf
1652 powf
1653 rint
1654 round
1655 roundf
1656 sinf
1657 trunc
1658 truncf
1659"
1660
1661SYSTEM_FEATURES="
1662 dos_paths
1663 libc_msvcrt
1664 MMAL_PARAMETER_VIDEO_MAX_NUM_CALLBACKS
1665 section_data_rel_ro
1666 threads
1667 uwp
1668"
1669
1670SYSTEM_FUNCS="
1671 aligned_malloc
1672 clock_gettime
1673 closesocket
1674 CommandLineToArgvW
1675 fcntl
1676 getaddrinfo
1677 gethrtime
1678 getopt
1679 GetProcessAffinityMask
1680 GetProcessMemoryInfo
1681 GetProcessTimes
1682 getrusage
1683 GetSystemTimeAsFileTime
1684 gettimeofday
1685 gmtime_r
1686 inet_aton
1687 isatty
1688 localtime_r
1689 mach_absolute_time
1690 MapViewOfFile
1691 memalign
1692 mmap
1693 mprotect
1694 nanosleep
1695 posix_memalign
1696 sched_getaffinity
1697 SetConsoleTextAttribute
1698 setmode
1699 setrlimit
1700 Sleep
1701 strerror_r
1702 sysconf
1703 sysctl
1704 usleep
1705 VirtualAlloc
1706"
1707
1708SYSTEM_LIBRARIES="
1709 bcrypt
1710 sdl
1711 vaapi_1
1712 vaapi_drm
1713 vaapi_x11
1714 vdpau_x11
1715"
1716
1717TOOLCHAIN_FEATURES="
1718 as_arch_directive
1719 as_fpu_directive
1720 as_func
1721 as_object_arch
1722 asm_mod_q
1723 blocks_extension
1724 ebp_available
1725 ebx_available
1726 gnu_as
1727 ibm_asm
1728 inline_asm_labels
1729 pragma_deprecated
1730 symver_asm_label
1731 symver_gnu_asm
1732 vfp_args
1733 xform_asm
1734 xmm_clobbers
1735"
1736
1737TYPES_LIST="
1738 CUVIDDECODECREATEINFO_bitDepthMinus8
1739 socklen_t
1740 struct_addrinfo
1741 struct_group_source_req
1742 struct_ip_mreq_source
1743 struct_ipv6_mreq
1744 struct_pollfd
1745 struct_rusage_ru_maxrss
1746 struct_sockaddr_in6
1747 struct_sockaddr_sa_len
1748 struct_sockaddr_storage
1749 struct_v4l2_frmivalenum_discrete
1750"
1751
1752HAVE_LIST="
1753 $ARCH_EXT_LIST
1754 $(add_suffix _external $ARCH_EXT_LIST)
1755 $(add_suffix _inline $ARCH_EXT_LIST)
1756 $ARCH_FEATURES
1757 $BUILTIN_LIST
1758 $HAVE_LIST_CMDLINE
1759 $HAVE_LIST_PUB
1760 $HEADERS_LIST
1761 $INTRINSICS_LIST
1762 $MATH_FUNCS
1763 $SYSTEM_FEATURES
1764 $SYSTEM_FUNCS
1765 $SYSTEM_LIBRARIES
1766 $THREADS_LIST
1767 $TOOLCHAIN_FEATURES
1768 $TYPES_LIST
1769"
1770
1771# options emitted with CONFIG_ prefix but not available on the command line
1772CONFIG_EXTRA="
1773 aandcttables
1774 ac3dsp
1775 adts_header
1776 audio_frame_queue
1777 audiodsp
1778 blockdsp
1779 bswapdsp
1780 cabac
1781 cbs
1782 cbs_h264
1783 cbs_h265
1784 cbs_mpeg2
1785 dirac_parse
1786 dvprofile
1787 faandct
1788 faanidct
1789 fdctdsp
1790 flacdsp
1791 fmtconvert
1792 g722dsp
1793 gmp
1794 golomb
1795 gplv3
1796 h263dsp
1797 h264chroma
1798 h264dsp
1799 h264parse
1800 h264pred
1801 h264qpel
1802 hevcparse
1803 hpeldsp
1804 huffman
1805 huffyuvdsp
1806 huffyuvencdsp
1807 idctdsp
1808 iirfilter
1809 imdct15
1810 intrax8
1811 iso_media
1812 ividsp
1813 jpegtables
1814 lgplv3
1815 libx262
1816 libxcb_shape
1817 lpc
1818 lzf
1819 me_cmp
1820 mpeg_er
1821 mpegaudio
1822 mpegaudiodsp
1823 mpegaudioheader
1824 mpegvideo
1825 mpegvideoenc
1826 mss34dsp
1827 pixblockdsp
1828 qpeldsp
1829 qsv
1830 qsvdec
1831 qsvenc
1832 qsvvpp
1833 rangecoder
1834 riffdec
1835 riffenc
1836 rtpdec
1837 rtpenc_chain
1838 rv34dsp
1839 sinewin
1840 snappy
1841 srtp
1842 startcode
1843 texturedsp
1844 texturedspenc
1845 tpeldsp
1846 vaapi_encode
1847 vc1dsp
1848 videodsp
1849 vp3dsp
1850 vp56dsp
1851 vp8dsp
1852 wma_freqs
1853 wmv2dsp
1854"
1855
1856CMDLINE_SELECT="
1857 $ARCH_EXT_LIST
1858 $CONFIG_LIST
1859 $HAVE_LIST_CMDLINE
1860 $THREADS_LIST
1861 asm
1862 cross_compile
1863 debug
1864 extra_warnings
1865 logging
1866 lto
1867 optimizations
1868 rpath
1869"
1870
1871PATHS_LIST="
1872 bindir
1873 datadir
1874 docdir
1875 incdir
1876 libdir
1877 mandir
1878 prefix
1879 shlibdir
1880"
1881
1882CMDLINE_SET="
1883 $PATHS_LIST
1884 ar
1885 arch
1886 as
1887 cc
1888 objcc
1889 cpu
1890 cross_prefix
1891 custom_allocator
1892 dep_cc
1893 env
1894 extra_version
1895 host_cc
1896 host_cflags
1897 host_extralibs
1898 host_ld
1899 host_ldflags
1900 host_os
1901 ignore_tests
1902 ld
1903 logfile
1904 malloc_prefix
1905 nm
1906 optflags
1907 pkg_config
1908 pkg_config_flags
1909 samples
1910 sysinclude
1911 sysroot
1912 target_exec
1913 target_os
1914 target_path
1915 target_samples
1916 toolchain
1917 x86asmexe
1918"
1919
1920CMDLINE_APPEND="
1921 extra_cflags
1922 extra_objcflags
1923 host_cppflags
1924"
1925
1926# code dependency declarations
1927
1928# architecture extensions
1929
1930armv5te_deps="arm"
1931armv6_deps="arm"
1932armv6t2_deps="arm"
1933armv8_deps="aarch64"
1934neon_deps_any="aarch64 arm"
1935intrinsics_neon_deps="neon"
1936vfp_deps_any="aarch64 arm"
1937vfpv3_deps="vfp"
1938
1939map 'eval ${v}_inline_deps=inline_asm' $ARCH_EXT_LIST_ARM
1940
1941altivec_deps="ppc"
1942dcbzl_deps="ppc"
1943ldbrx_deps="ppc"
1944ppc4xx_deps="ppc"
1945vsx_deps="altivec"
1946power8_deps="vsx"
1947
1948loongson_deps="mips"
1949mips32r1_deps="mips32"
1950mips32r2_deps="mips32"
1951mips32r6_deps="mips32"
1952mips64r1_deps="mips64"
1953mips64r2_deps="mips64"
1954mips64r6_deps="mips64"
1955
1956vis_deps="sparc"
1957
1958cpunop_deps="i686"
1959x86_64_select="i686"
1960x86_64_suggest="fast_cmov"
1961
1962amd3dnow_deps="mmx"
1963amd3dnowext_deps="amd3dnow"
1964i686_deps="x86"
1965mmx_deps="x86"
1966mmxext_deps="mmx"
1967sse_deps="mmxext"
1968sse2_deps="sse"
1969sse3_deps="sse2"
1970ssse3_deps="sse3"
1971sse4_deps="ssse3"
1972sse42_deps="sse4"
1973avx_deps="sse42"
1974xop_deps="avx"
1975fma3_deps="avx"
1976fma4_deps="avx"
1977avx2_deps="avx"
1978
1979mmx_external_deps="x86asm"
1980mmx_inline_deps="inline_asm x86"
1981mmx_suggest="mmx_external mmx_inline"
1982
1983for ext in $(filter_out mmx $ARCH_EXT_LIST_X86_SIMD); do
1984 eval dep=\$${ext}_deps
1985 eval ${ext}_external_deps='"${dep}_external"'
1986 eval ${ext}_inline_deps='"${dep}_inline"'
1987 eval ${ext}_suggest='"${ext}_external ${ext}_inline"'
1988done
1989
1990aligned_stack_if_any="aarch64 ppc x86"
1991fast_64bit_if_any="aarch64 alpha ia64 mips64 parisc64 ppc64 sparc64 x86_64"
1992fast_clz_if_any="aarch64 alpha avr32 mips ppc x86"
1993fast_unaligned_if_any="aarch64 ppc x86"
1994simd_align_16_if_any="altivec neon sse"
1995simd_align_32_if_any="avx"
1996
1997# system capabilities
1998symver_if_any="symver_asm_label symver_gnu_asm"
1999valgrind_backtrace_conflict="optimizations"
2000valgrind_backtrace_deps="valgrind_valgrind_h"
2001
2002# threading support
2003atomics_gcc_if="sync_val_compare_and_swap"
2004atomics_suncc_if="atomic_cas_ptr machine_rw_barrier"
2005atomics_win32_if="MemoryBarrier"
2006atomics_native_if_any="$ATOMICS_LIST"
2007w32threads_deps="atomics_native CONDITION_VARIABLE"
2008threads_if_any="$THREADS_LIST"
2009
2010# subsystems
2011cbs_h264_select="cbs golomb"
2012cbs_h265_select="cbs golomb"
2013cbs_mpeg2_select="cbs"
2014dct_select="rdft"
2015dirac_parse_select="golomb"
2016error_resilience_select="me_cmp"
2017faandct_deps="faan"
2018faandct_select="fdctdsp"
2019faanidct_deps="faan"
2020faanidct_select="idctdsp"
2021h264dsp_select="startcode"
2022hevcparse_select="golomb"
2023intrax8_select="blockdsp idctdsp"
2024mdct_select="fft"
2025rdft_select="fft"
2026me_cmp_select="fdctdsp idctdsp pixblockdsp"
2027mpeg_er_select="error_resilience"
2028mpegaudio_select="mpegaudiodsp mpegaudioheader"
2029mpegaudiodsp_select="dct"
2030mpegvideo_select="blockdsp hpeldsp idctdsp me_cmp mpeg_er videodsp"
2031mpegvideoenc_select="me_cmp mpegvideo pixblockdsp qpeldsp"
2032vc1dsp_select="h264chroma qpeldsp startcode"
2033
2034# decoders / encoders
2035aac_decoder_select="adts_header imdct15 mdct sinewin"
2036aac_encoder_select="audio_frame_queue iirfilter mdct sinewin"
2037aac_latm_decoder_select="aac_decoder aac_latm_parser"
2038ac3_decoder_select="ac3_parser ac3dsp bswapdsp fmtconvert mdct"
2039ac3_encoder_select="ac3dsp audiodsp mdct me_cmp"
2040ac3_fixed_encoder_select="ac3dsp audiodsp mdct me_cmp"
2041adpcm_g722_decoder_select="g722dsp"
2042adpcm_g722_encoder_select="g722dsp"
2043aic_decoder_select="golomb idctdsp"
2044alac_encoder_select="lpc"
2045als_decoder_select="bswapdsp"
2046amrnb_decoder_select="lsp"
2047amrwb_decoder_select="lsp"
2048amv_decoder_select="sp5x_decoder"
2049ape_decoder_select="bswapdsp"
2050asv1_decoder_select="blockdsp bswapdsp idctdsp"
2051asv1_encoder_select="bswapdsp fdctdsp pixblockdsp"
2052asv2_decoder_select="blockdsp bswapdsp idctdsp"
2053asv2_encoder_select="bswapdsp fdctdsp pixblockdsp"
2054atrac1_decoder_select="mdct sinewin"
2055atrac3_decoder_select="mdct"
2056atrac3p_decoder_select="mdct sinewin"
2057bink_decoder_select="blockdsp hpeldsp"
2058binkaudio_dct_decoder_select="mdct rdft dct sinewin wma_freqs"
2059binkaudio_rdft_decoder_select="mdct rdft sinewin wma_freqs"
2060cavs_decoder_select="blockdsp golomb h264chroma idctdsp qpeldsp videodsp"
2061clearvideo_decoder_select="idctdsp"
2062cllc_decoder_select="bswapdsp"
2063comfortnoise_encoder_select="lpc"
2064cook_decoder_select="audiodsp mdct sinewin"
2065cscd_decoder_select="lzo"
2066cscd_decoder_suggest="zlib"
2067dca_decoder_select="fmtconvert mdct"
2068dds_decoder_select="texturedsp"
2069dnxhd_decoder_select="blockdsp idctdsp"
2070dnxhd_encoder_select="aandcttables blockdsp fdctdsp idctdsp mpegvideoenc pixblockdsp"
2071dvvideo_decoder_select="dvprofile idctdsp"
2072dvvideo_encoder_select="dvprofile fdctdsp me_cmp pixblockdsp"
2073dxa_decoder_deps="zlib"
2074dxv_decoder_select="lzf texturedsp"
2075eac3_decoder_select="ac3_decoder"
2076eac3_encoder_select="ac3_encoder"
2077eamad_decoder_select="aandcttables blockdsp bswapdsp idctdsp mpegvideo"
2078eatgq_decoder_select="aandcttables idctdsp"
2079eatqi_decoder_select="aandcttables blockdsp bswapdsp idctdsp"
2080exr_decoder_deps="zlib"
2081ffv1_decoder_select="rangecoder"
2082ffv1_encoder_select="rangecoder"
2083ffvhuff_decoder_select="huffyuv_decoder"
2084ffvhuff_encoder_select="huffyuv_encoder"
2085fic_decoder_select="golomb"
2086flac_decoder_select="flacdsp"
2087flac_encoder_select="bswapdsp flacdsp lpc"
2088flashsv_decoder_deps="zlib"
2089flashsv_encoder_deps="zlib"
2090flashsv2_decoder_deps="zlib"
2091flv_decoder_select="h263_decoder"
2092flv_encoder_select="h263_encoder"
2093fourxm_decoder_select="blockdsp bswapdsp"
2094fraps_decoder_select="bswapdsp huffman"
2095g2m_decoder_deps="zlib"
2096g2m_decoder_select="blockdsp idctdsp jpegtables"
2097h261_decoder_select="mpeg_er mpegvideo"
2098h261_encoder_select="aandcttables mpegvideoenc"
2099h263_decoder_select="error_resilience h263_parser h263dsp mpeg_er mpegvideo qpeldsp"
2100h263_encoder_select="aandcttables h263dsp mpegvideoenc"
2101h263i_decoder_select="h263_decoder"
2102h263p_encoder_select="h263_encoder"
2103h264_decoder_select="cabac golomb h264chroma h264dsp h264parse h264pred h264qpel videodsp"
2104h264_decoder_suggest="error_resilience"
2105hap_decoder_select="snappy texturedsp"
2106hap_encoder_deps="libsnappy"
2107hap_encoder_select="texturedspenc"
2108hevc_decoder_select="bswapdsp cabac hevcparse videodsp"
2109huffyuv_decoder_select="bswapdsp huffyuvdsp"
2110huffyuv_encoder_select="bswapdsp huffman huffyuvencdsp"
2111iac_decoder_select="imc_decoder"
2112imc_decoder_select="bswapdsp fft mdct sinewin"
2113indeo3_decoder_select="hpeldsp"
2114indeo4_decoder_select="ividsp"
2115indeo5_decoder_select="ividsp"
2116interplay_video_decoder_select="hpeldsp"
2117jpegls_decoder_select="mjpeg_decoder"
2118jv_decoder_select="blockdsp"
2119lagarith_decoder_select="huffyuvdsp"
2120ljpeg_encoder_select="aandcttables idctdsp jpegtables"
2121magicyuv_decoder_select="huffyuvdsp"
2122mdec_decoder_select="blockdsp idctdsp mpegvideo"
2123metasound_decoder_select="lsp mdct sinewin"
2124mimic_decoder_select="blockdsp bswapdsp hpeldsp idctdsp"
2125mjpeg_decoder_select="blockdsp hpeldsp idctdsp jpegtables"
2126mjpeg_encoder_select="aandcttables jpegtables mpegvideoenc"
2127mjpegb_decoder_select="mjpeg_decoder"
2128mlp_decoder_select="mlp_parser"
2129motionpixels_decoder_select="bswapdsp"
2130mp1_decoder_select="mpegaudio"
2131mp1float_decoder_select="mpegaudio"
2132mp2_decoder_select="mpegaudio"
2133mp2float_decoder_select="mpegaudio"
2134mp3_decoder_select="mpegaudio"
2135mp3adu_decoder_select="mpegaudio"
2136mp3adufloat_decoder_select="mpegaudio"
2137mp3float_decoder_select="mpegaudio"
2138mp3on4_decoder_select="mpegaudio"
2139mp3on4float_decoder_select="mpegaudio"
2140mpc7_decoder_select="bswapdsp mpegaudiodsp"
2141mpc8_decoder_select="mpegaudiodsp"
2142mpeg1video_decoder_select="error_resilience mpeg_er mpegvideo"
2143mpeg1video_encoder_select="aandcttables mpegvideoenc"
2144mpeg2video_decoder_select="error_resilience mpeg_er mpegvideo"
2145mpeg2video_encoder_select="aandcttables mpegvideoenc"
2146mpeg4_decoder_select="h263_decoder mpeg4video_parser"
2147mpeg4_encoder_select="h263_encoder"
2148msa1_decoder_select="mss34dsp"
2149msmpeg4v1_decoder_select="h263_decoder"
2150msmpeg4v2_decoder_select="h263_decoder"
2151msmpeg4v2_encoder_select="h263_encoder"
2152msmpeg4v3_decoder_select="h263_decoder"
2153msmpeg4v3_encoder_select="h263_encoder"
2154mss2_decoder_select="error_resilience mpeg_er mpegvideo qpeldsp vc1_decoder"
2155mts2_decoder_select="mss34dsp"
2156mxpeg_decoder_select="mjpeg_decoder"
2157nellymoser_decoder_select="mdct sinewin"
2158nellymoser_encoder_select="audio_frame_queue mdct sinewin"
2159nuv_decoder_select="idctdsp lzo"
2160on2avc_decoder_select="mdct"
2161opus_decoder_deps="avresample"
2162opus_decoder_select="imdct15"
2163png_decoder_deps="zlib"
2164png_encoder_deps="zlib"
2165png_encoder_select="huffyuvencdsp"
2166prores_decoder_select="idctdsp"
2167prores_encoder_select="fdctdsp"
2168qcelp_decoder_select="lsp"
2169qdm2_decoder_select="mdct rdft mpegaudiodsp"
2170ra_144_encoder_select="audio_frame_queue lpc"
2171ralf_decoder_select="golomb"
2172rscc_decoder_deps="zlib"
2173rv10_decoder_select="error_resilience h263_decoder h263dsp mpeg_er"
2174rv10_encoder_select="h263_encoder"
2175rv20_decoder_select="error_resilience h263_decoder h263dsp mpeg_er"
2176rv20_encoder_select="h263_encoder"
2177rv30_decoder_select="error_resilience golomb h264chroma h264pred h264qpel mpeg_er mpegvideo rv34dsp videodsp"
2178rv40_decoder_select="error_resilience golomb h264chroma h264pred h264qpel mpeg_er mpegvideo rv34dsp videodsp"
2179screenpresso_decoder_deps="zlib"
2180sipr_decoder_select="lsp"
2181sp5x_decoder_select="mjpeg_decoder"
2182svq1_decoder_select="hpeldsp"
2183svq1_encoder_select="aandcttables hpeldsp me_cmp mpegvideoenc"
2184svq3_decoder_select="golomb h264dsp h264parse h264pred hpeldsp tpeldsp videodsp"
2185svq3_decoder_suggest="zlib"
2186tak_decoder_select="audiodsp"
2187tdsc_decoder_deps="zlib"
2188tdsc_decoder_select="mjpeg_decoder"
2189theora_decoder_select="vp3_decoder"
2190thp_decoder_select="mjpeg_decoder"
2191tiff_decoder_suggest="zlib"
2192tiff_encoder_suggest="zlib"
2193truehd_decoder_select="mlp_decoder"
2194truemotion2_decoder_select="bswapdsp"
2195truespeech_decoder_select="bswapdsp"
2196tscc_decoder_deps="zlib"
2197txd_decoder_select="texturedsp"
2198twinvq_decoder_select="mdct lsp sinewin"
2199utvideo_decoder_select="bswapdsp huffyuvdsp"
2200utvideo_encoder_select="bswapdsp huffman huffyuvencdsp"
2201vble_decoder_select="huffyuvdsp"
2202vc1_decoder_select="blockdsp error_resilience h263_decoder h264qpel intrax8 mpeg_er mpegvideo vc1dsp"
2203vc1image_decoder_select="vc1_decoder"
2204vorbis_decoder_select="mdct"
2205vorbis_encoder_select="mdct"
2206vp3_decoder_select="hpeldsp vp3dsp videodsp"
2207vp5_decoder_select="h264chroma hpeldsp videodsp vp3dsp vp56dsp"
2208vp6_decoder_select="h264chroma hpeldsp huffman videodsp vp3dsp vp56dsp"
2209vp6a_decoder_select="vp6_decoder"
2210vp6f_decoder_select="vp6_decoder"
2211vp7_decoder_select="h264pred videodsp vp8dsp"
2212vp8_decoder_select="h264pred videodsp vp8dsp"
2213vp9_decoder_select="videodsp vp9_superframe_split_bsf"
2214webp_decoder_select="vp8_decoder"
2215wmapro_decoder_select="mdct sinewin wma_freqs"
2216wmav1_decoder_select="mdct sinewin wma_freqs"
2217wmav1_encoder_select="mdct sinewin wma_freqs"
2218wmav2_decoder_select="mdct sinewin wma_freqs"
2219wmav2_encoder_select="mdct sinewin wma_freqs"
2220wmavoice_decoder_select="lsp rdft dct mdct sinewin"
2221wmv1_decoder_select="h263_decoder"
2222wmv1_encoder_select="h263_encoder"
2223wmv2_decoder_select="blockdsp error_resilience h263_decoder idctdsp intrax8 videodsp wmv2dsp"
2224wmv2_encoder_select="h263_encoder wmv2dsp"
2225wmv3_decoder_select="vc1_decoder"
2226wmv3image_decoder_select="wmv3_decoder"
2227zerocodec_decoder_deps="zlib"
2228zlib_decoder_deps="zlib"
2229zlib_encoder_deps="zlib"
2230zmbv_decoder_deps="zlib"
2231zmbv_encoder_deps="zlib"
2232
2233# hardware accelerators
2234d3d11va_deps="dxva_h ID3D11VideoDecoder"
2235dxva2_deps="dxva2api_h DXVA2_ConfigPictureDecode ole32"
2236vda_deps="VideoDecodeAcceleration_VDADecoder_h blocks_extension pthreads"
2237vda_extralibs="-framework CoreFoundation -framework VideoDecodeAcceleration -framework QuartzCore"
2238
2239h263_vaapi_hwaccel_deps="vaapi"
2240h263_vaapi_hwaccel_select="h263_decoder"
2241h264_cuvid_hwaccel_deps="cuvid CUVIDH264PICPARAMS"
2242h264_cuvid_hwaccel_select="h264_decoder"
2243h264_d3d11va_hwaccel_deps="d3d11va"
2244h264_d3d11va_hwaccel_select="h264_decoder"
2245h264_d3d11va2_hwaccel_deps="d3d11va"
2246h264_d3d11va2_hwaccel_select="h264_decoder"
2247h264_dxva2_hwaccel_deps="dxva2"
2248h264_dxva2_hwaccel_select="h264_decoder"
2249h264_vaapi_hwaccel_deps="vaapi"
2250h264_vaapi_hwaccel_select="h264_decoder"
2251h264_vda_hwaccel_deps="vda"
2252h264_vda_hwaccel_select="h264_decoder"
2253h264_vda_old_hwaccel_deps="vda"
2254h264_vda_old_hwaccel_select="h264_decoder"
2255h264_vdpau_hwaccel_deps="vdpau"
2256h264_vdpau_hwaccel_select="h264_decoder"
2257hevc_cuvid_hwaccel_deps="cuvid CUVIDHEVCPICPARAMS"
2258hevc_cuvid_hwaccel_select="hevc_decoder"
2259hevc_d3d11va_hwaccel_deps="d3d11va DXVA_PicParams_HEVC"
2260hevc_d3d11va_hwaccel_select="hevc_decoder"
2261hevc_d3d11va2_hwaccel_deps="d3d11va DXVA_PicParams_HEVC"
2262hevc_d3d11va2_hwaccel_select="hevc_decoder"
2263hevc_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_HEVC"
2264hevc_dxva2_hwaccel_select="hevc_decoder"
2265hevc_vaapi_hwaccel_deps="vaapi VAPictureParameterBufferHEVC"
2266hevc_vaapi_hwaccel_select="hevc_decoder"
2267hevc_vdpau_hwaccel_deps="vdpau VdpPictureInfoHEVC"
2268hevc_vdpau_hwaccel_select="hevc_decoder"
2269mpeg1_vdpau_hwaccel_deps="vdpau"
2270mpeg1_vdpau_hwaccel_select="mpeg1video_decoder"
2271mpeg2_d3d11va_hwaccel_deps="d3d11va"
2272mpeg2_d3d11va_hwaccel_select="mpeg2video_decoder"
2273mpeg2_d3d11va2_hwaccel_deps="d3d11va"
2274mpeg2_d3d11va2_hwaccel_select="mpeg2video_decoder"
2275mpeg2_dxva2_hwaccel_deps="dxva2"
2276mpeg2_dxva2_hwaccel_select="mpeg2video_decoder"
2277mpeg2_vaapi_hwaccel_deps="vaapi"
2278mpeg2_vaapi_hwaccel_select="mpeg2video_decoder"
2279mpeg2_vdpau_hwaccel_deps="vdpau"
2280mpeg2_vdpau_hwaccel_select="mpeg2video_decoder"
2281mpeg4_vaapi_hwaccel_deps="vaapi"
2282mpeg4_vaapi_hwaccel_select="mpeg4_decoder"
2283mpeg4_vdpau_hwaccel_deps="vdpau"
2284mpeg4_vdpau_hwaccel_select="mpeg4_decoder"
2285vc1_d3d11va_hwaccel_deps="d3d11va"
2286vc1_d3d11va_hwaccel_select="vc1_decoder"
2287vc1_d3d11va2_hwaccel_deps="d3d11va"
2288vc1_d3d11va2_hwaccel_select="vc1_decoder"
2289vc1_dxva2_hwaccel_deps="dxva2"
2290vc1_dxva2_hwaccel_select="vc1_decoder"
2291vc1_vaapi_hwaccel_deps="vaapi"
2292vc1_vaapi_hwaccel_select="vc1_decoder"
2293vc1_vdpau_hwaccel_deps="vdpau"
2294vc1_vdpau_hwaccel_select="vc1_decoder"
2295vp8_vaapi_hwaccel_deps="vaapi VAPictureParameterBufferVP8"
2296vp8_vaapi_hwaccel_select="vp8_decoder"
2297wmv3_d3d11va_hwaccel_select="vc1_d3d11va_hwaccel"
2298wmv3_d3d11va2_hwaccel_select="vc1_d3d11va2_hwaccel"
2299wmv3_dxva2_hwaccel_select="vc1_dxva2_hwaccel"
2300wmv3_vaapi_hwaccel_select="vc1_vaapi_hwaccel"
2301wmv3_vdpau_hwaccel_select="vc1_vdpau_hwaccel"
2302
2303# hardware-accelerated codecs
2304amf_deps_any="libdl LoadLibrary"
2305nvenc_deps_any="libdl LoadLibrary"
2306omx_deps="libdl pthreads"
2307omx_rpi_select="omx"
2308qsv_deps="libmfx"
2309qsvdec_select="qsv"
2310qsvenc_select="qsv"
2311qsvvpp_select="qsv"
2312vaapi_encode_deps="vaapi"
2313
2314hwupload_cuda_filter_deps="cuda"
2315scale_npp_filter_deps="cuda libnpp"
2316
2317h264_amf_encoder_deps="amf"
2318h264_mmal_decoder_deps="mmal"
2319h264_nvenc_encoder_deps="nvenc"
2320h264_omx_encoder_deps="omx"
2321h264_qsv_decoder_select="h264_mp4toannexb_bsf h264_parser qsvdec"
2322h264_qsv_encoder_select="qsvenc"
2323h264_vaapi_encoder_deps="VAEncPictureParameterBufferH264"
2324h264_vaapi_encoder_select="cbs_h264 vaapi_encode"
2325hevc_amf_encoder_deps="amf"
2326hevc_nvenc_encoder_deps="nvenc"
2327hevc_qsv_decoder_select="hevc_mp4toannexb_bsf hevc_parser qsvdec"
2328hevc_qsv_encoder_select="hevcparse qsvenc"
2329hevc_vaapi_encoder_deps="VAEncPictureParameterBufferHEVC"
2330hevc_vaapi_encoder_select="cbs_h265 vaapi_encode"
2331mjpeg_qsv_encoder_deps="libmfx"
2332mjpeg_qsv_encoder_select="qsvenc"
2333mjpeg_vaapi_encoder_deps="VAEncPictureParameterBufferJPEG"
2334mjpeg_vaapi_encoder_select="vaapi_encode jpegtables"
2335mpeg2_mmal_decoder_deps="mmal"
2336mpeg2_qsv_decoder_select="qsvdec mpegvideo_parser"
2337mpeg2_qsv_encoder_select="qsvenc"
2338mpeg2_vaapi_encoder_deps="VAEncPictureParameterBufferMPEG2"
2339mpeg2_vaapi_encoder_select="cbs_mpeg2 vaapi_encode"
2340mpeg4_omx_encoder_deps="omx"
2341vc1_mmal_decoder_deps="mmal"
2342vc1_qsv_decoder_select="qsvdec vc1_parser"
2343vp8_qsv_decoder_select="qsvdec vp8_parser"
2344vp8_vaapi_encoder_deps="VAEncPictureParameterBufferVP8"
2345vp8_vaapi_encoder_select="vaapi_encode"
2346vp9_vaapi_encoder_deps="VAEncPictureParameterBufferVP9"
2347vp9_vaapi_encoder_select="vaapi_encode"
2348
2349nvenc_h264_encoder_select="h264_nvenc_encoder"
2350nvenc_hevc_encoder_select="hevc_nvenc_encoder"
2351
2352# parsers
2353aac_parser_select="adts_header"
2354h264_parser_select="golomb h264dsp h264parse"
2355hevc_parser_select="hevcparse"
2356mpegaudio_parser_select="mpegaudioheader"
2357mpegvideo_parser_select="mpegvideo"
2358mpeg4video_parser_select="error_resilience h263dsp mpegvideo qpeldsp"
2359vc1_parser_select="vc1dsp"
2360
2361# bitstream_filters
2362aac_adtstoasc_bsf_select="adts_header"
2363h264_metadata_bsf_select="cbs_h264"
2364h264_redundant_pps_bsf_select="cbs_h264"
2365hevc_metadata_bsf_select="cbs_h265"
2366mjpeg2jpeg_bsf_select="jpegtables"
2367mpeg2_metadata_bsf_select="cbs_mpeg2"
2368trace_headers_bsf_select="cbs_h264 cbs_h265 cbs_mpeg2"
2369
2370# external libraries
2371avisynth_deps="LoadLibrary"
2372avxsynth_deps="libdl"
2373avisynth_demuxer_deps_any="avisynth avxsynth"
2374avisynth_demuxer_select="riffdec"
2375libaom_av1_decoder_deps="libaom"
2376libaom_av1_encoder_deps="libaom"
2377libdav1d_decoder_deps="libdav1d"
2378libdcadec_decoder_deps="libdcadec"
2379libfaac_encoder_deps="libfaac"
2380libfaac_encoder_select="audio_frame_queue"
2381libfdk_aac_decoder_deps="libfdk_aac"
2382libfdk_aac_encoder_deps="libfdk_aac"
2383libfdk_aac_encoder_select="audio_frame_queue"
2384libgsm_decoder_deps="libgsm"
2385libgsm_encoder_deps="libgsm"
2386libgsm_ms_decoder_deps="libgsm"
2387libgsm_ms_encoder_deps="libgsm"
2388libilbc_decoder_deps="libilbc"
2389libilbc_encoder_deps="libilbc"
2390libkvazaar_encoder_deps="libkvazaar"
2391libmp3lame_encoder_deps="libmp3lame"
2392libmp3lame_encoder_select="audio_frame_queue mpegaudioheader"
2393libopencore_amrnb_decoder_deps="libopencore_amrnb"
2394libopencore_amrnb_encoder_deps="libopencore_amrnb"
2395libopencore_amrnb_encoder_select="audio_frame_queue"
2396libopencore_amrwb_decoder_deps="libopencore_amrwb"
2397libopenh264_decoder_deps="libopenh264"
2398libopenh264_decoder_select="h264_mp4toannexb_bsf"
2399libopenh264_encoder_deps="libopenh264"
2400libopenjpeg_decoder_deps="libopenjpeg"
2401libopenjpeg_encoder_deps="libopenjpeg"
2402libopus_decoder_deps="libopus"
2403libopus_encoder_deps="libopus"
2404libopus_encoder_select="audio_frame_queue"
2405libschroedinger_decoder_deps="libschroedinger"
2406libschroedinger_encoder_deps="libschroedinger"
2407libspeex_decoder_deps="libspeex"
2408libspeex_encoder_deps="libspeex"
2409libspeex_encoder_select="audio_frame_queue"
2410libtheora_encoder_deps="libtheora"
2411libtwolame_encoder_deps="libtwolame"
2412libvo_aacenc_encoder_deps="libvo_aacenc"
2413libvo_aacenc_encoder_select="audio_frame_queue"
2414libvo_amrwbenc_encoder_deps="libvo_amrwbenc"
2415libvorbis_encoder_deps="libvorbis"
2416libvorbis_encoder_select="audio_frame_queue"
2417libvpx_vp8_decoder_deps="libvpx"
2418libvpx_vp8_encoder_deps="libvpx"
2419libvpx_vp9_decoder_deps="libvpx"
2420libvpx_vp9_encoder_deps="libvpx"
2421libwavpack_encoder_deps="libwavpack"
2422libwavpack_encoder_select="audio_frame_queue"
2423libwebp_encoder_deps="libwebp"
2424libx262_encoder_deps="libx262"
2425libx264_encoder_deps="libx264"
2426libx265_encoder_deps="libx265"
2427libxavs_encoder_deps="libxavs"
2428libxvid_encoder_deps="libxvid mkstemp"
2429
2430# demuxers / muxers
2431ac3_demuxer_select="ac3_parser"
2432asf_demuxer_select="riffdec"
2433asf_muxer_select="riffenc"
2434asf_stream_muxer_select="asf_muxer"
2435avi_demuxer_select="iso_media riffdec"
2436avi_muxer_select="riffenc"
2437caf_demuxer_select="iso_media riffdec"
2438dash_muxer_select="mp4_muxer"
2439dirac_demuxer_select="dirac_parser"
2440dv_demuxer_select="dvprofile"
2441dv_muxer_select="dvprofile"
2442dxa_demuxer_select="riffdec"
2443eac3_demuxer_select="ac3_parser"
2444f4v_muxer_select="mov_muxer"
2445flac_demuxer_select="flac_parser"
2446hds_muxer_select="flv_muxer"
2447hls_muxer_select="mpegts_muxer"
2448ipod_muxer_select="mov_muxer"
2449ismv_muxer_select="mov_muxer"
2450matroska_audio_muxer_select="matroska_muxer"
2451matroska_demuxer_select="iso_media riffdec"
2452matroska_demuxer_suggest="bzlib lzo zlib"
2453matroska_muxer_select="iso_media riffenc"
2454mmf_muxer_select="riffenc"
2455mov_demuxer_select="iso_media riffdec"
2456mov_demuxer_suggest="zlib"
2457mov_muxer_select="iso_media riffenc rtpenc_chain"
2458mp3_demuxer_select="mpegaudio_parser"
2459mp3_muxer_select="mpegaudioheader"
2460mp4_muxer_select="mov_muxer"
2461mpegts_demuxer_select="iso_media"
2462mpegts_muxer_select="adts_muxer latm_muxer"
2463mpegtsraw_demuxer_select="mpegts_demuxer"
2464mxf_d10_muxer_select="mxf_muxer"
2465nut_muxer_select="riffenc"
2466nuv_demuxer_select="riffdec"
2467oga_muxer_select="ogg_muxer"
2468ogg_demuxer_select="dirac_parse"
2469opus_muxer_select="ogg_muxer"
2470psp_muxer_select="mov_muxer"
2471rtp_demuxer_select="sdp_demuxer"
2472rtpdec_select="asf_demuxer jpegtables mov_demuxer mpegts_demuxer rm_demuxer rtp_protocol srtp"
2473rtsp_demuxer_select="http_protocol rtpdec"
2474rtsp_muxer_select="rtp_muxer http_protocol rtp_protocol rtpenc_chain"
2475sap_demuxer_select="sdp_demuxer"
2476sap_muxer_select="rtp_muxer rtp_protocol rtpenc_chain"
2477sdp_demuxer_select="rtpdec"
2478smoothstreaming_muxer_select="ismv_muxer"
2479spdif_demuxer_select="adts_header"
2480spdif_muxer_select="adts_header"
2481spx_muxer_select="ogg_muxer"
2482swf_demuxer_suggest="zlib"
2483tak_demuxer_select="tak_parser"
2484tg2_muxer_select="mov_muxer"
2485tgp_muxer_select="mov_muxer"
2486w64_demuxer_select="wav_demuxer"
2487wav_demuxer_select="riffdec"
2488wav_muxer_select="riffenc"
2489webm_muxer_select="iso_media riffenc"
2490wtv_demuxer_select="mpegts_demuxer riffdec"
2491xmv_demuxer_select="riffdec"
2492xwma_demuxer_select="riffdec"
2493
2494# indevs
2495alsa_indev_deps="alsa"
2496avfoundation_indev_deps="AVFoundation_AVFoundation_h objc_arc pthreads"
2497avfoundation_indev_extralibs="-framework Foundation -framework AVFoundation -framework CoreVideo -framework CoreMedia"
2498bktr_indev_deps_any="dev_bktr_ioctl_bt848_h machine_ioctl_bt848_h dev_video_bktr_ioctl_bt848_h dev_ic_bt8xx_h"
2499fbdev_indev_deps="linux_fb_h"
2500jack_indev_deps="libjack"
2501jack_indev_deps_any="sem_timedwait dispatch_dispatch_h"
2502libcdio_indev_deps="libcdio"
2503libdc1394_indev_deps="libdc1394"
2504oss_indev_deps_any="sys_soundcard_h"
2505pulse_indev_deps="libpulse"
2506sndio_indev_deps="sndio"
2507v4l2_indev_deps_any="linux_videodev2_h sys_videoio_h"
2508vfwcap_indev_deps="vfw32 vfwcap_defines"
2509xcbgrab_indev_deps="libxcb libxcb_shape"
2510xcbgrab_indev_suggest="libxcb_shm libxcb_xfixes"
2511
2512# protocols
2513ffrtmpcrypt_protocol_conflict="librtmp_protocol"
2514ffrtmpcrypt_protocol_deps_any="gmp mbedtls openssl"
2515ffrtmpcrypt_protocol_select="tcp_protocol"
2516ffrtmphttp_protocol_conflict="librtmp_protocol"
2517ffrtmphttp_protocol_select="http_protocol"
2518gopher_protocol_select="network"
2519http_protocol_select="tcp_protocol"
2520http_protocol_suggest="zlib"
2521httpproxy_protocol_select="tcp_protocol"
2522httpproxy_protocol_suggest="zlib"
2523https_protocol_select="tls_protocol"
2524https_protocol_suggest="zlib"
2525icecast_protocol_select="http_protocol"
2526mmsh_protocol_select="http_protocol"
2527mmst_protocol_select="network"
2528rtmp_protocol_conflict="librtmp_protocol"
2529rtmp_protocol_select="tcp_protocol"
2530rtmp_protocol_suggest="zlib"
2531rtmpe_protocol_select="ffrtmpcrypt_protocol"
2532rtmpe_protocol_suggest="zlib"
2533rtmps_protocol_conflict="librtmp_protocol"
2534rtmps_protocol_select="tls_protocol"
2535rtmps_protocol_suggest="zlib"
2536rtmpt_protocol_select="ffrtmphttp_protocol"
2537rtmpt_protocol_suggest="zlib"
2538rtmpte_protocol_select="ffrtmpcrypt_protocol ffrtmphttp_protocol"
2539rtmpte_protocol_suggest="zlib"
2540rtmpts_protocol_select="ffrtmphttp_protocol https_protocol"
2541rtmpts_protocol_suggest="zlib"
2542rtp_protocol_select="udp_protocol"
2543sctp_protocol_deps="struct_sctp_event_subscribe"
2544sctp_protocol_select="network"
2545srtp_protocol_select="rtp_protocol srtp"
2546tcp_protocol_select="network"
2547tls_protocol_deps_any="gnutls mbedtls openssl"
2548tls_protocol_select="tcp_protocol"
2549udp_protocol_select="network"
2550unix_protocol_deps="sys_un_h"
2551unix_protocol_select="network"
2552
2553# external library protocols
2554librtmp_protocol_deps="librtmp"
2555librtmpe_protocol_deps="librtmp"
2556librtmps_protocol_deps="librtmp"
2557librtmpt_protocol_deps="librtmp"
2558librtmpte_protocol_deps="librtmp"
2559libsrt_protocol_deps="libsrt"
2560libsrt_protocol_select="network"
2561
2562# filters
2563asyncts_filter_deps="avresample"
2564blackframe_filter_deps="gpl"
2565boxblur_filter_deps="gpl"
2566bs2b_filter_deps="libbs2b"
2567cropdetect_filter_deps="gpl"
2568deinterlace_qsv_filter_deps="libmfx"
2569deinterlace_vaapi_filter_deps="vaapi"
2570delogo_filter_deps="gpl"
2571drawtext_filter_deps="libfreetype"
2572drawtext_filter_suggest="libfontconfig"
2573frei0r_filter_deps="frei0r libdl"
2574frei0r_src_filter_deps="frei0r libdl"
2575hdcd_filter_deps="libhdcd"
2576hqdn3d_filter_deps="gpl"
2577interlace_filter_deps="gpl"
2578movie_filter_deps="avcodec avformat"
2579ocv_filter_deps="libopencv"
2580overlay_qsv_filter_deps="libmfx"
2581overlay_qsv_filter_select="qsvvpp"
2582resample_filter_deps="avresample"
2583scale_filter_deps="swscale"
2584scale_qsv_filter_deps="libmfx"
2585scale_vaapi_filter_deps="vaapi VAProcPipelineParameterBuffer"
2586vpp_qsv_filter_deps="libmfx"
2587vpp_qsv_filter_select="qsvvpp"
2588
2589# examples
2590decode_audio_example_deps="avcodec avutil"
2591decode_video_example_deps="avcodec avutil"
2592encode_audio_example_deps="avcodec avutil"
2593encode_video_example_deps="avcodec avutil"
2594filter_audio_example_deps="avfilter avutil"
2595metadata_example_deps="avformat avutil"
2596output_example_deps="avcodec avformat avresample avutil swscale"
2597qsvdec_example_deps="avcodec avutil libmfx h264_qsv_decoder"
2598transcode_aac_example_deps="avcodec avformat avresample"
2599
2600# EXTRALIBS_LIST
2601cpu_init_extralibs="pthreads_extralibs"
2602cws2fws_extralibs="zlib_extralibs"
2603
2604# libraries, in linking order
2605avcodec_deps="avutil"
2606avcodec_select="null_bsf"
2607avdevice_deps="avformat avcodec avutil"
2608avfilter_deps="avutil"
2609avformat_deps="avcodec avutil"
2610avformat_suggest="network"
2611avresample_deps="avutil"
2612swscale_deps="avutil"
2613
2614avcodec_extralibs="pthreads_extralibs libm_extralibs"
2615avdevice_extralibs="libm_extralibs"
2616avformat_extralibs="libm_extralibs"
2617avfilter_extralibs="pthreads_extralibs libm_extralibs"
2618avresample_extralibs="libm_extralibs"
2619avutil_extralibs="bcrypt_extralibs clock_gettime_extralibs cuda_extralibs cuvid_extralibs d3d11va_extralibs libm_extralibs libmfx_extralibs nanosleep_extralibs pthreads_extralibs user32_extralibs vaapi_extralibs vaapi_drm_extralibs vaapi_x11_extralibs vdpau_x11_extralibs"
2620swscale_extralibs="libm_extralibs"
2621
2622# programs
2623avconv_deps="avcodec avfilter avformat avresample swscale"
2624avconv_select="aformat_filter anull_filter asyncts_filter atrim_filter format_filter
2625 fps_filter null_filter resample_filter scale_filter
2626 trim_filter"
2627avconv_suggest="psapi shell32"
2628avplay_deps="avcodec avfilter avformat avresample sdl"
2629avplay_select="rdft format_filter transpose_filter hflip_filter vflip_filter"
2630avplay_suggest="shell32"
2631avprobe_deps="avcodec avformat"
2632avprobe_suggest="shell32"
2633
2634# documentation
2635pod2man_deps="doc"
2636texi2html_deps="doc"
2637
2638# default parameters
2639
2640logfile="avbuild/config.log"
2641
2642# installation paths
2643prefix_default="/usr/local"
2644bindir_default='${prefix}/bin'
2645datadir_default='${prefix}/share/avconv'
2646docdir_default='${prefix}/share/doc/libav'
2647incdir_default='${prefix}/include'
2648libdir_default='${prefix}/lib'
2649mandir_default='${prefix}/share/man'
2650shlibdir_default="$libdir_default"
2651
2652# toolchain
2653ar_default="ar"
2654cc_default="gcc"
2655host_cc_default="gcc"
2656x86asmexe_default="nasm"
2657ln_s="ln -s -f"
2658nm_default="nm -g"
2659pkg_config_default=pkg-config
2660ranlib="ranlib"
2661strip="strip"
2662version_script='--version-script'
2663objformat="elf32"
2664
2665# machine
2666arch_default=$(uname -m)
2667cpu="generic"
2668intrinsics="none"
2669
2670# OS
2671target_os_default=$(tolower $(uname -s))
2672host_os=$target_os_default
2673
2674# configurable options
2675enable $EXAMPLE_LIST $LIBRARY_LIST $PROGRAM_LIST
2676
2677enable asm
2678enable debug
2679enable doc
2680enable faan faandct faanidct
2681enable optimizations
2682enable safe_bitstream_reader
2683enable static
2684enable swscale_alpha
2685enable valgrind_backtrace
2686
2687# By default, enable only those hwaccels that have no external dependencies.
2688enable d3d11va dxva2 vda vdpau
2689
2690# internal components are enabled by default
2691enable $EXTRALIBS_LIST
2692
2693# Avoid external, non-system, libraries getting enabled by dependency resolution
2694disable $EXTERNAL_LIBRARY_LIST
2695
2696# build settings
2697SHFLAGS='-shared -Wl,-soname,$$(@F)'
2698LIBPREF="lib"
2699LIBSUF=".a"
2700LIBNAME='$(LIBPREF)$(NAME)$(LIBSUF)'
2701SLIBPREF="lib"
2702SLIBSUF=".so"
2703SLIBNAME='$(SLIBPREF)$(NAME)$(SLIBSUF)'
2704SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
2705SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
2706LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
2707SLIB_INSTALL_NAME='$(SLIBNAME_WITH_VERSION)'
2708SLIB_INSTALL_LINKS='$(SLIBNAME_WITH_MAJOR) $(SLIBNAME)'
2709VERSION_SCRIPT_POSTPROCESS_CMD="cat"
2710
2711asflags_filter=echo
2712cflags_filter=echo
2713ldflags_filter=echo
2714
2715AS_C='-c'
2716AS_O='-o $@'
2717CC_C='-c'
2718CC_E='-E -o $@'
2719CC_O='-o $@'
2720OBJCC_C='-c'
2721OBJCC_E='-E -o $@'
2722OBJCC_O='-o $@'
2723X86ASM_O='-o $@'
2724LD_O='-o $@'
2725LD_LIB='-l%'
2726LD_PATH='-L'
2727HOSTCC_C='-c'
2728HOSTCC_E='-E -o $@'
2729HOSTCC_O='-o $@'
2730HOSTLD_O='-o $@'
2731
2732host_extralibs='-lm'
2733host_cflags_filter=echo
2734host_ldflags_filter=echo
2735
2736target_path='$(CURDIR)'
2737
2738# since the object filename is not given with the -MM flag, the compiler
2739# is only able to print the basename, and we must add the path ourselves
2740DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< | sed -e "/^\#.*/d" -e "s,^[[:space:]]*$(*F)\\.o,$(@D)/$(*F).o," > $(@:.o=.d)'
2741DEPFLAGS='-MM'
2742
2743mkdir -p avbuild
2744
2745# find source path
2746if test -f configure; then
2747 source_path=.
2748else
2749 source_path=$(cd $(dirname "$0"); pwd)
2750 echo "$source_path" | grep -q '[[:blank:]]' &&
2751 die "Out of tree builds are impossible with whitespace in source path."
2752 test -e "$source_path/config.h" &&
2753 die "Out of tree builds are impossible with config.h in source dir."
2754fi
2755
2756for v in "$@"; do
2757 r=${v#*=}
2758 l=${v%"$r"}
2759 r=$(sh_quote "$r")
2760 LIBAV_CONFIGURATION="${LIBAV_CONFIGURATION# } ${l}${r}"
2761done
2762
2763find_things(){
2764 thing=$1
2765 pattern=$2
2766 file=$source_path/$3
2767 sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" "$file"
2768}
2769
2770ENCODER_LIST=$(find_things encoder ENC libavcodec/allcodecs.c)
2771DECODER_LIST=$(find_things decoder DEC libavcodec/allcodecs.c)
2772PARSER_LIST=$(find_things parser PARSER libavcodec/allcodecs.c)
2773MUXER_LIST=$(find_things muxer _MUX libavformat/allformats.c)
2774DEMUXER_LIST=$(find_things demuxer DEMUX libavformat/allformats.c)
2775INDEV_LIST=$(find_things indev _IN libavdevice/alldevices.c)
2776FILTER_LIST=$(find_things filter FILTER libavfilter/allfilters.c)
2777
2778find_things_extern(){
2779 thing=$1
2780 pattern=$2
2781 file=$source_path/$3
2782 sed -n "s/^[^#]*extern.*$pattern *ff_\([^ ]*\)_$thing;/\1_$thing/p" "$file"
2783}
2784
2785BSF_LIST=$(find_things_extern bsf AVBitStreamFilter libavcodec/bitstream_filters.c)
2786HWACCEL_LIST=$(find_things_extern hwaccel AVHWAccel libavcodec/hwaccels.h)
2787PROTOCOL_LIST=$(find_things_extern protocol URLProtocol libavformat/protocols.c)
2788
2789AVCODEC_COMPONENTS_LIST="
2790 $BSF_LIST
2791 $DECODER_LIST
2792 $ENCODER_LIST
2793 $HWACCEL_LIST
2794 $PARSER_LIST
2795"
2796
2797AVDEVICE_COMPONENTS_LIST="
2798 $INDEV_LIST
2799"
2800
2801AVFILTER_COMPONENTS_LIST="
2802 $FILTER_LIST
2803"
2804
2805AVFORMAT_COMPONENTS_LIST="
2806 $DEMUXER_LIST
2807 $MUXER_LIST
2808 $PROTOCOL_LIST
2809"
2810
2811ALL_COMPONENTS="
2812 $AVCODEC_COMPONENTS_LIST
2813 $AVDEVICE_COMPONENTS_LIST
2814 $AVFILTER_COMPONENTS_LIST
2815 $AVFORMAT_COMPONENTS_LIST
2816"
2817
2818for n in $COMPONENT_LIST; do
2819 v=$(toupper ${n%s})_LIST
2820 eval enable \$$v
2821 eval ${n}_if_any="\$$v"
2822done
2823
2824enable $ARCH_EXT_LIST
2825
2826die_unknown(){
2827 echo "Unknown option \"$1\"."
2828 echo "See $0 --help for available options."
2829 exit 1
2830}
2831
2832print_3_columns() {
2833 printf "%-25s %-25s %-25s\n" $(cat | tr ' ' '\n' | sort)
2834}
2835
2836show_list() {
2837 suffix=_$1
2838 shift
2839 echo $* | sed s/$suffix//g | print_3_columns
2840 exit 0
2841}
2842
2843for opt do
2844 optval="${opt#*=}"
2845 case "$opt" in
2846 --extra-ldflags=*)
2847 add_ldflags $optval
2848 ;;
2849 --extra-ldexeflags=*)
2850 add_ldexeflags $optval
2851 ;;
2852 --extra-ldsoflags=*)
2853 add_ldsoflags $optval
2854 ;;
2855 --extra-libs=*)
2856 add_extralibs $optval
2857 ;;
2858 --disable-devices)
2859 disable $INDEV_LIST
2860 ;;
2861 --enable-debug=*)
2862 debuglevel="$optval"
2863 ;;
2864 --disable-programs)
2865 disable $PROGRAM_LIST
2866 ;;
2867 --disable-everything)
2868 map 'eval unset \${$(toupper ${v%s})_LIST}' $COMPONENT_LIST
2869 ;;
2870 --disable-all)
2871 map 'eval unset \${$(toupper ${v%s})_LIST}' $COMPONENT_LIST
2872 disable $LIBRARY_LIST $PROGRAM_LIST doc
2873 ;;
2874 --enable-*=*|--disable-*=*)
2875 eval $(echo "${opt%%=*}" | sed 's/--/action=/;s/-/ thing=/')
2876 is_in "${thing}s" $COMPONENT_LIST || die_unknown "$opt"
2877 eval list=\$$(toupper $thing)_LIST
2878 name=$(echo "${optval}" | sed "s/,/_${thing}|/g")_${thing}
2879 $action $(filter "$name" $list)
2880 ;;
2881 --enable-yasm|--disable-yasm)
2882 warn "The ${opt} option is only provided for compatibility and will be\n"\
2883 "removed in the future. Use --enable-x86asm / --disable-x86asm instead."
2884 test $opt = --enable-yasm && x86asm=yes || x86asm=no
2885 ;;
2886 --enable-?*|--disable-?*)
2887 eval $(echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g')
2888 if is_in $option $COMPONENT_LIST; then
2889 test $action = disable && action=unset
2890 eval $action \$$(toupper ${option%s})_LIST
2891 elif is_in $option $CMDLINE_SELECT; then
2892 $action $option
2893 else
2894 die_unknown $opt
2895 fi
2896 ;;
2897 --list-*)
2898 NAME="${opt#--list-}"
2899 is_in $NAME $COMPONENT_LIST || die_unknown $opt
2900 NAME=${NAME%s}
2901 eval show_list $NAME \$$(toupper $NAME)_LIST
2902 ;;
2903 --help|-h) show_help
2904 ;;
2905 --quiet|-q) quiet=yes
2906 ;;
2907 *)
2908 optname="${opt%%=*}"
2909 optname="${optname#--}"
2910 optname=$(echo "$optname" | sed 's/-/_/g')
2911 if is_in $optname $CMDLINE_SET; then
2912 eval $optname='$optval'
2913 elif is_in $optname $CMDLINE_APPEND; then
2914 append $optname "$optval"
2915 else
2916 die_unknown $opt
2917 fi
2918 ;;
2919 esac
2920done
2921
2922for e in $env; do
2923 eval "export $e"
2924done
2925
2926disabled logging && logfile=/dev/null
2927
2928# command line configuration sanity checks
2929
2930# we need to build at least one lib type
2931if ! enabled_any static shared; then
2932 cat <<EOF
2933At least one library type must be built.
2934Specify --enable-static to build the static libraries or --enable-shared to
2935build the shared libraries as well. To only build the shared libraries specify
2936--disable-static in addition to --enable-shared.
2937EOF
2938 exit 1
2939fi
2940
2941# Die early if licensing-related configure options are incompatible.
2942die_license_disabled() {
2943 enabled $1 || { enabled $v && die "$v is $1 and --enable-$1 is not specified."; }
2944}
2945
2946map "die_license_disabled gpl" $EXTERNAL_LIBRARY_GPL_LIST
2947map "die_license_disabled nonfree" $EXTERNAL_LIBRARY_NONFREE_LIST $HWACCEL_LIBRARY_NONFREE_LIST
2948map "die_license_disabled version3" $EXTERNAL_LIBRARY_VERSION3_LIST
2949
2950enabled version3 && { enabled gpl && enable gplv3 || enable lgplv3; }
2951
2952if enabled nonfree; then
2953 license="nonfree and unredistributable"
2954elif enabled gplv3; then
2955 license="GPL version 3 or later"
2956elif enabled lgplv3; then
2957 license="LGPL version 3 or later"
2958elif enabled gpl; then
2959 license="GPL version 2 or later"
2960else
2961 license="LGPL version 2.1 or later"
2962fi
2963
2964enabled_all gnutls openssl &&
2965 die "GnuTLS and OpenSSL must not be enabled at the same time."
2966
2967enabled_all gnutls mbedtls &&
2968 die "GnuTLS and mbedTLS must not be enabled at the same time."
2969
2970enabled_all openssl mbedtls &&
2971 die "OpenSSL and mbedTLS must not be enabled at the same time."
2972
2973# Disable all the library-specific components if the library itself
2974# is disabled, see AVCODEC_LIST and following _LIST variables.
2975
2976disable_components(){
2977 disabled ${1} && disable $(
2978 eval components="\$$(toupper ${1})_COMPONENTS"
2979 map 'eval echo \${$(toupper ${v%s})_LIST}' $components
2980 )
2981}
2982
2983map 'disable_components $v' $LIBRARY_LIST
2984
2985echo "# $0 $LIBAV_CONFIGURATION" > $logfile
2986set >> $logfile
2987
2988case "$toolchain" in
2989 *-asan)
2990 cc_default="${toolchain%-asan}"
2991 add_cflags -fsanitize=address
2992 add_ldflags -fsanitize=address
2993 ;;
2994 *-msan)
2995 cc_default="${toolchain%-msan}"
2996 add_cflags -fsanitize=memory -fsanitize-memory-track-origins
2997 add_ldflags -fsanitize=memory
2998 ;;
2999 *-tsan)
3000 cc_default="${toolchain%-tsan}"
3001 add_cflags -fsanitize=thread -fPIE
3002 add_ldflags -fsanitize=thread -pie
3003 case "$toolchain" in
3004 gcc-tsan)
3005 add_cflags -fPIC
3006 add_ldflags -fPIC
3007 ;;
3008 esac
3009 ;;
3010 *-usan)
3011 cc_default="${toolchain%-usan}"
3012 add_cflags -fsanitize=undefined
3013 add_ldflags -fsanitize=undefined
3014 case "$toolchain" in
3015 clang-usan)
3016 add_cflags -O1
3017 ;;
3018 esac
3019 ;;
3020 valgrind-*)
3021 target_exec_default="valgrind"
3022 case "$toolchain" in
3023 valgrind-massif)
3024 target_exec_args="--alloc-fn=av_malloc --alloc-fn=av_mallocz"
3025 ;;
3026 valgrind-memcheck)
3027 target_exec_args="--track-origins=yes --leak-check=full"
3028 ;;
3029 esac
3030 ;;
3031 msvc)
3032 # Check whether the current MSVC version needs the C99 converter.
3033 # From MSVC 2013 (compiler major version 18) onwards, it does actually
3034 # support enough of C99 to build libav. Default to the new
3035 # behaviour if the regexp was unable to match anything, since this
3036 # successfully parses the version number of existing supported
3037 # versions that require the converter (MSVC 2010 and 2012).
3038 cl_major_ver=$(cl 2>&1 | sed -n 's/.*Version \([[:digit:]]\{1,\}\)\..*/\1/p')
3039 if [ -z "$cl_major_ver" ] || [ $cl_major_ver -ge 18 ]; then
3040 cc_default="cl"
3041 else
3042 cc_default="c99wrap cl"
3043 fi
3044 ld_default="$source_path/compat/windows/mslink"
3045 nm_default="dumpbin -symbols"
3046 ar_default="lib"
3047 case "$arch" in
3048 aarch64|arm64)
3049 as_default="armasm64"
3050 ;;
3051 arm*)
3052 as_default="armasm"
3053 ;;
3054 esac
3055 target_os_default="win32"
3056 # Use a relative path for TMPDIR. This makes sure all the
3057 # ffconf temp files are written with a relative path, avoiding
3058 # issues with msys/win32 path conversion for MSVC parameters
3059 # such as -Fo<file> or -out:<file>.
3060 TMPDIR=.
3061 ;;
3062 icl)
3063 cc_default="icl"
3064 ld_default="xilink"
3065 nm_default="dumpbin -symbols"
3066 ar_default="xilib"
3067 target_os_default="win32"
3068 TMPDIR=.
3069 ;;
3070 gcov)
3071 add_cflags -fprofile-arcs -ftest-coverage
3072 add_ldflags -fprofile-arcs -ftest-coverage
3073 ;;
3074 llvm-cov)
3075 add_cflags -fprofile-arcs -ftest-coverage
3076 add_ldflags --coverage
3077 ;;
3078 hardened)
3079 add_cppflags -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2
3080 add_cflags -fno-strict-overflow -fstack-protector-all
3081 add_ldflags -Wl,-z,relro -Wl,-z,now
3082 ;;
3083 ?*)
3084 die "Unknown toolchain $toolchain"
3085 ;;
3086esac
3087
3088if test -n "$cross_prefix"; then
3089 test -n "$arch" && test -n "$target_os" ||
3090 die "Must specify target arch (--arch) and OS (--target-os) when cross-compiling"
3091 enable cross_compile
3092fi
3093
3094ar_default="${cross_prefix}${ar_default}"
3095cc_default="${cross_prefix}${cc_default}"
3096objcc_default="${cross_prefix}${objcc_default}"
3097x86asmexe_default="${cross_prefix}${x86asmexe_default}"
3098nm_default="${cross_prefix}${nm_default}"
3099pkg_config_default="${cross_prefix}${pkg_config_default}"
3100ranlib="${cross_prefix}${ranlib}"
3101strip="${cross_prefix}${strip}"
3102
3103sysinclude_default="${sysroot}/usr/include"
3104
3105set_default arch cc pkg_config sysinclude target_exec target_os x86asmexe
3106enabled cross_compile || host_cc_default=$cc
3107set_default host_cc
3108
3109if ! $pkg_config --version >/dev/null 2>&1; then
3110 warn "$pkg_config not found, library detection may fail."
3111 pkg_config=false
3112fi
3113
3114exesuf() {
3115 case $1 in
3116 mingw32*|mingw64*|win32|win64|cygwin*|*-dos|freedos|opendos|os/2*|symbian) echo .exe ;;
3117 esac
3118}
3119
3120EXESUF=$(exesuf $target_os)
3121HOSTEXESUF=$(exesuf $host_os)
3122
3123# set temporary file name
3124: ${TMPDIR:=$TEMPDIR}
3125: ${TMPDIR:=$TMP}
3126: ${TMPDIR:=/tmp}
3127
3128if ! test_cmd mktemp -u XXXXXX; then
3129 # simple replacement for missing mktemp
3130 # NOT SAFE FOR GENERAL USE
3131 mktemp(){
3132 tmpname="${2%%XXX*}.${HOSTNAME}.${UID}.$$"
3133 echo "$tmpname"
3134 mkdir "$tmpname"
3135 }
3136fi
3137
3138AVTMPDIR=$(mktemp -d "${TMPDIR}/avconf.XXXXXXXX" 2> /dev/null) ||
3139 die "Unable to create temporary directory in $TMPDIR."
3140
3141tmpfile(){
3142 tmp="${AVTMPDIR}/test"$2
3143 (set -C; exec > $tmp) 2> /dev/null ||
3144 die "Unable to create temporary file in $AVTMPDIR."
3145 eval $1=$tmp
3146}
3147
3148trap 'rm -rf -- "$AVTMPDIR"' EXIT
3149trap 'exit 2' INT
3150
3151tmpfile TMPASM .asm
3152tmpfile TMPC .c
3153tmpfile TMPE $EXESUF
3154tmpfile TMPH .h
3155tmpfile TMPO .o
3156tmpfile TMPS .S
3157tmpfile TMPSH .sh
3158tmpfile TMPV .ver
3159
3160unset -f mktemp
3161
3162chmod +x $TMPE
3163
3164# make sure we can execute files in $TMPDIR
3165cat > $TMPSH 2>> $logfile <<EOF
3166#! /bin/sh
3167EOF
3168chmod +x $TMPSH >> $logfile 2>&1
3169if ! $TMPSH >> $logfile 2>&1; then
3170 cat <<EOF
3171Unable to create and execute files in $TMPDIR. Set the TMPDIR environment
3172variable to another directory and make sure that it is not mounted noexec.
3173EOF
3174 die "Sanity test failed."
3175fi
3176
3177armasm_flags(){
3178 for flag; do
3179 case $flag in
3180 # Filter out MSVC cl.exe options from cflags that shouldn't
3181 # be passed to gas-preprocessor
3182 -M[TD]*) ;;
3183 *) echo $flag ;;
3184 esac
3185 done
3186}
3187
3188cparser_flags(){
3189 for flag; do
3190 case $flag in
3191 -Wno-switch) echo -Wno-switch-enum ;;
3192 -Wno-format-zero-length) ;;
3193 -Wdisabled-optimization) ;;
3194 -Wno-pointer-sign) echo -Wno-other ;;
3195 *) echo $flag ;;
3196 esac
3197 done
3198}
3199
3200msvc_common_flags(){
3201 for flag; do
3202 case $flag in
3203 # In addition to specifying certain flags under the compiler
3204 # specific filters, they must be specified here as well or else the
3205 # generic catch all at the bottom will print the original flag.
3206 -Wall) ;;
3207 -Wextra) ;;
3208 -std=c99) ;;
3209 # Common flags
3210 -fomit-frame-pointer) ;;
3211 -g) echo -Z7 ;;
3212 -fno-math-errno) ;;
3213 -fno-common) ;;
3214 -fno-signed-zeros) ;;
3215 -fPIC) ;;
3216 -mthumb) ;;
3217 -march=*) ;;
3218 -lz) echo zlib.lib ;;
3219 -lx264) echo libx264.lib ;;
3220 -l*) echo ${flag#-l}.lib ;;
3221 -L*) echo -libpath:${flag#-L} ;;
3222 *) echo $flag ;;
3223 esac
3224 done
3225}
3226
3227msvc_flags(){
3228 msvc_common_flags "$@"
3229 for flag; do
3230 case $flag in
3231 -Wall) echo -W3 -wd4018 -wd4146 -wd4244 -wd4305 \
3232 -wd4554 ;;
3233 -Wextra) echo -W4 -wd4244 -wd4127 -wd4018 -wd4389 \
3234 -wd4146 -wd4057 -wd4204 -wd4706 -wd4305 \
3235 -wd4152 -wd4324 -we4013 -wd4100 -wd4214 \
3236 -wd4273 -wd4554 -wd4701 -wd4703 ;;
3237 esac
3238 done
3239}
3240
3241icl_flags(){
3242 msvc_common_flags "$@"
3243 for flag; do
3244 case $flag in
3245 # Despite what Intel's documentation says -Wall, which is supported
3246 # on Windows, does enable remarks so disable them here.
3247 -Wall) echo $flag -Qdiag-disable:remark ;;
3248 -std=c99) echo -Qstd=c99 ;;
3249 esac
3250 done
3251}
3252
3253suncc_flags(){
3254 for flag; do
3255 case $flag in
3256 -march=*|-mcpu=*)
3257 case "${flag#*=}" in
3258 native) echo -xtarget=native ;;
3259 v9|niagara) echo -xarch=sparc ;;
3260 ultrasparc) echo -xarch=sparcvis ;;
3261 ultrasparc3|niagara2) echo -xarch=sparcvis2 ;;
3262 i586|pentium) echo -xchip=pentium ;;
3263 i686|pentiumpro|pentium2) echo -xtarget=pentium_pro ;;
3264 pentium3*|c3-2) echo -xtarget=pentium3 ;;
3265 pentium-m) echo -xarch=sse2 -xchip=pentium3 ;;
3266 pentium4*) echo -xtarget=pentium4 ;;
3267 prescott|nocona) echo -xarch=sse3 -xchip=pentium4 ;;
3268 *-sse3) echo -xarch=sse3 ;;
3269 core2) echo -xarch=ssse3 -xchip=core2 ;;
3270 corei7) echo -xarch=sse4_2 -xchip=nehalem ;;
3271 corei7-avx) echo -xarch=avx -xchip=sandybridge ;;
3272 amdfam10|barcelona|bdver*) echo -xarch=sse4_1 ;;
3273 athlon-4|athlon-[mx]p) echo -xarch=ssea ;;
3274 k8|opteron|athlon64|athlon-fx)
3275 echo -xarch=sse2a ;;
3276 athlon*) echo -xarch=pentium_proa ;;
3277 esac
3278 ;;
3279 -std=c99) echo -xc99 ;;
3280 -fomit-frame-pointer) echo -xregs=frameptr ;;
3281 -fPIC) echo -KPIC -xcode=pic32 ;;
3282 -W*,*) echo $flag ;;
3283 -f*-*|-W*|-mimpure-text) ;;
3284 -shared) echo -G ;;
3285 *) echo $flag ;;
3286 esac
3287 done
3288}
3289
3290probe_cc(){
3291 pfx=$1
3292 _cc=$2
3293
3294 unset _type _ident _cc_c _cc_e _cc_o _flags _cflags
3295 unset _ld_o _ldflags _ld_lib _ld_path
3296 unset _depflags _DEPCMD _DEPFLAGS
3297 _flags_filter=echo
3298
3299 if $_cc -v 2>&1 | grep -q '^gcc.*LLVM'; then
3300 _type=llvm_gcc
3301 gcc_extra_ver=$(expr "$($_cc --version 2>/dev/null | head -n1)" : '.*\((.*)\)')
3302 _ident="llvm-gcc $($_cc -dumpversion 2>/dev/null) $gcc_extra_ver"
3303 _depflags='-MMD -MF $(@:.o=.d) -MT $@'
3304 _cflags_speed='-O3'
3305 _cflags_size='-Os'
3306 elif $_cc -v 2>&1 | grep -qi ^gcc; then
3307 _type=gcc
3308 gcc_version=$($_cc --version | head -n1)
3309 gcc_basever=$($_cc -dumpversion)
3310 gcc_pkg_ver=$(expr "$gcc_version" : '[^ ]* \(([^)]*)\)')
3311 gcc_ext_ver=$(expr "$gcc_version" : ".*$gcc_pkg_ver $gcc_basever \\(.*\\)")
3312 _ident=$(cleanws "gcc $gcc_basever $gcc_pkg_ver $gcc_ext_ver")
3313 if ! $_cc -dumpversion | grep -q '^2\.'; then
3314 _depflags='-MMD -MF $(@:.o=.d) -MT $@'
3315 fi
3316 _cflags_speed='-O3'
3317 _cflags_size='-Os'
3318 elif $_cc --version 2>/dev/null | grep -q ^icc; then
3319 _type=icc
3320 _ident=$($_cc --version | head -n1)
3321 _depflags='-MMD'
3322 _cflags_speed='-O3'
3323 _cflags_size='-Os'
3324 _cflags_noopt='-O1'
3325 elif $_cc -v 2>&1 | grep -q xlc; then
3326 _type=xlc
3327 _ident=$($_cc -qversion 2>/dev/null | head -n1)
3328 _cflags_speed='-O5'
3329 _cflags_size='-O5 -qcompact'
3330 elif $_cc --vsn 2>/dev/null | grep -Eq "ARM (C/C\+\+ )?Compiler"; then
3331 test -d "$sysroot" || die "No valid sysroot specified."
3332 _type=armcc
3333 _ident=$($_cc --vsn | grep -i build | head -n1 | sed 's/.*: //')
3334 armcc_conf="$PWD/armcc.conf"
3335 $_cc --arm_linux_configure \
3336 --arm_linux_config_file="$armcc_conf" \
3337 --configure_sysroot="$sysroot" \
3338 --configure_cpp_headers="$sysinclude" >>$logfile 2>&1 ||
3339 die "Error creating armcc configuration file."
3340 $_cc --vsn | grep -q RVCT && armcc_opt=rvct || armcc_opt=armcc
3341 _flags="--arm_linux_config_file=$armcc_conf --translate_gcc"
3342 as_default="${cross_prefix}gcc"
3343 _depflags='-MMD'
3344 _cflags_speed='-O3'
3345 _cflags_size='-Os'
3346 elif $_cc -v 2>&1 | grep -q clang; then
3347 _type=clang
3348 _ident=$($_cc --version 2>/dev/null | head -n1)
3349 _depflags='-MMD -MF $(@:.o=.d) -MT $@'
3350 _cflags_speed='-O3'
3351 _cflags_size='-Os'
3352 elif $_cc -V 2>&1 | grep -q Sun; then
3353 _type=suncc
3354 _ident=$($_cc -V 2>&1 | head -n1 | cut -d' ' -f 2-)
3355 _DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< | sed -e "1s,^.*: ,$@: ," -e "\$$!s,\$$, \\\," -e "1!s,^.*: , ," > $(@:.o=.d)'
3356 _DEPFLAGS='-xM1 -xc99'
3357 _ldflags='-std=c99'
3358 _cflags_speed='-O5'
3359 _cflags_size='-O5 -xspace'
3360 _flags_filter=suncc_flags
3361 elif $_cc -v 2>&1 | grep -q 'PathScale\|Path64'; then
3362 _type=pathscale
3363 _ident=$($_cc -v 2>&1 | head -n1 | tr -d :)
3364 _depflags='-MMD -MF $(@:.o=.d) -MT $@'
3365 _cflags_speed='-O2'
3366 _cflags_size='-Os'
3367 _flags_filter='filter_out -Wdisabled-optimization'
3368 elif $_cc -v 2>&1 | grep -q Open64; then
3369 _type=open64
3370 _ident=$($_cc -v 2>&1 | head -n1 | tr -d :)
3371 _depflags='-MMD -MF $(@:.o=.d) -MT $@'
3372 _cflags_speed='-O2'
3373 _cflags_size='-Os'
3374 _flags_filter='filter_out -Wdisabled-optimization|-Wtype-limits|-fno-signed-zeros'
3375 elif $_cc 2>&1 | grep -q 'Microsoft.*ARM.*Assembler'; then
3376 _type=armasm
3377 _ident=$($_cc | head -n1)
3378 # 4509: "This form of conditional instruction is deprecated"
3379 _flags="-nologo -ignore 4509"
3380 _flags_filter=armasm_flags
3381 elif $_cc -nologo- 2>&1 | grep -q Microsoft; then
3382 _type=msvc
3383 _ident=$($_cc 2>&1 | head -n1)
3384 _DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< 2>&1 | awk '\''/including/ { sub(/^.*file: */, ""); gsub(/\\/, "/"); if (!match($$0, / /)) print "$@:", $$0 }'\'' > $(@:.o=.d)'
3385 _DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -showIncludes -Zs'
3386 _cflags_speed="-O2"
3387 _cflags_size="-O1"
3388 _cflags_noopt="-O1"
3389 if $_cc -nologo- 2>&1 | grep -q Linker; then
3390 _ld_o='-out:$@'
3391 else
3392 _ld_o='-Fe$@'
3393 fi
3394 _cc_o='-Fo$@'
3395 _cc_e='-P -Fi$@'
3396 _flags_filter=msvc_flags
3397 _ld_lib='lib%.a'
3398 _ld_path='-libpath:'
3399 _flags='-nologo'
3400 elif $_cc 2>&1 | grep -q Intel; then
3401 _type=icl
3402 _ident=$($_cc 2>&1 | head -n1)
3403 _depflags='-QMMD -QMF$(@:.o=.d) -QMT$@'
3404 # Not only is O3 broken on 13.x+ but it is slower on all previous
3405 # versions (tested) as well.
3406 _cflags_speed="-O2"
3407 _cflags_size="-O1 -Oi" # -O1 without -Oi miscompiles stuff
3408 if $_cc 2>&1 | grep -q Linker; then
3409 _ld_o='-out:$@'
3410 else
3411 _ld_o='-Fe$@'
3412 fi
3413 _cc_o='-Fo$@'
3414 _cc_e='-P'
3415 _flags_filter=icl_flags
3416 _ld_lib='lib%.a'
3417 _ld_path='-libpath:'
3418 # -Qdiag-error to make icl error when seeing certain unknown arguments
3419 _flags='-nologo -Qdiag-error:4044,10157'
3420 # -Qvec- -Qsimd- to prevent miscompilation, -GS for consistency
3421 # with MSVC which enables it by default.
3422 _cflags='-Qms0 -Qvec- -Qsimd- -GS'
3423 elif $_cc -? 2>/dev/null | grep -q 'LLVM.*Linker'; then
3424 # lld can emulate multiple different linkers; in ms link.exe mode,
3425 # the -? parameter gives the help output which contains an identifyable
3426 # string, while it gives an error in other modes.
3427 _type=lld-link
3428 # The link.exe mode doesn't have a switch for getting the version,
3429 # but we can force it back to gnu mode and get the version from there.
3430 _ident=$($_cc -flavor gnu --version 2>/dev/null)
3431 _ld_o='-out:$@'
3432 _flags_filter=msvc_flags
3433 _ld_lib='lib%.a'
3434 _ld_path='-libpath:'
3435 elif $_cc --version 2>/dev/null | grep -q ^cparser; then
3436 _type=cparser
3437 _ident=$($_cc --version | head -n1)
3438 _depflags='-MMD'
3439 _cflags_speed='-O4'
3440 _cflags_size='-O2'
3441 _flags_filter=cparser_flags
3442 fi
3443
3444 eval ${pfx}_type=\$_type
3445 eval ${pfx}_ident=\$_ident
3446}
3447
3448set_ccvars(){
3449 eval ${1}_C=\${_cc_c-\${${1}_C}}
3450 eval ${1}_E=\${_cc_e-\${${1}_E}}
3451 eval ${1}_O=\${_cc_o-\${${1}_O}}
3452
3453 if [ -n "$_depflags" ]; then
3454 eval ${1}_DEPFLAGS=\$_depflags
3455 else
3456 eval ${1}DEP=\${_DEPCMD:-\$DEPCMD}
3457 eval ${1}DEP_FLAGS=\${_DEPFLAGS:-\$DEPFLAGS}
3458 eval DEP${1}FLAGS=\$_flags
3459 fi
3460}
3461
3462probe_cc cc "$cc"
3463cflags_filter=$_flags_filter
3464cflags_speed=$_cflags_speed
3465cflags_size=$_cflags_size
3466cflags_noopt=$_cflags_noopt
3467add_cflags $_flags $_cflags
3468cc_ldflags=$_ldflags
3469set_ccvars CC
3470
3471probe_cc hostcc "$host_cc"
3472host_cflags_filter=$_flags_filter
3473host_cflags_speed=$_cflags_speed
3474add_host_cflags $_flags $_cflags
3475set_ccvars HOSTCC
3476
3477test -n "$cc_type" && enable $cc_type ||
3478 warn "Unknown C compiler $cc, unable to select optimal CFLAGS"
3479
3480: ${as_default:=$cc}
3481: ${objcc_default:=$cc}
3482: ${dep_cc_default:=$cc}
3483: ${ld_default:=$cc}
3484: ${host_ld_default:=$host_cc}
3485set_default ar as objcc dep_cc ld host_ld
3486
3487probe_cc as "$as"
3488asflags_filter=$_flags_filter
3489add_asflags $_flags $_cflags
3490set_ccvars AS
3491
3492probe_cc objcc "$objcc"
3493objcflags_filter=$_flags_filter
3494add_objcflags $_flags $_cflags
3495set_ccvars OBJC
3496
3497probe_cc ld "$ld"
3498ldflags_filter=$_flags_filter
3499add_ldflags $_flags $_ldflags
3500test "$cc_type" != "$ld_type" && add_ldflags $cc_ldflags
3501LD_O=${_ld_o-$LD_O}
3502LD_LIB=${_ld_lib-$LD_LIB}
3503LD_PATH=${_ld_path-$LD_PATH}
3504
3505probe_cc hostld "$host_ld"
3506host_ldflags_filter=$_flags_filter
3507add_host_ldflags $_flags $_ldflags
3508HOSTLD_O=${_ld_o-$HOSTLD_O}
3509
3510if [ -z "$CC_DEPFLAGS" ] && [ "$dep_cc" != "$cc" ]; then
3511 probe_cc depcc "$dep_cc"
3512 CCDEP=${_DEPCMD:-$DEPCMD}
3513 CCDEP_FLAGS=${_DEPFLAGS:=$DEPFLAGS}
3514 DEPCCFLAGS=$_flags
3515fi
3516
3517if $ar 2>&1 | grep -q Microsoft; then
3518 arflags="-nologo"
3519 ar_o='-out:$@'
3520else
3521 arflags="rc"
3522 ar_o='$@'
3523fi
3524
3525add_cflags $extra_cflags
3526add_objcflags $extra_objcflags
3527add_asflags $extra_cflags
3528
3529if test -n "$sysroot"; then
3530 case "$cc_type" in
3531 gcc|llvm_gcc|clang)
3532 add_cppflags --sysroot="$sysroot"
3533 add_ldflags --sysroot="$sysroot"
3534 ;;
3535 esac
3536fi
3537
3538if test "$cpu" = host; then
3539 enabled cross_compile &&
3540 die "--cpu=host makes no sense when cross-compiling."
3541
3542 case "$cc_type" in
3543 gcc|llvm_gcc)
3544 check_native(){
3545 $cc $1=native -v -c -o $TMPO $TMPC >$TMPE 2>&1 || return
3546 sed -n "/cc1.*$1=/{
3547 s/.*$1=\\([^ ]*\\).*/\\1/
3548 p
3549 q
3550 }" $TMPE
3551 }
3552 cpu=$(check_native -march || check_native -mcpu)
3553 ;;
3554 esac
3555
3556 test "${cpu:-host}" = host &&
3557 die "--cpu=host not supported with compiler $cc"
3558fi
3559
3560# Deal with common $arch aliases
3561case "$arch" in
3562 aarch64|arm64)
3563 arch="aarch64"
3564 ;;
3565 arm*)
3566 arch="arm"
3567 ;;
3568 mips*|IP*)
3569 case "$arch" in
3570 *el)
3571 add_cppflags -EL
3572 add_ldflags -EL
3573 ;;
3574 *eb)
3575 add_cppflags -EB
3576 add_ldflags -EB
3577 ;;
3578 esac
3579 arch="mips"
3580 ;;
3581 parisc*|hppa*)
3582 arch="parisc"
3583 ;;
3584 "Power Macintosh"|ppc*|powerpc*)
3585 arch="ppc"
3586 ;;
3587 s390|s390x)
3588 arch="s390"
3589 ;;
3590 sh4|sh)
3591 arch="sh4"
3592 ;;
3593 sun4u|sparc*)
3594 arch="sparc"
3595 ;;
3596 tilegx|tile-gx)
3597 arch="tilegx"
3598 ;;
3599 i[3-6]86|i86pc|BePC|x86pc|x86_64|amd64)
3600 arch="x86"
3601 ;;
3602esac
3603
3604is_in $arch $ARCH_LIST || warn "unknown architecture $arch"
3605enable $arch
3606
3607# Add processor-specific flags
3608if enabled aarch64; then
3609
3610 case $cpu in
3611 armv*)
3612 cpuflags="-march=$cpu"
3613 ;;
3614 *)
3615 cpuflags="-mcpu=$cpu"
3616 ;;
3617 esac
3618
3619elif enabled alpha; then
3620
3621 cpuflags="-mcpu=$cpu"
3622
3623elif enabled arm; then
3624
3625 check_arm_arch() {
3626 test_cpp_condition stddef.h \
3627 "defined __ARM_ARCH_${1}__ || defined __TARGET_ARCH_${2:-$1}" \
3628 $cpuflags
3629 }
3630
3631 probe_arm_arch() {
3632 if check_arm_arch 4; then echo armv4
3633 elif check_arm_arch 4T; then echo armv4t
3634 elif check_arm_arch 5; then echo armv5
3635 elif check_arm_arch 5E; then echo armv5e
3636 elif check_arm_arch 5T; then echo armv5t
3637 elif check_arm_arch 5TE; then echo armv5te
3638 elif check_arm_arch 5TEJ; then echo armv5te
3639 elif check_arm_arch 6; then echo armv6
3640 elif check_arm_arch 6J; then echo armv6j
3641 elif check_arm_arch 6K; then echo armv6k
3642 elif check_arm_arch 6Z; then echo armv6z
3643 elif check_arm_arch 6ZK; then echo armv6zk
3644 elif check_arm_arch 6T2; then echo armv6t2
3645 elif check_arm_arch 7; then echo armv7
3646 elif check_arm_arch 7A 7_A; then echo armv7-a
3647 elif check_arm_arch 7S; then echo armv7-a
3648 elif check_arm_arch 7R 7_R; then echo armv7-r
3649 elif check_arm_arch 7M 7_M; then echo armv7-m
3650 elif check_arm_arch 7EM 7E_M; then echo armv7-m
3651 elif check_arm_arch 8A 8_A; then echo armv8-a
3652 fi
3653 }
3654
3655 [ "$cpu" = generic ] && cpu=$(probe_arm_arch)
3656
3657 case $cpu in
3658 armv*)
3659 cpuflags="-march=$cpu"
3660 subarch=$(echo $cpu | sed 's/[^a-z0-9]//g')
3661 ;;
3662 *)
3663 cpuflags="-mcpu=$cpu"
3664 case $cpu in
3665 cortex-a*) subarch=armv7a ;;
3666 cortex-r*) subarch=armv7r ;;
3667 cortex-m*) enable thumb; subarch=armv7m ;;
3668 arm11*) subarch=armv6 ;;
3669 arm[79]*e*|arm9[24]6*|arm96*|arm102[26]) subarch=armv5te ;;
3670 armv4*|arm7*|arm9[24]*) subarch=armv4 ;;
3671 *) subarch=$(probe_arm_arch) ;;
3672 esac
3673 ;;
3674 esac
3675
3676 case "$subarch" in
3677 armv5t*) enable fast_clz ;;
3678 armv[6-8]*) enable fast_clz fast_unaligned ;;
3679 esac
3680
3681elif enabled avr32; then
3682
3683 case $cpu in
3684 ap7[02]0[0-2])
3685 subarch="avr32_ap"
3686 cpuflags="-mpart=$cpu"
3687 ;;
3688 ap)
3689 subarch="avr32_ap"
3690 cpuflags="-march=$cpu"
3691 ;;
3692 uc3[ab]*)
3693 subarch="avr32_uc"
3694 cpuflags="-mcpu=$cpu"
3695 ;;
3696 uc)
3697 subarch="avr32_uc"
3698 cpuflags="-march=$cpu"
3699 ;;
3700 esac
3701
3702elif enabled bfin; then
3703
3704 cpuflags="-mcpu=$cpu"
3705
3706elif enabled mips; then
3707
3708 cpuflags="-march=$cpu"
3709
3710elif enabled ppc; then
3711
3712 disable ldbrx
3713
3714 case $(tolower $cpu) in
3715 601|ppc601|powerpc601)
3716 cpuflags="-mcpu=601"
3717 disable altivec
3718 ;;
3719 603*|ppc603*|powerpc603*)
3720 cpuflags="-mcpu=603"
3721 disable altivec
3722 ;;
3723 604*|ppc604*|powerpc604*)
3724 cpuflags="-mcpu=604"
3725 disable altivec
3726 ;;
3727 g3|75*|ppc75*|powerpc75*)
3728 cpuflags="-mcpu=750"
3729 disable altivec
3730 ;;
3731 g4|745*|ppc745*|powerpc745*)
3732 cpuflags="-mcpu=7450"
3733 disable vsx
3734 ;;
3735 74*|ppc74*|powerpc74*)
3736 cpuflags="-mcpu=7400"
3737 disable vsx
3738 ;;
3739 g5|970|ppc970|powerpc970)
3740 cpuflags="-mcpu=970"
3741 disable vsx
3742 ;;
3743 power[3-6]*)
3744 cpuflags="-mcpu=$cpu"
3745 disable vsx
3746 ;;
3747 power[7-8]*)
3748 cpuflags="-mcpu=$cpu"
3749 enable ldbrx
3750 ;;
3751 cell)
3752 cpuflags="-mcpu=cell"
3753 enable ldbrx
3754 disable vsx
3755 ;;
3756 e500mc)
3757 cpuflags="-mcpu=e500mc"
3758 disable altivec
3759 ;;
3760 e500v2)
3761 cpuflags="-mcpu=8548 -mhard-float -mfloat-gprs=double"
3762 disable altivec
3763 disable dcbzl
3764 ;;
3765 e500)
3766 cpuflags="-mcpu=8540 -mhard-float"
3767 disable altivec
3768 disable dcbzl
3769 ;;
3770 esac
3771
3772elif enabled sparc; then
3773
3774 case $cpu in
3775 cypress|f93[04]|tsc701|sparcl*|supersparc|hypersparc|niagara|v[789])
3776 cpuflags="-mcpu=$cpu"
3777 ;;
3778 ultrasparc*|niagara[234])
3779 cpuflags="-mcpu=$cpu"
3780 ;;
3781 esac
3782
3783elif enabled x86; then
3784
3785 case $cpu in
3786 i[345]86|pentium)
3787 cpuflags="-march=$cpu"
3788 disable i686
3789 disable mmx
3790 ;;
3791 # targets that do NOT support nopl and conditional mov (cmov)
3792 pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
3793 cpuflags="-march=$cpu"
3794 disable i686
3795 ;;
3796 # targets that do support nopl and conditional mov (cmov)
3797 i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64*|k8*|opteron*|athlon-fx|core2|corei7*|amdfam10|barcelona|atom|bdver*)
3798 cpuflags="-march=$cpu"
3799 enable i686
3800 enable fast_cmov
3801 ;;
3802 # targets that do support conditional mov but on which it's slow
3803 pentium4|pentium4m|prescott|nocona)
3804 cpuflags="-march=$cpu"
3805 enable i686
3806 disable fast_cmov
3807 ;;
3808 esac
3809
3810fi
3811
3812if [ "$cpu" != generic ]; then
3813 add_cflags $cpuflags
3814 add_asflags $cpuflags
3815 test "$cc_type" = "$ld_type" && add_ldflags $cpuflags
3816fi
3817
3818# compiler sanity check
3819test_exec <<EOF
3820int main(void){ return 0; }
3821EOF
3822if test "$?" != 0; then
3823 echo "$cc is unable to create an executable file."
3824 if test -z "$cross_prefix" && ! enabled cross_compile ; then
3825 echo "If $cc is a cross-compiler, use the --enable-cross-compile option."
3826 echo "Only do this if you know what cross compiling means."
3827 fi
3828 die "C compiler test failed."
3829fi
3830
3831add_cppflags -D_ISOC99_SOURCE
3832
3833# some compilers silently accept -std=c11, so we also need to check that the
3834# version macro is defined properly
3835test_cpp_condition stdlib.h "__STDC_VERSION__ >= 201112L" -std=c11 &&
3836 add_cflags -std=c11 ||
3837 check_cflags -std=c99
3838
3839check_cppflags -D_FILE_OFFSET_BITS=64
3840check_cppflags -D_LARGEFILE_SOURCE
3841
3842add_host_cppflags -D_ISOC99_SOURCE
3843check_host_cflags -std=c99
3844check_host_cflags -Wall
3845check_host_cflags $host_cflags_speed
3846
3847check_64bit(){
3848 arch32=$1
3849 arch64=$2
3850 expr=${3:-'sizeof(void *) > 4'}
3851 test_code cc "" "int test[2*($expr) - 1]" &&
3852 subarch=$arch64 || subarch=$arch32
3853 enable $subarch
3854}
3855
3856case "$arch" in
3857 aarch64|alpha|ia64)
3858 enabled shared && enable_weak pic
3859 ;;
3860 mips)
3861 check_64bit mips mips64 '_MIPS_SIM > 1'
3862 enabled shared && enable_weak pic
3863 ;;
3864 parisc)
3865 check_64bit parisc parisc64
3866 enabled shared && enable_weak pic
3867 ;;
3868 ppc)
3869 check_64bit ppc ppc64
3870 enabled shared && enable_weak pic
3871 ;;
3872 s390)
3873 check_64bit s390 s390x
3874 enabled shared && enable_weak pic
3875 ;;
3876 sparc)
3877 check_64bit sparc sparc64
3878 enabled shared && enable_weak pic
3879 ;;
3880 x86)
3881 check_64bit x86_32 x86_64
3882 if enabled x86_64; then
3883 enabled shared && enable_weak pic
3884 objformat=elf64
3885 fi
3886 ;;
3887esac
3888
3889# OS specific
3890case $target_os in
3891 aix)
3892 SHFLAGS=-shared
3893 add_cppflags '-I\$(SRC_PATH)/compat/aix'
3894 enabled shared && add_ldflags -Wl,-brtl
3895 arflags='-Xany -r -c'
3896 ;;
3897 android)
3898 disable symver
3899 enable section_data_rel_ro
3900 SLIB_INSTALL_NAME='$(SLIBNAME)'
3901 SLIB_INSTALL_LINKS=
3902 SHFLAGS='-shared -Wl,-soname,$(SLIBNAME)'
3903 ;;
3904 haiku)
3905 prefix_default="/boot/common"
3906 network_extralibs="-lnetwork"
3907 host_extralibs=
3908 ;;
3909 sunos)
3910 SHFLAGS='-shared -Wl,-h,$$(@F)'
3911 enabled x86 && append SHFLAGS -mimpure-text
3912 network_extralibs="-lsocket -lnsl"
3913 # When using suncc to build, the Solaris linker will mark
3914 # an executable with each instruction set encountered by
3915 # the Solaris assembler. As our libraries contain their own
3916 # guards for processor-specific code, instead suppress
3917 # generation of the HWCAPS ELF section on Solaris x86 only.
3918 enabled_all suncc x86 &&
3919 echo "hwcap_1 = OVERRIDE;" > mapfile &&
3920 add_ldflags -Wl,-M,mapfile
3921 nm_default='nm -P -g'
3922 version_script='-M'
3923 VERSION_SCRIPT_POSTPROCESS_CMD='perl $(SRC_PATH)/compat/solaris/make_sunver.pl - $(OBJS)'
3924 ;;
3925 netbsd)
3926 disable symver
3927 oss_indev_extralibs="-lossaudio"
3928 ;;
3929 openbsd|bitrig)
3930 disable symver
3931 SHFLAGS='-shared'
3932 SLIB_INSTALL_NAME='$(SLIBNAME).$(LIBMAJOR).$(LIBMINOR)'
3933 SLIB_INSTALL_LINKS=
3934 oss_indev_extralibs="-lossaudio"
3935 ;;
3936 dragonfly)
3937 disable symver
3938 ;;
3939 freebsd)
3940 ;;
3941 bsd/os)
3942 add_extralibs -lpoll -lgnugetopt
3943 ;;
3944 darwin)
3945 enabled ppc && add_asflags -force_cpusubtype_ALL
3946 SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR),-current_version,$(LIBVERSION),-compatibility_version,$(LIBMAJOR)'
3947 enabled x86_32 && append SHFLAGS -Wl,-read_only_relocs,suppress
3948 add_ldflags -Wl,-dynamic,-search_paths_first
3949 check_cflags -Werror=partial-availability
3950 SLIBSUF=".dylib"
3951 SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME).$(LIBVERSION)$(SLIBSUF)'
3952 SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(NAME).$(LIBMAJOR)$(SLIBSUF)'
3953 enabled x86_64 && objformat="macho64" || objformat="macho32"
3954 enabled_any pic shared ||
3955 { check_cflags -mdynamic-no-pic && add_asflags -mdynamic-no-pic; }
3956 check_headers dispatch/dispatch.h &&
3957 add_cppflags '-I\$(SRC_PATH)/compat/dispatch_semaphore'
3958 if test -n "$sysroot"; then
3959 is_in -isysroot $cc $CPPFLAGS $CFLAGS || check_cppflags -isysroot $sysroot
3960 is_in -isysroot $ld $LDFLAGS || check_ldflags -isysroot $sysroot
3961 fi
3962 ;;
3963 msys*)
3964 die "Native MSYS builds are discouraged, please use the MINGW environment."
3965 ;;
3966 mingw32*|mingw64*)
3967 target_os=mingw32
3968 LIBTARGET=i386
3969 if enabled x86_64; then
3970 LIBTARGET="i386:x86-64"
3971 elif enabled arm; then
3972 LIBTARGET="arm"
3973 elif enabled aarch64; then
3974 LIBTARGET="arm64"
3975 fi
3976 if enabled shared; then
3977 # Cannot build both shared and static libs when using dllimport.
3978 disable static
3979 fi
3980 check_ldflags -Wl,--nxcompat
3981 check_ldflags -Wl,--dynamicbase
3982 shlibdir_default="$bindir_default"
3983 SLIBPREF=""
3984 SLIBSUF=".dll"
3985 SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
3986 SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(NAME)-$(LIBMAJOR)$(SLIBSUF)'
3987 SLIB_EXTRA_CMD=-'$(DLLTOOL) -m $(LIBTARGET) -d $$(@:$(SLIBSUF)=.def) -l $(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib) -D $(SLIBNAME_WITH_MAJOR)'
3988 SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
3989 SLIB_INSTALL_LINKS=
3990 SLIB_INSTALL_EXTRA_SHLIB='$(SLIBNAME:$(SLIBSUF)=.lib)'
3991 SLIB_INSTALL_EXTRA_LIB='lib$(SLIBNAME:$(SLIBSUF)=.dll.a) $(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.def)'
3992 SLIB_CREATE_DEF_CMD='EXTERN_PREFIX="$(EXTERN_PREFIX)" AR="$(AR_CMD)" NM="$(NM_CMD)" $(SRC_PATH)/compat/windows/makedef $(SUBDIR)lib$(NAME).ver $(OBJS) > $$(@:$(SLIBSUF)=.def)'
3993 SHFLAGS='-shared -Wl,--out-implib,$(SUBDIR)lib$(SLIBNAME:$(SLIBSUF)=.dll.a) -Wl,--enable-auto-image-base $$(@:$(SLIBSUF)=.def)'
3994 enabled x86_64 && objformat="win64" || objformat="win32"
3995 dlltool="${cross_prefix}dlltool"
3996 ranlib=:
3997 enable dos_paths
3998 ;;
3999 win32|win64)
4000 disable symver
4001 if enabled shared; then
4002 # Link to the import library instead of the normal static library
4003 # for shared libs.
4004 LD_LIB='%.lib'
4005 # Cannot build both shared and static libs with MSVC or icl.
4006 disable static
4007 fi
4008 shlibdir_default="$bindir_default"
4009 SLIBPREF=""
4010 SLIBSUF=".dll"
4011 SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
4012 SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(NAME)-$(LIBMAJOR)$(SLIBSUF)'
4013 SLIB_CREATE_DEF_CMD='EXTERN_PREFIX="$(EXTERN_PREFIX)" $(SRC_PATH)/compat/windows/makedef $(SUBDIR)lib$(NAME).ver $(OBJS) > $$(@:$(SLIBSUF)=.def)'
4014 SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
4015 SLIB_INSTALL_LINKS=
4016 SLIB_INSTALL_EXTRA_SHLIB='$(SLIBNAME:$(SLIBSUF)=.lib)'
4017 SLIB_INSTALL_EXTRA_LIB='$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.def)'
4018 SHFLAGS='-dll -def:$$(@:$(SLIBSUF)=.def) -implib:$(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib)'
4019 enabled x86_64 && objformat="win64" || objformat="win32"
4020 ranlib=:
4021 enable dos_paths
4022 ;;
4023 cygwin*)
4024 target_os=cygwin
4025 shlibdir_default="$bindir_default"
4026 SLIBPREF="cyg"
4027 SLIBSUF=".dll"
4028 SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
4029 SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(NAME)-$(LIBMAJOR)$(SLIBSUF)'
4030 SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
4031 SLIB_INSTALL_LINKS=
4032 SLIB_INSTALL_EXTRA_LIB='lib$(NAME).dll.a'
4033 SHFLAGS='-shared -Wl,--out-implib,$(SUBDIR)lib$(NAME).dll.a'
4034 enabled x86_64 && objformat="win64" || objformat="win32"
4035 enable dos_paths
4036 ;;
4037 *-dos|freedos|opendos)
4038 network_extralibs="-lsocket"
4039 objformat="coff"
4040 enable dos_paths
4041 add_cppflags -U__STRICT_ANSI__
4042 ;;
4043 linux)
4044 enable section_data_rel_ro
4045 ;;
4046 irix*)
4047 target_os=irix
4048 ranlib="echo ignoring ranlib"
4049 ;;
4050 os/2*)
4051 ln_s="cp -f"
4052 objformat="aout"
4053 add_cppflags -D_GNU_SOURCE
4054 add_ldflags -Zomf -Zbin-files -Zargs-wild -Zhigh-mem -Zmap
4055 SHFLAGS='$(SUBDIR)$(NAME).def -Zdll -Zomf'
4056 LIBSUF="_s.a"
4057 SLIBPREF=""
4058 SLIBSUF=".dll"
4059 SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
4060 SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(shell echo $(NAME) | cut -c1-6)$(LIBMAJOR)$(SLIBSUF)'
4061 SLIB_CREATE_DEF_CMD='echo LIBRARY $(SLIBNAME_WITH_MAJOR) INITINSTANCE TERMINSTANCE > $(SUBDIR)$(NAME).def; \
4062 echo CODE PRELOAD MOVEABLE DISCARDABLE >> $(SUBDIR)$(NAME).def; \
4063 echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $(SUBDIR)$(NAME).def; \
4064 echo EXPORTS >> $(SUBDIR)$(NAME).def; \
4065 emxexp $(OBJS) >> $(SUBDIR)$(NAME).def'
4066 SLIB_EXTRA_CMD='emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(NAME).def; \
4067 emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib $(SUBDIR)$(NAME).def;'
4068 SLIB_INSTALL_EXTRA_LIB='$(LIBPREF)$(NAME)_dll.a $(LIBPREF)$(NAME)_dll.lib'
4069 enable dos_paths
4070 ;;
4071 gnu/kfreebsd)
4072 add_cppflags -D_BSD_SOURCE
4073 ;;
4074 gnu)
4075 ;;
4076 qnx)
4077 add_cppflags -D_QNX_SOURCE
4078 network_extralibs="-lsocket"
4079 ;;
4080 symbian)
4081 SLIBSUF=".dll"
4082 enable dos_paths
4083 add_cflags --include=$sysinclude/gcce/gcce.h -fvisibility=default
4084 add_cppflags -D__GCCE__ -D__SYMBIAN32__ -DSYMBIAN_OE_POSIX_SIGNALS
4085 add_ldflags -Wl,--target1-abs,--no-undefined \
4086 -Wl,-Ttext,0x80000,-Tdata,0x1000000 -shared \
4087 -Wl,--entry=_E32Startup -Wl,-u,_E32Startup
4088 add_extralibs -l:eexe.lib -l:usrt2_2.lib -l:dfpaeabi.dso \
4089 -l:drtaeabi.dso -l:scppnwdl.dso -lsupc++ -lgcc \
4090 -l:libc.dso -l:libm.dso -l:euser.dso -l:libcrt0.lib
4091 ;;
4092 minix)
4093 ;;
4094 none)
4095 ;;
4096 *)
4097 die "Unknown OS '$target_os'."
4098 ;;
4099esac
4100
4101# determine libc flavour
4102
4103probe_libc(){
4104 pfx=$1
4105 pfx_no_=${pfx%_}
4106 # uclibc defines __GLIBC__, so it needs to be checked before glibc.
4107 if test_${pfx}cpp_condition features.h "defined __UCLIBC__"; then
4108 eval ${pfx}libc_type=uclibc
4109 add_${pfx}cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
4110 elif test_${pfx}cpp_condition features.h "defined __GLIBC__"; then
4111 eval ${pfx}libc_type=glibc
4112 add_${pfx}cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
4113 # MinGW headers can be installed on Cygwin, so check for newlib first.
4114 elif test_${pfx}cpp_condition newlib.h "defined _NEWLIB_VERSION"; then
4115 eval ${pfx}libc_type=newlib
4116 add_${pfx}cppflags -U__STRICT_ANSI__ -D_XOPEN_SOURCE=600
4117 test_${pfx}cpp_condition windows.h "!defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0600" &&
4118 add_${pfx}cppflags -D_WIN32_WINNT=0x0600
4119 # MinGW64 is backwards compatible with MinGW32, so check for it first.
4120 elif test_${pfx}cpp_condition _mingw.h "defined __MINGW64_VERSION_MAJOR"; then
4121 eval ${pfx}libc_type=mingw64
4122 add_${pfx}cppflags -U__STRICT_ANSI__ -D__USE_MINGW_ANSI_STDIO=1
4123 eval test \$${pfx_no_}cc_type = "gcc" &&
4124 add_${pfx}cppflags -D__printf__=__gnu_printf__
4125 test_${pfx}cpp_condition windows.h "!defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0600" &&
4126 add_${pfx}cppflags -D_WIN32_WINNT=0x0600
4127 add_${pfx}cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
4128 elif test_${pfx}cpp_condition _mingw.h "defined __MINGW_VERSION" ||
4129 test_${pfx}cpp_condition _mingw.h "defined __MINGW32_VERSION"; then
4130 eval ${pfx}libc_type=mingw32
4131 test_${pfx}cpp_condition _mingw.h "__MINGW32_MAJOR_VERSION > 3 || \
4132 (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" ||
4133 die "ERROR: MinGW32 runtime version must be >= 3.15."
4134 add_${pfx}cppflags -U__STRICT_ANSI__ -D__USE_MINGW_ANSI_STDIO=1
4135 test_${pfx}cpp_condition _mingw.h "__MSVCRT_VERSION__ < 0x0700" &&
4136 add_${pfx}cppflags -D__MSVCRT_VERSION__=0x0700
4137 test_${pfx}cpp_condition windows.h "!defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0600" &&
4138 add_${pfx}cppflags -D_WIN32_WINNT=0x0600
4139 eval test \$${pfx_no_}cc_type = "gcc" &&
4140 add_${pfx}cppflags -D__printf__=__gnu_printf__
4141 add_${pfx}cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
4142 elif test_${pfx}cpp_condition crtversion.h "defined _VC_CRT_MAJOR_VERSION"; then
4143 eval ${pfx}libc_type=msvcrt
4144 if test_${pfx}cpp_condition crtversion.h "_VC_CRT_MAJOR_VERSION < 14"; then
4145 if [ "$pfx" = host_ ]; then
4146 add_host_cppflags -Dsnprintf=_snprintf
4147 else
4148 add_compat strtod.o strtod=avpriv_strtod
4149 add_compat msvcrt/snprintf.o snprintf=avpriv_snprintf \
4150 _snprintf=avpriv_snprintf \
4151 vsnprintf=avpriv_vsnprintf
4152 fi
4153 fi
4154 add_${pfx}cppflags -D_USE_MATH_DEFINES -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS
4155 # The MSVC 2010 headers (Win 7.0 SDK) set _WIN32_WINNT to
4156 # 0x601 by default unless something else is set by the user.
4157 # This can easily lead to us detecting functions only present
4158 # in such new versions and producing binaries requiring windows 7.0.
4159 # Therefore explicitly set the default to Vista unless the user has
4160 # set something else on the command line.
4161 # Don't do this if WINAPI_FAMILY is set and is set to a non-desktop
4162 # family. For these cases, configure is free to use any functions
4163 # found in the SDK headers by default. (Alternatively, we could force
4164 # _WIN32_WINNT to 0x0602 in that case.)
4165 test_${pfx}cpp_condition stdlib.h "defined(_WIN32_WINNT)" ||
4166 { test_${pfx}cpp <<EOF && add_${pfx}cppflags -D_WIN32_WINNT=0x0600; }
4167#ifdef WINAPI_FAMILY
4168#include <winapifamily.h>
4169#if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
4170#error not desktop
4171#endif
4172#endif
4173EOF
4174 if [ "$pfx" = "" ]; then
4175 check_func strtoll || add_cflags -Dstrtoll=_strtoi64
4176 fi
4177 elif test_${pfx}cpp_condition stddef.h "defined __KLIBC__"; then
4178 eval ${pfx}libc_type=klibc
4179 elif test_${pfx}cpp_condition sys/cdefs.h "defined __BIONIC__"; then
4180 eval ${pfx}libc_type=bionic
4181 elif test_${pfx}cpp_condition sys/brand.h "defined LABELED_BRAND_NAME"; then
4182 eval ${pfx}libc_type=solaris
4183 add_${pfx}cppflags -D__EXTENSIONS__ -D_XOPEN_SOURCE=600
4184 else
4185 eval ${pfx}libc_type=default
4186 add_${pfx}cppflags -D_DEFAULT_SOURCE
4187 fi
4188 eval test -n "\${${pfx}libc_type}" && enable ${pfx}libc_${libc_type}
4189}
4190
4191probe_libc
4192probe_libc host_
4193
4194# hacks for compiler/libc/os combinations
4195
4196case $libc_type in
4197 bionic)
4198 add_compat strtod.o strtod=avpriv_strtod
4199 ;;
4200esac
4201
4202check_compile_assert flt_lim "float.h limits.h" "DBL_MAX == (double)DBL_MAX" ||
4203 add_cppflags '-I\$(SRC_PATH)/compat/float'
4204
4205test_cpp_condition stdlib.h "defined(__PIC__) || defined(__pic__) || defined(PIC)" && enable_weak pic
4206
4207set_default $PATHS_LIST
4208set_default nm
4209
4210disabled optimizations || check_cflags -fomit-frame-pointer
4211
4212enable_weak_pic() {
4213 disabled pic && return
4214 enable pic
4215 add_cppflags -DPIC
4216 case "$target_os" in
4217 mingw*|cygwin*|win*)
4218 ;;
4219 *)
4220 add_cflags -fPIC
4221 add_asflags -fPIC
4222 ;;
4223 esac
4224}
4225
4226enabled pic && enable_weak_pic
4227
4228test_cc <<EOF || die "Symbol mangling check failed."
4229int ff_extern;
4230EOF
4231sym=$($nm $TMPO | awk '/ff_extern/{ print substr($0, match($0, /[^ \t]*ff_extern/)) }')
4232extern_prefix=${sym%%ff_extern*}
4233
4234! disabled inline_asm && check_inline_asm inline_asm '"" ::'
4235
4236for restrict_keyword in restrict __restrict__ __restrict ""; do
4237 test_code cc "" "char * $restrict_keyword p" && break
4238done
4239
4240check_cc pragma_deprecated "" '_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")'
4241
4242# The global variable ensures the bits appear unchanged in the object file.
4243test_cc <<EOF || die "endian test failed"
4244unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
4245EOF
4246od -t x1 $TMPO | grep -q '42 *49 *47 *45' && enable bigendian
4247
4248check_gas() {
4249 log "check_gas using '$as' as AS"
4250 # :vararg is used on aarch64, arm and ppc altivec
4251 check_as vararg "
4252.macro m n, y:vararg=0
4253\n: .int \y
4254.endm
4255m x" || return 1
4256 # .altmacro is only used in arm asm
4257 ! enabled arm || check_as gnu_as ".altmacro"
4258}
4259
4260if enabled_any arm aarch64 || enabled_all ppc altivec && enabled asm; then
4261 nogas=:
4262 enabled_any arm aarch64 && nogas=die
4263 enabled_all ppc altivec && nogas=warn
4264 as_noop=-v
4265
4266 case $as_type in
4267 arm*) gaspp_as_type=armasm; as_noop=-h ;;
4268 gcc) gaspp_as_type=gas ;;
4269 *) gaspp_as_type=$as_type ;;
4270 esac
4271
4272 [ $target_os = "darwin" ] && gaspp_as_type="apple-$gaspp_as_type"
4273
4274 test_cmd gas-preprocessor.pl -arch $arch -as-type $gaspp_as_type -- $as $as_noop &&
4275 gas="gas-preprocessor.pl -arch $arch -as-type $gaspp_as_type -- $as"
4276
4277 if ! check_gas ; then
4278 as=${gas:=$as}
4279 check_gas || \
4280 $nogas "GNU assembler not found, install/update gas-preprocessor"
4281 fi
4282
4283 check_as as_func ".func test
4284 .endfunc"
4285fi
4286
4287check_inline_asm inline_asm_labels '"1:\n"'
4288
4289if enabled aarch64; then
4290 enabled armv8 && check_insn armv8 'prfm pldl1strm, [x0]'
4291 # internal assembler in clang 3.3 does not support this instruction
4292 enabled neon && check_insn neon 'ext v0.8B, v0.8B, v1.8B, #1'
4293 enabled vfp && check_insn vfp 'fmadd d0, d0, d1, d2'
4294
4295 map 'enabled_any ${v}_external ${v}_inline || disable $v' $ARCH_EXT_LIST_ARM
4296
4297elif enabled alpha; then
4298
4299 check_cflags -mieee
4300
4301elif enabled arm; then
4302
4303 enabled msvc && check_cpp_condition thumb stddef.h "defined _M_ARMT"
4304 test_cpp_condition stddef.h "defined __thumb__" && enable_weak thumb
4305 enabled thumb && check_cflags -mthumb || check_cflags -marm
4306
4307 if check_cpp_condition vfp_args stddef.h "defined __ARM_PCS_VFP"; then
4308 :
4309 elif check_cpp_condition vfp_args stddef.h "defined _M_ARM_FP && _M_ARM_FP >= 30"; then
4310 :
4311 elif ! test_cpp_condition stddef.h "defined __ARM_PCS || defined __SOFTFP__" && [ $target_os != darwin ]; then
4312 case "${cross_prefix:-$cc}" in
4313 *hardfloat*) enable vfp_args; fpabi=vfp ;;
4314 *) check_ld vfp_args <<EOF && fpabi=vfp || fpabi=soft ;;
4315__asm__ (".eabi_attribute 28, 1");
4316int main(void) { return 0; }
4317EOF
4318 esac
4319 warn "Compiler does not indicate floating-point ABI, guessing $fpabi."
4320 fi
4321
4322 enabled armv5te && check_insn armv5te 'qadd r0, r0, r0'
4323 enabled armv6 && check_insn armv6 'sadd16 r0, r0, r0'
4324 enabled armv6t2 && check_insn armv6t2 'movt r0, #0'
4325 enabled neon && check_insn neon 'vadd.i16 q0, q0, q0'
4326 enabled vfp && check_insn vfp 'fadds s0, s0, s0'
4327 enabled vfpv3 && check_insn vfpv3 'vmov.f32 s0, #1.0'
4328
4329 [ $target_os = linux ] || [ $target_os = android ] ||
4330 map 'enabled_any ${v}_external ${v}_inline || disable $v' \
4331 $ARCH_EXT_LIST_ARM
4332
4333 check_inline_asm asm_mod_q '"add r0, %Q0, %R0" :: "r"((long long)0)'
4334
4335 check_as as_arch_directive ".arch armv7-a"
4336 check_as as_fpu_directive ".fpu neon"
4337
4338 # llvm's integrated assembler supports .object_arch from llvm 3.5
4339 [ "$objformat" = elf32 ] || [ "$objformat" = elf64 ] &&
4340 check_as as_object_arch ".object_arch armv4"
4341
4342 # MS armasm fails to assemble our PIC constructs
4343 [ $target_os != win32 ] && enabled_all armv6t2 shared !pic && enable_weak_pic
4344
4345elif enabled mips; then
4346
4347 # make sure that only one instruction set is enabled
4348 disable $ARCH_EXT_LIST_MIPS
4349
4350 check_inline_asm loongson '"dmult.g $1, $2, $3"'
4351
4352 if enabled mips64; then
4353 check_inline_asm mips64r6 '"dlsa $0, $0, $0, 1"' ||
4354 check_inline_asm mips64r2 '"dext $0, $0, 0, 1"' ||
4355 check_inline_asm mips64r1 '"daddi $0, $0, 0"'
4356 else
4357 check_inline_asm mips32r6 '"aui $0, $0, 0"' ||
4358 check_inline_asm mips32r2 '"ext $0, $0, 0, 1"' ||
4359 check_inline_asm mips32r1 '"addi $0, $0, 0"'
4360 fi
4361
4362elif enabled parisc; then
4363
4364 if enabled gcc; then
4365 case $($cc -dumpversion) in
4366 4.[3-8].*) check_cflags -fno-optimize-sibling-calls ;;
4367 esac
4368 fi
4369
4370elif enabled ppc; then
4371
4372 enable local_aligned_8 local_aligned_16 local_aligned_32
4373
4374 check_inline_asm dcbzl '"dcbzl 0, %0" :: "r"(0)'
4375 check_inline_asm ibm_asm '"add 0, 0, 0"'
4376 check_inline_asm ppc4xx '"maclhw r10, r11, r12"'
4377 check_inline_asm xform_asm '"lwzx %1, %y0" :: "Z"(*(int*)0), "r"(0)'
4378
4379 if enabled altivec; then
4380 check_cflags -maltivec -mabi=altivec
4381
4382 # check if our compiler supports Motorola AltiVec C API
4383 check_cc altivec altivec.h "vector signed int v1 = (vector signed int) { 0 };
4384 vector signed int v2 = (vector signed int) { 1 };
4385 v1 = vec_add(v1, v2);"
4386
4387 enabled altivec || warn "Altivec disabled, possibly missing --cpu flag"
4388 fi
4389
4390 if enabled vsx; then
4391 check_cflags -mvsx &&
4392 check_cc vsx altivec.h "int v[4] = { 0 };
4393 vector signed int v1 = vec_vsx_ld(0, v);"
4394 fi
4395
4396 if enabled power8; then
4397 check_cpp_condition power8 altivec.h "defined(_ARCH_PWR8)"
4398 fi
4399
4400elif enabled x86; then
4401
4402 check_builtin rdtsc intrin.h "__rdtsc()"
4403 check_builtin mm_empty mmintrin.h "_mm_empty()"
4404
4405 enable local_aligned_8 local_aligned_16 local_aligned_32
4406
4407 # check whether EBP is available on x86
4408 # As 'i' is stored on the stack, this program will crash
4409 # if the base pointer is used to access it because the
4410 # base pointer is cleared in the inline assembly code.
4411 check_exec_crash <<EOF && enable ebp_available
4412volatile int i=0;
4413__asm__ volatile ("xorl %%ebp, %%ebp" ::: "%ebp");
4414return i;
4415EOF
4416
4417 # check whether EBX is available on x86
4418 check_inline_asm ebx_available '""::"b"(0)' &&
4419 check_inline_asm ebx_available '"":::"%ebx"'
4420
4421 # check whether xmm clobbers are supported
4422 check_inline_asm xmm_clobbers '"":::"%xmm0"'
4423
4424 # check whether binutils is new enough to compile SSSE3/MMXEXT
4425 enabled ssse3 && check_inline_asm ssse3_inline '"pabsw %xmm0, %xmm0"'
4426 enabled mmxext && check_inline_asm mmxext_inline '"pmaxub %mm0, %mm1"'
4427
4428 probe_x86asm(){
4429 x86asmexe_probe=$1
4430 if test_cmd $x86asmexe_probe -v; then
4431 x86asmexe=$x86asmexe_probe
4432 x86asm_type=nasm
4433 x86asm_debug="-g -F dwarf"
4434 X86ASMDEP=
4435 X86ASM_DEPFLAGS='-MD $(@:.o=.d)'
4436 elif test_cmd $x86asmexe_probe --version; then
4437 x86asmexe=$x86asmexe_probe
4438 x86asm_type=yasm
4439 x86asm_debug="-g dwarf2"
4440 X86ASMDEP='$(DEPX86ASM) $(X86ASMFLAGS) -M $(X86ASM_O) $< > $(@:.o=.d)'
4441 X86ASM_DEPFLAGS=
4442 fi
4443 check_x86asm x86asm "movbe ecx, [5]"
4444 }
4445
4446 if ! disabled_any asm mmx x86asm; then
4447 disable x86asm
4448 for program in $x86asmexe nasm yasm; do
4449 probe_x86asm $program && break
4450 done
4451 disabled x86asm && die "nasm/yasm not found or too old. Use --disable-x86asm for a crippled build."
4452 X86ASMFLAGS="-f $objformat"
4453 enabled pic && append X86ASMFLAGS "-DPIC"
4454 test -n "$extern_prefix" && append X86ASMFLAGS "-DPREFIX"
4455 case "$objformat" in
4456 elf*) enabled debug && append X86ASMFLAGS $x86asm_debug ;;
4457 esac
4458
4459 check_x86asm avx2_external "vextracti128 xmm0, ymm0, 0"
4460 check_x86asm xop_external "vpmacsdd xmm0, xmm1, xmm2, xmm3"
4461 check_x86asm fma3_external "vfmadd132ps ymm0, ymm1, ymm2"
4462 check_x86asm fma4_external "vfmaddps ymm0, ymm1, ymm2, ymm3"
4463 check_x86asm cpunop "CPU amdnop"
4464 fi
4465
4466 case "$cpu" in
4467 athlon*|opteron*|k8*|pentium|pentium-mmx|prescott|nocona|atom|geode)
4468 disable fast_clz
4469 ;;
4470 esac
4471
4472fi
4473
4474check_cc intrinsics_neon arm_neon.h "int16x8_t test = vdupq_n_s16(0)"
4475
4476check_ldflags -Wl,--as-needed
4477
4478if ! disabled network; then
4479 check_func getaddrinfo $network_extralibs
4480 check_func inet_aton $network_extralibs
4481
4482 check_type netdb.h "struct addrinfo"
4483 check_type netinet/in.h "struct group_source_req" -D_BSD_SOURCE
4484 check_type netinet/in.h "struct ip_mreq_source" -D_BSD_SOURCE
4485 check_type netinet/in.h "struct ipv6_mreq" -D_DARWIN_C_SOURCE
4486 check_type poll.h "struct pollfd"
4487 check_type netinet/sctp.h "struct sctp_event_subscribe"
4488 check_struct "sys/types.h sys/socket.h" "struct sockaddr" sa_len
4489 check_type netinet/in.h "struct sockaddr_in6"
4490 check_type "sys/types.h sys/socket.h" "struct sockaddr_storage"
4491 check_type "sys/types.h sys/socket.h" socklen_t
4492
4493 # Prefer arpa/inet.h over winsock2
4494 if check_headers arpa/inet.h ; then
4495 check_func closesocket
4496 elif check_headers winsock2.h ; then
4497 check_func_headers winsock2.h closesocket -lws2 &&
4498 network_extralibs="-lws2" ||
4499 { check_func_headers winsock2.h closesocket -lws2_32 &&
4500 network_extralibs="-lws2_32"; } || disable winsock2_h network
4501 check_func_headers ws2tcpip.h getaddrinfo $network_extralibs
4502
4503 check_type ws2tcpip.h socklen_t
4504 check_type ws2tcpip.h "struct addrinfo"
4505 check_type ws2tcpip.h "struct group_source_req"
4506 check_type ws2tcpip.h "struct ip_mreq_source"
4507 check_type ws2tcpip.h "struct ipv6_mreq"
4508 check_type winsock2.h "struct pollfd"
4509 check_struct winsock2.h "struct sockaddr" sa_len
4510 check_type ws2tcpip.h "struct sockaddr_in6"
4511 check_type ws2tcpip.h "struct sockaddr_storage"
4512 else
4513 disable network
4514 fi
4515fi
4516
4517check_builtin atomic_cas_ptr atomic.h "void **ptr; void *oldval, *newval; atomic_cas_ptr(ptr, oldval, newval)"
4518check_builtin machine_rw_barrier mbarrier.h "__machine_rw_barrier()"
4519check_builtin MemoryBarrier windows.h "MemoryBarrier()"
4520check_builtin sync_val_compare_and_swap "" "int *ptr; int oldval, newval; __sync_val_compare_and_swap(ptr, oldval, newval)"
4521
4522case "$custom_allocator" in
4523 jemalloc)
4524 # jemalloc by default does not use a prefix
4525 require libjemalloc jemalloc/jemalloc.h malloc -ljemalloc
4526 ;;
4527 tcmalloc)
4528 require_pkg_config libtcmalloc libtcmalloc gperftools/tcmalloc.h tc_malloc
4529 malloc_prefix=tc_
4530 ;;
4531esac
4532
4533check_func_headers malloc.h _aligned_malloc && enable aligned_malloc
4534check_func ${malloc_prefix}memalign && enable memalign
4535check_func ${malloc_prefix}posix_memalign && enable posix_memalign
4536
4537test_cpp_condition unistd.h "defined(_POSIX_MONOTONIC_CLOCK)" &&
4538 { check_lib clock_gettime time.h clock_gettime ||
4539 check_lib clock_gettime time.h clock_gettime -lrt; }
4540
4541check_func fcntl
4542check_func gethrtime
4543check_func getopt
4544check_func getrusage
4545check_func gettimeofday
4546check_func isatty
4547check_func mkstemp
4548check_func mmap
4549check_func mprotect
4550# Solaris has nanosleep in -lrt, OpenSolaris no longer needs that
4551check_func_headers time.h nanosleep || check_lib nanosleep time.h nanosleep -lrt
4552check_func sched_getaffinity
4553check_func setrlimit
4554check_func strerror_r
4555check_func sysconf
4556check_func sysctl
4557check_func usleep
4558
4559check_func_headers io.h setmode
4560check_func_headers mach/mach_time.h mach_absolute_time
4561check_func_headers stdlib.h getenv
4562check_func_headers time.h gmtime_r
4563check_func_headers time.h localtime_r
4564
4565check_func_headers windows.h GetProcessAffinityMask
4566check_func_headers windows.h GetProcessTimes
4567check_func_headers windows.h GetSystemTimeAsFileTime
4568check_func_headers windows.h LoadLibrary
4569check_func_headers windows.h MapViewOfFile
4570check_func_headers windows.h SetConsoleTextAttribute
4571check_func_headers windows.h Sleep
4572check_func_headers windows.h VirtualAlloc
4573
4574check_headers direct.h
4575check_headers dxgidebug.h
4576check_headers dxva.h
4577check_headers dxva2api.h
4578check_headers io.h
4579check_headers malloc.h
4580check_headers poll.h
4581check_headers sys/param.h
4582check_headers sys/resource.h
4583check_headers sys/select.h
4584check_headers sys/time.h
4585check_headers sys/un.h
4586check_headers unistd.h
4587check_headers valgrind/valgrind.h
4588check_headers VideoDecodeAcceleration/VDADecoder.h
4589check_headers windows.h
4590
4591# it seems there are versions of clang in some distros that try to use the
4592# gcc headers, which explodes for stdatomic
4593# so we also check that atomics actually work here
4594check_builtin stdatomic stdatomic.h "atomic_int foo; atomic_store(&foo, 0)"
4595
4596check_lib bcrypt "windows.h bcrypt.h" BCryptGenRandom -lbcrypt &&
4597 check_cpp_condition bcrypt bcrypt.h "defined BCRYPT_RNG_ALGORITHM"
4598check_lib ole32 "windows.h" CoTaskMemFree -lole32
4599check_lib shell32 "windows.h shellapi.h" CommandLineToArgvW -lshell32
4600check_lib psapi "windows.h psapi.h" GetProcessMemoryInfo -lpsapi
4601
4602check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss
4603
4604check_type "cuviddec.h" "CUVIDH264PICPARAMS"
4605check_type "cuviddec.h" "CUVIDHEVCPICPARAMS"
4606check_struct "cuviddec.h" "CUVIDDECODECREATEINFO" bitDepthMinus8
4607
4608check_type "windows.h dxva.h" "DXVA_PicParams_HEVC" -DWINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP -D_CRT_BUILD_DESKTOP_APP=0
4609check_type "windows.h d3d11.h" "ID3D11VideoDecoder"
4610check_type "d3d9.h dxva2api.h" DXVA2_ConfigPictureDecode -D_WIN32_WINNT=0x0602
4611
4612check_type "va/va.h va/va_dec_hevc.h" "VAPictureParameterBufferHEVC"
4613check_type "va/va.h va/va_dec_vp8.h" "VAPictureParameterBufferVP8"
4614check_type "va/va.h va/va_vpp.h" "VAProcPipelineParameterBuffer"
4615check_type "va/va.h va/va_enc_h264.h" "VAEncPictureParameterBufferH264"
4616check_type "va/va.h va/va_enc_hevc.h" "VAEncPictureParameterBufferHEVC"
4617check_type "va/va.h va/va_enc_jpeg.h" "VAEncPictureParameterBufferJPEG"
4618check_type "va/va.h va/va_enc_mpeg2.h" "VAEncPictureParameterBufferMPEG2"
4619check_type "va/va.h va/va_enc_vp8.h" "VAEncPictureParameterBufferVP8"
4620check_type "va/va.h va/va_enc_vp9.h" "VAEncPictureParameterBufferVP9"
4621
4622check_type "vdpau/vdpau.h" "VdpPictureInfoHEVC"
4623
4624if ! disabled w32threads && ! enabled pthreads; then
4625 check_lib w32threads "windows.h process.h" _beginthreadex &&
4626 check_type "windows.h" CONDITION_VARIABLE
4627fi
4628
4629# check for some common methods of building with pthread support
4630# do this before the optional library checks as some of them require pthreads
4631if ! disabled pthreads && ! enabled w32threads; then
4632 if check_lib pthreads pthread.h pthread_join -pthread; then
4633 add_cflags -pthread
4634 elif check_lib pthreads pthread.h pthread_join -pthreads; then
4635 add_cflags -pthreads
4636 elif check_lib pthreads pthread.h pthread_join -lpthreadGC2; then
4637 :
4638 elif check_lib pthreads pthread.h pthread_join -lpthread; then
4639 :
4640 elif check_func pthread_join; then
4641 enable pthreads
4642 fi
4643 enabled pthreads &&
4644 check_builtin sem_timedwait semaphore.h "sem_t *s; sem_init(s,0,0); sem_timedwait(s,0); sem_destroy(s)" $pthreads_extralibs
4645fi
4646
4647disabled zlib || check_lib zlib zlib.h zlibVersion -lz
4648disabled bzlib || check_lib bzlib bzlib.h BZ2_bzlibVersion -lbz2
4649
4650# On some systems dynamic loading requires no extra linker flags
4651check_lib libdl dlfcn.h dlopen || check_lib libdl dlfcn.h dlopen -ldl
4652
4653check_lib libm math.h sin -lm
4654
4655atan2f_args=2
4656ldexpf_args=2
4657powf_args=2
4658
4659for func in $MATH_FUNCS; do
4660 eval check_mathfunc $func \${${func}_args:-1} $libm_extralibs
4661done
4662
4663# these are off by default, so fail if requested and not available
4664enabled amf && require_cpp_condition amf AMF/core/Version.h "(AMF_VERSION_MAJOR << 48 | AMF_VERSION_MINOR << 32 | AMF_VERSION_RELEASE << 16 | AMF_VERSION_BUILD_NUM) >= 0x0001000400040001"
4665enabled avisynth && require_headers avisynth/avisynth_c.h
4666enabled avxsynth && require_headers avxsynth/avxsynth_c.h
4667enabled cuda && require cuda cuda.h cuInit -lcuda
4668enabled cuvid && require cuvid cuviddec.h cuvidCreateDecoder -lnvcuvid
4669enabled frei0r && require_headers frei0r.h
4670enabled gnutls && require_pkg_config gnutls gnutls gnutls/gnutls.h gnutls_global_init &&
4671 check_lib gmp gmp.h mpz_export -lgmp
4672enabled libaom && {
4673 enabled libaom_av1_decoder && require_pkg_config libaom_av1_decoder "aom >= 1.0.0" "aom/aom_decoder.h aom/aomdx.h" aom_codec_av1_dx
4674 enabled libaom_av1_encoder && {
4675 require_pkg_config libaom_av1_encoder "aom >= 1.0.0" "aom/aom_encoder.h aom/aomcx.h" aom_codec_av1_cx &&
4676 require_cpp_condition libaom_av1_encoder aom/aom_encoder.h "defined AOM_FRAME_IS_INTRAONLY";
4677 }
4678}
4679enabled libbs2b && require_pkg_config libbs2b libbs2b bs2b.h bs2b_open
4680enabled libdc1394 && require_pkg_config libdc1394 libdc1394-2 dc1394/dc1394.h dc1394_new
4681enabled libdav1d && require_pkg_config libdav1d "dav1d >= 0.1.0" dav1d/dav1d.h dav1d_version
4682enabled libdcadec && require libdcadec libdcadec/dca_context.h dcadec_context_create -ldcadec
4683enabled libfaac && require libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
4684enabled libfdk_aac && require_pkg_config libfdk_aac fdk-aac "fdk-aac/aacenc_lib.h" aacEncOpen
4685enabled libfontconfig && require_pkg_config libfontconfig fontconfig "fontconfig/fontconfig.h" FcInit
4686enabled libfreetype && require_pkg_config libfreetype freetype2 "ft2build.h FT_FREETYPE_H" FT_Init_FreeType
4687enabled libgsm && require libgsm gsm.h gsm_create -lgsm
4688enabled libhdcd && require_pkg_config libhdcd libhdcd "hdcd/hdcd_simple.h" hdcd_new
4689enabled libilbc && require libilbc ilbc.h WebRtcIlbcfix_InitDecode -lilbc
4690enabled libkvazaar && require_pkg_config libkvazaar "kvazaar >= 0.8.1" kvazaar.h kvz_api_get
4691enabled libmfx && require_pkg_config libmfx libmfx "mfx/mfxvideo.h" MFXInit
4692enabled libmp3lame && require "libmp3lame >= 3.98.3" lame/lame.h lame_set_VBR_quality -lmp3lame
4693enabled libnpp && require libnpp npp.h nppGetLibVersion -lnppi -lnppc
4694enabled libopencore_amrnb && require libopencore_amrnb opencore-amrnb/interf_dec.h Decoder_Interface_init -lopencore-amrnb
4695enabled libopencore_amrwb && require libopencore_amrwb opencore-amrwb/dec_if.h D_IF_init -lopencore-amrwb
4696enabled libopencv && require_pkg_config libopencv opencv opencv/cv.h cvCreateImageHeader
4697enabled libopenh264 && require_pkg_config libopenh264 openh264 wels/codec_api.h WelsGetCodecVersion
4698enabled libopenjpeg && { check_lib libopenjpeg openjpeg.h opj_version -lopenjpeg -DOPJ_STATIC ||
4699 require_pkg_config libopenjpeg libopenjpeg1 openjpeg.h opj_version -DOPJ_STATIC; }
4700enabled libopus && require_pkg_config libopus opus opus_multistream.h opus_multistream_decoder_create
4701enabled libpulse && require_pkg_config libpulse libpulse-simple pulse/simple.h pa_simple_new
4702enabled librtmp && require_pkg_config librtmp librtmp librtmp/rtmp.h RTMP_Socket
4703enabled libschroedinger && require_pkg_config libschroedinger schroedinger-1.0 schroedinger/schro.h schro_init
4704enabled libsnappy && require libsnappy snappy-c.h snappy_compress -lsnappy
4705enabled libspeex && require_pkg_config libspeex speex speex/speex.h speex_decoder_init
4706enabled libsrt && require_pkg_config libsrt "srt >= 1.3.0" srt/srt.h srt_socket
4707enabled libtheora && require libtheora theora/theoraenc.h th_info_init -ltheoraenc -ltheoradec -logg
4708enabled libtwolame && require libtwolame twolame.h twolame_init -ltwolame
4709enabled libvo_aacenc && require libvo_aacenc vo-aacenc/voAAC.h voGetAACEncAPI -lvo-aacenc
4710enabled libvo_amrwbenc && require libvo_amrwbenc vo-amrwbenc/enc_if.h E_IF_init -lvo-amrwbenc
4711enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
4712enabled libvpx && require_pkg_config libvpx "vpx >= 1.3.0" vpx/vpx_codec.h vpx_codec_version &&
4713 { enabled libvpx_vp8_decoder &&
4714 check_pkg_config libvpx_vp8_decoder vpx "vpx/vpx_decoder.h vpx/vp8dx.h" vpx_codec_vp8_dx
4715 enabled libvpx_vp8_encoder &&
4716 check_pkg_config libvpx_vp8_encoder vpx "vpx/vpx_encoder.h vpx/vp8cx.h" vpx_codec_vp8_cx
4717 enabled libvpx_vp9_decoder &&
4718 check_pkg_config libvpx_vp9_decoder vpx "vpx/vpx_decoder.h vpx/vp8dx.h" vpx_codec_vp9_dx
4719 enabled libvpx_vp9_encoder &&
4720 check_pkg_config libvpx_vp9_encoder vpx "vpx/vpx_encoder.h vpx/vp8cx.h" vpx_codec_vp9_cx
4721 disabled_all libvpx_vp8_decoder libvpx_vp9_decoder libvpx_vp8_encoder libvpx_vp9_encoder &&
4722 die "libvpx enabled but no supported decoders/encoders found"
4723 }
4724enabled libwavpack && require libwavpack wavpack/wavpack.h WavpackOpenFileOutput -lwavpack
4725enabled libwebp && require_pkg_config libwebp libwebp webp/encode.h WebPGetEncoderVersion
4726enabled libx264 && require_pkg_config libx264 x264 "stdint.h x264.h" x264_encoder_encode &&
4727 require_cpp_condition libx264 x264.h "X264_BUILD >= 118" &&
4728 check_cpp_condition libx262 x264.h "X264_MPEG2"
4729enabled libx265 && require_pkg_config libx265 x265 x265.h x265_api_get &&
4730 require_cpp_condition libx265 x265.h "X265_BUILD >= 57"
4731enabled libxavs && require libxavs "stdint.h xavs.h" xavs_encoder_encode -lxavs
4732enabled libxvid && require libxvid xvid.h xvid_global -lxvidcore
4733enabled mbedtls && require mbedtls mbedtls/ssl.h mbedtls_ssl_init -lmbedtls -lmbedcrypto -lmbedx509
4734enabled mmal && { check_lib mmal interface/mmal/mmal.h mmal_port_connect -lmmal_core -lmmal_util -lmmal_vc_client -lbcm_host ||
4735 { ! enabled cross_compile &&
4736 add_cflags -isystem/opt/vc/include/ -isystem/opt/vc/include/interface/vmcs_host/linux -isystem/opt/vc/include/interface/vcos/pthreads -fgnu89-inline &&
4737 add_ldflags -L/opt/vc/lib/ &&
4738 check_lib mmal interface/mmal/mmal.h mmal_port_connect -lmmal_core -lmmal_util -lmmal_vc_client -lbcm_host; } ||
4739 die "ERROR: mmal not found" &&
4740 check_func_headers interface/mmal/mmal.h "MMAL_PARAMETER_VIDEO_MAX_NUM_CALLBACKS"; }
4741enabled nvenc && require_cpp_condition nvenc nvEncodeAPI.h "NVENCAPI_MAJOR_VERSION >= 6"
4742enabled omx && require_headers OMX_Core.h
4743enabled omx_rpi && { check_headers OMX_Core.h ||
4744 { ! enabled cross_compile && add_cflags -isystem/opt/vc/include/IL && check_headers OMX_Core.h ; } ||
4745 die "ERROR: OpenMAX IL headers not found"; } && enable omx
4746enabled openssl && { { check_pkg_config openssl openssl openssl/ssl.h OPENSSL_init_ssl ||
4747 check_pkg_config openssl openssl openssl/ssl.h SSL_library_init; } ||
4748 check_lib openssl openssl/ssl.h SSL_library_init -lssl -lcrypto ||
4749 check_lib openssl openssl/ssl.h SSL_library_init -lssl32 -leay32 ||
4750 check_lib openssl openssl/ssl.h SSL_library_init -lssl -lcrypto -lws2_32 -lgdi32 ||
4751 die "ERROR: openssl not found"; }
4752
4753# SDL adds some CFLAGS that should not be part of the general CFLAGS.
4754enabled avplay &&
4755 test_pkg_config sdl "sdl >= 1.2.1 sdl < 1.3.0" SDL_events.h SDL_PollEvent
4756
4757check_headers linux/fb.h
4758check_headers linux/videodev2.h
4759check_struct linux/videodev2.h "struct v4l2_frmivalenum" discrete
4760
4761check_headers AVFoundation/AVFoundation.h
4762
4763check_headers sys/videoio.h
4764
4765check_lib user32 "windows.h winuser.h" GetShellWindow -luser32
4766check_lib vfw32 "windows.h vfw.h" capCreateCaptureWindow -lvfw32
4767# check that WM_CAP_DRIVER_CONNECT is defined to the proper value
4768# w32api 3.12 had it defined wrong
4769check_cpp_condition vfwcap_defines vfw.h "WM_CAP_DRIVER_CONNECT > WM_USER"
4770
4771# check for ioctl_meteor.h, ioctl_bt848.h and alternatives
4772check_headers "dev/bktr/ioctl_meteor.h dev/bktr/ioctl_bt848.h" ||
4773 check_headers "machine/ioctl_meteor.h machine/ioctl_bt848.h" ||
4774 check_headers "dev/video/meteor/ioctl_meteor.h dev/video/bktr/ioctl_bt848.h" ||
4775 check_headers "dev/ic/bt8xx.h"
4776
4777check_headers sys/soundcard.h
4778
4779enabled alsa_indev &&
4780 check_lib alsa alsa/asoundlib.h snd_pcm_htimestamp -lasound
4781
4782enabled libjack &&
4783 require_pkg_config libjack jack jack/jack.h jack_port_get_latency_range
4784
4785enabled sndio_indev && check_lib sndio sndio.h sio_open -lsndio
4786
4787if enabled libcdio; then
4788 check_lib libcdio "cdio/cdda.h cdio/paranoia.h" cdio_cddap_open -lcdio_paranoia -lcdio_cdda -lcdio ||
4789 check_lib libcdio "cdio/paranoia/cdda.h cdio/paranoia/paranoia.h" cdio_cddap_open -lcdio_paranoia -lcdio_cdda -lcdio ||
4790 die "ERROR: No usable libcdio/cdparanoia found"
4791fi
4792
4793if enabled libxcb; then
4794 require_pkg_config libxcb xcb xcb/xcb.h xcb_connect
4795 require_pkg_config libxcb_shape xcb-shape xcb/shape.h xcb_shape_rectangles
4796 disabled libxcb_shm ||
4797 check_pkg_config libxcb_shm xcb-shm xcb/shm.h xcb_shm_attach
4798 disabled libxcb_xfixes ||
4799 check_pkg_config libxcb_xfixes xcb-xfixes xcb/xfixes.h xcb_xfixes_get_cursor_image
4800fi
4801
4802# d3d11va requires linking directly to dxgi and d3d11 if not building for
4803# the desktop api partition
4804test_cpp <<EOF && enable uwp && d3d11va_extralibs="-ldxgi -ld3d11"
4805#ifdef WINAPI_FAMILY
4806#include <winapifamily.h>
4807#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
4808#error desktop, not uwp
4809#else
4810// WINAPI_FAMILY_APP, WINAPI_FAMILY_PHONE_APP => UWP
4811#endif
4812#else
4813#error no family set
4814#endif
4815EOF
4816
4817enabled vaapi && require vaapi va/va.h vaInitialize -lva
4818
4819if enabled vaapi; then
4820 require_cc vaapi "va/va.h" "vaCreateSurfaces(0, 0, 0, 0, 0, 0, 0, 0)"
4821 check_lib vaapi_drm "va/va.h va/va_drm.h" vaGetDisplayDRM -lva -lva-drm
4822 check_lib vaapi_x11 "va/va.h va/va_x11.h" vaGetDisplay -lva -lva-x11 -lX11
4823fi
4824
4825enabled vaapi &&
4826 test_cpp_condition "va/va.h" "VA_CHECK_VERSION(1, 0, 0)" &&
4827 enable vaapi_1
4828
4829enabled vdpau &&
4830 check_cpp_condition vdpau vdpau/vdpau.h "defined VDP_DECODER_PROFILE_MPEG4_PART2_ASP"
4831
4832enabled vdpau &&
4833 check_lib vdpau_x11 "vdpau/vdpau.h vdpau/vdpau_x11.h" vdp_device_create_x11 -lvdpau -lX11
4834
4835enabled debug && add_cflags -g"$debuglevel" && add_asflags -g"$debuglevel"
4836
4837# add some useful compiler flags if supported
4838check_cflags -Wdeclaration-after-statement
4839check_cflags -Wall
4840check_cflags -Wdisabled-optimization
4841check_cflags -Wpointer-arith
4842check_cflags -Wredundant-decls
4843check_cflags -Wwrite-strings
4844check_cflags -Wtype-limits
4845check_cflags -Wundef
4846check_cflags -Wmissing-prototypes
4847check_cflags -Wstrict-prototypes
4848
4849if enabled extra_warnings; then
4850 check_cflags -Wcast-qual
4851 check_cflags -Wextra
4852 check_cflags -Wpedantic
4853fi
4854
4855check_disable_warning(){
4856 warning_flag=-W${1#-Wno-}
4857 test_cflags $warning_flag && add_cflags $1
4858}
4859
4860check_disable_warning -Wno-parentheses
4861check_disable_warning -Wno-switch
4862check_disable_warning -Wno-format-zero-length
4863check_disable_warning -Wno-pointer-sign
4864
4865check_disable_warning_headers(){
4866 warning_flag=-W${1#-Wno-}
4867 test_cflags $warning_flag && add_cflags_headers $1
4868}
4869
4870check_disable_warning_headers -Wno-deprecated-declarations
4871check_disable_warning_headers -Wno-unused-variable
4872
4873check_objcflags -fobjc-arc && enable objc_arc
4874
4875test_cc <<EOF && enable blocks_extension
4876void (^block)(void);
4877EOF
4878
4879# add some linker flags
4880check_ldflags -Wl,--warn-common
4881check_ldflags -Wl,-rpath-link=libswscale:libavfilter:libavdevice:libavformat:libavcodec:libavutil:libavresample
4882enabled rpath && add_ldexeflags -Wl,-rpath,$libdir && add_ldsoflags -Wl,-rpath,$libdir
4883test_ldflags -Wl,-Bsymbolic && append SHFLAGS -Wl,-Bsymbolic
4884
4885# add some strip flags
4886# -wN '..@*' is more selective than -x, but not available everywhere.
4887check_stripflags -wN \'..@*\' || check_stripflags -x || strip='true'
4888
4889enabled neon_clobber_test &&
4890 check_ldflags -Wl,--wrap,avcodec_open2 \
4891 -Wl,--wrap,avcodec_decode_audio4 \
4892 -Wl,--wrap,avcodec_decode_video2 \
4893 -Wl,--wrap,avcodec_decode_subtitle2 \
4894 -Wl,--wrap,avcodec_encode_audio2 \
4895 -Wl,--wrap,avcodec_encode_video2 \
4896 -Wl,--wrap,avcodec_encode_subtitle \
4897 -Wl,--wrap,avcodec_send_packet \
4898 -Wl,--wrap,avcodec_receive_packet \
4899 -Wl,--wrap,avcodec_send_frame \
4900 -Wl,--wrap,avcodec_receive_frame \
4901 -Wl,--wrap,avresample_convert ||
4902 disable neon_clobber_test
4903
4904enabled xmm_clobber_test &&
4905 check_ldflags -Wl,--wrap,avcodec_open2 \
4906 -Wl,--wrap,avcodec_decode_audio4 \
4907 -Wl,--wrap,avcodec_decode_video2 \
4908 -Wl,--wrap,avcodec_decode_subtitle2 \
4909 -Wl,--wrap,avcodec_encode_audio2 \
4910 -Wl,--wrap,avcodec_encode_video2 \
4911 -Wl,--wrap,avcodec_encode_subtitle \
4912 -Wl,--wrap,avcodec_send_packet \
4913 -Wl,--wrap,avcodec_receive_packet \
4914 -Wl,--wrap,avcodec_send_frame \
4915 -Wl,--wrap,avcodec_receive_frame \
4916 -Wl,--wrap,avresample_convert \
4917 -Wl,--wrap,sws_scale ||
4918 disable xmm_clobber_test
4919
4920check_ld proper_dce <<EOF
4921extern const int array[512];
4922static inline int func(void) { return array[0]; }
4923int main(void) { return 0; }
4924EOF
4925
4926if enabled proper_dce; then
4927 echo "X { local: *; };" > $TMPV
4928 if test_ldflags -Wl,${version_script},$TMPV; then
4929 append SHFLAGS '-Wl,${version_script},\$(SUBDIR)lib\$(NAME).ver'
4930 quotes='""'
4931 test_cc <<EOF && enable symver_asm_label
4932void ff_foo(void) __asm__ ("av_foo@VERSION");
4933void ff_foo(void) { ${inline_asm+__asm__($quotes);} }
4934EOF
4935 test_cc <<EOF && enable symver_gnu_asm
4936__asm__(".symver ff_foo,av_foo@VERSION");
4937void ff_foo(void) {}
4938EOF
4939 fi
4940fi
4941
4942if [ -z "$optflags" ]; then
4943 if enabled small; then
4944 optflags=$cflags_size
4945 elif enabled optimizations; then
4946 optflags=$cflags_speed
4947 else
4948 optflags=$cflags_noopt
4949 fi
4950fi
4951
4952check_optflags(){
4953 check_cflags "$@"
4954 enabled lto && check_ldflags "$@"
4955}
4956
4957check_optflags $optflags
4958check_optflags -fno-math-errno
4959check_optflags -fno-signed-zeros
4960
4961if enabled lto; then
4962 test "$cc_type" != "$ld_type" && die "LTO requires same compiler and linker"
4963 check_cflags -flto
4964 check_ldflags -flto $cpuflags
4965fi
4966
4967if enabled icc; then
4968 # Just warnings, no remarks
4969 check_cflags -w1
4970 # -wd: Disable following warnings
4971 # 144, 167, 556: -Wno-pointer-sign
4972 # 1292: attribute "foo" ignored
4973 # 1419: external declaration in primary source file
4974 # 10006: ignoring unknown option -fno-signed-zeros
4975 # 10148: ignoring unknown option -Wno-parentheses
4976 # 10156: ignoring option '-W'; no argument required
4977 check_cflags -wd144,167,556,1292,1419,10006,10148,10156
4978 # 11030: Warning unknown option --as-needed
4979 # 10156: ignoring option '-export'; no argument required
4980 check_ldflags -wd10156,11030
4981 # icc 11.0 and 11.1 work with ebp_available, but don't pass the test
4982 enable ebp_available
4983 if enabled x86_32; then
4984 icc_version=$($cc -dumpversion)
4985 test ${icc_version%%.*} -ge 11 &&
4986 check_cflags -falign-stack=maintain-16-byte ||
4987 disable aligned_stack
4988 fi
4989elif enabled gcc; then
4990 check_optflags -fno-tree-vectorize
4991 check_cflags -Werror=implicit-function-declaration
4992 check_cflags -Werror=missing-prototypes
4993 check_cflags -Werror=return-type
4994 check_cflags -Werror=declaration-after-statement
4995 check_cflags -Werror=vla
4996 check_cflags -Werror=format-security
4997 check_cflags -fdiagnostics-color=auto
4998 enabled extra_warnings || check_disable_warning -Wno-maybe-uninitialized
4999 if enabled x86_32; then
5000 case $target_os in
5001 *bsd*)
5002 # BSDs don't guarantee a 16 byte aligned stack, but we can
5003 # request GCC to try to maintain 16 byte alignment throughout
5004 # function calls. Library entry points that might call assembly
5005 # functions align the stack. (The parameter means 2^4 bytes.)
5006 check_cflags -mpreferred-stack-boundary=4
5007 ;;
5008 esac
5009 fi
5010elif enabled llvm_gcc; then
5011 check_cflags -mllvm -stack-alignment=16
5012elif enabled clang; then
5013 if enabled x86_32; then
5014 # Clang doesn't support maintaining alignment without assuming the
5015 # same alignment in every function. If 16 byte alignment would be
5016 # enabled, one would also have to either add attribute_align_arg on
5017 # every single entry point into the libraries or enable -mstackrealign
5018 # (doing stack realignment in every single function).
5019 case $target_os in
5020 mingw32|win32|*bsd*)
5021 disable aligned_stack
5022 ;;
5023 *)
5024 check_cflags -mllvm -stack-alignment=16
5025 ;;
5026 esac
5027 else
5028 check_cflags -mllvm -stack-alignment=16
5029 fi
5030 check_cflags -Qunused-arguments
5031 check_cflags -Werror=implicit-function-declaration
5032 check_cflags -Werror=missing-prototypes
5033 check_cflags -Werror=return-type
5034elif enabled cparser; then
5035 add_cflags -Wno-missing-variable-declarations
5036 add_cflags -Wno-empty-statement
5037elif enabled armcc; then
5038 add_cflags -W${armcc_opt},--diag_suppress=4343 # hardfp compat
5039 add_cflags -W${armcc_opt},--diag_suppress=3036 # using . as system include dir
5040 # 2523: use of inline assembly is deprecated
5041 add_cflags -W${armcc_opt},--diag_suppress=2523
5042 add_cflags -W${armcc_opt},--diag_suppress=1207
5043 add_cflags -W${armcc_opt},--diag_suppress=1293 # assignment in condition
5044 add_cflags -W${armcc_opt},--diag_suppress=3343 # hardfp compat
5045 add_cflags -W${armcc_opt},--diag_suppress=167 # pointer sign
5046 add_cflags -W${armcc_opt},--diag_suppress=513 # pointer sign
5047elif enabled pathscale; then
5048 add_cflags -fstrict-overflow -OPT:wrap_around_unsafe_opt=OFF
5049 disable inline_asm
5050elif enabled_any msvc icl; then
5051 enabled x86_32 && disable aligned_stack
5052 enabled_all x86_32 debug && add_cflags -Oy-
5053 enabled debug && add_ldflags -debug
5054 enable pragma_deprecated
5055 if enabled icl; then
5056 # -Qansi-alias is basically -fstrict-aliasing, but does not work
5057 # (correctly) on icl 13.x.
5058 test_cpp_condition "windows.h" "__ICL < 1300 || __ICL >= 1400" &&
5059 add_cflags -Qansi-alias
5060 # icl will pass the inline asm tests but inline asm is currently
5061 # not supported (build will fail)
5062 disable inline_asm
5063 fi
5064 # msvcrt10 x64 incorrectly enables log2, only msvcrt12 (MSVC 2013) onwards actually has log2.
5065 check_cpp_condition log2 crtversion.h "_VC_CRT_MAJOR_VERSION >= 12"
5066 # The CRT headers contain __declspec(restrict) in a few places, but if redefining
5067 # restrict, this might break. MSVC 2010 and 2012 fail with __declspec(__restrict)
5068 # (as it ends up if the restrict redefine is done before including stdlib.h), while
5069 # MSVC 2013 and newer can handle it fine.
5070 # If this declspec fails, force including stdlib.h before the restrict redefinition
5071 # happens in config.h.
5072 if [ $restrict_keyword != restrict ]; then
5073 test_cc <<EOF || add_cflags -FIstdlib.h
5074__declspec($restrict_keyword) void *foo(int);
5075EOF
5076 fi
5077fi
5078
5079for pfx in "" host_; do
5080 varname=${pfx%_}cc_type
5081 eval "type=\$$varname"
5082 if [ "$type" = "msvc" ]; then
5083 test_${pfx}cc <<EOF || add_${pfx}cflags -Dinline=__inline
5084static inline int foo(int a) { return a; }
5085EOF
5086 fi
5087done
5088
5089case $as_type in
5090 clang)
5091 add_asflags -Qunused-arguments
5092 ;;
5093esac
5094
5095case $ld_type in
5096 clang)
5097 check_ldflags -Qunused-arguments
5098 ;;
5099esac
5100
5101enabled asm || { arch=c; disable $ARCH_LIST $ARCH_EXT_LIST; }
5102
5103check_cmd pod2man --help
5104check_cmd texi2html -version
5105
5106check_deps $CONFIG_LIST \
5107 $CONFIG_EXTRA \
5108 $HAVE_LIST \
5109 $ALL_COMPONENTS \
5110
5111flatten_extralibs(){
5112 unset nested_entries
5113 list_name=$1
5114 eval list=\$${1}
5115 for entry in $list; do
5116 entry_copy=$entry
5117 resolve entry_copy
5118 append nested_entries $(filter '*_extralibs' $entry_copy)
5119 flat_entries=$(filter_out '*_extralibs' $entry_copy)
5120 eval $entry="\$flat_entries"
5121 done
5122 append $list_name "$nested_entries"
5123
5124 resolve nested_entries
5125 if test -n "$(filter '*_extralibs' $nested_entries)"; then
5126 flatten_extralibs $list_name
5127 fi
5128}
5129
5130for linkunit in $LIBRARY_LIST; do
5131 unset current_extralibs
5132 eval components=\$$(toupper ${linkunit})_COMPONENTS_LIST
5133 for comp in ${components}; do
5134 enabled $comp || continue
5135 comp_extralibs="${comp}_extralibs"
5136 append current_extralibs $comp_extralibs
5137 done
5138 eval prepend ${linkunit}_extralibs $current_extralibs
5139done
5140
5141for linkunit in $LIBRARY_LIST $PROGRAM_LIST $EXTRALIBS_LIST; do
5142 flatten_extralibs ${linkunit}_extralibs
5143 unique ${linkunit}_extralibs
5144 resolve ${linkunit}_extralibs
5145 eval ${linkunit}_extralibs=\$\(\$ldflags_filter \$${linkunit}_extralibs\)
5146done
5147
5148map 'enabled $v && intrinsics=${v#intrinsics_}' $INTRINSICS_LIST
5149
5150for thread in $THREADS_LIST; do
5151 if enabled $thread; then
5152 test -n "$thread_type" &&
5153 die "ERROR: Only one thread type must be selected." ||
5154 thread_type="$thread"
5155 fi
5156done
5157
5158if disabled stdatomic; then
5159 if enabled atomics_gcc; then
5160 add_cppflags '-I\$(SRC_PATH)/compat/atomics/gcc'
5161 elif enabled atomics_win32; then
5162 add_cppflags '-I\$(SRC_PATH)/compat/atomics/win32'
5163 elif enabled atomics_suncc; then
5164 add_cppflags '-I\$(SRC_PATH)/compat/atomics/suncc'
5165 elif enabled pthreads; then
5166 add_compat atomics/pthread/stdatomic.o
5167 add_cppflags '-I\$(SRC_PATH)/compat/atomics/pthread'
5168 else
5169 enabled threads && die "Threading is enabled, but no atomics are available"
5170 add_cppflags '-I\$(SRC_PATH)/compat/atomics/dummy'
5171 fi
5172fi
5173
5174enabled zlib && add_cppflags -DZLIB_CONST
5175
5176# conditional library dependencies, in linking order
5177enabled movie_filter && prepend avfilter_deps "avformat avcodec"
5178enabled_any asyncts_filter resample_filter &&
5179 prepend avfilter_deps "avresample"
5180enabled scale_filter && prepend avfilter_deps "swscale"
5181
5182enabled opus_decoder && prepend avcodec_deps "avresample"
5183
5184expand_deps(){
5185 lib_deps=${1}_deps
5186 eval "deps=\$$lib_deps"
5187 append $lib_deps $(map 'eval echo \$${v}_deps' $deps)
5188 unique $lib_deps
5189}
5190
5191map 'expand_deps $v' $LIBRARY_LIST
5192
5193if test "$quiet" != "yes"; then
5194
5195echo "install prefix $prefix"
5196echo "source path $source_path"
5197echo "C compiler $cc"
5198echo "C library $libc_type"
5199if test "$host_cc" != "$cc"; then
5200 echo "host C compiler $host_cc"
5201 echo "host C library $host_libc_type"
5202fi
5203echo "ARCH $arch ($cpu)"
5204if test "$extra_version" != ""; then
5205 echo "version string suffix $extra_version"
5206fi
5207echo "big-endian ${bigendian-no}"
5208echo "runtime cpu detection ${runtime_cpudetect-no}"
5209if enabled x86; then
5210 echo "standalone assembly ${x86asm-no}"
5211 echo "x86 assembler ${x86asmexe}"
5212 echo "MMX enabled ${mmx-no}"
5213 echo "MMXEXT enabled ${mmxext-no}"
5214 echo "3DNow! enabled ${amd3dnow-no}"
5215 echo "3DNow! extended enabled ${amd3dnowext-no}"
5216 echo "SSE enabled ${sse-no}"
5217 echo "SSSE3 enabled ${ssse3-no}"
5218 echo "AVX enabled ${avx-no}"
5219 echo "XOP enabled ${xop-no}"
5220 echo "FMA3 enabled ${fma3-no}"
5221 echo "FMA4 enabled ${fma4-no}"
5222 echo "i686 features enabled ${i686-no}"
5223 echo "CMOV is fast ${fast_cmov-no}"
5224 echo "EBX available ${ebx_available-no}"
5225 echo "EBP available ${ebp_available-no}"
5226fi
5227if enabled aarch64; then
5228 echo "NEON enabled ${neon-no}"
5229 echo "VFP enabled ${vfp-no}"
5230fi
5231if enabled arm; then
5232 echo "ARMv5TE enabled ${armv5te-no}"
5233 echo "ARMv6 enabled ${armv6-no}"
5234 echo "ARMv6T2 enabled ${armv6t2-no}"
5235 echo "VFP enabled ${vfp-no}"
5236 echo "NEON enabled ${neon-no}"
5237fi
5238if enabled ppc; then
5239 echo "AltiVec enabled ${altivec-no}"
5240 echo "VSX enabled ${vsx-no}"
5241 echo "POWER8 enabled ${power8-no}"
5242 echo "PPC 4xx optimizations ${ppc4xx-no}"
5243 echo "dcbzl available ${dcbzl-no}"
5244fi
5245echo "debug symbols ${debug-no}"
5246echo "optimize for size ${small-no}"
5247echo "optimizations ${optimizations-no}"
5248echo "static ${static-no}"
5249echo "shared ${shared-no}"
5250echo "network support ${network-no}"
5251echo "threading support ${thread_type-no}"
5252echo "safe bitstream reader ${safe_bitstream_reader-no}"
5253
5254echo "External libraries:"
5255print_enabled '' $EXTERNAL_LIBRARY_LIST | print_3_columns
5256echo
5257echo "External libraries providing hardware acceleration:"
5258print_enabled '' $HWACCEL_LIBRARY_LIST | print_3_columns
5259echo
5260
5261echo "Libraries:"
5262print_enabled '' $LIBRARY_LIST | print_3_columns
5263echo
5264
5265echo "Programs:"
5266print_enabled '' $PROGRAM_LIST | print_3_columns
5267echo
5268
5269for type in decoder encoder hwaccel parser demuxer muxer protocol filter bsf indev; do
5270 echo "Enabled ${type}s:"
5271 eval list=\$$(toupper $type)_LIST
5272 print_enabled '_*' $list | print_3_columns
5273 echo
5274done
5275
5276if test -n "$ignore_tests"; then
5277 ignore_tests=$(echo $ignore_tests | tr ',' ' ')
5278 echo "Ignored FATE tests:"
5279 echo $ignore_tests | print_3_columns
5280 echo
5281fi
5282
5283echo "License: $license"
5284
5285fi # test "$quiet" != "yes"
5286
5287test -n "$WARNINGS" && printf "\n$WARNINGS"
5288
5289test -e Makefile || echo "include $source_path/Makefile" > Makefile
5290
5291esc(){
5292 echo "$*" | sed 's/%/%25/g;s/:/%3a/g'
5293}
5294
5295echo "config:$arch:$subarch:$cpu:$target_os:$(esc $cc_ident):$(esc $LIBAV_CONFIGURATION)" > avbuild/config.fate
5296
5297config_files="$TMPH avbuild/config.mak"
5298
5299cat > avbuild/config.mak <<EOF
5300# Automatically generated by configure - do not modify!
5301LIBAV_CONFIGURATION=$LIBAV_CONFIGURATION
5302prefix=$prefix
5303LIBDIR=\$(DESTDIR)$libdir
5304SHLIBDIR=\$(DESTDIR)$shlibdir
5305INCDIR=\$(DESTDIR)$incdir
5306BINDIR=\$(DESTDIR)$bindir
5307DATADIR=\$(DESTDIR)$datadir
5308DOCDIR=\$(DESTDIR)$docdir
5309MANDIR=\$(DESTDIR)$mandir
5310SRC_PATH=$source_path
5311CC_IDENT=$cc_ident
5312ARCH=$arch
5313INTRINSICS=$intrinsics
5314EXTERN_PREFIX=$extern_prefix
5315CC=$cc
5316AS=$as
5317OBJCC=$objcc
5318LD=$ld
5319DEPCC=$dep_cc
5320DEPCCFLAGS=$DEPCCFLAGS \$(CPPFLAGS)
5321DEPAS=$as
5322DEPASFLAGS=$DEPASFLAGS \$(CPPFLAGS)
5323X86ASM=$x86asmexe
5324DEPX86ASM=$x86asmexe
5325DEPX86ASMFLAGS=\$(X86ASMFLAGS)
5326AR=$ar
5327ARFLAGS=$arflags
5328AR_O=$ar_o
5329AR_CMD=$ar
5330NM_CMD=$nm
5331RANLIB=$ranlib
5332STRIP=$strip
5333LN_S=$ln_s
5334CPPFLAGS=$CPPFLAGS
5335CFLAGS=$CFLAGS
5336OBJCFLAGS=$OBJCFLAGS
5337ASFLAGS=$ASFLAGS
5338AS_C=$AS_C
5339AS_O=$AS_O
5340OBJCC_C=$OBJCC_C
5341OBJCC_E=$OBJCC_E
5342OBJCC_O=$OBJCC_O
5343CC_C=$CC_C
5344CC_E=$CC_E
5345CC_O=$CC_O
5346X86ASM_O=$X86ASM_O
5347LD_O=$LD_O
5348LD_LIB=$LD_LIB
5349LD_PATH=$LD_PATH
5350DLLTOOL=$dlltool
5351LDFLAGS=$LDFLAGS
5352LDEXEFLAGS=$LDEXEFLAGS
5353LDSOFLAGS=$LDSOFLAGS
5354SHFLAGS=$(echo $($ldflags_filter $SHFLAGS))
5355STRIPFLAGS=$STRIPFLAGS
5356X86ASMFLAGS=$X86ASMFLAGS
5357LIBPREF=$LIBPREF
5358LIBSUF=$LIBSUF
5359LIBNAME=$LIBNAME
5360SLIBPREF=$SLIBPREF
5361SLIBSUF=$SLIBSUF
5362EXESUF=$EXESUF
5363EXTRA_VERSION=$extra_version
5364CCDEP=$CCDEP
5365CCDEP_FLAGS=$CCDEP_FLAGS
5366ASDEP=$ASDEP
5367ASDEP_FLAGS=$ASDEP_FLAGS
5368X86ASMDEP=$X86ASMDEP
5369X86ASMDEP_FLAGS=$X86ASMDEP_FLAGS
5370CC_DEPFLAGS=$CC_DEPFLAGS
5371AS_DEPFLAGS=$AS_DEPFLAGS
5372X86ASM_DEPFLAGS=$X86ASM_DEPFLAGS
5373HOSTCC=$host_cc
5374HOSTLD=$host_ld
5375HOSTCFLAGS=$host_cflags
5376HOSTCPPFLAGS=$host_cppflags
5377HOSTEXESUF=$HOSTEXESUF
5378HOSTLDFLAGS=$host_ldflags
5379HOSTEXTRALIBS=$host_extralibs
5380DEPHOSTCC=$host_cc
5381DEPHOSTCCFLAGS=$DEPHOSTCCFLAGS \$(HOSTCCFLAGS)
5382HOSTCCDEP=$HOSTCCDEP
5383HOSTCCDEP_FLAGS=$HOSTCCDEP_FLAGS
5384HOSTCC_DEPFLAGS=$HOSTCC_DEPFLAGS
5385HOSTCC_C=$HOSTCC_C
5386HOSTCC_O=$HOSTCC_O
5387HOSTLD_O=$HOSTLD_O
5388TARGET_EXEC=$target_exec $target_exec_args
5389TARGET_PATH=$target_path
5390TARGET_SAMPLES=${target_samples:-\$(SAMPLES)}
5391CFLAGS-avplay=$sdl_cflags
5392CFLAGS_HEADERS=$CFLAGS_HEADERS
5393LIB_INSTALL_EXTRA_CMD=$LIB_INSTALL_EXTRA_CMD
5394EXTRALIBS=$extralibs
5395COMPAT_OBJS=$compat_objs
5396INSTALL=install
5397LIBTARGET=${LIBTARGET}
5398SLIBNAME=${SLIBNAME}
5399SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}
5400SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}
5401SLIB_CREATE_DEF_CMD=${SLIB_CREATE_DEF_CMD}
5402SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}
5403SLIB_INSTALL_NAME=${SLIB_INSTALL_NAME}
5404SLIB_INSTALL_LINKS=${SLIB_INSTALL_LINKS}
5405SLIB_INSTALL_EXTRA_LIB=${SLIB_INSTALL_EXTRA_LIB}
5406SLIB_INSTALL_EXTRA_SHLIB=${SLIB_INSTALL_EXTRA_SHLIB}
5407VERSION_SCRIPT_POSTPROCESS_CMD=${VERSION_SCRIPT_POSTPROCESS_CMD}
5408SAMPLES:=${samples:-\$(LIBAV_SAMPLES)}
5409IGNORE_TESTS=$ignore_tests
5410EOF
5411
5412map 'eval echo "${v}_FFLIBS=\$${v}_deps" >> avbuild/config.mak' $LIBRARY_LIST
5413
5414for entry in $LIBRARY_LIST $PROGRAM_LIST $EXTRALIBS_LIST; do
5415 eval echo "EXTRALIBS-${entry}=\$${entry}_extralibs" >> avbuild/config.mak
5416done
5417
5418cat > $TMPH <<EOF
5419/* Automatically generated by configure - do not modify! */
5420#ifndef LIBAV_CONFIG_H
5421#define LIBAV_CONFIG_H
5422#define LIBAV_CONFIGURATION "$(c_escape $LIBAV_CONFIGURATION)"
5423#define LIBAV_LICENSE "$(c_escape $license)"
5424#define AVCONV_DATADIR "$(eval c_escape $datadir)"
5425#define CC_IDENT "$(c_escape ${cc_ident:-Unknown compiler})"
5426#define EXTERN_PREFIX "${extern_prefix}"
5427#define EXTERN_ASM ${extern_prefix}
5428#define SLIBSUF "$SLIBSUF"
5429EOF
5430
5431test $restrict_keyword != restrict &&
5432 echo "#define restrict $restrict_keyword" >> $TMPH
5433
5434test -n "$malloc_prefix" &&
5435 echo "#define MALLOC_PREFIX $malloc_prefix" >>$TMPH
5436
5437if enabled x86asm; then
5438 append config_files $TMPASM
5439 cat > $TMPASM <<EOF
5440; Automatically generated by configure - do not modify!
5441EOF
5442fi
5443
5444enabled getenv || echo "#define getenv(x) NULL" >> $TMPH
5445
5446print_config ARCH_ "$config_files" $ARCH_LIST
5447print_config HAVE_ "$config_files" $HAVE_LIST
5448print_config CONFIG_ "$config_files" $CONFIG_LIST \
5449 $CONFIG_EXTRA \
5450 $ALL_COMPONENTS \
5451
5452echo "#endif /* LIBAV_CONFIG_H */" >> $TMPH
5453
5454# Do not overwrite an unchanged config.h to avoid superfluous rebuilds.
5455cp_if_changed $TMPH config.h
5456touch avbuild/.config
5457
5458enabled x86asm && cp_if_changed $TMPASM config.asm
5459
5460cat > $TMPH <<EOF
5461/* Generated by libav configure */
5462#ifndef AVUTIL_AVCONFIG_H
5463#define AVUTIL_AVCONFIG_H
5464EOF
5465
5466print_config AV_HAVE_ $TMPH $HAVE_LIST_PUB
5467
5468echo "#endif /* AVUTIL_AVCONFIG_H */" >> $TMPH
5469
5470cp_if_changed $TMPH libavutil/avconfig.h
5471
5472# generate the lists of enabled components
5473print_enabled_components(){
5474 file=$1
5475 struct_name=$2
5476 name=$3
5477 shift 3
5478 echo "static const $struct_name * const $name[] = {" > $TMPH
5479 for c in $*; do
5480 enabled $c && printf " &ff_%s,\n" $c >> $TMPH
5481 done
5482 echo " NULL };" >> $TMPH
5483 cp_if_changed $TMPH $file
5484}
5485
5486print_enabled_components libavcodec/bsf_list.c AVBitStreamFilter bitstream_filters $BSF_LIST
5487print_enabled_components libavformat/protocol_list.c URLProtocol url_protocols $PROTOCOL_LIST
5488
5489# Settings for pkg-config files
5490
5491cat > $TMPH <<EOF
5492# Automatically generated by configure - do not modify!
5493shared=$shared
5494prefix=$prefix
5495libdir=$libdir
5496incdir=$incdir
5497source_path=${source_path}
5498LIBPREF=${LIBPREF}
5499LIBSUF=${LIBSUF}
5500extralibs_avutil="$avutil_extralibs"
5501extralibs_avcodec="$avcodec_extralibs"
5502extralibs_avformat="$avformat_extralibs"
5503extralibs_avdevice="$avdevice_extralibs"
5504extralibs_avfilter="$avfilter_extralibs"
5505extralibs_avresample="$avresample_extralibs"
5506extralibs_swscale="$swscale_extralibs"
5507EOF
5508
5509for lib in $LIBRARY_LIST; do
5510 lib_deps="$(eval echo \$${lib}_deps)"
5511 echo ${lib}_deps=\"$lib_deps\" >> $TMPH
5512done
5513
5514cp_if_changed $TMPH avbuild/config.sh