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