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