cosmetics: typo
[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 837asmalign_pot="unknown"
20369773 838ln_s="ln -sf"
8a608357
MR
839
840# machine
cc6a90dd 841arch=`uname -m`
38d0a8aa 842cpu="generic"
8a608357 843
8a608357 844# OS
b9663405 845targetos=$(tolower $(uname -s))
8a608357
MR
846
847# non-library system interfaces
3eac5c63 848bktr="yes"
8a608357
MR
849
850# libraries
8a608357
MR
851zlib="yes"
852
853# configurable options
cddf3f45 854debug="yes"
65d1bea2 855dostrip="yes"
8a608357
MR
856ffmpeg="yes"
857ffplay="yes"
858ffserver="yes"
8a608357 859ipv6="yes"
5af4e0cc 860static="yes"
1eb2212e 861mpegaudio_hp="yes"
8a608357
MR
862network="yes"
863optimize="yes"
8a608357 864protocols="yes"
8a608357
MR
865vhook="default"
866
8a608357 867# build settings
baa3a937 868SHFLAGS='-shared -Wl,-soname,$@'
cab3ef82 869VHOOKSHFLAGS='$(SHFLAGS)'
e240ee67 870LDLATEFLAGS='-Wl,-rpath-link,\$(BUILD_ROOT)/libavcodec -Wl,-rpath-link,\$(BUILD_ROOT)/libavformat -Wl,-rpath-link,\$(BUILD_ROOT)/libavutil'
c536cb09 871FFSERVERLDFLAGS=-Wl,-E
f39e56a8 872LDCONFIG="ldconfig"
f3ec2d46
SG
873LIBPREF="lib"
874LIBSUF=".a"
4bdd05e7 875LIB='$(LIBPREF)$(NAME)$(LIBSUF)'
f3ec2d46
SG
876SLIBPREF="lib"
877SLIBSUF=".so"
4bdd05e7 878SLIBNAME='$(SLIBPREF)$(NAME)$(SLIBSUF)'
b29bddab
DB
879SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
880SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
21d0a823 881LIB_INSTALL_EXTRA_CMD='$(RANLIB) "$(LIBDIR)/$(LIB)"'
ef0bc4c9 882
c597172e
MR
883# find source path
884source_path="`dirname \"$0\"`"
885source_path_used="yes"
886if test -z "$source_path" -o "$source_path" = "." ; then
887 source_path="`pwd`"
888 source_path_used="no"
889else
890 source_path="`cd \"$source_path\"; pwd`"
891 echo "$source_path" | grep -q '[[:blank:]]' &&
892 die "Out of tree builds are impossible with whitespace in source path."
893fi
894
895if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
896 show_help
897fi
898
899FFMPEG_CONFIGURATION="$@"
900
facbea95
AJ
901ENCODER_LIST=`sed -n 's/^[^#]*ENC.*(.*, *\(.*\)).*/\1_encoder/p' "$source_path/libavcodec/allcodecs.c"`
902DECODER_LIST=`sed -n 's/^[^#]*DEC.*(.*, *\(.*\)).*/\1_decoder/p' "$source_path/libavcodec/allcodecs.c"`
903PARSER_LIST=`sed -n 's/^[^#]*PARSER.*(.*, *\(.*\)).*/\1_parser/p' "$source_path/libavcodec/allcodecs.c"`
904BSF_LIST=`sed -n 's/^[^#]*BSF.*(.*, *\(.*\)).*/\1_bsf/p' "$source_path/libavcodec/allcodecs.c"`
905MUXER_LIST=`sed -n 's/^[^#]*_MUX.*(.*, *\(.*\)).*/\1_muxer/p' "$source_path/libavformat/allformats.c"`
906DEMUXER_LIST=`sed -n 's/^[^#]*DEMUX.*(.*, *\(.*\)).*/\1_demuxer/p' "$source_path/libavformat/allformats.c"`
907PROTOCOL_LIST=`sed -n 's/^[^#]*PROTOCOL.*(.*, *\(.*\)).*/\1_protocol/p' "$source_path/libavformat/allformats.c"`
c597172e 908
cd61e407 909enable $ENCODER_LIST $DECODER_LIST $PARSER_LIST $MUXER_LIST $DEMUXER_LIST $PROTOCOL_LIST $BSF_LIST
d3ea5692 910enable $ARCH_EXT_LIST
c597172e
MR
911
912die_unknown(){
913 echo "Unknown option \"$1\"."
914 echo "See $0 --help for available options."
915 exit 1
916}
917
794f8e97
PI
918show_list() {
919 for part in $*; do
920 echo $part | sed 's/_[^_]*$//'
921 done | sort
922 exit 0
923}
924
c597172e
MR
925for opt do
926 optval="${opt#*=}"
927 case "$opt" in
928 --log)
929 ;;
930 --log=*) logging="$optval"
931 ;;
932 --prefix=*) PREFIX="$optval"
933 ;;
934 --libdir=*) libdir="$optval"
935 ;;
936 --shlibdir=*) shlibdir="$optval"
937 ;;
938 --incdir=*) incdir="$optval"
939 ;;
940 --mandir=*) mandir="$optval"
941 ;;
942 --source-path=*) source_path="$optval"
943 ;;
944 --cross-prefix=*) cross_prefix="$optval"
945 ;;
946 --cross-compile) cross_compile="yes"
947 ;;
948 --target-os=*) targetos="$optval"
949 ;;
950 --cc=*) cc="$optval"
951 ;;
952 --make=*) make="$optval"
953 ;;
954 --extra-cflags=*) add_cflags "$optval"
955 ;;
956 --extra-ldflags=*) add_ldflags "$optval"
957 ;;
958 --extra-libs=*) add_extralibs "$optval"
959 ;;
960 --build-suffix=*) BUILDSUF="$optval"
961 ;;
962 --arch=*) arch="$optval"
963 ;;
964 --cpu=*) cpu="$optval"
965 ;;
c597172e
MR
966 --disable-opts) optimize="no"
967 ;;
c597172e
MR
968 --enable-sunmlib) mlib="yes"
969 ;;
970 --disable-strip) dostrip="no"
971 ;;
972 --disable-encoders) disable $ENCODER_LIST
973 ;;
974 --disable-decoders) disable $DECODER_LIST
975 ;;
976 --disable-muxers) disable $MUXER_LIST
977 ;;
978 --disable-demuxers) disable $DEMUXER_LIST
979 ;;
980 --disable-parsers) disable $PARSER_LIST
981 ;;
cd61e407
JM
982 --disable-bsfs) disable $BSF_LIST
983 ;;
c08fb000
AB
984 --disable-protocols) disable $PROTOCOL_LIST
985 ;;
c597172e
MR
986 --enable-*=*|--disable-*=*)
987 eval `echo "$opt" | sed 's/=/-/;s/--/action=/;s/-/ thing=/;s/-/ name=/'`
988 case "$thing" in
cd61e407 989 encoder|decoder|muxer|demuxer|parser|bsf|protocol) $action ${optval}_${thing} ;;
c597172e
MR
990 *) die_unknown "$opt" ;;
991 esac
992 ;;
993 --enable-?*|--disable-?*)
994 eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'`
995 echo "$CMDLINE_SELECT" | grep -q "^ *$option\$" || die_unknown $opt
996 $action $option
997 ;;
794f8e97
PI
998 --list-*)
999 NAME="${opt#--list-}"
4a0d6686 1000 is_in $NAME $COMPONENT_LIST || die_unknown $opt
794f8e97
PI
1001 NAME=$(toupper ${NAME%s})
1002 eval show_list \$${NAME}_LIST
1003 ;;
c597172e
MR
1004 --help) show_help
1005 ;;
1006 *)
1007 die_unknown $opt
1008 ;;
1009 esac
1010done
1011
270739bb
MR
1012case "$arch" in
1013 i386|i486|i586|i686|i86pc|BePC)
1014 arch="x86_32"
7b829d2a 1015 enable fast_unaligned
270739bb
MR
1016 ;;
1017 x86_64|amd64)
1018 arch="x86_32"
7b829d2a 1019 enable fast_unaligned
270739bb
MR
1020 canon_arch="`$cc -dumpmachine | sed -e 's,\([^-]*\)-.*,\1,'`"
1021 if [ x"$canon_arch" = x"x86_64" -o x"$canon_arch" = x"amd64" ]; then
1022 if [ -z "`echo $CFLAGS | grep -- -m32`" ]; then
1023 arch="x86_64"
c2a29455 1024 enable fast_64bit
270739bb
MR
1025 fi
1026 fi
1027 ;;
1028 # armv4l is a subset of armv[567]*l
1029 arm|armv[4567]*l)
1030 arch="armv4l"
1031 ;;
1032 alpha)
1033 arch="alpha"
c2a29455 1034 enable fast_64bit
270739bb 1035 ;;
c2a29455 1036 "Power Macintosh"|ppc|powerpc)
270739bb
MR
1037 arch="powerpc"
1038 ;;
c2a29455
AJ
1039 ppc64)
1040 arch="powerpc"
1041 enable fast_64bit
1042 ;;
e241ba14 1043 mips|mipsel|IP*)
270739bb
MR
1044 arch="mips"
1045 ;;
1046 sun4u|sparc64)
1047 arch="sparc64"
c2a29455 1048 enable fast_64bit
270739bb
MR
1049 ;;
1050 sparc)
1051 arch="sparc"
1052 ;;
1053 sh4)
1054 arch="sh4"
1055 ;;
c2a29455
AJ
1056 parisc)
1057 arch="parisc"
1058 ;;
1059 parisc64)
270739bb 1060 arch="parisc"
c2a29455 1061 enable fast_64bit
270739bb
MR
1062 ;;
1063 s390|s390x)
1064 arch="s390"
1065 ;;
1066 m68k)
1067 arch="m68k"
1068 ;;
1069 ia64)
1070 arch="ia64"
c2a29455 1071 enable fast_64bit
270739bb
MR
1072 ;;
1073 bfin)
1074 arch="bfin"
1075 ;;
1076 *)
1077 arch="unknown"
1078 ;;
1079esac
1080
9eeed841
MR
1081enable $arch
1082enabled_any x86_32 x86_64 && enable x86
1083enabled sparc64 && enable sparc
1084
ef0bc4c9 1085# OS specific
c597172e 1086osextralibs="-lm"
ced75d92 1087case $targetos in
4a5444db 1088 beos|haiku|zeta)
74cec57d 1089 PREFIX="$HOME/config"
d474299a
MR
1090 # helps building libavcodec
1091 add_cflags "-DPIC -fomit-frame-pointer"
1092 # 3 gcc releases known for BeOS, each with ugly bugs
1093 gcc_version="`$cc -v 2>&1 | grep version | cut -d ' ' -f3-`"
1094 case "$gcc_version" in
1095 2.9-beos-991026*|2.9-beos-000224*) echo "R5/GG gcc"
1096 mmx="no"
1097 ;;
1098 *20010315*) echo "BeBits gcc"
1099 add_cflags "-fno-expensive-optimizations"
1100 ;;
1101 esac
74cec57d 1102 LDCONFIG="echo ignoring ldconfig"
d474299a 1103 SHFLAGS=-nostart
d474299a 1104 # enable BeOS things
a4db8c89 1105 audio_beos="yes"
d474299a
MR
1106 # no need for libm, but the inet stuff
1107 # Check for BONE
74cec57d 1108 # XXX: actually should check for NOT net_server
d474299a 1109 if (echo $BEINCLUDES|grep 'headers/be/bone' >/dev/null); then
c597172e 1110 osextralibs="-lbind -lsocket"
d474299a
MR
1111 else
1112 beos_netserver="yes"
c597172e 1113 osextralibs="-lnet"
d474299a 1114 fi ;;
4a5444db 1115 sunos)
d474299a
MR
1116 FFSERVERLDFLAGS=""
1117 SHFLAGS="-shared -Wl,-h,\$@"
1118 add_extralibs "-lsocket -lnsl"
1119 ;;
4a5444db 1120 netbsd)
d474299a
MR
1121 add_extralibs "-lossaudio"
1122 ;;
4a5444db 1123 openbsd)
d474299a 1124 need_memalign="no"
d474299a 1125 LIBOBJFLAGS="\$(PIC)"
21d0a823 1126 LDCONFIG="ldconfig -m \$(SHLIBDIR)"
d474299a
MR
1127 SHFLAGS='-shared'
1128 SLIBNAME='$(SLIBPREF)$(NAME)$(SLIBSUF).$(LIBVERSION)'
1129 SLIBNAME_WITH_VERSION='$(SLIBNAME)'
1130 SLIBNAME_WITH_MAJOR='$(SLIBNAME)'
1131 add_extralibs "-lossaudio"
1132 ;;
4a5444db 1133 freebsd)
d474299a
MR
1134 need_memalign="no"
1135 add_cflags "-pthread"
1136 ;;
4a5444db 1137 gnu/kfreebsd)
d474299a
MR
1138 add_cflags "-pthread"
1139 ;;
4a5444db 1140 bsd/os)
c597172e 1141 osextralibs="-lpoll -lgnugetopt -lm"
d474299a
MR
1142 strip="strip -d"
1143 ;;
4a5444db 1144 darwin)
d474299a 1145 need_memalign="no"
21d0a823
DB
1146 SHFLAGS="-dynamiclib -Wl,-single_module -Wl,-install_name,\$(SHLIBDIR)/\$(SLIBNAME),-current_version,\$(SPPVERSION),-compatibility_version,\$(SPPVERSION) -Wl,-read_only_relocs,suppress"
1147 VHOOKSHFLAGS='-dynamiclib -Wl,-single_module -flat_namespace -undefined suppress -Wl,-install_name,$(SHLIBDIR)/vhook/$@'
c597172e 1148 osextralibs=""
d474299a
MR
1149 strip="strip -x"
1150 FFLDFLAGS="-Wl,-dynamic,-search_paths_first"
1151 SLIBSUF=".dylib"
1152 SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME).$(LIBVERSION)$(SLIBSUF)'
1153 SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(NAME).$(LIBMAJOR)$(SLIBSUF)'
1154 FFSERVERLDFLAGS=-Wl,-bind_at_load
1155 ;;
4a5444db 1156 mingw32*)
91c5172d 1157 targetos=mingw32
5880d5b5 1158 shlibdir="$bindir"
70b4d492
RP
1159 VHOOKSHFLAGS='-shared -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil'
1160 VHOOKLIBS='-lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)'
1161 if enabled swscaler; then
1162 VHOOKSHFLAGS="$VHOOKSHFLAGS -L\$(BUILD_ROOT)/libswscale"
1163 VHOOKLIBS="$VHOOKLIBS -lswscale\$(BUILDSUF)"
1164 fi
4ec9ec81 1165 ffserver="no"
4ec9ec81
MR
1166 SLIBPREF=""
1167 SLIBSUF=".dll"
1168 EXESUF=".exe"
1169 SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
1170 SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(NAME)-$(LIBMAJOR)$(SLIBSUF)'
1171 SLIB_EXTRA_CMD="-lib /machine:i386 /def:\$(@:${SLIBSUF}=.def)"
21d0a823 1172 SLIB_INSTALL_EXTRA_CMD="-install -m 644 \$(SLIBNAME_WITH_MAJOR:\$(SLIBSUF)=.lib) \"\$(SHLIBDIR)/\$(SLIBNAME_WITH_MAJOR:\$(SLIBSUF)=.lib)\""
d205abe9 1173 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 1174 ;;
4a5444db 1175 cygwin*)
ced75d92 1176 targetos=cygwin
d474299a 1177 shlibdir="$bindir"
41d5a86a
VP
1178 VHOOKSHFLAGS='-shared -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil'
1179 VHOOKLIBS='-lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)'
1180 if enabled swscaler; then
1181 VHOOKSHFLAGS="$VHOOKSHFLAGS -L\$(BUILD_ROOT)/libswscale"
1182 VHOOKLIBS="$VHOOKLIBS -lswscale\$(BUILDSUF)"
1183 fi
c597172e 1184 osextralibs=""
d474299a
MR
1185 EXESUF=".exe"
1186 SLIBPREF="cyg"
1187 SLIBSUF=".dll"
1188 SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
1189 SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(NAME)-$(LIBMAJOR)$(SLIBSUF)'
d205abe9 1190 SHFLAGS='-shared -Wl,--out-implib=lib$(NAME).dll.a -Wl,--enable-auto-image-base'
d474299a 1191 ;;
4a5444db 1192 linux)
d474299a 1193 LDLATEFLAGS="-Wl,--as-needed $LDLATEFLAGS"
b48e359f 1194 dv1394="yes"
d474299a 1195 ;;
4a5444db 1196 irix*)
ced75d92 1197 targetos=irix
d474299a 1198 ranlib="echo ignoring ranlib"
d474299a 1199 ;;
d474299a
MR
1200 *)
1201 targetos="${targetos}-UNKNOWN"
1202 ;;
ef0bc4c9 1203esac
de6d9b64 1204
c597172e 1205add_extralibs $osextralibs
de6d9b64 1206
e3c00e34 1207if ! disabled logging ; then
90be59ef 1208 enabled logging || logfile="$logging"
57bd82d4
MR
1209 echo "# $0 $@" >$logfile
1210 set >>$logfile
2ba042a7
MR
1211else
1212 logfile=/dev/null
57bd82d4 1213fi
e89b8b0a 1214
28d8e661
DB
1215# Combine FFLDFLAGS and the LDFLAGS environment variable.
1216LDFLAGS="$FFLDFLAGS $LDFLAGS"
e89b8b0a 1217
fac252f9 1218test -n "$cross_prefix" && cross_compile=yes
1ea46bed
MR
1219cc="${cross_prefix}${cc}"
1220ar="${cross_prefix}${ar}"
1221ranlib="${cross_prefix}${ranlib}"
1222strip="${cross_prefix}${strip}"
20369773 1223ln_s="${cross_prefix}${ln_s}"
1ea46bed 1224
320d060a 1225# we need to build at least one lib type
93b3c083 1226if ! enabled_any static shared; then
320d060a
DB
1227 cat <<EOF
1228At least one library type must be built.
1229Specify --enable-static to build the static libraries or --enable-shared to
1230build the shared libraries as well. To only build the shared libraries specify
1231--disable-static in addition to --enable-shared.
1232EOF
1233 exit 1;
1234fi
1235
2a320695
RP
1236if disabled static; then
1237 LIB=""
1238fi
1239
93b3c083 1240if ! enabled libogg; then
ddf50e4c
RP
1241 enabled libtheora && die "libogg must be enabled to enable libtheora."
1242 enabled libvorbis && die "libogg must be enabled to enable libvorbis."
5c5dea3f
NB
1243fi
1244
a2234ceb
RP
1245if enabled_any libfaad libfaadbin ; then
1246 if check_header faad.h; then
1247 check_cc << EOF
1248#include <faad.h>
1249#ifndef FAAD2_VERSION
1250ok faad1
1251#endif
1252int main( void ) { return 0; }
1253EOF
1254 test $? = 0 && enable libfaad2
1255 else
ff3dac65 1256 die "FAAD test failed."
a2234ceb
RP
1257 fi
1258fi
1259
1260
93b3c083 1261if ! enabled gpl; then
54118497
RP
1262 die_gpl_disabled(){
1263 name=$1
1264 shift
1265 enabled_any $@ && die "$name is under GPL and --enable-gpl is not specified."
1266 }
1267 die_gpl_disabled "The Postprocessing code" pp
7bc5f2a8 1268 die_gpl_disabled "liba52" liba52
1cc60c47
DB
1269 die_gpl_disabled "libx264" libx264
1270 die_gpl_disabled "libxvidcore" libxvid
54118497
RP
1271 die_gpl_disabled "FAAD2" libfaad2
1272 die_gpl_disabled "The X11 grabber" x11grab
1273 die_gpl_disabled "The software scaler" swscaler
ebb810d9 1274fi
b2e3c528 1275
9eeed841 1276check_deps $ARCH_EXT_LIST
0f3cb305 1277
5d323602
MR
1278test -z "$need_memalign" && need_memalign="$mmx"
1279
cf9d24ad 1280#Darwin CC versions
ced75d92 1281if test $targetos = darwin; then
b2924696 1282 if test -n "`$cc -v 2>&1 | grep xlc`"; then
30a3e5d4 1283 add_cflags "-qpdf2 -qlanglvl=extc99 -qmaxmem=-1 -qarch=auto -qtune=auto"
cf9d24ad 1284 else
26c1b3be
DB
1285 add_cflags "-no-cpp-precomp -pipe"
1286 check_cflags "-force_cpusubtype_ALL"
1287 check_cflags "-Wno-sign-compare"
7799eeec 1288 disabled shared && add_cflags -mdynamic-no-pic
cf9d24ad 1289 fi
2a1a6b64
MN
1290fi
1291
703afd07 1292disabled optimize || add_cflags -fomit-frame-pointer
cf9d24ad 1293
a4adb608 1294# Add processor-specific flags
38d0a8aa 1295if test $cpu != "generic"; then
bc8ec47b
MR
1296 warn_altivec(){
1297 $1 altivec && echo "WARNING: Tuning for $2 but AltiVec $1.";
1658bc4f 1298 }
38d0a8aa 1299 case $cpu in
bb270c08 1300 601|ppc601|PowerPC601)
1c5d830c 1301 add_cflags "-mcpu=601"
bc8ec47b 1302 warn_altivec enabled PPC601
bb270c08
DB
1303 ;;
1304 603*|ppc603*|PowerPC603*)
1c5d830c 1305 add_cflags "-mcpu=603"
bc8ec47b 1306 warn_altivec enabled PPC603
bb270c08
DB
1307 ;;
1308 604*|ppc604*|PowerPC604*)
1c5d830c 1309 add_cflags "-mcpu=604"
bc8ec47b 1310 warn_altivec enabled PPC604
bb270c08
DB
1311 ;;
1312 G3|g3|75*|ppc75*|PowerPC75*)
1c5d830c 1313 add_cflags "-mcpu=750 -mpowerpc-gfxopt"
bc8ec47b 1314 warn_altivec enabled PPC75x
bb270c08
DB
1315 ;;
1316 G4|g4|745*|ppc745*|PowerPC745*)
1c5d830c 1317 add_cflags "-mcpu=7450 -mpowerpc-gfxopt"
bc8ec47b 1318 warn_altivec disabled PPC745x
bb270c08
DB
1319 ;;
1320 74*|ppc74*|PowerPC74*)
1c5d830c 1321 add_cflags "-mcpu=7400 -mpowerpc-gfxopt"
bc8ec47b 1322 warn_altivec disabled PPC74xx
bb270c08
DB
1323 ;;
1324 G5|g5|970|ppc970|PowerPC970|power4*|Power4*)
1c5d830c 1325 add_cflags "-mcpu=970 -mpowerpc-gfxopt -mpowerpc64"
bc8ec47b 1326 warn_altivec disabled PPC970
9cafbd6c 1327 enable ppc64
bb270c08 1328 ;;
e07e357d
LB
1329 Cell|CELL|cell)
1330 add_cflags "-mcpu=cell"
1331 warn_altivec disabled Cell
9cafbd6c 1332 enable ppc64
e07e357d 1333 ;;
e7768fc5
GP
1334 # targets that do NOT support conditional mov (cmov)
1335 i[345]86|pentium|pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
38d0a8aa 1336 add_cflags "-march=$cpu"
e7768fc5
GP
1337 cmov="no"
1338 ;;
1339 # targets that do support conditional mov (cmov)
416519dd 1340 i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64|k8|opteron|athlon-fx|core2)
e7768fc5 1341 add_cflags "-march=$cpu"
4c8d81fa 1342 cmov="yes"
7073e9fc 1343 fast_cmov="yes"
94e4c3a3
GP
1344 ;;
1345 # targets that do support conditional mov but on which it's slow
1346 pentium4|prescott|nocona)
1347 add_cflags "-march=$cpu"
1348 cmov="yes"
7073e9fc 1349 fast_cmov="no"
bb270c08 1350 ;;
d7b34d08 1351 sparc64)
1c5d830c 1352 add_cflags "-mcpu=v9"
d7b34d08 1353 ;;
8684704b
MH
1354 bf*) #bf531 bf532 bf533 bf561 bf5xx all get this config
1355 add_cflags "-mfdpic"
846dffeb 1356 add_ldflags "-mfdpic"
8684704b 1357 ;;
bb270c08 1358 *)
38d0a8aa 1359 echo "WARNING: Unknown CPU \"$cpu\", ignored."
bb270c08 1360 ;;
a4adb608
MN
1361 esac
1362fi
1363
412c1562
MR
1364gnu_make(){
1365 $1 --version 2>&1 | grep -q GNU
1366}
1367
1368if ! gnu_make $make; then
1369 gnu_make gmake && make=gmake || die "GNU make not found."
1370fi
1371
be0d52ab
MR
1372# make sure we can execute files in $TMPDIR
1373cat >$TMPE 2>>$logfile <<EOF
1374#! /bin/sh
1375EOF
1376chmod +x $TMPE >>$logfile 2>&1
1377if ! $TMPE >>$logfile 2>&1; then
1378 cat <<EOF
1379Unable to create and execute files in $TMPDIR1. Set the TMPDIR environment
68300911
DB
1380variable to another directory and make sure that $TMPDIR1 is not mounted
1381noexec.
be0d52ab
MR
1382EOF
1383 die "Sanity test failed."
1384fi
0244f743 1385rm $TMPE
be0d52ab 1386
1a268acc
MR
1387# compiler sanity check
1388check_exec <<EOF
1389int main(){
1390 return 0;
1391}
1392EOF
1393if test "$?" != 0; then
1394 echo "$cc is unable to create an executable file."
93b3c083 1395 if test -z "$cross_prefix" && ! enabled cross_compile ; then
1a268acc 1396 echo "If $cc is a cross-compiler, use the --cross-compile option."
c7ae6345 1397 echo "Only do this if you know what cross compiling means."
1a268acc
MR
1398 fi
1399 die "C compiler test failed."
1400fi
1401
9eeed841 1402if enabled x86; then
44965991
PI
1403 # check whether EBP is available on x86
1404 # As 'i' is stored on the stack, this program will crash
1405 # if the base pointer is used to access it because the
1406 # base pointer is cleared in the inline assembly code.
7dfef245 1407 check_exec_crash <<EOF && enable ebp_available
44965991
PI
1408 volatile int i=0;
1409 asm volatile (
1410 "xorl %%ebp, %%ebp"
1411 ::: "%ebp");
1412 return i;
44965991
PI
1413EOF
1414
1415 # check wether EBX is available on x86
1416 check_cc <<EOF && enable ebx_available
1417int main(){
1418 asm volatile ("":::"%ebx");
1419}
1420EOF
8e380710
LM
1421
1422 # check whether binutils is new enough to compile SSSE3
9eeed841 1423 enabled ssse3 && check_cc <<EOF || disable ssse3
8e380710
LM
1424int main(){
1425 asm volatile ("pabsw %xmm0, %xmm0");
1426}
1427EOF
44965991
PI
1428fi
1429
87ea51e0
LB
1430# check for assembler specific support
1431
cc6a90dd 1432if test $arch = "powerpc"; then
87ea51e0
LB
1433check_cc <<EOF && dcbzl=yes
1434int main(void) {
1435 register long zero = 0;
1436 char data[1024];
1437 asm volatile("dcbzl %0, %1" : : "b" (data), "r" (zero));
1438return 0;
1439}
1440EOF
1441fi
1442
57bd82d4
MR
1443# check for SIMD availability
1444
115329f1 1445# AltiVec flags: The FSF version of GCC differs from the Apple version
9eeed841 1446if enabled altivec; then
0182fee8
MR
1447 if test -n "`$cc -v 2>&1 | grep version | grep Apple`"; then
1448 add_cflags "-faltivec"
1449 else
1450 add_cflags "-maltivec -mabi=altivec"
1451 fi
b6e52719 1452
0182fee8 1453 check_header altivec.h
a9a07762 1454
0182fee8 1455 # check if our compiler supports Motorola AltiVec C API
90be59ef 1456 if enabled altivec_h; then
f25fc9b1
MR
1457 inc_altivec_h="#include <altivec.h>"
1458 else
1459 inc_altivec_h=
1460 fi
1461 check_cc <<EOF || altivec=no
dcd479c0 1462$inc_altivec_h
a9a07762
MN
1463int main(void) {
1464 vector signed int v1, v2, v3;
1465 v1 = vec_add(v2,v3);
1466 return 0;
1467}
1468EOF
1469fi
ab6c65f6 1470
854fdb51 1471# check armv5te instructions support
9eeed841 1472enabled armv5te && check_cc <<EOF || disable armv5te
0182fee8
MR
1473int main(void) {
1474 __asm__ __volatile__ ("qadd r0, r0, r0");
1475}
854fdb51 1476EOF
854fdb51 1477
9eeed841 1478enabled armv6 && check_cc <<EOF || disable armv6
edab3048
MR
1479int main(void) {
1480 __asm__ __volatile__ ("sadd16 r0, r0, r0");
1481}
1482EOF
edab3048 1483
854fdb51 1484# check iwmmxt support
9eeed841 1485enabled iwmmxt && check_cc <<EOF || disable iwmmxt
0182fee8
MR
1486int main(void) {
1487 __asm__ __volatile__ ("wunpckelub wr6, wr4");
1488}
854fdb51 1489EOF
d46aba26 1490
29799f8b 1491# check if our compiler supports mmi
57bd82d4 1492enabled mmi && check_cc <<EOF || mmi="no"
d46aba26
LS
1493int main(void) {
1494 __asm__ ("lq \$2, 0(\$2)");
1495 return 0;
1496}
1497EOF
57bd82d4 1498
57bd82d4
MR
1499# ---
1500# big/little-endian test
9eebe687
MR
1501check_cc <<EOF || die "endian test failed"
1502unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
a3999908 1503EOF
e89d9fd8 1504grep -q BIGE $TMPO && enable bigendian
487a54d7 1505
a3999908 1506# ---
3d204385
NK
1507# check availability of some header files
1508
0701ca7f
MR
1509check_header malloc.h
1510check_func memalign
3d204385 1511
93b3c083 1512if ! enabled_any memalign memalign_hack && enabled need_memalign ; then
57bd82d4 1513 die "Error, no memalign() but SSE enabled, disable it or use --enable-memalign-hack."
8bf5d58f
MN
1514fi
1515
0701ca7f 1516check_header byteswap.h
47d23bbf 1517
6ffa87d3 1518check_func mkstemp
b6c748ed 1519check_func gethrtime
6ffa87d3 1520
e16e49ac
RP
1521check_header termios.h
1522check_header conio.h
1523
0701ca7f 1524check_func inet_aton
57bd82d4 1525enabled zlib && check_lib zlib.h zlibVersion -lz || zlib="no"
57bd82d4 1526
b0c858d8
FR
1527# ffserver uses poll(),
1528# if it's not found we can emulate it using select().
1529if enabled ffserver; then
1530 check_header sys/poll.h
1531fi
1532
57bd82d4
MR
1533# check for some common methods of building with pthread support
1534# do this before the optional library checks as some of them require pthreads
1535if enabled pthreads; then
9e7fd101
MR
1536 if check_func pthread_create; then
1537 :
1538 elif check_func pthread_create -pthread; then
1539 add_cflags -pthread
1540 add_ldflags -pthread
1541 elif check_func pthread_create -pthreads; then
1542 add_cflags -pthreads
1543 add_ldflags -pthreads
1544 elif ! check_lib pthread.h pthread_create -lpthread; then
1545 die "ERROR: can't find pthreads library"
1546 fi
57bd82d4
MR
1547fi
1548
8eee7025 1549for thread in $THREADS_LIST; do
e5f94c2b 1550 if enabled $thread; then
aa45201d 1551 if test -n "$thread_type"; then
e5f94c2b
RP
1552 die "ERROR: Only one thread type must be selected."
1553 else
1554 thread_type="$thread"
1555 fi
1556 fi
1557done
1558
f32adb22
MR
1559# test for lrintf in math.h
1560check_exec <<EOF && lrintf=yes || lrintf=no
1561#define _ISOC9X_SOURCE 1
1562#include <math.h>
1563int main( void ) { return (lrintf(3.999f) > 0)?0:1; }
1564EOF
1565
f5a756ef 1566enabled_any libamr_nb libamr_wb && enable libamr
12b61a74 1567
57bd82d4 1568# these are off by default, so fail if requested and not available
79fda097 1569enabled avisynth && require2 vfw32 "windows.h vfw.h" AVIFileInit -lvfw32
7bc5f2a8 1570enabled liba52 && require liba52 a52dec/a52.h a52_init -la52
f5a756ef
DB
1571enabled libamr_nb && require libamrnb amrnb/interf_dec.h Speech_Decode_Frame_init -lamrnb -lm
1572enabled libamr_wb && require libamrwb amrwb/dec_if.h D_IF_init -lamrwb -lm
f7b8bffe 1573enabled libdc1394 && require libdc1394 libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394
79fda097
DB
1574enabled libfaac && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
1575enabled libfaad && require2 libfaad faad.h faacDecOpen -lfaad
910c62e1 1576enabled libgsm && require libgsm gsm.h gsm_create -lgsm
6ebe07fb 1577enabled libmp3lame && require LAME lame/lame.h lame_init -lmp3lame -lm
79fda097
DB
1578enabled libnut && require libnut libnut.h nut_demuxer_init -lnut
1579enabled libogg && require libogg ogg/ogg.h ogg_sync_init -logg
910c62e1
DB
1580enabled libtheora && require libtheora theora/theora.h theora_info_init -ltheora -logg
1581enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbis -lvorbisenc -logg
1cc60c47
DB
1582enabled libx264 && require x264 x264.h x264_encoder_open -lx264
1583enabled libxvid && require Xvid xvid.h xvid_global -lxvidcore
910c62e1 1584enabled mlib && require mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
8ac17293 1585
6ea67bbb
JR
1586# disable the native AC-3 decoder if liba52 is enabled
1587enabled liba52 && disable ac3_decoder
1588
c13e1abd
FH
1589_restrict=
1590for restrict_keyword in restrict __restrict__ __restrict; do
57bd82d4 1591 check_cc <<EOF && _restrict=$restrict_keyword && break
dcd479c0
MR
1592void foo(char * $restrict_keyword p);
1593EOF
c13e1abd
FH
1594done
1595
a8721c09
FB
1596# dlopen/dlfcn.h probing
1597
0701ca7f 1598check_header dlfcn.h
a8721c09 1599
dcd479c0 1600if check_func dlopen; then
dcd479c0 1601 ldl=
0701ca7f
MR
1602elif check_func dlopen -ldl; then
1603 ldl=-ldl
a8721c09
FB
1604fi
1605
66be5b45 1606check_func getrusage
7495c306 1607check_func2 windows.h GetProcessTimes
66be5b45 1608
4f3da985
RP
1609check_func fork
1610
703afd07 1611test "$vhook" = "default" && vhook="$dlopen"
a8721c09 1612
81a409c8 1613enabled_any vhook liba52bin libfaadbin ffserver && add_extralibs $ldl
bfd2edeb 1614
b0268cc0 1615if test "$targetos" = cygwin -o "$targetos" = mingw32 && enabled_all static vhook ; then
fbb9d104
VP
1616 vhook="no"
1617 echo
b0268cc0 1618 echo "At the moment vhooks don't work on Cygwin or MinGW static builds."
fbb9d104
VP
1619 echo "Patches welcome."
1620 echo
1621fi
1622
8d923001
MR
1623if enabled vhook; then
1624 check_ldflags -rdynamic
1625 check_ldflags -export-dynamic
1626fi
bfd2edeb 1627
703afd07 1628enabled audio_beos && add_extralibs "-lmedia -lbe"
9464f2b8 1629
eea50282
MR
1630check_foo_config imlib2 imlib2 Imlib2.h imlib_load_font
1631check_foo_config freetype2 freetype ft2build.h FT_Init_FreeType
04511d53 1632
a86b921c 1633##########################################
29799f8b 1634# SDL check
a86b921c 1635
a86b921c
FB
1636sdl_too_old=no
1637sdl=no
6a1a892f 1638SDL_CONFIG="${cross_prefix}sdl-config"
225e21ef
MR
1639if "${SDL_CONFIG}" --version >/dev/null 2>&1; then
1640 sdl_cflags=`"${SDL_CONFIG}" --cflags`
1641 temp_cflags $sdl_cflags
dcd479c0 1642 temp_extralibs `"${SDL_CONFIG}" --libs`
225e21ef 1643 if check_lib SDL.h SDL_Init; then
dcd479c0 1644 _sdlversion=`"${SDL_CONFIG}" --version | sed 's/[^0-9]//g'`
29f3b38a 1645 if test "$_sdlversion" -lt 121 ; then
dcd479c0
MR
1646 sdl_too_old=yes
1647 else
1648 sdl=yes
225e21ef 1649 check_cc $sdl_cflags <<EOF && enable sdl_video_size
29f3b38a
MR
1650#include <SDL.h>
1651int main(void){
1652 const SDL_VideoInfo *vi = SDL_GetVideoInfo();
1653 int w = vi->current_w;
1654 return 0;
1655}
1656EOF
dcd479c0
MR
1657 fi
1658 fi
29f3b38a 1659 restore_flags
c3f6b472 1660fi
57bd82d4 1661
d5697779 1662texi2html -version >/dev/null 2>&1 && enable texi2html || disable texi2html
146ea952 1663
7a91333f 1664##########################################
73b46a95
RP
1665# Network check
1666
1667if enabled network; then
1668 # Prefer arpa/inet.h over winsock2
1669 if check_header arpa/inet.h ; then
1670 check_func closesocket
1671 elif check_header winsock2.h ; then
1672 add_extralibs -lws2_32
1673 check_func2 winsock2.h closesocket
1674 fi
1675fi
1676
1677##########################################
29799f8b 1678# IPv6 check
7a91333f 1679
0c7bb0e5 1680enabled network && enabled ipv6 && check_ld <<EOF && ipv6=yes || ipv6=no
7a91333f
HZ
1681#include <sys/types.h>
1682#include <sys/socket.h>
1683#include <netinet/in.h>
1684#include <netdb.h>
1685int main( void ) {
1686 struct sockaddr_storage saddr;
1687 struct ipv6_mreq mreq6;
1688 getaddrinfo(0,0,0,0);
1689 getnameinfo(0,0,0,0,0,0,0);
12fe88b4 1690 IN6_IS_ADDR_MULTICAST((const struct in6_addr *)0);
7a91333f
HZ
1691}
1692EOF
1693
06e31011
RP
1694check_header linux/videodev.h
1695check_header linux/videodev2.h
47f38850 1696
f8aa696f
DB
1697# check for ioctl_meteor.h, ioctl_bt848.h and alternatives
1698if enabled bktr; then
3eac5c63
MR
1699 { check_header dev/bktr/ioctl_meteor.h &&
1700 check_header dev/bktr/ioctl_bt848.h; } ||
1701 { check_header machine/ioctl_meteor.h &&
1702 check_header machine/ioctl_bt848.h; } ||
1703 { check_header dev/video/meteor/ioctl_meteor.h &&
1704 check_header dev/video/bktr/ioctl_bt848.h; } ||
1705 check_header dev/ic/bt8xx.h ||
1706 disable bktr
f8aa696f
DB
1707fi
1708
c7682de0
RP
1709check_header sys/soundcard.h
1710check_header soundcard.h
deb29777 1711
f58f4ce1 1712# Deal with the x11 frame grabber
56a059ac 1713enabled x11grab &&
f58f4ce1
GP
1714enabled gpl &&
1715enabled x11_grab_device_demuxer &&
1716check_header X11/Xlib.h &&
1717check_header X11/extensions/XShm.h &&
1718check_func XOpenDisplay -lX11 &&
1719check_func XShmCreateImage -lX11 -lXext &&
1720add_extralibs -lX11 -lXext ||
1721disable x11_grab_device_demuxer
1722
57bd82d4
MR
1723enabled debug && add_cflags -g
1724
1725# add some useful compiler flags if supported
1726check_cflags -Wdeclaration-after-statement
dcd479c0
MR
1727check_cflags -Wall
1728check_cflags -Wno-switch
c07bd6a9
MN
1729check_cflags -Wdisabled-optimization
1730check_cflags -Wpointer-arith
1731check_cflags -Wredundant-decls
cc1fb623 1732check_cflags -Wno-pointer-sign
5af4e0cc 1733enabled extra_warnings && check_cflags -Winline
cf9d24ad 1734
57bd82d4 1735# add some linker flags
5c0e9479 1736check_ldflags -Wl,--warn-common
e240ee67 1737check_ldflags $LDLATEFLAGS
94a3401e 1738
bd2216e4
MR
1739if enabled small; then
1740 check_cflags -Os # not all compilers support -Os
1741 optimize="small"
1742elif enabled optimize; then
b2924696 1743 if test -n "`$cc -v 2>&1 | grep xlc`"; then
30a3e5d4
NP
1744 add_cflags "-O5"
1745 add_ldflags "-O5"
cf9d24ad 1746 else
30a3e5d4 1747 add_cflags "-O3"
cf9d24ad 1748 fi
cddf3f45
GM
1749fi
1750
80581e98 1751# PIC flags for shared library objects where they are needed
5af4e0cc 1752if enabled shared; then
f25fc9b1
MR
1753 # LIBOBJFLAGS may have already been set in the OS configuration
1754 if test -z "$LIBOBJFLAGS" ; then
cc6a90dd 1755 case "$arch" in
f824ba7b 1756 x86_64|ia64|alpha|sparc*|power*) LIBOBJFLAGS="\$(PIC)" ;;
813457e5 1757 esac
80581e98 1758 fi
80581e98
MN
1759fi
1760
90be59ef 1761if enabled gprof; then
30a3e5d4
NP
1762 add_cflags "-p"
1763 add_ldflags "-p"
1db54e20
DB
1764fi
1765
3b26ee47 1766VHOOKCFLAGS="-fPIC"
18451f7d 1767
4454dc1b
JD
1768# find if .align arg is power-of-two or not
1769if test $asmalign_pot = "unknown"; then
1770 asmalign_pot="no"
1771 echo 'asm (".align 3");' | check_cc && asmalign_pot="yes"
1772fi
1773
660db1d6
DB
1774enabled_any $ENCODER_LIST && enable encoders
1775enabled_any $DECODER_LIST && enable decoders
1776enabled_any $MUXER_LIST && enable muxers
1777enabled_any $DEMUXER_LIST && enable demuxers
c08fb000 1778enabled_any $PROTOCOL_LIST && enable protocols
cd61e407 1779enabled_any $BSF_LIST && enable bsfs
f70f03f6 1780
660db1d6 1781enabled_any $THREADS_LIST && enable threads
f70f03f6
MR
1782
1783check_deps $CONFIG_LIST $HAVE_LIST $DECODER_LIST $ENCODER_LIST $PARSER_LIST \
cd61e407 1784 $BSF_LIST $DEMUXER_LIST $MUXER_LIST $PROTOCOL_LIST
f70f03f6 1785
f7b8bffe 1786enabled libdc1394 && append pkg_requires "libraw1394"
fb2ce7d9
MR
1787enabled libogg && append pkg_requires "ogg >= 1.1"
1788enabled libtheora && append pkg_requires "theora"
1789enabled libvorbis && append pkg_requires "vorbis vorbisenc"
fb2ce7d9 1790
f36958f8
DB
1791echo "install prefix $PREFIX"
1792echo "source path $source_path"
1793echo "C compiler $cc"
1794echo "make $make"
bfd5afd8 1795echo ".align is power-of-two $asmalign_pot"
f36958f8 1796echo "ARCH $arch ($cpu)"
eb94aca9 1797if test "$BUILDSUF" != ""; then
f36958f8 1798 echo "build suffix $BUILDSUF"
eb94aca9 1799fi
0db2ce77 1800echo "big-endian ${bigendian-no}"
419b8784 1801if test $arch = "x86_32" -o $arch = "x86_64"; then
0db2ce77
MR
1802 echo "MMX enabled ${mmx-no}"
1803 echo "CMOV enabled ${cmov-no}"
1804 echo "CMOV is fast ${fast_cmov-no}"
971cc990
MN
1805 echo "EBX available ${ebx_available-no}"
1806 echo "EBP available ${ebp_available-no}"
e41e8342 1807fi
cc6a90dd 1808if test $arch = "armv4l"; then
0db2ce77
MR
1809 echo "ARMv5TE enabled ${armv5te-no}"
1810 echo "ARMv6 enabled ${armv6-no}"
1811 echo "IWMMXT enabled ${iwmmxt-no}"
eba9ae3c 1812fi
e241ba14 1813if test $arch = "mips"; then
0db2ce77 1814 echo "MMI enabled ${mmi-no}"
e41e8342 1815fi
cc6a90dd 1816if test $arch = "powerpc"; then
0db2ce77
MR
1817 echo "AltiVec enabled ${altivec-no}"
1818 echo "dcbzl available ${dcbzl-no}"
e41e8342 1819fi
0db2ce77
MR
1820echo "gprof enabled ${gprof-no}"
1821echo "debug symbols ${debug-no}"
1822echo "strip symbols ${dostrip-no}"
1823echo "optimize ${optimize-no}"
1824echo "static ${static-no}"
1825echo "shared ${shared-no}"
1826echo "postprocessing support ${pp-no}"
1827echo "software scaler enabled ${swscaler-no}"
1828echo "video hooking ${vhook-no}"
90be59ef 1829if enabled vhook; then
0db2ce77
MR
1830 echo "Imlib2 support ${imlib2-no}"
1831 echo "FreeType support ${freetype2-no}"
68892110 1832fi
0db2ce77 1833echo "network support ${network-no}"
90be59ef 1834if enabled network; then
0db2ce77 1835 echo "IPv6 support ${ipv6-no}"
bfd5afd8 1836fi
0db2ce77
MR
1837echo "threading support ${thread_type-no}"
1838echo "SDL support ${sdl-no}"
90be59ef 1839if enabled sdl_too_old; then
bfd5afd8
DB
1840 echo "-> Your SDL version is too old - please upgrade to have FFplay/SDL support."
1841fi
0db2ce77
MR
1842echo "Sun medialib support ${mlib-no}"
1843echo "AVISynth enabled ${avisynth-no}"
1844echo "liba52 support ${liba52-no}"
1845echo "liba52 dlopened ${liba52bin-no}"
1846echo "libamr-nb support ${libamr_nb-no}"
1847echo "libamr-wb support ${libamr_wb-no}"
f7b8bffe 1848echo "libdc1394 support ${libdc1394-no}"
0db2ce77
MR
1849echo "libfaac enabled ${libfaac-no}"
1850echo "libfaad enabled ${libfaad-no}"
7e0871a7 1851echo "libfaad dlopened ${libfaadbin-no}"
0db2ce77
MR
1852echo "libgsm enabled ${libgsm-no}"
1853echo "libmp3lame enabled ${libmp3lame-no}"
1854echo "libnut enabled ${libnut-no}"
1855echo "libogg enabled ${libogg-no}"
1856echo "libtheora enabled ${libtheora-no}"
1857echo "libvorbis enabled ${libvorbis-no}"
1858echo "x264 enabled ${libx264-no}"
1859echo "XviD enabled ${libxvid-no}"
1860echo "zlib enabled ${zlib-no}"
93b3c083 1861if ! enabled gpl; then
f25fc9b1 1862 echo "License: LGPL"
b2e3c528 1863else
f25fc9b1 1864 echo "License: GPL"
b2e3c528 1865fi
de6d9b64 1866
29799f8b 1867echo "Creating config.mak and config.h..."
de6d9b64 1868
29799f8b
DB
1869echo "# Automatically generated by configure - do not modify!" > config.mak
1870echo "/* Automatically generated by configure - do not modify! */" > $TMPH
0fd12426 1871echo "#define FFMPEG_CONFIGURATION \"$FFMPEG_CONFIGURATION\"" >> $TMPH
de6d9b64 1872
2266e085 1873echo "PREFIX=$PREFIX" >> config.mak
c75560ae 1874echo "prefix=\$(DESTDIR)\$(PREFIX)" >> config.mak
22a324da
DB
1875echo "LIBDIR=\$(DESTDIR)$libdir" >> config.mak
1876echo "SHLIBDIR=\$(DESTDIR)$shlibdir" >> config.mak
1877echo "INCDIR=\$(DESTDIR)$incdir" >> config.mak
1878echo "BINDIR=\$(DESTDIR)$bindir" >> config.mak
1879echo "MANDIR=\$(DESTDIR)$mandir" >> config.mak
4a908fbc 1880echo "MAKE=$make" >> config.mak
980fc7b8
FB
1881echo "CC=$cc" >> config.mak
1882echo "AR=$ar" >> config.mak
be7109c1 1883echo "RANLIB=$ranlib" >> config.mak
20369773 1884echo "LN_S=$ln_s" >> config.mak
90be59ef 1885if enabled dostrip; then
f25fc9b1 1886 echo "STRIP=$strip" >> config.mak
65d1bea2 1887else
f25fc9b1 1888 echo "STRIP=echo ignoring strip" >> config.mak
65d1bea2 1889fi
75388c74 1890
a9b3f630 1891echo "OPTFLAGS=$CFLAGS" >> config.mak
408382a4 1892echo "VHOOKCFLAGS=$VHOOKCFLAGS">>config.mak
0f3cb305 1893echo "LDFLAGS=$LDFLAGS" >> config.mak
f39e56a8 1894echo "LDCONFIG=$LDCONFIG" >> config.mak
c536cb09 1895echo "FFSERVERLDFLAGS=$FFSERVERLDFLAGS" >> config.mak
e1707f52 1896echo "SHFLAGS=$SHFLAGS" >> config.mak
408382a4 1897echo "VHOOKSHFLAGS=$VHOOKSHFLAGS" >> config.mak
fbb9d104 1898echo "VHOOKLIBS=$VHOOKLIBS" >> config.mak
80581e98 1899echo "LIBOBJFLAGS=$LIBOBJFLAGS" >> config.mak
5af4e0cc 1900echo "BUILD_STATIC=$static" >> config.mak
eb94aca9 1901echo "BUILDSUF=$BUILDSUF" >> config.mak
f3ec2d46 1902echo "LIBPREF=$LIBPREF" >> config.mak
eb94aca9 1903echo "LIBSUF=\${BUILDSUF}$LIBSUF" >> config.mak
60147de8 1904echo "LIB=$LIB" >> config.mak
f3ec2d46 1905echo "SLIBPREF=$SLIBPREF" >> config.mak
eb94aca9
CY
1906echo "SLIBSUF=\${BUILDSUF}$SLIBSUF" >> config.mak
1907echo "EXESUF=\${BUILDSUF}$EXESUF" >> config.mak
4dc62701 1908
90be59ef 1909if enabled bigendian; then
0f3cb305
FB
1910 echo "WORDS_BIGENDIAN=yes" >> config.mak
1911 echo "#define WORDS_BIGENDIAN 1" >> $TMPH
91d1f1a4 1912fi
90be59ef 1913if enabled mmx; then
e82c5a8c 1914 echo "#define __CPU__ 586" >> $TMPH
de6d9b64 1915fi
44161118 1916
90be59ef 1917if enabled sdl; then
6a1a892f
FD
1918 echo "SDL_LIBS=`"${SDL_CONFIG}" --libs`" >> config.mak
1919 echo "SDL_CFLAGS=`"${SDL_CONFIG}" --cflags`" >> config.mak
a86b921c 1920fi
90be59ef 1921if enabled texi2html; then
146ea952
NB
1922 echo "BUILD_DOC=yes" >> config.mak
1923fi
5a872801 1924
790c9ca7 1925sws_version=`grep '#define LIBSWSCALE_VERSION ' "$source_path/libswscale/swscale.h" | sed 's/[^0-9\.]//g'`
6d9a2421 1926pp_version=`grep '#define LIBPOSTPROC_VERSION ' "$source_path/libpostproc/postprocess.h" | sed 's/[^0-9\.]//g'`
5a872801
LB
1927lavc_version=`grep '#define LIBAVCODEC_VERSION ' "$source_path/libavcodec/avcodec.h" | sed 's/[^0-9\.]//g'`
1928lavf_version=`grep '#define LIBAVFORMAT_VERSION ' "$source_path/libavformat/avformat.h" | sed 's/[^0-9\.]//g'`
1929lavu_version=`grep '#define LIBAVUTIL_VERSION ' "$source_path/libavutil/avutil.h" | sed 's/[^0-9\.]//g'`
1930
1931
1932
5af4e0cc 1933if enabled shared; then
0319c531 1934 echo "BUILD_SHARED=yes" >> config.mak
97006039 1935 echo "PIC=-fPIC -DPIC" >> config.mak
7e303556
DB
1936 echo "SPPMAJOR=${pp_version%%.*}" >> config.mak
1937 echo "SPPVERSION=$pp_version" >> config.mak
39503a27 1938 echo "LAVCMAJOR=${lavc_version%%.*}" >> config.mak
5a872801 1939 echo "LAVCVERSION=$lavc_version" >> config.mak
39503a27 1940 echo "LAVFMAJOR=${lavf_version%%.*}" >> config.mak
5a872801 1941 echo "LAVFVERSION=$lavf_version" >> config.mak
39503a27 1942 echo "LAVUMAJOR=${lavu_version%%.*}" >> config.mak
5a872801 1943 echo "LAVUVERSION=$lavu_version" >> config.mak
790c9ca7
LA
1944 echo "SWSMAJOR=${sws_version%%.*}" >> config.mak
1945 echo "SWSVERSION=$sws_version" >> config.mak
4bdd05e7 1946 echo "SLIBNAME=${SLIBNAME}" >> config.mak
f3b60109
DB
1947 echo "SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}" >> config.mak
1948 echo "SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}" >> config.mak
5cb854e1 1949 echo "SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}" >> config.mak
8fbec4f4 1950 echo "SLIB_INSTALL_EXTRA_CMD=${SLIB_INSTALL_EXTRA_CMD}" >> config.mak
0319c531 1951fi
d7e27559 1952echo "LIB_INSTALL_EXTRA_CMD=${LIB_INSTALL_EXTRA_CMD}" >> config.mak
ef0bc4c9 1953echo "EXTRALIBS=$extralibs" >> config.mak
d2845d68 1954
3d907e22
MR
1955print_config ARCH_ $TMPH config.mak $ARCH_LIST
1956print_config HAVE_ $TMPH config.mak $HAVE_LIST
1957print_config CONFIG_ $TMPH config.mak $CONFIG_LIST \
1958 $DECODER_LIST \
1959 $ENCODER_LIST \
1960 $PARSER_LIST \
1961 $BSF_LIST \
1962 $DEMUXER_LIST \
1963 $MUXER_LIST \
1964 $PROTOCOL_LIST \
8ac17293 1965
c13e1abd
FH
1966echo "#define restrict $_restrict" >> $TMPH
1967
bd2216e4 1968if enabled small; then
3bf98161 1969 echo "#define av_always_inline" >> $TMPH
bb801c97
MN
1970fi
1971
997baf01
MR
1972echo "SRC_PATH=\"$source_path\"" >> config.mak
1973echo "SRC_PATH_BARE=$source_path" >> config.mak
1974echo "BUILD_ROOT=\"$PWD\"" >> config.mak
0f3cb305 1975
8156056e 1976# Apparently it's not possible to portably echo a backslash.
90be59ef 1977if enabled asmalign_pot; then
8156056e 1978 printf '#define ASMALIGN(ZEROBITS) ".align " #ZEROBITS "\\n\\t"\n' >> $TMPH
4454dc1b 1979else
8156056e 1980 printf '#define ASMALIGN(ZEROBITS) ".align 1<<" #ZEROBITS "\\n\\t"\n' >> $TMPH
4454dc1b
JD
1981fi
1982
bc634f6f 1983
9cb2cf10 1984# Do not overwrite config.h if unchanged to avoid superfluous rebuilds.
c683a5d1 1985if ! cmp -s $TMPH config.h; then
9cb2cf10
DB
1986 mv -f $TMPH config.h
1987else
1988 echo "config.h is unchanged"
1989fi
3d204385 1990
f3ec2d46 1991rm -f $TMPO $TMPC $TMPE $TMPS $TMPH
def4272a 1992
165af439 1993# build tree in object directory if source path is different from current one
90be59ef 1994if enabled source_path_used; then
165af439
MR
1995 DIRS="\
1996 doc \
165af439
MR
1997 libavcodec \
1998 libavcodec/alpha \
1999 libavcodec/armv4l \
2000 libavcodec/bfin \
2001 libavcodec/i386 \
165af439
MR
2002 libavcodec/mlib \
2003 libavcodec/ppc \
7506d47a 2004 libavcodec/sh4 \
862a70f1
AJ
2005 libavcodec/sparc \
2006 libavformat \
165af439 2007 libavutil \
862a70f1 2008 libpostproc \
165af439
MR
2009 libswscale \
2010 tests \
c07ed8c8 2011 tools \
165af439
MR
2012 vhook \
2013 "
2014 FILES="\
2015 Makefile \
2016 common.mak \
862a70f1 2017 doc/texi2pod.pl \
165af439 2018 libavcodec/Makefile \
862a70f1 2019 libavformat/Makefile \
165af439 2020 libavutil/Makefile \
862a70f1 2021 libpostproc/Makefile \
165af439 2022 libswscale/Makefile \
165af439
MR
2023 "
2024 for dir in $DIRS ; do
2025 mkdir -p $dir
2026 done
2027 for f in $FILES ; do
20369773 2028 $ln_s "$source_path/$f" $f
165af439
MR
2029 done
2030fi
def4272a 2031
def4272a 2032
d0674868 2033# build pkg-config files
77aee36c 2034# FIXME: libdir and includedir are hardcoded and may differ from the real path.
def4272a 2035
d0674868
DB
2036pkgconfig_generate(){
2037name=$1
2038comment=$2
2039version=$3
2040libs=$4
2041requires=$5
2042include=$6
2043cat <<EOF >$name.pc
2266e085 2044prefix=$PREFIX
a94e666c 2045exec_prefix=\${prefix}
def4272a 2046libdir=\${exec_prefix}/lib
a94e666c 2047includedir=\${prefix}/include
def4272a 2048
d0674868
DB
2049Name: $name
2050Description: $comment
2051Version: $version
2052Requires: $requires
def4272a 2053Conflicts:
d0674868
DB
2054Libs: -L\${libdir} $libs
2055Cflags: -I\${includedir} -I\${includedir}/$include
def4272a 2056EOF
d0674868 2057}
def4272a 2058
d0674868
DB
2059pkgconfig_generate_uninstalled(){
2060name=$1
9c476fd6 2061shortname=${name#lib}
d0674868
DB
2062comment=$2
2063version=$3
2064libs=$4
2065requires=$5
2066cat <<EOF >$name-uninstalled.pc
def4272a
AJ
2067prefix=
2068exec_prefix=
d0674868
DB
2069libdir=\${pcfiledir}/$name
2070includedir=\${pcfiledir}/$name
def4272a 2071
d0674868
DB
2072Name: $name
2073Description: $comment
2074Version: $version
2075Requires: $requires
def4272a 2076Conflicts:
d0674868 2077Libs: \${libdir}/${LIBPREF}${shortname}${LIBSUF} $libs
def4272a
AJ
2078Cflags: -I\${includedir}
2079EOF
d0674868 2080}
def4272a 2081
9d824ad1 2082pkgconfig_generate libavutil "FFmpeg utility library" "$lavu_version" -lavutil "" ffmpeg
d0674868 2083pkgconfig_generate_uninstalled libavutil "FFmpeg utility library" "$lavu_version"
def4272a 2084
d0674868
DB
2085pkgconfig_generate libavcodec "FFmpeg codec library" "$lavc_version" "-lavcodec $extralibs" "$pkg_requires libavutil = $lavu_version" ffmpeg
2086pkgconfig_generate_uninstalled libavcodec "FFmpeg codec library" "$lavc_version" "$extralibs" "$pkg_requires libavutil = $lavu_version"
def4272a 2087
d0674868
DB
2088pkgconfig_generate libavformat "FFmpeg container format library" "$lavf_version" "-lavformat $extralibs" "$pkg_requires libavcodec = $lavc_version" ffmpeg
2089pkgconfig_generate_uninstalled libavformat "FFmpeg container format library" "$lavf_version" "$extralibs" "$pkg_requires libavcodec = $lavc_version"
def4272a 2090
90be59ef 2091if enabled pp; then
2e3bcd38
DB
2092 pkgconfig_generate libpostproc "FFmpeg post processing library" "$pp_version" -lpostproc "" postproc
2093 pkgconfig_generate_uninstalled libpostproc "FFmpeg post processing library" "$pp_version"
2094fi
790c9ca7 2095
c839db53 2096if enabled swscaler; then
3d3361e5 2097 pkgconfig_generate libswscale "FFmpeg image rescaling library" "$sws_version" -lswscale "libavutil = $lavu_version" ffmpeg
20c516c6 2098 pkgconfig_generate_uninstalled libswscale "FFmpeg image rescaling library" "$sws_version" "" "libavutil = $lavu_version"
6c0d0413 2099else
3d3361e5 2100 pkgconfig_generate libswscale "FFmpeg image rescaling library" "$sws_version" "" "$pkg_requires libavcodec = $lavc_version" ffmpeg
d0674868 2101 pkgconfig_generate_uninstalled libswscale "FFmpeg image rescaling library" "$sws_version" "" "$pkg_requires libavcodec = $lavc_version"
c505dd31
MR
2102 apply libswscale.pc sed s/^Libs:.*$/Libs:/
2103 apply libswscale-uninstalled.pc sed s/^Libs:.*$/Libs:/
6c0d0413 2104fi