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