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