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