configure: make jack depend on pthreads
[libav.git] / configure
CommitLineData
aeb29222 1#!/bin/sh
0f3cb305 2#
070c5d0f 3# Libav configure script
f57620d5 4#
949906ea
DB
5# Copyright (c) 2000-2002 Fabrice Bellard
6# Copyright (c) 2005-2008 Diego Biurrun
7# Copyright (c) 2005-2008 Mans Rullgard
0f3cb305 8#
cf9d24ad 9
31e647f8 10# Prevent locale nonsense from breaking basic text processing.
79ab96ba
DB
11LC_ALL=C
12export LC_ALL
31e647f8 13
cde2d79a 14# make sure we are running under a compatible shell
c21d6325
MR
15# try to make this part work with most shells
16
17try_exec(){
0dbe81bb 18 echo "Trying shell $1"
2270b4b2 19 type "$1" > /dev/null 2>&1 && exec "$@"
c21d6325
MR
20}
21
5237ce67 22unset foo
2270b4b2 23(: ${foo%%bar}) 2> /dev/null
0dbe81bb
MR
24E1="$?"
25
2270b4b2 26(: ${foo?}) 2> /dev/null
0dbe81bb
MR
27E2="$?"
28
29if test "$E1" != 0 || test "$E2" = 0; then
30 echo "Broken shell detected. Trying alternatives."
c21d6325
MR
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" "$@"
cde2d79a
MR
43 fi
44 echo "No compatible shell script interpreter found."
fc53da20 45 echo "This configure script requires a POSIX-compatible shell"
c21d6325 46 echo "such as bash or ksh."
070c5d0f 47 echo "THIS IS NOT A BUG IN LIBAV, DO NOT REPORT IT AS SUCH."
505dfb09 48 echo "Instead, install a working POSIX-compatible shell."
070c5d0f 49 echo "Disabling this configure test will create a broken Libav."
c21d6325
MR
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
cde2d79a
MR
54 exit 1
55fi
56
afab4c42
MR
57test -d /usr/xpg4/bin && PATH=/usr/xpg4/bin:$PATH
58
74c53c2d 59show_help(){
06454877
MR
60cat <<EOF
61Usage: configure [options]
62Options: [defaults in brackets after descriptions]
63
64Standard options:
65 --help print this message
19bd477d 66 --logfile=FILE log tests and output to FILE [config.log]
06454877
MR
67 --disable-logging do not log configure debug information
68 --prefix=PREFIX install in PREFIX [$prefix]
69 --bindir=DIR install binaries in DIR [PREFIX/bin]
6291d7e4 70 --datadir=DIR install data files in DIR [PREFIX/share/avconv]
06454877
MR
71 --libdir=DIR install libs in DIR [PREFIX/lib]
72 --shlibdir=DIR install shared libs in DIR [PREFIX/lib]
73 --incdir=DIR install includes in DIR [PREFIX/include]
74 --mandir=DIR install man page in DIR [PREFIX/share/man]
75
76Configuration options:
77 --disable-static do not build static libraries [no]
78 --enable-shared build shared libraries [no]
79 --enable-gpl allow use of GPL code, the resulting libs
80 and binaries will be under GPL [no]
81 --enable-version3 upgrade (L)GPL to version 3 [no]
82 --enable-nonfree allow use of nonfree code, the resulting libs
83 and binaries will be unredistributable [no]
84 --disable-doc do not build documentation
85 --disable-ffmpeg disable ffmpeg build
6291d7e4 86 --disable-avconv disable avconv build
266463da 87 --disable-avplay disable avplay build
9e12f0bf 88 --disable-avprobe disable avprobe build
4d58e4cb 89 --disable-avserver disable avserver build
5a0f7131
MR
90 --disable-avdevice disable libavdevice build
91 --disable-avcodec disable libavcodec build
92 --disable-avformat disable libavformat build
93 --disable-swscale disable libswscale build
014f8d81 94 --enable-postproc enable libpostproc build (deprecated) [no]
cccc039f 95 --disable-avfilter disable video filter support [no]
0dbfc1db 96 --disable-pthreads disable pthreads [auto]
7b7b220c 97 --disable-w32threads disable Win32 threads [auto]
06454877
MR
98 --enable-x11grab enable X11 grabbing [no]
99 --disable-network disable network support [no]
06454877
MR
100 --enable-gray enable full grayscale support (slower color)
101 --disable-swscale-alpha disable alpha channel support in swscale
102 --disable-fastdiv disable table-based division
103 --enable-small optimize for size instead of speed
104 --disable-aandct disable AAN DCT code
7f3f5f46 105 --disable-dct disable DCT code
06454877
MR
106 --disable-fft disable FFT code
107 --disable-golomb disable Golomb code
3447f12d 108 --disable-huffman disable Huffman code
06454877
MR
109 --disable-lpc disable LPC code
110 --disable-mdct disable MDCT code
111 --disable-rdft disable RDFT code
dcb73592 112 --enable-vaapi enable VAAPI code
ac3dbb4d 113 --enable-vda enable VDA code
e8f6bd4b 114 --enable-vdpau enable VDPAU code
92c6a099 115 --disable-dxva2 disable DXVA2 code
06454877
MR
116 --enable-runtime-cpudetect detect cpu capabilities at runtime (bigger binary)
117 --enable-hardcoded-tables use hardcoded tables instead of runtime generation
8cfbbd92
RB
118 --disable-safe-bitstream-reader
119 disable buffer boundary checking in bitreaders
120 (faster, but may crash)
06454877 121 --enable-memalign-hack emulate memalign, interferes with memory debuggers
bb55e3a3 122 --disable-everything disable all components listed below
06454877
MR
123 --disable-encoder=NAME disable encoder NAME
124 --enable-encoder=NAME enable encoder NAME
125 --disable-encoders disable all encoders
126 --disable-decoder=NAME disable decoder NAME
127 --enable-decoder=NAME enable decoder NAME
128 --disable-decoders disable all decoders
129 --disable-hwaccel=NAME disable hwaccel NAME
130 --enable-hwaccel=NAME enable hwaccel NAME
131 --disable-hwaccels disable all hwaccels
132 --disable-muxer=NAME disable muxer NAME
133 --enable-muxer=NAME enable muxer NAME
134 --disable-muxers disable all muxers
135 --disable-demuxer=NAME disable demuxer NAME
136 --enable-demuxer=NAME enable demuxer NAME
137 --disable-demuxers disable all demuxers
138 --enable-parser=NAME enable parser NAME
139 --disable-parser=NAME disable parser NAME
140 --disable-parsers disable all parsers
141 --enable-bsf=NAME enable bitstream filter NAME
142 --disable-bsf=NAME disable bitstream filter NAME
143 --disable-bsfs disable all bitstream filters
144 --enable-protocol=NAME enable protocol NAME
145 --disable-protocol=NAME disable protocol NAME
146 --disable-protocols disable all protocols
147 --disable-indev=NAME disable input device NAME
148 --disable-outdev=NAME disable output device NAME
149 --disable-indevs disable input devices
150 --disable-outdevs disable output devices
151 --disable-devices disable all devices
152 --enable-filter=NAME enable filter NAME
153 --disable-filter=NAME disable filter NAME
154 --disable-filters disable all filters
155 --list-decoders show all available decoders
156 --list-encoders show all available encoders
157 --list-hwaccels show all available hardware accelerators
158 --list-muxers show all available muxers
159 --list-demuxers show all available demuxers
160 --list-parsers show all available parsers
161 --list-protocols show all available protocols
162 --list-bsfs show all available bitstream filters
163 --list-indevs show all available input devices
164 --list-outdevs show all available output devices
165 --list-filters show all available filters
166
167External library support:
168 --enable-avisynth enable reading of AVISynth script files [no]
169 --enable-bzlib enable bzlib [autodetect]
47941088 170 --enable-frei0r enable frei0r video filtering
bc8c1395 171 --enable-gnutls enable gnutls [no]
06454877
MR
172 --enable-libopencore-amrnb enable AMR-NB de/encoding via libopencore-amrnb [no]
173 --enable-libopencore-amrwb enable AMR-WB decoding via libopencore-amrwb [no]
6ebf0bfc 174 --enable-libopencv enable video filtering via libopencv [no]
e417d80d 175 --enable-libcdio enable audio CD grabbing with libcdio
06454877
MR
176 --enable-libdc1394 enable IIDC-1394 grabbing using libdc1394
177 and libraw1394 [no]
178 --enable-libdirac enable Dirac support via libdirac [no]
179 --enable-libfaac enable FAAC support via libfaac [no]
a5b64584 180 --enable-libfreetype enable libfreetype [no]
06454877
MR
181 --enable-libgsm enable GSM support via libgsm [no]
182 --enable-libmp3lame enable MP3 encoding via libmp3lame [no]
183 --enable-libnut enable NUT (de)muxing via libnut,
184 native (de)muxer exists [no]
185 --enable-libopenjpeg enable JPEG 2000 decoding via OpenJPEG [no]
7c922411 186 --enable-libpulse enable Pulseaudio input via libpulse [no]
0f943ce6 187 --enable-librtmp enable RTMP[E] support via librtmp [no]
06454877 188 --enable-libschroedinger enable Dirac support via libschroedinger [no]
b606a017 189 --enable-libspeex enable Speex support via libspeex [no]
06454877 190 --enable-libtheora enable Theora encoding via libtheora [no]
d89e738a 191 --enable-libvo-aacenc enable AAC encoding via libvo-aacenc [no]
f502ff3f 192 --enable-libvo-amrwbenc enable AMR-WB encoding via libvo-amrwbenc [no]
06454877
MR
193 --enable-libvorbis enable Vorbis encoding via libvorbis,
194 native implementation exists [no]
8299a7f8 195 --enable-libvpx enable VP8 support via libvpx [no]
06454877 196 --enable-libx264 enable H.264 encoding via x264 [no]
de295976 197 --enable-libxavs enable AVS encoding via xavs [no]
06454877
MR
198 --enable-libxvid enable Xvid encoding via xvidcore,
199 native MPEG-4/Xvid encoder exists [no]
200 --enable-mlib enable Sun medialib [no]
a060866f 201 --enable-openssl enable openssl [no]
06454877
MR
202 --enable-zlib enable zlib [autodetect]
203
204Advanced options (experts only):
06454877
MR
205 --cross-prefix=PREFIX use PREFIX for compilation tools [$cross_prefix]
206 --enable-cross-compile assume a cross-compiler is used
207 --sysroot=PATH root of cross-build tree
208 --sysinclude=PATH location of cross-build system headers
209 --target-os=OS compiler targets OS [$target_os]
210 --target-exec=CMD command to run executables on target
211 --target-path=DIR path to view of build directory on target
212 --nm=NM use nm tool
121d78d0 213 --ar=AR use archive tool AR [$ar_default]
06454877
MR
214 --as=AS use assembler AS [$as_default]
215 --cc=CC use C compiler CC [$cc_default]
216 --ld=LD use linker LD
217 --host-cc=HOSTCC use host C compiler HOSTCC
218 --host-cflags=HCFLAGS use HCFLAGS when compiling for host
219 --host-ldflags=HLDFLAGS use HLDFLAGS when linking for host
220 --host-libs=HLIBS use libs HLIBS when linking for host
221 --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS [$CFLAGS]
222 --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]
223 --extra-libs=ELIBS add ELIBS [$ELIBS]
224 --extra-version=STRING version string suffix []
225 --build-suffix=SUFFIX library name suffix []
226 --arch=ARCH select architecture [$arch]
227 --cpu=CPU select the minimum required CPU (affects
228 instruction selection, may crash on older CPUs)
c8a4ae00 229 --disable-asm disable all assembler optimizations
06454877
MR
230 --disable-altivec disable AltiVec optimizations
231 --disable-amd3dnow disable 3DNow! optimizations
232 --disable-amd3dnowext disable 3DNow! extended optimizations
233 --disable-mmx disable MMX optimizations
234 --disable-mmx2 disable MMX2 optimizations
235 --disable-sse disable SSE optimizations
236 --disable-ssse3 disable SSSE3 optimizations
87f1355f 237 --disable-avx disable AVX optimizations
06454877
MR
238 --disable-armv5te disable armv5te optimizations
239 --disable-armv6 disable armv6 optimizations
240 --disable-armv6t2 disable armv6t2 optimizations
241 --disable-armvfp disable ARM VFP optimizations
242 --disable-iwmmxt disable iwmmxt optimizations
243 --disable-mmi disable MMI optimizations
5ea20630 244 --disable-neon disable NEON optimizations
06454877
MR
245 --disable-vis disable VIS optimizations
246 --disable-yasm disable use of yasm assembler
247 --enable-pic build position-independent code
4ae40685 248 --malloc-prefix=PFX prefix malloc and related names with PFX
6b35d421 249 --enable-sram allow use of on-chip SRAM
9baec618 250 --disable-symver disable symbol versioning
9cd7b854 251 --optflags override optimization-related compiler flags
06454877 252
070c5d0f 253Developer options (useful when working on Libav itself):
06454877
MR
254 --disable-debug disable debugging symbols
255 --enable-debug=LEVEL set the debug level [$debuglevel]
06454877
MR
256 --disable-optimizations disable compiler optimizations
257 --enable-extra-warnings enable more compiler warnings
52b3cc60
RD
258 --samples=PATH location of test samples for FATE, if not set use
259 \$FATE_SAMPLES at make invocation time.
06454877
MR
260
261NOTE: Object files are built at the place where configure is launched.
262EOF
60e8bc13 263 exit 0
74c53c2d 264}
cf9d24ad 265
0884fadf
MR
266quotes='""'
267
57bd82d4 268log(){
2270b4b2 269 echo "$@" >> $logfile
57bd82d4
MR
270}
271
720c69da 272log_file(){
c8e9f801 273 log BEGIN $1
2270b4b2 274 pr -n -t $1 >> $logfile
c8e9f801
MR
275 log END $1
276}
277
2ba042a7 278echolog(){
c8e9f801 279 log "$@"
57bd82d4 280 echo "$@"
2ba042a7
MR
281}
282
7bfc8ae6
MR
283warn(){
284 log "WARNING: $*"
285 WARNINGS="${WARNINGS}WARNING: $*\n"
286}
287
2ba042a7
MR
288die(){
289 echolog "$@"
290 cat <<EOF
d326cf7f 291
2ba042a7 292If you think configure made a mistake, make sure you are using the latest
4a6a21f5 293version from Git. If the latest version fails, report the problem to the
070c5d0f 294libav-user@libav.org mailing list or IRC #libav on irc.freenode.net.
2ba042a7 295EOF
e155a21a 296 if disabled logging; then
2ba042a7 297 cat <<EOF
e155a21a
DB
298Rerun configure with logging enabled (do not use --disable-logging), and
299include the log this produces with your report.
2ba042a7
MR
300EOF
301 else
302cat <<EOF
e155a21a
DB
303Include the log file "$logfile" produced by configure as this will help
304solving the problem.
2ba042a7
MR
305EOF
306 fi
57bd82d4
MR
307 exit 1
308}
309
6c6007d6 310# Avoid locale weirdness, besides we really just want to translate ASCII.
44161118 311toupper(){
6c6007d6 312 echo "$@" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
44161118
MR
313}
314
4a5444db 315tolower(){
6c6007d6 316 echo "$@" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
4a5444db
MR
317}
318
14a8acf1
MR
319c_escape(){
320 echo "$*" | sed 's/["\\]/\\\0/g'
321}
322
b04251c5
MR
323sh_quote(){
324 v=$(echo "$1" | sed "s/'/'\\\\''/g")
d72c981c 325 test "x$v" = "x${v#*[!A-Za-z0-9_/.+-]}" || v="'$v'"
b04251c5
MR
326 echo "$v"
327}
328
bb7a22b5
MR
329cleanws(){
330 echo "$@" | sed 's/^ *//;s/ */ /g;s/ *$//'
331}
332
be8f2501
MR
333filter(){
334 pat=$1
335 shift
336 for v; do
98ef6079 337 eval "case $v in $pat) echo $v ;; esac"
be8f2501
MR
338 done
339}
340
9d201b26
MR
341filter_out(){
342 pat=$1
343 shift
344 for v; do
345 eval "case $v in $pat) ;; *) echo $v ;; esac"
346 done
347}
348
36e2dea0
MR
349map(){
350 m=$1
351 shift
e0e335a0 352 for v; do eval $m; done
36e2dea0
MR
353}
354
a8d04fba
MR
355set_all(){
356 value=$1
357 shift
358 for var in $*; do
359 eval $var=$value
360 done
361}
362
72a43668
MR
363set_weak(){
364 value=$1
365 shift
366 for var; do
367 eval : \${$var:=$value}
368 done
369}
370
3f8040db
MR
371set_safe(){
372 var=$1
373 shift
374 eval $(echo "$var" | sed 's/[^A-Za-z0-9_]/_/g')='$*'
375}
376
377get_safe(){
378 eval echo \$$(echo "$1" | sed 's/[^A-Za-z0-9_]/_/g')
379}
380
799c9e9b
MR
381pushvar(){
382 for var in $*; do
383 eval level=\${${var}_level:=0}
384 eval ${var}_${level}="\$$var"
385 eval ${var}_level=$(($level+1))
386 done
387}
388
389popvar(){
390 for var in $*; do
391 eval level=\${${var}_level:-0}
392 test $level = 0 && continue
393 eval level=$(($level-1))
394 eval $var="\${${var}_${level}}"
395 eval ${var}_level=$level
396 eval unset ${var}_${level}
397 done
398}
399
a8d04fba
MR
400enable(){
401 set_all yes $*
402}
403
404disable(){
405 set_all no $*
406}
407
72a43668
MR
408enable_weak(){
409 set_weak yes $*
410}
411
412disable_weak(){
413 set_weak no $*
414}
415
72702705 416enable_safe(){
fd07f803
MR
417 for var; do
418 enable $(echo "$var" | sed 's/[^A-Za-z0-9_]/_/g')
419 done
72702705
MR
420}
421
422disable_safe(){
fd07f803
MR
423 for var; do
424 disable $(echo "$var" | sed 's/[^A-Za-z0-9_]/_/g')
425 done
72702705
MR
426}
427
f9d328da
MR
428do_enable_deep(){
429 for var; do
430 enabled $var && continue
431 eval sel="\$${var}_select"
c510c7b5
MR
432 eval sgs="\$${var}_suggest"
433 pushvar var sgs
f9d328da 434 enable_deep $sel
c510c7b5
MR
435 popvar sgs
436 enable_deep_weak $sgs
f9d328da
MR
437 popvar var
438 done
439}
440
441enable_deep(){
442 do_enable_deep $*
443 enable $*
444}
445
72a43668
MR
446enable_deep_weak(){
447 do_enable_deep $*
448 enable_weak $*
449}
450
57bd82d4 451enabled(){
3250003c
MR
452 test "${1#!}" = "$1" && op== || op=!=
453 eval test "x\$${1#!}" $op "xyes"
44161118
MR
454}
455
37970ebf 456disabled(){
3250003c
MR
457 test "${1#!}" = "$1" && op== || op=!=
458 eval test "x\$${1#!}" $op "xno"
37970ebf
RP
459}
460
44161118
MR
461enabled_all(){
462 for opt; do
463 enabled $opt || return 1
464 done
465}
466
85bca2c5
DB
467disabled_all(){
468 for opt; do
469 disabled $opt || return 1
470 done
471}
472
44161118
MR
473enabled_any(){
474 for opt; do
475 enabled $opt && return 0
476 done
477}
478
85bca2c5
DB
479disabled_any(){
480 for opt; do
481 disabled $opt && return 0
482 done
f7b230a7 483 return 1
85bca2c5
DB
484}
485
c9d19248
MR
486set_default(){
487 for opt; do
88268e94 488 eval : \${$opt:=\$${opt}_default}
c9d19248
MR
489 done
490}
491
4a0d6686
AJ
492is_in(){
493 value=$1
494 shift
495 for var in $*; do
496 [ $var = $value ] && return 0
497 done
498 return 1
499}
500
30fd06be
MR
501check_deps(){
502 for cfg; do
3250003c 503 cfg="${cfg#!}"
799c9e9b
MR
504 enabled ${cfg}_checking && die "Circular dependency for $cfg."
505 disabled ${cfg}_checking && continue
506 enable ${cfg}_checking
507
30fd06be
MR
508 eval dep_all="\$${cfg}_deps"
509 eval dep_any="\$${cfg}_deps_any"
7ef3425f 510 eval dep_sel="\$${cfg}_select"
c510c7b5 511 eval dep_sgs="\$${cfg}_suggest"
3d7453e0
MR
512 eval dep_ifa="\$${cfg}_if"
513 eval dep_ifn="\$${cfg}_if_any"
799c9e9b 514
3d7453e0
MR
515 pushvar cfg dep_all dep_any dep_sel dep_sgs dep_ifa dep_ifn
516 check_deps $dep_all $dep_any $dep_sel $dep_sgs $dep_ifa $dep_ifn
517 popvar cfg dep_all dep_any dep_sel dep_sgs dep_ifa dep_ifn
799c9e9b 518
3d7453e0
MR
519 [ -n "$dep_ifa" ] && { enabled_all $dep_ifa && enable_weak $cfg; }
520 [ -n "$dep_ifn" ] && { enabled_any $dep_ifn && enable_weak $cfg; }
6a702d4c
MR
521 enabled_all $dep_all || disable $cfg
522 enabled_any $dep_any || disable $cfg
7ef3425f 523 disabled_any $dep_sel && disable $cfg
799c9e9b 524
4ec45764
RP
525 if enabled $cfg; then
526 eval dep_extralibs="\$${cfg}_extralibs"
527 test -n "$dep_extralibs" && add_extralibs $dep_extralibs
f9d328da 528 enable_deep $dep_sel
c510c7b5 529 enable_deep_weak $dep_sgs
4ec45764
RP
530 fi
531
799c9e9b 532 disable ${cfg}_checking
30fd06be
MR
533 done
534}
535
72cfcf41
MR
536print_config_h(){
537 enabled $1 && v=1 || v=0
538 echo "#define $2 $v"
539}
540
541print_config_mak(){
542 enabled $1 && v= || v=!
543 echo "$v$2=yes"
544}
545
55127e7b
MR
546print_config_asm(){
547 enabled $1 && echo "%define $2"
548}
549
44161118
MR
550print_config(){
551 pfx=$1
72cfcf41
MR
552 files=$2
553 shift 2
44161118 554 for cfg; do
5e622c40 555 ucname="$(toupper $cfg)"
72cfcf41
MR
556 for f in $files; do
557 "print_config_${f##*.}" $cfg ${pfx}${ucname} >>$f
558 done
44161118 559 done
57bd82d4
MR
560}
561
31c0121d
MR
562print_enabled(){
563 test "$1" = -n && end=" " && shift || end="\n"
564 suf=$1
565 shift
566 for v; do
567 enabled $v && printf "%s$end" ${v%$suf};
568 done
569}
570
57bd82d4
MR
571append(){
572 var=$1
573 shift
57bd82d4
MR
574 eval "$var=\"\$$var $*\""
575}
576
60361817
MR
577prepend(){
578 var=$1
579 shift
580 eval "$var=\"$* \$$var\""
581}
582
50a334e4 583add_cppflags(){
caf458dd 584 append CPPFLAGS $($filter_cppflags "$@")
50a334e4
MR
585}
586
57bd82d4 587add_cflags(){
caf458dd 588 append CFLAGS $($filter_cflags "$@")
57bd82d4
MR
589}
590
2f2e6c7c 591add_asflags(){
caf458dd 592 append ASFLAGS $($filter_asflags "$@")
2f2e6c7c
MR
593}
594
57bd82d4
MR
595add_ldflags(){
596 append LDFLAGS "$@"
597}
598
599add_extralibs(){
60361817 600 prepend extralibs "$@"
57bd82d4
MR
601}
602
b0cfb663 603check_cmd(){
b3cb5d51 604 log "$@"
2270b4b2 605 "$@" >> $logfile 2>&1
b0cfb663
MR
606}
607
dcd479c0 608check_cc(){
57bd82d4 609 log check_cc "$@"
2270b4b2 610 cat > $TMPC
720c69da 611 log_file $TMPC
50a334e4 612 check_cmd $cc $CPPFLAGS $CFLAGS "$@" -c -o $TMPO $TMPC
57bd82d4
MR
613}
614
615check_cpp(){
616 log check_cpp "$@"
2270b4b2 617 cat > $TMPC
720c69da 618 log_file $TMPC
9e7f3277 619 check_cmd $cc $CPPFLAGS $CFLAGS "$@" -E -o $TMPO $TMPC
dcd479c0
MR
620}
621
f65883c8
MR
622check_as(){
623 log check_as "$@"
624 cat > $TMPC
625 log_file $TMPC
2f2e6c7c 626 check_cmd $as $CPPFLAGS $ASFLAGS "$@" -c -o $TMPO $TMPC
f65883c8
MR
627}
628
940f335a
MR
629check_asm(){
630 log check_asm "$@"
631 name="$1"
3784e82e 632 code="$2"
940f335a 633 shift 2
49214f61
MR
634 disable $name
635 check_as "$@" <<EOF && enable $name
3784e82e 636void foo(void){ __asm__ volatile($code); }
940f335a
MR
637EOF
638}
639
304d586d
LM
640check_yasm(){
641 log check_yasm "$@"
642 echo "$1" > $TMPS
643 log_file $TMPS
644 shift 1
645 check_cmd $yasmexe $YASMFLAGS "$@" -o $TMPO $TMPS
646}
647
dcd479c0 648check_ld(){
57bd82d4 649 log check_ld "$@"
3155a644
MR
650 flags=''
651 libs=''
652 for f; do
653 test "${f}" = "${f#-l}" && flags="$flags $f" || libs="$libs $f"
654 done
2a194acd 655 check_cc $($filter_cflags $flags) || return
7e75f9fe 656 check_cmd $ld $LDFLAGS $flags -o $TMPE $TMPO $libs $extralibs
dcd479c0
MR
657}
658
7b00340f
DB
659print_include(){
660 hdr=$1
661 test "${hdr%.h}" = "${hdr}" &&
662 echo "#include $hdr" ||
663 echo "#include <$hdr>"
664}
665
50a334e4
MR
666check_cppflags(){
667 log check_cppflags "$@"
caf458dd
MR
668 set -- $($filter_cppflags "$@")
669 check_cc "$@" <<EOF && append CPPFLAGS "$@"
50a334e4
MR
670int x;
671EOF
672}
673
dcd479c0 674check_cflags(){
57bd82d4 675 log check_cflags "$@"
caf458dd
MR
676 set -- $($filter_cflags "$@")
677 check_cc "$@" <<EOF && append CFLAGS "$@"
dcd479c0
MR
678int x;
679EOF
680}
681
2ed46eea
MR
682test_ldflags(){
683 log test_ldflags "$@"
684 check_ld "$@" <<EOF
c23a0ac8 685int main(void){ return 0; }
dcd479c0
MR
686EOF
687}
688
2ed46eea
MR
689check_ldflags(){
690 log check_ldflags "$@"
691 test_ldflags "$@" && add_ldflags "$@"
692}
693
dcd479c0 694check_header(){
57bd82d4 695 log check_header "$@"
dcd479c0
MR
696 header=$1
697 shift
b77df637
MR
698 disable_safe $header
699 check_cpp "$@" <<EOF && enable_safe $header
dcd479c0
MR
700#include <$header>
701int x;
702EOF
703}
704
705check_func(){
57bd82d4 706 log check_func "$@"
dcd479c0
MR
707 func=$1
708 shift
d8bc5f06
MR
709 disable $func
710 check_ld "$@" <<EOF && enable $func
dcd479c0 711extern int $func();
c23a0ac8 712int main(void){ $func(); }
dcd479c0
MR
713EOF
714}
715
645d2652 716check_mathfunc(){
6b73c0ae 717 log check_mathfunc "$@"
645d2652
MR
718 func=$1
719 shift
720 disable $func
721 check_ld "$@" <<EOF && enable $func
722#include <math.h>
33bd38db
MR
723float foo(float f) { return $func(f); }
724int main(void){ return 0; }
645d2652
MR
725EOF
726}
727
2446d3d6
DB
728check_func_headers(){
729 log check_func_headers "$@"
f8d7b072 730 headers=$1
edaf1ae2 731 funcs=$2
f8d7b072 732 shift 2
edaf1ae2
MR
733 {
734 for hdr in $headers; do
7b00340f 735 print_include $hdr
edaf1ae2
MR
736 done
737 for func in $funcs; do
738 echo "long check_$func(void) { return (long) $func; }"
739 done
740 echo "int main(void) { return 0; }"
741 } | check_ld "$@" && enable $funcs && enable_safe $headers
f8d7b072
MR
742}
743
a5344cf7
SS
744check_cpp_condition(){
745 log check_cpp_condition "$@"
746 header=$1
747 condition=$2
f855b7b9
MR
748 shift 2
749 check_cpp $($filter_cppflags "$@") <<EOF
a5344cf7
SS
750#include <$header>
751#if !($condition)
752#error "unsatisfied condition: $condition"
753#endif
754EOF
755}
756
57bd82d4
MR
757check_lib(){
758 log check_lib "$@"
759 header="$1"
760 func="$2"
761 shift 2
84400e9d 762 check_header $header && check_func $func "$@" && add_extralibs "$@"
57bd82d4
MR
763}
764
f8d7b072
MR
765check_lib2(){
766 log check_lib2 "$@"
767 headers="$1"
edaf1ae2 768 funcs="$2"
f8d7b072 769 shift 2
edaf1ae2 770 check_func_headers "$headers" "$funcs" "$@" && add_extralibs "$@"
f8d7b072
MR
771}
772
3f8040db
MR
773check_pkg_config(){
774 log check_pkg_config "$@"
775 pkg="$1"
776 headers="$2"
777 funcs="$3"
778 shift 3
779 $pkg_config --exists $pkg || return
780 pkg_cflags=$($pkg_config --cflags $pkg)
781 pkg_libs=$($pkg_config --libs $pkg)
782 check_func_headers "$headers" "$funcs" $pkg_cflags $pkg_libs "$@" &&
783 set_safe ${pkg}_cflags $pkg_cflags &&
784 set_safe ${pkg}_libs $pkg_libs
785}
786
dcd479c0 787check_exec(){
2270b4b2 788 check_ld "$@" && { enabled cross_compile || $TMPE >> $logfile 2>&1; }
57bd82d4
MR
789}
790
7dfef245 791check_exec_crash(){
5e622c40 792 code=$(cat)
7dfef245
MR
793
794 # exit() is not async signal safe. _Exit (C99) and _exit (POSIX)
795 # are safe but may not be available everywhere. Thus we use
796 # raise(SIGTERM) instead. The check is run in a subshell so we
797 # can redirect the "Terminated" message from the shell. SIGBUS
798 # is not defined by standard C so it is used conditionally.
799
2270b4b2 800 (check_exec "$@") >> $logfile 2>&1 <<EOF
7dfef245
MR
801#include <signal.h>
802static void sighandler(int sig){
803 raise(SIGTERM);
804}
e5af4a11 805int main(void){
7dfef245
MR
806 signal(SIGILL, sighandler);
807 signal(SIGFPE, sighandler);
808 signal(SIGSEGV, sighandler);
809#ifdef SIGBUS
810 signal(SIGBUS, sighandler);
811#endif
812 { $code }
813}
814EOF
815}
816
72be9e73
DY
817check_type(){
818 log check_type "$@"
819 headers=$1
820 type=$2
821 shift 2
ae550ce9 822 disable_safe "$type"
72be9e73
DY
823 incs=""
824 for hdr in $headers; do
825 incs="$incs
826#include <$hdr>"
827 done
ae550ce9 828 check_cc "$@" <<EOF && enable_safe "$type"
72be9e73
DY
829$incs
830$type v;
831EOF
832}
833
14d36751
MR
834check_struct(){
835 log check_type "$@"
836 headers=$1
837 struct=$2
838 member=$3
839 shift 3
840 disable_safe "${struct}_${member}"
841 incs=""
842 for hdr in $headers; do
843 incs="$incs
844#include <$hdr>"
845 done
846 check_cc "$@" <<EOF && enable_safe "${struct}_${member}"
847$incs
848const void *p = &(($struct *)0)->$member;
849EOF
850}
851
57bd82d4
MR
852require(){
853 name="$1"
854 header="$2"
855 func="$3"
856 shift 3
857 check_lib $header $func "$@" || die "ERROR: $name not found"
dcd479c0
MR
858}
859
f8d7b072
MR
860require2(){
861 name="$1"
862 headers="$2"
863 func="$3"
864 shift 3
865 check_lib2 "$headers" $func "$@" || die "ERROR: $name not found"
866}
867
3f8040db
MR
868require_pkg_config(){
869 pkg="$1"
870 check_pkg_config "$@" || die "ERROR: $pkg not found"
871 add_cflags $(get_safe ${pkg}_cflags)
872 add_extralibs $(get_safe ${pkg}_libs)
873}
874
f0125de9
MR
875check_host_cc(){
876 log check_host_cc "$@"
877 cat > $TMPC
878 log_file $TMPC
879 check_cmd $host_cc $host_cflags "$@" -c -o $TMPO $TMPC
880}
881
882check_host_cflags(){
883 log check_host_cflags "$@"
884 check_host_cc "$@" <<EOF && append host_cflags "$@"
885int x;
886EOF
887}
888
c505dd31
MR
889apply(){
890 file=$1
891 shift
892 "$@" < "$file" > "$file.tmp" && mv "$file.tmp" "$file" || rm "$file.tmp"
893}
894
c34681df 895cp_if_changed(){
5e27ec28
MR
896 cmp -s "$1" "$2" && echo "$2 is unchanged" && return
897 mkdir -p "$(dirname $2)"
898 cp -f "$1" "$2"
c34681df
MR
899}
900
dcd61286
DB
901# CONFIG_LIST contains configurable options, while HAVE_LIST is for
902# system-dependent things.
903
4a0d6686
AJ
904COMPONENT_LIST="
905 bsfs
906 decoders
907 demuxers
908 encoders
3cde40aa 909 filters
5666fd73 910 hwaccels
c552605c 911 indevs
4a0d6686 912 muxers
c552605c 913 outdevs
4a0d6686
AJ
914 parsers
915 protocols
916"
917
055c61b8
DB
918PROGRAM_LIST="
919 avconv
920 avplay
921 avprobe
922 avserver
923 ffmpeg
924"
925
4a0d6686
AJ
926CONFIG_LIST="
927 $COMPONENT_LIST
055c61b8 928 $PROGRAM_LIST
e8ed9b7a 929 aandct
a5444fee 930 ac3dsp
5a0f7131
MR
931 avcodec
932 avdevice
f7679c54 933 avfilter
5a0f7131 934 avformat
c88f5d72 935 avisynth
f402916e 936 bzlib
7f3f5f46 937 dct
c73f65d9 938 doc
05aec7bb 939 dwt
92c6a099 940 dxva2
27a9466b 941 fastdiv
1848f7d9 942 fft
47941088 943 frei0r
bc8c1395 944 gnutls
4f034993 945 golomb
c88f5d72 946 gpl
d8d0d0b2 947 gray
88b97357 948 h264chroma
4693b031 949 h264dsp
4a384de5 950 h264pred
3abe5fbd 951 hardcoded_tables
3447f12d 952 huffman
e417d80d 953 libcdio
f7b8bffe 954 libdc1394
690bfceb 955 libdirac
2eed5a46 956 libfaac
a5b64584 957 libfreetype
c88f5d72 958 libgsm
6ebe07fb 959 libmp3lame
c88f5d72 960 libnut
0b175caa
DB
961 libopencore_amrnb
962 libopencore_amrwb
6ebf0bfc 963 libopencv
9a77d59a 964 libopenjpeg
0de9c41f 965 libpulse
0f943ce6 966 librtmp
f7cd9eed 967 libschroedinger
ae14f311 968 libspeex
150d2772 969 libtheora
d89e738a 970 libvo_aacenc
f502ff3f 971 libvo_amrwbenc
c88f5d72 972 libvorbis
8299a7f8 973 libvpx
1cc60c47 974 libx264
de295976 975 libxavs
1cc60c47 976 libxvid
f4d608e3 977 lpc
b781cc12 978 lsp
47a158cb 979 mdct
c88f5d72 980 memalign_hack
a8150374 981 mlib
c4f5c2d6 982 mpegaudiodsp
c88f5d72 983 network
3fe142e2 984 nonfree
a060866f 985 openssl
8a3c8627 986 pic
4a24ab64 987 postproc
68602540 988 rdft
44b70ce5 989 rtpdec
e90f5b5a 990 runtime_cpudetect
8cfbbd92 991 safe_bitstream_reader
2e35e684 992 shared
4538729a 993 sinewin
bd2216e4 994 small
6b35d421 995 sram
2e35e684 996 static
5a0f7131 997 swscale
a9ddb5b1 998 swscale_alpha
8986fddc 999 thumb
17492d5e 1000 vaapi
ac3dbb4d 1001 vda
17492d5e 1002 vdpau
9cad0e4e 1003 version3
56a059ac 1004 x11grab
c88f5d72 1005 zlib
4a0d6686 1006"
c88f5d72 1007
8eee7025 1008THREADS_LIST='
8eee7025
DB
1009 pthreads
1010 w32threads
1011'
1012
3f5b56e5
MR
1013ARCH_LIST='
1014 alpha
a2fc0f6a 1015 arm
fdcd782d
MR
1016 avr32
1017 avr32_ap
1018 avr32_uc
3f5b56e5
MR
1019 bfin
1020 ia64
1021 m68k
1022 mips
bae3abb0 1023 mips64
3f5b56e5 1024 parisc
79cb09b2 1025 ppc
34d11b87 1026 ppc64
3f5b56e5
MR
1027 s390
1028 sh4
1029 sparc
1030 sparc64
0844bae1 1031 tomi
3f5b56e5
MR
1032 x86
1033 x86_32
1034 x86_64
1035'
1036
1037ARCH_EXT_LIST='
1ac9331a 1038 altivec
3bf96eec 1039 amd3dnow
a1ef9f08 1040 amd3dnowext
1ac9331a 1041 armv5te
edab3048 1042 armv6
ab5cb084 1043 armv6t2
f55b299a 1044 armvfp
87f1355f 1045 avx
3f5b56e5
MR
1046 iwmmxt
1047 mmi
1048 mmx
d7f0920b 1049 mmx2
6b18d278 1050 neon
799fde37 1051 ppc4xx
1bb04d5a 1052 sse
9eeed841 1053 ssse3
93eb8e4d 1054 vfpv3
bd9d34a0 1055 vis
3f5b56e5
MR
1056'
1057
a3e02a8c
MR
1058HAVE_LIST_PUB='
1059 bigendian
d268eee9 1060 fast_unaligned
a3e02a8c
MR
1061'
1062
3f5b56e5
MR
1063HAVE_LIST="
1064 $ARCH_EXT_LIST
a3e02a8c 1065 $HAVE_LIST_PUB
3f5b56e5 1066 $THREADS_LIST
59782b82 1067 aligned_stack
35fd8122 1068 alsa_asoundlib_h
3f5b56e5 1069 altivec_h
c9fdab0d 1070 arpa_inet_h
6308729e 1071 asm_mod_y
dffb41b9 1072 attribute_may_alias
e7ea5e3d 1073 attribute_packed
ecf97f22 1074 closesocket
1ac9331a 1075 cmov
c88f5d72 1076 dcbzl
f8aa696f
DB
1077 dev_bktr_ioctl_bt848_h
1078 dev_bktr_ioctl_meteor_h
1079 dev_ic_bt8xx_h
f8aa696f 1080 dev_video_bktr_ioctl_bt848_h
3e0b1c9a 1081 dev_video_meteor_ioctl_meteor_h
18b67ae5 1082 dlfcn_h
c88f5d72 1083 dlopen
bc574408 1084 dos_paths
cd534fdf 1085 dxva_h
245626d0
DB
1086 ebp_available
1087 ebx_available
6b7c7703
VS
1088 exp2
1089 exp2f
c2a29455 1090 fast_64bit
669b5583 1091 fast_clz
7073e9fc 1092 fast_cmov
534a2231 1093 fcntl
9d99cc5a 1094 fork
84882df6 1095 getaddrinfo
da9e86f8 1096 gethrtime
02e8f427 1097 GetProcessAffinityMask
fc5607f8 1098 GetProcessMemoryInfo
4e68cb8a 1099 GetProcessTimes
66be5b45 1100 getrusage
a49d3025 1101 gnu_as
2f0c136e 1102 ibm_asm
2e1913b1 1103 inet_aton
61d251db 1104 inline_asm
abfc8d05 1105 isatty
9f5ff83f 1106 ldbrx
0b4a1821
AS
1107 libdc1394_1
1108 libdc1394_2
a33cab3a 1109 llrint
07876e25 1110 llrintf
d96cd429
MR
1111 local_aligned_16
1112 local_aligned_8
a5b64584 1113 localtime_r
291fd18a 1114 log2
6b7c7703 1115 log2f
85dd97ad 1116 loongson
a33cab3a 1117 lrint
c88f5d72 1118 lrintf
e4673692 1119 lzo1x_999_compress
f8aa696f
DB
1120 machine_ioctl_bt848_h
1121 machine_ioctl_meteor_h
c88f5d72 1122 malloc_h
73f6d31e 1123 MapViewOfFile
c88f5d72 1124 memalign
6ffa87d3 1125 mkstemp
0328b9ea 1126 mmap
3e0b1c9a 1127 poll_h
1f91cdce 1128 posix_memalign
a33cab3a
MK
1129 round
1130 roundf
ea4d5f48 1131 sched_getaffinity
c88f5d72
MR
1132 sdl
1133 sdl_video_size
b507ebd1 1134 setmode
3e0b1c9a 1135 setrlimit
15d59d2c 1136 sndio_h
72be9e73 1137 socklen_t
deb29777 1138 soundcard_h
87958234 1139 strerror_r
6379900c 1140 strptime
47941088 1141 strtok_r
c0018613 1142 struct_addrinfo
b4d68544 1143 struct_ipv6_mreq
3e0b1c9a 1144 struct_rusage_ru_maxrss
b4d68544 1145 struct_sockaddr_in6
3b2372bf 1146 struct_sockaddr_sa_len
33a4dbdd 1147 struct_sockaddr_storage
a6a4793d 1148 struct_v4l2_frmivalenum_discrete
b462d132 1149 symver
b462d132 1150 symver_asm_label
3e0b1c9a 1151 symver_gnu_asm
bcc73960 1152 sysconf
b9e22269 1153 sysctl
b58412f1 1154 sys_mman_h
06bb5905 1155 sys_param_h
b091aa44 1156 sys_resource_h
81644c2e 1157 sys_select_h
deb29777 1158 sys_soundcard_h
1b6e8b73 1159 sys_videoio_h
b265431e 1160 threads
23d3931a 1161 trunc
7b04b8a0 1162 truncf
ce742de2 1163 vfp_args
7c5bfe7a 1164 VirtualAlloc
6ff3f3e7 1165 winsock2_h
cc078b5d 1166 xform_asm
6f74fb03 1167 xmm_clobbers
304d586d 1168 yasm
0cb78cef 1169"
44161118 1170
b6bb00b0
MR
1171# options emitted with CONFIG_ prefix but not available on command line
1172CONFIG_EXTRA="
dc4f5a1c 1173 avutil
9cad0e4e
DB
1174 gplv3
1175 lgplv3
b6bb00b0
MR
1176"
1177
520cc7f1 1178CMDLINE_SELECT="
3f5b56e5 1179 $ARCH_EXT_LIST
520cc7f1 1180 $CONFIG_LIST
8eee7025 1181 $THREADS_LIST
c8a4ae00 1182 asm
db6107b6 1183 cross_compile
520cc7f1
MR
1184 debug
1185 extra_warnings
8c6afa4d 1186 logging
d2bbb2f7 1187 optimizations
9baec618 1188 symver
7595a5e4 1189 yasm
520cc7f1 1190"
426be5dc
DB
1191
1192PATHS_LIST='
d156bede 1193 bindir
14a8acf1 1194 datadir
26759c44
MR
1195 incdir
1196 libdir
26759c44
MR
1197 mandir
1198 prefix
1199 shlibdir
426be5dc
DB
1200'
1201
1202CMDLINE_SET="
1203 $PATHS_LIST
121d78d0 1204 ar
426be5dc 1205 arch
313c46a6 1206 as
426be5dc
DB
1207 build_suffix
1208 cc
1209 cpu
1210 cross_prefix
50567afa 1211 dep_cc
ac63af34 1212 extra_version
9da6609f
MR
1213 host_cc
1214 host_cflags
1215 host_ldflags
1216 host_libs
82bb3329 1217 host_os
684b28e0 1218 ld
426be5dc 1219 logfile
4ae40685 1220 malloc_prefix
89641463 1221 nm
9cd7b854 1222 optflags
3f8040db 1223 pkg_config
2fad0977 1224 samples
c5200f17
MR
1225 sysinclude
1226 sysroot
a7ada2ba 1227 target_exec
26759c44 1228 target_os
a7ada2ba 1229 target_path
426be5dc 1230"
520cc7f1 1231
89f2932b
MR
1232CMDLINE_APPEND="
1233 extra_cflags
1234"
1235
912f3148
DB
1236# code dependency declarations
1237
9eeed841 1238# architecture extensions
808fa33c 1239
a2fc0f6a
MR
1240armv5te_deps="arm"
1241armv6_deps="arm"
ab5cb084 1242armv6t2_deps="arm"
a2fc0f6a
MR
1243armvfp_deps="arm"
1244iwmmxt_deps="arm"
808fa33c 1245neon_deps="arm"
93eb8e4d 1246vfpv3_deps="armvfp"
808fa33c 1247
e241ba14 1248mmi_deps="mips"
808fa33c
MR
1249
1250altivec_deps="ppc"
1251ppc4xx_deps="ppc"
1252
1253vis_deps="sparc"
1254
7f8c3d1f 1255x86_64_suggest="cmov fast_cmov"
808fa33c
MR
1256amd3dnow_deps="mmx"
1257amd3dnowext_deps="amd3dnow"
9eeed841 1258mmx_deps="x86"
75aa95a6 1259mmx2_deps="mmx"
75aa95a6
DB
1260sse_deps="mmx"
1261ssse3_deps="sse"
87f1355f 1262avx_deps="ssse3"
9eeed841 1263
59782b82 1264aligned_stack_if_any="ppc x86"
e939cedd 1265fast_64bit_if_any="alpha ia64 mips64 parisc64 ppc64 sparc64 x86_64"
669b5583 1266fast_clz_if_any="alpha armv5te avr32 mips ppc x86"
e939cedd 1267fast_unaligned_if_any="armv6 ppc x86"
669b5583 1268
6fec122a 1269inline_asm_deps="!tms470"
3e0b1c9a 1270need_memalign="altivec neon sse"
89e053f8 1271
b462d132
MR
1272symver_if_any="symver_asm_label symver_gnu_asm"
1273
26fbcc85 1274# subsystems
dc609252 1275dct_select="rdft"
26fbcc85
MR
1276mdct_select="fft"
1277rdft_select="fft"
c4f5c2d6 1278mpegaudiodsp_select="dct"
26fbcc85 1279
5666fd73 1280# decoders / encoders / hardware accelerators
cfc2a0cf 1281aac_decoder_select="mdct sinewin"
4538729a 1282aac_encoder_select="mdct sinewin"
136e19e1 1283aac_latm_decoder_select="aac_decoder aac_latm_parser"
6d9f52b2 1284ac3_decoder_select="mdct ac3dsp ac3_parser"
a5444fee 1285ac3_encoder_select="mdct ac3dsp"
3d269059 1286ac3_fixed_encoder_select="mdct ac3dsp"
f4d608e3 1287alac_encoder_select="lpc"
b781cc12 1288amrnb_decoder_select="lsp"
2b2a597e 1289amrwb_decoder_select="lsp"
4538729a 1290atrac1_decoder_select="mdct sinewin"
26fbcc85 1291atrac3_decoder_select="mdct"
a33657ce
DB
1292binkaudio_dct_decoder_select="mdct rdft dct sinewin"
1293binkaudio_rdft_decoder_select="mdct rdft sinewin"
4f034993 1294cavs_decoder_select="golomb"
4538729a 1295cook_decoder_select="mdct sinewin"
2eef7c62 1296cscd_decoder_suggest="zlib"
26fbcc85 1297dca_decoder_select="mdct"
e8ed9b7a 1298dnxhd_encoder_select="aandct"
2eef7c62 1299dxa_decoder_select="zlib"
baf91bb9 1300eac3_decoder_select="ac3_decoder"
aa47c35d 1301eac3_encoder_select="mdct ac3dsp"
84c04e25 1302eamad_decoder_select="aandct"
e8ed9b7a 1303eatgq_decoder_select="aandct"
d52b39c7 1304eatqi_decoder_select="aandct"
4f034993
MR
1305ffv1_decoder_select="golomb"
1306flac_decoder_select="golomb"
f4d608e3 1307flac_encoder_select="golomb lpc"
2eef7c62
AJ
1308flashsv_decoder_select="zlib"
1309flashsv_encoder_select="zlib"
c2d23309 1310flashsv2_decoder_select="zlib"
4414137e 1311flv_decoder_select="h263_decoder"
4d4b4bd1 1312flv_encoder_select="h263_encoder"
3447f12d 1313fraps_decoder_select="huffman"
e8ed9b7a 1314h261_encoder_select="aandct"
7f647ae0 1315h263_decoder_select="h263_parser"
e8ed9b7a 1316h263_encoder_select="aandct"
95a61cfc 1317h263_vaapi_hwaccel_select="vaapi h263_decoder"
4414137e 1318h263i_decoder_select="h263_decoder"
fe629c2d 1319h263p_encoder_select="h263_encoder"
88b97357 1320h264_decoder_select="golomb h264chroma h264dsp h264pred"
92c6a099
LA
1321h264_dxva2_hwaccel_deps="dxva2api_h"
1322h264_dxva2_hwaccel_select="dxva2 h264_decoder"
76718f3f 1323h264_vaapi_hwaccel_select="vaapi h264_decoder"
ac3dbb4d 1324h264_vda_hwaccel_select="vda h264_decoder"
95a61cfc 1325h264_vdpau_decoder_select="vdpau h264_decoder"
56c8227d 1326imc_decoder_select="fft mdct sinewin"
4f034993
MR
1327jpegls_decoder_select="golomb"
1328jpegls_encoder_select="golomb"
e8ed9b7a 1329ljpeg_encoder_select="aandct"
4f034993 1330loco_decoder_select="golomb"
e8ed9b7a 1331mjpeg_encoder_select="aandct"
2cca233b 1332mlp_decoder_select="mlp_parser"
c4f5c2d6 1333mp1_decoder_select="mpegaudiodsp"
c4f5c2d6 1334mp1float_decoder_select="mpegaudiodsp"
3e0b1c9a 1335mp2_decoder_select="mpegaudiodsp"
c4f5c2d6 1336mp2float_decoder_select="mpegaudiodsp"
3e0b1c9a
DB
1337mp3_decoder_select="mpegaudiodsp"
1338mp3adu_decoder_select="mpegaudiodsp"
c4f5c2d6
MR
1339mp3adufloat_decoder_select="mpegaudiodsp"
1340mp3float_decoder_select="mpegaudiodsp"
3e0b1c9a 1341mp3on4_decoder_select="mpegaudiodsp"
c4f5c2d6 1342mp3on4float_decoder_select="mpegaudiodsp"
606c9297
DB
1343mpc7_decoder_select="mpegaudiodsp"
1344mpc8_decoder_select="mpegaudiodsp"
95a61cfc 1345mpeg_vdpau_decoder_select="vdpau mpegvideo_decoder"
3e0b1c9a
DB
1346mpeg_xvmc_decoder_deps="X11_extensions_XvMClib_h"
1347mpeg_xvmc_decoder_select="mpegvideo_decoder"
95a61cfc 1348mpeg1_vdpau_decoder_select="vdpau mpeg1video_decoder"
3e0b1c9a 1349mpeg1video_encoder_select="aandct"
164aab02
LA
1350mpeg2_dxva2_hwaccel_deps="dxva2api_h"
1351mpeg2_dxva2_hwaccel_select="dxva2 mpeg2video_decoder"
95a61cfc 1352mpeg2_vaapi_hwaccel_select="vaapi mpeg2video_decoder"
3e0b1c9a
DB
1353mpeg2video_encoder_select="aandct"
1354mpeg4_decoder_select="h263_decoder mpeg4video_parser"
1355mpeg4_encoder_select="h263_encoder"
95a61cfc 1356mpeg4_vaapi_hwaccel_select="vaapi mpeg4_decoder"
70e0c871 1357mpeg4_vdpau_decoder_select="vdpau mpeg4_decoder"
4414137e 1358msmpeg4v1_decoder_select="h263_decoder"
4e169d89 1359msmpeg4v1_encoder_select="h263_encoder"
4414137e 1360msmpeg4v2_decoder_select="h263_decoder"
4e169d89 1361msmpeg4v2_encoder_select="h263_encoder"
4414137e 1362msmpeg4v3_decoder_select="h263_decoder"
4e169d89 1363msmpeg4v3_encoder_select="h263_encoder"
4538729a
MR
1364nellymoser_decoder_select="mdct sinewin"
1365nellymoser_encoder_select="mdct sinewin"
2eef7c62
AJ
1366png_decoder_select="zlib"
1367png_encoder_select="zlib"
b781cc12 1368qcelp_decoder_select="lsp"
c4f5c2d6 1369qdm2_decoder_select="mdct rdft mpegaudiodsp"
31ed3f1f 1370ra_144_encoder_select="lpc"
a8beb22f 1371rv10_decoder_select="h263_decoder"
b2bf38b4 1372rv10_encoder_select="h263_encoder"
a8beb22f 1373rv20_decoder_select="h263_decoder"
b2bf38b4 1374rv20_encoder_select="h263_encoder"
88b97357
DB
1375rv30_decoder_select="golomb h264chroma h264pred"
1376rv40_decoder_select="golomb h264chroma h264pred"
4f034993 1377shorten_decoder_select="golomb"
b781cc12 1378sipr_decoder_select="lsp"
05aec7bb
MR
1379snow_decoder_select="dwt"
1380snow_encoder_select="aandct dwt"
19ecfb8a 1381svq1_encoder_select="aandct"
88b97357 1382svq3_decoder_select="golomb h264chroma h264dsp h264pred"
bee2eac5 1383svq3_decoder_suggest="zlib"
4eef77c1 1384theora_decoder_select="vp3_decoder"
2eef7c62
AJ
1385tiff_decoder_suggest="zlib"
1386tiff_encoder_suggest="zlib"
aec09a00 1387truehd_decoder_select="mlp_decoder"
2eef7c62 1388tscc_decoder_select="zlib"
4538729a 1389twinvq_decoder_select="mdct lsp sinewin"
88b97357 1390vc1_decoder_select="h263_decoder h264chroma"
9104cd51 1391vc1_dxva2_hwaccel_deps="dxva2api_h DXVA_PictureParameters_wDecodedPictureIndex"
f0f86627 1392vc1_dxva2_hwaccel_select="dxva2 vc1_decoder"
95a61cfc 1393vc1_vaapi_hwaccel_select="vaapi vc1_decoder"
95a61cfc 1394vc1_vdpau_decoder_select="vdpau vc1_decoder"
45ecda85 1395vc1image_decoder_select="vc1_decoder"
26fbcc85
MR
1396vorbis_decoder_select="mdct"
1397vorbis_encoder_select="mdct"
3447f12d 1398vp6_decoder_select="huffman"
e82dc4c9
DB
1399vp6a_decoder_select="vp6_decoder"
1400vp6f_decoder_select="vp6_decoder"
4a384de5 1401vp8_decoder_select="h264pred"
4538729a
MR
1402wmapro_decoder_select="mdct sinewin"
1403wmav1_decoder_select="mdct sinewin"
1404wmav1_encoder_select="mdct sinewin"
1405wmav2_decoder_select="mdct sinewin"
1406wmav2_encoder_select="mdct sinewin"
1407wmavoice_decoder_select="lsp rdft dct mdct sinewin"
f95bfab0 1408wmv1_decoder_select="h263_decoder"
665507aa 1409wmv1_encoder_select="h263_encoder"
f95bfab0 1410wmv2_decoder_select="h263_decoder"
1746e2a9 1411wmv2_encoder_select="h263_encoder"
015f8ee0 1412wmv3_decoder_select="vc1_decoder"
f0f86627 1413wmv3_dxva2_hwaccel_select="vc1_dxva2_hwaccel"
015f8ee0
DB
1414wmv3_vaapi_hwaccel_select="vc1_vaapi_hwaccel"
1415wmv3_vdpau_decoder_select="vc1_vdpau_decoder"
45ecda85 1416wmv3image_decoder_select="wmv3_decoder"
2eef7c62
AJ
1417zlib_decoder_select="zlib"
1418zlib_encoder_select="zlib"
1419zmbv_decoder_select="zlib"
1420zmbv_encoder_select="zlib"
30fd06be 1421
0afab17e 1422vaapi_deps="va_va_h"
ac3dbb4d 1423vda_deps="VideoDecodeAcceleration_VDADecoder_h pthreads"
c89c96e9
MR
1424vdpau_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
1425
28b80940 1426# parsers
88b97357 1427h264_parser_select="golomb h264chroma h264dsp h264pred"
28b80940 1428
912f3148 1429# external libraries
1b71f045 1430libdirac_decoder_deps="libdirac !libschroedinger"
690bfceb 1431libdirac_encoder_deps="libdirac"
c9171a83 1432libfaac_encoder_deps="libfaac"
299c77d5
MR
1433libgsm_decoder_deps="libgsm"
1434libgsm_encoder_deps="libgsm"
8ffed8d8
MR
1435libgsm_ms_decoder_deps="libgsm"
1436libgsm_ms_encoder_deps="libgsm"
1cc60c47 1437libmp3lame_encoder_deps="libmp3lame"
0b175caa
DB
1438libopencore_amrnb_decoder_deps="libopencore_amrnb"
1439libopencore_amrnb_encoder_deps="libopencore_amrnb"
1440libopencore_amrwb_decoder_deps="libopencore_amrwb"
9a77d59a 1441libopenjpeg_decoder_deps="libopenjpeg"
f7cd9eed
AS
1442libschroedinger_decoder_deps="libschroedinger"
1443libschroedinger_encoder_deps="libschroedinger"
ae14f311 1444libspeex_decoder_deps="libspeex"
b606a017 1445libspeex_encoder_deps="libspeex"
150d2772 1446libtheora_encoder_deps="libtheora"
d89e738a 1447libvo_aacenc_encoder_deps="libvo_aacenc"
f502ff3f 1448libvo_amrwbenc_encoder_deps="libvo_amrwbenc"
b0caf888 1449libvorbis_encoder_deps="libvorbis"
8299a7f8 1450libvpx_decoder_deps="libvpx"
ee0e9146 1451libvpx_encoder_deps="libvpx"
1cc60c47 1452libx264_encoder_deps="libx264"
de295976 1453libxavs_encoder_deps="libxavs"
1cc60c47 1454libxvid_encoder_deps="libxvid"
30fd06be 1455
912f3148 1456# demuxers / muxers
c2dd0e9e 1457ac3_demuxer_select="ac3_parser"
647c2356 1458asf_stream_muxer_select="asf_muxer"
4e622dea 1459avisynth_demuxer_deps="avisynth"
c2dd0e9e 1460dirac_demuxer_select="dirac_parser"
5b423887 1461eac3_demuxer_select="ac3_parser"
c2dd0e9e 1462flac_demuxer_select="flac_parser"
647c2356 1463ipod_muxer_select="mov_muxer"
4e622dea
SS
1464libnut_demuxer_deps="libnut"
1465libnut_muxer_deps="libnut"
647c2356 1466matroska_audio_muxer_select="matroska_muxer"
4e622dea
SS
1467matroska_demuxer_suggest="zlib bzlib"
1468mov_demuxer_suggest="zlib"
c2dd0e9e 1469mp3_demuxer_select="mpegaudio_parser"
647c2356
DB
1470mp4_muxer_select="mov_muxer"
1471mpegtsraw_demuxer_select="mpegts_demuxer"
1472mxf_d10_muxer_select="mxf_muxer"
24ca518b 1473ogg_demuxer_select="golomb"
647c2356 1474psp_muxer_select="mov_muxer"
44594cc7 1475rtp_demuxer_select="sdp_demuxer"
44b70ce5
MS
1476rtpdec_select="asf_demuxer rm_demuxer rtp_protocol mpegts_demuxer mov_demuxer"
1477rtsp_demuxer_select="http_protocol rtpdec"
1478rtsp_muxer_select="rtp_muxer http_protocol rtp_protocol"
01c8d258 1479sap_demuxer_select="sdp_demuxer"
2aab70c4 1480sap_muxer_select="rtp_muxer rtp_protocol"
44b70ce5 1481sdp_demuxer_select="rtpdec"
f1e94694 1482spdif_muxer_select="aac_parser"
647c2356
DB
1483tg2_muxer_select="mov_muxer"
1484tgp_muxer_select="mov_muxer"
6bdaa5f4 1485w64_demuxer_deps="wav_demuxer"
4e622dea
SS
1486
1487# indevs / outdevs
38e54a75 1488alsa_indev_deps="alsa_asoundlib_h snd_pcm_htimestamp"
38e54a75 1489alsa_outdev_deps="alsa_asoundlib_h"
38e54a75 1490bktr_indev_deps_any="dev_bktr_ioctl_bt848_h machine_ioctl_bt848_h dev_video_bktr_ioctl_bt848_h dev_ic_bt8xx_h"
38e54a75 1491dv1394_indev_deps="dv1394 dv_demuxer"
c6f95144 1492fbdev_indev_deps="linux_fb_h"
d788a97c 1493jack_indev_deps="jack_jack_h pthreads"
e417d80d 1494libcdio_indev_deps="libcdio"
38e54a75 1495libdc1394_indev_deps="libdc1394"
38e54a75
SS
1496oss_indev_deps_any="soundcard_h sys_soundcard_h"
1497oss_outdev_deps_any="soundcard_h sys_soundcard_h"
0de9c41f 1498pulse_indev_deps="libpulse"
15d59d2c
B
1499sndio_indev_deps="sndio_h"
1500sndio_outdev_deps="sndio_h"
38e54a75
SS
1501v4l_indev_deps="linux_videodev_h"
1502v4l2_indev_deps_any="linux_videodev2_h sys_videoio_h"
ec1ee802 1503vfwcap_indev_deps="capCreateCaptureWindow vfwcap_defines"
a1b3c5a3 1504vfwcap_indev_extralibs="-lavicap32"
38e54a75 1505x11_grab_device_indev_deps="x11grab XShmCreateImage"
781c1aa6 1506x11_grab_device_indev_extralibs="-lX11 -lXext -lXfixes"
30fd06be 1507
912f3148 1508# protocols
3fff6382 1509gopher_protocol_deps="network"
c40e1757
JS
1510httpproxy_protocol_deps="network"
1511httpproxy_protocol_select="tcp_protocol"
c08fb000 1512http_protocol_deps="network"
279a0c97 1513http_protocol_select="tcp_protocol"
183baead 1514https_protocol_select="tls_protocol"
c60a2d70 1515mmsh_protocol_select="http_protocol"
b4cf3f6c 1516mmst_protocol_deps="network"
deeb7012
MS
1517rtmp_protocol_select="tcp_protocol"
1518rtp_protocol_select="udp_protocol"
c08fb000 1519tcp_protocol_deps="network"
558d192d
MS
1520tls_protocol_deps_any="openssl gnutls"
1521tls_protocol_select="tcp_protocol"
c08fb000
AB
1522udp_protocol_deps="network"
1523
6ebf0bfc 1524# filters
13fabd7a 1525blackframe_filter_deps="gpl"
ce6b6ef6 1526boxblur_filter_deps="gpl"
68b79bfc 1527cropdetect_filter_deps="gpl"
b157be1f 1528delogo_filter_deps="gpl"
a5b64584 1529drawtext_filter_deps="libfreetype"
2e5ff4d0 1530frei0r_filter_deps="frei0r dlopen strtok_r"
a42bb9d6 1531frei0r_src_filter_deps="frei0r dlopen strtok_r"
a4dc7aa5 1532hqdn3d_filter_deps="gpl"
cf69ad35 1533ocv_filter_deps="libopencv"
92fe2587 1534scale_filter_deps="swscale"
acbac567 1535yadif_filter_deps="gpl"
6ebf0bfc 1536
5a0f7131
MR
1537# libraries
1538avdevice_deps="avcodec avformat"
1539avformat_deps="avcodec"
ced9556b 1540postproc_deps="gpl"
f7679c54 1541
912f3148 1542# programs
d2ba1fb5 1543avconv_deps="avcodec avformat swscale"
266463da
AK
1544avplay_deps="avcodec avformat swscale sdl"
1545avplay_select="rdft"
9e12f0bf 1546avprobe_deps="avcodec avformat"
4d58e4cb
AK
1547avserver_deps="avformat ffm_muxer fork rtp_protocol rtsp_demuxer"
1548avserver_extralibs='$ldl'
3e0b1c9a 1549ffmpeg_deps="avcodec avformat swscale"
a2830dca 1550
c73f65d9 1551doc_deps="texi2html"
912f3148 1552
57442411
MR
1553# tests
1554
1555test_deps(){
1556 suf1=$1
1557 suf2=$2
1558 shift 2
1559 for v; do
1560 dep=${v%=*}
1561 tests=${v#*=}
1562 for name in ${tests}; do
908f12f3 1563 append ${name}_test_deps ${dep}$suf1 ${dep}$suf2
57442411
MR
1564 done
1565 done
1566}
1567
908f12f3
MR
1568mxf_d10_test_deps="avfilter"
1569seek_lavf_mxf_d10_test_deps="mxf_d10_test"
1570
57442411 1571test_deps _encoder _decoder \
57442411
MR
1572 adpcm_ima_qt \
1573 adpcm_ima_wav \
1574 adpcm_ms \
1575 adpcm_swf \
1576 adpcm_yamaha=adpcm_yam \
1577 alac \
1578 asv1 \
1579 asv2 \
1580 bmp \
a7638957 1581 dnxhd="dnxhd_1080i dnxhd_720p dnxhd_720p_rd" \
3fe5fc93 1582 dvvideo="dv dv_411 dv50" \
57442411
MR
1583 ffv1 \
1584 flac \
1585 flashsv \
1586 flv \
3e0b1c9a 1587 adpcm_g726=g726 \
57442411
MR
1588 gif \
1589 h261 \
1590 h263="h263 h263p" \
1591 huffyuv \
1592 jpegls \
1593 mjpeg="jpg mjpeg ljpeg" \
1594 mp2 \
1595 mpeg1video="mpeg mpeg1b" \
3fe5fc93
MR
1596 mpeg2video="mpeg2 mpeg2_422 mpeg2_idct_int mpeg2_ilace mpeg2_ivlc_qprd" \
1597 mpeg2video="mpeg2thread mpeg2thread_ilace" \
1598 mpeg4="mpeg4 mpeg4_adap mpeg4_qpel mpeg4_qprd mpeg4adv mpeg4nr" \
1599 mpeg4="mpeg4thread error rc" \
c0b16605 1600 msmpeg4v3=msmpeg4 \
57442411
MR
1601 msmpeg4v2 \
1602 pbm=pbmpipe \
1603 pcx \
1604 pgm="pgm pgmpipe" \
f0f54c29 1605 png \
57442411
MR
1606 ppm="ppm ppmpipe" \
1607 rawvideo="rgb yuv" \
1608 roq \
1609 rv10 \
1610 rv20 \
1611 sgi \
1612 snow="snow snowll" \
1613 svq1 \
1614 targa=tga \
1615 tiff \
1616 wmav1 \
1617 wmav2 \
1618 wmv1 \
1619 wmv2 \
1620
1621test_deps _muxer _demuxer \
1622 aiff \
1623 pcm_alaw=alaw \
1624 asf \
1625 au \
1626 avi \
1627 dv=dv_fmt \
1628 ffm \
1629 flv=flv_fmt \
1630 gxf \
1631 matroska=mkv \
1632 mmf \
1633 mov \
1634 pcm_mulaw=mulaw \
0218808d 1635 mxf="mxf mxf_d10" \
57442411
MR
1636 nut \
1637 ogg \
1638 rawvideo=pixfmt \
1639 rm \
1640 swf \
1641 mpegts=ts \
1642 voc \
1643 wav \
1644 yuv4mpegpipe=yuv4mpeg \
1645
6fd96d1a 1646ac3_fixed_test_deps="ac3_fixed_encoder ac3_decoder rm_muxer rm_demuxer"
57442411 1647mpg_test_deps="mpeg1system_muxer mpegps_demuxer"
9c261f83 1648
de6d9b64 1649# default parameters
8a608357 1650
19bd477d 1651logfile="config.log"
8a608357
MR
1652
1653# installation paths
c9d19248
MR
1654prefix_default="/usr/local"
1655bindir_default='${prefix}/bin'
6291d7e4 1656datadir_default='${prefix}/share/avconv'
c9d19248
MR
1657incdir_default='${prefix}/include'
1658libdir_default='${prefix}/lib'
1659mandir_default='${prefix}/share/man'
1660shlibdir_default="$libdir_default"
8a608357
MR
1661
1662# toolchain
121d78d0 1663ar_default="ar"
13c7df3d 1664cc_default="gcc"
a3d7c197 1665cc_version=\"unknown\"
9da6609f 1666host_cc_default="gcc"
11e6d03a 1667ln_s="ln -sf"
89641463 1668nm_default="nm"
11e6d03a 1669objformat="elf"
3f8040db 1670pkg_config_default=pkg-config
be7109c1 1671ranlib="ranlib"
11e6d03a 1672yasmexe="yasm"
8a608357 1673
8182dc34 1674nm_opts='-g'
3e0b1c9a 1675nogas=":"
8182dc34 1676
8a608357 1677# machine
8d4c00ed 1678arch_default=$(uname -m)
38d0a8aa 1679cpu="generic"
8a608357 1680
8a608357 1681# OS
8d4c00ed
MR
1682target_os_default=$(tolower $(uname -s))
1683host_os=$target_os_default
8a608357 1684
8a608357 1685# configurable options
055c61b8
DB
1686enable $PROGRAM_LIST
1687
5a0f7131
MR
1688enable avcodec
1689enable avdevice
cccc039f 1690enable avfilter
5a0f7131 1691enable avformat
dc4f5a1c 1692enable avutil
3e0b1c9a
DB
1693enable swscale
1694
3e0b1c9a
DB
1695enable asm
1696enable debug
1697enable doc
1698enable fastdiv
497237c7 1699enable network
8400d6b8 1700enable optimizations
8cfbbd92 1701enable safe_bitstream_reader
530dc538 1702enable static
a9ddb5b1 1703enable swscale_alpha
8a608357 1704
8a608357 1705# build settings
9987769a 1706SHFLAGS='-shared -Wl,-soname,$$(@F)'
4d58e4cb 1707AVSERVERLDFLAGS=-Wl,-E
f3ec2d46
SG
1708LIBPREF="lib"
1709LIBSUF=".a"
c5f14466
RP
1710FULLNAME='$(NAME)$(BUILDSUF)'
1711LIBNAME='$(LIBPREF)$(FULLNAME)$(LIBSUF)'
f3ec2d46
SG
1712SLIBPREF="lib"
1713SLIBSUF=".so"
c5f14466 1714SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF)'
b29bddab
DB
1715SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
1716SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
6cfac0e9 1717LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
2f138f0b
MR
1718SLIB_INSTALL_NAME='$(SLIBNAME_WITH_VERSION)'
1719SLIB_INSTALL_LINKS='$(SLIBNAME_WITH_MAJOR) $(SLIBNAME)'
ef0bc4c9 1720
bc877faf 1721AS_O='-o $@'
7e6c86e6
MR
1722CC_O='-o $@'
1723
0a6db2a2 1724host_cflags='-D_ISOC99_SOURCE -O3 -g'
9da6609f
MR
1725host_libs='-lm'
1726
9b861379 1727target_path='$(CURDIR)'
a7ada2ba 1728
a158446b
MR
1729# since the object filename is not given with the -MM flag, the compiler
1730# is only able to print the basename, and we must add the path ourselves
c1c3933a 1731DEPEND_CMD='$(DEPCC) $(DEPFLAGS) $< | sed -e "/^\#.*/d" -e "s,^[[:space:]]*$(*F)\\.o,$(@D)/$(*F).o," > $(@:.o=.d)'
d8059267 1732DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -MM'
315c741d 1733
c597172e 1734# find source path
24524f36 1735if test -f configure; then
f038cf3c 1736 source_path=.
c597172e 1737else
8477f2de 1738 source_path=$(cd $(dirname "$0"); pwd)
c597172e 1739 echo "$source_path" | grep -q '[[:blank:]]' &&
7483e694 1740 die "Out of tree builds are impossible with whitespace in source path."
337cee68
MC
1741 test -e "$source_path/config.h" &&
1742 die "Out of tree builds are impossible with config.h in source dir."
c597172e
MR
1743fi
1744
13cbe2c0 1745for v in "$@"; do
b04251c5
MR
1746 r=${v#*=}
1747 l=${v%"$r"}
1748 r=$(sh_quote "$r")
29ba0911 1749 LIBAV_CONFIGURATION="${LIBAV_CONFIGURATION# } ${l}${r}"
13cbe2c0 1750done
c597172e 1751
73ef8980
MR
1752find_things(){
1753 thing=$1
1754 pattern=$2
1755 file=$source_path/$3
932ccf39 1756 sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" "$file"
73ef8980
MR
1757}
1758
1759ENCODER_LIST=$(find_things encoder ENC libavcodec/allcodecs.c)
1760DECODER_LIST=$(find_things decoder DEC libavcodec/allcodecs.c)
5666fd73 1761HWACCEL_LIST=$(find_things hwaccel HWACCEL libavcodec/allcodecs.c)
73ef8980
MR
1762PARSER_LIST=$(find_things parser PARSER libavcodec/allcodecs.c)
1763BSF_LIST=$(find_things bsf BSF libavcodec/allcodecs.c)
1764MUXER_LIST=$(find_things muxer _MUX libavformat/allformats.c)
1765DEMUXER_LIST=$(find_things demuxer DEMUX libavformat/allformats.c)
38e54a75
SS
1766OUTDEV_LIST=$(find_things outdev OUTDEV libavdevice/alldevices.c)
1767INDEV_LIST=$(find_things indev _IN libavdevice/alldevices.c)
73ef8980 1768PROTOCOL_LIST=$(find_things protocol PROTOCOL libavformat/allformats.c)
81124ba0 1769FILTER_LIST=$(find_things filter FILTER libavfilter/allfilters.c)
c597172e 1770
54e75be4
DB
1771ALL_COMPONENTS="
1772 $BSF_LIST
1773 $DECODER_LIST
1774 $DEMUXER_LIST
1775 $ENCODER_LIST
1776 $FILTER_LIST
1777 $HWACCEL_LIST
1778 $INDEV_LIST
1779 $MUXER_LIST
1780 $OUTDEV_LIST
1781 $PARSER_LIST
1782 $PROTOCOL_LIST
1783"
1784
57442411 1785find_tests(){
b9d5f1b7 1786 map "echo ${2}\${v}_test" $(ls "$source_path"/tests/ref/$1 | grep -v '[^-a-z0-9_]')
57442411
MR
1787}
1788
1789ACODEC_TESTS=$(find_tests acodec)
1790VCODEC_TESTS=$(find_tests vsynth1)
1791LAVF_TESTS=$(find_tests lavf)
48c28162 1792LAVFI_TESTS=$(find_tests lavfi)
b9d5f1b7 1793SEEK_TESTS=$(find_tests seek seek_)
57442411 1794
54e75be4
DB
1795ALL_TESTS="$ACODEC_TESTS $VCODEC_TESTS $LAVF_TESTS $LAVFI_TESTS $SEEK_TESTS"
1796
40fe5019
MR
1797pcm_test_deps=$(map 'echo ${v%_*}_decoder $v' $(filter pcm_* $ENCODER_LIST))
1798
8469ae22
MR
1799for n in $COMPONENT_LIST; do
1800 v=$(toupper ${n%s})_LIST
1801 eval enable \$$v
1802 eval ${n}_if_any="\$$v"
1803done
1804
54e75be4 1805enable $ARCH_EXT_LIST $ALL_TESTS
c597172e
MR
1806
1807die_unknown(){
1808 echo "Unknown option \"$1\"."
1809 echo "See $0 --help for available options."
1810 exit 1
1811}
1812
794f8e97 1813show_list() {
bf0c4afa
RP
1814 suffix=_$1
1815 shift
2b444ea7 1816 echo $* | sed s/$suffix//g | tr ' ' '\n' | sort | pr -3 -t
794f8e97
PI
1817 exit 0
1818}
1819
c597172e 1820for opt do
7483e694
DB
1821 optval="${opt#*=}"
1822 case "$opt" in
0f010b2f 1823 --extra-ldflags=*) add_ldflags $optval
7483e694 1824 ;;
0f010b2f 1825 --extra-libs=*) add_extralibs $optval
7483e694 1826 ;;
8fb1cb58 1827 --disable-devices) disable $INDEV_LIST $OUTDEV_LIST
9aa8ed9d 1828 ;;
40bcf4c7
BL
1829 --enable-debug=*) debuglevel="$optval"
1830 ;;
36e2dea0 1831 --disable-everything)
1b15dc3c 1832 map 'eval unset \${$(toupper ${v%s})_LIST}' $COMPONENT_LIST
36e2dea0 1833 ;;
7483e694 1834 --enable-*=*|--disable-*=*)
8b93ddc3 1835 eval $(echo "${opt%%=*}" | sed 's/--/action=/;s/-/ thing=/')
be8f2501
MR
1836 is_in "${thing}s" $COMPONENT_LIST || die_unknown "$opt"
1837 eval list=\$$(toupper $thing)_LIST
8b93ddc3
MR
1838 name=$(echo "${optval}" | sed "s/,/_${thing}|/g")_${thing}
1839 $action $(filter "$name" $list)
7483e694
DB
1840 ;;
1841 --enable-?*|--disable-?*)
5e622c40 1842 eval $(echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g')
e3773a55 1843 if is_in $option $COMPONENT_LIST; then
fed5d54b 1844 test $action = disable && action=unset
e3773a55
MR
1845 eval $action \$$(toupper ${option%s})_LIST
1846 elif is_in $option $CMDLINE_SELECT; then
1847 $action $option
1848 else
1849 die_unknown $opt
1850 fi
7483e694
DB
1851 ;;
1852 --list-*)
1853 NAME="${opt#--list-}"
1854 is_in $NAME $COMPONENT_LIST || die_unknown $opt
1855 NAME=${NAME%s}
1856 eval show_list $NAME \$$(toupper $NAME)_LIST
1857 ;;
1858 --help|-h) show_help
1859 ;;
1860 *)
884a36a7 1861 optname="${opt%%=*}"
26759c44
MR
1862 optname="${optname#--}"
1863 optname=$(echo "$optname" | sed 's/-/_/g')
89f2932b
MR
1864 if is_in $optname $CMDLINE_SET; then
1865 eval $optname='$optval'
1866 elif is_in $optname $CMDLINE_APPEND; then
1867 append $optname "$optval"
1868 else
1869 die_unknown $opt
1870 fi
7483e694
DB
1871 ;;
1872 esac
c597172e
MR
1873done
1874
bcea99bb
MR
1875disabled logging && logfile=/dev/null
1876
29ba0911 1877echo "# $0 $LIBAV_CONFIGURATION" > $logfile
bcea99bb
MR
1878set >> $logfile
1879
9da6609f
MR
1880test -n "$cross_prefix" && enable cross_compile
1881
8d4c00ed
MR
1882if enabled cross_compile; then
1883 test -n "$arch" && test -n "$target_os" ||
1884 die "Must specify target arch and OS when cross-compiling"
1885fi
1886
1887set_default arch target_os
1888
121d78d0 1889ar_default="${cross_prefix}${ar_default}"
11e6d03a 1890cc_default="${cross_prefix}${cc_default}"
20e0ed95 1891nm_default="${cross_prefix}${nm_default}"
3f8040db 1892pkg_config_default="${cross_prefix}${pkg_config_default}"
adb2b908 1893ranlib="${cross_prefix}${ranlib}"
adb2b908 1894
c5200f17
MR
1895sysinclude_default="${sysroot}/usr/include"
1896
e0be794a 1897set_default cc nm pkg_config sysinclude
9da6609f
MR
1898enabled cross_compile || host_cc_default=$cc
1899set_default host_cc
13c7df3d 1900
762f95e4
MR
1901if ! $pkg_config --version >/dev/null 2>&1; then
1902 warn "$pkg_config not found, library detection may fail."
1903 pkg_config=false
1904fi
1905
82bb3329
MR
1906exesuf() {
1907 case $1 in
1c69c79f 1908 mingw32*|cygwin*|*-dos|freedos|opendos|os/2*|symbian) echo .exe ;;
82bb3329
MR
1909 esac
1910}
1911
1912EXESUF=$(exesuf $target_os)
1913HOSTEXESUF=$(exesuf $host_os)
c0f5b7f1 1914
e4e69e0b 1915# set temporary file name
a49d42c2 1916: ${TMPDIR:=$TEMPDIR}
c51fafa1 1917: ${TMPDIR:=$TMP}
a49d42c2 1918: ${TMPDIR:=/tmp}
e4e69e0b 1919
a210bce2 1920if ! check_cmd mktemp -u XXXXXX; then
54460a83
MR
1921 # simple replacement for missing mktemp
1922 # NOT SAFE FOR GENERAL USE
1923 mktemp(){
09a5c245 1924 echo "${2%%XXX*}.${HOSTNAME}.${UID}.$$"
54460a83
MR
1925 }
1926fi
1927
1928tmpfile(){
1929 tmp=$(mktemp -u "${TMPDIR}/ffconf.XXXXXXXX")$2 &&
1930 (set -C; exec > $tmp) 2>/dev/null ||
f7ba16a7 1931 die "Unable to create temporary file in $TMPDIR."
54460a83
MR
1932 append TMPFILES $tmp
1933 eval $1=$tmp
1934}
1935
1936trap 'rm -f -- $TMPFILES' EXIT
54460a83 1937
55127e7b 1938tmpfile TMPASM .asm
3e0b1c9a
DB
1939tmpfile TMPC .c
1940tmpfile TMPE $EXESUF
1941tmpfile TMPH .h
1942tmpfile TMPO .o
1943tmpfile TMPS .S
1944tmpfile TMPSH .sh
1945tmpfile TMPV .ver
54460a83
MR
1946
1947unset -f mktemp
e4e69e0b 1948
fb3c4ffc
MR
1949chmod +x $TMPE
1950
993f2d0f
MR
1951# make sure we can execute files in $TMPDIR
1952cat > $TMPSH 2>> $logfile <<EOF
1953#! /bin/sh
1954EOF
1955chmod +x $TMPSH >> $logfile 2>&1
1956if ! $TMPSH >> $logfile 2>&1; then
1957 cat <<EOF
1958Unable to create and execute files in $TMPDIR. Set the TMPDIR environment
1959variable to another directory and make sure that it is not mounted noexec.
1960EOF
1961 die "Sanity test failed."
1962fi
993f2d0f 1963
3e0b1c9a 1964filter_asflags=echo
19b4c628
MR
1965filter_cflags=echo
1966filter_cppflags=echo
19b4c628 1967
613a4e3f
MR
1968if $cc -v 2>&1 | grep -q '^gcc.*LLVM'; then
1969 cc_type=llvm_gcc
1970 cc_version=__VERSION__
1971 gcc_extra_ver=$(expr "$($cc --version | head -n1)" : '.*\((.*)\)')
1972 cc_ident="llvm-gcc $($cc -dumpversion) $gcc_extra_ver"
1973 CC_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
1974 AS_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
1975 speed_cflags='-O3'
1976 size_cflags='-Os'
1977elif $cc -v 2>&1 | grep -qi ^gcc; then
629687f6 1978 cc_type=gcc
a3d7c197 1979 cc_version=__VERSION__
5d57846b
MR
1980 gcc_version=$($cc --version | head -n1)
1981 gcc_basever=$($cc -dumpversion)
3ad464bf 1982 gcc_pkg_ver=$(expr "$gcc_version" : '[^ ]* \(([^)]*)\)')
5d57846b
MR
1983 gcc_ext_ver=$(expr "$gcc_version" : ".*$gcc_pkg_ver $gcc_basever \\(.*\\)")
1984 cc_ident=$(cleanws "gcc $gcc_basever $gcc_pkg_ver $gcc_ext_ver")
aef6bd1b
MR
1985 if ! $cc -dumpversion | grep -q '^2\.'; then
1986 CC_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
1987 AS_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
1988 fi
14ca9cd0
MR
1989 speed_cflags='-O3'
1990 size_cflags='-Os'
629687f6
MR
1991elif $cc --version 2>/dev/null | grep -q Intel; then
1992 cc_type=icc
6e3fa35d 1993 cc_version="AV_STRINGIFY(__INTEL_COMPILER)"
bb5cecdc 1994 cc_ident=$($cc --version | head -n1)
bdefad73 1995 icc_version=$($cc -dumpversion)
07dec06e
MR
1996 CC_DEPFLAGS='-MMD'
1997 AS_DEPFLAGS='-MMD'
14ca9cd0
MR
1998 speed_cflags='-O3'
1999 size_cflags='-Os'
b05394a0 2000 noopt_cflags='-O1'
629687f6
MR
2001elif $cc -v 2>&1 | grep -q xlc; then
2002 cc_type=xlc
6e3fa35d 2003 cc_version="AV_STRINGIFY(__IBMC__)"
bb5cecdc 2004 cc_ident=$($cc -qversion 2>/dev/null | head -n1)
14ca9cd0
MR
2005 speed_cflags='-O5'
2006 size_cflags='-O5 -qcompact'
df442a8d
MR
2007elif $cc -V 2>/dev/null | grep -q Compaq; then
2008 cc_type=ccc
6e3fa35d 2009 cc_version="AV_STRINGIFY(__DECC_VER)"
bb5cecdc 2010 cc_ident=$($cc -V | head -n1 | cut -d' ' -f1-3)
d8059267 2011 DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -M'
03754fcd 2012 debuglevel=3
df442a8d 2013 add_ldflags -Wl,-z,now # calls to libots crash without this
14ca9cd0
MR
2014 speed_cflags='-fast'
2015 size_cflags='-O1'
6a0d5493 2016elif $cc --vsn 2>/dev/null | grep -q "ARM C/C++ Compiler"; then
03e37762
MR
2017 test -d "$sysroot" || die "No valid sysroot specified."
2018 cc_type=armcc
6e3fa35d 2019 cc_version="AV_STRINGIFY(__ARMCC_VERSION)"
bb5cecdc 2020 cc_ident=$($cc --vsn | head -n1)
03e37762
MR
2021 armcc_conf="$PWD/armcc.conf"
2022 $cc --arm_linux_configure \
2023 --arm_linux_config_file="$armcc_conf" \
2024 --configure_sysroot="$sysroot" \
2025 --configure_cpp_headers="$sysinclude" >>$logfile 2>&1 ||
2026 die "Error creating armcc configuration file."
bcafde61 2027 $cc --vsn | grep -q RVCT && armcc_opt=rvct || armcc_opt=armcc
03e37762 2028 cc="$cc --arm_linux_config_file=$armcc_conf --translate_gcc"
75800dce 2029 as_default="${cross_prefix}gcc"
07dec06e
MR
2030 CC_DEPFLAGS='-MMD'
2031 AS_DEPFLAGS='-MMD'
14ca9cd0
MR
2032 speed_cflags='-O3'
2033 size_cflags='-Os'
d0f0f628 2034 filter_asflags="filter_out -W${armcc_opt}*"
6fec122a
MR
2035elif $cc -version 2>/dev/null | grep -q TMS470; then
2036 cc_type=tms470
6e3fa35d 2037 cc_version="AV_STRINGIFY(__TI_COMPILER_VERSION__)"
bb5cecdc 2038 cc_ident=$($cc -version | head -n1 | tr -s ' ')
6fec122a
MR
2039 cc="$cc --gcc --abi=eabi -eo=.o -mc -me"
2040 CC_O='-fr=$(@D)'
2041 as_default="${cross_prefix}gcc"
2042 ld_default="${cross_prefix}gcc"
6fec122a
MR
2043 TMPO=$(basename $TMPC .c).o
2044 append TMPFILES $TMPO
2045 add_cflags -D__gnuc_va_list=va_list -D__USER_LABEL_PREFIX__=
07dec06e
MR
2046 CC_DEPFLAGS='-ppa -ppd=$(@:.o=.d)'
2047 AS_DEPFLAGS='-MMD'
14ca9cd0
MR
2048 speed_cflags='-O3 -mf=5'
2049 size_cflags='-O3 -mf=2'
6fec122a
MR
2050 filter_cflags=tms470_flags
2051 tms470_flags(){
2052 for flag; do
2053 case $flag in
2054 -march=*|-mcpu=*)
2055 case "${flag#*=}" in
2056 armv7-a|cortex-a*) echo -mv=7a8 ;;
2057 armv7-r|cortex-r*) echo -mv=7r4 ;;
2058 armv7-m|cortex-m*) echo -mv=7m3 ;;
2059 armv6*|arm11*) echo -mv=6 ;;
2060 armv5*e|arm[79]*e*|arm9[24]6*|arm96*|arm102[26])
2061 echo -mv=5e ;;
2062 armv4*|arm7*|arm9[24]*) echo -mv=4 ;;
2063 esac
2064 ;;
2065 -mfpu=neon) echo --float_support=vfpv3 --neon ;;
2066 -mfpu=vfp) echo --float_support=vfpv2 ;;
5fcb865b 2067 -mfpu=vfpv3) echo --float_support=vfpv3 ;;
a2709020 2068 -msoft-float) echo --float_support=vfplib ;;
14ca9cd0 2069 -O[0-3]|-mf=*) echo $flag ;;
6fec122a 2070 -g) echo -g -mn ;;
587d24ff 2071 -pds=*) echo $flag ;;
6fec122a
MR
2072 esac
2073 done
2074 }
06da6943
DC
2075elif $cc -v 2>&1 | grep -q clang; then
2076 cc_type=clang
b67a8f49
DC
2077 $cc -dM -E $TMPC | grep -q __clang_version__ &&
2078 cc_version=__clang_version__ || cc_version=__VERSION__
bb5cecdc 2079 cc_ident=$($cc --version | head -n1)
06da6943
DC
2080 CC_DEPFLAGS='-MMD'
2081 AS_DEPFLAGS='-MMD'
14ca9cd0
MR
2082 speed_cflags='-O3'
2083 size_cflags='-Os'
2a472e9c
MK
2084elif $cc -V 2>&1 | grep -q Sun; then
2085 cc_type=suncc
2086 cc_version="AV_STRINGIFY(__SUNPRO_C)"
448f5b83 2087 cc_ident=$($cc -V 2>&1 | head -n1 | cut -d' ' -f 2-)
faa374b7 2088 DEPEND_CMD='$(DEPCC) $(DEPFLAGS) $< | sed -e "1s,^.*: ,$@: ," -e "\$$!s,\$$, \\\," -e "1!s,^.*: , ," > $(@:.o=.d)'
2a472e9c 2089 DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -xM1'
558c2683 2090 add_ldflags -xc99
14ca9cd0
MR
2091 speed_cflags='-O5'
2092 size_cflags='-O5 -xspace'
03279bbe
MK
2093 filter_cflags=suncc_flags
2094 suncc_flags(){
2095 for flag; do
2096 case $flag in
2097 -march=*|-mcpu=*)
2098 case "${flag#*=}" in
2099 native) echo -xtarget=native ;;
87ddc38b 2100 v9|niagara) echo -xarch=sparc ;;
03279bbe 2101 ultrasparc) echo -xarch=sparcvis ;;
87ddc38b 2102 ultrasparc3|niagara2) echo -xarch=sparcvis2 ;;
03279bbe
MK
2103 i586|pentium) echo -xchip=pentium ;;
2104 i686|pentiumpro|pentium2) echo -xtarget=pentium_pro ;;
2105 pentium3*|c3-2) echo -xtarget=pentium3 ;;
2106 pentium-m) echo -xarch=sse2 -xchip=pentium3 ;;
2107 pentium4*) echo -xtarget=pentium4 ;;
2108 prescott|nocona) echo -xarch=sse3 -xchip=pentium4 ;;
2109 *-sse3) echo -xarch=sse3 ;;
2110 core2) echo -xarch=ssse3 -xchip=core2 ;;
2111 amdfam10|barcelona) echo -xarch=sse4_1 ;;
2112 athlon-4|athlon-[mx]p) echo -xarch=ssea ;;
2113 k8|opteron|athlon64|athlon-fx)
2114 echo -xarch=sse2a ;;
2115 athlon*) echo -xarch=pentium_proa ;;
2116 esac
2117 ;;
2118 -std=c99) echo -xc99 ;;
2119 -fomit-frame-pointer) echo -xregs=frameptr ;;
2120 -fPIC) echo -KPIC -xcode=pic32 ;;
03279bbe
MK
2121 -W*,*) echo $flag ;;
2122 -f*-*|-W*) ;;
2123 *) echo $flag ;;
2124 esac
2125 done
2126 }
180ec37d 2127elif $cc -v 2>&1 | grep -q 'PathScale\|Path64'; then
349d78fe
MR
2128 cc_type=pathscale
2129 cc_version=__PATHSCALE__
2130 cc_ident=$($cc -v 2>&1 | head -n1 | tr -d :)
2131 CC_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
2132 AS_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
2133 speed_cflags='-O2'
2134 size_cflags='-Os'
7b2d2190 2135 filter_cflags='filter_out -Wdisabled-optimization'
6de163e9
MR
2136elif $cc -v 2>&1 | grep -q Open64; then
2137 cc_type=open64
2138 cc_version=__OPEN64__
2139 cc_ident=$($cc -v 2>&1 | head -n1 | tr -d :)
2140 CC_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
2141 AS_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
2142 speed_cflags='-O2'
2143 size_cflags='-Os'
7b2d2190 2144 filter_cflags='filter_out -Wdisabled-optimization|-Wtype-limits|-fno-signed-zeros'
629687f6
MR
2145fi
2146
851ffa80
MR
2147test -n "$cc_type" && enable $cc_type ||
2148 warn "Unknown C compiler $cc, unable to select optimal CFLAGS"
629687f6 2149
75bafbac 2150: ${as_default:=$cc}
50567afa 2151: ${dep_cc_default:=$cc}
684b28e0 2152: ${ld_default:=$cc}
121d78d0 2153set_default ar as dep_cc ld
75800dce 2154
07dec06e
MR
2155test -n "$CC_DEPFLAGS" || CCDEP=$DEPEND_CMD
2156test -n "$AS_DEPFLAGS" || ASDEP=$DEPEND_CMD
2157
7f32f40c 2158add_cflags $extra_cflags
2f2e6c7c 2159add_asflags $extra_cflags
7f32f40c 2160
154d432c
MR
2161if test -n "$sysroot"; then
2162 case "$cc_type" in
00ba041c 2163 gcc|llvm_gcc|clang)
467256f2 2164 add_cppflags --sysroot="$sysroot"
154d432c
MR
2165 add_ldflags --sysroot="$sysroot"
2166 ;;
6fec122a
MR
2167 tms470)
2168 add_cppflags -I"$sysinclude"
2169 add_ldflags --sysroot="$sysroot"
2170 ;;
154d432c
MR
2171 esac
2172fi
2173
d22c13a8
MR
2174if test "$cpu" = host; then
2175 enabled cross_compile && die "--cpu=host makes no sense when cross-compiling."
2176
2177 case "$cc_type" in
613a4e3f 2178 gcc|llvm_gcc)
d22c13a8
MR
2179 check_native(){
2180 $cc $1=native -v -c -o $TMPO $TMPC >$TMPE 2>&1 || return
b695256e 2181 sed -n "/cc1.*$1=/{
27ce1be8
MR
2182 s/.*$1=\\([^ ]*\\).*/\\1/
2183 p
2184 q
2185 }" $TMPE
d22c13a8
MR
2186 }
2187 cpu=$(check_native -march || check_native -mcpu)
2188 ;;
2189 esac
2190
2191 test "${cpu:-host}" = host && die "--cpu=host not supported with compiler $cc"
2192fi
2193
e939cedd
MR
2194# Deal with common $arch aliases
2195case "$arch" in
2196 arm*)
2197 arch="arm"
2198 ;;
2199 mips|mipsel|IP*)
2200 arch="mips"
2201 ;;
47b1860e 2202 mips64*)
e939cedd
MR
2203 arch="mips"
2204 subarch="mips64"
2205 ;;
2206 parisc|hppa)
2207 arch="parisc"
2208 ;;
2209 parisc64|hppa64)
2210 arch="parisc"
2211 subarch="parisc64"
2212 ;;
2213 "Power Macintosh"|ppc|powerpc)
2214 arch="ppc"
2215 ;;
47b1860e 2216 ppc64|powerpc64)
e939cedd
MR
2217 arch="ppc"
2218 subarch="ppc64"
2219 ;;
2220 s390|s390x)
2221 arch="s390"
2222 ;;
2223 sh4|sh)
2224 arch="sh4"
2225 ;;
2226 sun4u|sparc64)
2227 arch="sparc"
2228 subarch="sparc64"
2229 ;;
d33ed7b3 2230 i[3-6]86|i86pc|BePC|x86pc|x86_64|amd64)
e939cedd
MR
2231 arch="x86"
2232 ;;
2233esac
2234
851ffa80 2235is_in $arch $ARCH_LIST || warn "unknown architecture $arch"
343aef9b 2236enable $arch
e939cedd 2237
df5cdc24 2238# Add processor-specific flags
5d54c126
MR
2239if test "$cpu" = generic; then
2240 : do nothing
2241elif enabled ppc; then
343aef9b 2242
56348891
MR
2243 case $(tolower $cpu) in
2244 601|ppc601|powerpc601)
9dbd5c3d 2245 cpuflags="-mcpu=601"
64ad53ff 2246 disable altivec
9dbd5c3d 2247 ;;
56348891 2248 603*|ppc603*|powerpc603*)
9dbd5c3d 2249 cpuflags="-mcpu=603"
64ad53ff 2250 disable altivec
9dbd5c3d 2251 ;;
56348891 2252 604*|ppc604*|powerpc604*)
9dbd5c3d 2253 cpuflags="-mcpu=604"
64ad53ff 2254 disable altivec
9dbd5c3d 2255 ;;
56348891 2256 g3|75*|ppc75*|powerpc75*)
9dbd5c3d 2257 cpuflags="-mcpu=750 -mpowerpc-gfxopt"
64ad53ff 2258 disable altivec
9dbd5c3d 2259 ;;
56348891 2260 g4|745*|ppc745*|powerpc745*)
9dbd5c3d
MR
2261 cpuflags="-mcpu=7450 -mpowerpc-gfxopt"
2262 ;;
56348891 2263 74*|ppc74*|powerpc74*)
9dbd5c3d
MR
2264 cpuflags="-mcpu=7400 -mpowerpc-gfxopt"
2265 ;;
56348891 2266 g5|970|ppc970|powerpc970|power4*)
9dbd5c3d
MR
2267 cpuflags="-mcpu=970 -mpowerpc-gfxopt -mpowerpc64"
2268 ;;
56348891 2269 cell)
9dbd5c3d
MR
2270 cpuflags="-mcpu=cell"
2271 enable ldbrx
2272 ;;
7b0b81a1
AL
2273 e500v2)
2274 cpuflags="-mcpu=8548 -mhard-float -mfloat-gprs=double"
2275 disable altivec
2276 ;;
2277 e500)
2278 cpuflags="-mcpu=8540 -mhard-float"
2279 disable altivec
2280 ;;
9dbd5c3d 2281 esac
343aef9b
MR
2282
2283elif enabled x86; then
2284
9dbd5c3d
MR
2285 case $cpu in
2286 i[345]86|pentium)
2287 cpuflags="-march=$cpu"
2288 disable mmx
2289 ;;
2290 # targets that do NOT support conditional mov (cmov)
2291 pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
2292 cpuflags="-march=$cpu"
2293 disable cmov
2294 ;;
2295 # targets that do support conditional mov (cmov)
9ddf1b1a 2296 i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64*|k8*|opteron*|athlon-fx|core2|amdfam10|barcelona|atom)
9dbd5c3d
MR
2297 cpuflags="-march=$cpu"
2298 enable cmov
2299 enable fast_cmov
2300 ;;
2301 # targets that do support conditional mov but on which it's slow
2302 pentium4|pentium4m|prescott|nocona)
2303 cpuflags="-march=$cpu"
2304 enable cmov
2305 disable fast_cmov
2306 ;;
2307 esac
343aef9b
MR
2308
2309elif enabled sparc; then
2310
9dbd5c3d 2311 case $cpu in
26b7199e
MK
2312 niagara)
2313 cpuflags="-mcpu=$cpu"
2314 disable vis
2315 ;;
9dbd5c3d
MR
2316 sparc64)
2317 cpuflags="-mcpu=v9"
2318 ;;
2319 esac
343aef9b
MR
2320
2321elif enabled arm; then
2322
34ba23c9
MR
2323 case $cpu in
2324 armv*)
2325 cpuflags="-march=$cpu"
c2eae137 2326 subarch=$(echo $cpu | sed 's/[^a-z0-9]//g')
34ba23c9
MR
2327 ;;
2328 *)
2329 cpuflags="-mcpu=$cpu"
c2eae137
MR
2330 case $cpu in
2331 cortex-a*) subarch=armv7a ;;
2332 cortex-r*) subarch=armv7r ;;
9e19704a 2333 cortex-m*) enable thumb; subarch=armv7m ;;
c2eae137
MR
2334 arm11*) subarch=armv6 ;;
2335 arm[79]*e*|arm9[24]6*|arm96*|arm102[26]) subarch=armv5te ;;
2336 armv4*|arm7*|arm9[24]*) subarch=armv4 ;;
2337 esac
34ba23c9
MR
2338 ;;
2339 esac
343aef9b
MR
2340
2341elif enabled alpha; then
2342
34ba23c9 2343 enabled ccc && cpuflags="-arch $cpu" || cpuflags="-mcpu=$cpu"
343aef9b
MR
2344
2345elif enabled bfin; then
2346
34ba23c9 2347 cpuflags="-mcpu=$cpu"
343aef9b
MR
2348
2349elif enabled mips; then
2350
34ba23c9 2351 cpuflags="-march=$cpu"
343aef9b
MR
2352
2353elif enabled avr32; then
2354
9dbd5c3d
MR
2355 case $cpu in
2356 ap7[02]0[0-2])
2357 subarch="avr32_ap"
2358 cpuflags="-mpart=$cpu"
2359 ;;
2360 ap)
2361 subarch="avr32_ap"
2362 cpuflags="-march=$cpu"
2363 ;;
2364 uc3[ab]*)
2365 subarch="avr32_uc"
2366 cpuflags="-mcpu=$cpu"
2367 ;;
2368 uc)
2369 subarch="avr32_uc"
2370 cpuflags="-march=$cpu"
2371 ;;
2372 esac
df5cdc24 2373
343aef9b
MR
2374fi
2375
df5cdc24
MR
2376add_cflags $cpuflags
2377add_asflags $cpuflags
2378
993f2d0f
MR
2379# compiler sanity check
2380check_exec <<EOF
2381int main(void){ return 0; }
2382EOF
2383if test "$?" != 0; then
2384 echo "$cc is unable to create an executable file."
2385 if test -z "$cross_prefix" && ! enabled cross_compile ; then
2386 echo "If $cc is a cross-compiler, use the --enable-cross-compile option."
2387 echo "Only do this if you know what cross compiling means."
2388 fi
2389 die "C compiler test failed."
2390fi
2391
046f081b 2392add_cppflags -D_ISOC99_SOURCE
e9b9a2f8 2393check_cflags -std=c99
50a334e4 2394check_cc -D_FILE_OFFSET_BITS=64 <<EOF && add_cppflags -D_FILE_OFFSET_BITS=64
9d821fc2
DB
2395#include <stdlib.h>
2396EOF
50a334e4 2397check_cc -D_LARGEFILE_SOURCE <<EOF && add_cppflags -D_LARGEFILE_SOURCE
9d821fc2
DB
2398#include <stdlib.h>
2399EOF
e9b9a2f8 2400
f0125de9 2401check_host_cflags -std=c99
0a6db2a2 2402check_host_cflags -Wall
f0125de9 2403
b24dbcbd 2404case "$arch" in
6b70965f 2405 alpha|ia64|mips|parisc|ppc|sparc)
8a3c8627 2406 spic=$shared
b24dbcbd 2407 ;;
e939cedd 2408 x86)
cfdb6148 2409 subarch="x86_32"
e939cedd 2410 check_cc <<EOF && subarch="x86_64"
58b3536d 2411 int test[(int)sizeof(char*) - 7];
cfdb6148 2412EOF
de27f4d9 2413 if test "$subarch" = "x86_64"; then
e939cedd 2414 spic=$shared
de27f4d9 2415 fi
b24dbcbd 2416 ;;
b24dbcbd
RP
2417esac
2418
343aef9b 2419enable $subarch
8a3c8627 2420enabled spic && enable pic
b24dbcbd 2421
7483e694 2422# OS specific
4f854758 2423case $target_os in
a1629e28 2424 haiku)
63ae7e7c 2425 prefix_default="/boot/common"
108caaaa 2426 network_extralibs="-lnetwork"
f59c4bd6 2427 host_libs=
a1629e28 2428 ;;
7483e694 2429 sunos)
4d58e4cb 2430 AVSERVERLDFLAGS=""
9987769a 2431 SHFLAGS='-shared -Wl,-h,$$(@F)'
0600d30a 2432 enabled x86 && SHFLAGS="-mimpure-text $SHFLAGS"
7483e694 2433 network_extralibs="-lsocket -lnsl"
50a334e4 2434 add_cppflags -D__EXTENSIONS__
87a74f47
SM
2435 # When using suncc to build, the Solaris linker will mark
2436 # an executable with each instruction set encountered by
2437 # the Solaris assembler. As our libraries contain their own
2438 # guards for processor-specific code, instead suppress
2439 # generation of the HWCAPS ELF section on Solaris x86 only.
2440 enabled_all suncc x86 && echo "hwcap_1 = OVERRIDE;" > mapfile && add_ldflags -Wl,-M,mapfile
8182dc34 2441 nm_opts='-P -g'
7483e694
DB
2442 ;;
2443 netbsd)
a1e4b3f6 2444 disable symver
07a8eef6
MR
2445 oss_indev_extralibs="-lossaudio"
2446 oss_outdev_extralibs="-lossaudio"
7483e694
DB
2447 ;;
2448 openbsd)
89e053f8 2449 enable malloc_aligned
7c4a001a 2450 # On OpenBSD 4.5. the compiler does not use PIC unless
070c5d0f 2451 # explicitly using -fPIC. Libav builds fine without PIC,
7c4a001a
MR
2452 # however the generated executable will not do anything
2453 # (simply quits with exit-code 1, no crash, no output).
a7b9c8ae 2454 # Thus explicitly enable PIC here.
cd78208b 2455 enable pic
a1e4b3f6 2456 disable symver
7483e694 2457 SHFLAGS='-shared'
07a8eef6
MR
2458 oss_indev_extralibs="-lossaudio"
2459 oss_outdev_extralibs="-lossaudio"
7483e694 2460 ;;
a1e4b3f6
MR
2461 dragonfly)
2462 enable malloc_aligned
2463 disable symver
2464 ;;
2465 freebsd)
89e053f8 2466 enable malloc_aligned
7483e694
DB
2467 ;;
2468 bsd/os)
355d81df 2469 add_extralibs -lpoll -lgnugetopt
7483e694
DB
2470 ;;
2471 darwin)
89e053f8 2472 enable malloc_aligned
301ab19d 2473 gas="gas-preprocessor.pl $cc"
e08b8239 2474 enabled ppc && add_asflags -force_cpusubtype_ALL
dff68563
SM
2475 SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(SHLIBDIR)/$(SLIBNAME),-current_version,$(LIBVERSION),-compatibility_version,$(LIBMAJOR)'
2476 enabled x86_32 && append SHFLAGS -Wl,-read_only_relocs,suppress
355d81df 2477 add_ldflags -Wl,-dynamic,-search_paths_first
7483e694
DB
2478 SLIBSUF=".dylib"
2479 SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME).$(LIBVERSION)$(SLIBSUF)'
2480 SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME).$(LIBMAJOR)$(SLIBSUF)'
4d58e4cb 2481 AVSERVERLDFLAGS=-Wl,-bind_at_load
304d586d 2482 objformat="macho"
1b0f6fb8 2483 enabled x86_64 && objformat="macho64"
8dfa86f7 2484 enabled_any pic shared ||
2704bd1a 2485 { check_cflags -mdynamic-no-pic && add_asflags -mdynamic-no-pic; }
7483e694
DB
2486 ;;
2487 mingw32*)
9d3f4f50 2488 if test $target_os = "mingw32ce"; then
1aa71e25
MS
2489 disable network
2490 else
2491 target_os=mingw32
2492 fi
dcc01c06 2493 LIBTARGET=i386
1fc9fb8a 2494 if enabled x86_64; then
89e053f8 2495 enable malloc_aligned
417516f6 2496 LIBTARGET="i386:x86-64"
336cc1b0 2497 elif enabled arm; then
15c5156d 2498 LIBTARGET=arm-wince
dcc01c06 2499 fi
fbd971a4 2500 shlibdir_default="$bindir_default"
7483e694
DB
2501 SLIBPREF=""
2502 SLIBSUF=".dll"
7483e694
DB
2503 SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
2504 SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
2f138f0b
MR
2505 SLIB_EXTRA_CMD=-'$(DLLTOOL) -m $(LIBTARGET) -d $$(@:$(SLIBSUF)=.def) -l $(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib) -D $(SLIBNAME_WITH_MAJOR)'
2506 SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
2507 SLIB_INSTALL_LINKS=
2508 SLIB_INSTALL_EXTRA_SHLIB='$(SLIBNAME:$(SLIBSUF)=.lib)'
2509 SLIB_INSTALL_EXTRA_LIB='lib$(SLIBNAME:$(SLIBSUF)=.dll.a) $(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.def)'
4b51fb1c 2510 SHFLAGS='-shared -Wl,--output-def,$$(@:$(SLIBSUF)=.def) -Wl,--out-implib,$(SUBDIR)lib$(SLIBNAME:$(SLIBSUF)=.dll.a) -Wl,--enable-runtime-pseudo-reloc -Wl,--enable-auto-image-base'
304d586d 2511 objformat="win32"
ec10a9ab 2512 dlltool="${cross_prefix}dlltool"
bc574408 2513 enable dos_paths
1894e741 2514 check_cflags -fno-common
e26011d0
RP
2515 check_cpp_condition _mingw.h "defined (__MINGW64_VERSION_MAJOR) || (__MINGW32_MAJOR_VERSION > 3) \
2516 || (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" ||
f7ad5aa2 2517 die "ERROR: MinGW runtime version must be >= 3.15."
5666a9f2 2518 add_cppflags -U__STRICT_ANSI__
7483e694
DB
2519 ;;
2520 cygwin*)
4f854758 2521 target_os=cygwin
fbd971a4 2522 shlibdir_default="$bindir_default"
7483e694
DB
2523 SLIBPREF="cyg"
2524 SLIBSUF=".dll"
2525 SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
2526 SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
2527 SHFLAGS='-shared -Wl,--enable-auto-image-base'
304d586d 2528 objformat="win32"
bc574408 2529 enable dos_paths
1894e741 2530 check_cflags -fno-common
a7a187a1 2531 add_cppflags -U__STRICT_ANSI__
7483e694 2532 ;;
4f365f37 2533 *-dos|freedos|opendos)
4f365f37 2534 network_extralibs="-lsocket"
ff1c015d 2535 objformat="coff"
bc574408 2536 enable dos_paths
a7a187a1 2537 add_cppflags -U__STRICT_ANSI__
4f365f37 2538 ;;
7483e694 2539 linux)
046f081b 2540 add_cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
7483e694
DB
2541 enable dv1394
2542 ;;
2543 irix*)
4f854758 2544 target_os=irix
7483e694
DB
2545 ranlib="echo ignoring ranlib"
2546 ;;
d22e8442 2547 os/2*)
d22e8442 2548 ln_s="cp -f"
9297f1ed 2549 objformat="aout"
e14574eb 2550 add_cppflags -D_GNU_SOURCE
355d81df 2551 add_ldflags -Zomf -Zbin-files -Zargs-wild -Zmap
71c61f62 2552 SHFLAGS='$(SUBDIR)$(NAME).def -Zdll -Zomf'
4d58e4cb 2553 AVSERVERLDFLAGS=""
287d3b13 2554 LIBSUF="_s.a"
d22e8442
DY
2555 SLIBPREF=""
2556 SLIBSUF=".dll"
2557 SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
2558 SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(shell echo $(NAME) | cut -c1-6)$(LIBMAJOR)$(SLIBSUF)'
71c61f62
MR
2559 SLIB_CREATE_DEF_CMD='echo LIBRARY $(SLIBNAME_WITH_MAJOR) INITINSTANCE TERMINSTANCE > $(SUBDIR)$(NAME).def; \
2560 echo PROTMODE >> $(SUBDIR)$(NAME).def; \
2561 echo CODE PRELOAD MOVEABLE DISCARDABLE >> $(SUBDIR)$(NAME).def; \
2562 echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $(SUBDIR)$(NAME).def; \
2563 echo EXPORTS >> $(SUBDIR)$(NAME).def; \
2564 emxexp -o $(OBJS) >> $(SUBDIR)$(NAME).def'
2565 SLIB_EXTRA_CMD='emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(NAME).def; \
2566 emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib $(SUBDIR)$(NAME).def;'
2f138f0b 2567 SLIB_INSTALL_EXTRA_LIB='$(LIBPREF)$(NAME)_dll.a $(LIBPREF)$(NAME)_dll.lib'
bc574408 2568 enable dos_paths
d22e8442 2569 ;;
83993c1c 2570 gnu/kfreebsd)
c1f54478 2571 add_cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -D_BSD_SOURCE
83993c1c 2572 ;;
34e82167 2573 gnu)
f60d1366 2574 add_cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
34e82167 2575 ;;
d33ed7b3
MR
2576 qnx)
2577 add_cppflags -D_QNX_SOURCE
2578 network_extralibs="-lsocket"
2579 ;;
1c69c79f
MS
2580 symbian)
2581 SLIBSUF=".dll"
2582 enable dos_paths
e3bc07f4
MS
2583 add_cflags --include=$sysinclude/gcce/gcce.h -fvisibility=default
2584 add_cppflags -D__GCCE__ -D__SYMBIAN32__ -DSYMBIAN_OE_POSIX_SIGNALS
2585 add_ldflags -Wl,--target1-abs,--no-undefined \
2586 -Wl,-Ttext,0x80000,-Tdata,0x1000000 -shared \
2587 -Wl,--entry=_E32Startup -Wl,-u,_E32Startup
2588 add_extralibs -l:eexe.lib -l:usrt2_2.lib -l:dfpaeabi.dso \
2589 -l:drtaeabi.dso -l:scppnwdl.dso -lsupc++ -lgcc \
2590 -l:libc.dso -l:libm.dso -l:euser.dso -l:libcrt0.lib
1c69c79f 2591 ;;
614d8911
MR
2592 none)
2593 ;;
7483e694 2594 *)
4f924f9a 2595 die "Unknown OS '$target_os'."
7483e694
DB
2596 ;;
2597esac
2598
29ba0911 2599echo "config:$arch:$subarch:$cpu:$target_os:$cc_ident:$LIBAV_CONFIGURATION" >config.fate
db7515fd 2600
13cb2187
AS
2601check_cpp_condition stdlib.h "defined(__PIC__) || defined(__pic__) || defined(PIC)" && enable pic
2602
c9d19248
MR
2603set_default $PATHS_LIST
2604
320d060a 2605# we need to build at least one lib type
93b3c083 2606if ! enabled_any static shared; then
320d060a
DB
2607 cat <<EOF
2608At least one library type must be built.
2609Specify --enable-static to build the static libraries or --enable-shared to
2610build the shared libraries as well. To only build the shared libraries specify
2611--disable-static in addition to --enable-shared.
2612EOF
2613 exit 1;
2614fi
2615
2184c6f7 2616die_license_disabled() {
4c27207c 2617 enabled $1 || { enabled $2 && die "$2 is $1 and --enable-$1 is not specified."; }
2184c6f7
DB
2618}
2619
e417d80d 2620die_license_disabled gpl libcdio
2184c6f7 2621die_license_disabled gpl libx264
de295976 2622die_license_disabled gpl libxavs
2184c6f7 2623die_license_disabled gpl libxvid
2184c6f7
DB
2624die_license_disabled gpl x11grab
2625
2f7ae63b 2626die_license_disabled nonfree libfaac
a060866f 2627die_license_disabled nonfree openssl
b2e3c528 2628
0b175caa
DB
2629die_license_disabled version3 libopencore_amrnb
2630die_license_disabled version3 libopencore_amrwb
d89e738a 2631die_license_disabled version3 libvo_aacenc
f502ff3f 2632die_license_disabled version3 libvo_amrwbenc
0b175caa 2633
9cad0e4e 2634enabled version3 && { enabled gpl && enable gplv3 || enable lgplv3; }
3fe142e2 2635
40617a6d 2636disabled optimizations || check_cflags -fomit-frame-pointer
cf9d24ad 2637
e276d9e8
MR
2638enable_pic() {
2639 enable pic
bce7b696
MR
2640 add_cppflags -DPIC
2641 add_cflags -fPIC
2642 add_asflags -fPIC
e276d9e8
MR
2643}
2644
2645enabled pic && enable_pic
bce7b696 2646
b4d96ba2
MR
2647check_cc <<EOF || die "Symbol mangling check failed."
2648int ff_extern;
2649EOF
8182dc34 2650sym=$($nm $nm_opts $TMPO | awk '/ff_extern/{ print substr($0, match($0, /[^ \t]*ff_extern/)) }')
b4d96ba2
MR
2651extern_prefix=${sym%%ff_extern*}
2652
f65883c8
MR
2653check_cc <<EOF && enable inline_asm
2654void foo(void) { __asm__ volatile ("" ::); }
2655EOF
61d251db 2656
df5e3978
MR
2657_restrict=
2658for restrict_keyword in restrict __restrict__ __restrict; do
2659 check_cc <<EOF && _restrict=$restrict_keyword && break
2660void foo(char * $restrict_keyword p);
2661EOF
2662done
2663
2664check_cc <<EOF && enable attribute_packed
2665struct { int x; } __attribute__((packed)) x;
2666EOF
2667
dffb41b9
MR
2668check_cc <<EOF && enable attribute_may_alias
2669union { int x; } __attribute__((may_alias)) x;
2670EOF
2671
df5e3978
MR
2672check_cc <<EOF || die "endian test failed"
2673unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
2674EOF
48fc536a 2675od -t x1 $TMPO | grep -q '42 *49 *47 *45' && enable bigendian
df5e3978 2676
e939cedd
MR
2677if enabled alpha; then
2678
2679 check_cflags -mieee
2680
2681elif enabled arm; then
e45391bb 2682
8986fddc 2683 enabled thumb && check_cflags -mthumb || check_cflags -marm
301ab19d 2684 nogas=die
50fa82e6 2685
44caaa56
MR
2686 if check_cpp_condition stddef.h "defined __ARM_PCS_VFP"; then
2687 enable vfp_args
2688 elif ! check_cpp_condition stddef.h "defined __ARM_PCS || defined __SOFTFP__"; then
2689 case "${cross_prefix:-$cc}" in
2690 *hardfloat*) enable vfp_args; fpabi=vfp ;;
2691 *) check_ld <<EOF && enable vfp_args && fpabi=vfp || fpabi=soft ;;
fa0912fe
MR
2692__asm__ (".eabi_attribute 28, 1");
2693int main(void) { return 0; }
2694EOF
44caaa56
MR
2695 esac
2696 warn "Compiler does not indicate floating-point ABI, guessing $fpabi."
2697 fi
fa0912fe 2698
fa0912fe
MR
2699 enabled armv5te && check_asm armv5te '"qadd r0, r0, r0"'
2700 enabled armv6 && check_asm armv6 '"sadd16 r0, r0, r0"'
2701 enabled armv6t2 && check_asm armv6t2 '"movt r0, #0"'
2702 enabled armvfp && check_asm armvfp '"fadds s0, s0, s0"'
2703 enabled iwmmxt && check_asm iwmmxt '"wunpckelub wr6, wr4"'
2704 enabled neon && check_asm neon '"vadd.i16 q0, q0, q0"'
93eb8e4d 2705 enabled vfpv3 && check_asm vfpv3 '"vmov.f32 s0, #1.0"'
e45391bb 2706
6308729e
MR
2707 check_asm asm_mod_y '"vmul.i32 d0, d0, %y0" :: "x"(0)'
2708
e276d9e8
MR
2709 enabled_all armv6t2 shared !pic && enable_pic
2710
fa0912fe 2711elif enabled mips; then
e45391bb 2712
fa0912fe
MR
2713 check_asm loongson '"dmult.g $1, $2, $3"'
2714 enabled mmi && check_asm mmi '"lq $2, 0($2)"'
e45391bb 2715
fa0912fe 2716elif enabled ppc; then
e45391bb 2717
e6a0c354
MR
2718 enable local_aligned_8 local_aligned_16
2719
135448fa 2720 check_asm dcbzl '"dcbzl 0, %0" :: "r"(0)'
2f0c136e 2721 check_asm ibm_asm '"add 0, 0, 0"'
fa0912fe 2722 check_asm ppc4xx '"maclhw r10, r11, r12"'
64de20d1 2723 check_asm xform_asm '"lwzx %1, %y0" :: "Z"(*(int*)0), "r"(0)'
fa0912fe
MR
2724
2725 # AltiVec flags: The FSF version of GCC differs from the Apple version
2726 if enabled altivec; then
301ab19d 2727 nogas=warn
fa0912fe
MR
2728 check_cflags -maltivec -mabi=altivec &&
2729 { check_header altivec.h && inc_altivec_h="#include <altivec.h>" ; } ||
2730 check_cflags -faltivec
2731
2732 # check if our compiler supports Motorola AltiVec C API
2733 check_cc <<EOF || disable altivec
2734$inc_altivec_h
2735int main(void) {
29a2fdb1
MR
2736 vector signed int v1 = (vector signed int) { 0 };
2737 vector signed int v2 = (vector signed int) { 1 };
2738 v1 = vec_add(v1, v2);
fa0912fe
MR
2739 return 0;
2740}
2741EOF
2742
29a2fdb1 2743 enabled altivec || warn "Altivec disabled, possibly missing --cpu flag"
fa0912fe 2744 fi
e45391bb 2745
fa0912fe 2746elif enabled sparc; then
e45391bb 2747
fa0912fe
MR
2748 enabled vis && check_asm vis '"pdist %f0, %f0, %f0"' -mcpu=ultrasparc &&
2749 add_cflags -mcpu=ultrasparc -mtune=ultrasparc
e45391bb 2750
fa0912fe 2751elif enabled x86; then
e45391bb 2752
e6a0c354
MR
2753 enable local_aligned_8 local_aligned_16
2754
44965991
PI
2755 # check whether EBP is available on x86
2756 # As 'i' is stored on the stack, this program will crash
2757 # if the base pointer is used to access it because the
2758 # base pointer is cleared in the inline assembly code.
7dfef245 2759 check_exec_crash <<EOF && enable ebp_available
44965991 2760 volatile int i=0;
be449fca 2761 __asm__ volatile (
44965991
PI
2762 "xorl %%ebp, %%ebp"
2763 ::: "%ebp");
2764 return i;
44965991
PI
2765EOF
2766
f494213c 2767 # check whether EBX is available on x86
7cee5421
MR
2768 check_asm ebx_available '""::"b"(0)' &&
2769 check_asm ebx_available '"":::"%ebx"'
8e380710 2770
6f74fb03
RP
2771 # check whether xmm clobbers are supported
2772 check_asm xmm_clobbers '"":::"%xmm0"'
2773
d7f0920b 2774 # check whether binutils is new enough to compile SSSE3/MMX2
940f335a 2775 enabled ssse3 && check_asm ssse3 '"pabsw %xmm0, %xmm0"'
5fd89ca0 2776 enabled mmx2 && check_asm mmx2 '"pmaxub %mm0, %mm1"'
6bd859d6 2777
9cca1e40 2778 if ! disabled_any asm mmx yasm; then
b6c06894
MR
2779 if check_cmd $yasmexe --version; then
2780 enabled x86_64 && yasm_extra="-m amd64"
2781 yasm_debug="-g dwarf2"
2782 elif check_cmd nasm -v; then
2783 yasmexe=nasm
2784 yasm_debug="-g -F dwarf"
2785 enabled x86_64 && test "$objformat" = elf && objformat=elf64
2786 fi
2787
2788 YASMFLAGS="-f $objformat $yasm_extra"
2789 enabled pic && append YASMFLAGS "-DPIC"
2790 test -n "$extern_prefix" && append YASMFLAGS "-DPREFIX"
2791 case "$objformat" in
2792 elf*) enabled debug && append YASMFLAGS $yasm_debug ;;
2793 esac
2794
e287201c 2795 check_yasm "vextractf128 xmm0, ymm0, 0" && enable yasm ||
25432e85 2796 die "yasm not found, use --disable-yasm for a crippled build"
31a0dcb2 2797 fi
e45391bb 2798
669b5583
MR
2799 case "$cpu" in
2800 athlon*|opteron*|k8*|pentium|pentium-mmx|prescott|nocona|atom|geode)
2801 disable fast_clz
2802 ;;
2803 esac
2804
44965991
PI
2805fi
2806
301ab19d
MR
2807if enabled asm; then
2808 as=${gas:=$as}
2809 check_asm gnu_as '".macro m n\n\\n:.int 0\n.endm\nm x"' ||
2810 $nogas "GNU assembler not found, install gas-preprocessor"
2811fi
2812
4a7e068b
MR
2813check_ldflags -Wl,--as-needed
2814
a98bb16d
RP
2815if check_func dlopen; then
2816 ldl=
2817elif check_func dlopen -ldl; then
2818 ldl=-ldl
8bf5d58f
MN
2819fi
2820
54fe299b
DV
2821if enabled network; then
2822 check_type "sys/types.h sys/socket.h" socklen_t
2823 check_type netdb.h "struct addrinfo"
2824 check_type netinet/in.h "struct ipv6_mreq" -D_DARWIN_C_SOURCE
2825 check_type netinet/in.h "struct sockaddr_in6"
2826 check_type "sys/types.h sys/socket.h" "struct sockaddr_storage"
2827 check_struct "sys/types.h sys/socket.h" "struct sockaddr" sa_len
2828 # Prefer arpa/inet.h over winsock2
2829 if check_header arpa/inet.h ; then
2830 check_func closesocket
2831 elif check_header winsock2.h ; then
2832 check_func_headers winsock2.h closesocket -lws2 && \
2833 network_extralibs="-lws2" || \
2834 { check_func_headers winsock2.h closesocket -lws2_32 && \
2835 network_extralibs="-lws2_32"; }
2836 check_type ws2tcpip.h socklen_t
2837 check_type ws2tcpip.h "struct addrinfo"
2838 check_type ws2tcpip.h "struct ipv6_mreq"
2839 check_type ws2tcpip.h "struct sockaddr_in6"
2840 check_type ws2tcpip.h "struct sockaddr_storage"
2841 check_struct winsock2.h "struct sockaddr" sa_len
2842 else
2843 disable network
2844 fi
2845fi
2846
75ecf149
DB
2847# Solaris has nanosleep in -lrt, OpenSolaris no longer needs that
2848check_func nanosleep || { check_func nanosleep -lrt && add_extralibs -lrt; }
2849
534a2231 2850check_func fcntl
7483e694 2851check_func fork
84882df6 2852check_func getaddrinfo $network_extralibs
7483e694
DB
2853check_func gethrtime
2854check_func getrusage
fc5607f8 2855check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss
094c09bb 2856check_func inet_aton $network_extralibs
abfc8d05 2857check_func isatty
a5b64584 2858check_func localtime_r
4ae40685 2859check_func ${malloc_prefix}memalign && enable memalign
7483e694 2860check_func mkstemp
0328b9ea 2861check_func mmap
4ae40685 2862check_func ${malloc_prefix}posix_memalign && enable posix_memalign
0104b608 2863check_func setrlimit
87958234 2864check_func strerror_r
6379900c 2865check_func strptime
47941088 2866check_func strtok_r
ea4d5f48 2867check_func sched_getaffinity
bcc73960 2868check_func sysconf
b9e22269 2869check_func sysctl
b507ebd1 2870check_func_headers io.h setmode
e4673692 2871check_func_headers lzo/lzo1x.h lzo1x_999_compress
fc5607f8 2872check_lib2 "windows.h psapi.h" GetProcessMemoryInfo -lpsapi
02e8f427 2873check_func_headers windows.h GetProcessAffinityMask
2446d3d6 2874check_func_headers windows.h GetProcessTimes
73f6d31e 2875check_func_headers windows.h MapViewOfFile
7c5bfe7a 2876check_func_headers windows.h VirtualAlloc
6ffa87d3 2877
a98bb16d 2878check_header dlfcn.h
cd534fdf 2879check_header dxva.h
92c6a099 2880check_header dxva2api.h
a98bb16d 2881check_header malloc.h
bf6ce82d 2882check_header poll.h
b58412f1 2883check_header sys/mman.h
06bb5905 2884check_header sys/param.h
b091aa44 2885check_header sys/resource.h
bf6ce82d 2886check_header sys/select.h
272081b0
CEH
2887check_header vdpau/vdpau.h
2888check_header vdpau/vdpau_x11.h
68178ca9 2889check_header X11/extensions/XvMClib.h
a98bb16d 2890
9104cd51
RP
2891check_struct dxva2api.h DXVA_PictureParameters wDecodedPictureIndex
2892
a4fa192c 2893disabled zlib || check_lib zlib.h zlibVersion -lz || disable zlib
632948bd 2894disabled bzlib || check_lib2 bzlib.h BZ2_bzlibVersion -lbz2 || disable bzlib
57bd82d4 2895
ff3755cb
JG
2896if ! disabled w32threads && ! enabled pthreads; then
2897 check_func _beginthreadex && enable w32threads
2898fi
2899
57bd82d4
MR
2900# check for some common methods of building with pthread support
2901# do this before the optional library checks as some of them require pthreads
0dbfc1db
MR
2902if ! disabled pthreads && ! enabled w32threads; then
2903 enable pthreads
9e7fd101
MR
2904 if check_func pthread_create; then
2905 :
2906 elif check_func pthread_create -pthread; then
2907 add_cflags -pthread
afc9aee2 2908 add_extralibs -pthread
9e7fd101
MR
2909 elif check_func pthread_create -pthreads; then
2910 add_cflags -pthreads
afc9aee2 2911 add_extralibs -pthreads
8d94f606
GT
2912 elif check_func pthread_create -lpthreadGC2; then
2913 add_extralibs -lpthreadGC2
9e7fd101 2914 elif ! check_lib pthread.h pthread_create -lpthread; then
0dbfc1db 2915 disable pthreads
9e7fd101 2916 fi
57bd82d4
MR
2917fi
2918
8eee7025 2919for thread in $THREADS_LIST; do
e5f94c2b 2920 if enabled $thread; then
3ae3b721
RP
2921 test -n "$thread_type" &&
2922 die "ERROR: Only one thread type must be selected." ||
e5f94c2b 2923 thread_type="$thread"
e5f94c2b
RP
2924 fi
2925done
2926
50f7c296 2927check_lib math.h sin -lm && LIBM="-lm"
f3e3f28e 2928enabled vaapi && require vaapi va/va.h vaInitialize -lva
fdf88598 2929
645d2652
MR
2930check_mathfunc exp2
2931check_mathfunc exp2f
2932check_mathfunc llrint
07876e25 2933check_mathfunc llrintf
645d2652
MR
2934check_mathfunc log2
2935check_mathfunc log2f
2936check_mathfunc lrint
2937check_mathfunc lrintf
2938check_mathfunc round
2939check_mathfunc roundf
23d3931a 2940check_mathfunc trunc
645d2652 2941check_mathfunc truncf
f32adb22 2942
57bd82d4 2943# these are off by default, so fail if requested and not available
a1b3c5a3 2944enabled avisynth && require2 vfw32 "windows.h vfw.h" AVIFileInit -lavifil32
47941088 2945enabled frei0r && { check_header frei0r.h || die "ERROR: frei0r.h header not found"; }
bc8c1395 2946enabled gnutls && require_pkg_config gnutls gnutls/gnutls.h gnutls_global_init
4fa18c56
MR
2947enabled libdirac && require_pkg_config dirac \
2948 "libdirac_decoder/dirac_parser.h libdirac_encoder/dirac_encoder.h" \
2949 "dirac_decoder_init dirac_encoder_init"
79fda097 2950enabled libfaac && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
bf0cb89a 2951enabled libfreetype && require_pkg_config freetype2 "ft2build.h FT_FREETYPE_H" FT_Init_FreeType
5af41508 2952enabled libgsm && require libgsm gsm/gsm.h gsm_create -lgsm
9b9d3868 2953enabled libmp3lame && require "libmp3lame >= 3.98.3" lame/lame.h lame_set_VBR_quality -lmp3lame
7483e694 2954enabled libnut && require libnut libnut.h nut_demuxer_init -lnut
eb7626a3
MR
2955enabled libopencore_amrnb && require libopencore_amrnb opencore-amrnb/interf_dec.h Decoder_Interface_init -lopencore-amrnb
2956enabled libopencore_amrwb && require libopencore_amrwb opencore-amrwb/dec_if.h D_IF_init -lopencore-amrwb
4fa18c56 2957enabled libopencv && require_pkg_config opencv opencv/cv.h cvCreateImageHeader
3d6fac8c 2958enabled libopenjpeg && require libopenjpeg openjpeg.h opj_version -lopenjpeg
0de9c41f 2959enabled libpulse && require_pkg_config libpulse-simple pulse/simple.h pa_simple_new
4fa18c56
MR
2960enabled librtmp && require_pkg_config librtmp librtmp/rtmp.h RTMP_Socket
2961enabled libschroedinger && require_pkg_config schroedinger-1.0 schroedinger/schro.h schro_init
ae14f311 2962enabled libspeex && require libspeex speex/speex.h speex_decoder_init -lspeex
c261a5d9 2963enabled libtheora && require libtheora theora/theoraenc.h th_info_init -ltheoraenc -ltheoradec -logg
d89e738a 2964enabled libvo_aacenc && require libvo_aacenc vo-aacenc/voAAC.h voGetAACEncAPI -lvo-aacenc
f502ff3f 2965enabled libvo_amrwbenc && require libvo_amrwbenc vo-amrwbenc/enc_if.h E_IF_init -lvo-amrwbenc
7483e694 2966enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
7d07d6f5
DB
2967enabled libvpx && {
2968 enabled libvpx_decoder && { check_lib2 "vpx/vpx_decoder.h vpx/vp8dx.h" vpx_codec_dec_init_ver -lvpx ||
2969 die "ERROR: libvpx decoder version must be >=0.9.1"; }
2970 enabled libvpx_encoder && { check_lib2 "vpx/vpx_encoder.h vpx/vp8cx.h" vpx_codec_enc_init_ver -lvpx ||
2971 die "ERROR: libvpx encoder version must be >=0.9.1"; } }
eb7626a3 2972enabled libx264 && require libx264 x264.h x264_encoder_encode -lx264 &&
46c3c53b
AK
2973 { check_cpp_condition x264.h "X264_BUILD >= 118" ||
2974 die "ERROR: libx264 version must be >= 0.118."; }
de295976 2975enabled libxavs && require libxavs xavs.h xavs_encoder_encode -lxavs
2bfecf73 2976enabled libxvid && require libxvid xvid.h xvid_global -lxvidcore
7483e694 2977enabled mlib && require mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
a060866f
MS
2978enabled openssl && { check_lib openssl/ssl.h SSL_library_init -lssl -lcrypto ||
2979 check_lib openssl/ssl.h SSL_library_init -lssl32 -leay32 ||
2980 check_lib openssl/ssl.h SSL_library_init -lssl -lcrypto -lws2_32 -lgdi32 ||
2981 die "ERROR: openssl not found"; }
8ac17293 2982
0b4a1821
AS
2983# libdc1394 check
2984if enabled libdc1394; then
2985 { check_lib dc1394/dc1394.h dc1394_new -ldc1394 -lraw1394 &&
2986 enable libdc1394_2; } ||
2987 { check_lib libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394 &&
2988 enable libdc1394_1; } ||
2989 die "ERROR: No version of libdc1394 found "
2990fi
2991
8f1b06c8 2992if check_pkg_config sdl SDL_version.h SDL_Linked_Version; then
aa692d54
MR
2993 check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x010201" $sdl_cflags &&
2994 enable sdl &&
2995 check_struct SDL.h SDL_VideoInfo current_w $sdl_cflags && enable sdl_video_size
c3f6b472 2996fi
57bd82d4 2997
2270b4b2 2998texi2html -version > /dev/null 2>&1 && enable texi2html || disable texi2html
146ea952 2999
c6f95144 3000check_header linux/fb.h
06e31011
RP
3001check_header linux/videodev.h
3002check_header linux/videodev2.h
a6a4793d
LB
3003check_struct linux/videodev2.h "struct v4l2_frmivalenum" discrete
3004
1b6e8b73 3005check_header sys/videoio.h
47f38850 3006
27796dc3 3007check_func_headers "windows.h vfw.h" capCreateCaptureWindow "$vfwcap_indev_extralibs"
ec1ee802
RP
3008# check that WM_CAP_DRIVER_CONNECT is defined to the proper value
3009# w32api 3.12 had it defined wrong
3010check_cpp_condition vfw.h "WM_CAP_DRIVER_CONNECT > WM_USER" && enable vfwcap_defines
c2345207 3011
f8aa696f 3012# check for ioctl_meteor.h, ioctl_bt848.h and alternatives
1c915f83
RP
3013{ check_header dev/bktr/ioctl_meteor.h &&
3014 check_header dev/bktr/ioctl_bt848.h; } ||
3015{ check_header machine/ioctl_meteor.h &&
3016 check_header machine/ioctl_bt848.h; } ||
3017{ check_header dev/video/meteor/ioctl_meteor.h &&
3018 check_header dev/video/bktr/ioctl_bt848.h; } ||
3019check_header dev/ic/bt8xx.h
f8aa696f 3020
15d59d2c 3021check_header sndio.h
c7682de0
RP
3022check_header sys/soundcard.h
3023check_header soundcard.h
deb29777 3024
b6f3d925 3025enabled_any alsa_indev alsa_outdev && check_lib2 alsa/asoundlib.h snd_pcm_htimestamp -lasound
35fd8122 3026
0e57fe17 3027enabled jack_indev && check_lib2 jack/jack.h jack_client_open -ljack
80ff8a16 3028
15d59d2c
B
3029enabled_any sndio_indev sndio_outdev && check_lib2 sndio.h sio_open -lsndio
3030
e417d80d
AK
3031enabled libcdio &&
3032 check_lib2 "cdio/cdda.h cdio/paranoia.h" cdio_cddap_open "-lcdio_paranoia -lcdio_cdda -lcdio"
3033
56a059ac 3034enabled x11grab &&
f58f4ce1
GP
3035check_header X11/Xlib.h &&
3036check_header X11/extensions/XShm.h &&
0a045661 3037check_header X11/extensions/Xfixes.h &&
f58f4ce1 3038check_func XOpenDisplay -lX11 &&
781c1aa6
R
3039check_func XShmCreateImage -lX11 -lXext &&
3040check_func XFixesGetCursorImage -lX11 -lXext -lXfixes
f58f4ce1 3041
ac3dbb4d
SZ
3042# check for VDA header
3043if ! disabled vda && check_header VideoDecodeAcceleration/VDADecoder.h; then
be1e8725 3044 enable vda && add_extralibs -framework CoreFoundation -framework VideoDecodeAcceleration -framework QuartzCore
ac3dbb4d
SZ
3045fi
3046
598ef02b 3047if ! disabled vdpau && enabled vdpau_vdpau_h; then
deda2a4a
AC
3048check_cpp_condition \
3049 vdpau/vdpau.h "defined VDP_DECODER_PROFILE_MPEG4_PART2_ASP" ||
d1ebd4a9
AC
3050 { echolog "Please upgrade to libvdpau >= 0.2 if you would like vdpau support." &&
3051 disable vdpau; }
abf649c7 3052fi
deda2a4a 3053
95e561ec 3054enabled debug && add_cflags -g"$debuglevel" && add_asflags -g"$debuglevel"
57bd82d4
MR
3055
3056# add some useful compiler flags if supported
3057check_cflags -Wdeclaration-after-statement
dcd479c0 3058check_cflags -Wall
440e3b2f 3059check_cflags -Wno-parentheses
dcd479c0 3060check_cflags -Wno-switch
b36518dc 3061check_cflags -Wno-format-zero-length
c07bd6a9
MN
3062check_cflags -Wdisabled-optimization
3063check_cflags -Wpointer-arith
3064check_cflags -Wredundant-decls
cc1fb623 3065check_cflags -Wno-pointer-sign
f4929996 3066check_cflags -Wcast-qual
9aceb3cf 3067check_cflags -Wwrite-strings
652a5bf6 3068check_cflags -Wtype-limits
764551c6 3069check_cflags -Wundef
fc298fd9 3070check_cflags -Wmissing-prototypes
c2ed91de 3071check_cflags -Wstrict-prototypes
5af4e0cc 3072enabled extra_warnings && check_cflags -Winline
cf9d24ad 3073
57bd82d4 3074# add some linker flags
5c0e9479 3075check_ldflags -Wl,--warn-common
965dbe09 3076check_ldflags -Wl,-rpath-link=libpostproc:libswscale:libavfilter:libavdevice:libavformat:libavcodec:libavutil
fef2d661 3077test_ldflags -Wl,-Bsymbolic && append SHFLAGS -Wl,-Bsymbolic
94a3401e 3078
a482e61b 3079echo "X{};" > $TMPV
b462d132 3080if test_ldflags -Wl,--version-script,$TMPV; then
a482e61b 3081 append SHFLAGS '-Wl,--version-script,\$(SUBDIR)lib\$(NAME).ver'
b462d132
MR
3082 check_cc <<EOF && enable symver_asm_label
3083void ff_foo(void) __asm__ ("av_foo@VERSION");
0884fadf 3084void ff_foo(void) { ${inline_asm+__asm__($quotes);} }
b462d132
MR
3085EOF
3086 check_cc <<EOF && enable symver_gnu_asm
3087__asm__(".symver ff_foo,av_foo@VERSION");
3088void ff_foo(void) {}
3089EOF
3090fi
a482e61b 3091
9cd7b854
MR
3092if [ -n "$optflags" ]; then
3093 add_cflags $optflags
3094elif enabled small; then
14ca9cd0 3095 add_cflags $size_cflags
8400d6b8 3096elif enabled optimizations; then
14ca9cd0 3097 add_cflags $speed_cflags
b05394a0
MR
3098else
3099 add_cflags $noopt_cflags
cddf3f45 3100fi
11fdbc44 3101check_cflags -fno-math-errno
b2eb2ff0 3102check_cflags -fno-signed-zeros
cddf3f45 3103
629687f6 3104if enabled icc; then
b1598b58
MR
3105 # Just warnings, no remarks
3106 check_cflags -w1
3107 # -wd: Disable following warnings
3108 # 144, 167, 556: -Wno-pointer-sign
91bcad19 3109 # 1292: attribute "foo" ignored
b1598b58 3110 # 10006: ignoring unknown option -fno-signed-zeros
f1c7c6ae 3111 # 10148: ignoring unknown option -Wno-parentheses
b1598b58 3112 # 10156: ignoring option '-W'; no argument required
91bcad19 3113 check_cflags -wd144,167,556,1292,10006,10148,10156
b1598b58
MR
3114 # 11030: Warning unknown option --as-needed
3115 # 10156: ignoring option '-export'; no argument required
3116 check_ldflags -wd10156,11030
3117 # Allow to compile with optimizations
3118 check_ldflags -march=$cpu
be2cf98a
CEH
3119 # icc 11.0 and 11.1 work with ebp_available, but don't pass the test
3120 enable ebp_available
bdefad73
MR
3121 if enabled x86_32; then
3122 test ${icc_version%%.*} -ge 11 && \
3123 check_cflags -falign-stack=maintain-16-byte || \
3124 disable aligned_stack
3125 fi
df442a8d
MR
3126elif enabled ccc; then
3127 # disable some annoying warnings
3128 add_cflags -msg_disable cvtu32to64
3129 add_cflags -msg_disable embedcomment
3130 add_cflags -msg_disable needconstext
3131 add_cflags -msg_disable nomainieee
3132 add_cflags -msg_disable ptrmismatch1
3133 add_cflags -msg_disable unreachcode
973859f5
MR
3134elif enabled gcc; then
3135 check_cflags -fno-tree-vectorize
765e6134 3136 check_cflags -Werror=implicit-function-declaration
de63bfec 3137 check_cflags -Werror=missing-prototypes
9d6b2077 3138 check_cflags -Werror=declaration-after-statement
613a4e3f
MR
3139elif enabled llvm_gcc; then
3140 check_cflags -mllvm -stack-alignment=16
06da6943 3141elif enabled clang; then
5c8ef670 3142 check_cflags -mllvm -stack-alignment=16
06da6943 3143 check_cflags -Qunused-arguments
c98d164a
MS
3144 check_cflags -Werror=implicit-function-declaration
3145 check_cflags -Werror=missing-prototypes
138132be
MR
3146elif enabled armcc; then
3147 # 2523: use of inline assembler is deprecated
bcafde61
MR
3148 add_cflags -W${armcc_opt},--diag_suppress=2523
3149 add_cflags -W${armcc_opt},--diag_suppress=1207
5a92140b 3150 add_cflags -W${armcc_opt},--diag_suppress=1293 # assignment in condition
b0c1b66a 3151 add_cflags -W${armcc_opt},--diag_suppress=3343 # hardfp compat
d0ce090e
MR
3152 add_cflags -W${armcc_opt},--diag_suppress=167 # pointer sign
3153 add_cflags -W${armcc_opt},--diag_suppress=513 # pointer sign
587d24ff
MR
3154elif enabled tms470; then
3155 add_cflags -pds=824 -pds=837
5f3b8314
MR
3156elif enabled pathscale; then
3157 add_cflags -fstrict-overflow -OPT:wrap_around_unsafe_opt=OFF
504a64b9
CEH
3158fi
3159
7483e694
DB
3160enabled_any $THREADS_LIST && enable threads
3161
3162check_deps $CONFIG_LIST \
b6bb00b0 3163 $CONFIG_EXTRA \
7483e694 3164 $HAVE_LIST \
54e75be4
DB
3165 $ALL_COMPONENTS \
3166 $ALL_TESTS \
f70f03f6 3167
3bfd582c 3168enabled asm || { arch=c; disable $ARCH_LIST $ARCH_EXT_LIST; }
c8a4ae00 3169
9bbd6a4c
MR
3170! enabled_any memalign posix_memalign malloc_aligned &&
3171 enabled_any $need_memalign && enable memalign_hack
3172
3e89171a 3173echo "install prefix $prefix"
f36958f8
DB
3174echo "source path $source_path"
3175echo "C compiler $cc"
f36958f8 3176echo "ARCH $arch ($cpu)"
ce8871c2
MR
3177if test "$build_suffix" != ""; then
3178 echo "build suffix $build_suffix"
eb94aca9 3179fi
ac63af34
DB
3180if test "$extra_version" != ""; then
3181 echo "version string suffix $extra_version"
3182fi
0db2ce77 3183echo "big-endian ${bigendian-no}"
e90f5b5a 3184echo "runtime cpu detection ${runtime_cpudetect-no}"
5b6c2cbd 3185if enabled x86; then
6348a96c 3186 echo "${yasmexe} ${yasm-no}"
0db2ce77 3187 echo "MMX enabled ${mmx-no}"
30e98e62 3188 echo "MMX2 enabled ${mmx2-no}"
3bf96eec 3189 echo "3DNow! enabled ${amd3dnow-no}"
a1ef9f08 3190 echo "3DNow! extended enabled ${amd3dnowext-no}"
1bb04d5a 3191 echo "SSE enabled ${sse-no}"
30e98e62 3192 echo "SSSE3 enabled ${ssse3-no}"
c73b779d 3193 echo "AVX enabled ${avx-no}"
0db2ce77
MR
3194 echo "CMOV enabled ${cmov-no}"
3195 echo "CMOV is fast ${fast_cmov-no}"
971cc990
MN
3196 echo "EBX available ${ebx_available-no}"
3197 echo "EBP available ${ebp_available-no}"
e41e8342 3198fi
5b6c2cbd 3199if enabled arm; then
0db2ce77
MR
3200 echo "ARMv5TE enabled ${armv5te-no}"
3201 echo "ARMv6 enabled ${armv6-no}"
ab5cb084 3202 echo "ARMv6T2 enabled ${armv6t2-no}"
f55b299a 3203 echo "ARM VFP enabled ${armvfp-no}"
0db2ce77 3204 echo "IWMMXT enabled ${iwmmxt-no}"
6b18d278 3205 echo "NEON enabled ${neon-no}"
eba9ae3c 3206fi
5b6c2cbd 3207if enabled mips; then
0db2ce77 3208 echo "MMI enabled ${mmi-no}"
e41e8342 3209fi
5b6c2cbd 3210if enabled ppc; then
0db2ce77 3211 echo "AltiVec enabled ${altivec-no}"
30e98e62 3212 echo "PPC 4xx optimizations ${ppc4xx-no}"
0db2ce77 3213 echo "dcbzl available ${dcbzl-no}"
30e98e62
DB
3214fi
3215if enabled sparc; then
3216 echo "VIS enabled ${vis-no}"