Fix the creation of alldevices.c (create it without any rename).
[libav.git] / configure
CommitLineData
aeb29222 1#!/bin/sh
0f3cb305 2#
f57620d5
MR
3# FFmpeg configure script
4#
5# Copyright (c) 2000, 2001, 2002 Fabrice Bellard
6# Copyright (c) 2005-2006 Diego Biurrun
7# Copyright (c) 2005-2006 Mans Rullgard
0f3cb305 8#
cf9d24ad 9
cde2d79a 10# make sure we are running under a compatible shell
c21d6325
MR
11# try to make this part work with most shells
12
13try_exec(){
0dbe81bb 14 echo "Trying shell $1"
c21d6325
MR
15 type "$1" >/dev/null 2>&1 && exec "$@"
16}
17
5237ce67 18unset foo
0dbe81bb
MR
19(: ${foo%%bar}) 2>/dev/null
20E1="$?"
21
22(: ${foo?}) 2>/dev/null
23E2="$?"
24
25if test "$E1" != 0 || test "$E2" = 0; then
26 echo "Broken shell detected. Trying alternatives."
c21d6325
MR
27 export FF_CONF_EXEC
28 if test "0$FF_CONF_EXEC" -lt 1; then
29 FF_CONF_EXEC=1
30 try_exec bash "$0" "$@"
31 fi
32 if test "0$FF_CONF_EXEC" -lt 2; then
33 FF_CONF_EXEC=2
34 try_exec ksh "$0" "$@"
35 fi
36 if test "0$FF_CONF_EXEC" -lt 3; then
37 FF_CONF_EXEC=3
38 try_exec /usr/xpg4/bin/sh "$0" "$@"
cde2d79a
MR
39 fi
40 echo "No compatible shell script interpreter found."
fc53da20 41 echo "This configure script requires a POSIX-compatible shell"
c21d6325 42 echo "such as bash or ksh."
505dfb09
DB
43 echo "THIS IS NOT A BUG IN FFMPEG, DO NOT REPORT IT AS SUCH."
44 echo "Instead, install a working POSIX-compatible shell."
45 echo "Disabling this configure test will create a broken FFmpeg."
c21d6325
MR
46 if test "$BASH_VERSION" = '2.04.0(1)-release'; then
47 echo "This bash version ($BASH_VERSION) is broken on your platform."
48 echo "Upgrade to a later version if available."
49 fi
cde2d79a
MR
50 exit 1
51fi
52
74c53c2d
MR
53show_help(){
54 echo "Usage: configure [options]"
55 echo "Options: [defaults in brackets after descriptions]"
56 echo
57 echo "Standard options:"
58 echo " --help print this message"
2ba042a7 59 echo " --log[=FILE|yes|no] log tests and output to FILE [config.err]"
2266e085 60 echo " --prefix=PREFIX install in PREFIX [$PREFIX]"
74c53c2d 61 echo " --libdir=DIR install libs in DIR [PREFIX/lib]"
84c22efd 62 echo " --shlibdir=DIR install shared libs in DIR [PREFIX/lib]"
74c53c2d 63 echo " --incdir=DIR install includes in DIR [PREFIX/include/ffmpeg]"
4ca5ece5 64 echo " --mandir=DIR install man page in DIR [PREFIX/share/man]"
74c53c2d
MR
65 echo " --enable-static build static libraries [default=yes]"
66 echo " --disable-static do not build static libraries [default=no]"
67 echo " --enable-shared build shared libraries [default=no]"
68 echo " --disable-shared do not build shared libraries [default=yes]"
0a622b98
MR
69 echo " --enable-gpl allow use of GPL code, the resulting libav*"
70 echo " and ffmpeg will be under GPL [default=no]"
dc922953
DB
71 echo " --enable-pp enable GPLed postprocessing support [default=no]"
72 echo " --enable-swscaler software scaler support [default=no]"
e5f94c2b 73 echo " --enable-beosthreads use BeOS threads [default=no]"
74c53c2d 74 echo " --enable-pthreads use pthreads [default=no]"
eb113804 75 echo " --enable-w32threads use Win32 threads [default=no]"
56a059ac 76 echo " --enable-x11grab enable X11 grabbing [default=no]"
0a622b98
MR
77 echo
78 echo "External library support:"
79 echo " --enable-sunmlib use Sun medialib [default=no]"
e2745046
MR
80 echo " --enable-liba52 enable GPLed liba52 support [default=no]"
81 echo " --enable-liba52bin open liba52.so.0 at runtime [default=no]"
8ac17293 82 echo " --enable-avisynth allow reading AVISynth script files [default=no]"
f5a756ef
DB
83 echo " --enable-libamr-nb enable libamr-nb floating point audio codec"
84 echo " --enable-libamr-wb enable libamr-wb floating point audio codec"
f7b8bffe
RP
85 echo " --enable-libdc1394 enable IIDC-1394 grabbing using libdc1394"
86 echo " and libraw1394 [default=no]"
e2745046
MR
87 echo " --enable-libfaac enable FAAC support via libfaac [default=no]"
88 echo " --enable-libfaad enable FAAD support via libfaad [default=no]"
06f32b26 89 echo " --enable-libfaadbin open libfaad.so.0 at runtime [default=no]"
dc922953 90 echo " --enable-libgsm enable GSM support via libgsm [default=no]"
e2745046 91 echo " --enable-libmp3lame enable MP3 encoding via libmp3lame [default=no]"
31235134
DB
92 echo " --enable-libnut enable NUT (de)muxing via libnut,"
93 echo " native demuxer exists [default=no]"
71757822 94 echo " --enable-libtheora enable Theora encoding via libtheora [default=no]"
f9def9cc
DB
95 echo " --enable-libvorbis enable Vorbis encoding via libvorbis,"
96 echo " native implementation exists [default=no]"
1cc60c47
DB
97 echo " --enable-libx264 enable H.264 encoding via x264 [default=no]"
98 echo " --enable-libxvid enable Xvid encoding via xvidcore,"
31235134 99 echo " native MPEG-4/Xvid encoder exists [default=no]"
74c53c2d
MR
100 echo ""
101 echo "Advanced options (experts only):"
102 echo " --source-path=PATH path to source code [$source_path]"
103 echo " --cross-prefix=PREFIX use PREFIX for compilation tools [$cross_prefix]"
fac252f9 104 echo " --cross-compile assume a cross-compiler is used"
abcd6d60 105 echo " --target-os=OS compiler targets OS [$targetos]"
74c53c2d
MR
106 echo " --cc=CC use C compiler CC [$cc]"
107 echo " --make=MAKE use specified make [$make]"
108 echo " --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS [$CFLAGS]"
109 echo " --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]"
110 echo " --extra-libs=ELIBS add ELIBS [$ELIBS]"
111 echo " --build-suffix=SUFFIX suffix for application specific build []"
cc6a90dd 112 echo " --arch=ARCH select architecture [$arch]"
7c758d33
DB
113 echo " --cpu=CPU selects the minimum cpu required (affects"
114 echo " instruction selection, may crash on older CPUs)"
2b4c3615 115 echo " --enable-powerpc-perf enable performance report on PPC"
74c53c2d
MR
116 echo " (requires enabling PMC)"
117 echo " --disable-mmx disable MMX usage"
1839e854 118 echo " --disable-armv5te disable armv5te usage"
edab3048 119 echo " --disable-armv6 disable armv6 usage"
74c53c2d
MR
120 echo " --disable-iwmmxt disable iwmmxt usage"
121 echo " --disable-altivec disable AltiVec usage"
74c53c2d 122 echo " --disable-network disable network support [default=no]"
0c7bb0e5 123 echo " --disable-ipv6 disable ipv6 support [default=no]"
74c53c2d 124 echo " --disable-zlib disable zlib [default=no]"
74c53c2d 125 echo " --disable-vhook disable video hooking support"
74c53c2d 126 echo " --disable-debug disable debugging symbols"
74c53c2d
MR
127 echo " --disable-mpegaudio-hp faster (but less accurate)"
128 echo " MPEG audio decoding [default=no]"
cde9e780 129 echo " --enable-gray enable full grayscale support (slower color)"
786b30af 130 echo " --disable-ffmpeg disable ffmpeg build"
74c53c2d
MR
131 echo " --disable-ffserver disable ffserver build"
132 echo " --disable-ffplay disable ffplay build"
133 echo " --enable-small optimize for size instead of speed"
134 echo " --enable-memalign-hack emulate memalign, interferes with memory debuggers"
74c53c2d
MR
135 echo " --disable-encoder=NAME disables encoder NAME"
136 echo " --enable-encoder=NAME enables encoder NAME"
137 echo " --disable-decoder=NAME disables decoder NAME"
138 echo " --enable-decoder=NAME enables decoder NAME"
139 echo " --disable-encoders disables all encoders"
140 echo " --disable-decoders disables all decoders"
ff70e601
MR
141 echo " --disable-muxer=NAME disables muxer NAME"
142 echo " --enable-muxer=NAME enables muxer NAME"
74c53c2d 143 echo " --disable-muxers disables all muxers"
ff70e601
MR
144 echo " --disable-demuxer=NAME disables demuxer NAME"
145 echo " --enable-demuxer=NAME enables demuxer NAME"
74c53c2d 146 echo " --disable-demuxers disables all demuxers"
af9e7d18
MR
147 echo " --enable-parser=NAME enables parser NAME"
148 echo " --disable-parser=NAME disables parser NAME"
149 echo " --disable-parsers disables all parsers"
cd61e407
JM
150 echo " --enable-bsf=NAME enables bitstream filter NAME"
151 echo " --disable-bsf=NAME disables bitstream filter NAME"
152 echo " --disable-bsfs disables all bitstream filters"
c08fb000
AB
153 echo " --enable-protocol=NAME enables protocol NAME"
154 echo " --disable-protocol=NAME disables protocol NAME"
155 echo " --disable-protocols disables all protocols"
794f8e97
PI
156 echo " --list-decoders show all available decoders"
157 echo " --list-encoders show all available encoders"
158 echo " --list-muxers show all available muxers"
159 echo " --list-demuxers show all available demuxers"
160 echo " --list-parsers show all available parsers"
161 echo " --list-protocols show all available protocols"
162 echo " --list-bsfs show all available bitstream filters"
0a622b98
MR
163 echo
164 echo "Developer options (useful when working on FFmpeg itself):"
165 echo " --enable-gprof enable profiling with gprof [$gprof]"
d2bbb2f7 166 echo " --disable-optimizations disable compiler optimizations"
0a622b98
MR
167 echo " --enable-extra-warnings enable more compiler warnings"
168 echo " --disable-strip disable stripping of executables and shared libraries"
74c53c2d
MR
169 echo ""
170 echo "NOTE: Object files are built at the place where configure is launched."
171 exit 1
172}
cf9d24ad 173
57bd82d4
MR
174log(){
175 echo "$@" >>$logfile
176}
177
720c69da 178log_file(){
c8e9f801 179 log BEGIN $1
6b324648 180 pr -n -t $1 >>$logfile
c8e9f801
MR
181 log END $1
182}
183
2ba042a7 184echolog(){
c8e9f801 185 log "$@"
57bd82d4 186 echo "$@"
2ba042a7
MR
187}
188
189die(){
190 echolog "$@"
191 cat <<EOF
192If you think configure made a mistake, make sure you are using the latest
193version from SVN. If the latest version fails, report the problem to the
194ffmpeg-devel@mplayerhq.hu mailing list or IRC #ffmpeg on irc.freenode.net.
195EOF
720c69da 196 if enabled logging; then
2ba042a7
MR
197 cat <<EOF
198Include the log file "$logfile" produced by configure as this will help
199solving the problem.
200EOF
201 else
202cat <<EOF
203Rerun configure with logging enabled (do not use --log=no), and include the
204log this produces with your report.
205EOF
206 fi
57bd82d4
MR
207 rm -f $TMPC $TMPO $TMPE $TMPS $TMPH
208 exit 1
209}
210
904e48f1 211# "tr '[a-z]' '[A-Z]'" is a workaround for Solaris tr not grokking "tr a-z A-Z"
44161118
MR
212toupper(){
213 echo "$@" | tr '[a-z]' '[A-Z]'
214}
215
4a5444db
MR
216tolower(){
217 echo "$@" | tr '[A-Z]' '[a-z]'
218}
219
a8d04fba
MR
220set_all(){
221 value=$1
222 shift
223 for var in $*; do
224 eval $var=$value
225 done
226}
227
799c9e9b
MR
228pushvar(){
229 for var in $*; do
230 eval level=\${${var}_level:=0}
231 eval ${var}_${level}="\$$var"
232 eval ${var}_level=$(($level+1))
233 done
234}
235
236popvar(){
237 for var in $*; do
238 eval level=\${${var}_level:-0}
239 test $level = 0 && continue
240 eval level=$(($level-1))
241 eval $var="\${${var}_${level}}"
242 eval ${var}_level=$level
243 eval unset ${var}_${level}
244 done
245}
246
a8d04fba
MR
247enable(){
248 set_all yes $*
249}
250
251disable(){
252 set_all no $*
253}
254
57bd82d4 255enabled(){
44161118
MR
256 eval test "x\$$1" = "xyes"
257}
258
37970ebf
RP
259disabled(){
260 eval test "x\$$1" = "xno"
261}
262
44161118
MR
263enabled_all(){
264 for opt; do
265 enabled $opt || return 1
266 done
267}
268
85bca2c5
DB
269disabled_all(){
270 for opt; do
271 disabled $opt || return 1
272 done
273}
274
44161118
MR
275enabled_any(){
276 for opt; do
277 enabled $opt && return 0
278 done
279}
280
85bca2c5
DB
281disabled_any(){
282 for opt; do
283 disabled $opt && return 0
284 done
285}
286
4a0d6686
AJ
287is_in(){
288 value=$1
289 shift
290 for var in $*; do
291 [ $var = $value ] && return 0
292 done
293 return 1
294}
295
30fd06be
MR
296check_deps(){
297 for cfg; do
799c9e9b
MR
298 enabled ${cfg}_checking && die "Circular dependency for $cfg."
299 disabled ${cfg}_checking && continue
300 enable ${cfg}_checking
301
30fd06be
MR
302 eval dep_all="\$${cfg}_deps"
303 eval dep_any="\$${cfg}_deps_any"
799c9e9b
MR
304
305 pushvar cfg dep_all dep_any
306 check_deps $dep_all $dep_any
307 popvar cfg dep_all dep_any
308
30fd06be
MR
309 enabled_all $dep_all || disable $cfg
310 enabled_any $dep_any || disable $cfg
799c9e9b 311
4ec45764
RP
312 if enabled $cfg; then
313 eval dep_extralibs="\$${cfg}_extralibs"
314 test -n "$dep_extralibs" && add_extralibs $dep_extralibs
315 fi
316
799c9e9b 317 disable ${cfg}_checking
30fd06be
MR
318 done
319}
320
44161118
MR
321print_config(){
322 pfx=$1
323 header=$2
324 makefile=$3
325 shift 3
326 for cfg; do
3d907e22 327 ucname="`toupper $cfg`"
44161118 328 if enabled $cfg; then
3d907e22
MR
329 echo "#define ${pfx}${ucname} 1" >> $header
330 echo "#define ENABLE_${ucname} 1" >> $header
331 echo "${pfx}${ucname}=yes" >> $makefile
332 else
333 echo "#define ENABLE_${ucname} 0" >> $header
44161118
MR
334 fi
335 done
57bd82d4
MR
336}
337
338flags_saved(){
339 (: ${SAVE_CFLAGS?}) 2>/dev/null
340}
341
dcd479c0 342save_flags(){
57bd82d4 343 flags_saved && return
dcd479c0
MR
344 SAVE_CFLAGS="$CFLAGS"
345 SAVE_LDFLAGS="$LDFLAGS"
346 SAVE_extralibs="$extralibs"
347}
348
349restore_flags(){
f5d28d10 350 flags_saved || return
dcd479c0
MR
351 CFLAGS="$SAVE_CFLAGS"
352 LDFLAGS="$SAVE_LDFLAGS"
353 extralibs="$SAVE_extralibs"
354 unset SAVE_CFLAGS
355 unset SAVE_LDFLAGS
356 unset SAVE_extralibs
357}
358
359temp_cflags(){
360 save_flags
361 CFLAGS="$CFLAGS $*"
362}
363
364temp_ldflags(){
365 save_flags
366 LDFLAGS="$LDFLAGS $*"
367}
368
369temp_extralibs(){
370 save_flags
371 extralibs="$extralibs $*"
372}
373
57bd82d4
MR
374append(){
375 var=$1
376 shift
377 flags_saved && eval "SAVE_$var=\"\$SAVE_$var $*\""
378 eval "$var=\"\$$var $*\""
379}
380
381add_cflags(){
382 append CFLAGS "$@"
383}
384
385add_ldflags(){
386 append LDFLAGS "$@"
387}
388
389add_extralibs(){
390 append extralibs "$@"
391}
392
b0cfb663 393check_cmd(){
b3cb5d51 394 log "$@"
9b4f605c 395 "$@" >>$logfile 2>&1
b0cfb663
MR
396}
397
dcd479c0 398check_cc(){
57bd82d4
MR
399 log check_cc "$@"
400 cat >$TMPC
720c69da 401 log_file $TMPC
b0cfb663 402 check_cmd $cc $CFLAGS "$@" -c -o $TMPO $TMPC
57bd82d4
MR
403}
404
405check_cpp(){
406 log check_cpp "$@"
dcd479c0 407 cat >$TMPC
720c69da 408 log_file $TMPC
b0cfb663 409 check_cmd $cc $CFLAGS "$@" -E -o $TMPO $TMPC
dcd479c0
MR
410}
411
940f335a
MR
412check_asm(){
413 log check_asm "$@"
414 name="$1"
415 asm="$2"
416 shift 2
417 check_cc "$@" <<EOF && enable $name || disable $name
418int foo(void){
419 asm volatile($asm);
420}
421EOF
422}
423
dcd479c0 424check_ld(){
57bd82d4 425 log check_ld "$@"
0607887f 426 check_cc || return
3155a644
MR
427 flags=''
428 libs=''
429 for f; do
430 test "${f}" = "${f#-l}" && flags="$flags $f" || libs="$libs $f"
431 done
432 check_cmd $cc $LDFLAGS $flags -o $TMPE $TMPO $extralibs $libs
dcd479c0
MR
433}
434
435check_cflags(){
57bd82d4
MR
436 log check_cflags "$@"
437 check_cc "$@" <<EOF && add_cflags "$@"
dcd479c0
MR
438int x;
439EOF
440}
441
442check_ldflags(){
57bd82d4
MR
443 log check_ldflags "$@"
444 check_ld "$@" <<EOF && add_ldflags "$@"
e5af4a11 445int main(void){
57bd82d4
MR
446 return 0;
447}
dcd479c0
MR
448EOF
449}
450
451check_header(){
57bd82d4 452 log check_header "$@"
dcd479c0
MR
453 header=$1
454 shift
d8bc5f06
MR
455 var=`echo $header | sed 's/[^A-Za-z0-9_]/_/g'`
456 disable $var
457 check_cpp "$@" <<EOF && enable $var
dcd479c0
MR
458#include <$header>
459int x;
460EOF
461}
462
463check_func(){
57bd82d4 464 log check_func "$@"
dcd479c0
MR
465 func=$1
466 shift
d8bc5f06
MR
467 disable $func
468 check_ld "$@" <<EOF && enable $func
dcd479c0 469extern int $func();
e5af4a11 470int main(void){
dcd479c0
MR
471 $func();
472}
473EOF
474}
475
f8d7b072
MR
476check_func2(){
477 log check_func2 "$@"
478 headers=$1
479 func=$2
480 shift 2
481 disable $func
482 incs=""
483 for hdr in $headers; do
484 incs="$incs
485#include <$hdr>"
486 done
487 check_ld "$@" <<EOF && enable $func
488$incs
e5af4a11 489int main(void){
f8d7b072
MR
490 (void) $func;
491 return 0;
492}
493EOF
494}
495
57bd82d4
MR
496check_lib(){
497 log check_lib "$@"
498 header="$1"
499 func="$2"
500 shift 2
fcfcde17
MR
501 temp_extralibs "$@"
502 check_header $header && check_func $func && add_extralibs "$@"
503 err=$?
504 restore_flags
505 return $err
57bd82d4
MR
506}
507
f8d7b072
MR
508check_lib2(){
509 log check_lib2 "$@"
510 headers="$1"
511 func="$2"
512 shift 2
513 temp_extralibs "$@"
514 check_func2 "$headers" $func && add_extralibs "$@"
515 err=$?
516 restore_flags
517 return $err
518}
519
dcd479c0 520check_exec(){
90be59ef 521 check_ld "$@" && { enabled cross_compile || $TMPE >>$logfile 2>&1; }
57bd82d4
MR
522}
523
7dfef245
MR
524check_exec_crash(){
525 code=`cat`
526
527 # exit() is not async signal safe. _Exit (C99) and _exit (POSIX)
528 # are safe but may not be available everywhere. Thus we use
529 # raise(SIGTERM) instead. The check is run in a subshell so we
530 # can redirect the "Terminated" message from the shell. SIGBUS
531 # is not defined by standard C so it is used conditionally.
532
533 (check_exec "$@") >>$logfile 2>&1 <<EOF
534#include <signal.h>
535static void sighandler(int sig){
536 raise(SIGTERM);
537}
e5af4a11 538int main(void){
7dfef245
MR
539 signal(SIGILL, sighandler);
540 signal(SIGFPE, sighandler);
541 signal(SIGSEGV, sighandler);
542#ifdef SIGBUS
543 signal(SIGBUS, sighandler);
544#endif
545 { $code }
546}
547EOF
548}
549
57bd82d4
MR
550require(){
551 name="$1"
552 header="$2"
553 func="$3"
554 shift 3
555 check_lib $header $func "$@" || die "ERROR: $name not found"
dcd479c0
MR
556}
557
f8d7b072
MR
558require2(){
559 name="$1"
560 headers="$2"
561 func="$3"
562 shift 3
563 check_lib2 "$headers" $func "$@" || die "ERROR: $name not found"
564}
565
eea50282
MR
566check_foo_config(){
567 cfg=$1
568 pkg=$2
569 header=$3
570 func=$4
571 shift 4
572 disable $cfg
573 check_cmd ${pkg}-config --version
574 err=$?
575 if test "$err" = 0; then
576 temp_cflags `${pkg}-config --cflags`
577 temp_extralibs `${pkg}-config --libs`
578 check_lib "$@" $header $func && enable $cfg
579 fi
580 return $err
581}
582
c505dd31
MR
583apply(){
584 file=$1
585 shift
586 "$@" < "$file" > "$file.tmp" && mv "$file.tmp" "$file" || rm "$file.tmp"
587}
588
4a0d6686
AJ
589COMPONENT_LIST="
590 bsfs
591 decoders
592 demuxers
593 encoders
594 muxers
595 parsers
596 protocols
597"
598
599CONFIG_LIST="
600 $COMPONENT_LIST
c88f5d72
MR
601 avisynth
602 beos_netserver
c88f5d72
MR
603 ffmpeg
604 ffplay
605 ffserver
606 gpl
ecfc4f44 607 gprof
d8d0d0b2 608 gray
c88f5d72 609 ipv6
7bc5f2a8 610 liba52
f8904fd9 611 liba52bin
f5a756ef
DB
612 libamr
613 libamr_nb
614 libamr_wb
f7b8bffe 615 libdc1394
2eed5a46
DB
616 libfaac
617 libfaad
618 libfaadbin
c88f5d72 619 libgsm
6ebe07fb 620 libmp3lame
c88f5d72 621 libnut
150d2772 622 libtheora
c88f5d72 623 libvorbis
1cc60c47
DB
624 libx264
625 libxvid
c88f5d72 626 memalign_hack
c88f5d72
MR
627 mpegaudio_hp
628 network
2b4c3615 629 powerpc_perf
c88f5d72 630 pp
bd2216e4 631 small
c88f5d72
MR
632 swscaler
633 vhook
56a059ac 634 x11grab
c88f5d72 635 zlib
4a0d6686 636"
c88f5d72 637
8eee7025
DB
638THREADS_LIST='
639 beosthreads
8eee7025
DB
640 pthreads
641 w32threads
642'
643
3f5b56e5
MR
644ARCH_LIST='
645 alpha
646 armv4l
647 bfin
648 ia64
649 m68k
650 mips
651 parisc
652 powerpc
653 s390
654 sh4
655 sparc
656 sparc64
657 x86
658 x86_32
659 x86_64
660'
661
662ARCH_EXT_LIST='
1ac9331a 663 altivec
1ac9331a 664 armv5te
edab3048 665 armv6
3f5b56e5
MR
666 iwmmxt
667 mmi
668 mmx
9eeed841 669 ssse3
bd9d34a0 670 vis
3f5b56e5
MR
671'
672
673HAVE_LIST="
674 $ARCH_EXT_LIST
675 $THREADS_LIST
676 altivec_h
c9fdab0d 677 arpa_inet_h
c88f5d72 678 byteswap_h
ecf97f22 679 closesocket
1ac9331a 680 cmov
e16e49ac 681 conio_h
c88f5d72 682 dcbzl
f8aa696f
DB
683 dev_bktr_ioctl_bt848_h
684 dev_bktr_ioctl_meteor_h
685 dev_ic_bt8xx_h
686 dev_video_meteor_ioctl_meteor_h
687 dev_video_bktr_ioctl_bt848_h
18b67ae5 688 dlfcn_h
c88f5d72 689 dlopen
245626d0
DB
690 ebp_available
691 ebx_available
c2a29455 692 fast_64bit
7073e9fc 693 fast_cmov
7b829d2a 694 fast_unaligned
9d99cc5a 695 fork
c88f5d72 696 freetype2
da9e86f8 697 gethrtime
4e68cb8a 698 GetProcessTimes
66be5b45 699 getrusage
c88f5d72 700 imlib2
2e1913b1 701 inet_aton
c88f5d72 702 lrintf
f8aa696f
DB
703 machine_ioctl_bt848_h
704 machine_ioctl_meteor_h
c88f5d72
MR
705 malloc_h
706 memalign
6ffa87d3 707 mkstemp
c88f5d72 708 mlib
9cafbd6c 709 ppc64
c88f5d72
MR
710 sdl
711 sdl_video_size
deb29777 712 soundcard_h
b0c858d8 713 sys_poll_h
deb29777 714 sys_soundcard_h
e16e49ac 715 termios_h
b265431e 716 threads
6ff3f3e7 717 winsock2_h
0cb78cef 718"
44161118 719
520cc7f1 720CMDLINE_SELECT="
3f5b56e5 721 $ARCH_EXT_LIST
520cc7f1 722 $CONFIG_LIST
8eee7025 723 $THREADS_LIST
520cc7f1
MR
724 debug
725 extra_warnings
d2bbb2f7 726 optimizations
520cc7f1
MR
727 shared
728 static
729"
730
912f3148
DB
731# code dependency declarations
732
9eeed841
MR
733# architecture extensions
734altivec_deps="powerpc"
735armv5te_deps="armv4l"
736armv6_deps="armv4l"
737iwmmxt_deps="armv4l"
e241ba14 738mmi_deps="mips"
9eeed841
MR
739mmx_deps="x86"
740ssse3_deps="x86"
bd9d34a0 741vis_deps="sparc"
9eeed841 742
912f3148 743# decoders / encoders
6ea67bbb 744ac3_decoder_deps="gpl"
33a0dd37 745dxa_decoder_deps="zlib"
30fd06be 746flashsv_decoder_deps="zlib"
773be23a 747flashsv_encoder_deps="zlib"
4a815a7f 748flv_decoder_deps="h263_decoder"
df495dbd 749h263_decoder_deps="h263_parser mpeg4video_parser"
4a815a7f 750h263i_decoder_deps="h263_decoder"
26b4fe82 751h264_decoder_deps="h264_parser"
30fd06be 752mpeg_xvmc_decoder_deps="xvmc"
4a815a7f
DB
753mpeg4_decoder_deps="h263_decoder"
754msmpeg4v1_decoder_deps="h263_decoder"
755msmpeg4v2_decoder_deps="h263_decoder"
756msmpeg4v3_decoder_deps="h263_decoder"
30fd06be
MR
757png_decoder_deps="zlib"
758png_encoder_deps="zlib"
e2525c6f 759svq3_decoder_deps="h264_parser"
4a815a7f
DB
760vc1_decoder_deps="h263_decoder"
761wmv1_decoder_deps="h263_decoder"
762wmv2_decoder_deps="h263_decoder"
763wmv3_decoder_deps="h263_decoder"
30fd06be
MR
764zmbv_decoder_deps="zlib"
765zmbv_encoder_deps="zlib"
766
912f3148 767# external libraries
7bc5f2a8 768liba52_decoder_deps="liba52"
4ec45764 769liba52bin_decoder_extralibs='$ldl'
f5a756ef
DB
770libamr_nb_decoder_deps="libamr_nb"
771libamr_nb_encoder_deps="libamr_nb"
772libamr_wb_decoder_deps="libamr_wb"
773libamr_wb_encoder_deps="libamr_wb"
c9171a83 774libfaac_encoder_deps="libfaac"
69ddbd1d 775libfaad_decoder_deps="libfaad"
4ec45764 776libfaadbin_decoder_extralibs='$ldl'
299c77d5
MR
777libgsm_decoder_deps="libgsm"
778libgsm_encoder_deps="libgsm"
8ffed8d8
MR
779libgsm_ms_decoder_deps="libgsm"
780libgsm_ms_encoder_deps="libgsm"
1cc60c47 781libmp3lame_encoder_deps="libmp3lame"
150d2772 782libtheora_encoder_deps="libtheora"
b0caf888 783libvorbis_encoder_deps="libvorbis"
1cc60c47
DB
784libx264_encoder_deps="libx264"
785libxvid_encoder_deps="libxvid"
13566c31 786mpeg4aac_decoder_deps="libfaad"
30fd06be 787
912f3148 788# demuxers / muxers
03a76ba9 789ac3_demuxer_deps="ac3_parser"
50383e88 790audio_beos_demuxer_deps="audio_beos"
4ec45764 791audio_beos_demuxer_extralibs="-lmedia -lbe"
50383e88 792audio_beos_muxer_deps="audio_beos"
4ec45764 793audio_beos_muxer_extralibs="-lmedia -lbe"
53b73365 794avisynth_demuxer_deps="avisynth"
73483024 795bktr_demuxer_deps_any="dev_bktr_ioctl_bt848_h machine_ioctl_bt848_h dev_video_bktr_ioctl_bt848_h dev_ic_bt8xx_h"
30fd06be 796dv1394_demuxer_deps="dv1394"
f7b8bffe 797libdc1394_demuxer_deps="libdc1394"
d7c59247
DB
798libnut_demuxer_deps="libnut"
799libnut_muxer_deps="libnut"
4bd8e17c 800mp3_demuxer_deps="mpegaudio_parser"
c7682de0
RP
801oss_demuxer_deps_any="soundcard_h sys_soundcard_h"
802oss_muxer_deps_any="soundcard_h sys_soundcard_h"
30fd06be 803redir_demuxer_deps="network"
47b515bf 804rtp_muxer_deps="network mpegts_demuxer"
c08fb000
AB
805rtsp_demuxer_deps="rtp_protocol rtp_muxer"
806sdp_demuxer_deps="rtsp_demuxer"
06e31011
RP
807v4l2_demuxer_deps="linux_videodev2_h"
808v4l_demuxer_deps="linux_videodev_h"
06eab4ba 809x11_grab_device_demuxer_deps="x11grab XShmCreateImage"
4ec45764 810x11_grab_device_demuxer_extralibs="-lX11 -lXext"
30fd06be 811
912f3148 812# protocols
c08fb000
AB
813http_protocol_deps="network"
814rtp_protocol_deps="udp_protocol"
815tcp_protocol_deps="network"
816udp_protocol_deps="network"
817
912f3148 818# programs
fa859b4d 819ffplay_deps="sdl"
6ad42348 820ffserver_deps="ffm_muxer rtp_protocol rtsp_demuxer"
4ec45764
RP
821ffserver_extralibs='$ldl'
822vhook_extralibs='$ldl'
a2830dca 823
912f3148 824
0f3cb305 825# set temporary file name
57514323 826if test ! -z "$TMPDIR" ; then
0f3cb305 827 TMPDIR1="${TMPDIR}"
57514323 828elif test ! -z "$TEMPDIR" ; then
0f3cb305 829 TMPDIR1="${TEMPDIR}"
3d204385 830else
0f3cb305 831 TMPDIR1="/tmp"
3d204385
NK
832fi
833
0f3cb305
FB
834TMPC="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.c"
835TMPO="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.o"
f3ec2d46 836TMPE="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}"
0f3cb305
FB
837TMPS="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.S"
838TMPH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.h"
839
de6d9b64 840# default parameters
8a608357 841
497237c7 842enable logging
2ba042a7 843logfile="config.err"
8a608357
MR
844
845# installation paths
2266e085 846PREFIX="/usr/local"
c75560ae 847libdir='$(PREFIX)/lib'
84c22efd 848shlibdir="$libdir"
c75560ae 849incdir='$(PREFIX)/include/ffmpeg'
4ca5ece5 850mandir='$(PREFIX)/share/man'
c75560ae 851bindir='$(PREFIX)/bin'
8a608357
MR
852
853# toolchain
de6d9b64
FB
854cc="gcc"
855ar="ar"
be7109c1 856ranlib="ranlib"
4a908fbc 857make="make"
0f3cb305 858strip="strip"
8a608357 859asmalign_pot="unknown"
20369773 860ln_s="ln -sf"
8a608357
MR
861
862# machine
cc6a90dd 863arch=`uname -m`
38d0a8aa 864cpu="generic"
8a608357 865
8a608357 866# OS
b9663405 867targetos=$(tolower $(uname -s))
8a608357 868
8a608357 869# libraries
497237c7 870enable zlib
8a608357
MR
871
872# configurable options
497237c7
RP
873enable debug
874enable dostrip
875enable ffmpeg
876enable ffplay
877enable ffserver
878enable ipv6
879enable static
880enable mpegaudio_hp
881enable network
8400d6b8 882enable optimizations
497237c7 883enable protocols
8a608357
MR
884vhook="default"
885
8a608357 886# build settings
baa3a937 887SHFLAGS='-shared -Wl,-soname,$@'
cab3ef82 888VHOOKSHFLAGS='$(SHFLAGS)'
e240ee67 889LDLATEFLAGS='-Wl,-rpath-link,\$(BUILD_ROOT)/libavcodec -Wl,-rpath-link,\$(BUILD_ROOT)/libavformat -Wl,-rpath-link,\$(BUILD_ROOT)/libavutil'
c536cb09 890FFSERVERLDFLAGS=-Wl,-E
f39e56a8 891LDCONFIG="ldconfig"
f3ec2d46
SG
892LIBPREF="lib"
893LIBSUF=".a"
c5f14466
RP
894FULLNAME='$(NAME)$(BUILDSUF)'
895LIBNAME='$(LIBPREF)$(FULLNAME)$(LIBSUF)'
f3ec2d46
SG
896SLIBPREF="lib"
897SLIBSUF=".so"
c5f14466 898SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF)'
b29bddab
DB
899SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
900SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
24743a76 901LIB_INSTALL_EXTRA_CMD='$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
ef0bc4c9 902
c597172e
MR
903# find source path
904source_path="`dirname \"$0\"`"
497237c7 905enable source_path_used
c597172e
MR
906if test -z "$source_path" -o "$source_path" = "." ; then
907 source_path="`pwd`"
497237c7 908 disable source_path_used
c597172e
MR
909else
910 source_path="`cd \"$source_path\"; pwd`"
911 echo "$source_path" | grep -q '[[:blank:]]' &&
912 die "Out of tree builds are impossible with whitespace in source path."
913fi
914
c597172e
MR
915FFMPEG_CONFIGURATION="$@"
916
facbea95
AJ
917ENCODER_LIST=`sed -n 's/^[^#]*ENC.*(.*, *\(.*\)).*/\1_encoder/p' "$source_path/libavcodec/allcodecs.c"`
918DECODER_LIST=`sed -n 's/^[^#]*DEC.*(.*, *\(.*\)).*/\1_decoder/p' "$source_path/libavcodec/allcodecs.c"`
919PARSER_LIST=`sed -n 's/^[^#]*PARSER.*(.*, *\(.*\)).*/\1_parser/p' "$source_path/libavcodec/allcodecs.c"`
920BSF_LIST=`sed -n 's/^[^#]*BSF.*(.*, *\(.*\)).*/\1_bsf/p' "$source_path/libavcodec/allcodecs.c"`
921MUXER_LIST=`sed -n 's/^[^#]*_MUX.*(.*, *\(.*\)).*/\1_muxer/p' "$source_path/libavformat/allformats.c"`
922DEMUXER_LIST=`sed -n 's/^[^#]*DEMUX.*(.*, *\(.*\)).*/\1_demuxer/p' "$source_path/libavformat/allformats.c"`
c4035e5d
LA
923OUTDEV_LIST=`sed -n 's/^[^#]*_MUX.*(.*, *\(.*\)).*/\1_muxer/p' "$source_path/libavdevice/alldevices.c"`
924INDEV_LIST=`sed -n 's/^[^#]*DEMUX.*(.*, *\(.*\)).*/\1_demuxer/p' "$source_path/libavdevice/alldevices.c"`
facbea95 925PROTOCOL_LIST=`sed -n 's/^[^#]*PROTOCOL.*(.*, *\(.*\)).*/\1_protocol/p' "$source_path/libavformat/allformats.c"`
c597172e 926
c721d803 927enable $ENCODER_LIST $DECODER_LIST $PARSER_LIST $MUXER_LIST $DEMUXER_LIST $PROTOCOL_LIST $BSF_LIST $INDEV_LIST $OUTDEV_LIST
d3ea5692 928enable $ARCH_EXT_LIST
c597172e
MR
929
930die_unknown(){
931 echo "Unknown option \"$1\"."
932 echo "See $0 --help for available options."
933 exit 1
934}
935
794f8e97 936show_list() {
bf0c4afa
RP
937 suffix=_$1
938 shift
939 echo $* | sed s/$suffix//g | tr ' ' '\n' | sort
794f8e97
PI
940 exit 0
941}
942
c597172e
MR
943for opt do
944 optval="${opt#*=}"
945 case "$opt" in
946 --log)
947 ;;
948 --log=*) logging="$optval"
949 ;;
950 --prefix=*) PREFIX="$optval"
951 ;;
952 --libdir=*) libdir="$optval"
953 ;;
954 --shlibdir=*) shlibdir="$optval"
955 ;;
956 --incdir=*) incdir="$optval"
957 ;;
958 --mandir=*) mandir="$optval"
959 ;;
960 --source-path=*) source_path="$optval"
961 ;;
962 --cross-prefix=*) cross_prefix="$optval"
963 ;;
497237c7 964 --cross-compile) enable cross_compile
c597172e
MR
965 ;;
966 --target-os=*) targetos="$optval"
967 ;;
968 --cc=*) cc="$optval"
969 ;;
970 --make=*) make="$optval"
971 ;;
972 --extra-cflags=*) add_cflags "$optval"
973 ;;
974 --extra-ldflags=*) add_ldflags "$optval"
975 ;;
976 --extra-libs=*) add_extralibs "$optval"
977 ;;
978 --build-suffix=*) BUILDSUF="$optval"
979 ;;
980 --arch=*) arch="$optval"
981 ;;
982 --cpu=*) cpu="$optval"
983 ;;
497237c7 984 --enable-sunmlib) enable mlib
c597172e 985 ;;
497237c7 986 --disable-strip) disable dostrip
c597172e
MR
987 ;;
988 --disable-encoders) disable $ENCODER_LIST
989 ;;
990 --disable-decoders) disable $DECODER_LIST
991 ;;
992 --disable-muxers) disable $MUXER_LIST
993 ;;
994 --disable-demuxers) disable $DEMUXER_LIST
995 ;;
996 --disable-parsers) disable $PARSER_LIST
997 ;;
cd61e407
JM
998 --disable-bsfs) disable $BSF_LIST
999 ;;
c08fb000
AB
1000 --disable-protocols) disable $PROTOCOL_LIST
1001 ;;
c597172e
MR
1002 --enable-*=*|--disable-*=*)
1003 eval `echo "$opt" | sed 's/=/-/;s/--/action=/;s/-/ thing=/;s/-/ name=/'`
1004 case "$thing" in
cd61e407 1005 encoder|decoder|muxer|demuxer|parser|bsf|protocol) $action ${optval}_${thing} ;;
c597172e
MR
1006 *) die_unknown "$opt" ;;
1007 esac
1008 ;;
1009 --enable-?*|--disable-?*)
1010 eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'`
1011 echo "$CMDLINE_SELECT" | grep -q "^ *$option\$" || die_unknown $opt
1012 $action $option
1013 ;;
794f8e97
PI
1014 --list-*)
1015 NAME="${opt#--list-}"
4a0d6686 1016 is_in $NAME $COMPONENT_LIST || die_unknown $opt
bf0c4afa
RP
1017 NAME=${NAME%s}
1018 eval show_list $NAME \$$(toupper $NAME)_LIST
794f8e97 1019 ;;
c2675d4a 1020 --help|-h) show_help
c597172e
MR
1021 ;;
1022 *)
1023 die_unknown $opt
1024 ;;
1025 esac
1026done
1027
270739bb
MR
1028case "$arch" in
1029 i386|i486|i586|i686|i86pc|BePC)
1030 arch="x86_32"
7b829d2a 1031 enable fast_unaligned
270739bb
MR
1032 ;;
1033 x86_64|amd64)
1034 arch="x86_32"
7b829d2a 1035 enable fast_unaligned
270739bb
MR
1036 canon_arch="`$cc -dumpmachine | sed -e 's,\([^-]*\)-.*,\1,'`"
1037 if [ x"$canon_arch" = x"x86_64" -o x"$canon_arch" = x"amd64" ]; then
1038 if [ -z "`echo $CFLAGS | grep -- -m32`" ]; then
1039 arch="x86_64"
c2a29455 1040 enable fast_64bit
270739bb
MR
1041 fi
1042 fi
1043 ;;
1044 # armv4l is a subset of armv[567]*l
1045 arm|armv[4567]*l)
1046 arch="armv4l"
1047 ;;
1048 alpha)
1049 arch="alpha"
c2a29455 1050 enable fast_64bit
270739bb 1051 ;;
c2a29455 1052 "Power Macintosh"|ppc|powerpc)
270739bb
MR
1053 arch="powerpc"
1054 ;;
c2a29455
AJ
1055 ppc64)
1056 arch="powerpc"
1057 enable fast_64bit
1058 ;;
e241ba14 1059 mips|mipsel|IP*)
270739bb
MR
1060 arch="mips"
1061 ;;
1062 sun4u|sparc64)
1063 arch="sparc64"
c2a29455 1064 enable fast_64bit
270739bb
MR
1065 ;;
1066 sparc)
1067 arch="sparc"
1068 ;;
1069 sh4)
1070 arch="sh4"
1071 ;;
c2a29455
AJ
1072 parisc)
1073 arch="parisc"
1074 ;;
1075 parisc64)
270739bb 1076 arch="parisc"
c2a29455 1077 enable fast_64bit
270739bb
MR
1078 ;;
1079 s390|s390x)
1080 arch="s390"
1081 ;;
1082 m68k)
1083 arch="m68k"
1084 ;;
1085 ia64)
1086 arch="ia64"
c2a29455 1087 enable fast_64bit
270739bb
MR
1088 ;;
1089 bfin)
1090 arch="bfin"
1091 ;;
1092 *)
1093 arch="unknown"
1094 ;;
1095esac
1096
9eeed841
MR
1097enable $arch
1098enabled_any x86_32 x86_64 && enable x86
1099enabled sparc64 && enable sparc
1100
ef0bc4c9 1101# OS specific
ced75d92 1102case $targetos in
4a5444db 1103 beos|haiku|zeta)
74cec57d 1104 PREFIX="$HOME/config"
d474299a
MR
1105 # helps building libavcodec
1106 add_cflags "-DPIC -fomit-frame-pointer"
1107 # 3 gcc releases known for BeOS, each with ugly bugs
1108 gcc_version="`$cc -v 2>&1 | grep version | cut -d ' ' -f3-`"
1109 case "$gcc_version" in
1110 2.9-beos-991026*|2.9-beos-000224*) echo "R5/GG gcc"
497237c7 1111 disable mmx
d474299a
MR
1112 ;;
1113 *20010315*) echo "BeBits gcc"
1114 add_cflags "-fno-expensive-optimizations"
1115 ;;
1116 esac
74cec57d 1117 LDCONFIG="echo ignoring ldconfig"
d474299a 1118 SHFLAGS=-nostart
d474299a 1119 # enable BeOS things
497237c7 1120 enable audio_beos
d474299a
MR
1121 # no need for libm, but the inet stuff
1122 # Check for BONE
74cec57d 1123 # XXX: actually should check for NOT net_server
d474299a 1124 if (echo $BEINCLUDES|grep 'headers/be/bone' >/dev/null); then
4ec45764 1125 network_extralibs="-lbind -lsocket"
d474299a 1126 else
497237c7 1127 enable beos_netserver
4ec45764 1128 network_extralibs="-lnet"
d474299a 1129 fi ;;
4a5444db 1130 sunos)
d474299a 1131 FFSERVERLDFLAGS=""
35d6cebd 1132 SHFLAGS='-shared -Wl,-h,$@'
4ec45764 1133 network_extralibs="-lsocket -lnsl"
d474299a 1134 ;;
4a5444db 1135 netbsd)
4ec45764
RP
1136 oss_demuxer_extralibs="-lossaudio"
1137 oss_muxer_extralibs="-lossaudio"
d474299a 1138 ;;
4a5444db 1139 openbsd)
497237c7 1140 disable need_memalign
35d6cebd
DB
1141 LIBOBJFLAGS='$(PIC)'
1142 LDCONFIG='ldconfig -m $(SHLIBDIR)'
d474299a 1143 SHFLAGS='-shared'
c5f14466 1144 SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF).$(LIBVERSION)'
d474299a
MR
1145 SLIBNAME_WITH_VERSION='$(SLIBNAME)'
1146 SLIBNAME_WITH_MAJOR='$(SLIBNAME)'
4ec45764
RP
1147 oss_demuxer_extralibs="-lossaudio"
1148 oss_muxer_extralibs="-lossaudio"
d474299a 1149 ;;
4a5444db 1150 freebsd)
497237c7 1151 disable need_memalign
d474299a 1152 ;;
4a5444db 1153 bsd/os)
13ef7825 1154 osextralibs="-lpoll -lgnugetopt"
d474299a
MR
1155 strip="strip -d"
1156 ;;
4a5444db 1157 darwin)
497237c7 1158 disable need_memalign
35d6cebd 1159 SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(SHLIBDIR)/$(SLIBNAME),-current_version,$(SPPVERSION),-compatibility_version,$(SPPVERSION) -Wl,-read_only_relocs,suppress'
21d0a823 1160 VHOOKSHFLAGS='-dynamiclib -Wl,-single_module -flat_namespace -undefined suppress -Wl,-install_name,$(SHLIBDIR)/vhook/$@'
d474299a
MR
1161 strip="strip -x"
1162 FFLDFLAGS="-Wl,-dynamic,-search_paths_first"
1163 SLIBSUF=".dylib"
c5f14466
RP
1164 SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME).$(LIBVERSION)$(SLIBSUF)'
1165 SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME).$(LIBMAJOR)$(SLIBSUF)'
d474299a
MR
1166 FFSERVERLDFLAGS=-Wl,-bind_at_load
1167 ;;
4a5444db 1168 mingw32*)
91c5172d 1169 targetos=mingw32
5880d5b5 1170 shlibdir="$bindir"
70b4d492
RP
1171 VHOOKSHFLAGS='-shared -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil'
1172 VHOOKLIBS='-lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)'
1173 if enabled swscaler; then
1174 VHOOKSHFLAGS="$VHOOKSHFLAGS -L\$(BUILD_ROOT)/libswscale"
1175 VHOOKLIBS="$VHOOKLIBS -lswscale\$(BUILDSUF)"
1176 fi
497237c7 1177 disable ffserver
4ec9ec81
MR
1178 SLIBPREF=""
1179 SLIBSUF=".dll"
1180 EXESUF=".exe"
c5f14466
RP
1181 SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
1182 SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
35d6cebd 1183 SLIB_EXTRA_CMD='-lib /machine:i386 /def:$(@:$(SLIBSUF)=.def)'
c3cf5614
RP
1184 SLIB_INSTALL_EXTRA_CMD='-install -m 644 $(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"'
1185 SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"'
85aec3bd 1186 SHFLAGS='-shared -Wl,--output-def,$(@:$(SLIBSUF)=.def) -Wl,--enable-runtime-pseudo-reloc -Wl,--enable-auto-image-base'
d474299a 1187 ;;
4a5444db 1188 cygwin*)
ced75d92 1189 targetos=cygwin
d474299a 1190 shlibdir="$bindir"
41d5a86a
VP
1191 VHOOKSHFLAGS='-shared -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil'
1192 VHOOKLIBS='-lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)'
1193 if enabled swscaler; then
1194 VHOOKSHFLAGS="$VHOOKSHFLAGS -L\$(BUILD_ROOT)/libswscale"
1195 VHOOKLIBS="$VHOOKLIBS -lswscale\$(BUILDSUF)"
1196 fi
d474299a
MR
1197 EXESUF=".exe"
1198 SLIBPREF="cyg"
1199 SLIBSUF=".dll"
c5f14466
RP
1200 SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
1201 SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
85aec3bd 1202 SHFLAGS='-shared -Wl,--enable-auto-image-base'
d474299a 1203 ;;
4a5444db 1204 linux)
d474299a 1205 LDLATEFLAGS="-Wl,--as-needed $LDLATEFLAGS"
497237c7 1206 enable dv1394
d474299a 1207 ;;
4a5444db 1208 irix*)
ced75d92 1209 targetos=irix
d474299a 1210 ranlib="echo ignoring ranlib"
d474299a 1211 ;;
d474299a
MR
1212 *)
1213 targetos="${targetos}-UNKNOWN"
1214 ;;
ef0bc4c9 1215esac
de6d9b64 1216
c597172e 1217add_extralibs $osextralibs
de6d9b64 1218
e3c00e34 1219if ! disabled logging ; then
90be59ef 1220 enabled logging || logfile="$logging"
57bd82d4
MR
1221 echo "# $0 $@" >$logfile
1222 set >>$logfile
2ba042a7
MR
1223else
1224 logfile=/dev/null
57bd82d4 1225fi
e89b8b0a 1226
28d8e661
DB
1227# Combine FFLDFLAGS and the LDFLAGS environment variable.
1228LDFLAGS="$FFLDFLAGS $LDFLAGS"
e89b8b0a 1229
497237c7 1230test -n "$cross_prefix" && enable cross_compile
1ea46bed
MR
1231cc="${cross_prefix}${cc}"
1232ar="${cross_prefix}${ar}"
1233ranlib="${cross_prefix}${ranlib}"
1234strip="${cross_prefix}${strip}"
1235
320d060a 1236# we need to build at least one lib type
93b3c083 1237if ! enabled_any static shared; then
320d060a
DB
1238 cat <<EOF
1239At least one library type must be built.
1240Specify --enable-static to build the static libraries or --enable-shared to
1241build the shared libraries as well. To only build the shared libraries specify
1242--disable-static in addition to --enable-shared.
1243EOF
1244 exit 1;
1245fi
1246
abc4e572 1247disabled static && LIBNAME=""
2a320695 1248
a2234ceb
RP
1249if enabled_any libfaad libfaadbin ; then
1250 if check_header faad.h; then
1251 check_cc << EOF
1252#include <faad.h>
1253#ifndef FAAD2_VERSION
1254ok faad1
1255#endif
db817cf3 1256int main(void) { return 0; }
a2234ceb
RP
1257EOF
1258 test $? = 0 && enable libfaad2
1259 else
ff3dac65 1260 die "FAAD test failed."
a2234ceb
RP
1261 fi
1262fi
1263
1264
93b3c083 1265if ! enabled gpl; then
54118497
RP
1266 die_gpl_disabled(){
1267 name=$1
1268 shift
1269 enabled_any $@ && die "$name is under GPL and --enable-gpl is not specified."
1270 }
1271 die_gpl_disabled "The Postprocessing code" pp
7bc5f2a8 1272 die_gpl_disabled "liba52" liba52
1cc60c47
DB
1273 die_gpl_disabled "libx264" libx264
1274 die_gpl_disabled "libxvidcore" libxvid
54118497
RP
1275 die_gpl_disabled "FAAD2" libfaad2
1276 die_gpl_disabled "The X11 grabber" x11grab
1277 die_gpl_disabled "The software scaler" swscaler
ebb810d9 1278fi
b2e3c528 1279
9eeed841 1280check_deps $ARCH_EXT_LIST
0f3cb305 1281
5d323602
MR
1282test -z "$need_memalign" && need_memalign="$mmx"
1283
cf9d24ad 1284#Darwin CC versions
ced75d92 1285if test $targetos = darwin; then
b2924696 1286 if test -n "`$cc -v 2>&1 | grep xlc`"; then
30a3e5d4 1287 add_cflags "-qpdf2 -qlanglvl=extc99 -qmaxmem=-1 -qarch=auto -qtune=auto"
cf9d24ad 1288 else
26c1b3be
DB
1289 add_cflags "-no-cpp-precomp -pipe"
1290 check_cflags "-force_cpusubtype_ALL"
1291 check_cflags "-Wno-sign-compare"
7799eeec 1292 disabled shared && add_cflags -mdynamic-no-pic
cf9d24ad 1293 fi
2a1a6b64
MN
1294fi
1295
8400d6b8 1296disabled optimizations || add_cflags -fomit-frame-pointer
cf9d24ad 1297
a4adb608 1298# Add processor-specific flags
38d0a8aa 1299if test $cpu != "generic"; then
bc8ec47b
MR
1300 warn_altivec(){
1301 $1 altivec && echo "WARNING: Tuning for $2 but AltiVec $1.";
1658bc4f 1302 }
38d0a8aa 1303 case $cpu in
bb270c08 1304 601|ppc601|PowerPC601)
1c5d830c 1305 add_cflags "-mcpu=601"
bc8ec47b 1306 warn_altivec enabled PPC601
bb270c08
DB
1307 ;;
1308 603*|ppc603*|PowerPC603*)
1c5d830c 1309 add_cflags "-mcpu=603"
bc8ec47b 1310 warn_altivec enabled PPC603
bb270c08
DB
1311 ;;
1312 604*|ppc604*|PowerPC604*)
1c5d830c 1313 add_cflags "-mcpu=604"
bc8ec47b 1314 warn_altivec enabled PPC604
bb270c08
DB
1315 ;;
1316 G3|g3|75*|ppc75*|PowerPC75*)
1c5d830c 1317 add_cflags "-mcpu=750 -mpowerpc-gfxopt"
bc8ec47b 1318 warn_altivec enabled PPC75x
bb270c08
DB
1319 ;;
1320 G4|g4|745*|ppc745*|PowerPC745*)
1c5d830c 1321 add_cflags "-mcpu=7450 -mpowerpc-gfxopt"
bc8ec47b 1322 warn_altivec disabled PPC745x
bb270c08
DB
1323 ;;
1324 74*|ppc74*|PowerPC74*)
1c5d830c 1325 add_cflags "-mcpu=7400 -mpowerpc-gfxopt"
bc8ec47b 1326 warn_altivec disabled PPC74xx
bb270c08
DB
1327 ;;
1328 G5|g5|970|ppc970|PowerPC970|power4*|Power4*)
1c5d830c 1329 add_cflags "-mcpu=970 -mpowerpc-gfxopt -mpowerpc64"
bc8ec47b 1330 warn_altivec disabled PPC970
9cafbd6c 1331 enable ppc64
bb270c08 1332 ;;
e07e357d
LB
1333 Cell|CELL|cell)
1334 add_cflags "-mcpu=cell"
1335 warn_altivec disabled Cell
9cafbd6c 1336 enable ppc64
e07e357d 1337 ;;
e7768fc5
GP
1338 # targets that do NOT support conditional mov (cmov)
1339 i[345]86|pentium|pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
38d0a8aa 1340 add_cflags "-march=$cpu"
497237c7 1341 disable cmov
e7768fc5
GP
1342 ;;
1343 # targets that do support conditional mov (cmov)
416519dd 1344 i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64|k8|opteron|athlon-fx|core2)
e7768fc5 1345 add_cflags "-march=$cpu"
497237c7
RP
1346 enable cmov
1347 enable fast_cmov
94e4c3a3
GP
1348 ;;
1349 # targets that do support conditional mov but on which it's slow
1350 pentium4|prescott|nocona)
1351 add_cflags "-march=$cpu"
497237c7
RP
1352 enable cmov
1353 disable fast_cmov
bb270c08 1354 ;;
d7b34d08 1355 sparc64)
1c5d830c 1356 add_cflags "-mcpu=v9"
d7b34d08 1357 ;;
8684704b
MH
1358 bf*) #bf531 bf532 bf533 bf561 bf5xx all get this config
1359 add_cflags "-mfdpic"
846dffeb 1360 add_ldflags "-mfdpic"
8684704b 1361 ;;
6b19786b
MR
1362 arm*)
1363 add_cflags "-mcpu=$cpu"
1364 ;;
bb270c08 1365 *)
38d0a8aa 1366 echo "WARNING: Unknown CPU \"$cpu\", ignored."
bb270c08 1367 ;;
a4adb608
MN
1368 esac
1369fi
1370
412c1562
MR
1371gnu_make(){
1372 $1 --version 2>&1 | grep -q GNU
1373}
1374
1375if ! gnu_make $make; then
1376 gnu_make gmake && make=gmake || die "GNU make not found."
1377fi
1378
be0d52ab
MR
1379# make sure we can execute files in $TMPDIR
1380cat >$TMPE 2>>$logfile <<EOF
1381#! /bin/sh
1382EOF
1383chmod +x $TMPE >>$logfile 2>&1
1384if ! $TMPE >>$logfile 2>&1; then
1385 cat <<EOF
1386Unable to create and execute files in $TMPDIR1. Set the TMPDIR environment
68300911
DB
1387variable to another directory and make sure that $TMPDIR1 is not mounted
1388noexec.
be0d52ab
MR
1389EOF
1390 die "Sanity test failed."
1391fi
0244f743 1392rm $TMPE
be0d52ab 1393
1a268acc
MR
1394# compiler sanity check
1395check_exec <<EOF
e5af4a11 1396int main(void){
1a268acc
MR
1397 return 0;
1398}
1399EOF
1400if test "$?" != 0; then
1401 echo "$cc is unable to create an executable file."
93b3c083 1402 if test -z "$cross_prefix" && ! enabled cross_compile ; then
1a268acc 1403 echo "If $cc is a cross-compiler, use the --cross-compile option."
c7ae6345 1404 echo "Only do this if you know what cross compiling means."
1a268acc
MR
1405 fi
1406 die "C compiler test failed."
1407fi
1408
9eeed841 1409if enabled x86; then
44965991
PI
1410 # check whether EBP is available on x86
1411 # As 'i' is stored on the stack, this program will crash
1412 # if the base pointer is used to access it because the
1413 # base pointer is cleared in the inline assembly code.
7dfef245 1414 check_exec_crash <<EOF && enable ebp_available
44965991
PI
1415 volatile int i=0;
1416 asm volatile (
1417 "xorl %%ebp, %%ebp"
1418 ::: "%ebp");
1419 return i;
44965991
PI
1420EOF
1421
1422 # check wether EBX is available on x86
940f335a 1423 check_asm ebx_available '"":::"%ebx"'
8e380710
LM
1424
1425 # check whether binutils is new enough to compile SSSE3
940f335a 1426 enabled ssse3 && check_asm ssse3 '"pabsw %xmm0, %xmm0"'
44965991
PI
1427fi
1428
87ea51e0
LB
1429# check for assembler specific support
1430
cc6a90dd 1431if test $arch = "powerpc"; then
497237c7 1432check_cc <<EOF && enable dcbzl
87ea51e0
LB
1433int main(void) {
1434 register long zero = 0;
1435 char data[1024];
1436 asm volatile("dcbzl %0, %1" : : "b" (data), "r" (zero));
1437return 0;
1438}
1439EOF
1440fi
1441
57bd82d4
MR
1442# check for SIMD availability
1443
115329f1 1444# AltiVec flags: The FSF version of GCC differs from the Apple version
9eeed841 1445if enabled altivec; then
3ae3b721
RP
1446 test -n "`$cc -v 2>&1 | grep version | grep Apple`" &&
1447 add_cflags "-faltivec" ||
0182fee8 1448 add_cflags "-maltivec -mabi=altivec"
b6e52719 1449
0182fee8 1450 check_header altivec.h
a9a07762 1451
0182fee8 1452 # check if our compiler supports Motorola AltiVec C API
3ae3b721
RP
1453 enabled altivec_h &&
1454 inc_altivec_h="#include <altivec.h>" ||
f25fc9b1 1455 inc_altivec_h=
497237c7 1456 check_cc <<EOF || disable altivec
dcd479c0 1457$inc_altivec_h
a9a07762
MN
1458int main(void) {
1459 vector signed int v1, v2, v3;
1460 v1 = vec_add(v2,v3);
1461 return 0;
1462}
1463EOF
1464fi
ab6c65f6 1465
940f335a
MR
1466enabled armv5te && check_asm armv5te '"qadd r0, r0, r0"'
1467enabled armv6 && check_asm armv6 '"sadd16 r0, r0, r0"'
1468enabled iwmmxt && check_asm iwmmxt '"wunpckelub wr6, wr4"'
1469enabled mmi && check_asm mmi '"lq $2, 0($2)"'
1470enabled vis && check_asm vis '"pdist %f0, %f0, %f0"' -mcpu=ultrasparc
bd9d34a0 1471
8b03def6
DB
1472enabled vis && add_cflags "-mcpu=ultrasparc -mtune=ultrasparc"
1473
57bd82d4
MR
1474# ---
1475# big/little-endian test
9eebe687
MR
1476check_cc <<EOF || die "endian test failed"
1477unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
a3999908 1478EOF
e89d9fd8 1479grep -q BIGE $TMPO && enable bigendian
487a54d7 1480
a3999908 1481# ---
3d204385
NK
1482# check availability of some header files
1483
a98bb16d
RP
1484if check_func dlopen; then
1485 ldl=
1486elif check_func dlopen -ldl; then
1487 ldl=-ldl
8bf5d58f
MN
1488fi
1489
a98bb16d 1490check_func fork
b6c748ed 1491check_func gethrtime
a98bb16d
RP
1492check_func getrusage
1493check_func inet_aton
1494check_func memalign
1495check_func mkstemp
1496check_func2 windows.h GetProcessTimes
6ffa87d3 1497
a98bb16d 1498check_header byteswap.h
e16e49ac 1499check_header conio.h
a98bb16d
RP
1500check_header dlfcn.h
1501check_header malloc.h
1502check_header termios.h
1503
1504if ! enabled_any memalign memalign_hack && enabled need_memalign ; then
1505 die "Error, no memalign() but SSE enabled, disable it or use --enable-memalign-hack."
1506fi
e16e49ac 1507
497237c7 1508enabled zlib && check_lib zlib.h zlibVersion -lz || disable zlib
57bd82d4 1509
b0c858d8
FR
1510# ffserver uses poll(),
1511# if it's not found we can emulate it using select().
1512if enabled ffserver; then
1513 check_header sys/poll.h
1514fi
1515
57bd82d4
MR
1516# check for some common methods of building with pthread support
1517# do this before the optional library checks as some of them require pthreads
1518if enabled pthreads; then
9e7fd101
MR
1519 if check_func pthread_create; then
1520 :
1521 elif check_func pthread_create -pthread; then
1522 add_cflags -pthread
1523 add_ldflags -pthread
1524 elif check_func pthread_create -pthreads; then
1525 add_cflags -pthreads
1526 add_ldflags -pthreads
1527 elif ! check_lib pthread.h pthread_create -lpthread; then
1528 die "ERROR: can't find pthreads library"
1529 fi
57bd82d4
MR
1530fi
1531
8eee7025 1532for thread in $THREADS_LIST; do
e5f94c2b 1533 if enabled $thread; then
3ae3b721
RP
1534 test -n "$thread_type" &&
1535 die "ERROR: Only one thread type must be selected." ||
e5f94c2b 1536 thread_type="$thread"
e5f94c2b
RP
1537 fi
1538done
1539
fdf88598
MR
1540check_lib math.h sin -lm
1541
f32adb22 1542# test for lrintf in math.h
497237c7 1543check_exec <<EOF && enable lrintf || disable lrintf
f32adb22
MR
1544#define _ISOC9X_SOURCE 1
1545#include <math.h>
db817cf3 1546int main(void) { return (lrintf(3.999f) > 0)?0:1; }
f32adb22
MR
1547EOF
1548
f5a756ef 1549enabled_any libamr_nb libamr_wb && enable libamr
12b61a74 1550
57bd82d4 1551# these are off by default, so fail if requested and not available
79fda097 1552enabled avisynth && require2 vfw32 "windows.h vfw.h" AVIFileInit -lvfw32
7bc5f2a8 1553enabled liba52 && require liba52 a52dec/a52.h a52_init -la52
f5a756ef
DB
1554enabled libamr_nb && require libamrnb amrnb/interf_dec.h Speech_Decode_Frame_init -lamrnb -lm
1555enabled libamr_wb && require libamrwb amrwb/dec_if.h D_IF_init -lamrwb -lm
f7b8bffe 1556enabled libdc1394 && require libdc1394 libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394
79fda097
DB
1557enabled libfaac && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
1558enabled libfaad && require2 libfaad faad.h faacDecOpen -lfaad
910c62e1 1559enabled libgsm && require libgsm gsm.h gsm_create -lgsm
6ebe07fb 1560enabled libmp3lame && require LAME lame/lame.h lame_init -lmp3lame -lm
79fda097 1561enabled libnut && require libnut libnut.h nut_demuxer_init -lnut
910c62e1 1562enabled libtheora && require libtheora theora/theora.h theora_info_init -ltheora -logg
3837d107 1563enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
1cc60c47
DB
1564enabled libx264 && require x264 x264.h x264_encoder_open -lx264
1565enabled libxvid && require Xvid xvid.h xvid_global -lxvidcore
910c62e1 1566enabled mlib && require mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
8ac17293 1567
6ea67bbb
JR
1568# disable the native AC-3 decoder if liba52 is enabled
1569enabled liba52 && disable ac3_decoder
1570
c13e1abd
FH
1571_restrict=
1572for restrict_keyword in restrict __restrict__ __restrict; do
57bd82d4 1573 check_cc <<EOF && _restrict=$restrict_keyword && break
dcd479c0
MR
1574void foo(char * $restrict_keyword p);
1575EOF
c13e1abd
FH
1576done
1577
703afd07 1578test "$vhook" = "default" && vhook="$dlopen"
a8721c09 1579
b0268cc0 1580if test "$targetos" = cygwin -o "$targetos" = mingw32 && enabled_all static vhook ; then
497237c7 1581 disable vhook
fbb9d104 1582 echo
b0268cc0 1583 echo "At the moment vhooks don't work on Cygwin or MinGW static builds."
fbb9d104
VP
1584 echo "Patches welcome."
1585 echo
1586fi
1587
8d923001
MR
1588if enabled vhook; then
1589 check_ldflags -rdynamic
1590 check_ldflags -export-dynamic
1591fi
bfd2edeb 1592
eea50282
MR
1593check_foo_config imlib2 imlib2 Imlib2.h imlib_load_font
1594check_foo_config freetype2 freetype ft2build.h FT_Init_FreeType
04511d53 1595
a86b921c 1596##########################################
29799f8b 1597# SDL check
a86b921c 1598
497237c7
RP
1599disable sdl_too_old
1600disable sdl
6a1a892f 1601SDL_CONFIG="${cross_prefix}sdl-config"
225e21ef
MR
1602if "${SDL_CONFIG}" --version >/dev/null 2>&1; then
1603 sdl_cflags=`"${SDL_CONFIG}" --cflags`
1604 temp_cflags $sdl_cflags
dcd479c0 1605 temp_extralibs `"${SDL_CONFIG}" --libs`
225e21ef 1606 if check_lib SDL.h SDL_Init; then
dcd479c0 1607 _sdlversion=`"${SDL_CONFIG}" --version | sed 's/[^0-9]//g'`
29f3b38a 1608 if test "$_sdlversion" -lt 121 ; then
497237c7 1609 enable sdl_too_old
dcd479c0 1610 else
497237c7 1611 enable sdl
225e21ef 1612 check_cc $sdl_cflags <<EOF && enable sdl_video_size
29f3b38a
MR
1613#include <SDL.h>
1614int main(void){
1615 const SDL_VideoInfo *vi = SDL_GetVideoInfo();
1616 int w = vi->current_w;
1617 return 0;
1618}
1619EOF
dcd479c0
MR
1620 fi
1621 fi
29f3b38a 1622 restore_flags
c3f6b472 1623fi
57bd82d4 1624
d5697779 1625texi2html -version >/dev/null 2>&1 && enable texi2html || disable texi2html
146ea952 1626
7a91333f 1627##########################################
73b46a95
RP
1628# Network check
1629
1630if enabled network; then
1631 # Prefer arpa/inet.h over winsock2
1632 if check_header arpa/inet.h ; then
1633 check_func closesocket
1634 elif check_header winsock2.h ; then
ea10ddde 1635 network_extralibs="-lws2_32"
73b46a95
RP
1636 check_func2 winsock2.h closesocket
1637 fi
1638fi
1639
1640##########################################
29799f8b 1641# IPv6 check
7a91333f 1642
497237c7 1643enabled network && enabled ipv6 && check_ld <<EOF && enable ipv6 || disable ipv6
7a91333f
HZ
1644#include <sys/types.h>
1645#include <sys/socket.h>
1646#include <netinet/in.h>
1647#include <netdb.h>
db817cf3 1648int main(void) {
7a91333f
HZ
1649 struct sockaddr_storage saddr;
1650 struct ipv6_mreq mreq6;
1651 getaddrinfo(0,0,0,0);
1652 getnameinfo(0,0,0,0,0,0,0);
12fe88b4 1653 IN6_IS_ADDR_MULTICAST((const struct in6_addr *)0);
7a91333f
HZ
1654}
1655EOF
1656
06e31011
RP
1657check_header linux/videodev.h
1658check_header linux/videodev2.h
47f38850 1659
f8aa696f 1660# check for ioctl_meteor.h, ioctl_bt848.h and alternatives
1c915f83
RP
1661{ check_header dev/bktr/ioctl_meteor.h &&
1662 check_header dev/bktr/ioctl_bt848.h; } ||
1663{ check_header machine/ioctl_meteor.h &&
1664 check_header machine/ioctl_bt848.h; } ||
1665{ check_header dev/video/meteor/ioctl_meteor.h &&
1666 check_header dev/video/bktr/ioctl_bt848.h; } ||
1667check_header dev/ic/bt8xx.h
f8aa696f 1668
c7682de0
RP
1669check_header sys/soundcard.h
1670check_header soundcard.h
deb29777 1671
f58f4ce1 1672# Deal with the x11 frame grabber
56a059ac 1673enabled x11grab &&
f58f4ce1
GP
1674check_header X11/Xlib.h &&
1675check_header X11/extensions/XShm.h &&
1676check_func XOpenDisplay -lX11 &&
06eab4ba 1677check_func XShmCreateImage -lX11 -lXext
f58f4ce1 1678
57bd82d4
MR
1679enabled debug && add_cflags -g
1680
1681# add some useful compiler flags if supported
1682check_cflags -Wdeclaration-after-statement
dcd479c0
MR
1683check_cflags -Wall
1684check_cflags -Wno-switch
c07bd6a9
MN
1685check_cflags -Wdisabled-optimization
1686check_cflags -Wpointer-arith
1687check_cflags -Wredundant-decls
cc1fb623 1688check_cflags -Wno-pointer-sign
5af4e0cc 1689enabled extra_warnings && check_cflags -Winline
cf9d24ad 1690
57bd82d4 1691# add some linker flags
5c0e9479 1692check_ldflags -Wl,--warn-common
e240ee67 1693check_ldflags $LDLATEFLAGS
94a3401e 1694
bd2216e4
MR
1695if enabled small; then
1696 check_cflags -Os # not all compilers support -Os
8400d6b8
DB
1697 optimizations="small"
1698elif enabled optimizations; then
b2924696 1699 if test -n "`$cc -v 2>&1 | grep xlc`"; then
30a3e5d4
NP
1700 add_cflags "-O5"
1701 add_ldflags "-O5"
cf9d24ad 1702 else
30a3e5d4 1703 add_cflags "-O3"
cf9d24ad 1704 fi
cddf3f45
GM
1705fi
1706
80581e98 1707# PIC flags for shared library objects where they are needed
5af4e0cc 1708if enabled shared; then
f25fc9b1
MR
1709 # LIBOBJFLAGS may have already been set in the OS configuration
1710 if test -z "$LIBOBJFLAGS" ; then
cc6a90dd 1711 case "$arch" in
35d6cebd 1712 x86_64|ia64|alpha|sparc*|power*) LIBOBJFLAGS='$(PIC)' ;;
813457e5 1713 esac
80581e98 1714 fi
80581e98
MN
1715fi
1716
90be59ef 1717if enabled gprof; then
30a3e5d4
NP
1718 add_cflags "-p"
1719 add_ldflags "-p"
1db54e20
DB
1720fi
1721
3b26ee47 1722VHOOKCFLAGS="-fPIC"
18451f7d 1723
7f3c02fc 1724# Find out if the .align argument is a power of two or not.
4454dc1b 1725if test $asmalign_pot = "unknown"; then
497237c7
RP
1726 disable asmalign_pot
1727 echo 'asm (".align 3");' | check_cc && enable asmalign_pot
4454dc1b
JD
1728fi
1729
660db1d6
DB
1730enabled_any $ENCODER_LIST && enable encoders
1731enabled_any $DECODER_LIST && enable decoders
1732enabled_any $MUXER_LIST && enable muxers
1733enabled_any $DEMUXER_LIST && enable demuxers
c721d803
LA
1734enabled_any $OUTDEV_LIST && enable muxers
1735enabled_any $INDEV_LIST && enable demuxers
c08fb000 1736enabled_any $PROTOCOL_LIST && enable protocols
cd61e407 1737enabled_any $BSF_LIST && enable bsfs
f70f03f6 1738
660db1d6 1739enabled_any $THREADS_LIST && enable threads
f70f03f6
MR
1740
1741check_deps $CONFIG_LIST $HAVE_LIST $DECODER_LIST $ENCODER_LIST $PARSER_LIST \
c721d803
LA
1742 $BSF_LIST $DEMUXER_LIST $MUXER_LIST $PROTOCOL_LIST \
1743 $INDEV_LIST $OUTDEV_LIST
f70f03f6 1744
f7b8bffe 1745enabled libdc1394 && append pkg_requires "libraw1394"
fb2ce7d9 1746enabled libtheora && append pkg_requires "theora"
f9def9cc 1747enabled libvorbis && append pkg_requires "vorbisenc"
fb2ce7d9 1748
f36958f8
DB
1749echo "install prefix $PREFIX"
1750echo "source path $source_path"
1751echo "C compiler $cc"
1752echo "make $make"
bfd5afd8 1753echo ".align is power-of-two $asmalign_pot"
f36958f8 1754echo "ARCH $arch ($cpu)"
eb94aca9 1755if test "$BUILDSUF" != ""; then
f36958f8 1756 echo "build suffix $BUILDSUF"
eb94aca9 1757fi
0db2ce77 1758echo "big-endian ${bigendian-no}"
419b8784 1759if test $arch = "x86_32" -o $arch = "x86_64"; then
0db2ce77
MR
1760 echo "MMX enabled ${mmx-no}"
1761 echo "CMOV enabled ${cmov-no}"
1762 echo "CMOV is fast ${fast_cmov-no}"
971cc990
MN
1763 echo "EBX available ${ebx_available-no}"
1764 echo "EBP available ${ebp_available-no}"
e41e8342 1765fi
cc6a90dd 1766if test $arch = "armv4l"; then
0db2ce77
MR
1767 echo "ARMv5TE enabled ${armv5te-no}"
1768 echo "ARMv6 enabled ${armv6-no}"
1769 echo "IWMMXT enabled ${iwmmxt-no}"
eba9ae3c 1770fi
e241ba14 1771if test $arch = "mips"; then
0db2ce77 1772 echo "MMI enabled ${mmi-no}"
e41e8342 1773fi
cc6a90dd 1774if test $arch = "powerpc"; then
0db2ce77
MR
1775 echo "AltiVec enabled ${altivec-no}"
1776 echo "dcbzl available ${dcbzl-no}"
e41e8342 1777fi
0db2ce77
MR
1778echo "gprof enabled ${gprof-no}"
1779echo "debug symbols ${debug-no}"
1780echo "strip symbols ${dostrip-no}"
8400d6b8 1781echo "optimizations ${optimizations-no}"
0db2ce77
MR
1782echo "static ${static-no}"
1783echo "shared ${shared-no}"
1784echo "postprocessing support ${pp-no}"
1785echo "software scaler enabled ${swscaler-no}"
1786echo "video hooking ${vhook-no}"
90be59ef 1787if enabled vhook; then
0db2ce77
MR
1788 echo "Imlib2 support ${imlib2-no}"
1789 echo "FreeType support ${freetype2-no}"
68892110 1790fi
0db2ce77 1791echo "network support ${network-no}"
90be59ef 1792if enabled network; then
0db2ce77 1793 echo "IPv6 support ${ipv6-no}"
bfd5afd8 1794fi
0db2ce77
MR
1795echo "threading support ${thread_type-no}"
1796echo "SDL support ${sdl-no}"
90be59ef 1797if enabled sdl_too_old; then
bfd5afd8
DB
1798 echo "-> Your SDL version is too old - please upgrade to have FFplay/SDL support."
1799fi
0db2ce77
MR
1800echo "Sun medialib support ${mlib-no}"
1801echo "AVISynth enabled ${avisynth-no}"
1802echo "liba52 support ${liba52-no}"
1803echo "liba52 dlopened ${liba52bin-no}"
1804echo "libamr-nb support ${libamr_nb-no}"
1805echo "libamr-wb support ${libamr_wb-no}"
f7b8bffe 1806echo "libdc1394 support ${libdc1394-no}"
0db2ce77
MR
1807echo "libfaac enabled ${libfaac-no}"
1808echo "libfaad enabled ${libfaad-no}"
7e0871a7 1809echo "libfaad dlopened ${libfaadbin-no}"
0db2ce77
MR
1810echo "libgsm enabled ${libgsm-no}"
1811echo "libmp3lame enabled ${libmp3lame-no}"
1812echo "libnut enabled ${libnut-no}"
0db2ce77
MR
1813echo "libtheora enabled ${libtheora-no}"
1814echo "libvorbis enabled ${libvorbis-no}"
1815echo "x264 enabled ${libx264-no}"
1816echo "XviD enabled ${libxvid-no}"
1817echo "zlib enabled ${zlib-no}"
3ae3b721
RP
1818enabled gpl &&
1819 echo "License: GPL" ||
f25fc9b1 1820 echo "License: LGPL"
de6d9b64 1821
8138b9db
RP
1822for type in decoder encoder parser demuxer muxer protocol bsf; do
1823 echo "Enabled ${type}s:"
1824 ucname="\$`toupper $type`_LIST"
1825 list="`eval echo $ucname`"
1826 partlist=""
1827 for part in $list; do
1828 enabled $part && partlist="$partlist $part"
1829 done
1830 partlist=`echo $partlist | sed s/_$type//g | tr ' ' '\n' | sort`
1831 echo $partlist
1832done
1833
29799f8b 1834echo "Creating config.mak and config.h..."
de6d9b64 1835
29799f8b
DB
1836echo "# Automatically generated by configure - do not modify!" > config.mak
1837echo "/* Automatically generated by configure - do not modify! */" > $TMPH
9c05103f
DB
1838echo "#ifndef FFMPEG_CONFIG_H" >> $TMPH
1839echo "#define FFMPEG_CONFIG_H" >> $TMPH
0fd12426 1840echo "#define FFMPEG_CONFIGURATION \"$FFMPEG_CONFIGURATION\"" >> $TMPH
de6d9b64 1841
2266e085 1842echo "PREFIX=$PREFIX" >> config.mak
c75560ae 1843echo "prefix=\$(DESTDIR)\$(PREFIX)" >> config.mak
22a324da
DB
1844echo "LIBDIR=\$(DESTDIR)$libdir" >> config.mak
1845echo "SHLIBDIR=\$(DESTDIR)$shlibdir" >> config.mak
1846echo "INCDIR=\$(DESTDIR)$incdir" >> config.mak
1847echo "BINDIR=\$(DESTDIR)$bindir" >> config.mak
1848echo "MANDIR=\$(DESTDIR)$mandir" >> config.mak
4a908fbc 1849echo "MAKE=$make" >> config.mak
980fc7b8
FB
1850echo "CC=$cc" >> config.mak
1851echo "AR=$ar" >> config.mak
be7109c1 1852echo "RANLIB=$ranlib" >> config.mak
78eb6531 1853echo "LDCONFIG=$LDCONFIG" >> config.mak
20369773 1854echo "LN_S=$ln_s" >> config.mak
3ae3b721
RP
1855enabled dostrip &&
1856 echo "STRIP=$strip" >> config.mak ||
f25fc9b1 1857 echo "STRIP=echo ignoring strip" >> config.mak
75388c74 1858
a9b3f630 1859echo "OPTFLAGS=$CFLAGS" >> config.mak
408382a4 1860echo "VHOOKCFLAGS=$VHOOKCFLAGS">>config.mak
0f3cb305 1861echo "LDFLAGS=$LDFLAGS" >> config.mak
c536cb09 1862echo "FFSERVERLDFLAGS=$FFSERVERLDFLAGS" >> config.mak
e1707f52 1863echo "SHFLAGS=$SHFLAGS" >> config.mak
408382a4 1864echo "VHOOKSHFLAGS=$VHOOKSHFLAGS" >> config.mak
fbb9d104 1865echo "VHOOKLIBS=$VHOOKLIBS" >> config.mak
80581e98 1866echo "LIBOBJFLAGS=$LIBOBJFLAGS" >> config.mak
5af4e0cc 1867echo "BUILD_STATIC=$static" >> config.mak
eb94aca9 1868echo "BUILDSUF=$BUILDSUF" >> config.mak
c5f14466 1869echo "FULLNAME=$FULLNAME" >> config.mak
f3ec2d46 1870echo "LIBPREF=$LIBPREF" >> config.mak
c5f14466 1871echo "LIBSUF=$LIBSUF" >> config.mak
24743a76 1872echo "LIBNAME=$LIBNAME" >> config.mak
f3ec2d46 1873echo "SLIBPREF=$SLIBPREF" >> config.mak
c5f14466
RP
1874echo "SLIBSUF=$SLIBSUF" >> config.mak
1875echo "EXESUF=$EXESUF" >> config.mak
4dc62701 1876
90be59ef 1877if enabled bigendian; then
0f3cb305
FB
1878 echo "WORDS_BIGENDIAN=yes" >> config.mak
1879 echo "#define WORDS_BIGENDIAN 1" >> $TMPH
91d1f1a4 1880fi
90be59ef 1881if enabled mmx; then
e82c5a8c 1882 echo "#define __CPU__ 586" >> $TMPH
de6d9b64 1883fi
44161118 1884
90be59ef 1885if enabled sdl; then
6a1a892f
FD
1886 echo "SDL_LIBS=`"${SDL_CONFIG}" --libs`" >> config.mak
1887 echo "SDL_CFLAGS=`"${SDL_CONFIG}" --cflags`" >> config.mak
a86b921c 1888fi
90be59ef 1889if enabled texi2html; then
146ea952
NB
1890 echo "BUILD_DOC=yes" >> config.mak
1891fi
5a872801 1892
790c9ca7 1893sws_version=`grep '#define LIBSWSCALE_VERSION ' "$source_path/libswscale/swscale.h" | sed 's/[^0-9\.]//g'`
6d9a2421 1894pp_version=`grep '#define LIBPOSTPROC_VERSION ' "$source_path/libpostproc/postprocess.h" | sed 's/[^0-9\.]//g'`
5a872801 1895lavc_version=`grep '#define LIBAVCODEC_VERSION ' "$source_path/libavcodec/avcodec.h" | sed 's/[^0-9\.]//g'`
c721d803 1896lavd_version=`grep '#define LIBAVDEVICE_VERSION ' "$source_path/libavdevice/avdevice.h" | sed 's/[^0-9\.]//g'`
5a872801
LB
1897lavf_version=`grep '#define LIBAVFORMAT_VERSION ' "$source_path/libavformat/avformat.h" | sed 's/[^0-9\.]//g'`
1898lavu_version=`grep '#define LIBAVUTIL_VERSION ' "$source_path/libavutil/avutil.h" | sed 's/[^0-9\.]//g'`
1899
1900
1901
5af4e0cc 1902if enabled shared; then
0319c531 1903 echo "BUILD_SHARED=yes" >> config.mak
97006039 1904 echo "PIC=-fPIC -DPIC" >> config.mak
7e303556
DB
1905 echo "SPPMAJOR=${pp_version%%.*}" >> config.mak
1906 echo "SPPVERSION=$pp_version" >> config.mak
39503a27 1907 echo "LAVCMAJOR=${lavc_version%%.*}" >> config.mak
5a872801 1908 echo "LAVCVERSION=$lavc_version" >> config.mak
c721d803
LA
1909 echo "LAVDMAJOR=${lavd_version%%.*}" >> config.mak
1910 echo "LAVDVERSION=$lavd_version" >> config.mak
39503a27 1911 echo "LAVFMAJOR=${lavf_version%%.*}" >> config.mak
5a872801 1912 echo "LAVFVERSION=$lavf_version" >> config.mak
39503a27 1913 echo "LAVUMAJOR=${lavu_version%%.*}" >> config.mak
5a872801 1914 echo "LAVUVERSION=$lavu_version" >> config.mak
790c9ca7
LA
1915 echo "SWSMAJOR=${sws_version%%.*}" >> config.mak
1916 echo "SWSVERSION=$sws_version" >> config.mak
4bdd05e7 1917 echo "SLIBNAME=${SLIBNAME}" >> config.mak
f3b60109
DB
1918 echo "SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}" >> config.mak
1919 echo "SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}" >> config.mak
5cb854e1 1920 echo "SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}" >> config.mak
8fbec4f4 1921 echo "SLIB_INSTALL_EXTRA_CMD=${SLIB_INSTALL_EXTRA_CMD}" >> config.mak
5b5d0491 1922 echo "SLIB_UNINSTALL_EXTRA_CMD=${SLIB_UNINSTALL_EXTRA_CMD}" >> config.mak
0319c531 1923fi
d7e27559 1924echo "LIB_INSTALL_EXTRA_CMD=${LIB_INSTALL_EXTRA_CMD}" >> config.mak
ef0bc4c9 1925echo "EXTRALIBS=$extralibs" >> config.mak
d2845d68 1926
3d907e22
MR
1927print_config ARCH_ $TMPH config.mak $ARCH_LIST
1928print_config HAVE_ $TMPH config.mak $HAVE_LIST
1929print_config CONFIG_ $TMPH config.mak $CONFIG_LIST \
1930 $DECODER_LIST \
1931 $ENCODER_LIST \
1932 $PARSER_LIST \
1933 $BSF_LIST \
1934 $DEMUXER_LIST \
1935 $MUXER_LIST \
1936 $PROTOCOL_LIST \
c721d803
LA
1937 $INDEV_LIST \
1938 $OUTDEV_LIST \
8ac17293 1939
c13e1abd
FH
1940echo "#define restrict $_restrict" >> $TMPH
1941
bd2216e4 1942if enabled small; then
3bf98161 1943 echo "#define av_always_inline" >> $TMPH
bb801c97
MN
1944fi
1945
997baf01
MR
1946echo "SRC_PATH=\"$source_path\"" >> config.mak
1947echo "SRC_PATH_BARE=$source_path" >> config.mak
1948echo "BUILD_ROOT=\"$PWD\"" >> config.mak
0f3cb305 1949
8156056e 1950# Apparently it's not possible to portably echo a backslash.
3ae3b721
RP
1951enabled asmalign_pot &&
1952 printf '#define ASMALIGN(ZEROBITS) ".align " #ZEROBITS "\\n\\t"\n' >> $TMPH ||
8156056e 1953 printf '#define ASMALIGN(ZEROBITS) ".align 1<<" #ZEROBITS "\\n\\t"\n' >> $TMPH
4454dc1b 1954
bc634f6f 1955
9c05103f
DB
1956echo "#endif /* FFMPEG_CONFIG_H */" >> $TMPH
1957
9cb2cf10 1958# Do not overwrite config.h if unchanged to avoid superfluous rebuilds.
3ae3b721
RP
1959cmp -s $TMPH config.h &&
1960 echo "config.h is unchanged" ||
1961 mv -f $TMPH config.h
3d204385 1962
f3ec2d46 1963rm -f $TMPO $TMPC $TMPE $TMPS $TMPH
def4272a 1964
165af439 1965# build tree in object directory if source path is different from current one
90be59ef 1966if enabled source_path_used; then
165af439
MR
1967 DIRS="\
1968 doc \
165af439
MR
1969 libavcodec \
1970 libavcodec/alpha \
1971 libavcodec/armv4l \
1972 libavcodec/bfin \
1973 libavcodec/i386 \
165af439
MR
1974 libavcodec/mlib \
1975 libavcodec/ppc \
7506d47a 1976 libavcodec/sh4 \
862a70f1
AJ
1977 libavcodec/sparc \
1978 libavformat \
165af439 1979 libavutil \
862a70f1 1980 libpostproc \
165af439
MR
1981 libswscale \
1982 tests \
c07ed8c8 1983 tools \
165af439
MR
1984 vhook \
1985 "
1986 FILES="\
1987 Makefile \
1988 common.mak \
862a70f1 1989 doc/texi2pod.pl \
165af439 1990 libavcodec/Makefile \
862a70f1 1991 libavformat/Makefile \
165af439 1992 libavutil/Makefile \
862a70f1 1993 libpostproc/Makefile \
165af439 1994 libswscale/Makefile \
165af439
MR
1995 "
1996 for dir in $DIRS ; do
1997 mkdir -p $dir
1998 done
1999 for f in $FILES ; do
20369773 2000 $ln_s "$source_path/$f" $f
165af439
MR
2001 done
2002fi
def4272a 2003
def4272a 2004
d0674868 2005# build pkg-config files
77aee36c 2006# FIXME: libdir and includedir are hardcoded and may differ from the real path.
def4272a 2007
d0674868
DB
2008pkgconfig_generate(){
2009name=$1
2010comment=$2
2011version=$3
2012libs=$4
2013requires=$5
2014include=$6
2015cat <<EOF >$name.pc
2266e085 2016prefix=$PREFIX
a94e666c 2017exec_prefix=\${prefix}
def4272a 2018libdir=\${exec_prefix}/lib
a94e666c 2019includedir=\${prefix}/include
def4272a 2020
d0674868
DB
2021Name: $name
2022Description: $comment
2023Version: $version
2024Requires: $requires
def4272a 2025Conflicts:
d0674868
DB
2026Libs: -L\${libdir} $libs
2027Cflags: -I\${includedir} -I\${includedir}/$include
def4272a 2028EOF
d0674868 2029}
def4272a 2030
d0674868
DB
2031pkgconfig_generate_uninstalled(){
2032name=$1
9c476fd6 2033shortname=${name#lib}
d0674868
DB
2034comment=$2
2035version=$3
2036libs=$4
2037requires=$5
2038cat <<EOF >$name-uninstalled.pc
def4272a
AJ
2039prefix=
2040exec_prefix=
d0674868
DB
2041libdir=\${pcfiledir}/$name
2042includedir=\${pcfiledir}/$name
def4272a 2043
d0674868
DB
2044Name: $name
2045Description: $comment
2046Version: $version
2047Requires: $requires
def4272a 2048Conflicts:
d0674868 2049Libs: \${libdir}/${LIBPREF}${shortname}${LIBSUF} $libs
def4272a
AJ
2050Cflags: -I\${includedir}
2051EOF
d0674868 2052}
def4272a 2053
9d824ad1 2054pkgconfig_generate libavutil "FFmpeg utility library" "$lavu_version" -lavutil "" ffmpeg
d0674868 2055pkgconfig_generate_uninstalled libavutil "FFmpeg utility library" "$lavu_version"
def4272a 2056
d0674868
DB
2057pkgconfig_generate libavcodec "FFmpeg codec library" "$lavc_version" "-lavcodec $extralibs" "$pkg_requires libavutil = $lavu_version" ffmpeg
2058pkgconfig_generate_uninstalled libavcodec "FFmpeg codec library" "$lavc_version" "$extralibs" "$pkg_requires libavutil = $lavu_version"
def4272a 2059
d0674868
DB
2060pkgconfig_generate libavformat "FFmpeg container format library" "$lavf_version" "-lavformat $extralibs" "$pkg_requires libavcodec = $lavc_version" ffmpeg
2061pkgconfig_generate_uninstalled libavformat "FFmpeg container format library" "$lavf_version" "$extralibs" "$pkg_requires libavcodec = $lavc_version"
def4272a 2062
c721d803
LA
2063pkgconfig_generate libavdevice "FFmpeg device handling library" "$lavd_version" "-lavdevice $extralibs" "$pkg_requires libavformat = $lavf_version" ffmpeg
2064pkgconfig_generate_uninstalled libavdevice "FFmpeg device handling library" "$lavd_version" "$extralibs" "$pkg_requires libavformat = $lavf_version"
90be59ef 2065if enabled pp; then
2e3bcd38
DB
2066 pkgconfig_generate libpostproc "FFmpeg post processing library" "$pp_version" -lpostproc "" postproc
2067 pkgconfig_generate_uninstalled libpostproc "FFmpeg post processing library" "$pp_version"
2068fi
790c9ca7 2069
c839db53 2070if enabled swscaler; then
3d3361e5 2071 pkgconfig_generate libswscale "FFmpeg image rescaling library" "$sws_version" -lswscale "libavutil = $lavu_version" ffmpeg
20c516c6 2072 pkgconfig_generate_uninstalled libswscale "FFmpeg image rescaling library" "$sws_version" "" "libavutil = $lavu_version"
6c0d0413 2073else
3d3361e5 2074 pkgconfig_generate libswscale "FFmpeg image rescaling library" "$sws_version" "" "$pkg_requires libavcodec = $lavc_version" ffmpeg
d0674868 2075 pkgconfig_generate_uninstalled libswscale "FFmpeg image rescaling library" "$sws_version" "" "$pkg_requires libavcodec = $lavc_version"
c505dd31
MR
2076 apply libswscale.pc sed s/^Libs:.*$/Libs:/
2077 apply libswscale-uninstalled.pc sed s/^Libs:.*$/Libs:/
6c0d0413 2078fi