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