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