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