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