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