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