lavc: add libdcadec decoder
[libav.git] / configure
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.
11 LC_ALL=C
12 export LC_ALL
13
14 # make sure we are running under a compatible shell
15 # try to make this part work with most shells
16
17 try_exec(){
18 echo "Trying shell $1"
19 type "$1" > /dev/null 2>&1 && exec "$@"
20 }
21
22 unset foo
23 (: ${foo%%bar}) 2> /dev/null
24 E1="$?"
25
26 (: ${foo?}) 2> /dev/null
27 E2="$?"
28
29 if test "$E1" != 0 || test "$E2" = 0; then
30 echo "Broken shell detected. Trying alternatives."
31 export FF_CONF_EXEC
32 if test "0$FF_CONF_EXEC" -lt 1; then
33 FF_CONF_EXEC=1
34 try_exec bash "$0" "$@"
35 fi
36 if test "0$FF_CONF_EXEC" -lt 2; then
37 FF_CONF_EXEC=2
38 try_exec ksh "$0" "$@"
39 fi
40 if test "0$FF_CONF_EXEC" -lt 3; then
41 FF_CONF_EXEC=3
42 try_exec /usr/xpg4/bin/sh "$0" "$@"
43 fi
44 echo "No compatible shell script interpreter found."
45 echo "This configure script requires a POSIX-compatible shell"
46 echo "such as bash or ksh."
47 echo "THIS IS NOT A BUG IN 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
55 fi
56
57 test -d /usr/xpg4/bin && PATH=/usr/xpg4/bin:$PATH
58
59 show_help(){
60 cat <<EOF
61 Usage: configure [options]
62 Options: [defaults in brackets after descriptions]
63
64 Help options:
65 --help print this message
66 --list-decoders show all available decoders
67 --list-encoders show all available encoders
68 --list-hwaccels show all available hardware accelerators
69 --list-demuxers show all available demuxers
70 --list-muxers show all available muxers
71 --list-parsers show all available parsers
72 --list-protocols show all available protocols
73 --list-bsfs show all available bitstream filters
74 --list-indevs show all available input devices
75 --list-outdevs show all available output devices
76 --list-filters show all available filters
77
78 Standard options:
79 --logfile=FILE log tests and output to FILE [config.log]
80 --disable-logging do not log configure debug information
81 --prefix=PREFIX install in PREFIX [$prefix]
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
91 Licensing 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
98 Configuration 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
107 Program 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 --disable-avserver deprecated, does nothing
113
114 Component options:
115 --disable-doc do not build documentation
116 --disable-avdevice disable libavdevice build
117 --disable-avcodec disable libavcodec build
118 --disable-avformat disable libavformat build
119 --disable-avutil disable libavutil build
120 --disable-swscale disable libswscale build
121 --disable-avfilter disable video filter support [no]
122 --disable-avresample disable libavresample build [no]
123 --disable-pthreads disable pthreads [auto]
124 --disable-w32threads disable Win32 threads [auto]
125 --disable-network disable network support [no]
126 --disable-dct disable DCT code
127 --disable-error-resilience disable error resilience code
128 --disable-lsp disable LSP code
129 --disable-lzo disable LZO decoder code
130 --disable-mdct disable MDCT code
131 --disable-rdft disable RDFT code
132 --disable-fft disable FFT code
133 --disable-faan disable floating point AAN (I)DCT code
134
135 Hardware accelerators:
136 --enable-dxva2 enable DXVA2 code
137 --enable-vaapi enable VAAPI code
138 --enable-vda enable VDA code
139 --enable-vdpau enable VDPAU code
140
141 Individual component options:
142 --disable-everything disable all components listed below
143 --disable-encoder=NAME disable encoder NAME
144 --enable-encoder=NAME enable encoder NAME
145 --disable-encoders disable all encoders
146 --disable-decoder=NAME disable decoder NAME
147 --enable-decoder=NAME enable decoder NAME
148 --disable-decoders disable all decoders
149 --disable-hwaccel=NAME disable hwaccel NAME
150 --enable-hwaccel=NAME enable hwaccel NAME
151 --disable-hwaccels disable all hwaccels
152 --disable-muxer=NAME disable muxer NAME
153 --enable-muxer=NAME enable muxer NAME
154 --disable-muxers disable all muxers
155 --disable-demuxer=NAME disable demuxer NAME
156 --enable-demuxer=NAME enable demuxer NAME
157 --disable-demuxers disable all demuxers
158 --enable-parser=NAME enable parser NAME
159 --disable-parser=NAME disable parser NAME
160 --disable-parsers disable all parsers
161 --enable-bsf=NAME enable bitstream filter NAME
162 --disable-bsf=NAME disable bitstream filter NAME
163 --disable-bsfs disable all bitstream filters
164 --enable-protocol=NAME enable protocol NAME
165 --disable-protocol=NAME disable protocol NAME
166 --disable-protocols disable all protocols
167 --enable-indev=NAME enable input device NAME
168 --disable-indev=NAME disable input device NAME
169 --disable-indevs disable input devices
170 --enable-outdev=NAME enable output device NAME
171 --disable-outdev=NAME disable output device NAME
172 --disable-outdevs disable output devices
173 --disable-devices disable all devices
174 --enable-filter=NAME enable filter NAME
175 --disable-filter=NAME disable filter NAME
176 --disable-filters disable all filters
177
178 External library support:
179 --enable-avisynth enable reading of AviSynth script files [no]
180 --enable-bzlib enable bzlib [autodetect]
181 --enable-frei0r enable frei0r video filtering
182 --enable-gnutls enable gnutls [no]
183 --enable-libbs2b enable bs2b DSP library [no]
184 --enable-libcdio enable audio CD grabbing with libcdio
185 --enable-libdc1394 enable IIDC-1394 grabbing using libdc1394
186 and libraw1394 [no]
187 --enable-libdcadec enable DCA decoding via libdcadec [no]
188 --enable-libfaac enable AAC encoding via libfaac [no]
189 --enable-libfdk-aac enable AAC de/encoding via libfdk-aac [no]
190 --enable-libfreetype enable libfreetype [no]
191 --enable-libgsm enable GSM de/encoding via libgsm [no]
192 --enable-libilbc enable iLBC de/encoding via libilbc [no]
193 --enable-libmfx enable HW acceleration through libmfx
194 --enable-libmp3lame enable MP3 encoding via libmp3lame [no]
195 --enable-libopencore-amrnb enable AMR-NB de/encoding via libopencore-amrnb [no]
196 --enable-libopencore-amrwb enable AMR-WB decoding via libopencore-amrwb [no]
197 --enable-libopencv enable video filtering via libopencv [no]
198 --enable-libopenh264 enable H.264 encoding via OpenH264 [no]
199 --enable-libopenjpeg enable JPEG 2000 de/encoding via OpenJPEG [no]
200 --enable-libopus enable Opus de/encoding via libopus [no]
201 --enable-libpulse enable Pulseaudio input via libpulse [no]
202 --enable-librtmp enable RTMP[E] support via librtmp [no]
203 --enable-libschroedinger enable Dirac de/encoding via libschroedinger [no]
204 --enable-libspeex enable Speex de/encoding via libspeex [no]
205 --enable-libtheora enable Theora encoding via libtheora [no]
206 --enable-libtwolame enable MP2 encoding via libtwolame [no]
207 --enable-libvo-aacenc enable AAC encoding via libvo-aacenc [no]
208 --enable-libvo-amrwbenc enable AMR-WB encoding via libvo-amrwbenc [no]
209 --enable-libvorbis enable Vorbis encoding via libvorbis [no]
210 --enable-libvpx enable VP8 and VP9 de/encoding via libvpx [no]
211 --enable-libwavpack enable wavpack encoding via libwavpack [no]
212 --enable-libwebp enable WebP encoding via libwebp [no]
213 --enable-libx264 enable H.264 encoding via x264 [no]
214 --enable-libx265 enable HEVC encoding via x265 [no]
215 --enable-libxavs enable AVS encoding via xavs [no]
216 --enable-libxcb enable X11 grabbing using XCB [no]
217 --enable-libxcb-shm enable X11 grabbing shm communication [auto]
218 --enable-libxcb-xfixes enable X11 grabbing mouse rendering [auto]
219 --enable-libxvid enable Xvid encoding via xvidcore,
220 native MPEG-4/Xvid encoder exists [no]
221 --enable-mmal enable decoding via MMAL [no]
222 --enable-openssl enable openssl [no]
223 --enable-x11grab enable X11 grabbing (legacy) [no]
224 --enable-zlib enable zlib [autodetect]
225
226 Toolchain options:
227 --arch=ARCH select architecture [$arch]
228 --cpu=CPU select the minimum required CPU (affects
229 instruction selection, may crash on older CPUs)
230 --cross-prefix=PREFIX use PREFIX for compilation tools [$cross_prefix]
231 --enable-cross-compile assume a cross-compiler is used
232 --sysroot=PATH root of cross-build tree
233 --sysinclude=PATH location of cross-build system headers
234 --target-os=OS compiler targets OS [$target_os]
235 --target-exec=CMD command to run executables on target
236 --target-path=DIR path to view of build directory on target
237 --target-samples=DIR path to samples directory on target
238 --toolchain=NAME set tool defaults according to NAME
239 --nm=NM use nm tool
240 --ar=AR use archive tool AR [$ar_default]
241 --as=AS use assembler AS [$as_default]
242 --cc=CC use C compiler CC [$cc_default]
243 --dep-cc=DEPCC use dependency generator DEPCC [$cc_default]
244 --ld=LD use linker LD
245 --pkg-config=PKGCONFIG use pkg-config tool PKGCONFIG [$pkg_config_default]
246 --pkg-config-flags=FLAGS pass additional flags to pkgconf []
247 --host-cc=HOSTCC use host C compiler HOSTCC
248 --host-cflags=HCFLAGS use HCFLAGS when compiling for host
249 --host-cppflags=HCPPFLAGS use HCPPFLAGS when compiling for host
250 --host-ld=HOSTLD use host linker HOSTLD
251 --host-ldflags=HLDFLAGS use HLDFLAGS when linking for host
252 --host-libs=HLIBS use libs HLIBS when linking for host
253 --host-os=OS compiler host OS [$target_os]
254 --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS [$CFLAGS]
255 --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]
256 --extra-ldexeflags=ELDFLAGS add ELDFLAGS to LDEXEFLAGS [$LDEXEFLAGS]
257 --extra-libs=ELIBS add ELIBS [$ELIBS]
258 --extra-version=STRING version string suffix []
259 --optflags=OPTFLAGS override optimization-related compiler flags
260 --build-suffix=SUFFIX library name suffix []
261 --enable-pic build position-independent code
262 --enable-thumb compile for Thumb instruction set
263 --enable-lto use link-time optimization
264
265 Advanced options (experts only):
266 --malloc-prefix=PREFIX prefix malloc and related names with PREFIX
267 --disable-symver disable symbol versioning
268 --enable-hardcoded-tables use hardcoded tables instead of runtime generation
269 --disable-safe-bitstream-reader
270 disable buffer boundary checking in bitreaders
271 (faster, but may crash)
272 --enable-memalign-hack emulate memalign, interferes with memory debuggers
273 --enable-sram allow use of on-chip SRAM
274
275 Optimization options (experts only):
276 --disable-asm disable all assembly optimizations
277 --disable-altivec disable AltiVec optimizations
278 --disable-amd3dnow disable 3DNow! optimizations
279 --disable-amd3dnowext disable 3DNow! extended optimizations
280 --disable-mmx disable MMX optimizations
281 --disable-mmxext disable MMXEXT optimizations
282 --disable-sse disable SSE optimizations
283 --disable-sse2 disable SSE2 optimizations
284 --disable-sse3 disable SSE3 optimizations
285 --disable-ssse3 disable SSSE3 optimizations
286 --disable-sse4 disable SSE4 optimizations
287 --disable-sse42 disable SSE4.2 optimizations
288 --disable-avx disable AVX optimizations
289 --disable-xop disable XOP optimizations
290 --disable-fma3 disable FMA3 optimizations
291 --disable-fma4 disable FMA4 optimizations
292 --disable-avx2 disable AVX2 optimizations
293 --disable-armv5te disable armv5te optimizations
294 --disable-armv6 disable armv6 optimizations
295 --disable-armv6t2 disable armv6t2 optimizations
296 --disable-vfp disable VFP optimizations
297 --disable-neon disable NEON optimizations
298 --disable-inline-asm disable use of inline assembly
299 --disable-yasm disable use of nasm/yasm assembly
300
301 Developer options (useful when working on Libav itself):
302 --disable-debug disable debugging symbols
303 --enable-debug=LEVEL set the debug level [$debuglevel]
304 --disable-optimizations disable compiler optimizations
305 --enable-extra-warnings enable more compiler warnings
306 --samples=PATH location of test samples for FATE, if not set use
307 \$LIBAV_SAMPLES at make invocation time.
308 --enable-neon-clobber-test check NEON registers for clobbering (should be
309 used only for debugging purposes)
310 --enable-xmm-clobber-test check XMM registers for clobbering (Win64-only;
311 should be used only for debugging purposes)
312 --enable-random randomly enable/disable components
313 --disable-random
314 --enable-random=LIST randomly enable/disable specific components or
315 --disable-random=LIST component groups. LIST is a comma-separated list
316 of NAME[:PROB] entries where NAME is a component
317 (group) and PROB the probability associated with
318 NAME (default 0.5).
319 --random-seed=VALUE seed value for --enable/disable-random
320
321 NOTE: Object files are built at the place where configure is launched.
322 EOF
323 exit 0
324 }
325
326 quotes='""'
327
328 log(){
329 echo "$@" >> $logfile
330 }
331
332 log_file(){
333 log BEGIN $1
334 pr -n -t $1 >> $logfile
335 log END $1
336 }
337
338 echolog(){
339 log "$@"
340 echo "$@"
341 }
342
343 warn(){
344 log "WARNING: $*"
345 WARNINGS="${WARNINGS}WARNING: $*\n"
346 }
347
348 die(){
349 echolog "$@"
350 cat <<EOF
351
352 If you think configure made a mistake, make sure you are using the latest
353 version from Git. If the latest version fails, report the problem to the
354 libav-tools@libav.org mailing list or IRC #libav on irc.freenode.net.
355 EOF
356 if disabled logging; then
357 cat <<EOF
358 Rerun configure with logging enabled (do not use --disable-logging), and
359 include the log this produces with your report.
360 EOF
361 else
362 cat <<EOF
363 Include the log file "$logfile" produced by configure as this will help
364 solving the problem.
365 EOF
366 fi
367 exit 1
368 }
369
370 # Avoid locale weirdness, besides we really just want to translate ASCII.
371 toupper(){
372 echo "$@" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
373 }
374
375 tolower(){
376 echo "$@" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
377 }
378
379 c_escape(){
380 echo "$*" | sed 's/["\\]/\\\0/g'
381 }
382
383 sh_quote(){
384 v=$(echo "$1" | sed "s/'/'\\\\''/g")
385 test "x$v" = "x${v#*[!A-Za-z0-9_/.+-]}" || v="'$v'"
386 echo "$v"
387 }
388
389 cleanws(){
390 echo "$@" | sed 's/^ *//;s/ */ /g;s/ *$//'
391 }
392
393 filter(){
394 pat=$1
395 shift
396 for v; do
397 eval "case $v in $pat) echo $v ;; esac"
398 done
399 }
400
401 filter_out(){
402 pat=$1
403 shift
404 for v; do
405 eval "case $v in $pat) ;; *) echo $v ;; esac"
406 done
407 }
408
409 map(){
410 m=$1
411 shift
412 for v; do eval $m; done
413 }
414
415 add_suffix(){
416 suffix=$1
417 shift
418 for v; do echo ${v}${suffix}; done
419 }
420
421 set_all(){
422 value=$1
423 shift
424 for var in $*; do
425 eval $var=$value
426 done
427 }
428
429 set_weak(){
430 value=$1
431 shift
432 for var; do
433 eval : \${$var:=$value}
434 done
435 }
436
437 sanitize_var_name(){
438 echo $@ | sed 's/[^A-Za-z0-9_]/_/g'
439 }
440
441 set_safe(){
442 var=$1
443 shift
444 eval $(sanitize_var_name "$var")='$*'
445 }
446
447 get_safe(){
448 eval echo \$$(sanitize_var_name "$1")
449 }
450
451 pushvar(){
452 for pvar in $*; do
453 eval level=\${${pvar}_level:=0}
454 eval ${pvar}_${level}="\$$pvar"
455 eval ${pvar}_level=$(($level+1))
456 done
457 }
458
459 popvar(){
460 for pvar in $*; do
461 eval level=\${${pvar}_level:-0}
462 test $level = 0 && continue
463 eval level=$(($level-1))
464 eval $pvar="\${${pvar}_${level}}"
465 eval ${pvar}_level=$level
466 eval unset ${pvar}_${level}
467 done
468 }
469
470 enable(){
471 set_all yes $*
472 }
473
474 disable(){
475 set_all no $*
476 }
477
478 enable_weak(){
479 set_weak yes $*
480 }
481
482 disable_weak(){
483 set_weak no $*
484 }
485
486 enable_safe(){
487 for var; do
488 enable $(echo "$var" | sed 's/[^A-Za-z0-9_]/_/g')
489 done
490 }
491
492 disable_safe(){
493 for var; do
494 disable $(echo "$var" | sed 's/[^A-Za-z0-9_]/_/g')
495 done
496 }
497
498 do_enable_deep(){
499 for var; do
500 enabled $var && continue
501 eval sel="\$${var}_select"
502 eval sgs="\$${var}_suggest"
503 pushvar var sgs
504 enable_deep $sel
505 popvar sgs
506 enable_deep_weak $sgs
507 popvar var
508 done
509 }
510
511 enable_deep(){
512 do_enable_deep $*
513 enable $*
514 }
515
516 enable_deep_weak(){
517 for var; do
518 disabled $var && continue
519 pushvar var
520 do_enable_deep $var
521 popvar var
522 enable_weak $var
523 done
524 }
525
526 enabled(){
527 test "${1#!}" = "$1" && op== || op=!=
528 eval test "x\$${1#!}" $op "xyes"
529 }
530
531 disabled(){
532 test "${1#!}" = "$1" && op== || op=!=
533 eval test "x\$${1#!}" $op "xno"
534 }
535
536 enabled_all(){
537 for opt; do
538 enabled $opt || return 1
539 done
540 }
541
542 disabled_all(){
543 for opt; do
544 disabled $opt || return 1
545 done
546 }
547
548 enabled_any(){
549 for opt; do
550 enabled $opt && return 0
551 done
552 }
553
554 disabled_any(){
555 for opt; do
556 disabled $opt && return 0
557 done
558 return 1
559 }
560
561 set_default(){
562 for opt; do
563 eval : \${$opt:=\$${opt}_default}
564 done
565 }
566
567 is_in(){
568 value=$1
569 shift
570 for var in $*; do
571 [ $var = $value ] && return 0
572 done
573 return 1
574 }
575
576 do_check_deps(){
577 for cfg; do
578 cfg="${cfg#!}"
579 enabled ${cfg}_checking && die "Circular dependency for $cfg."
580 disabled ${cfg}_checking && continue
581 enable ${cfg}_checking
582 append allopts $cfg
583
584 eval dep_all="\$${cfg}_deps"
585 eval dep_any="\$${cfg}_deps_any"
586 eval dep_sel="\$${cfg}_select"
587 eval dep_sgs="\$${cfg}_suggest"
588 eval dep_ifa="\$${cfg}_if"
589 eval dep_ifn="\$${cfg}_if_any"
590
591 pushvar cfg dep_all dep_any dep_sel dep_sgs dep_ifa dep_ifn
592 do_check_deps $dep_all $dep_any $dep_sel $dep_sgs $dep_ifa $dep_ifn
593 popvar cfg dep_all dep_any dep_sel dep_sgs dep_ifa dep_ifn
594
595 [ -n "$dep_ifa" ] && { enabled_all $dep_ifa && enable_weak $cfg; }
596 [ -n "$dep_ifn" ] && { enabled_any $dep_ifn && enable_weak $cfg; }
597 enabled_all $dep_all || disable $cfg
598 enabled_any $dep_any || disable $cfg
599 disabled_any $dep_sel && disable $cfg
600
601 if enabled $cfg; then
602 enable_deep $dep_sel
603 enable_deep_weak $dep_sgs
604 fi
605
606 disable ${cfg}_checking
607 done
608 }
609
610 check_deps(){
611 unset allopts
612
613 do_check_deps "$@"
614
615 for cfg in $allopts; do
616 enabled $cfg || continue
617 eval dep_extralibs="\$${cfg}_extralibs"
618 test -n "$dep_extralibs" && add_extralibs $dep_extralibs
619 done
620 }
621
622 print_config(){
623 pfx=$1
624 files=$2
625 shift 2
626 map 'eval echo "$v \${$v:-no}"' "$@" |
627 awk "BEGIN { split(\"$files\", files) }
628 {
629 c = \"$pfx\" toupper(\$1);
630 v = \$2;
631 sub(/yes/, 1, v);
632 sub(/no/, 0, v);
633 for (f in files) {
634 file = files[f];
635 if (file ~ /\\.h\$/) {
636 printf(\"#define %s %d\\n\", c, v) >>file;
637 } else if (file ~ /\\.asm\$/) {
638 printf(\"%%define %s %d\\n\", c, v) >>file;
639 } else if (file ~ /\\.mak\$/) {
640 n = -v ? \"\" : \"!\";
641 printf(\"%s%s=yes\\n\", n, c) >>file;
642 }
643 }
644 }"
645 }
646
647 print_enabled(){
648 suf=$1
649 shift
650 for v; do
651 enabled $v && printf "%s\n" ${v%$suf};
652 done
653 }
654
655 append(){
656 var=$1
657 shift
658 eval "$var=\"\$$var $*\""
659 }
660
661 prepend(){
662 var=$1
663 shift
664 eval "$var=\"$* \$$var\""
665 }
666
667 unique(){
668 var=$1
669 uniq_list=""
670 for tok in $(eval echo \$$var); do
671 uniq_list="$(filter_out $tok $uniq_list) $tok"
672 done
673 eval "$var=\"${uniq_list}\""
674 }
675
676 add_cppflags(){
677 append CPPFLAGS "$@"
678 }
679
680 add_cflags(){
681 append CFLAGS $($cflags_filter "$@")
682 }
683
684 add_asflags(){
685 append ASFLAGS $($asflags_filter "$@")
686 }
687
688 add_ldflags(){
689 append LDFLAGS $($ldflags_filter "$@")
690 }
691
692 add_ldexeflags(){
693 append LDEXEFLAGS $($ldflags_filter "$@")
694 }
695
696 add_stripflags(){
697 append STRIPFLAGS "$@"
698 }
699
700 add_extralibs(){
701 prepend extralibs $($ldflags_filter "$@")
702 }
703
704 add_host_cppflags(){
705 append host_cppflags "$@"
706 }
707
708 add_host_cflags(){
709 append host_cflags $($host_cflags_filter "$@")
710 }
711
712 add_host_ldflags(){
713 append host_ldflags $($host_ldflags_filter "$@")
714 }
715
716 add_compat(){
717 append compat_objs $1
718 shift
719 map 'add_cppflags -D$v' "$@"
720 }
721
722 check_cmd(){
723 log "$@"
724 "$@" >> $logfile 2>&1
725 }
726
727 cc_o(){
728 eval printf '%s\\n' $CC_O
729 }
730
731 cc_e(){
732 eval printf '%s\\n' $CC_E
733 }
734
735 check_cc(){
736 log check_cc "$@"
737 cat > $TMPC
738 log_file $TMPC
739 check_cmd $cc $CPPFLAGS $CFLAGS "$@" $CC_C $(cc_o $TMPO) $TMPC
740 }
741
742 check_cpp(){
743 log check_cpp "$@"
744 cat > $TMPC
745 log_file $TMPC
746 check_cmd $cc $CPPFLAGS $CFLAGS "$@" $(cc_e $TMPO) $TMPC
747 }
748
749 as_o(){
750 eval printf '%s\\n' $AS_O
751 }
752
753 check_as(){
754 log check_as "$@"
755 cat > $TMPS
756 log_file $TMPS
757 check_cmd $as $CPPFLAGS $ASFLAGS "$@" $AS_C $(as_o $TMPO) $TMPS
758 }
759
760 check_inline_asm(){
761 log check_inline_asm "$@"
762 name="$1"
763 code="$2"
764 shift 2
765 disable $name
766 check_cc "$@" <<EOF && enable $name
767 void foo(void){ __asm__ volatile($code); }
768 EOF
769 }
770
771 check_insn(){
772 log check_insn "$@"
773 check_inline_asm ${1}_inline "\"$2\""
774 echo "$2" | check_as && enable ${1}_external || disable ${1}_external
775 }
776
777 check_yasm(){
778 log check_yasm "$@"
779 echo "$1" > $TMPS
780 log_file $TMPS
781 shift 1
782 check_cmd $yasmexe $YASMFLAGS "$@" -o $TMPO $TMPS
783 }
784
785 ld_o(){
786 eval printf '%s\\n' $LD_O
787 }
788
789 check_ld(){
790 log check_ld "$@"
791 flags=$(filter_out '-l*' "$@")
792 libs=$(filter '-l*' "$@")
793 check_cc $($cflags_filter $flags) || return
794 flags=$($ldflags_filter $flags)
795 libs=$($ldflags_filter $libs)
796 check_cmd $ld $LDFLAGS $flags $(ld_o $TMPE) $TMPO $libs $extralibs
797 }
798
799 print_include(){
800 hdr=$1
801 test "${hdr%.h}" = "${hdr}" &&
802 echo "#include $hdr" ||
803 echo "#include <$hdr>"
804 }
805
806 check_code(){
807 log check_code "$@"
808 check=$1
809 headers=$2
810 code=$3
811 shift 3
812 {
813 for hdr in $headers; do
814 print_include $hdr
815 done
816 echo "int main(void) { $code; return 0; }"
817 } | check_$check "$@"
818 }
819
820 check_cppflags(){
821 log check_cppflags "$@"
822 check_cc "$@" <<EOF && append CPPFLAGS "$@"
823 int x;
824 EOF
825 }
826
827 test_cflags(){
828 log test_cflags "$@"
829 set -- $($cflags_filter "$@")
830 check_cc "$@" <<EOF
831 int x;
832 EOF
833 }
834
835 check_cflags(){
836 log check_cflags "$@"
837 test_cflags "$@" && add_cflags "$@"
838 }
839
840 test_ldflags(){
841 log test_ldflags "$@"
842 check_ld "$@" <<EOF
843 int main(void){ return 0; }
844 EOF
845 }
846
847 check_ldflags(){
848 log check_ldflags "$@"
849 test_ldflags "$@" && add_ldflags "$@"
850 }
851
852 test_stripflags(){
853 log test_stripflags "$@"
854 # call check_cc to get a fresh TMPO
855 check_cc <<EOF
856 int main(void) { return 0; }
857 EOF
858 check_cmd $strip $STRIPFLAGS "$@" $TMPO
859 }
860
861 check_stripflags(){
862 log check_stripflags "$@"
863 test_stripflags "$@" && add_stripflags "$@"
864 }
865
866 check_header(){
867 log check_header "$@"
868 header=$1
869 shift
870 disable_safe $header
871 check_cpp "$@" <<EOF && enable_safe $header
872 #include <$header>
873 int x;
874 EOF
875 }
876
877 check_func(){
878 log check_func "$@"
879 func=$1
880 shift
881 disable $func
882 check_ld "$@" <<EOF && enable $func
883 extern int $func();
884 int main(void){ $func(); }
885 EOF
886 }
887
888 check_mathfunc(){
889 log check_mathfunc "$@"
890 func=$1
891 narg=$2
892 shift 2
893 test $narg = 2 && args="f, g" || args="f"
894 disable $func
895 check_ld "$@" <<EOF && enable $func
896 #include <math.h>
897 float foo(float f, float g) { return $func($args); }
898 int main(void){ return 0; }
899 EOF
900 }
901
902 check_func_headers(){
903 log check_func_headers "$@"
904 headers=$1
905 funcs=$2
906 shift 2
907 {
908 for hdr in $headers; do
909 print_include $hdr
910 done
911 for func in $funcs; do
912 echo "long check_$func(void) { return (long) $func; }"
913 done
914 echo "int main(void) { return 0; }"
915 } | check_ld "$@" && enable $funcs && enable_safe $headers
916 }
917
918 check_cpp_condition(){
919 log check_cpp_condition "$@"
920 header=$1
921 condition=$2
922 shift 2
923 check_cpp "$@" <<EOF
924 #include <$header>
925 #if !($condition)
926 #error "unsatisfied condition: $condition"
927 #endif
928 EOF
929 }
930
931 check_lib(){
932 log check_lib "$@"
933 header="$1"
934 func="$2"
935 shift 2
936 check_header $header && check_func $func "$@" && add_extralibs "$@"
937 }
938
939 check_lib2(){
940 log check_lib2 "$@"
941 headers="$1"
942 funcs="$2"
943 shift 2
944 check_func_headers "$headers" "$funcs" "$@" && add_extralibs "$@"
945 }
946
947 check_pkg_config(){
948 log check_pkg_config "$@"
949 pkg="$1"
950 headers="$2"
951 funcs="$3"
952 shift 3
953 check_cmd $pkg_config --exists --print-errors $pkg || return
954 pkg_cflags=$($pkg_config --cflags $pkg_config_flags $pkg)
955 pkg_libs=$($pkg_config --libs $pkg_config_flags $pkg)
956 check_func_headers "$headers" "$funcs" $pkg_cflags $pkg_libs "$@" &&
957 set_safe ${pkg}_cflags $pkg_cflags &&
958 set_safe ${pkg}_libs $pkg_libs
959 }
960
961 check_exec(){
962 check_ld "$@" && { enabled cross_compile || $TMPE >> $logfile 2>&1; }
963 }
964
965 check_exec_crash(){
966 code=$(cat)
967
968 # exit() is not async signal safe. _Exit (C99) and _exit (POSIX)
969 # are safe but may not be available everywhere. Thus we use
970 # raise(SIGTERM) instead. The check is run in a subshell so we
971 # can redirect the "Terminated" message from the shell. SIGBUS
972 # is not defined by standard C so it is used conditionally.
973
974 (check_exec "$@") >> $logfile 2>&1 <<EOF
975 #include <signal.h>
976 static void sighandler(int sig){
977 raise(SIGTERM);
978 }
979 int foo(void){
980 $code
981 }
982 int (*func_ptr)(void) = foo;
983 int main(void){
984 signal(SIGILL, sighandler);
985 signal(SIGFPE, sighandler);
986 signal(SIGSEGV, sighandler);
987 #ifdef SIGBUS
988 signal(SIGBUS, sighandler);
989 #endif
990 return func_ptr();
991 }
992 EOF
993 }
994
995 check_type(){
996 log check_type "$@"
997 headers=$1
998 type=$2
999 shift 2
1000 disable_safe "$type"
1001 check_code cc "$headers" "$type v" "$@" && enable_safe "$type"
1002 }
1003
1004 check_struct(){
1005 log check_struct "$@"
1006 headers=$1
1007 struct=$2
1008 member=$3
1009 shift 3
1010 disable_safe "${struct}_${member}"
1011 check_code cc "$headers" "const void *p = &(($struct *)0)->$member" "$@" &&
1012 enable_safe "${struct}_${member}"
1013 }
1014
1015 check_builtin(){
1016 log check_builtin "$@"
1017 name=$1
1018 headers=$2
1019 builtin=$3
1020 shift 3
1021 disable "$name"
1022 check_code ld "$headers" "$builtin" "$@" && enable "$name"
1023 }
1024
1025 check_compile_assert(){
1026 log check_compile_assert "$@"
1027 name=$1
1028 headers=$2
1029 condition=$3
1030 shift 3
1031 disable "$name"
1032 check_code cc "$headers" "char c[2 * !!($condition) - 1]" "$@" && enable "$name"
1033 }
1034
1035 require(){
1036 name="$1"
1037 header="$2"
1038 func="$3"
1039 shift 3
1040 check_lib $header $func "$@" || die "ERROR: $name not found"
1041 }
1042
1043 require2(){
1044 name="$1"
1045 headers="$2"
1046 func="$3"
1047 shift 3
1048 check_lib2 "$headers" $func "$@" || die "ERROR: $name not found"
1049 }
1050
1051 require_pkg_config(){
1052 pkg="$1"
1053 check_pkg_config "$@" || die "ERROR: $pkg not found"
1054 add_cflags $(get_safe ${pkg}_cflags)
1055 add_extralibs $(get_safe ${pkg}_libs)
1056 }
1057
1058 hostcc_e(){
1059 eval printf '%s\\n' $HOSTCC_E
1060 }
1061
1062 hostcc_o(){
1063 eval printf '%s\\n' $HOSTCC_O
1064 }
1065
1066 check_host_cc(){
1067 log check_host_cc "$@"
1068 cat > $TMPC
1069 log_file $TMPC
1070 check_cmd $host_cc $host_cflags "$@" $HOSTCC_C $(hostcc_o $TMPO) $TMPC
1071 }
1072
1073 check_host_cpp(){
1074 log check_host_cpp "$@"
1075 cat > $TMPC
1076 log_file $TMPC
1077 check_cmd $host_cc $host_cppflags $host_cflags "$@" $(hostcc_e $TMPO) $TMPC
1078 }
1079
1080 check_host_cppflags(){
1081 log check_host_cppflags "$@"
1082 check_host_cc "$@" <<EOF && append host_cppflags "$@"
1083 int x;
1084 EOF
1085 }
1086
1087 check_host_cflags(){
1088 log check_host_cflags "$@"
1089 set -- $($host_cflags_filter "$@")
1090 check_host_cc "$@" <<EOF && append host_cflags "$@"
1091 int x;
1092 EOF
1093 }
1094
1095 check_host_cpp_condition(){
1096 log check_host_cpp_condition "$@"
1097 header=$1
1098 condition=$2
1099 shift 2
1100 check_host_cpp "$@" <<EOF
1101 #include <$header>
1102 #if !($condition)
1103 #error "unsatisfied condition: $condition"
1104 #endif
1105 EOF
1106 }
1107
1108 apply(){
1109 file=$1
1110 shift
1111 "$@" < "$file" > "$file.tmp" && mv "$file.tmp" "$file" || rm "$file.tmp"
1112 }
1113
1114 cp_if_changed(){
1115 cmp -s "$1" "$2" && echo "$2 is unchanged" && return
1116 mkdir -p "$(dirname $2)"
1117 $cp_f "$1" "$2"
1118 }
1119
1120 # CONFIG_LIST contains configurable options, while HAVE_LIST is for
1121 # system-dependent things.
1122
1123 COMPONENT_LIST="
1124 bsfs
1125 decoders
1126 demuxers
1127 encoders
1128 filters
1129 hwaccels
1130 indevs
1131 muxers
1132 outdevs
1133 parsers
1134 protocols
1135 "
1136
1137 EXAMPLE_LIST="
1138 avcodec_example
1139 filter_audio_example
1140 metadata_example
1141 output_example
1142 qsvdec_example
1143 transcode_aac_example
1144 "
1145
1146 EXTERNAL_LIBRARY_LIST="
1147 avisynth
1148 bzlib
1149 frei0r
1150 gnutls
1151 libbs2b
1152 libcdio
1153 libdc1394
1154 libdcadec
1155 libfaac
1156 libfdk_aac
1157 libfontconfig
1158 libfreetype
1159 libgsm
1160 libilbc
1161 libmfx
1162 libmp3lame
1163 libopencore_amrnb
1164 libopencore_amrwb
1165 libopencv
1166 libopenh264
1167 libopenjpeg
1168 libopus
1169 libpulse
1170 librtmp
1171 libschroedinger
1172 libspeex
1173 libtheora
1174 libtwolame
1175 libvo_aacenc
1176 libvo_amrwbenc
1177 libvorbis
1178 libvpx
1179 libwavpack
1180 libwebp
1181 libx264
1182 libx265
1183 libxavs
1184 libxcb
1185 libxcb_shm
1186 libxcb_xfixes
1187 libxvid
1188 mmal
1189 openssl
1190 x11grab
1191 zlib
1192 "
1193
1194 FEATURE_LIST="
1195 gray
1196 hardcoded_tables
1197 runtime_cpudetect
1198 safe_bitstream_reader
1199 shared
1200 small
1201 sram
1202 static
1203 swscale_alpha
1204 "
1205
1206 HWACCEL_LIST="
1207 dxva2
1208 vaapi
1209 vda
1210 vdpau
1211 "
1212
1213 LIBRARY_LIST="
1214 avcodec
1215 avdevice
1216 avfilter
1217 avformat
1218 avresample
1219 avutil
1220 swscale
1221 "
1222
1223 LICENSE_LIST="
1224 gpl
1225 nonfree
1226 version3
1227 "
1228
1229 PROGRAM_LIST="
1230 avconv
1231 avplay
1232 avprobe
1233 "
1234
1235 SUBSYSTEM_LIST="
1236 dct
1237 doc
1238 error_resilience
1239 faan
1240 fft
1241 lsp
1242 lzo
1243 mdct
1244 network
1245 rdft
1246 "
1247
1248 CONFIG_LIST="
1249 $COMPONENT_LIST
1250 $EXAMPLE_LIST
1251 $EXTERNAL_LIBRARY_LIST
1252 $FEATURE_LIST
1253 $HWACCEL_LIST
1254 $LICENSE_LIST
1255 $LIBRARY_LIST
1256 $PROGRAM_LIST
1257 $SUBSYSTEM_LIST
1258 memalign_hack
1259 neon_clobber_test
1260 pic
1261 pod2man
1262 texi2html
1263 thumb
1264 xmm_clobber_test
1265 "
1266
1267 THREADS_LIST="
1268 pthreads
1269 w32threads
1270 "
1271
1272 ATOMICS_LIST="
1273 atomics_gcc
1274 atomics_suncc
1275 atomics_win32
1276 "
1277
1278 ARCH_LIST="
1279 aarch64
1280 alpha
1281 arm
1282 avr32
1283 avr32_ap
1284 avr32_uc
1285 bfin
1286 ia64
1287 m68k
1288 mips
1289 mips64
1290 parisc
1291 ppc
1292 ppc64
1293 s390
1294 sh4
1295 sparc
1296 sparc64
1297 tilegx
1298 tilepro
1299 tomi
1300 x86
1301 x86_32
1302 x86_64
1303 "
1304
1305 ARCH_EXT_LIST_ARM="
1306 armv5te
1307 armv6
1308 armv6t2
1309 armv8
1310 neon
1311 vfp
1312 vfpv3
1313 "
1314
1315 ARCH_EXT_LIST_X86_SIMD="
1316 amd3dnow
1317 amd3dnowext
1318 avx
1319 avx2
1320 fma3
1321 fma4
1322 mmx
1323 mmxext
1324 sse
1325 sse2
1326 sse3
1327 sse4
1328 sse42
1329 ssse3
1330 xop
1331 "
1332
1333 ARCH_EXT_LIST_PPC="
1334 altivec
1335 dcbzl
1336 ldbrx
1337 ppc4xx
1338 "
1339
1340 ARCH_EXT_LIST_X86="
1341 $ARCH_EXT_LIST_X86_SIMD
1342 cpunop
1343 i686
1344 "
1345
1346 ARCH_EXT_LIST="
1347 $ARCH_EXT_LIST_ARM
1348 $ARCH_EXT_LIST_PPC
1349 $ARCH_EXT_LIST_X86
1350 loongson
1351 vis
1352 "
1353
1354 ARCH_FEATURES="
1355 aligned_stack
1356 fast_64bit
1357 fast_clz
1358 fast_cmov
1359 local_aligned_8
1360 local_aligned_16
1361 simd_align_16
1362 "
1363
1364 BUILTIN_LIST="
1365 atomic_cas_ptr
1366 machine_rw_barrier
1367 MemoryBarrier
1368 mm_empty
1369 rdtsc
1370 sync_val_compare_and_swap
1371 "
1372 HAVE_LIST_CMDLINE="
1373 inline_asm
1374 symver
1375 yasm
1376 "
1377
1378 HAVE_LIST_PUB="
1379 bigendian
1380 fast_unaligned
1381 "
1382
1383 HEADERS_LIST="
1384 alsa_asoundlib_h
1385 altivec_h
1386 arpa_inet_h
1387 cdio_paranoia_h
1388 cdio_paranoia_paranoia_h
1389 dev_bktr_ioctl_bt848_h
1390 dev_bktr_ioctl_meteor_h
1391 dev_ic_bt8xx_h
1392 dev_video_bktr_ioctl_bt848_h
1393 dev_video_meteor_ioctl_meteor_h
1394 direct_h
1395 dlfcn_h
1396 dxva_h
1397 gsm_h
1398 io_h
1399 mach_mach_time_h
1400 machine_ioctl_bt848_h
1401 machine_ioctl_meteor_h
1402 malloc_h
1403 poll_h
1404 sndio_h
1405 soundcard_h
1406 sys_mman_h
1407 sys_param_h
1408 sys_resource_h
1409 sys_select_h
1410 sys_soundcard_h
1411 sys_time_h
1412 sys_un_h
1413 sys_videoio_h
1414 unistd_h
1415 windows_h
1416 winsock2_h
1417 "
1418
1419 INTRINSICS_LIST="
1420 intrinsics_neon
1421 "
1422
1423 MATH_FUNCS="
1424 atanf
1425 atan2f
1426 cbrtf
1427 cosf
1428 exp2
1429 exp2f
1430 expf
1431 isinf
1432 isnan
1433 ldexpf
1434 llrint
1435 llrintf
1436 log2
1437 log2f
1438 log10f
1439 lrint
1440 lrintf
1441 powf
1442 rint
1443 round
1444 roundf
1445 sinf
1446 trunc
1447 truncf
1448 "
1449
1450 SYSTEM_FUNCS="
1451 aligned_malloc
1452 clock_gettime
1453 closesocket
1454 CommandLineToArgvW
1455 CoTaskMemFree
1456 CryptGenRandom
1457 dlopen
1458 fcntl
1459 flt_lim
1460 fork
1461 getaddrinfo
1462 gethrtime
1463 getopt
1464 GetProcessAffinityMask
1465 GetProcessMemoryInfo
1466 GetProcessTimes
1467 getrusage
1468 getservbyport
1469 GetSystemTimeAsFileTime
1470 gettimeofday
1471 gmtime_r
1472 inet_aton
1473 isatty
1474 jack_port_get_latency_range
1475 localtime_r
1476 mach_absolute_time
1477 MapViewOfFile
1478 memalign
1479 mkstemp
1480 mmap
1481 mprotect
1482 nanosleep
1483 posix_memalign
1484 sched_getaffinity
1485 SetConsoleTextAttribute
1486 setmode
1487 setrlimit
1488 Sleep
1489 strerror_r
1490 strptime
1491 sysconf
1492 sysctl
1493 usleep
1494 VirtualAlloc
1495 "
1496
1497 TOOLCHAIN_FEATURES="
1498 as_dn_directive
1499 as_func
1500 as_object_arch
1501 asm_mod_q
1502 attribute_may_alias
1503 attribute_packed
1504 ebp_available
1505 ebx_available
1506 gnu_as
1507 ibm_asm
1508 inline_asm_labels
1509 pragma_deprecated
1510 symver_asm_label
1511 symver_gnu_asm
1512 vfp_args
1513 xform_asm
1514 xmm_clobbers
1515 "
1516
1517 TYPES_LIST="
1518 CONDITION_VARIABLE_Ptr
1519 DXVA_PicParams_HEVC
1520 socklen_t
1521 struct_addrinfo
1522 struct_group_source_req
1523 struct_ip_mreq_source
1524 struct_ipv6_mreq
1525 struct_pollfd
1526 struct_rusage_ru_maxrss
1527 struct_sockaddr_in6
1528 struct_sockaddr_sa_len
1529 struct_sockaddr_storage
1530 struct_v4l2_frmivalenum_discrete
1531 "
1532
1533 HAVE_LIST="
1534 $ARCH_EXT_LIST
1535 $(add_suffix _external $ARCH_EXT_LIST)
1536 $(add_suffix _inline $ARCH_EXT_LIST)
1537 $ARCH_FEATURES
1538 $ATOMICS_LIST
1539 $BUILTIN_LIST
1540 $HAVE_LIST_CMDLINE
1541 $HAVE_LIST_PUB
1542 $HEADERS_LIST
1543 $INTRINSICS_LIST
1544 $MATH_FUNCS
1545 $SYSTEM_FUNCS
1546 $THREADS_LIST
1547 $TOOLCHAIN_FEATURES
1548 $TYPES_LIST
1549 atomics_native
1550 dos_paths
1551 dxva2_lib
1552 libc_msvcrt
1553 libdc1394_1
1554 libdc1394_2
1555 sdl
1556 section_data_rel_ro
1557 threads
1558 vaapi_x11
1559 vdpau_x11
1560 xlib
1561 "
1562
1563 # options emitted with CONFIG_ prefix but not available on the command line
1564 CONFIG_EXTRA="
1565 aandcttables
1566 ac3dsp
1567 audio_frame_queue
1568 audiodsp
1569 blockdsp
1570 bswapdsp
1571 cabac
1572 dvprofile
1573 faandct
1574 faanidct
1575 fdctdsp
1576 fmtconvert
1577 gcrypt
1578 golomb
1579 gplv3
1580 h263dsp
1581 h264chroma
1582 h264dsp
1583 h264pred
1584 h264qpel
1585 hpeldsp
1586 huffman
1587 huffyuvdsp
1588 huffyuvencdsp
1589 idctdsp
1590 iirfilter
1591 imdct15
1592 intrax8
1593 lgplv3
1594 lpc
1595 me_cmp
1596 mpeg_er
1597 mpegaudio
1598 mpegaudiodsp
1599 mpegvideo
1600 mpegvideoenc
1601 nettle
1602 pixblockdsp
1603 qpeldsp
1604 qsv
1605 qsvdec
1606 qsvenc
1607 rangecoder
1608 riffdec
1609 riffenc
1610 rtpdec
1611 rtpenc_chain
1612 sinewin
1613 startcode
1614 tpeldsp
1615 videodsp
1616 vp3dsp
1617 wma_freqs
1618 "
1619
1620 CMDLINE_SELECT="
1621 $ARCH_EXT_LIST
1622 $CONFIG_LIST
1623 $HAVE_LIST_CMDLINE
1624 $THREADS_LIST
1625 asm
1626 cross_compile
1627 debug
1628 extra_warnings
1629 logging
1630 lto
1631 optimizations
1632 rpath
1633 "
1634
1635 PATHS_LIST="
1636 bindir
1637 datadir
1638 docdir
1639 incdir
1640 libdir
1641 mandir
1642 prefix
1643 shlibdir
1644 "
1645
1646 CMDLINE_SET="
1647 $PATHS_LIST
1648 ar
1649 arch
1650 as
1651 build_suffix
1652 cc
1653 cpu
1654 cross_prefix
1655 dep_cc
1656 extra_version
1657 host_cc
1658 host_cflags
1659 host_ld
1660 host_ldflags
1661 host_libs
1662 host_os
1663 ld
1664 logfile
1665 malloc_prefix
1666 nm
1667 optflags
1668 pkg_config
1669 pkg_config_flags
1670 random_seed
1671 samples
1672 sysinclude
1673 sysroot
1674 target_exec
1675 target_os
1676 target_path
1677 target_samples
1678 toolchain
1679 "
1680
1681 CMDLINE_APPEND="
1682 extra_cflags
1683 host_cppflags
1684 "
1685
1686 # code dependency declarations
1687
1688 # architecture extensions
1689
1690 armv5te_deps="arm"
1691 armv6_deps="arm"
1692 armv6t2_deps="arm"
1693 armv8_deps="aarch64"
1694 neon_deps_any="aarch64 arm"
1695 intrinsics_neon_deps="neon"
1696 vfp_deps_any="aarch64 arm"
1697 vfpv3_deps="vfp"
1698
1699 map 'eval ${v}_inline_deps=inline_asm' $ARCH_EXT_LIST_ARM
1700
1701 altivec_deps="ppc"
1702 ppc4xx_deps="ppc"
1703
1704 cpunop_deps="i686"
1705 x86_64_select="i686"
1706 x86_64_suggest="fast_cmov"
1707
1708 amd3dnow_deps="mmx"
1709 amd3dnowext_deps="amd3dnow"
1710 i686_deps="x86"
1711 mmx_deps="x86"
1712 mmxext_deps="mmx"
1713 sse_deps="mmxext"
1714 sse2_deps="sse"
1715 sse3_deps="sse2"
1716 ssse3_deps="sse3"
1717 sse4_deps="ssse3"
1718 sse42_deps="sse4"
1719 avx_deps="sse42"
1720 xop_deps="avx"
1721 fma3_deps="avx"
1722 fma4_deps="avx"
1723 avx2_deps="avx"
1724
1725 mmx_external_deps="yasm"
1726 mmx_inline_deps="inline_asm"
1727 mmx_suggest="mmx_external mmx_inline"
1728
1729 for ext in $(filter_out mmx $ARCH_EXT_LIST_X86_SIMD); do
1730 eval dep=\$${ext}_deps
1731 eval ${ext}_external_deps='"${dep}_external"'
1732 eval ${ext}_inline_deps='"${dep}_inline"'
1733 eval ${ext}_suggest='"${ext}_external ${ext}_inline"'
1734 done
1735
1736 aligned_stack_if_any="aarch64 ppc x86"
1737 fast_64bit_if_any="aarch64 alpha ia64 mips64 parisc64 ppc64 sparc64 x86_64"
1738 fast_clz_if_any="aarch64 alpha avr32 mips ppc x86"
1739 fast_unaligned_if_any="aarch64 ppc x86"
1740 simd_align_16_if_any="altivec neon sse"
1741
1742 # system capabilities
1743 log2_deps="!libc_msvcrt"
1744
1745 symver_if_any="symver_asm_label symver_gnu_asm"
1746
1747 # threading support
1748 atomics_gcc_if="sync_val_compare_and_swap"
1749 atomics_suncc_if="atomic_cas_ptr machine_rw_barrier"
1750 atomics_win32_if="MemoryBarrier"
1751 atomics_native_if_any="$ATOMICS_LIST"
1752 w32threads_deps="atomics_native"
1753 threads_if_any="$THREADS_LIST"
1754
1755 # subsystems
1756 dct_select="rdft"
1757 error_resilience_select="me_cmp"
1758 faandct_deps="faan fdctdsp"
1759 faanidct_deps="faan idctdsp"
1760 intrax8_select="error_resilience"
1761 mdct_select="fft"
1762 rdft_select="fft"
1763 me_cmp_select="fdctdsp idctdsp pixblockdsp"
1764 mpeg_er_select="error_resilience"
1765 mpegaudio_select="mpegaudiodsp"
1766 mpegaudiodsp_select="dct"
1767 mpegvideo_select="blockdsp hpeldsp idctdsp me_cmp videodsp"
1768 mpegvideoenc_select="me_cmp mpegvideo pixblockdsp qpeldsp"
1769 qsvdec_select="qsv"
1770 qsvenc_select="qsv"
1771
1772 # decoders / encoders
1773 aac_decoder_select="imdct15 mdct sinewin"
1774 aac_encoder_select="audio_frame_queue iirfilter mdct sinewin"
1775 aac_latm_decoder_select="aac_decoder aac_latm_parser"
1776 ac3_decoder_select="ac3_parser ac3dsp bswapdsp fmtconvert mdct"
1777 ac3_encoder_select="ac3dsp audiodsp mdct me_cmp"
1778 ac3_fixed_encoder_select="ac3dsp audiodsp mdct me_cmp"
1779 aic_decoder_select="golomb idctdsp"
1780 alac_encoder_select="lpc"
1781 als_decoder_select="bswapdsp"
1782 amrnb_decoder_select="lsp"
1783 amrwb_decoder_select="lsp"
1784 amv_decoder_select="sp5x_decoder"
1785 ape_decoder_select="bswapdsp"
1786 asv1_decoder_select="blockdsp bswapdsp idctdsp"
1787 asv1_encoder_select="bswapdsp fdctdsp pixblockdsp"
1788 asv2_decoder_select="blockdsp bswapdsp idctdsp"
1789 asv2_encoder_select="bswapdsp fdctdsp pixblockdsp"
1790 atrac1_decoder_select="mdct sinewin"
1791 atrac3_decoder_select="mdct"
1792 atrac3p_decoder_select="mdct sinewin"
1793 bink_decoder_select="blockdsp hpeldsp"
1794 binkaudio_dct_decoder_select="mdct rdft dct sinewin wma_freqs"
1795 binkaudio_rdft_decoder_select="mdct rdft sinewin wma_freqs"
1796 cavs_decoder_select="blockdsp golomb h264chroma idctdsp qpeldsp videodsp"
1797 cllc_decoder_select="bswapdsp"
1798 comfortnoise_encoder_select="lpc"
1799 cook_decoder_select="audiodsp mdct sinewin"
1800 cscd_decoder_select="lzo"
1801 cscd_decoder_suggest="zlib"
1802 dca_decoder_select="fmtconvert mdct"
1803 dnxhd_decoder_select="blockdsp idctdsp"
1804 dnxhd_encoder_select="aandcttables blockdsp fdctdsp idctdsp mpegvideoenc pixblockdsp"
1805 dvvideo_decoder_select="dvprofile idctdsp"
1806 dvvideo_encoder_select="dvprofile fdctdsp me_cmp pixblockdsp"
1807 dxa_decoder_deps="zlib"
1808 eac3_decoder_select="ac3_decoder"
1809 eac3_encoder_select="ac3_encoder"
1810 eamad_decoder_select="aandcttables blockdsp bswapdsp idctdsp mpegvideo"
1811 eatgq_decoder_select="aandcttables idctdsp"
1812 eatqi_decoder_select="aandcttables blockdsp bswapdsp idctdsp mpeg1video_decoder"
1813 exr_decoder_deps="zlib"
1814 ffv1_decoder_select="golomb rangecoder"
1815 ffv1_encoder_select="rangecoder"
1816 ffvhuff_decoder_select="huffyuv_decoder"
1817 ffvhuff_encoder_select="huffyuv_encoder"
1818 fic_decoder_select="golomb"
1819 flac_decoder_select="golomb"
1820 flac_encoder_select="bswapdsp golomb lpc"
1821 flashsv_decoder_deps="zlib"
1822 flashsv_encoder_deps="zlib"
1823 flashsv2_decoder_deps="zlib"
1824 flv_decoder_select="h263_decoder"
1825 flv_encoder_select="h263_encoder"
1826 fourxm_decoder_select="blockdsp bswapdsp"
1827 fraps_decoder_select="bswapdsp huffman"
1828 g2m_decoder_deps="zlib"
1829 g2m_decoder_select="blockdsp idctdsp"
1830 h261_decoder_select="mpeg_er mpegvideo"
1831 h261_encoder_select="aandcttables mpegvideoenc"
1832 h263_decoder_select="error_resilience h263_parser h263dsp mpeg_er mpegvideo qpeldsp"
1833 h263_encoder_select="aandcttables h263dsp mpegvideoenc"
1834 h263i_decoder_select="h263_decoder"
1835 h263p_encoder_select="h263_encoder"
1836 h264_decoder_select="cabac golomb h264chroma h264dsp h264pred h264qpel startcode videodsp"
1837 h264_decoder_suggest="error_resilience"
1838 h264_qsv_decoder_deps="libmfx"
1839 h264_qsv_decoder_select="h264_mp4toannexb_bsf h264_parser qsvdec h264_qsv_hwaccel"
1840 h264_qsv_encoder_deps="libmfx"
1841 h264_qsv_encoder_select="qsvenc"
1842 hevc_decoder_select="bswapdsp cabac golomb videodsp"
1843 huffyuv_decoder_select="bswapdsp huffyuvdsp"
1844 huffyuv_encoder_select="bswapdsp huffman huffyuvencdsp"
1845 iac_decoder_select="imc_decoder"
1846 imc_decoder_select="bswapdsp fft mdct sinewin"
1847 indeo3_decoder_select="hpeldsp"
1848 interplay_video_decoder_select="hpeldsp"
1849 jpegls_decoder_select="golomb mjpeg_decoder"
1850 jpegls_encoder_select="golomb"
1851 jv_decoder_select="blockdsp"
1852 lagarith_decoder_select="huffyuvdsp"
1853 ljpeg_encoder_select="aandcttables idctdsp"
1854 loco_decoder_select="golomb"
1855 mdec_decoder_select="blockdsp idctdsp mpegvideo"
1856 metasound_decoder_select="lsp mdct sinewin"
1857 mimic_decoder_select="blockdsp bswapdsp hpeldsp idctdsp"
1858 mjpeg_decoder_select="blockdsp hpeldsp idctdsp"
1859 mjpeg_encoder_select="aandcttables mpegvideoenc"
1860 mjpegb_decoder_select="mjpeg_decoder"
1861 mlp_decoder_select="mlp_parser"
1862 motionpixels_decoder_select="bswapdsp"
1863 mp1_decoder_select="mpegaudio"
1864 mp1float_decoder_select="mpegaudio"
1865 mp2_decoder_select="mpegaudio"
1866 mp2float_decoder_select="mpegaudio"
1867 mp3_decoder_select="mpegaudio"
1868 mp3adu_decoder_select="mpegaudio"
1869 mp3adufloat_decoder_select="mpegaudio"
1870 mp3float_decoder_select="mpegaudio"
1871 mp3on4_decoder_select="mpegaudio"
1872 mp3on4float_decoder_select="mpegaudio"
1873 mpc7_decoder_select="bswapdsp mpegaudiodsp"
1874 mpc8_decoder_select="mpegaudiodsp"
1875 mpeg_xvmc_decoder_deps="X11_extensions_XvMClib_h"
1876 mpeg_xvmc_decoder_select="mpeg2video_decoder"
1877 mpeg1video_decoder_select="error_resilience mpeg_er mpegvideo"
1878 mpeg1video_encoder_select="aandcttables mpegvideoenc"
1879 mpeg2video_decoder_select="error_resilience mpeg_er mpegvideo"
1880 mpeg2video_encoder_select="aandcttables mpegvideoenc"
1881 mpeg4_decoder_select="h263_decoder mpeg4video_parser"
1882 mpeg4_encoder_select="h263_encoder"
1883 msmpeg4v1_decoder_select="h263_decoder"
1884 msmpeg4v2_decoder_select="h263_decoder"
1885 msmpeg4v2_encoder_select="h263_encoder"
1886 msmpeg4v3_decoder_select="h263_decoder"
1887 msmpeg4v3_encoder_select="h263_encoder"
1888 mss2_decoder_select="error_resilience mpeg_er qpeldsp vc1_decoder"
1889 mxpeg_decoder_select="mjpeg_decoder"
1890 nellymoser_decoder_select="mdct sinewin"
1891 nellymoser_encoder_select="audio_frame_queue mdct sinewin"
1892 nuv_decoder_select="idctdsp lzo"
1893 on2avc_decoder_select="mdct"
1894 opus_decoder_deps="avresample"
1895 opus_decoder_select="imdct15"
1896 png_decoder_deps="zlib"
1897 png_encoder_deps="zlib"
1898 png_encoder_select="huffyuvencdsp"
1899 prores_decoder_select="idctdsp"
1900 prores_encoder_select="fdctdsp"
1901 qcelp_decoder_select="lsp"
1902 qdm2_decoder_select="mdct rdft mpegaudiodsp"
1903 ra_144_encoder_select="audio_frame_queue lpc"
1904 ralf_decoder_select="golomb"
1905 rv10_decoder_select="error_resilience h263_decoder h263dsp mpeg_er"
1906 rv10_encoder_select="h263_encoder"
1907 rv20_decoder_select="error_resilience h263_decoder h263dsp mpeg_er"
1908 rv20_encoder_select="h263_encoder"
1909 rv30_decoder_select="error_resilience golomb h264chroma h264pred h264qpel mpeg_er mpegvideo videodsp"
1910 rv40_decoder_select="error_resilience golomb h264chroma h264pred h264qpel mpeg_er mpegvideo videodsp"
1911 shorten_decoder_select="golomb"
1912 sipr_decoder_select="lsp"
1913 sp5x_decoder_select="mjpeg_decoder"
1914 svq1_decoder_select="hpeldsp"
1915 svq1_encoder_select="aandcttables hpeldsp me_cmp mpegvideoenc"
1916 svq3_decoder_select="h264_decoder hpeldsp tpeldsp"
1917 svq3_decoder_suggest="zlib"
1918 tak_decoder_select="audiodsp"
1919 tdsc_decoder_deps="zlib"
1920 tdsc_decoder_select="mjpeg_decoder"
1921 theora_decoder_select="vp3_decoder"
1922 thp_decoder_select="mjpeg_decoder"
1923 tiff_decoder_suggest="zlib"
1924 tiff_encoder_suggest="zlib"
1925 truehd_decoder_select="mlp_decoder"
1926 truemotion2_decoder_select="bswapdsp"
1927 truespeech_decoder_select="bswapdsp"
1928 tscc_decoder_deps="zlib"
1929 twinvq_decoder_select="mdct lsp sinewin"
1930 utvideo_decoder_select="bswapdsp"
1931 utvideo_encoder_select="bswapdsp huffman huffyuvencdsp"
1932 vble_decoder_select="huffyuvdsp"
1933 vc1_decoder_select="blockdsp error_resilience h263_decoder h264chroma h264qpel intrax8 mpeg_er qpeldsp startcode"
1934 vc1image_decoder_select="vc1_decoder"
1935 vorbis_decoder_select="mdct"
1936 vorbis_encoder_select="mdct"
1937 vp3_decoder_select="hpeldsp vp3dsp videodsp"
1938 vp5_decoder_select="h264chroma hpeldsp videodsp vp3dsp"
1939 vp6_decoder_select="h264chroma hpeldsp huffman videodsp vp3dsp"
1940 vp6a_decoder_select="vp6_decoder"
1941 vp6f_decoder_select="vp6_decoder"
1942 vp7_decoder_select="h264pred videodsp"
1943 vp8_decoder_select="h264pred videodsp"
1944 vp9_decoder_select="videodsp"
1945 webp_decoder_select="vp8_decoder"
1946 wmapro_decoder_select="mdct sinewin wma_freqs"
1947 wmav1_decoder_select="mdct sinewin wma_freqs"
1948 wmav1_encoder_select="mdct sinewin wma_freqs"
1949 wmav2_decoder_select="mdct sinewin wma_freqs"
1950 wmav2_encoder_select="mdct sinewin wma_freqs"
1951 wmavoice_decoder_select="lsp rdft dct mdct sinewin"
1952 wmv1_decoder_select="h263_decoder"
1953 wmv1_encoder_select="h263_encoder"
1954 wmv2_decoder_select="blockdsp h263_decoder idctdsp intrax8 videodsp"
1955 wmv2_encoder_select="h263_encoder"
1956 wmv3_decoder_select="vc1_decoder"
1957 wmv3image_decoder_select="wmv3_decoder"
1958 zerocodec_decoder_deps="zlib"
1959 zlib_decoder_deps="zlib"
1960 zlib_encoder_deps="zlib"
1961 zmbv_decoder_deps="zlib"
1962 zmbv_encoder_deps="zlib"
1963
1964 # hardware accelerators
1965 dxva2_deps="dxva2api_h"
1966 vaapi_deps="va_va_h"
1967 vda_deps="VideoDecodeAcceleration_VDADecoder_h pthreads"
1968 vda_extralibs="-framework CoreFoundation -framework VideoDecodeAcceleration -framework QuartzCore"
1969 vdpau_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
1970
1971 h263_vaapi_hwaccel_deps="vaapi"
1972 h263_vaapi_hwaccel_select="h263_decoder"
1973 h263_vdpau_hwaccel_deps="vdpau"
1974 h263_vdpau_hwaccel_select="h263_decoder"
1975 h264_dxva2_hwaccel_deps="dxva2"
1976 h264_dxva2_hwaccel_select="h264_decoder"
1977 h264_mmal_decoder_deps="mmal"
1978 h264_mmal_hwaccel_deps="mmal"
1979 h264_mmal_decoder_select="h264_decoder"
1980 h264_mmal_encoder_deps="mmal"
1981 h264_qsv_hwaccel_deps="libmfx"
1982 h264_vaapi_hwaccel_deps="vaapi"
1983 h264_vaapi_hwaccel_select="h264_decoder"
1984 h264_vda_hwaccel_deps="vda"
1985 h264_vda_hwaccel_select="h264_decoder"
1986 h264_vda_old_hwaccel_deps="vda"
1987 h264_vda_old_hwaccel_select="h264_decoder"
1988 h264_vdpau_hwaccel_deps="vdpau"
1989 h264_vdpau_hwaccel_select="h264_decoder"
1990 hevc_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_HEVC"
1991 hevc_dxva2_hwaccel_select="hevc_decoder"
1992 mpeg1_vdpau_hwaccel_deps="vdpau"
1993 mpeg1_vdpau_hwaccel_select="mpeg1video_decoder"
1994 mpeg2_dxva2_hwaccel_deps="dxva2"
1995 mpeg2_dxva2_hwaccel_select="mpeg2video_decoder"
1996 mpeg2_vaapi_hwaccel_deps="vaapi"
1997 mpeg2_vaapi_hwaccel_select="mpeg2video_decoder"
1998 mpeg2_vdpau_hwaccel_deps="vdpau"
1999 mpeg2_vdpau_hwaccel_select="mpeg2video_decoder"
2000 mpeg4_vaapi_hwaccel_deps="vaapi"
2001 mpeg4_vaapi_hwaccel_select="mpeg4_decoder"
2002 mpeg4_vdpau_hwaccel_deps="vdpau"
2003 mpeg4_vdpau_hwaccel_select="mpeg4_decoder"
2004 vc1_dxva2_hwaccel_deps="dxva2"
2005 vc1_dxva2_hwaccel_select="vc1_decoder"
2006 vc1_vaapi_hwaccel_deps="vaapi"
2007 vc1_vaapi_hwaccel_select="vc1_decoder"
2008 vc1_vdpau_hwaccel_deps="vdpau"
2009 vc1_vdpau_hwaccel_select="vc1_decoder"
2010 wmv3_dxva2_hwaccel_select="vc1_dxva2_hwaccel"
2011 wmv3_vaapi_hwaccel_select="vc1_vaapi_hwaccel"
2012 wmv3_vdpau_hwaccel_select="vc1_vdpau_hwaccel"
2013
2014 # parsers
2015 h264_parser_select="h264_decoder"
2016 mpegvideo_parser_select="mpegvideo"
2017 mpeg4video_parser_select="error_resilience h263dsp mpeg_er mpegvideo qpeldsp"
2018 vc1_parser_select="mpegvideo startcode vc1_decoder"
2019
2020 # external libraries
2021 libdcadec_decoder_deps="libdcadec"
2022 libfaac_encoder_deps="libfaac"
2023 libfaac_encoder_select="audio_frame_queue"
2024 libfdk_aac_decoder_deps="libfdk_aac"
2025 libfdk_aac_encoder_deps="libfdk_aac"
2026 libfdk_aac_encoder_select="audio_frame_queue"
2027 libgsm_decoder_deps="libgsm"
2028 libgsm_encoder_deps="libgsm"
2029 libgsm_ms_decoder_deps="libgsm"
2030 libgsm_ms_encoder_deps="libgsm"
2031 libilbc_decoder_deps="libilbc"
2032 libilbc_encoder_deps="libilbc"
2033 libmp3lame_encoder_deps="libmp3lame"
2034 libmp3lame_encoder_select="audio_frame_queue"
2035 libopencore_amrnb_decoder_deps="libopencore_amrnb"
2036 libopencore_amrnb_encoder_deps="libopencore_amrnb"
2037 libopencore_amrnb_encoder_select="audio_frame_queue"
2038 libopencore_amrwb_decoder_deps="libopencore_amrwb"
2039 libopenh264_encoder_deps="libopenh264"
2040 libopenjpeg_decoder_deps="libopenjpeg"
2041 libopenjpeg_encoder_deps="libopenjpeg"
2042 libopus_decoder_deps="libopus"
2043 libopus_encoder_deps="libopus"
2044 libopus_encoder_select="audio_frame_queue"
2045 libschroedinger_decoder_deps="libschroedinger"
2046 libschroedinger_encoder_deps="libschroedinger"
2047 libspeex_decoder_deps="libspeex"
2048 libspeex_encoder_deps="libspeex"
2049 libspeex_encoder_select="audio_frame_queue"
2050 libtheora_encoder_deps="libtheora"
2051 libtwolame_encoder_deps="libtwolame"
2052 libvo_aacenc_encoder_deps="libvo_aacenc"
2053 libvo_aacenc_encoder_select="audio_frame_queue"
2054 libvo_amrwbenc_encoder_deps="libvo_amrwbenc"
2055 libvorbis_encoder_deps="libvorbis"
2056 libvorbis_encoder_select="audio_frame_queue"
2057 libvpx_vp8_decoder_deps="libvpx"
2058 libvpx_vp8_encoder_deps="libvpx"
2059 libvpx_vp9_decoder_deps="libvpx"
2060 libvpx_vp9_encoder_deps="libvpx"
2061 libwavpack_encoder_deps="libwavpack"
2062 libwebp_encoder_deps="libwebp"
2063 libx264_encoder_deps="libx264"
2064 libx265_encoder_deps="libx265"
2065 libxavs_encoder_deps="libxavs"
2066 libxvid_encoder_deps="libxvid"
2067
2068 # demuxers / muxers
2069 ac3_demuxer_select="ac3_parser"
2070 asf_demuxer_select="riffdec"
2071 asf_muxer_select="riffenc"
2072 asf_stream_muxer_select="asf_muxer"
2073 avi_demuxer_select="riffdec"
2074 avi_muxer_select="riffenc"
2075 avisynth_demuxer_deps="avisynth"
2076 avisynth_demuxer_select="riffdec"
2077 caf_demuxer_select="riffdec"
2078 dash_muxer_select="mp4_muxer"
2079 dirac_demuxer_select="dirac_parser"
2080 dv_demuxer_select="dvprofile"
2081 dv_muxer_select="dvprofile"
2082 dxa_demuxer_select="riffdec"
2083 eac3_demuxer_select="ac3_parser"
2084 f4v_muxer_select="mov_muxer"
2085 flac_demuxer_select="flac_parser"
2086 hds_muxer_select="flv_muxer"
2087 hls_muxer_select="mpegts_muxer"
2088 ipod_muxer_select="mov_muxer"
2089 ismv_muxer_select="mov_muxer"
2090 matroska_audio_muxer_select="matroska_muxer"
2091 matroska_demuxer_select="riffdec"
2092 matroska_demuxer_suggest="bzlib lzo zlib"
2093 matroska_muxer_select="riffenc"
2094 mmf_muxer_select="riffenc"
2095 mov_demuxer_select="riffdec"
2096 mov_demuxer_suggest="zlib"
2097 mov_muxer_select="riffenc rtpenc_chain"
2098 mp3_demuxer_select="mpegaudio_parser"
2099 mp4_muxer_select="mov_muxer"
2100 mpegts_muxer_select="adts_muxer latm_muxer"
2101 mpegtsraw_demuxer_select="mpegts_demuxer"
2102 mxf_d10_muxer_select="mxf_muxer"
2103 nut_muxer_select="riffenc"
2104 nuv_demuxer_select="riffdec"
2105 oga_muxer_select="ogg_muxer"
2106 ogg_demuxer_select="golomb"
2107 opus_muxer_select="ogg_muxer"
2108 psp_muxer_select="mov_muxer"
2109 rtp_demuxer_select="sdp_demuxer"
2110 rtpdec_select="asf_demuxer rm_demuxer rtp_protocol mpegts_demuxer mov_demuxer"
2111 rtsp_demuxer_select="http_protocol rtpdec"
2112 rtsp_muxer_select="rtp_muxer http_protocol rtp_protocol rtpenc_chain"
2113 sap_demuxer_select="sdp_demuxer"
2114 sap_muxer_select="rtp_muxer rtp_protocol rtpenc_chain"
2115 sdp_demuxer_select="rtpdec"
2116 smoothstreaming_muxer_select="ismv_muxer"
2117 spdif_muxer_select="aac_parser"
2118 spx_muxer_select="ogg_muxer"
2119 tak_demuxer_select="tak_parser"
2120 tg2_muxer_select="mov_muxer"
2121 tgp_muxer_select="mov_muxer"
2122 w64_demuxer_select="wav_demuxer"
2123 wav_demuxer_select="riffdec"
2124 wav_muxer_select="riffenc"
2125 webm_muxer_select="riffenc"
2126 wtv_demuxer_select="riffdec"
2127 xmv_demuxer_select="riffdec"
2128 xwma_demuxer_select="riffdec"
2129
2130 # indevs / outdevs
2131 alsa_indev_deps="alsa_asoundlib_h snd_pcm_htimestamp"
2132 alsa_outdev_deps="alsa_asoundlib_h"
2133 bktr_indev_deps_any="dev_bktr_ioctl_bt848_h machine_ioctl_bt848_h dev_video_bktr_ioctl_bt848_h dev_ic_bt8xx_h"
2134 dv1394_indev_deps="dv1394"
2135 dv1394_indev_select="dv_demuxer"
2136 fbdev_indev_deps="linux_fb_h"
2137 jack_indev_deps="jack_jack_h pthreads"
2138 libcdio_indev_deps="libcdio"
2139 libdc1394_indev_deps="libdc1394"
2140 oss_indev_deps_any="soundcard_h sys_soundcard_h"
2141 oss_outdev_deps_any="soundcard_h sys_soundcard_h"
2142 pulse_indev_deps="libpulse"
2143 sndio_indev_deps="sndio_h"
2144 sndio_outdev_deps="sndio_h"
2145 v4l2_indev_deps_any="linux_videodev2_h sys_videoio_h"
2146 vfwcap_indev_deps="capCreateCaptureWindow vfwcap_defines"
2147 vfwcap_indev_extralibs="-lavicap32"
2148 x11grab_indev_deps="x11grab"
2149 x11grab_xcb_indev_deps="libxcb"
2150
2151 # protocols
2152 ffrtmpcrypt_protocol_deps="!librtmp_protocol"
2153 ffrtmpcrypt_protocol_deps_any="gcrypt nettle openssl"
2154 ffrtmpcrypt_protocol_select="tcp_protocol"
2155 ffrtmphttp_protocol_deps="!librtmp_protocol"
2156 ffrtmphttp_protocol_select="http_protocol"
2157 gopher_protocol_select="network"
2158 http_protocol_select="tcp_protocol"
2159 httpproxy_protocol_select="tcp_protocol"
2160 https_protocol_select="tls_protocol"
2161 icecast_protocol_select="http_protocol"
2162 librtmp_protocol_deps="librtmp"
2163 librtmpe_protocol_deps="librtmp"
2164 librtmps_protocol_deps="librtmp"
2165 librtmpt_protocol_deps="librtmp"
2166 librtmpte_protocol_deps="librtmp"
2167 mmsh_protocol_select="http_protocol"
2168 mmst_protocol_select="network"
2169 rtmp_protocol_deps="!librtmp_protocol"
2170 rtmp_protocol_select="tcp_protocol"
2171 rtmpe_protocol_select="ffrtmpcrypt_protocol"
2172 rtmps_protocol_deps="!librtmp_protocol"
2173 rtmps_protocol_select="tls_protocol"
2174 rtmpt_protocol_select="ffrtmphttp_protocol"
2175 rtmpte_protocol_select="ffrtmpcrypt_protocol ffrtmphttp_protocol"
2176 rtmpts_protocol_select="ffrtmphttp_protocol https_protocol"
2177 rtp_protocol_select="udp_protocol"
2178 sctp_protocol_deps="struct_sctp_event_subscribe"
2179 sctp_protocol_select="network"
2180 srtp_protocol_select="rtp_protocol"
2181 tcp_protocol_select="network"
2182 tls_protocol_deps_any="openssl gnutls"
2183 tls_protocol_select="tcp_protocol"
2184 udp_protocol_select="network"
2185 unix_protocol_deps="sys_un_h"
2186 unix_protocol_select="network"
2187
2188 # filters
2189 blackframe_filter_deps="gpl"
2190 boxblur_filter_deps="gpl"
2191 bs2b_filter_deps="libbs2b"
2192 cropdetect_filter_deps="gpl"
2193 delogo_filter_deps="gpl"
2194 drawtext_filter_deps="libfreetype"
2195 frei0r_filter_deps="frei0r dlopen"
2196 frei0r_filter_extralibs='$ldl'
2197 frei0r_src_filter_deps="frei0r dlopen"
2198 frei0r_src_filter_extralibs='$ldl'
2199 hqdn3d_filter_deps="gpl"
2200 interlace_filter_deps="gpl"
2201 ocv_filter_deps="libopencv"
2202 resample_filter_deps="avresample"
2203 scale_filter_deps="swscale"
2204
2205 # examples
2206 avcodec_example_deps="avcodec avutil"
2207 filter_audio_example_deps="avfilter avutil"
2208 metadata_example_deps="avformat avutil"
2209 output_example_deps="avcodec avformat avutil swscale"
2210 qsvdec_example_deps="avcodec avutil libmfx h264_qsv_decoder vaapi_x11"
2211 transcode_aac_example_deps="avcodec avformat avresample"
2212
2213 # libraries, in linking order
2214 avcodec_deps="avutil"
2215 avdevice_deps="avformat avcodec avutil"
2216 avfilter_deps="avutil"
2217 avformat_deps="avcodec avutil"
2218 avresample_deps="avutil"
2219 swscale_deps="avutil"
2220
2221 # programs
2222 avconv_deps="avcodec avfilter avformat avresample swscale"
2223 avconv_select="aformat_filter anull_filter asyncts_filter atrim_filter format_filter
2224 fps_filter null_filter resample_filter scale_filter
2225 setpts_filter trim_filter"
2226 avplay_deps="avcodec avformat avresample swscale sdl"
2227 avplay_libs='$sdl_libs'
2228 avplay_select="rdft"
2229 avprobe_deps="avcodec avformat"
2230
2231 # documentation
2232 pod2man_deps="doc"
2233 texi2html_deps="doc"
2234
2235 # default parameters
2236
2237 logfile="config.log"
2238
2239 # installation paths
2240 prefix_default="/usr/local"
2241 bindir_default='${prefix}/bin'
2242 datadir_default='${prefix}/share/avconv'
2243 docdir_default='${prefix}/share/doc/libav'
2244 incdir_default='${prefix}/include'
2245 libdir_default='${prefix}/lib'
2246 mandir_default='${prefix}/share/man'
2247 shlibdir_default="$libdir_default"
2248
2249 # toolchain
2250 ar_default="ar"
2251 cc_default="gcc"
2252 host_cc_default="gcc"
2253 cp_f="cp -f"
2254 ln_s="ln -s -f"
2255 nm_default="nm -g"
2256 objformat="elf"
2257 pkg_config_default=pkg-config
2258 ranlib="ranlib"
2259 strip="strip"
2260 yasmexe="yasm"
2261
2262 # machine
2263 arch_default=$(uname -m)
2264 cpu="generic"
2265 intrinsics="none"
2266
2267 # OS
2268 target_os_default=$(tolower $(uname -s))
2269 host_os=$target_os_default
2270
2271 # configurable options
2272 enable $EXAMPLE_LIST $LIBRARY_LIST $PROGRAM_LIST
2273
2274 enable asm
2275 enable debug
2276 enable doc
2277 enable faan faandct faanidct
2278 enable optimizations
2279 enable safe_bitstream_reader
2280 enable static
2281 enable swscale_alpha
2282
2283 # By default, enable only those hwaccels that have no external dependencies.
2284 enable dxva2 vda vdpau
2285
2286 # build settings
2287 SHFLAGS='-shared -Wl,-soname,$$(@F)'
2288 LIBPREF="lib"
2289 LIBSUF=".a"
2290 FULLNAME='$(NAME)$(BUILDSUF)'
2291 LIBNAME='$(LIBPREF)$(FULLNAME)$(LIBSUF)'
2292 SLIBPREF="lib"
2293 SLIBSUF=".so"
2294 SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF)'
2295 SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
2296 SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
2297 LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
2298 SLIB_INSTALL_NAME='$(SLIBNAME_WITH_VERSION)'
2299 SLIB_INSTALL_LINKS='$(SLIBNAME_WITH_MAJOR) $(SLIBNAME)'
2300
2301 asflags_filter=echo
2302 cflags_filter=echo
2303 ldflags_filter=echo
2304
2305 AS_C='-c'
2306 AS_O='-o $@'
2307 CC_C='-c'
2308 CC_E='-E -o $@'
2309 CC_O='-o $@'
2310 LD_O='-o $@'
2311 LD_LIB='-l%'
2312 LD_PATH='-L'
2313 HOSTCC_C='-c'
2314 HOSTCC_E='-E -o $@'
2315 HOSTCC_O='-o $@'
2316 HOSTLD_O='-o $@'
2317
2318 host_libs='-lm'
2319 host_cflags_filter=echo
2320 host_ldflags_filter=echo
2321
2322 target_path='$(CURDIR)'
2323
2324 # since the object filename is not given with the -MM flag, the compiler
2325 # is only able to print the basename, and we must add the path ourselves
2326 DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< | sed -e "/^\#.*/d" -e "s,^[[:space:]]*$(*F)\\.o,$(@D)/$(*F).o," > $(@:.o=.d)'
2327 DEPFLAGS='-MM'
2328
2329 # find source path
2330 if test -f configure; then
2331 source_path=.
2332 else
2333 source_path=$(cd $(dirname "$0"); pwd)
2334 echo "$source_path" | grep -q '[[:blank:]]' &&
2335 die "Out of tree builds are impossible with whitespace in source path."
2336 test -e "$source_path/config.h" &&
2337 die "Out of tree builds are impossible with config.h in source dir."
2338 fi
2339
2340 for v in "$@"; do
2341 r=${v#*=}
2342 l=${v%"$r"}
2343 r=$(sh_quote "$r")
2344 LIBAV_CONFIGURATION="${LIBAV_CONFIGURATION# } ${l}${r}"
2345 done
2346
2347 find_things(){
2348 thing=$1
2349 pattern=$2
2350 file=$source_path/$3
2351 sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" "$file"
2352 }
2353
2354 ENCODER_LIST=$(find_things encoder ENC libavcodec/allcodecs.c)
2355 DECODER_LIST=$(find_things decoder DEC libavcodec/allcodecs.c)
2356 HWACCEL_LIST=$(find_things hwaccel HWACCEL libavcodec/allcodecs.c)
2357 PARSER_LIST=$(find_things parser PARSER libavcodec/allcodecs.c)
2358 BSF_LIST=$(find_things bsf BSF libavcodec/allcodecs.c)
2359 MUXER_LIST=$(find_things muxer _MUX libavformat/allformats.c)
2360 DEMUXER_LIST=$(find_things demuxer DEMUX libavformat/allformats.c)
2361 OUTDEV_LIST=$(find_things outdev OUTDEV libavdevice/alldevices.c)
2362 INDEV_LIST=$(find_things indev _IN libavdevice/alldevices.c)
2363 PROTOCOL_LIST=$(find_things protocol PROTOCOL libavformat/allformats.c)
2364 FILTER_LIST=$(find_things filter FILTER libavfilter/allfilters.c)
2365
2366 ALL_COMPONENTS="
2367 $BSF_LIST
2368 $DECODER_LIST
2369 $DEMUXER_LIST
2370 $ENCODER_LIST
2371 $FILTER_LIST
2372 $HWACCEL_LIST
2373 $INDEV_LIST
2374 $MUXER_LIST
2375 $OUTDEV_LIST
2376 $PARSER_LIST
2377 $PROTOCOL_LIST
2378 "
2379
2380 for n in $COMPONENT_LIST; do
2381 v=$(toupper ${n%s})_LIST
2382 eval enable \$$v
2383 eval ${n}_if_any="\$$v"
2384 done
2385
2386 enable $ARCH_EXT_LIST
2387
2388 die_unknown(){
2389 echo "Unknown option \"$1\"."
2390 echo "See $0 --help for available options."
2391 exit 1
2392 }
2393
2394 print_3_columns() {
2395 cat | tr ' ' '\n' | sort | pr -r -3 -t
2396 }
2397
2398 show_list() {
2399 suffix=_$1
2400 shift
2401 echo $* | sed s/$suffix//g | print_3_columns
2402 exit 0
2403 }
2404
2405 rand_list(){
2406 IFS=', '
2407 set -- $*
2408 unset IFS
2409 for thing; do
2410 comp=${thing%:*}
2411 prob=${thing#$comp}
2412 prob=${prob#:}
2413 is_in ${comp} $COMPONENT_LIST && eval comp=\$$(toupper ${comp%s})_LIST
2414 echo "prob ${prob:-0.5}"
2415 printf '%s\n' $comp
2416 done
2417 }
2418
2419 do_random(){
2420 action=$1
2421 shift
2422 random_seed=$(awk "BEGIN { srand($random_seed); print srand() }")
2423 $action $(rand_list "$@" | awk "BEGIN { srand($random_seed) } \$1 == \"prob\" { prob = \$2; next } rand() < prob { print }")
2424 }
2425
2426 for opt do
2427 optval="${opt#*=}"
2428 case "$opt" in
2429 --extra-ldflags=*)
2430 add_ldflags $optval
2431 ;;
2432 --extra-ldexeflags=*)
2433 add_ldexeflags $optval
2434 ;;
2435 --extra-libs=*)
2436 add_extralibs $optval
2437 ;;
2438 --disable-devices)
2439 disable $INDEV_LIST $OUTDEV_LIST
2440 ;;
2441 --enable-debug=*)
2442 debuglevel="$optval"
2443 ;;
2444 --disable-programs)
2445 disable $PROGRAM_LIST
2446 ;;
2447 --disable-everything)
2448 map 'eval unset \${$(toupper ${v%s})_LIST}' $COMPONENT_LIST
2449 ;;
2450 --disable-all)
2451 map 'eval unset \${$(toupper ${v%s})_LIST}' $COMPONENT_LIST
2452 disable $LIBRARY_LIST $PROGRAM_LIST doc
2453 ;;
2454 --enable-random|--disable-random)
2455 action=${opt%%-random}
2456 do_random ${action#--} $COMPONENT_LIST
2457 ;;
2458 --enable-random=*|--disable-random=*)
2459 action=${opt%%-random=*}
2460 do_random ${action#--} $optval
2461 ;;
2462 --enable-*=*|--disable-*=*)
2463 eval $(echo "${opt%%=*}" | sed 's/--/action=/;s/-/ thing=/')
2464 is_in "${thing}s" $COMPONENT_LIST || die_unknown "$opt"
2465 eval list=\$$(toupper $thing)_LIST
2466 name=$(echo "${optval}" | sed "s/,/_${thing}|/g")_${thing}
2467 $action $(filter "$name" $list)
2468 ;;
2469 --enable-avserver|--disable-avserver*)
2470 warn "avserver has been removed, the ${opt} option is only"\
2471 "provided for compatibility and will be removed in the future"
2472 ;;
2473 --enable-?*|--disable-?*)
2474 eval $(echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g')
2475 if is_in $option $COMPONENT_LIST; then
2476 test $action = disable && action=unset
2477 eval $action \$$(toupper ${option%s})_LIST
2478 elif is_in $option $CMDLINE_SELECT; then
2479 $action $option
2480 else
2481 die_unknown $opt
2482 fi
2483 ;;
2484 --list-*)
2485 NAME="${opt#--list-}"
2486 is_in $NAME $COMPONENT_LIST || die_unknown $opt
2487 NAME=${NAME%s}
2488 eval show_list $NAME \$$(toupper $NAME)_LIST
2489 ;;
2490 --help|-h) show_help
2491 ;;
2492 *)
2493 optname="${opt%%=*}"
2494 optname="${optname#--}"
2495 optname=$(echo "$optname" | sed 's/-/_/g')
2496 if is_in $optname $CMDLINE_SET; then
2497 eval $optname='$optval'
2498 elif is_in $optname $CMDLINE_APPEND; then
2499 append $optname "$optval"
2500 else
2501 die_unknown $opt
2502 fi
2503 ;;
2504 esac
2505 done
2506
2507 disabled logging && logfile=/dev/null
2508
2509 echo "# $0 $LIBAV_CONFIGURATION" > $logfile
2510 set >> $logfile
2511
2512 case "$toolchain" in
2513 clang-asan)
2514 cc_default="clang"
2515 add_cflags -fsanitize=address
2516 add_ldflags -fsanitize=address
2517 ;;
2518 clang-tsan)
2519 cc_default="clang"
2520 add_cflags -fsanitize=thread -pie
2521 add_ldflags -fsanitize=thread -pie
2522 ;;
2523 clang-usan)
2524 cc_default="clang"
2525 add_cflags -fsanitize=undefined -O1
2526 add_ldflags -fsanitize=undefined
2527 ;;
2528 gcc-asan)
2529 cc_default="gcc"
2530 add_cflags -fsanitize=address
2531 add_ldflags -fsanitize=address
2532 ;;
2533 gcc-tsan)
2534 cc_default="gcc"
2535 add_cflags -fsanitize=thread -pie -fPIC
2536 add_ldflags -fsanitize=thread -pie -fPIC
2537 ;;
2538 gcc-usan)
2539 cc_default="gcc"
2540 add_cflags -fsanitize=undefined
2541 add_ldflags -fsanitize=undefined
2542 ;;
2543 valgrind-massif)
2544 target_exec_default="valgrind"
2545 target_exec_args="--alloc-fn=av_malloc --alloc-fn=av_mallocz"
2546 ;;
2547 valgrind-memcheck)
2548 target_exec_default="valgrind"
2549 target_exec_args="--track-origins=yes --leak-check=full"
2550 ;;
2551 msvc)
2552 # Check whether the current MSVC version needs the C99 converter.
2553 # From MSVC 2013 (compiler major version 18) onwards, it does actually
2554 # support enough of C99 to build libav. Default to the new
2555 # behaviour if the regexp was unable to match anything, since this
2556 # successfully parses the version number of existing supported
2557 # versions that require the converter (MSVC 2010 and 2012).
2558 cl_major_ver=$(cl 2>&1 | sed -n 's/.*Version \([[:digit:]]\{1,\}\)\..*/\1/p')
2559 if [ -z "$cl_major_ver" ] || [ $cl_major_ver -ge 18 ]; then
2560 cc_default="cl"
2561 else
2562 cc_default="c99wrap cl"
2563 fi
2564 ld_default="link"
2565 nm_default="dumpbin -symbols"
2566 ar_default="lib"
2567 target_os_default="win32"
2568 # Use a relative path for TMPDIR. This makes sure all the
2569 # ffconf temp files are written with a relative path, avoiding
2570 # issues with msys/win32 path conversion for MSVC parameters
2571 # such as -Fo<file> or -out:<file>.
2572 TMPDIR=.
2573 ;;
2574 icl)
2575 cc_default="icl"
2576 ld_default="xilink"
2577 nm_default="dumpbin -symbols"
2578 ar_default="xilib"
2579 target_os_default="win32"
2580 TMPDIR=.
2581 ;;
2582 gcov)
2583 add_cflags -fprofile-arcs -ftest-coverage
2584 add_ldflags -fprofile-arcs -ftest-coverage
2585 ;;
2586 hardened)
2587 add_cppflags -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2
2588 add_cflags -fno-strict-overflow -fstack-protector-all
2589 add_ldflags -Wl,-z,relro -Wl,-z,now
2590 ;;
2591 ?*)
2592 die "Unknown toolchain $toolchain"
2593 ;;
2594 esac
2595
2596 test -n "$cross_prefix" && enable cross_compile
2597
2598 if enabled cross_compile; then
2599 test -n "$arch" && test -n "$target_os" ||
2600 die "Must specify target arch and OS when cross-compiling"
2601 fi
2602
2603 ar_default="${cross_prefix}${ar_default}"
2604 cc_default="${cross_prefix}${cc_default}"
2605 nm_default="${cross_prefix}${nm_default}"
2606 pkg_config_default="${cross_prefix}${pkg_config_default}"
2607 ranlib="${cross_prefix}${ranlib}"
2608 strip="${cross_prefix}${strip}"
2609
2610 sysinclude_default="${sysroot}/usr/include"
2611
2612 set_default arch cc pkg_config sysinclude target_exec target_os
2613 enabled cross_compile || host_cc_default=$cc
2614 set_default host_cc
2615
2616 if ! $pkg_config --version >/dev/null 2>&1; then
2617 warn "$pkg_config not found, library detection may fail."
2618 pkg_config=false
2619 fi
2620
2621 exesuf() {
2622 case $1 in
2623 mingw32*|win32|win64|cygwin*|*-dos|freedos|opendos|os/2*|symbian) echo .exe ;;
2624 esac
2625 }
2626
2627 EXESUF=$(exesuf $target_os)
2628 HOSTEXESUF=$(exesuf $host_os)
2629
2630 # set temporary file name
2631 : ${TMPDIR:=$TEMPDIR}
2632 : ${TMPDIR:=$TMP}
2633 : ${TMPDIR:=/tmp}
2634
2635 if ! check_cmd mktemp -u XXXXXX; then
2636 # simple replacement for missing mktemp
2637 # NOT SAFE FOR GENERAL USE
2638 mktemp(){
2639 echo "${2%%XXX*}.${HOSTNAME}.${UID}.$$"
2640 }
2641 fi
2642
2643 tmpfile(){
2644 tmp=$(mktemp -u "${TMPDIR}/ffconf.XXXXXXXX")$2 &&
2645 (set -C; exec > $tmp) 2>/dev/null ||
2646 die "Unable to create temporary file in $TMPDIR."
2647 append TMPFILES $tmp
2648 eval $1=$tmp
2649 }
2650
2651 trap 'rm -f -- $TMPFILES' EXIT
2652
2653 tmpfile TMPASM .asm
2654 tmpfile TMPC .c
2655 tmpfile TMPE $EXESUF
2656 tmpfile TMPH .h
2657 tmpfile TMPO .o
2658 tmpfile TMPS .S
2659 tmpfile TMPSH .sh
2660 tmpfile TMPV .ver
2661
2662 unset -f mktemp
2663
2664 chmod +x $TMPE
2665
2666 # make sure we can execute files in $TMPDIR
2667 cat > $TMPSH 2>> $logfile <<EOF
2668 #! /bin/sh
2669 EOF
2670 chmod +x $TMPSH >> $logfile 2>&1
2671 if ! $TMPSH >> $logfile 2>&1; then
2672 cat <<EOF
2673 Unable to create and execute files in $TMPDIR. Set the TMPDIR environment
2674 variable to another directory and make sure that it is not mounted noexec.
2675 EOF
2676 die "Sanity test failed."
2677 fi
2678
2679 armasm_flags(){
2680 for flag; do
2681 case $flag in
2682 # Filter out MSVC cl.exe options from cflags that shouldn't
2683 # be passed to gas-preprocessor
2684 -M[TD]*) ;;
2685 *) echo $flag ;;
2686 esac
2687 done
2688 }
2689
2690 ccc_flags(){
2691 for flag; do
2692 case $flag in
2693 -std=c99) echo -c99 ;;
2694 -mcpu=*) echo -arch ${flag#*=} ;;
2695 -mieee) echo -ieee ;;
2696 -O*|-fast) echo $flag ;;
2697 -fno-math-errno) echo -assume nomath_errno ;;
2698 -g) echo -g3 ;;
2699 -Wall) echo -msg_enable level2 ;;
2700 -Wno-pointer-sign) echo -msg_disable ptrmismatch1 ;;
2701 -Wl,*) echo $flag ;;
2702 -f*|-W*) ;;
2703 *) echo $flag ;;
2704 esac
2705 done
2706 }
2707
2708 cparser_flags(){
2709 for flag; do
2710 case $flag in
2711 -Wno-switch) echo -Wno-switch-enum ;;
2712 -Wno-format-zero-length) ;;
2713 -Wdisabled-optimization) ;;
2714 -Wno-pointer-sign) echo -Wno-other ;;
2715 *) echo $flag ;;
2716 esac
2717 done
2718 }
2719
2720 msvc_common_flags(){
2721 for flag; do
2722 case $flag in
2723 # In addition to specifying certain flags under the compiler
2724 # specific filters, they must be specified here as well or else the
2725 # generic catch all at the bottom will print the original flag.
2726 -Wall) ;;
2727 -std=c99) ;;
2728 # Common flags
2729 -fomit-frame-pointer) ;;
2730 -g) echo -Z7 ;;
2731 -fno-math-errno) ;;
2732 -fno-common) ;;
2733 -fno-signed-zeros) ;;
2734 -fPIC) ;;
2735 -mthumb) ;;
2736 -march=*) ;;
2737 -lz) echo zlib.lib ;;
2738 -lavifil32) echo vfw32.lib ;;
2739 -lavicap32) echo vfw32.lib user32.lib ;;
2740 -l*) echo ${flag#-l}.lib ;;
2741 -L*) echo -libpath:${flag#-L} ;;
2742 *) echo $flag ;;
2743 esac
2744 done
2745 }
2746
2747 msvc_flags(){
2748 msvc_common_flags "$@"
2749 for flag; do
2750 case $flag in
2751 -Wall) echo -W4 -wd4244 -wd4127 -wd4018 -wd4389 \
2752 -wd4146 -wd4057 -wd4204 -wd4706 -wd4305 \
2753 -wd4152 -wd4324 -we4013 -wd4100 -wd4214 \
2754 -wd4273 -wd4554 -wd4701 ;;
2755 esac
2756 done
2757 }
2758
2759 icl_flags(){
2760 msvc_common_flags "$@"
2761 for flag; do
2762 case $flag in
2763 # Despite what Intel's documentation says -Wall, which is supported
2764 # on Windows, does enable remarks so disable them here.
2765 -Wall) echo $flag -Qdiag-disable:remark ;;
2766 -std=c99) echo -Qstd=c99 ;;
2767 esac
2768 done
2769 }
2770
2771 pgi_flags(){
2772 for flag; do
2773 case $flag in
2774 -flto) echo -Mipa=fast,libopt,libinline,vestigial ;;
2775 -fomit-frame-pointer) echo -Mnoframe ;;
2776 -g) echo -gopt ;;
2777 *) echo $flag ;;
2778 esac
2779 done
2780 }
2781
2782 suncc_flags(){
2783 for flag; do
2784 case $flag in
2785 -march=*|-mcpu=*)
2786 case "${flag#*=}" in
2787 native) echo -xtarget=native ;;
2788 v9|niagara) echo -xarch=sparc ;;
2789 ultrasparc) echo -xarch=sparcvis ;;
2790 ultrasparc3|niagara2) echo -xarch=sparcvis2 ;;
2791 i586|pentium) echo -xchip=pentium ;;
2792 i686|pentiumpro|pentium2) echo -xtarget=pentium_pro ;;
2793 pentium3*|c3-2) echo -xtarget=pentium3 ;;
2794 pentium-m) echo -xarch=sse2 -xchip=pentium3 ;;
2795 pentium4*) echo -xtarget=pentium4 ;;
2796 prescott|nocona) echo -xarch=sse3 -xchip=pentium4 ;;
2797 *-sse3) echo -xarch=sse3 ;;
2798 core2) echo -xarch=ssse3 -xchip=core2 ;;
2799 corei7) echo -xarch=sse4_2 -xchip=nehalem ;;
2800 corei7-avx) echo -xarch=avx -xchip=sandybridge ;;
2801 amdfam10|barcelona|bdver*) echo -xarch=sse4_1 ;;
2802 athlon-4|athlon-[mx]p) echo -xarch=ssea ;;
2803 k8|opteron|athlon64|athlon-fx)
2804 echo -xarch=sse2a ;;
2805 athlon*) echo -xarch=pentium_proa ;;
2806 esac
2807 ;;
2808 -std=c99) echo -xc99 ;;
2809 -fomit-frame-pointer) echo -xregs=frameptr ;;
2810 -fPIC) echo -KPIC -xcode=pic32 ;;
2811 -W*,*) echo $flag ;;
2812 -f*-*|-W*|-mimpure-text) ;;
2813 -shared) echo -G ;;
2814 *) echo $flag ;;
2815 esac
2816 done
2817 }
2818
2819 tms470_flags(){
2820 for flag; do
2821 case $flag in
2822 -march=*|-mcpu=*)
2823 case "${flag#*=}" in
2824 armv7-a|cortex-a*) echo -mv=7a8 ;;
2825 armv7-r|cortex-r*) echo -mv=7r4 ;;
2826 armv7-m|cortex-m*) echo -mv=7m3 ;;
2827 armv6*|arm11*) echo -mv=6 ;;
2828 armv5*e|arm[79]*e*|arm9[24]6*|arm96*|arm102[26])
2829 echo -mv=5e ;;
2830 armv4*|arm7*|arm9[24]*) echo -mv=4 ;;
2831 esac
2832 ;;
2833 -mfpu=neon) echo --float_support=vfpv3 --neon ;;
2834 -mfpu=vfp) echo --float_support=vfpv2 ;;
2835 -mfpu=vfpv3) echo --float_support=vfpv3 ;;
2836 -mfpu=vfpv3-d16) echo --float_support=vfpv3d16 ;;
2837 -msoft-float) echo --float_support=vfplib ;;
2838 -O[0-3]|-mf=*) echo $flag ;;
2839 -g) echo -g -mn ;;
2840 -pds=*) echo $flag ;;
2841 -D*|-I*) echo $flag ;;
2842 --gcc|--abi=*) echo $flag ;;
2843 -me) echo $flag ;;
2844 esac
2845 done
2846 }
2847
2848 probe_cc(){
2849 pfx=$1
2850 _cc=$2
2851
2852 unset _type _ident _cc_c _cc_e _cc_o _flags _cflags
2853 unset _ld_o _ldflags _ld_lib _ld_path
2854 unset _depflags _DEPCMD _DEPFLAGS
2855 _flags_filter=echo
2856
2857 if $_cc -v 2>&1 | grep -q '^gcc.*LLVM'; then
2858 _type=llvm_gcc
2859 gcc_extra_ver=$(expr "$($_cc --version | head -n1)" : '.*\((.*)\)')
2860 _ident="llvm-gcc $($_cc -dumpversion) $gcc_extra_ver"
2861 _depflags='-MMD -MF $(@:.o=.d) -MT $@'
2862 _cflags_speed='-O3'
2863 _cflags_size='-Os'
2864 elif $_cc -v 2>&1 | grep -qi ^gcc; then
2865 _type=gcc
2866 gcc_version=$($_cc --version | head -n1)
2867 gcc_basever=$($_cc -dumpversion)
2868 gcc_pkg_ver=$(expr "$gcc_version" : '[^ ]* \(([^)]*)\)')
2869 gcc_ext_ver=$(expr "$gcc_version" : ".*$gcc_pkg_ver $gcc_basever \\(.*\\)")
2870 _ident=$(cleanws "gcc $gcc_basever $gcc_pkg_ver $gcc_ext_ver")
2871 if ! $_cc -dumpversion | grep -q '^2\.'; then
2872 _depflags='-MMD -MF $(@:.o=.d) -MT $@'
2873 fi
2874 _cflags_speed='-O3'
2875 _cflags_size='-Os'
2876 elif $_cc --version 2>/dev/null | grep -q ^icc; then
2877 _type=icc
2878 _ident=$($_cc --version | head -n1)
2879 _depflags='-MMD'
2880 _cflags_speed='-O3'
2881 _cflags_size='-Os'
2882 _cflags_noopt='-O1'
2883 elif $_cc -v 2>&1 | grep -q xlc; then
2884 _type=xlc
2885 _ident=$($_cc -qversion 2>/dev/null | head -n1)
2886 _cflags_speed='-O5'
2887 _cflags_size='-O5 -qcompact'
2888 elif $_cc -V 2>/dev/null | grep -q Compaq; then
2889 _type=ccc
2890 _ident=$($_cc -V | head -n1 | cut -d' ' -f1-3)
2891 _DEPFLAGS='-M'
2892 _cflags_speed='-fast'
2893 _cflags_size='-O1'
2894 _flags_filter=ccc_flags
2895 elif $_cc --vsn 2>/dev/null | grep -Eq "ARM (C/C\+\+ )?Compiler"; then
2896 test -d "$sysroot" || die "No valid sysroot specified."
2897 _type=armcc
2898 _ident=$($_cc --vsn | grep -i build | head -n1 | sed 's/.*: //')
2899 armcc_conf="$PWD/armcc.conf"
2900 $_cc --arm_linux_configure \
2901 --arm_linux_config_file="$armcc_conf" \
2902 --configure_sysroot="$sysroot" \
2903 --configure_cpp_headers="$sysinclude" >>$logfile 2>&1 ||
2904 die "Error creating armcc configuration file."
2905 $_cc --vsn | grep -q RVCT && armcc_opt=rvct || armcc_opt=armcc
2906 _flags="--arm_linux_config_file=$armcc_conf --translate_gcc"
2907 as_default="${cross_prefix}gcc"
2908 _depflags='-MMD'
2909 _cflags_speed='-O3'
2910 _cflags_size='-Os'
2911 elif $_cc -version 2>/dev/null | grep -Eq 'TMS470|TI ARM'; then
2912 _type=tms470
2913 _ident=$($_cc -version | head -n1 | tr -s ' ')
2914 _flags='--gcc --abi=eabi -me'
2915 _cc_e='-ppl -fe=$@'
2916 _cc_o='-fe=$@'
2917 _depflags='-ppa -ppd=$(@:.o=.d)'
2918 _cflags_speed='-O3 -mf=5'
2919 _cflags_size='-O3 -mf=2'
2920 _flags_filter=tms470_flags
2921 elif $_cc -v 2>&1 | grep -q clang; then
2922 _type=clang
2923 _ident=$($_cc --version | head -n1)
2924 _depflags='-MMD -MF $(@:.o=.d) -MT $@'
2925 _cflags_speed='-O3'
2926 _cflags_size='-Os'
2927 elif $_cc -V 2>&1 | grep -q Sun; then
2928 _type=suncc
2929 _ident=$($_cc -V 2>&1 | head -n1 | cut -d' ' -f 2-)
2930 _DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< | sed -e "1s,^.*: ,$@: ," -e "\$$!s,\$$, \\\," -e "1!s,^.*: , ," > $(@:.o=.d)'
2931 _DEPFLAGS='-xM1 -xc99'
2932 _ldflags='-std=c99'
2933 _cflags_speed='-O5'
2934 _cflags_size='-O5 -xspace'
2935 _flags_filter=suncc_flags
2936 elif $_cc -v 2>&1 | grep -q 'PathScale\|Path64'; then
2937 _type=pathscale
2938 _ident=$($_cc -v 2>&1 | head -n1 | tr -d :)
2939 _depflags='-MMD -MF $(@:.o=.d) -MT $@'
2940 _cflags_speed='-O2'
2941 _cflags_size='-Os'
2942 _flags_filter='filter_out -Wdisabled-optimization'
2943 elif $_cc -v 2>&1 | grep -q Open64; then
2944 _type=open64
2945 _ident=$($_cc -v 2>&1 | head -n1 | tr -d :)
2946 _depflags='-MMD -MF $(@:.o=.d) -MT $@'
2947 _cflags_speed='-O2'
2948 _cflags_size='-Os'
2949 _flags_filter='filter_out -Wdisabled-optimization|-Wtype-limits|-fno-signed-zeros'
2950 elif $_cc -V 2>&1 | grep -q Portland; then
2951 _type=pgi
2952 _ident="PGI $($_cc -V 2>&1 | awk '/^pgcc/ { print $2; exit }')"
2953 opt_common='-alias=ansi -Mdse -Mlre -Mpre'
2954 _cflags_speed="-O3 -Mautoinline -Munroll=c:4 $opt_common"
2955 _cflags_size="-O2 -Munroll=c:1 $opt_common"
2956 _cflags_noopt="-O1"
2957 _flags_filter=pgi_flags
2958 elif $_cc 2>&1 | grep -q 'Microsoft.*ARM.*Assembler'; then
2959 _type=armasm
2960 _ident=$($_cc | head -n1)
2961 # 4509: "This form of conditional instruction is deprecated"
2962 _flags="-nologo -ignore 4509"
2963 _flags_filter=armasm_flags
2964 elif $_cc 2>&1 | grep -q Microsoft; then
2965 _type=msvc
2966 _ident=$($cc 2>&1 | head -n1)
2967 _DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< 2>&1 | awk '\''/including/ { sub(/^.*file: */, ""); gsub(/\\/, "/"); if (!match($$0, / /)) print "$@:", $$0 }'\'' > $(@:.o=.d)'
2968 _DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -showIncludes -Zs'
2969 _cflags_speed="-O2"
2970 _cflags_size="-O1"
2971 if $_cc 2>&1 | grep -q Linker; then
2972 _ld_o='-out:$@'
2973 else
2974 _ld_o='-Fe$@'
2975 fi
2976 _cc_o='-Fo$@'
2977 _cc_e='-P -Fi$@'
2978 _flags_filter=msvc_flags
2979 _ld_lib='lib%.a'
2980 _ld_path='-libpath:'
2981 _flags='-nologo'
2982 _cflags='-D_USE_MATH_DEFINES -D_CRT_SECURE_NO_WARNINGS -Dinline=__inline -FIstdlib.h -Dstrtoll=_strtoi64'
2983 if [ $pfx = hostcc ]; then
2984 append _cflags -Dsnprintf=_snprintf
2985 fi
2986 elif $_cc 2>&1 | grep -q Intel; then
2987 _type=icl
2988 _ident=$($cc 2>&1 | head -n1)
2989 _depflags='-QMMD -QMF$(@:.o=.d) -QMT$@'
2990 # Not only is O3 broken on 13.x+ but it is slower on all previous
2991 # versions (tested) as well.
2992 _cflags_speed="-O2"
2993 _cflags_size="-O1 -Oi" # -O1 without -Oi miscompiles stuff
2994 if $_cc 2>&1 | grep -q Linker; then
2995 _ld_o='-out:$@'
2996 else
2997 _ld_o='-Fe$@'
2998 fi
2999 _cc_o='-Fo$@'
3000 _cc_e='-P'
3001 _flags_filter=icl_flags
3002 _ld_lib='lib%.a'
3003 _ld_path='-libpath:'
3004 # -Qdiag-error to make icl error when seeing certain unknown arguments
3005 _flags='-nologo -Qdiag-error:4044,10157'
3006 # -Qvec- -Qsimd- to prevent miscompilation, -GS for consistency
3007 # with MSVC which enables it by default.
3008 _cflags='-D_USE_MATH_DEFINES -FIstdlib.h -Dstrtoll=_strtoi64 -Qms0 -Qvec- -Qsimd- -GS'
3009 if [ $pfx = hostcc ]; then
3010 append _cflags -Dsnprintf=_snprintf
3011 fi
3012 elif $_cc --version 2>/dev/null | grep -q ^cparser; then
3013 _type=cparser
3014 _ident=$($_cc --version | head -n1)
3015 _depflags='-MMD'
3016 _cflags_speed='-O4'
3017 _cflags_size='-O2'
3018 _flags_filter=cparser_flags
3019 fi
3020
3021 eval ${pfx}_type=\$_type
3022 eval ${pfx}_ident=\$_ident
3023 }
3024
3025 set_ccvars(){
3026 eval ${1}_C=\${_cc_c-\${${1}_C}}
3027 eval ${1}_E=\${_cc_e-\${${1}_E}}
3028 eval ${1}_O=\${_cc_o-\${${1}_O}}
3029
3030 if [ -n "$_depflags" ]; then
3031 eval ${1}_DEPFLAGS=\$_depflags
3032 else
3033 eval ${1}DEP=\${_DEPCMD:-\$DEPCMD}
3034 eval ${1}DEP_FLAGS=\${_DEPFLAGS:-\$DEPFLAGS}
3035 eval DEP${1}FLAGS=\$_flags
3036 fi
3037 }
3038
3039 probe_cc cc "$cc"
3040 cflags_filter=$_flags_filter
3041 cflags_speed=$_cflags_speed
3042 cflags_size=$_cflags_size
3043 cflags_noopt=$_cflags_noopt
3044 add_cflags $_flags $_cflags
3045 cc_ldflags=$_ldflags
3046 set_ccvars CC
3047
3048 probe_cc hostcc "$host_cc"
3049 host_cflags_filter=$_flags_filter
3050 add_host_cflags $_flags $_cflags
3051 set_ccvars HOSTCC
3052
3053 test -n "$cc_type" && enable $cc_type ||
3054 warn "Unknown C compiler $cc, unable to select optimal CFLAGS"
3055
3056 : ${as_default:=$cc}
3057 : ${dep_cc_default:=$cc}
3058 : ${ld_default:=$cc}
3059 : ${host_ld_default:=$host_cc}
3060 set_default ar as dep_cc ld host_ld
3061
3062 probe_cc as "$as"
3063 asflags_filter=$_flags_filter
3064 add_asflags $_flags $_cflags
3065 set_ccvars AS
3066
3067 probe_cc ld "$ld"
3068 ldflags_filter=$_flags_filter
3069 add_ldflags $_flags $_ldflags
3070 test "$cc_type" != "$ld_type" && add_ldflags $cc_ldflags
3071 LD_O=${_ld_o-$LD_O}
3072 LD_LIB=${_ld_lib-$LD_LIB}
3073 LD_PATH=${_ld_path-$LD_PATH}
3074
3075 probe_cc hostld "$host_ld"
3076 host_ldflags_filter=$_flags_filter
3077 add_host_ldflags $_flags $_ldflags
3078 HOSTLD_O=${_ld_o-$HOSTLD_O}
3079
3080 if [ -z "$CC_DEPFLAGS" ] && [ "$dep_cc" != "$cc" ]; then
3081 probe_cc depcc "$dep_cc"
3082 CCDEP=${_DEPCMD:-$DEPCMD}
3083 CCDEP_FLAGS=${_DEPFLAGS:=$DEPFLAGS}
3084 DEPCCFLAGS=$_flags
3085 fi
3086
3087 if $ar 2>&1 | grep -q Microsoft; then
3088 arflags="-nologo"
3089 ar_o='-out:$@'
3090 elif $ar 2>&1 | grep -q 'Texas Instruments'; then
3091 arflags="rq"
3092 ar_o='$@'
3093 elif $ar 2>&1 | grep -q 'Usage: ar.*-X.*any'; then
3094 arflags='-Xany -r -c'
3095 ar_o='$@'
3096 else
3097 arflags="rc"
3098 ar_o='$@'
3099 fi
3100
3101 add_cflags $extra_cflags
3102 add_asflags $extra_cflags
3103
3104 if test -n "$sysroot"; then
3105 case "$cc_type" in
3106 gcc|llvm_gcc|clang)
3107 add_cppflags --sysroot="$sysroot"
3108 add_ldflags --sysroot="$sysroot"
3109 ;;
3110 tms470)
3111 add_cppflags -I"$sysinclude"
3112 add_ldflags --sysroot="$sysroot"
3113 ;;
3114 esac
3115 fi
3116
3117 if test "$cpu" = host; then
3118 enabled cross_compile &&
3119 die "--cpu=host makes no sense when cross-compiling."
3120
3121 case "$cc_type" in
3122 gcc|llvm_gcc)
3123 check_native(){
3124 $cc $1=native -v -c -o $TMPO $TMPC >$TMPE 2>&1 || return
3125 sed -n "/cc1.*$1=/{
3126 s/.*$1=\\([^ ]*\\).*/\\1/
3127 p
3128 q
3129 }" $TMPE
3130 }
3131 cpu=$(check_native -march || check_native -mcpu)
3132 ;;
3133 esac
3134
3135 test "${cpu:-host}" = host &&
3136 die "--cpu=host not supported with compiler $cc"
3137 fi
3138
3139 # Deal with common $arch aliases
3140 case "$arch" in
3141 aarch64|arm64)
3142 arch="aarch64"
3143 ;;
3144 arm*)
3145 arch="arm"
3146 ;;
3147 mips*|IP*)
3148 arch="mips"
3149 ;;
3150 parisc*|hppa*)
3151 arch="parisc"
3152 ;;
3153 "Power Macintosh"|ppc*|powerpc*)
3154 arch="ppc"
3155 ;;
3156 s390|s390x)
3157 arch="s390"
3158 ;;
3159 sh4|sh)
3160 arch="sh4"
3161 ;;
3162 sun4u|sparc*)
3163 arch="sparc"
3164 ;;
3165 tilegx|tile-gx)
3166 arch="tilegx"
3167 ;;
3168 i[3-6]86|i86pc|BePC|x86pc|x86_64|amd64)
3169 arch="x86"
3170 ;;
3171 esac
3172
3173 is_in $arch $ARCH_LIST || warn "unknown architecture $arch"
3174 enable $arch
3175
3176 # Add processor-specific flags
3177 if enabled aarch64; then
3178
3179 case $cpu in
3180 armv*)
3181 cpuflags="-march=$cpu"
3182 ;;
3183 *)
3184 cpuflags="-mcpu=$cpu"
3185 ;;
3186 esac
3187
3188 elif enabled alpha; then
3189
3190 cpuflags="-mcpu=$cpu"
3191
3192 elif enabled arm; then
3193
3194 check_arm_arch() {
3195 check_cpp_condition stddef.h \
3196 "defined __ARM_ARCH_${1}__ || defined __TARGET_ARCH_${2:-$1}" \
3197 $cpuflags
3198 }
3199
3200 probe_arm_arch() {
3201 if check_arm_arch 4; then echo armv4;
3202 elif check_arm_arch 4T; then echo armv4t;
3203 elif check_arm_arch 5; then echo armv5;
3204 elif check_arm_arch 5E; then echo armv5e;
3205 elif check_arm_arch 5T; then echo armv5t;
3206 elif check_arm_arch 5TE; then echo armv5te;
3207 elif check_arm_arch 5TEJ; then echo armv5te;
3208 elif check_arm_arch 6; then echo armv6;
3209 elif check_arm_arch 6J; then echo armv6j;
3210 elif check_arm_arch 6K; then echo armv6k;
3211 elif check_arm_arch 6Z; then echo armv6z;
3212 elif check_arm_arch 6ZK; then echo armv6zk;
3213 elif check_arm_arch 6T2; then echo armv6t2;
3214 elif check_arm_arch 7; then echo armv7;
3215 elif check_arm_arch 7A 7_A; then echo armv7-a;
3216 elif check_arm_arch 7S; then echo armv7-a;
3217 elif check_arm_arch 7R 7_R; then echo armv7-r;
3218 elif check_arm_arch 7M 7_M; then echo armv7-m;
3219 elif check_arm_arch 7EM 7E_M; then echo armv7-m;
3220 elif check_arm_arch 8A 8_A; then echo armv8-a;
3221 fi
3222 }
3223
3224 [ "$cpu" = generic ] && cpu=$(probe_arm_arch)
3225
3226 case $cpu in
3227 armv*)
3228 cpuflags="-march=$cpu"
3229 subarch=$(echo $cpu | sed 's/[^a-z0-9]//g')
3230 ;;
3231 *)
3232 cpuflags="-mcpu=$cpu"
3233 case $cpu in
3234 cortex-a*) subarch=armv7a ;;
3235 cortex-r*) subarch=armv7r ;;
3236 cortex-m*) enable thumb; subarch=armv7m ;;
3237 arm11*) subarch=armv6 ;;
3238 arm[79]*e*|arm9[24]6*|arm96*|arm102[26]) subarch=armv5te ;;
3239 armv4*|arm7*|arm9[24]*) subarch=armv4 ;;
3240 *) subarch=$(probe_arm_arch) ;;
3241 esac
3242 ;;
3243 esac
3244
3245 case "$subarch" in
3246 armv5t*) enable fast_clz ;;
3247 armv[6-8]*) enable fast_clz fast_unaligned ;;
3248 esac
3249
3250 elif enabled avr32; then
3251
3252 case $cpu in
3253 ap7[02]0[0-2])
3254 subarch="avr32_ap"
3255 cpuflags="-mpart=$cpu"
3256 ;;
3257 ap)
3258 subarch="avr32_ap"
3259 cpuflags="-march=$cpu"
3260 ;;
3261 uc3[ab]*)
3262 subarch="avr32_uc"
3263 cpuflags="-mcpu=$cpu"
3264 ;;
3265 uc)
3266 subarch="avr32_uc"
3267 cpuflags="-march=$cpu"
3268 ;;
3269 esac
3270
3271 elif enabled bfin; then
3272
3273 cpuflags="-mcpu=$cpu"
3274
3275 elif enabled mips; then
3276
3277 cpuflags="-march=$cpu"
3278
3279 elif enabled ppc; then
3280
3281 disable ldbrx
3282
3283 case $(tolower $cpu) in
3284 601|ppc601|powerpc601)
3285 cpuflags="-mcpu=601"
3286 disable altivec
3287 ;;
3288 603*|ppc603*|powerpc603*)
3289 cpuflags="-mcpu=603"
3290 disable altivec
3291 ;;
3292 604*|ppc604*|powerpc604*)
3293 cpuflags="-mcpu=604"
3294 disable altivec
3295 ;;
3296 g3|75*|ppc75*|powerpc75*)
3297 cpuflags="-mcpu=750"
3298 disable altivec
3299 ;;
3300 g4|745*|ppc745*|powerpc745*)
3301 cpuflags="-mcpu=7450"
3302 ;;
3303 74*|ppc74*|powerpc74*)
3304 cpuflags="-mcpu=7400"
3305 ;;
3306 g5|970|ppc970|powerpc970)
3307 cpuflags="-mcpu=970"
3308 ;;
3309 power[3-7]*)
3310 cpuflags="-mcpu=$cpu"
3311 ;;
3312 cell)
3313 cpuflags="-mcpu=cell"
3314 enable ldbrx
3315 ;;
3316 e500mc)
3317 cpuflags="-mcpu=e500mc"
3318 disable altivec
3319 ;;
3320 e500v2)
3321 cpuflags="-mcpu=8548 -mhard-float -mfloat-gprs=double"
3322 disable altivec
3323 disable dcbzl
3324 ;;
3325 e500)
3326 cpuflags="-mcpu=8540 -mhard-float"
3327 disable altivec
3328 disable dcbzl
3329 ;;
3330 esac
3331
3332 elif enabled sparc; then
3333
3334 case $cpu in
3335 cypress|f93[04]|tsc701|sparcl*|supersparc|hypersparc|niagara|v[789])
3336 cpuflags="-mcpu=$cpu"
3337 ;;
3338 ultrasparc*|niagara[234])
3339 cpuflags="-mcpu=$cpu"
3340 ;;
3341 esac
3342
3343 elif enabled x86; then
3344
3345 case $cpu in
3346 i[345]86|pentium)
3347 cpuflags="-march=$cpu"
3348 disable i686
3349 disable mmx
3350 ;;
3351 # targets that do NOT support nopl and conditional mov (cmov)
3352 pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
3353 cpuflags="-march=$cpu"
3354 disable i686
3355 ;;
3356 # targets that do support nopl and conditional mov (cmov)
3357 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*)
3358 cpuflags="-march=$cpu"
3359 enable i686
3360 enable fast_cmov
3361 ;;
3362 # targets that do support conditional mov but on which it's slow
3363 pentium4|pentium4m|prescott|nocona)
3364 cpuflags="-march=$cpu"
3365 enable i686
3366 disable fast_cmov
3367 ;;
3368 esac
3369
3370 fi
3371
3372 if [ "$cpu" != generic ]; then
3373 add_cflags $cpuflags
3374 add_asflags $cpuflags
3375 fi
3376
3377 # compiler sanity check
3378 check_exec <<EOF
3379 int main(void){ return 0; }
3380 EOF
3381 if test "$?" != 0; then
3382 echo "$cc is unable to create an executable file."
3383 if test -z "$cross_prefix" && ! enabled cross_compile ; then
3384 echo "If $cc is a cross-compiler, use the --enable-cross-compile option."
3385 echo "Only do this if you know what cross compiling means."
3386 fi
3387 die "C compiler test failed."
3388 fi
3389
3390 add_cppflags -D_ISOC99_SOURCE
3391 check_cflags -std=c99
3392 check_cc -D_FILE_OFFSET_BITS=64 <<EOF && add_cppflags -D_FILE_OFFSET_BITS=64
3393 #include <stdlib.h>
3394 EOF
3395 check_cc -D_LARGEFILE_SOURCE <<EOF && add_cppflags -D_LARGEFILE_SOURCE
3396 #include <stdlib.h>
3397 EOF
3398
3399 add_host_cppflags -D_ISOC99_SOURCE
3400 check_host_cflags -std=c99
3401 check_host_cflags -Wall
3402 check_host_cflags -O3
3403
3404 check_64bit(){
3405 arch32=$1
3406 arch64=$2
3407 expr=$3
3408 check_code cc "" "int test[2*($expr) - 1]" &&
3409 subarch=$arch64 || subarch=$arch32
3410 }
3411
3412 case "$arch" in
3413 aarch64|alpha|ia64)
3414 spic=$shared
3415 ;;
3416 mips)
3417 check_64bit mips mips64 '_MIPS_SIM > 1'
3418 spic=$shared
3419 ;;
3420 parisc)
3421 check_64bit parisc parisc64 'sizeof(void *) > 4'
3422 spic=$shared
3423 ;;
3424 ppc)
3425 check_64bit ppc ppc64 'sizeof(void *) > 4'
3426 spic=$shared
3427 ;;
3428 s390)
3429 check_64bit s390 s390x 'sizeof(void *) > 4'
3430 spic=$shared
3431 ;;
3432 sparc)
3433 check_64bit sparc sparc64 'sizeof(void *) > 4'
3434 spic=$shared
3435 ;;
3436 x86)
3437 check_64bit x86_32 x86_64 'sizeof(void *) > 4'
3438 if test "$subarch" = "x86_64"; then
3439 spic=$shared
3440 fi
3441 ;;
3442 esac
3443
3444 enable $subarch
3445 enabled spic && enable_weak pic
3446
3447 # OS specific
3448 case $target_os in
3449 aix)
3450 SHFLAGS=-shared
3451 add_cppflags '-I\$(SRC_PATH)/compat/aix'
3452 enabled shared && add_ldflags -Wl,-brtl
3453 ;;
3454 android)
3455 disable symver
3456 enable section_data_rel_ro
3457 SLIB_INSTALL_NAME='$(SLIBNAME)'
3458 SLIB_INSTALL_LINKS=
3459 # soname not set on purpose
3460 SHFLAGS=-shared
3461 ;;
3462 haiku)
3463 prefix_default="/boot/common"
3464 network_extralibs="-lnetwork"
3465 host_libs=
3466 ;;
3467 sunos)
3468 SHFLAGS='-shared -Wl,-h,$$(@F)'
3469 enabled x86 && SHFLAGS="-mimpure-text $SHFLAGS"
3470 network_extralibs="-lsocket -lnsl"
3471 # When using suncc to build, the Solaris linker will mark
3472 # an executable with each instruction set encountered by
3473 # the Solaris assembler. As our libraries contain their own
3474 # guards for processor-specific code, instead suppress
3475 # generation of the HWCAPS ELF section on Solaris x86 only.
3476 enabled_all suncc x86 &&
3477 echo "hwcap_1 = OVERRIDE;" > mapfile &&
3478 add_ldflags -Wl,-M,mapfile
3479 nm_default='nm -P -g'
3480 ;;
3481 netbsd)
3482 disable symver
3483 oss_indev_extralibs="-lossaudio"
3484 oss_outdev_extralibs="-lossaudio"
3485 ;;
3486 openbsd|bitrig)
3487 disable symver
3488 SHFLAGS='-shared'
3489 SLIB_INSTALL_NAME='$(SLIBNAME).$(LIBMAJOR).$(LIBMINOR)'
3490 SLIB_INSTALL_LINKS=
3491 oss_indev_extralibs="-lossaudio"
3492 oss_outdev_extralibs="-lossaudio"
3493 ;;
3494 dragonfly)
3495 disable symver
3496 ;;
3497 freebsd)
3498 ;;
3499 bsd/os)
3500 add_extralibs -lpoll -lgnugetopt
3501 ;;
3502 darwin)
3503 enabled ppc && add_asflags -force_cpusubtype_ALL
3504 SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR),-current_version,$(LIBVERSION),-compatibility_version,$(LIBMAJOR)'
3505 enabled x86_32 && append SHFLAGS -Wl,-read_only_relocs,suppress
3506 add_ldflags -Wl,-dynamic,-search_paths_first
3507 SLIBSUF=".dylib"
3508 SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME).$(LIBVERSION)$(SLIBSUF)'
3509 SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME).$(LIBMAJOR)$(SLIBSUF)'
3510 objformat="macho"
3511 enabled x86_64 && objformat="macho64"
3512 enabled_any pic shared ||
3513 { check_cflags -mdynamic-no-pic && add_asflags -mdynamic-no-pic; }
3514 ;;
3515 mingw32*)
3516 if test $target_os = "mingw32ce"; then
3517 disable network
3518 else
3519 target_os=mingw32
3520 fi
3521 LIBTARGET=i386
3522 if enabled x86_64; then
3523 LIBTARGET="i386:x86-64"
3524 elif enabled arm; then
3525 LIBTARGET=arm-wince
3526 fi
3527 check_ldflags -Wl,--nxcompat
3528 check_ldflags -Wl,--dynamicbase
3529 shlibdir_default="$bindir_default"
3530 SLIBPREF=""
3531 SLIBSUF=".dll"
3532 SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
3533 SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
3534 SLIB_EXTRA_CMD=-'sed -e "s/ @[^ ]*//" $$(@:$(SLIBSUF)=.orig.def) > $$(@:$(SLIBSUF)=.def); $(DLLTOOL) -m $(LIBTARGET) -d $$(@:$(SLIBSUF)=.def) -l $(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib) -D $(SLIBNAME_WITH_MAJOR)'
3535 SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
3536 SLIB_INSTALL_LINKS=
3537 SLIB_INSTALL_EXTRA_SHLIB='$(SLIBNAME:$(SLIBSUF)=.lib)'
3538 SLIB_INSTALL_EXTRA_LIB='lib$(SLIBNAME:$(SLIBSUF)=.dll.a) $(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.def)'
3539 SHFLAGS='-shared -Wl,--output-def,$$(@:$(SLIBSUF)=.orig.def) -Wl,--out-implib,$(SUBDIR)lib$(SLIBNAME:$(SLIBSUF)=.dll.a) -Wl,--enable-runtime-pseudo-reloc -Wl,--enable-auto-image-base'
3540 objformat="win32"
3541 dlltool="${cross_prefix}dlltool"
3542 ranlib=:
3543 enable dos_paths
3544 ;;
3545 win32|win64)
3546 disable symver
3547 if enabled shared; then
3548 # Link to the import library instead of the normal static library
3549 # for shared libs.
3550 LD_LIB='%.lib'
3551 # Cannot build both shared and static libs with MSVC or icl.
3552 disable static
3553 fi
3554 shlibdir_default="$bindir_default"
3555 SLIBPREF=""
3556 SLIBSUF=".dll"
3557 SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
3558 SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
3559 SLIB_CREATE_DEF_CMD='$(SRC_PATH)/compat/windows/makedef $(SUBDIR)lib$(NAME).ver $(OBJS) > $$(@:$(SLIBSUF)=.def)'
3560 SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
3561 SLIB_INSTALL_LINKS=
3562 SLIB_INSTALL_EXTRA_SHLIB='$(SLIBNAME:$(SLIBSUF)=.lib)'
3563 SLIB_INSTALL_EXTRA_LIB='$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.def)'
3564 SHFLAGS='-dll -def:$$(@:$(SLIBSUF)=.def) -implib:$(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib)'
3565 objformat="win32"
3566 ranlib=:
3567 enable dos_paths
3568 ;;
3569 cygwin*)
3570 target_os=cygwin
3571 shlibdir_default="$bindir_default"
3572 SLIBPREF="cyg"
3573 SLIBSUF=".dll"
3574 SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
3575 SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
3576 SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
3577 SLIB_INSTALL_LINKS=
3578 SLIB_INSTALL_EXTRA_LIB='lib$(FULLNAME).dll.a'
3579 SHFLAGS='-shared -Wl,--out-implib,$(SUBDIR)lib$(FULLNAME).dll.a'
3580 objformat="win32"
3581 enable dos_paths
3582 ;;
3583 *-dos|freedos|opendos)
3584 network_extralibs="-lsocket"
3585 objformat="coff"
3586 enable dos_paths
3587 add_cppflags -U__STRICT_ANSI__
3588 ;;
3589 linux)
3590 enable dv1394
3591 enable section_data_rel_ro
3592 ;;
3593 irix*)
3594 target_os=irix
3595 ranlib="echo ignoring ranlib"
3596 ;;
3597 os/2*)
3598 ln_s="cp -f"
3599 objformat="aout"
3600 add_cppflags -D_GNU_SOURCE
3601 add_ldflags -Zomf -Zbin-files -Zargs-wild -Zmap
3602 SHFLAGS='$(SUBDIR)$(NAME).def -Zdll -Zomf'
3603 LIBSUF="_s.a"
3604 SLIBPREF=""
3605 SLIBSUF=".dll"
3606 SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
3607 SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(shell echo $(NAME) | cut -c1-6)$(LIBMAJOR)$(SLIBSUF)'
3608 SLIB_CREATE_DEF_CMD='echo LIBRARY $(SLIBNAME_WITH_MAJOR) INITINSTANCE TERMINSTANCE > $(SUBDIR)$(NAME).def; \
3609 echo PROTMODE >> $(SUBDIR)$(NAME).def; \
3610 echo CODE PRELOAD MOVEABLE DISCARDABLE >> $(SUBDIR)$(NAME).def; \
3611 echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $(SUBDIR)$(NAME).def; \
3612 echo EXPORTS >> $(SUBDIR)$(NAME).def; \
3613 emxexp -o $(OBJS) >> $(SUBDIR)$(NAME).def'
3614 SLIB_EXTRA_CMD='emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(NAME).def; \
3615 emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib $(SUBDIR)$(NAME).def;'
3616 SLIB_INSTALL_EXTRA_LIB='$(LIBPREF)$(NAME)_dll.a $(LIBPREF)$(NAME)_dll.lib'
3617 enable dos_paths
3618 ;;
3619 gnu/kfreebsd)
3620 add_cppflags -D_BSD_SOURCE
3621 ;;
3622 gnu)
3623 ;;
3624 qnx)
3625 add_cppflags -D_QNX_SOURCE
3626 network_extralibs="-lsocket"
3627 ;;
3628 symbian)
3629 SLIBSUF=".dll"
3630 enable dos_paths
3631 add_cflags --include=$sysinclude/gcce/gcce.h -fvisibility=default
3632 add_cppflags -D__GCCE__ -D__SYMBIAN32__ -DSYMBIAN_OE_POSIX_SIGNALS
3633 add_ldflags -Wl,--target1-abs,--no-undefined \
3634 -Wl,-Ttext,0x80000,-Tdata,0x1000000 -shared \
3635 -Wl,--entry=_E32Startup -Wl,-u,_E32Startup
3636 add_extralibs -l:eexe.lib -l:usrt2_2.lib -l:dfpaeabi.dso \
3637 -l:drtaeabi.dso -l:scppnwdl.dso -lsupc++ -lgcc \
3638 -l:libc.dso -l:libm.dso -l:euser.dso -l:libcrt0.lib
3639 ;;
3640 osf1)
3641 add_cppflags -D_OSF_SOURCE -D_POSIX_PII -D_REENTRANT
3642 ;;
3643 minix)
3644 ;;
3645 plan9)
3646 add_cppflags -D_C99_SNPRINTF_EXTENSION \
3647 -D_REENTRANT_SOURCE \
3648 -D_RESEARCH_SOURCE \
3649 -DFD_SETSIZE=96 \
3650 -DHAVE_SOCK_OPTS
3651 add_compat strtod.o strtod=avpriv_strtod
3652 network_extralibs='-lbsd'
3653 exeobjs=compat/plan9/main.o
3654 cp_f='cp'
3655 ;;
3656 none)
3657 ;;
3658 *)
3659 die "Unknown OS '$target_os'."
3660 ;;
3661 esac
3662
3663 # determine libc flavour
3664
3665 probe_libc(){
3666 pfx=$1
3667 pfx_no_=${pfx%_}
3668 # uclibc defines __GLIBC__, so it needs to be checked before glibc.
3669 if check_${pfx}cpp_condition features.h "defined __UCLIBC__"; then
3670 eval ${pfx}libc_type=uclibc
3671 add_${pfx}cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
3672 elif check_${pfx}cpp_condition features.h "defined __GLIBC__"; then
3673 eval ${pfx}libc_type=glibc
3674 add_${pfx}cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
3675 # MinGW headers can be installed on Cygwin, so check for newlib first.
3676 elif check_${pfx}cpp_condition newlib.h "defined _NEWLIB_VERSION"; then
3677 eval ${pfx}libc_type=newlib
3678 add_${pfx}cppflags -U__STRICT_ANSI__
3679 # MinGW64 is backwards compatible with MinGW32, so check for it first.
3680 elif check_${pfx}cpp_condition _mingw.h "defined __MINGW64_VERSION_MAJOR"; then
3681 eval ${pfx}libc_type=mingw64
3682 add_${pfx}cppflags -U__STRICT_ANSI__ -D__USE_MINGW_ANSI_STDIO=1
3683 eval test \$${pfx_no_}cc_type = "gcc" &&
3684 add_${pfx}cppflags -D__printf__=__gnu_printf__
3685 elif check_${pfx}cpp_condition _mingw.h "defined __MINGW_VERSION" ||
3686 check_${pfx}cpp_condition _mingw.h "defined __MINGW32_VERSION"; then
3687 eval ${pfx}libc_type=mingw32
3688 check_${pfx}cpp_condition _mingw.h "__MINGW32_MAJOR_VERSION > 3 || \
3689 (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" ||
3690 die "ERROR: MinGW32 runtime version must be >= 3.15."
3691 add_${pfx}cppflags -U__STRICT_ANSI__ -D__USE_MINGW_ANSI_STDIO=1
3692 eval test \$${pfx_no_}cc_type = "gcc" &&
3693 add_${pfx}cppflags -D__printf__=__gnu_printf__
3694 elif check_${pfx}cpp_condition crtversion.h "defined _VC_CRT_MAJOR_VERSION"; then
3695 eval ${pfx}libc_type=msvcrt
3696 # The MSVC 2010 headers (Win 7.0 SDK) set _WIN32_WINNT to
3697 # 0x601 by default unless something else is set by the user.
3698 # This can easily lead to us detecting functions only present
3699 # in such new versions and producing binaries requiring windows 7.0.
3700 # Therefore explicitly set the default to XP unless the user has
3701 # set something else on the command line.
3702 check_${pfx}cpp_condition stdlib.h "defined(_WIN32_WINNT)" ||
3703 add_