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