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