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