simplify test for memalign emulation requirement
[libav.git] / configure
CommitLineData
de6d9b64 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."
c21d6325
MR
41 echo "This configure script requires a POSIX compatible shell"
42 echo "such as bash or ksh."
43 if test "$BASH_VERSION" = '2.04.0(1)-release'; then
44 echo "This bash version ($BASH_VERSION) is broken on your platform."
45 echo "Upgrade to a later version if available."
46 fi
cde2d79a
MR
47 exit 1
48fi
49
74c53c2d
MR
50show_help(){
51 echo "Usage: configure [options]"
52 echo "Options: [defaults in brackets after descriptions]"
53 echo
54 echo "Standard options:"
55 echo " --help print this message"
2ba042a7 56 echo " --log[=FILE|yes|no] log tests and output to FILE [config.err]"
2266e085 57 echo " --prefix=PREFIX install in PREFIX [$PREFIX]"
74c53c2d 58 echo " --libdir=DIR install libs in DIR [PREFIX/lib]"
84c22efd 59 echo " --shlibdir=DIR install shared libs in DIR [PREFIX/lib]"
74c53c2d
MR
60 echo " --incdir=DIR install includes in DIR [PREFIX/include/ffmpeg]"
61 echo " --mandir=DIR install man page in DIR [PREFIX/man]"
62 echo " --enable-mp3lame enable MP3 encoding via libmp3lame [default=no]"
f956e129 63 echo " --enable-libnut enable NUT support via libnut [default=no]"
74c53c2d
MR
64 echo " --enable-libogg enable Ogg support via libogg [default=no]"
65 echo " --enable-vorbis enable Vorbis support via libvorbis [default=no]"
74c53c2d
MR
66 echo " --enable-faad enable FAAD support via libfaad [default=no]"
67 echo " --enable-faadbin build FAAD support with runtime linking [default=no]"
68 echo " --enable-faac enable FAAC support via libfaac [default=no]"
69 echo " --enable-libgsm enable GSM support via libgsm [default=no]"
70 echo " --enable-xvid enable XviD support via xvidcore [default=no]"
71 echo " --enable-x264 enable H.264 encoding via x264 [default=no]"
72 echo " --enable-mingw32 enable MinGW native/cross Windows compile"
73 echo " --enable-mingwce enable MinGW native/cross WinCE compile"
74 echo " --enable-a52 enable GPLed A52 support [default=no]"
75 echo " --enable-a52bin open liba52.so.0 at runtime [default=no]"
76 echo " --enable-dts enable GPLed DTS support [default=no]"
77 echo " --enable-pp enable GPLed postprocessing support [default=no]"
78 echo " --enable-static build static libraries [default=yes]"
79 echo " --disable-static do not build static libraries [default=no]"
80 echo " --enable-shared build shared libraries [default=no]"
81 echo " --disable-shared do not build shared libraries [default=yes]"
82 echo " --enable-amr_nb enable amr_nb float audio codec"
83 echo " --enable-amr_nb-fixed use fixed point for amr-nb codec"
84 echo " --enable-amr_wb enable amr_wb float audio codec"
85 echo " --enable-amr_if2 enable amr_wb IF2 audio codec"
86 echo " --enable-sunmlib use Sun medialib [default=no]"
87 echo " --enable-pthreads use pthreads [default=no]"
88 echo " --enable-dc1394 enable IIDC-1394 grabbing using libdc1394"
89 echo " and libraw1394 [default=no]"
790c9ca7 90 echo " --enable-swscaler software scaler support [default=no]"
8ac17293 91 echo " --enable-avisynth allow reading AVISynth script files [default=no]"
74c53c2d
MR
92 echo " --enable-gpl allow use of GPL code, the resulting libav*"
93 echo " and ffmpeg will be under GPL [default=no]"
94 echo ""
95 echo "Advanced options (experts only):"
96 echo " --source-path=PATH path to source code [$source_path]"
97 echo " --cross-prefix=PREFIX use PREFIX for compilation tools [$cross_prefix]"
fac252f9 98 echo " --cross-compile assume a cross-compiler is used"
74c53c2d
MR
99 echo " --cc=CC use C compiler CC [$cc]"
100 echo " --make=MAKE use specified make [$make]"
101 echo " --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS [$CFLAGS]"
102 echo " --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]"
103 echo " --extra-libs=ELIBS add ELIBS [$ELIBS]"
104 echo " --build-suffix=SUFFIX suffix for application specific build []"
cc6a90dd 105 echo " --arch=ARCH select architecture [$arch]"
38d0a8aa
GP
106 echo " --cpu=CPU selects the minimum cpu required (affects
107 instruction selection, may crash on older CPUs)"
74c53c2d
MR
108 echo " --powerpc-perf-enable enable performance report on PPC"
109 echo " (requires enabling PMC)"
110 echo " --disable-mmx disable MMX usage"
1839e854 111 echo " --disable-armv5te disable armv5te usage"
74c53c2d
MR
112 echo " --disable-iwmmxt disable iwmmxt usage"
113 echo " --disable-altivec disable AltiVec usage"
114 echo " --disable-audio-oss disable OSS audio support [default=no]"
115 echo " --disable-audio-beos disable BeOS audio support [default=no]"
116 echo " --disable-v4l disable video4linux grabbing [default=no]"
117 echo " --disable-v4l2 disable video4linux2 grabbing [default=no]"
118 echo " --disable-bktr disable bktr video grabbing [default=no]"
119 echo " --disable-dv1394 disable DV1394 grabbing [default=no]"
120 echo " --disable-network disable network support [default=no]"
0c7bb0e5 121 echo " --disable-ipv6 disable ipv6 support [default=no]"
74c53c2d 122 echo " --disable-zlib disable zlib [default=no]"
74c53c2d
MR
123 echo " --disable-vhook disable video hooking support"
124 echo " --enable-gprof enable profiling with gprof [$gprof]"
125 echo " --disable-debug disable debugging symbols"
126 echo " --disable-opts disable compiler optimizations"
78fcba8f 127 echo " --enable-extra-warnings enable more compiler warnings"
74c53c2d
MR
128 echo " --disable-mpegaudio-hp faster (but less accurate)"
129 echo " MPEG audio decoding [default=no]"
130 echo " --disable-protocols disable I/O protocols support [default=no]"
786b30af 131 echo " --disable-ffmpeg disable ffmpeg build"
74c53c2d
MR
132 echo " --disable-ffserver disable ffserver build"
133 echo " --disable-ffplay disable ffplay build"
134 echo " --enable-small optimize for size instead of speed"
135 echo " --enable-memalign-hack emulate memalign, interferes with memory debuggers"
136 echo " --disable-strip disable stripping of executables and shared libraries"
137 echo " --disable-encoder=NAME disables encoder NAME"
138 echo " --enable-encoder=NAME enables encoder NAME"
139 echo " --disable-decoder=NAME disables decoder NAME"
140 echo " --enable-decoder=NAME enables decoder NAME"
141 echo " --disable-encoders disables all encoders"
142 echo " --disable-decoders disables all decoders"
ff70e601
MR
143 echo " --disable-muxer=NAME disables muxer NAME"
144 echo " --enable-muxer=NAME enables muxer NAME"
74c53c2d 145 echo " --disable-muxers disables all muxers"
ff70e601
MR
146 echo " --disable-demuxer=NAME disables demuxer NAME"
147 echo " --enable-demuxer=NAME enables demuxer NAME"
74c53c2d 148 echo " --disable-demuxers disables all demuxers"
af9e7d18
MR
149 echo " --enable-parser=NAME enables parser NAME"
150 echo " --disable-parser=NAME disables parser NAME"
151 echo " --disable-parsers disables all parsers"
74c53c2d
MR
152 echo ""
153 echo "NOTE: Object files are built at the place where configure is launched."
154 exit 1
155}
cf9d24ad 156
57bd82d4
MR
157log(){
158 echo "$@" >>$logfile
159}
160
720c69da 161log_file(){
c8e9f801
MR
162 log BEGIN $1
163 cat -n $1 >>$logfile
164 log END $1
165}
166
2ba042a7 167echolog(){
c8e9f801 168 log "$@"
57bd82d4 169 echo "$@"
2ba042a7
MR
170}
171
172die(){
173 echolog "$@"
174 cat <<EOF
175If you think configure made a mistake, make sure you are using the latest
176version from SVN. If the latest version fails, report the problem to the
177ffmpeg-devel@mplayerhq.hu mailing list or IRC #ffmpeg on irc.freenode.net.
178EOF
720c69da 179 if enabled logging; then
2ba042a7
MR
180 cat <<EOF
181Include the log file "$logfile" produced by configure as this will help
182solving the problem.
183EOF
184 else
185cat <<EOF
186Rerun configure with logging enabled (do not use --log=no), and include the
187log this produces with your report.
188EOF
189 fi
57bd82d4
MR
190 rm -f $TMPC $TMPO $TMPE $TMPS $TMPH
191 exit 1
192}
193
904e48f1 194# "tr '[a-z]' '[A-Z]'" is a workaround for Solaris tr not grokking "tr a-z A-Z"
44161118
MR
195toupper(){
196 echo "$@" | tr '[a-z]' '[A-Z]'
197}
198
a8d04fba
MR
199set_all(){
200 value=$1
201 shift
202 for var in $*; do
203 eval $var=$value
204 done
205}
206
207enable(){
208 set_all yes $*
209}
210
211disable(){
212 set_all no $*
213}
214
57bd82d4 215enabled(){
44161118
MR
216 eval test "x\$$1" = "xyes"
217}
218
219enabled_all(){
220 for opt; do
221 enabled $opt || return 1
222 done
223}
224
225enabled_any(){
226 for opt; do
227 enabled $opt && return 0
228 done
229}
230
231print_config(){
232 pfx=$1
233 header=$2
234 makefile=$3
235 shift 3
236 for cfg; do
237 if enabled $cfg; then
238 ucname="${pfx}`toupper $cfg`"
239 echo "#define ${ucname} 1" >> $header
240 echo "${ucname}=yes" >> $makefile
241 fi
242 done
57bd82d4
MR
243}
244
245flags_saved(){
246 (: ${SAVE_CFLAGS?}) 2>/dev/null
247}
248
dcd479c0 249save_flags(){
57bd82d4 250 flags_saved && return
dcd479c0
MR
251 SAVE_CFLAGS="$CFLAGS"
252 SAVE_LDFLAGS="$LDFLAGS"
253 SAVE_extralibs="$extralibs"
254}
255
256restore_flags(){
257 CFLAGS="$SAVE_CFLAGS"
258 LDFLAGS="$SAVE_LDFLAGS"
259 extralibs="$SAVE_extralibs"
260 unset SAVE_CFLAGS
261 unset SAVE_LDFLAGS
262 unset SAVE_extralibs
263}
264
265temp_cflags(){
266 save_flags
267 CFLAGS="$CFLAGS $*"
268}
269
270temp_ldflags(){
271 save_flags
272 LDFLAGS="$LDFLAGS $*"
273}
274
275temp_extralibs(){
276 save_flags
277 extralibs="$extralibs $*"
278}
279
57bd82d4
MR
280append(){
281 var=$1
282 shift
283 flags_saved && eval "SAVE_$var=\"\$SAVE_$var $*\""
284 eval "$var=\"\$$var $*\""
285}
286
287add_cflags(){
288 append CFLAGS "$@"
289}
290
291add_ldflags(){
292 append LDFLAGS "$@"
293}
294
295add_extralibs(){
296 append extralibs "$@"
297}
298
b0cfb663 299check_cmd(){
b3cb5d51 300 log "$@"
9b4f605c 301 "$@" >>$logfile 2>&1
b0cfb663
MR
302}
303
dcd479c0 304check_cc(){
57bd82d4
MR
305 log check_cc "$@"
306 cat >$TMPC
720c69da 307 log_file $TMPC
b0cfb663 308 check_cmd $cc $CFLAGS "$@" -c -o $TMPO $TMPC
57bd82d4
MR
309}
310
311check_cpp(){
312 log check_cpp "$@"
dcd479c0 313 cat >$TMPC
720c69da 314 log_file $TMPC
b0cfb663 315 check_cmd $cc $CFLAGS "$@" -E -o $TMPO $TMPC
dcd479c0
MR
316}
317
318check_ld(){
57bd82d4 319 log check_ld "$@"
0607887f 320 check_cc || return
b0cfb663 321 check_cmd $cc $LDFLAGS "$@" -o $TMPE $TMPO $extralibs
dcd479c0
MR
322}
323
324check_cflags(){
57bd82d4
MR
325 log check_cflags "$@"
326 check_cc "$@" <<EOF && add_cflags "$@"
dcd479c0
MR
327int x;
328EOF
329}
330
331check_ldflags(){
57bd82d4
MR
332 log check_ldflags "$@"
333 check_ld "$@" <<EOF && add_ldflags "$@"
334int main(){
335 return 0;
336}
dcd479c0
MR
337EOF
338}
339
340check_header(){
57bd82d4 341 log check_header "$@"
dcd479c0
MR
342 header=$1
343 shift
57bd82d4 344 check_cpp "$@" <<EOF
dcd479c0
MR
345#include <$header>
346int x;
347EOF
0701ca7f 348 err=$?
0dbe81bb 349 var=`echo $header | sed 's/[^A-Za-z0-9_]/_/g'`
0701ca7f
MR
350 test "$err" = 0 && enable $var || disable $var
351 return $err
dcd479c0
MR
352}
353
354check_func(){
57bd82d4 355 log check_func "$@"
dcd479c0
MR
356 func=$1
357 shift
358 check_ld "$@" <<EOF
359extern int $func();
360int main(){
361 $func();
362}
363EOF
0701ca7f
MR
364 err=$?
365 test "$err" = 0 && enable $func || disable $func
366 return $err
dcd479c0
MR
367}
368
57bd82d4
MR
369check_lib(){
370 log check_lib "$@"
371 header="$1"
372 func="$2"
373 shift 2
374 temp_extralibs "$@"
375 check_header $header && check_func $func && add_extralibs "$@"
376 err=$?
377 restore_flags
378 return $err
379}
380
dcd479c0 381check_exec(){
bd4700b1 382 check_ld "$@" && { test "$cross_compile" = yes || $TMPE >>$logfile 2>&1; }
57bd82d4
MR
383}
384
385require(){
386 name="$1"
387 header="$2"
388 func="$3"
389 shift 3
390 check_lib $header $func "$@" || die "ERROR: $name not found"
dcd479c0
MR
391}
392
c88f5d72
MR
393CONFIG_LIST='
394 encoders
395 decoders
396 parsers
397 muxers
398 demuxers
399 a52
400 a52bin
401 amr
402 amr_nb
403 amr_nb_fixed
404 amr_wb
405 audio_beos
406 audio_oss
407 avisynth
408 beos_netserver
409 bktr
410 dc1394
411 dts
412 dv1394
413 faac
414 faad
415 faadbin
416 ffmpeg
417 ffplay
418 ffserver
419 gpl
420 ipv6
421 libgsm
422 libnut
423 libogg
424 libvorbis
425 memalign_hack
426 mp3lame
427 mpegaudio_hp
428 network
429 pp
430 protocols
431 swscaler
432 vhook
433 video4linux
434 video4linux2
860391a5 435 wince
c88f5d72
MR
436 x264
437 xvid
438 zlib
439'
440
441HAVE_LIST='
442 altivec_h
b265431e 443 beosthreads
c88f5d72
MR
444 byteswap_h
445 dcbzl
18b67ae5 446 dlfcn_h
c88f5d72
MR
447 dlopen
448 freetype2
449 gprof
450 imlib2
2e1913b1 451 inet_aton
c88f5d72
MR
452 localtime_r
453 lrintf
454 malloc_h
455 memalign
456 mlib
9c914398 457 os2
b265431e
MR
458 os2threads
459 pthreads
c88f5d72
MR
460 sdl
461 sdl_video_size
b265431e
MR
462 threads
463 w32threads
c88f5d72 464'
44161118 465
0f3cb305 466# set temporary file name
57514323 467if test ! -z "$TMPDIR" ; then
0f3cb305 468 TMPDIR1="${TMPDIR}"
57514323 469elif test ! -z "$TEMPDIR" ; then
0f3cb305 470 TMPDIR1="${TEMPDIR}"
3d204385 471else
0f3cb305 472 TMPDIR1="/tmp"
3d204385
NK
473fi
474
0f3cb305
FB
475TMPC="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.c"
476TMPO="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.o"
f3ec2d46 477TMPE="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}"
0f3cb305
FB
478TMPS="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.S"
479TMPH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.h"
480
de6d9b64 481# default parameters
720c69da 482logging="yes"
2ba042a7 483logfile="config.err"
2266e085
DB
484PREFIX="/usr/local"
485libdir='${PREFIX}/lib'
84c22efd 486shlibdir="$libdir"
2266e085
DB
487incdir='${PREFIX}/include/ffmpeg'
488mandir='${PREFIX}/man'
489bindir='${PREFIX}/bin'
0f3cb305 490cross_prefix=""
fac252f9 491cross_compile="no"
de6d9b64
FB
492cc="gcc"
493ar="ar"
be7109c1 494ranlib="ranlib"
4a908fbc 495make="make"
0f3cb305 496strip="strip"
cc6a90dd 497arch=`uname -m`
38d0a8aa 498cpu="generic"
e45a2872 499powerpc_perf="no"
0f3cb305 500mmx="default"
e7768fc5 501cmov="no"
94e4c3a3 502cmov_is_fast="no"
1839e854 503armv5te="default"
eba9ae3c 504iwmmxt="default"
ab6c65f6 505altivec="default"
87ea51e0 506dcbzl="no"
d46aba26 507mmi="default"
cc6a90dd 508case "$arch" in
ef0bc4c9 509 i386|i486|i586|i686|i86pc|BePC)
419b8784 510 arch="x86_32"
de6d9b64 511 ;;
7bf9648e 512 x86_64|amd64)
a63e5f1c 513 arch="x86_32"
32255f6c 514 canon_arch="`$cc -dumpmachine | sed -e 's,\([^-]*\)-.*,\1,'`"
7bf9648e
JM
515 if [ x"$canon_arch" = x"x86_64" -o x"$canon_arch" = x"amd64" ]; then
516 if [ -z "`echo $CFLAGS | grep -- -m32`" ]; then
cc6a90dd 517 arch="x86_64"
7bf9648e 518 fi
053dea12
AJ
519 fi
520 ;;
6dc7b6b3
DB
521 # armv4l is a subset of armv[567]*l
522 arm|armv[4567]*l)
cc6a90dd 523 arch="armv4l"
6ed7422a 524 ;;
91d1f1a4 525 alpha)
cc6a90dd 526 arch="alpha"
91d1f1a4 527 ;;
2645e80f 528 "Power Macintosh"|ppc|ppc64|powerpc)
cc6a90dd 529 arch="powerpc"
90cee0c3 530 ;;
b028a866 531 mips|mipsel|IP*)
cc6a90dd 532 arch="mips"
d46aba26 533 ;;
bb476ff3 534 sun4u|sparc64)
cc6a90dd 535 arch="sparc64"
a7beab73 536 ;;
bb476ff3 537 sparc)
cc6a90dd 538 arch="sparc"
bb476ff3 539 ;;
bdb2e37c 540 sh4)
cc6a90dd 541 arch="sh4"
bdb2e37c 542 ;;
67860b26 543 parisc|parisc64)
cc6a90dd 544 arch="parisc"
67860b26
SH
545 ;;
546 s390|s390x)
cc6a90dd 547 arch="s390"
67860b26
SH
548 ;;
549 m68k)
cc6a90dd 550 arch="m68k"
67860b26
SH
551 ;;
552 ia64)
cc6a90dd 553 arch="ia64"
67860b26 554 ;;
81a9b052 555 bfin)
cc6a90dd 556 arch="bfin"
81a9b052 557 ;;
de6d9b64 558 *)
cc6a90dd 559 arch="unknown"
de6d9b64
FB
560 ;;
561esac
562gprof="no"
9d2a0f1c
MR
563video4linux="yes"
564video4linux2="yes"
6beefa40 565bktr="no"
5cbcf02c 566audio_oss="yes"
dfdfa47c 567audio_beos="no"
8aa3ee32 568dv1394="yes"
f02be79d 569dc1394="no"
5cbcf02c 570network="yes"
0c7bb0e5 571ipv6="yes"
0147f198 572zlib="yes"
bb4c2140 573libgsm="no"
a6741398 574mp3lame="no"
f956e129 575libnut="no"
9146ca37 576libogg="no"
be74741c 577libvorbis="no"
0fc50e58
ZK
578faad="no"
579faadbin="no"
29d48296 580faac="no"
1ddadfa9 581xvid="no"
6662ec29 582x264="no"
ba9261e5 583a52="no"
57514323 584a52bin="no"
23c99253 585dts="no"
ba9261e5 586pp="no"
732d9245 587mingw32="no"
860391a5 588wince="no"
f3ec2d46 589os2="no"
320d060a 590lstatic="yes"
83286d2a 591lshared="no"
cddf3f45
GM
592optimize="yes"
593debug="yes"
78fcba8f 594extrawarnings="no"
65d1bea2 595dostrip="yes"
da186ae2 596installstrip="-s"
ef0bc4c9 597extralibs="-lm"
0f3cb305 598bigendian="no"
a8721c09 599vhook="default"
8ac17293 600avisynth="no"
18b67ae5 601dlfcn_h="no"
adbc0510 602dlopen="no"
1eb2212e 603mpegaudio_hp="yes"
baa3a937 604SHFLAGS='-shared -Wl,-soname,$@'
cab3ef82 605VHOOKSHFLAGS='$(SHFLAGS)'
8e72b130 606beos_netserver="no"
04f46ced 607protocols="yes"
786b30af 608ffmpeg="yes"
8154d2e0 609ffserver="yes"
a86b921c 610ffplay="yes"
80581e98 611LIBOBJFLAGS=""
e89b8b0a 612FFLDFLAGS=-Wl,--warn-common
e240ee67 613LDLATEFLAGS='-Wl,-rpath-link,\$(BUILD_ROOT)/libavcodec -Wl,-rpath-link,\$(BUILD_ROOT)/libavformat -Wl,-rpath-link,\$(BUILD_ROOT)/libavutil'
c536cb09 614FFSERVERLDFLAGS=-Wl,-E
f39e56a8 615LDCONFIG="ldconfig"
f3ec2d46
SG
616LIBPREF="lib"
617LIBSUF=".a"
4bdd05e7 618LIB='$(LIBPREF)$(NAME)$(LIBSUF)'
f3ec2d46
SG
619SLIBPREF="lib"
620SLIBSUF=".so"
4bdd05e7 621SLIBNAME='$(SLIBPREF)$(NAME)$(SLIBSUF)'
b29bddab
DB
622SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
623SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
951bf3e6 624EXESUF=""
eb94aca9 625BUILDSUF=""
891f64b3 626amr_nb="no"
d663a1fd 627amr_wb="no"
bc634f6f 628amr_nb_fixed="no"
2a515c08 629amr_if2="no"
bde24d6e 630mlib="no"
9c3d33d6 631pthreads="no"
790c9ca7 632swscaler="no"
b2e3c528 633gpl="no"
9ddbcae6 634memalign_hack="no"
4454dc1b 635asmalign_pot="unknown"
d4596ae3 636LIB_INSTALL_EXTRA_CMD='$(RANLIB) "$(libdir)/$(LIB)"'
ef0bc4c9
FR
637
638# OS specific
639targetos=`uname -s`
640case $targetos in
641BeOS)
2266e085 642PREFIX="/boot/home/config"
ef0bc4c9 643# helps building libavcodec
30a3e5d4 644add_cflags "-DPIC -fomit-frame-pointer"
31ba0b4d 645# 3 gcc releases known for BeOS, each with ugly bugs
b2924696 646gcc_version="`$cc -v 2>&1 | grep version | cut -d ' ' -f3-`"
31ba0b4d
FR
647case "$gcc_version" in
6482.9-beos-991026*|2.9-beos-000224*) echo "R5/GG gcc"
649mmx="no"
650;;
651*20010315*) echo "BeBits gcc"
30a3e5d4 652add_cflags "-fno-expensive-optimizations"
31ba0b4d
FR
653;;
654esac
e1707f52 655SHFLAGS=-nostart
29799f8b 656# disable Linux things
e1707f52 657audio_oss="no"
9d2a0f1c
MR
658video4linux="no"
659video4linux2="no"
8aa3ee32 660dv1394="no"
29799f8b 661# enable BeOS things
dfdfa47c 662audio_beos="yes"
b265431e 663beosthreads="yes"
ef0bc4c9
FR
664# no need for libm, but the inet stuff
665# Check for BONE
666if (echo $BEINCLUDES|grep 'headers/be/bone' >/dev/null); then
667extralibs="-lbind -lsocket"
668else
8e72b130 669beos_netserver="yes"
26b35efb 670extralibs="-lnet"
ef0bc4c9 671fi ;;
4baca069 672SunOS)
9d2a0f1c
MR
673video4linux="no"
674video4linux2="no"
4baca069 675audio_oss="no"
8aa3ee32 676dv1394="no"
4baca069 677make="gmake"
e89b8b0a 678FFLDFLAGS=""
c536cb09 679FFSERVERLDFLAGS=""
813457e5 680SHFLAGS="-shared -Wl,-h,\$@"
30a3e5d4 681add_extralibs "-lsocket -lnsl"
4baca069 682;;
b7aa4a59 683NetBSD)
9d2a0f1c
MR
684video4linux="no"
685video4linux2="no"
6beefa40 686bktr="yes"
b7aa4a59
SS
687audio_oss="yes"
688dv1394="no"
689make="gmake"
30a3e5d4 690add_extralibs "-lossaudio"
b7aa4a59 691;;
8c802695 692OpenBSD)
9d2a0f1c
MR
693video4linux="no"
694video4linux2="no"
6beefa40 695bktr="yes"
8c802695
JM
696audio_oss="yes"
697dv1394="no"
698make="gmake"
80581e98 699LIBOBJFLAGS="\$(PIC)"
a1309f8f 700LDCONFIG="ldconfig -m \$(shlibdir)"
30a3e5d4 701add_extralibs "-lossaudio"
8c802695 702;;
9c938e77 703FreeBSD)
9d2a0f1c
MR
704video4linux="no"
705video4linux2="no"
6beefa40 706bktr="yes"
9c938e77 707audio_oss="yes"
8aa3ee32 708dv1394="no"
9c938e77 709make="gmake"
5d323602 710need_memalign="no"
30a3e5d4 711add_cflags "-pthread"
9c938e77 712;;
38f0d3ce 713GNU/kFreeBSD)
9d2a0f1c
MR
714video4linux="no"
715video4linux2="no"
38f0d3ce
DB
716bktr="yes"
717audio_oss="yes"
718dv1394="no"
30a3e5d4 719add_cflags "-pthread"
38f0d3ce 720;;
4a908fbc 721BSD/OS)
9d2a0f1c
MR
722video4linux="no"
723video4linux2="no"
6beefa40 724bktr="yes"
6063bce7 725audio_oss="yes"
8aa3ee32 726dv1394="no"
4a908fbc
AB
727extralibs="-lpoll -lgnugetopt -lm"
728make="gmake"
1db68540
SS
729strip="strip -d"
730installstrip=""
4a908fbc 731;;
90cee0c3 732Darwin)
a43bd1d7 733cc="cc"
9d2a0f1c
MR
734video4linux="no"
735video4linux2="no"
90cee0c3 736audio_oss="no"
8aa3ee32 737dv1394="no"
5d323602 738need_memalign="no"
a1309f8f 739SHFLAGS="-dynamiclib -Wl,-single_module -Wl,-install_name,\$(shlibdir)/\$(SLIBNAME),-current_version,\$(SPPVERSION),-compatibility_version,\$(SPPVERSION)"
408382a4 740VHOOKSHFLAGS='-dynamiclib -Wl,-single_module -flat_namespace -undefined suppress -Wl,-install_name,$(shlibdir)/vhook/$@'
90cee0c3 741extralibs=""
47930f09 742strip="strip -x"
da186ae2 743installstrip=""
e89b8b0a 744FFLDFLAGS="-Wl,-dynamic,-search_paths_first"
4e159595 745SLIBSUF=".dylib"
f3b60109
DB
746SLIBNAME_WITH_FULLVERSION='$(SLIBPREF)$(NAME).$(LIBVERSION)$(SLIBSUF)'
747SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(NAME).$(LIBMAJOR)$(SLIBSUF)'
c536cb09 748FFSERVERLDFLAGS=-Wl,-bind_at_load
d4596ae3 749LIB_INSTALL_EXTRA_CMD='$(RANLIB) "$(libdir)/$(LIB)"'
90cee0c3 750;;
732d9245 751MINGW32*)
951bf3e6 752# Note: the rest of the mingw32 config is done afterwards as mingw32
29799f8b 753# can be forced on the command line for Linux cross compilation.
732d9245
BE
754mingw32="yes"
755;;
3f027ca7 756CYGWIN*)
b2828252 757targetos=CYGWIN
6bc0e1cf 758shlibdir="$bindir"
9d2a0f1c
MR
759video4linux="no"
760video4linux2="no"
3f027ca7 761audio_oss="yes"
8aa3ee32 762dv1394="no"
07a1b05e 763VHOOKSHFLAGS='-shared -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil'
fbb9d104 764VHOOKLIBS='-lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)'
3f027ca7 765extralibs=""
487c2fad 766EXESUF=".exe"
4581fdff
VP
767SLIBPREF="cyg"
768SLIBSUF=".dll"
769SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
770SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(NAME)-$(LIBMAJOR)$(SLIBSUF)'
771SHFLAGS='-shared -Wl,--out-implib=lib$(NAME).dll.a'
3f027ca7 772;;
b55e4ef4 773Linux)
e240ee67 774LDLATEFLAGS="-Wl,--as-needed $LDLATEFLAGS"
b55e4ef4 775;;
99614dd4 776IRIX*)
b2828252 777targetos=IRIX
99614dd4 778ranlib="echo ignoring ranlib"
9d2a0f1c
MR
779video4linux="no"
780video4linux2="no"
99614dd4
MB
781audio_oss="no"
782make="gmake"
783;;
f3ec2d46
SG
784OS/2)
785TMPE=$TMPE".exe"
3ca4b654 786ar="emxomfar -p128"
69db4e10
SG
787ranlib="echo ignoring ranlib"
788strip="echo ignoring strip"
30a3e5d4 789add_cflags "-Zomf"
e89b8b0a 790FFLDFLAGS="-Zomf -Zstack 16384 -s"
3ca4b654 791SHFLAGS="-Zdll -Zomf"
c536cb09 792FFSERVERLDFLAGS=""
f3ec2d46
SG
793LIBPREF=""
794LIBSUF=".lib"
795SLIBPREF=""
796SLIBSUF=".dll"
951bf3e6 797EXESUF=".exe"
f3ec2d46 798extralibs=""
c99dd233 799pkg_requires=""
9d2a0f1c
MR
800video4linux="no"
801video4linux2="no"
f3ec2d46 802audio_oss="no"
8aa3ee32 803dv1394="no"
f3ec2d46 804ffserver="no"
3ca4b654 805vhook="no"
f3ec2d46 806os2="yes"
b265431e 807os2threads="yes"
f3ec2d46 808;;
b2828252
DB
809*)
810targetos="${targetos}-UNKNOWN"
811;;
ef0bc4c9 812esac
de6d9b64 813
0f3cb305 814# find source path
997baf01 815source_path="`dirname \"$0\"`"
0f3cb305
FB
816source_path_used="yes"
817if test -z "$source_path" -o "$source_path" = "." ; then
997baf01 818 source_path="`pwd`"
0f3cb305 819 source_path_used="no"
e7a4dafb
MR
820else
821 source_path="`cd \"$source_path\"; pwd`"
997baf01
MR
822 echo "$source_path" | grep -q '[[:blank:]]' &&
823 die "Out of tree builds are impossible with whitespace in source path."
de6d9b64
FB
824fi
825
7d6ed4aa
MR
826if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
827 show_help
828fi
829
f255e0ab
MB
830FFMPEG_CONFIGURATION=" "
831for opt do
832 FFMPEG_CONFIGURATION="$FFMPEG_CONFIGURATION""$opt "
833done
834
f3902026
AJ
835ENCODER_LIST=`sed -n 's/^[^#]*ENC.*, *\(.*\)).*/\1_encoder/p' "$source_path/libavcodec/allcodecs.c"`
836DECODER_LIST=`sed -n 's/^[^#]*DEC.*, *\(.*\)).*/\1_decoder/p' "$source_path/libavcodec/allcodecs.c"`
837PARSER_LIST=`sed -n 's/^[^#]*PARSER.*, *\(.*\)).*/\1_parser/p' "$source_path/libavcodec/allcodecs.c"`
5b9b3b68
AJ
838MUXER_LIST=`sed -n 's/^[^#]*_MUX.*, *\(.*\)).*/\1_muxer/p' "$source_path/libavformat/allformats.c"`
839DEMUXER_LIST=`sed -n 's/^[^#]*DEMUX.*, *\(.*\)).*/\1_demuxer/p' "$source_path/libavformat/allformats.c"`
009cf97d 840
a8d04fba
MR
841enable $ENCODER_LIST $DECODER_LIST $PARSER_LIST $MUXER_LIST $DEMUXER_LIST
842
de6d9b64 843for opt do
fce53524 844 optval="${opt#*=}"
de6d9b64 845 case "$opt" in
2ba042a7
MR
846 --log)
847 ;;
fce53524 848 --log=*) logging="$optval"
57bd82d4 849 ;;
e48dc873 850 --prefix=*) PREFIX="$optval"
de6d9b64 851 ;;
e48dc873 852 --libdir=*) libdir="$optval"
cc973ecb 853 ;;
84c22efd
DB
854 --shlibdir=*) shlibdir="$optval"
855 ;;
fce53524 856 --incdir=*) incdir="$optval"
1d67a1d4 857 ;;
fce53524 858 --mandir=*) mandir="$optval"
23a65308 859 ;;
fce53524 860 --source-path=*) source_path="$optval"
0f3cb305 861 ;;
fce53524 862 --cross-prefix=*) cross_prefix="$optval"
0f3cb305 863 ;;
fac252f9
MR
864 --cross-compile) cross_compile=yes
865 ;;
fce53524 866 --cc=*) cc="$optval"
de6d9b64 867 ;;
fce53524 868 --make=*) make="$optval"
4a908fbc 869 ;;
30a3e5d4 870 --extra-cflags=*) add_cflags "$optval"
0f3cb305 871 ;;
28d8e661 872 --extra-ldflags=*) add_ldflags "$optval"
0f3cb305 873 ;;
28d8e661 874 --extra-libs=*) add_extralibs "$optval"
0f3cb305 875 ;;
fce53524 876 --build-suffix=*) BUILDSUF="$optval"
eb94aca9 877 ;;
cc6a90dd 878 --arch=*) arch="$optval"
de6d9b64 879 ;;
38d0a8aa 880 --cpu=*) cpu="$optval"
a4adb608 881 ;;
e45a2872
RD
882 --powerpc-perf-enable) powerpc_perf="yes"
883 ;;
de6d9b64
FB
884 --disable-mmx) mmx="no"
885 ;;
1839e854
SS
886 --disable-armv5te) armv5te="no"
887 ;;
eba9ae3c
GB
888 --disable-iwmmxt) iwmmxt="no"
889 ;;
ab6c65f6
BF
890 --disable-altivec) altivec="no"
891 ;;
de6d9b64
FB
892 --enable-gprof) gprof="yes"
893 ;;
9d2a0f1c 894 --disable-v4l) video4linux="no"
5cbcf02c 895 ;;
9d2a0f1c 896 --disable-v4l2) video4linux2="no"
0a7b514f 897 ;;
6beefa40
MN
898 --disable-bktr) bktr="no"
899 ;;
5cbcf02c
FB
900 --disable-audio-oss) audio_oss="no"
901 ;;
dfdfa47c
FR
902 --disable-audio-beos) audio_beos="no"
903 ;;
8aa3ee32
MK
904 --disable-dv1394) dv1394="no"
905 ;;
ffc0ef96 906 --disable-network) network="no"; ffserver="no"
5cbcf02c 907 ;;
0c7bb0e5
LB
908 --disable-ipv6) ipv6="no";
909 ;;
0147f198
FR
910 --disable-zlib) zlib="no"
911 ;;
ba9261e5 912 --enable-a52) a52="yes"
6ed7422a 913 ;;
bfd2edeb 914 --enable-a52bin) a52bin="yes"
57514323 915 ;;
c99dd233 916 --enable-dts) dts="yes"
23c99253 917 ;;
ba9261e5 918 --enable-pp) pp="yes"
bba9b16c 919 ;;
bb4c2140
MN
920 --enable-libgsm) libgsm="yes"
921 ;;
c99dd233 922 --enable-mp3lame) mp3lame="yes"
a6741398 923 ;;
f956e129
OS
924 --enable-libnut) libnut="yes"
925 ;;
9146ca37 926 --enable-libogg) libogg="yes"
c99dd233 927 pkg_requires="$pkg_requires ogg >= 1.1"
5c5dea3f 928 ;;
be74741c 929 --enable-vorbis) libvorbis="yes"
c99dd233 930 pkg_requires="$pkg_requires vorbis vorbisenc"
81e0d0b4 931 ;;
445ad18d
ZK
932 --enable-faad) faad="yes"
933 ;;
934 --enable-faadbin) faadbin="yes"
935 ;;
c99dd233 936 --enable-faac) faac="yes"
29d48296 937 ;;
1ddadfa9
AT
938 --enable-xvid) xvid="yes"
939 ;;
c99dd233 940 --enable-x264) x264="yes"
6662ec29 941 ;;
8ac17293
SH
942 --enable-avisynth) avisynth="yes";
943 ;;
f02be79d 944 --enable-dc1394) dc1394="yes"
c99dd233 945 pkg_requires="$pkg_requires libraw1394"
f02be79d 946 ;;
68892110
PG
947 --disable-vhook) vhook="no"
948 ;;
732d9245
BE
949 --enable-mingw32) mingw32="yes"
950 ;;
860391a5 951 --enable-mingwce) wince="yes"
ac44871c 952 ;;
320d060a
DB
953 --enable-static) lstatic="yes"
954 ;;
955 --disable-static) lstatic="no"
956 ;;
83286d2a 957 --enable-shared) lshared="yes"
0319c531 958 ;;
320d060a
DB
959 --disable-shared) lshared="no"
960 ;;
cddf3f45
GM
961 --disable-debug) debug="no"
962 ;;
963 --disable-opts) optimize="no"
964 ;;
78fcba8f
MR
965 --enable-extra-warnings) extrawarnings="yes"
966 ;;
1eb2212e
FB
967 --disable-mpegaudio-hp) mpegaudio_hp="no"
968 ;;
04f46ced
GB
969 --disable-protocols) protocols="no"; network="no"; ffserver="no"
970 ;;
786b30af
DB
971 --disable-ffmpeg) ffmpeg="no"
972 ;;
8154d2e0
FB
973 --disable-ffserver) ffserver="no"
974 ;;
a86b921c
FB
975 --disable-ffplay) ffplay="no"
976 ;;
cddf3f45 977 --enable-small) optimize="small"
553a6284 978 ;;
60827a1a 979 --enable-amr_nb) amr="yes"; amr_nb="yes"; amr_nb_fixed="no"
891f64b3 980 ;;
60827a1a 981 --enable-amr_nb-fixed) amr="yes"; amr_nb_fixed="yes"; amr_nb="no"
bc634f6f 982 ;;
60827a1a 983 --enable-amr_wb) amr="yes"; amr_wb="yes"
115329f1 984 ;;
60827a1a 985 --enable-amr_if2) amr="yes"; amr_if2="yes"
2a515c08 986 ;;
bde24d6e 987 --enable-sunmlib) mlib="yes"
f80f7964 988 ;;
9c3d33d6
MN
989 --enable-pthreads) pthreads="yes"
990 ;;
790c9ca7
LA
991 --enable-swscaler) swscaler="yes"
992 ;;
b2e3c528
MN
993 --enable-gpl) gpl="yes"
994 ;;
9ddbcae6 995 --enable-memalign-hack) memalign_hack="yes"
da9b170c 996 ;;
65d1bea2
MB
997 --disable-strip) dostrip="no"
998 ;;
a8d04fba 999 --enable-encoder=*) enable ${optval}_encoder
009cf97d 1000 ;;
a8d04fba 1001 --enable-decoder=*) enable ${optval}_decoder
f593b273 1002 ;;
a8d04fba 1003 --disable-encoder=*) disable ${optval}_encoder
f593b273 1004 ;;
a8d04fba 1005 --disable-decoder=*) disable ${optval}_decoder
009cf97d 1006 ;;
a8d04fba 1007 --disable-encoders) disable $ENCODER_LIST
009cf97d 1008 ;;
a8d04fba 1009 --disable-decoders) disable $DECODER_LIST
b4cad537 1010 ;;
a8d04fba 1011 --enable-muxer=*) enable ${optval}_muxer
a9e35095 1012 ;;
a8d04fba 1013 --disable-muxer=*) disable ${optval}_muxer
ff70e601 1014 ;;
a8d04fba 1015 --disable-muxers) disable $MUXER_LIST; ffserver="no"
ff70e601 1016 ;;
a8d04fba 1017 --enable-demuxer=*) enable ${optval}_demuxer
ff70e601 1018 ;;
a8d04fba 1019 --disable-demuxer=*) disable ${optval}_demuxer
ff70e601 1020 ;;
a8d04fba 1021 --disable-demuxers) disable $DEMUXER_LIST
a9e35095 1022 ;;
a8d04fba 1023 --enable-parser=*) enable ${optval}_parser
af9e7d18 1024 ;;
a8d04fba 1025 --disable-parser=*) disable ${optval}_parser
af9e7d18 1026 ;;
a8d04fba 1027 --disable-parsers) disable $PARSER_LIST
af9e7d18 1028 ;;
74c53c2d
MR
1029 --help) show_help
1030 ;;
b34c63f7
DB
1031 *)
1032 echo "Unknown option \"$opt\"."
1033 echo "See $0 --help for available options."
1034 exit 1
1035 ;;
de6d9b64
FB
1036 esac
1037done
1038
720c69da
MR
1039if test "$logging" != no; then
1040 test "$logging" = yes || logfile="$logging"
57bd82d4
MR
1041 echo "# $0 $@" >$logfile
1042 set >>$logfile
2ba042a7
MR
1043else
1044 logfile=/dev/null
57bd82d4 1045fi
e89b8b0a 1046
860391a5 1047if test "$mingw32" = "yes" -o "$wince" = "yes"; then
e67bcdd9
DB
1048 if test "$lshared" = "yes" && test "$lstatic" = "yes" ; then
1049 cat <<EOF
1050You can only build one library type at once on MinGW.
1051Specify --disable-static --enable-shared to only build
1052the shared libraries. To build only the static libraries
1053you do not need to pass additional options.
1054EOF
1055 exit 1
1056 fi
9d2a0f1c
MR
1057 video4linux="no"
1058 video4linux2="no"
e67bcdd9
DB
1059 bktr="no"
1060 audio_oss="no"
1061 dv1394="no"
1062 dc1394="no"
1063 ffserver="no"
1064 network="no"
b265431e
MR
1065 if enabled mingw32; then
1066 w32threads="yes"
1067 fi
860391a5 1068 if test "$wince" = "yes"; then
e67bcdd9
DB
1069 protocols="no"
1070 fi
e67bcdd9
DB
1071 SLIBPREF=""
1072 SLIBSUF=".dll"
1073 EXESUF=".exe"
d6a07a13
DB
1074 SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
1075 SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(NAME)-$(LIBMAJOR)$(SLIBSUF)'
dfeb80a5 1076 SLIB_EXTRA_CMD="-lib /machine:i386 /def:\$(@:${SLIBSUF}=.def)"
a77caa4d 1077 SHFLAGS="-shared -Wl,--output-def,\$(@:${SLIBSUF}=.def),--out-implib,lib\$(SLIBNAME:\$(SLIBSUF)=.dll.a) -Wl,--enable-runtime-pseudo-reloc"
e67bcdd9
DB
1078fi
1079
28d8e661
DB
1080# Combine FFLDFLAGS and the LDFLAGS environment variable.
1081LDFLAGS="$FFLDFLAGS $LDFLAGS"
e89b8b0a 1082
fac252f9 1083test -n "$cross_prefix" && cross_compile=yes
1ea46bed
MR
1084cc="${cross_prefix}${cc}"
1085ar="${cross_prefix}${ar}"
1086ranlib="${cross_prefix}${ranlib}"
1087strip="${cross_prefix}${strip}"
1088
320d060a
DB
1089# we need to build at least one lib type
1090if test "$lstatic" = "no" && test "$lshared" = "no" ; then
1091 cat <<EOF
1092At least one library type must be built.
1093Specify --enable-static to build the static libraries or --enable-shared to
1094build the shared libraries as well. To only build the shared libraries specify
1095--disable-static in addition to --enable-shared.
1096EOF
1097 exit 1;
1098fi
1099
be74741c 1100if test "$libvorbis" = "yes" ; then
9146ca37 1101 if test "$libogg" = "no"; then
29799f8b 1102 echo "libogg must be enabled to enable Vorbis."
5c5dea3f 1103 fail="yes"
5c5dea3f
NB
1104 fi
1105fi
1106
b2e3c528 1107if test "$gpl" != "yes"; then
ba64106a 1108 if test "$pp" != "no"; then
29799f8b 1109 echo "The Postprocessing code is under GPL and --enable-gpl is not specified."
b2e3c528
MN
1110 fail="yes"
1111 fi
1112
1113 if test "$a52" != "no" -o "$a52bin" != "no"; then
29799f8b 1114 echo "liba52 is under GPL and --enable-gpl is not specified."
b2e3c528
MN
1115 fail="yes"
1116 fi
23c99253 1117
1ddadfa9 1118 if test "$xvid" != "no"; then
29799f8b 1119 echo "libxvidcore is under GPL and --enable-gpl is not specified."
1ddadfa9
AT
1120 fail="yes"
1121 fi
1122
6662ec29 1123 if test "$x264" != "no"; then
29799f8b 1124 echo "x264 is under GPL and --enable-gpl is not specified."
6662ec29
MN
1125 fail="yes"
1126 fi
1127
23c99253 1128 if test "$dts" != "no"; then
29799f8b 1129 echo "libdts is under GPL and --enable-gpl is not specified."
23c99253
MN
1130 fail="yes"
1131 fi
115329f1 1132
b2e3c528 1133 if test "$faad" != "no" -o "$faadbin" != "no"; then
dcd479c0
MR
1134 if check_header faad.h; then
1135 check_cc << EOF
b2e3c528
MN
1136 #include <faad.h>
1137 #ifndef FAAD2_VERSION
1138 ok faad1
1139 #endif
1140 int main( void ) { return 0; }
1141EOF
dcd479c0 1142 if test $? = 0 ; then
29799f8b 1143 echo "FAAD2 is under GPL and --enable-gpl is not specified."
b2e3c528
MN
1144 fail="yes"
1145 fi
1146 else
1147 faad="no"
1148 faadbin="no"
29799f8b 1149 echo "FAAD test failed."
b2e3c528
MN
1150 fi
1151 fi
115329f1 1152
790c9ca7
LA
1153 if test "$swscaler" != "no"; then
1154 echo "The software scaler is under GPL and --enable-gpl is not specified."
1155 fail="yes"
1156 fi
ebb810d9 1157fi
b2e3c528 1158
ebb810d9
RP
1159if test "$fail" = "yes"; then
1160 exit 1
b2e3c528
MN
1161fi
1162
29799f8b 1163# compute MMX state
0f3cb305 1164if test $mmx = "default"; then
419b8784 1165 if test $arch = "x86_32" -o $arch = "x86_64"; then
0f3cb305
FB
1166 mmx="yes"
1167 else
1168 mmx="no"
1169 fi
1170fi
1171
5d323602
MR
1172test -z "$need_memalign" && need_memalign="$mmx"
1173
cf9d24ad 1174#Darwin CC versions
75388c74 1175needmdynamicnopic="no"
cf9d24ad 1176if test $targetos = Darwin; then
b2924696 1177 if test -n "`$cc -v 2>&1 | grep xlc`"; then
30a3e5d4 1178 add_cflags "-qpdf2 -qlanglvl=extc99 -qmaxmem=-1 -qarch=auto -qtune=auto"
cf9d24ad 1179 else
bb270c08
DB
1180 gcc_version="`$cc -v 2>&1 | grep version | cut -d ' ' -f3-`"
1181 case "$gcc_version" in
1182 *2.95*)
30a3e5d4 1183 add_cflags "-no-cpp-precomp -pipe"
bb270c08
DB
1184 ;;
1185 *[34].*)
30a3e5d4 1186 add_cflags "-no-cpp-precomp -pipe -force_cpusubtype_ALL -Wno-sign-compare"
bb270c08
DB
1187 if test "$lshared" = no; then
1188 needmdynamicnopic="yes"
1189 fi
1190 ;;
1191 *)
30a3e5d4 1192 add_cflags "-no-cpp-precomp -pipe"
bb270c08
DB
1193 if test "$lshared" = no; then
1194 needmdynamicnopic="yes"
1195 fi
1196 ;;
1197 esac
cf9d24ad 1198 fi
2a1a6b64
MN
1199fi
1200
1201if test $optimize != "no"; then
1202 add_cflags "-fomit-frame-pointer"
cf9d24ad
DC
1203fi
1204
ab6c65f6
BF
1205# Can only do AltiVec on PowerPC
1206if test $altivec = "default"; then
cc6a90dd 1207 if test $arch = "powerpc"; then
ab6c65f6
BF
1208 altivec="yes"
1209 else
1210 altivec="no"
1211 fi
1212fi
1213
a4adb608 1214# Add processor-specific flags
9007f514 1215POWERPCMODE="32bits"
38d0a8aa
GP
1216if test $cpu != "generic"; then
1217 case $cpu in
bb270c08 1218 601|ppc601|PowerPC601)
1c5d830c 1219 add_cflags "-mcpu=601"
bb270c08
DB
1220 if test $altivec = "yes"; then
1221 echo "WARNING: Tuning for PPC601 but AltiVec enabled!";
1222 fi
bb270c08
DB
1223 ;;
1224 603*|ppc603*|PowerPC603*)
1c5d830c 1225 add_cflags "-mcpu=603"
bb270c08
DB
1226 if test $altivec = "yes"; then
1227 echo "WARNING: Tuning for PPC603 but AltiVec enabled!";
1228 fi
bb270c08
DB
1229 ;;
1230 604*|ppc604*|PowerPC604*)
1c5d830c 1231 add_cflags "-mcpu=604"
bb270c08
DB
1232 if test $altivec = "yes"; then
1233 echo "WARNING: Tuning for PPC604 but AltiVec enabled!";
1234 fi
bb270c08
DB
1235 ;;
1236 G3|g3|75*|ppc75*|PowerPC75*)
1c5d830c 1237 add_cflags "-mcpu=750 -mpowerpc-gfxopt"
bb270c08
DB
1238 if test $altivec = "yes"; then
1239 echo "WARNING: Tuning for PPC75x but AltiVec enabled!";
1240 fi
bb270c08
DB
1241 ;;
1242 G4|g4|745*|ppc745*|PowerPC745*)
1c5d830c 1243 add_cflags "-mcpu=7450 -mpowerpc-gfxopt"
bb270c08
DB
1244 if test $altivec = "no"; then
1245 echo "WARNING: Tuning for PPC745x but AltiVec disabled!";
1246 fi
bb270c08
DB
1247 ;;
1248 74*|ppc74*|PowerPC74*)
1c5d830c 1249 add_cflags "-mcpu=7400 -mpowerpc-gfxopt"
bb270c08
DB
1250 if test $altivec = "no"; then
1251 echo "WARNING: Tuning for PPC74xx but AltiVec disabled!";
1252 fi
bb270c08
DB
1253 ;;
1254 G5|g5|970|ppc970|PowerPC970|power4*|Power4*)
1c5d830c 1255 add_cflags "-mcpu=970 -mpowerpc-gfxopt -mpowerpc64"
bb270c08
DB
1256 if test $altivec = "no"; then
1257 echo "WARNING: Tuning for PPC970 but AltiVec disabled!";
1258 fi
9007f514 1259 POWERPCMODE="64bits"
bb270c08 1260 ;;
e7768fc5
GP
1261 # targets that do NOT support conditional mov (cmov)
1262 i[345]86|pentium|pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
38d0a8aa 1263 add_cflags "-march=$cpu"
e7768fc5
GP
1264 cmov="no"
1265 ;;
1266 # targets that do support conditional mov (cmov)
94e4c3a3 1267 i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64|k8|opteron|athlon-fx)
e7768fc5 1268 add_cflags "-march=$cpu"
4c8d81fa 1269 cmov="yes"
94e4c3a3
GP
1270 cmov_is_fast="yes"
1271 ;;
1272 # targets that do support conditional mov but on which it's slow
1273 pentium4|prescott|nocona)
1274 add_cflags "-march=$cpu"
1275 cmov="yes"
1276 cmov_is_fast="no"
bb270c08 1277 ;;
d7b34d08 1278 sparc64)
1c5d830c 1279 add_cflags "-mcpu=v9"
d7b34d08 1280 ;;
bb270c08 1281 *)
38d0a8aa 1282 echo "WARNING: Unknown CPU \"$cpu\", ignored."
bb270c08 1283 ;;
a4adb608
MN
1284 esac
1285fi
1286
be0d52ab
MR
1287# make sure we can execute files in $TMPDIR
1288cat >$TMPE 2>>$logfile <<EOF
1289#! /bin/sh
1290EOF
1291chmod +x $TMPE >>$logfile 2>&1
1292if ! $TMPE >>$logfile 2>&1; then
1293 cat <<EOF
1294Unable to create and execute files in $TMPDIR1. Set the TMPDIR environment
68300911
DB
1295variable to another directory and make sure that $TMPDIR1 is not mounted
1296noexec.
be0d52ab
MR
1297EOF
1298 die "Sanity test failed."
1299fi
0244f743 1300rm $TMPE
be0d52ab 1301
1a268acc
MR
1302# compiler sanity check
1303check_exec <<EOF
1304int main(){
1305 return 0;
1306}
1307EOF
1308if test "$?" != 0; then
1309 echo "$cc is unable to create an executable file."
1310 if test -z "$cross_prefix" -a "$cross_compile" = no; then
1311 echo "If $cc is a cross-compiler, use the --cross-compile option."
c7ae6345 1312 echo "Only do this if you know what cross compiling means."
1a268acc
MR
1313 fi
1314 die "C compiler test failed."
1315fi
1316
87ea51e0
LB
1317# check for assembler specific support
1318
cc6a90dd 1319if test $arch = "powerpc"; then
87ea51e0
LB
1320check_cc <<EOF && dcbzl=yes
1321int main(void) {
1322 register long zero = 0;
1323 char data[1024];
1324 asm volatile("dcbzl %0, %1" : : "b" (data), "r" (zero));
1325return 0;
1326}
1327EOF
1328fi
1329
57bd82d4
MR
1330# check for SIMD availability
1331
115329f1 1332# AltiVec flags: The FSF version of GCC differs from the Apple version
cc6a90dd 1333if test $arch = "powerpc"; then
b6e52719 1334 if test $altivec = "yes"; then
b2924696 1335 if test -n "`$cc -v 2>&1 | grep version | grep Apple`"; then
30a3e5d4 1336 add_cflags "-faltivec"
b6e52719 1337 else
30a3e5d4 1338 add_cflags "-maltivec -mabi=altivec"
b6e52719
MD
1339 fi
1340 fi
1341fi
1342
0701ca7f 1343check_header altivec.h
a9a07762 1344
29799f8b 1345# check if our compiler supports Motorola AltiVec C API
ab6c65f6 1346if test $altivec = "yes"; then
6e7a01e4 1347 if test $altivec_h = "yes"; then
f25fc9b1
MR
1348 inc_altivec_h="#include <altivec.h>"
1349 else
1350 inc_altivec_h=
1351 fi
1352 check_cc <<EOF || altivec=no
dcd479c0 1353$inc_altivec_h
a9a07762
MN
1354int main(void) {
1355 vector signed int v1, v2, v3;
1356 v1 = vec_add(v2,v3);
1357 return 0;
1358}
1359EOF
1360fi
ab6c65f6 1361
854fdb51 1362# check armv5te instructions support
cc6a90dd 1363if test $armv5te = "default" -a $arch = "armv4l"; then
854fdb51
MR
1364 armv5te=no
1365 check_cc <<EOF && armv5te=yes
1366 int main(void) {
1367 __asm__ __volatile__ ("qadd r0, r0, r0");
1368 }
1369EOF
1370fi
1371
1372# check iwmmxt support
cc6a90dd 1373if test $iwmmxt = "default" -a $arch = "armv4l"; then
854fdb51
MR
1374 iwmmxt=no
1375 check_cc <<EOF && iwmmxt=yes
1376 int main(void) {
1377 __asm__ __volatile__ ("wunpckelub wr6, wr4");
1378 }
1379EOF
1380fi
1381
29799f8b 1382# mmi only available on mips
d46aba26 1383if test $mmi = "default"; then
cc6a90dd 1384 if test $arch = "mips"; then
d46aba26
LS
1385 mmi="yes"
1386 else
1387 mmi="no"
1388 fi
1389fi
1390
29799f8b 1391# check if our compiler supports mmi
57bd82d4 1392enabled mmi && check_cc <<EOF || mmi="no"
d46aba26
LS
1393int main(void) {
1394 __asm__ ("lq \$2, 0(\$2)");
1395 return 0;
1396}
1397EOF
57bd82d4 1398
57bd82d4
MR
1399# ---
1400# big/little-endian test
fac252f9 1401if test "$cross_compile" = "no"; then
57bd82d4 1402 check_ld <<EOF || die "endian test failed" && $TMPE && bigendian="yes"
a3999908
MN
1403#include <inttypes.h>
1404int main(int argc, char ** argv){
bb270c08
DB
1405 volatile uint32_t i=0x01234567;
1406 return (*((uint8_t*)(&i))) == 0x67;
a3999908
MN
1407}
1408EOF
487a54d7 1409else
f25fc9b1 1410 # programs cannot be launched if cross compiling, so make a static guess
cc6a90dd 1411 if test "$arch" = "powerpc" -o "$arch" = "mips" ; then
f25fc9b1
MR
1412 bigendian="yes"
1413 fi
487a54d7
FB
1414fi
1415
a3999908 1416# ---
3d204385
NK
1417# check availability of some header files
1418
0701ca7f
MR
1419check_header malloc.h
1420check_func memalign
3d204385 1421
5d323602
MR
1422if test "$memalign" = "no" -a "$need_memalign" = "yes" -a \
1423 "$memalign_hack" != "yes"; then
57bd82d4 1424 die "Error, no memalign() but SSE enabled, disable it or use --enable-memalign-hack."
8bf5d58f
MN
1425fi
1426
0701ca7f 1427check_header byteswap.h
47d23bbf 1428
0701ca7f
MR
1429check_func inet_aton
1430check_func localtime_r
57bd82d4 1431enabled zlib && check_lib zlib.h zlibVersion -lz || zlib="no"
57bd82d4
MR
1432
1433# check for some common methods of building with pthread support
1434# do this before the optional library checks as some of them require pthreads
1435if enabled pthreads; then
9e7fd101
MR
1436 if check_func pthread_create; then
1437 :
1438 elif check_func pthread_create -pthread; then
1439 add_cflags -pthread
1440 add_ldflags -pthread
1441 elif check_func pthread_create -pthreads; then
1442 add_cflags -pthreads
1443 add_ldflags -pthreads
1444 elif ! check_lib pthread.h pthread_create -lpthread; then
1445 die "ERROR: can't find pthreads library"
1446 fi
57bd82d4
MR
1447fi
1448
1449# these are off by default, so fail if requested and not available
4cbed916 1450enabled dts && require libdts dts.h dts_init -ldts -lm
57bd82d4 1451enabled libgsm && require libgsm gsm.h gsm_create -lgsm
4cbed916 1452enabled mp3lame && require LAME lame/lame.h lame_init -lmp3lame -lm
be74741c 1453enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbis -lvorbisenc -logg
aedf11f8 1454enabled libogg && require libogg ogg/ogg.h ogg_sync_init -logg
4d8aa1c3 1455enabled libnut && require libnut libnut.h nut_demuxer_init -lnut
57bd82d4
MR
1456enabled xvid && require XviD xvid.h xvid_global -lxvidcore
1457enabled x264 && require x264 x264.h x264_encoder_open -lx264
1458enabled dc1394 && require libdc1394 libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394
bde24d6e 1459enabled mlib && require mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
e0f80bd7 1460
3b9bee88
MR
1461# Ugh, faac uses stdcall calling convention on win32 so we can't use
1462# the generic test functions
1463if enabled faac; then
1464 save_flags
1465 temp_extralibs -lfaac
1466 check_ld <<EOF && add_extralibs -lfaac || die "ERROR: libfaac not found"
1467#include <stdint.h>
1468#include <faac.h>
1469int main(){
1470 char *id, *cpr;
1471 faacEncGetVersion(&id, &cpr);
1472 return 0;
1473}
1474EOF
1475 restore_flags
1476fi
1477
87f1c97e
MR
1478# Ugh, recent faad2 versions have renamed all functions and #define the
1479# old names in faad.h. Generic tests won't work.
1480if enabled faad; then
1481 save_flags
1482 temp_extralibs -lfaad
1483 check_ld <<EOF && add_extralibs -lfaad || die "ERROR: libfaad not found"
1484#include <faad.h>
1485int main(){
1486 faacDecOpen();
1487 return 0;
1488}
1489EOF
1490 restore_flags
1491fi
1492
8ac17293
SH
1493# Ugh, avisynth uses WINAPI calls. Generic tests won't work.
1494if enabled avisynth; then
1495 save_flags
1496 temp_extralibs -lvfw32
1497 check_ld <<EOF && add_extralibs -lvfw32 || die "ERROR: vfw32 not found"
1498#include <windows.h>
1499#include <vfw.h>
1500int main(){
1501 AVIFileInit();
1502 return 0;
1503}
1504EOF
1505 restore_flags
1506fi
1507
1508
95e2ce4a 1509# test for lrintf in math.h
fc2b267f 1510check_exec <<EOF && lrintf=yes || lrintf=no
95e2ce4a
MN
1511#define _ISOC9X_SOURCE 1
1512#include <math.h>
1513int main( void ) { return (lrintf(3.999f) > 0)?0:1; }
1514EOF
1515
c13e1abd
FH
1516_restrict=
1517for restrict_keyword in restrict __restrict__ __restrict; do
57bd82d4 1518 check_cc <<EOF && _restrict=$restrict_keyword && break
dcd479c0
MR
1519void foo(char * $restrict_keyword p);
1520EOF
c13e1abd
FH
1521done
1522
a8721c09
FB
1523# dlopen/dlfcn.h probing
1524
0701ca7f 1525check_header dlfcn.h
a8721c09 1526
dcd479c0 1527if check_func dlopen; then
dcd479c0 1528 ldl=
0701ca7f
MR
1529elif check_func dlopen -ldl; then
1530 ldl=-ldl
a8721c09
FB
1531fi
1532
f25fc9b1
MR
1533if test "$vhook" = "default"; then
1534 vhook="$dlopen"
a8721c09
FB
1535fi
1536
22df6d18 1537if enabled_any vhook a52bin faadbin; then
57bd82d4 1538 add_extralibs $ldl
bfd2edeb
MN
1539fi
1540
fbb9d104
VP
1541if test "$targetos" = "CYGWIN" -a "$lstatic" = "yes" ; then
1542 vhook="no"
1543 echo
1544 echo "At the moment vhooks don't work on Cygwin static builds."
1545 echo "Patches welcome."
1546 echo
1547fi
1548
8d923001
MR
1549if enabled vhook; then
1550 check_ldflags -rdynamic
1551 check_ldflags -export-dynamic
1552fi
bfd2edeb 1553
9464f2b8
DB
1554if enabled audio_beos; then
1555 add_extralibs "-lmedia -lbe"
1556fi
1557
a86b921c 1558##########################################
29799f8b 1559# imlib check
a86b921c 1560
dcd479c0
MR
1561temp_extralibs -lImlib2
1562check_ld <<EOF && imlib2=yes || imlib2=no
a8721c09
FB
1563#include <X11/Xlib.h>
1564#include <Imlib2.h>
1565int main( void ) { return (int) imlib_load_font("foo"); }
1566EOF
dcd479c0 1567restore_flags
52b41d7f 1568
a86b921c 1569##########################################
29799f8b 1570# FreeType check
a86b921c 1571
04511d53 1572freetype2=no
e2a5fd20 1573if test "x$targetos" != "xBeOS"; then
e2a3cd59 1574 if (freetype-config --version) >/dev/null 2>&1 ; then
dcd479c0
MR
1575 temp_cflags `freetype-config --cflags`
1576 temp_extralibs `freetype-config --libs`
1577 check_ld <<EOF && freetype2=yes
1578#include <ft2build.h>
1579int main( void ) { return (int) FT_Init_FreeType(0); }
1580EOF
1581 restore_flags
dee076fc 1582 fi
04511d53
PG
1583fi
1584
a86b921c 1585##########################################
29799f8b 1586# SDL check
a86b921c 1587
a86b921c
FB
1588sdl_too_old=no
1589sdl=no
6a1a892f
FD
1590SDL_CONFIG="${cross_prefix}sdl-config"
1591if ("${SDL_CONFIG}" --version) >/dev/null 2>&1 ; then
dcd479c0
MR
1592 temp_cflags `"${SDL_CONFIG}" --cflags`
1593 temp_extralibs `"${SDL_CONFIG}" --libs`
1594 check_ld <<EOF
1595#include <SDL.h>
1596#undef main /* We don't want SDL to override our main() */
1597int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
1598EOF
dcd479c0
MR
1599 if test $? = 0; then
1600 _sdlversion=`"${SDL_CONFIG}" --version | sed 's/[^0-9]//g'`
29f3b38a 1601 if test "$_sdlversion" -lt 121 ; then
dcd479c0
MR
1602 sdl_too_old=yes
1603 else
1604 sdl=yes
29f3b38a
MR
1605 check_cc <<EOF && sdl_video_size=yes || sdl_video_size=no
1606#include <SDL.h>
1607int main(void){
1608 const SDL_VideoInfo *vi = SDL_GetVideoInfo();
1609 int w = vi->current_w;
1610 return 0;
1611}
1612EOF
dcd479c0
MR
1613 fi
1614 fi
29f3b38a 1615 restore_flags
c3f6b472 1616fi
a86b921c 1617
57bd82d4
MR
1618enabled sdl || ffplay=no
1619
146ea952 1620##########################################
29799f8b 1621# texi2html check
146ea952
NB
1622
1623texi2html=no
e2a3cd59 1624if (texi2html -version) >/dev/null 2>&1; then
146ea952
NB
1625texi2html=yes
1626fi
1627
7a91333f 1628##########################################
29799f8b 1629# IPv6 check
7a91333f 1630
0c7bb0e5 1631enabled network && enabled ipv6 && check_ld <<EOF && ipv6=yes || ipv6=no
7a91333f
HZ
1632#include <sys/types.h>
1633#include <sys/socket.h>
1634#include <netinet/in.h>
1635#include <netdb.h>
1636int main( void ) {
1637 struct sockaddr_storage saddr;
1638 struct ipv6_mreq mreq6;
1639 getaddrinfo(0,0,0,0);
1640 getnameinfo(0,0,0,0,0,0,0);
12fe88b4 1641 IN6_IS_ADDR_MULTICAST((const struct in6_addr *)0);
7a91333f
HZ
1642}
1643EOF
1644
47f38850 1645# check for video4linux2 --- V4L2_PIX_FMT_YUV420
9d2a0f1c 1646enabled video4linux2 && check_cc <<EOF || video4linux2="no"
84fe9963 1647#include <sys/time.h>
f743a062
LA
1648#include <asm/types.h>
1649#include <linux/videodev2.h>
47f38850 1650int dummy = V4L2_PIX_FMT_YUV420;
490c189b 1651struct v4l2_buffer dummy1;
47f38850 1652EOF
47f38850 1653
57bd82d4
MR
1654enabled debug && add_cflags -g
1655
1656# add some useful compiler flags if supported
1657check_cflags -Wdeclaration-after-statement
dcd479c0
MR
1658check_cflags -Wall
1659check_cflags -Wno-switch
c07bd6a9
MN
1660check_cflags -Wdisabled-optimization
1661check_cflags -Wpointer-arith
1662check_cflags -Wredundant-decls
78fcba8f 1663enabled extrawarnings && check_cflags -Winline
cf9d24ad 1664
57bd82d4 1665# add some linker flags
e240ee67 1666check_ldflags $LDLATEFLAGS
94a3401e 1667
57bd82d4
MR
1668# not all compilers support -Os
1669test "$optimize" = "small" && check_cflags -Os
cddf3f45 1670
57bd82d4 1671if enabled optimize; then
b2924696 1672 if test -n "`$cc -v 2>&1 | grep xlc`"; then
30a3e5d4
NP
1673 add_cflags "-O5"
1674 add_ldflags "-O5"
cf9d24ad 1675 else
30a3e5d4 1676 add_cflags "-O3"
cf9d24ad 1677 fi
cddf3f45
GM
1678fi
1679
80581e98
MN
1680# PIC flags for shared library objects where they are needed
1681if test "$lshared" = "yes" ; then
f25fc9b1
MR
1682 # LIBOBJFLAGS may have already been set in the OS configuration
1683 if test -z "$LIBOBJFLAGS" ; then
cc6a90dd 1684 case "$arch" in
813457e5
MR
1685 x86_64|ia64|alpha|sparc*) LIBOBJFLAGS="\$(PIC)" ;;
1686 esac
80581e98 1687 fi
80581e98
MN
1688fi
1689
1db54e20 1690if test "$gprof" = "yes" ; then
30a3e5d4
NP
1691 add_cflags "-p"
1692 add_ldflags "-p"
1db54e20
DB
1693fi
1694
18451f7d
MR
1695VHOOKCFLAGS="-fPIC $CFLAGS"
1696test "$needmdynamicnopic" = yes && add_cflags -mdynamic-no-pic
1697
4454dc1b
JD
1698# find if .align arg is power-of-two or not
1699if test $asmalign_pot = "unknown"; then
1700 asmalign_pot="no"
1701 echo 'asm (".align 3");' | check_cc && asmalign_pot="yes"
1702fi
1703
2266e085 1704echo "install prefix $PREFIX"
29799f8b 1705echo "source path $source_path"
de6d9b64 1706echo "C compiler $cc"
4a908fbc 1707echo "make $make"
38d0a8aa 1708echo "ARCH $arch ($cpu)"
eb94aca9 1709if test "$BUILDSUF" != ""; then
f25fc9b1 1710 echo "build suffix $BUILDSUF"
eb94aca9 1711fi
29799f8b 1712echo "big-endian $bigendian"
419b8784 1713if test $arch = "x86_32" -o $arch = "x86_64"; then
f25fc9b1 1714 echo "MMX enabled $mmx"
e7768fc5 1715 echo "CMOV enabled $cmov"
94e4c3a3 1716 echo "CMOV is fast $cmov_is_fast"
e41e8342 1717fi
cc6a90dd 1718if test $arch = "armv4l"; then
1839e854 1719 echo "ARMv5TE enabled $armv5te"
f25fc9b1 1720 echo "IWMMXT enabled $iwmmxt"
eba9ae3c 1721fi
cc6a90dd 1722if test $arch = "mips"; then
f25fc9b1 1723 echo "MMI enabled $mmi"
e41e8342 1724fi
cc6a90dd 1725if test $arch = "powerpc"; then
f25fc9b1 1726 echo "AltiVec enabled $altivec"
87ea51e0 1727 echo "dcbzl available $dcbzl"
e41e8342 1728fi
de6d9b64 1729echo "gprof enabled $gprof"
0147f198 1730echo "zlib enabled $zlib"
bb4c2140 1731echo "libgsm enabled $libgsm"
a6741398 1732echo "mp3lame enabled $mp3lame"
f956e129 1733echo "libnut enabled $libnut"
9146ca37 1734echo "libogg enabled $libogg"
be74741c 1735echo "Vorbis enabled $libvorbis"
29799f8b 1736echo "FAAD enabled $faad"
445ad18d 1737echo "faadbin enabled $faadbin"
29799f8b
DB
1738echo "FAAC enabled $faac"
1739echo "XviD enabled $xvid"
6662ec29 1740echo "x264 enabled $x264"
5cbcf02c 1741echo "a52 support $a52"
57514323 1742echo "a52 dlopened $a52bin"
29799f8b 1743echo "DTS support $dts"
bba9b16c 1744echo "pp support $pp"
790c9ca7 1745echo "Software Scaler enabled $swscaler"
8ac17293 1746echo "AVISynth enabled $avisynth"
cddf3f45 1747echo "debug symbols $debug"
65d1bea2 1748echo "strip symbols $dostrip"
cddf3f45 1749echo "optimize $optimize"
320d060a 1750echo "static $lstatic"
1ddf5ba1 1751echo "shared $lshared"
29799f8b 1752echo "video hooking $vhook"
a86b921c
FB
1753echo "SDL support $sdl"
1754if test $sdl_too_old = "yes"; then
f25fc9b1 1755 echo "-> Your SDL version is too old - please upgrade to have FFplay/SDL support."
a86b921c 1756fi
68892110 1757
f25fc9b1
MR
1758if test "$vhook" = "yes"; then
1759 echo "Imlib2 support $imlib2"
1760 echo "FreeType support $freetype2"
68892110 1761fi
bde24d6e 1762echo "Sun medialib support" $mlib
9c3d33d6 1763echo "pthreads support" $pthreads
bc634f6f
ZK
1764echo "AMR-NB float support" $amr_nb
1765echo "AMR-NB fixed support" $amr_nb_fixed
d663a1fd 1766echo "AMR-WB float support" $amr_wb
2a515c08 1767echo "AMR-WB IF2 support" $amr_if2
7a91333f
HZ
1768echo "network support $network"
1769if test "$network" = "yes" ; then
f25fc9b1 1770 echo "IPv6 support $ipv6"
7a91333f 1771fi
4454dc1b 1772echo ".align is power-of-two" $asmalign_pot
b2e3c528 1773if test "$gpl" = "no" ; then
f25fc9b1 1774 echo "License: LGPL"
b2e3c528 1775else
f25fc9b1 1776 echo "License: GPL"
b2e3c528 1777fi
de6d9b64 1778
29799f8b 1779echo "Creating config.mak and config.h..."
de6d9b64 1780
29799f8b
DB
1781echo "# Automatically generated by configure - do not modify!" > config.mak
1782echo "/* Automatically generated by configure - do not modify! */" > $TMPH
f255e0ab 1783echo "#define FFMPEG_CONFIGURATION "'"'"$FFMPEG_CONFIGURATION"'"' >> $TMPH
de6d9b64 1784
2266e085
DB
1785echo "PREFIX=$PREFIX" >> config.mak
1786echo "prefix=\$(DESTDIR)\${PREFIX}" >> config.mak
9a695e98 1787echo "libdir=\$(DESTDIR)$libdir" >> config.mak
84c22efd 1788echo "shlibdir=\$(DESTDIR)$shlibdir" >> config.mak
1d67a1d4 1789echo "incdir=\$(DESTDIR)$incdir" >> config.mak
9a695e98
DB
1790echo "bindir=\$(DESTDIR)$bindir" >> config.mak
1791echo "mandir=\$(DESTDIR)$mandir" >> config.mak
4a908fbc 1792echo "MAKE=$make" >> config.mak
980fc7b8
FB
1793echo "CC=$cc" >> config.mak
1794echo "AR=$ar" >> config.mak
be7109c1 1795echo "RANLIB=$ranlib" >> config.mak
65d1bea2 1796if test "$dostrip" = "yes" ; then
f25fc9b1
MR
1797 echo "STRIP=$strip" >> config.mak
1798 echo "INSTALLSTRIP=$installstrip" >> config.mak
65d1bea2 1799else
f25fc9b1
MR
1800 echo "STRIP=echo ignoring strip" >> config.mak
1801 echo "INSTALLSTRIP=" >> config.mak
65d1bea2 1802fi
75388c74 1803
a9b3f630 1804echo "OPTFLAGS=$CFLAGS" >> config.mak
408382a4 1805echo "VHOOKCFLAGS=$VHOOKCFLAGS">>config.mak
0f3cb305 1806echo "LDFLAGS=$LDFLAGS" >> config.mak
f39e56a8 1807echo "LDCONFIG=$LDCONFIG" >> config.mak
c536cb09 1808echo "FFSERVERLDFLAGS=$FFSERVERLDFLAGS" >> config.mak
e1707f52 1809echo "SHFLAGS=$SHFLAGS" >> config.mak
408382a4 1810echo "VHOOKSHFLAGS=$VHOOKSHFLAGS" >> config.mak
fbb9d104 1811echo "VHOOKLIBS=$VHOOKLIBS" >> config.mak
80581e98 1812echo "LIBOBJFLAGS=$LIBOBJFLAGS" >> config.mak
b12f8273 1813echo "BUILD_STATIC=$lstatic" >> config.mak
eb94aca9 1814echo "BUILDSUF=$BUILDSUF" >> config.mak
f3ec2d46 1815echo "LIBPREF=$LIBPREF" >> config.mak
eb94aca9 1816echo "LIBSUF=\${BUILDSUF}$LIBSUF" >> config.mak
320d060a
DB
1817if test "$lstatic" = "yes" ; then
1818 echo "LIB=$LIB" >> config.mak
1a44a8b6
AS
1819else # Some Make complain if this variable does not exist.
1820 echo "LIB=" >> config.mak
320d060a 1821fi
f3ec2d46 1822echo "SLIBPREF=$SLIBPREF" >> config.mak
eb94aca9
CY
1823echo "SLIBSUF=\${BUILDSUF}$SLIBSUF" >> config.mak
1824echo "EXESUF=\${BUILDSUF}$EXESUF" >> config.mak
b2828252 1825echo "TARGET_OS=$targetos" >> config.mak
4dc62701
MR
1826
1827ucarch=`toupper $arch`
1828echo "TARGET_ARCH_${ucarch}=yes" >> config.mak
1829echo "#define ARCH_${ucarch} 1" >> $TMPH
1830
1831# special cases
1832case "$arch" in
1833 x86_32|x86_64)
1834 echo "TARGET_ARCH_X86=yes" >> config.mak
1835 echo "#define ARCH_X86 1" >> $TMPH
1836 ;;
1837 powerpc)
1838 if test "$POWERPCMODE" = "64bits"; then
1839 echo "#define POWERPC_MODE_64BITS 1" >> $TMPH
1840 fi
1841 if test "$powerpc_perf" = "yes"; then
1842 echo "#define POWERPC_PERFORMANCE_REPORT 1" >> $TMPH
1843 fi
1844 ;;
1845 sparc64)
1846 echo "TARGET_ARCH_SPARC=yes" >> config.mak
1847 echo "#define ARCH_SPARC 1" >> $TMPH
1848 ;;
1849esac
1850
0f3cb305
FB
1851if test "$bigendian" = "yes" ; then
1852 echo "WORDS_BIGENDIAN=yes" >> config.mak
1853 echo "#define WORDS_BIGENDIAN 1" >> $TMPH
91d1f1a4 1854fi
57514323 1855if test "$mmx" = "yes" ; then
980fc7b8 1856 echo "TARGET_MMX=yes" >> config.mak
045ed63f 1857 echo "#define HAVE_MMX 1" >> $TMPH
e82c5a8c 1858 echo "#define __CPU__ 586" >> $TMPH
de6d9b64 1859fi
e7768fc5
GP
1860if test "$cmov" = "yes" ; then
1861 echo "TARGET_CMOV=yes" >> config.mak
1862 echo "#define HAVE_CMOV 1" >> $TMPH
1863fi
94e4c3a3
GP
1864if test "$cmov_is_fast" = "yes" ; then
1865 echo "TARGET_CMOV_IS_FAST=yes" >> config.mak
1866 echo "#define CMOV_IS_FAST 1" >> $TMPH
1867fi
1839e854
SS
1868if test "$armv5te" = "yes" ; then
1869 echo "TARGET_ARMV5TE=yes" >> config.mak
1870 echo "#define HAVE_ARMV5TE 1" >> $TMPH
1871fi
eba9ae3c
GB
1872if test "$iwmmxt" = "yes" ; then
1873 echo "TARGET_IWMMXT=yes" >> config.mak
1874 echo "#define HAVE_IWMMXT 1" >> $TMPH
1875fi
d46aba26
LS
1876if test "$mmi" = "yes" ; then
1877 echo "TARGET_MMI=yes" >> config.mak
1878 echo "#define HAVE_MMI 1" >> $TMPH
1879fi
87ea51e0 1880
ab6c65f6
BF
1881if test "$altivec" = "yes" ; then
1882 echo "TARGET_ALTIVEC=yes" >> config.mak
1883 echo "#define HAVE_ALTIVEC 1" >> $TMPH
f80f7964 1884fi
44161118 1885
a86b921c 1886if test "$sdl" = "yes" ; then
6a1a892f
FD
1887 echo "SDL_LIBS=`"${SDL_CONFIG}" --libs`" >> config.mak
1888 echo "SDL_CFLAGS=`"${SDL_CONFIG}" --cflags`" >> config.mak
a86b921c 1889fi
146ea952
NB
1890if test "$texi2html" = "yes"; then
1891 echo "BUILD_DOC=yes" >> config.mak
1892fi
5a872801 1893
790c9ca7 1894sws_version=`grep '#define LIBSWSCALE_VERSION ' "$source_path/libswscale/swscale.h" | sed 's/[^0-9\.]//g'`
6d9a2421 1895pp_version=`grep '#define LIBPOSTPROC_VERSION ' "$source_path/libpostproc/postprocess.h" | sed 's/[^0-9\.]//g'`
5a872801
LB
1896lavc_version=`grep '#define LIBAVCODEC_VERSION ' "$source_path/libavcodec/avcodec.h" | sed 's/[^0-9\.]//g'`
1897lavf_version=`grep '#define LIBAVFORMAT_VERSION ' "$source_path/libavformat/avformat.h" | sed 's/[^0-9\.]//g'`
1898lavu_version=`grep '#define LIBAVUTIL_VERSION ' "$source_path/libavutil/avutil.h" | sed 's/[^0-9\.]//g'`
1899
1900
1901
57514323 1902if test "$lshared" = "yes" ; then
0319c531 1903 echo "BUILD_SHARED=yes" >> config.mak
97006039 1904 echo "PIC=-fPIC -DPIC" >> config.mak
39503a27 1905 echo "SPPMAJOR=${lavc_version%%.*}" >> config.mak
5a872801 1906 echo "SPPVERSION=$lavc_version" >> config.mak
39503a27 1907 echo "LAVCMAJOR=${lavc_version%%.*}" >> config.mak
5a872801 1908 echo "LAVCVERSION=$lavc_version" >> config.mak
39503a27 1909 echo "LAVFMAJOR=${lavf_version%%.*}" >> config.mak
5a872801 1910 echo "LAVFVERSION=$lavf_version" >> config.mak
39503a27 1911 echo "LAVUMAJOR=${lavu_version%%.*}" >> config.mak
5a872801 1912 echo "LAVUVERSION=$lavu_version" >> config.mak
790c9ca7
LA
1913 echo "SWSMAJOR=${sws_version%%.*}" >> config.mak
1914 echo "SWSVERSION=$sws_version" >> config.mak
4bdd05e7 1915 echo "SLIBNAME=${SLIBNAME}" >> config.mak
f3b60109
DB
1916 echo "SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}" >> config.mak
1917 echo "SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}" >> config.mak
5cb854e1 1918 echo "SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}" >> config.mak
0319c531 1919fi
d7e27559 1920echo "LIB_INSTALL_EXTRA_CMD=${LIB_INSTALL_EXTRA_CMD}" >> config.mak
ef0bc4c9 1921echo "EXTRALIBS=$extralibs" >> config.mak
d2845d68 1922
44161118
MR
1923enabled_any $ENCODER_LIST && enable encoders
1924enabled_any $DECODER_LIST && enable decoders
1925enabled_any $MUXER_LIST && enable muxers
1926enabled_any $DEMUXER_LIST && enable demuxers
f956e129 1927
b265431e
MR
1928enabled_any pthreads beosthreads os2threads w32threads && enable threads
1929
44161118
MR
1930print_config HAVE_ $TMPH config.mak $HAVE_LIST
1931print_config CONFIG_ $TMPH config.mak $CONFIG_LIST
8ac17293 1932
b2828252 1933if test "$targetos" = "Darwin"; then
90cee0c3 1934 echo "#define CONFIG_DARWIN 1" >> $TMPH
90cee0c3
MN
1935fi
1936
c13e1abd
FH
1937echo "#define restrict $_restrict" >> $TMPH
1938
bb801c97
MN
1939if test "$optimize" = "small"; then
1940 echo "#define always_inline" >> $TMPH
e5f28e8f 1941 echo "#define CONFIG_SMALL 1" >> $TMPH
bb801c97
MN
1942fi
1943
997baf01
MR
1944echo "SRC_PATH=\"$source_path\"" >> config.mak
1945echo "SRC_PATH_BARE=$source_path" >> config.mak
1946echo "BUILD_ROOT=\"$PWD\"" >> config.mak
0f3cb305 1947
2a515c08
TM
1948if test "$amr_if2" = "yes" ; then
1949 echo "AMR_CFLAGS=-DIF2=1" >> config.mak
1950fi
1951
8156056e 1952# Apparently it's not possible to portably echo a backslash.
4454dc1b 1953if test "$asmalign_pot" = "yes" ; then
8156056e 1954 printf '#define ASMALIGN(ZEROBITS) ".align " #ZEROBITS "\\n\\t"\n' >> $TMPH
4454dc1b 1955else
8156056e 1956 printf '#define ASMALIGN(ZEROBITS) ".align 1<<" #ZEROBITS "\\n\\t"\n' >> $TMPH
4454dc1b
JD
1957fi
1958
bc634f6f 1959
55006fc0 1960for codec in $DECODER_LIST $ENCODER_LIST $PARSER_LIST $DEMUXER_LIST $MUXER_LIST; do
44161118 1961 ucname="`toupper $codec`"
a8d04fba
MR
1962 config_name="CONFIG_$ucname"
1963 enabled_name="ENABLE_$ucname"
1964 if enabled $codec; then
1965 echo "#define $config_name 1" >> $TMPH
1966 echo "#define $enabled_name 1" >> $TMPH
1967 echo "$config_name=yes" >> config.mak
1968 else
1969 echo "#define $enabled_name 0" >> $TMPH
1970 fi
009cf97d
MN
1971done
1972
9cb2cf10 1973# Do not overwrite config.h if unchanged to avoid superfluous rebuilds.
c683a5d1 1974if ! cmp -s $TMPH config.h; then
9cb2cf10
DB
1975 mv -f $TMPH config.h
1976else
1977 echo "config.h is unchanged"
1978fi
3d204385 1979
f3ec2d46 1980rm -f $TMPO $TMPC $TMPE $TMPS $TMPH
def4272a 1981
165af439
MR
1982# build tree in object directory if source path is different from current one
1983if test "$source_path_used" = "yes" ; then
1984 DIRS="\
1985 doc \
1986 libavformat \
1987 libavcodec \
1988 libavcodec/alpha \
1989 libavcodec/armv4l \
1990 libavcodec/bfin \
1991 libavcodec/i386 \
1992 libavcodec/sparc \
1993 libavcodec/mlib \
1994 libavcodec/ppc \
1995 libavcodec/liba52 \
1996 libpostproc \
1997 libavutil \
1998 libswscale \
1999 tests \
2000 vhook \
2001 "
2002 FILES="\
2003 Makefile \
2004 common.mak \
2005 libavformat/Makefile \
2006 libavcodec/Makefile \
2007 libpostproc/Makefile \
2008 libavutil/Makefile \
2009 libswscale/Makefile \
2010 tests/Makefile \
2011 vhook/Makefile \
2012 doc/Makefile \
2013 doc/texi2pod.pl \
2014 "
2015 for dir in $DIRS ; do
2016 mkdir -p $dir
2017 done
2018 for f in $FILES ; do
2019 ln -sf "$source_path/$f" $f
2020 done
2021fi
def4272a 2022
29799f8b 2023# build pkg-config files libav*.pc and libpostproc.pc
31abdc45 2024# libavutil.pc
2025cat <<EOF >libavutil.pc
2266e085 2026prefix=$PREFIX
a94e666c 2027exec_prefix=\${prefix}
31abdc45 2028libdir=\${exec_prefix}/lib
a94e666c 2029includedir=\${prefix}/include
31abdc45 2030
2031Name: libavutil
2032Description: FFmpeg utility library
2033Version: $lavu_version
115329f1 2034Requires:
31abdc45 2035Conflicts:
2036Libs: -L\${libdir} -lavutil
2037Cflags: -I\${includedir} -I\${includedir}/ffmpeg
2038EOF
2039
2040cat <<EOF >libavutil-uninstalled.pc
2041prefix=
2042exec_prefix=
2043libdir=\${pcfiledir}/libavutil
2044includedir=\${pcfiledir}/libavutil
2045
2046Name: libavutil
2047Description: FFmpeg utility library
2048Version: $lavu_version
115329f1 2049Requires:
31abdc45 2050Conflicts:
2051Libs: \${libdir}/${LIBPREF}avutil${LIBSUF}
2052Cflags: -I\${includedir}
2053EOF
def4272a
AJ
2054
2055# libavcodec.pc
2056cat <<EOF >libavcodec.pc
2266e085 2057prefix=$PREFIX
a94e666c 2058exec_prefix=\${prefix}
def4272a 2059libdir=\${exec_prefix}/lib
a94e666c 2060includedir=\${prefix}/include
def4272a
AJ
2061
2062Name: libavcodec
2063Description: FFmpeg codec library
31abdc45 2064Version: $lavc_version
c99dd233 2065Requires: $pkg_requires libavutil = $lavu_version
def4272a
AJ
2066Conflicts:
2067Libs: -L\${libdir} -lavcodec $extralibs
2068Cflags: -I\${includedir} -I\${includedir}/ffmpeg
2069EOF
2070
2071cat <<EOF >libavcodec-uninstalled.pc
2072prefix=
2073exec_prefix=
2074libdir=\${pcfiledir}/libavcodec
2075includedir=\${pcfiledir}/libavcodec
2076
2077Name: libavcodec
2078Description: FFmpeg codec library
31abdc45 2079Version: $lavc_version
c99dd233 2080Requires: $pkg_requires libavutil = $lavu_version
def4272a
AJ
2081Conflicts:
2082Libs: \${libdir}/${LIBPREF}avcodec${LIBSUF} $extralibs
2083Cflags: -I\${includedir}
2084EOF
2085
2086# libavformat.pc
2087cat <<EOF >libavformat.pc
2266e085 2088prefix=$PREFIX
a94e666c 2089exec_prefix=\${prefix}
def4272a 2090libdir=\${exec_prefix}/lib
a94e666c 2091includedir=\${prefix}/include
def4272a
AJ
2092
2093Name: libavformat
2094Description: FFmpeg container format library
31abdc45 2095Version: $lavf_version
c99dd233 2096Requires: $pkg_requires libavcodec = $lavc_version
def4272a
AJ
2097Conflicts:
2098Libs: -L\${libdir} -lavformat $extralibs
2099Cflags: -I\${includedir} -I\${includedir}/ffmpeg
2100EOF
2101
2102cat <<EOF >libavformat-uninstalled.pc
2103prefix=
2104exec_prefix=
2105libdir=\${pcfiledir}/libavformat
2106includedir=\${pcfiledir}/libavformat
2107
2108Name: libavformat
2109Description: FFmpeg container format library
31abdc45 2110Version: $lavf_version
c99dd233 2111Requires: $pkg_requires libavcodec = $lavc_version
def4272a
AJ
2112Conflicts:
2113Libs: \${libdir}/${LIBPREF}avformat${LIBSUF} $extralibs
2114Cflags: -I\${includedir}
2115EOF
2116
2117
2118# libpostproc.pc
2119cat <<EOF >libpostproc.pc
2266e085 2120prefix=$PREFIX
a94e666c 2121exec_prefix=\${prefix}
def4272a 2122libdir=\${exec_prefix}/lib
a94e666c 2123includedir=\${prefix}/include
def4272a
AJ
2124
2125Name: libpostproc
2126Description: FFmpeg post processing library
31abdc45 2127Version: $lavc_version
115329f1 2128Requires:
def4272a
AJ
2129Conflicts:
2130Libs: -L\${libdir} -lpostproc
2131Cflags: -I\${includedir} -I\${includedir}/postproc
2132EOF
2133
2134cat <<EOF >libpostproc-uninstalled.pc
2135prefix=
2136exec_prefix=
6d9a2421
DB
2137libdir=\${pcfiledir}/libpostproc
2138includedir=\${pcfiledir}/libpostproc
def4272a
AJ
2139
2140Name: libpostproc
2141Description: FFmpeg post processing library
31abdc45 2142Version: $lavc_version
115329f1 2143Requires:
def4272a
AJ
2144Conflicts:
2145Libs: \${libdir}/${LIBPREF}postproc${LIBSUF}
2146Cflags: -I\${includedir}
2147EOF
790c9ca7 2148
6c0d0413 2149if test "$swscaler" != "no"; then
2150 sws_pc_libs="-L\${libdir} -lswscale"
2151 sws_pc_uninstalled_libs="\${libdir}/${LIBPREF}swscale${LIBSUF}"
2152 sws_pc_requires="$pkg_requires libavutil = $lavu_version"
2153else
2154 sws_pc_libs=""
2155 sws_pc_uninstalled_libs=""
2156 sws_pc_requires="$pkg_requires libavcodec = $lavc_version"
2157fi
790c9ca7
LA
2158# libswscale.pc
2159cat <<EOF >libswscale.pc
2160prefix=$PREFIX
2161exec_prefix=\${prefix}
2162libdir=\${exec_prefix}/lib
2163includedir=\${prefix}/include
2164
2165Name: libswscale
2166Description: FFmpeg image rescaling library
2167Version: $sws_version
6c0d0413 2168Requires: $sws_pc_requires
790c9ca7 2169Conflicts:
6c0d0413 2170Libs: $sws_pc_libs
790c9ca7
LA
2171Cflags: -I\${includedir} -I\${includedir}/swscale
2172EOF
2173
2174cat <<EOF >libswscale-uninstalled.pc
2175prefix=
2176exec_prefix=
2177libdir=\${pcfiledir}/libswscale
2178includedir=\${pcfiledir}/libswscale
2179
2180Name: libswscale
2181Description: FFmpeg image rescaling library
2182Version: $sws_version
6c0d0413 2183Requires: $sws_pc_requires
790c9ca7 2184Conflicts:
6c0d0413 2185Libs: $sws_pc_uninstalled_libs
790c9ca7
LA
2186Cflags: -I\${includedir}
2187EOF