fixed one overflow problem
[libav.git] / configure
CommitLineData
de6d9b64 1#!/bin/sh
0f3cb305
FB
2#
3# ffmpeg configure script (c) 2000, 2001, 2002 Gerard Lantau
4#
5# set temporary file name
57514323 6if test ! -z "$TMPDIR" ; then
0f3cb305 7 TMPDIR1="${TMPDIR}"
57514323 8elif test ! -z "$TEMPDIR" ; then
0f3cb305 9 TMPDIR1="${TEMPDIR}"
3d204385 10else
0f3cb305 11 TMPDIR1="/tmp"
3d204385
NK
12fi
13
0f3cb305
FB
14TMPC="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.c"
15TMPO="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.o"
16TMPS="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.S"
17TMPH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.h"
18
de6d9b64
FB
19# default parameters
20prefix="/usr/local"
0f3cb305 21cross_prefix=""
de6d9b64
FB
22cc="gcc"
23ar="ar"
0f3cb305 24strip="strip"
de6d9b64 25cpu=`uname -m`
0f3cb305 26mmx="default"
de6d9b64 27case "$cpu" in
ef0bc4c9 28 i386|i486|i586|i686|i86pc|BePC)
de6d9b64 29 cpu="x86"
de6d9b64 30 ;;
6ed7422a
FB
31 armv4l)
32 cpu="armv4l"
6ed7422a 33 ;;
91d1f1a4
NK
34 alpha)
35 cpu="alpha"
91d1f1a4 36 ;;
de6d9b64 37 *)
0f3cb305 38 cpu="unknown"
de6d9b64
FB
39 ;;
40esac
41gprof="no"
6ed7422a 42grab="yes"
a6741398 43mp3lame="no"
57514323 44a52bin="no"
daf8e955 45win32="no"
83286d2a 46lshared="no"
ef0bc4c9 47extralibs="-lm"
c02dbee1 48simpleidct="yes"
0f3cb305 49bigendian="no"
ef0bc4c9
FR
50
51# OS specific
52targetos=`uname -s`
53case $targetos in
54BeOS)
55prefix="/boot/home/config"
56# helps building libavcodec
57grab="no"
58CFLAGS="-O2 -DPIC"
59# no need for libm, but the inet stuff
60# Check for BONE
61if (echo $BEINCLUDES|grep 'headers/be/bone' >/dev/null); then
62extralibs="-lbind -lsocket"
63else
64echo "Not sure building for net_server will succeed... good luck."
65extralibs="-lsocket"
66fi ;;
67*) ;;
68esac
de6d9b64 69
0f3cb305
FB
70# find source path
71# XXX: we assume an absolute path is given when launching configure,
72# except in './configure' case.
73source_path=${0%configure}
74source_path=${source_path%/}
75source_path_used="yes"
76if test -z "$source_path" -o "$source_path" = "." ; then
77 source_path=`pwd`
78 source_path_used="no"
de6d9b64
FB
79fi
80
81for opt do
82 case "$opt" in
83 --prefix=*) prefix=`echo $opt | cut -d '=' -f 2`
84 ;;
0f3cb305
FB
85 --source-path=*) source_path=`echo $opt | cut -d '=' -f 2`
86 ;;
87 --cross-prefix=*) cross_prefix=`echo $opt | cut -d '=' -f 2`
88 ;;
de6d9b64
FB
89 --cc=*) cc=`echo $opt | cut -d '=' -f 2`
90 ;;
0f3cb305
FB
91 --extra-cflags=*) CFLAGS="${opt#--extra-cflags=}"
92 ;;
93 --extra-ldflags=*) LDFLAGS=${opt#--extra-ldflags=}
94 ;;
95 --extra-libs=*) extralibs=${opt#--extra-libs=}
96 ;;
de6d9b64
FB
97 --cpu=*) cpu=`echo $opt | cut -d '=' -f 2`
98 ;;
99 --disable-mmx) mmx="no"
100 ;;
101 --enable-gprof) gprof="yes"
102 ;;
6ed7422a
FB
103 --disable-grab) grab="no"
104 ;;
57514323
ZK
105 --enable-a52bin) a52bin="yes" ; extralibs="-ldl $extralibs"
106 ;;
a6741398
J
107 --enable-mp3lame) mp3lame="yes"
108 ;;
c02dbee1 109 --disable-simple_idct) simpleidct="no"
045ed63f 110 ;;
daf8e955
FB
111 --enable-win32) win32="yes"
112 ;;
83286d2a 113 --enable-shared) lshared="yes"
0319c531 114 ;;
de6d9b64
FB
115 esac
116done
117
0f3cb305
FB
118# compute mmx state
119if test $mmx = "default"; then
120 if test $cpu = "x86"; then
121 mmx="yes"
122 else
123 mmx="no"
124 fi
125fi
126
daf8e955
FB
127# Checking for CFLAGS
128if test -z "$CFLAGS"; then
129 CFLAGS="-O2"
130fi
131
57514323 132if test "$win32" = "yes" ; then
daf8e955 133 cross_prefix="i386-mingw32msvc-"
daf8e955
FB
134 grab="no"
135fi
136
0f3cb305
FB
137# endianness : guess with cpu type. Should also use prefix
138if test "$cpu" = "powerpc"; then
139 bigendian="yes"
140fi
141
142cc="${cross_prefix}${cc}"
143ar="${cross_prefix}${ar}"
144strip="${cross_prefix}${strip}"
145
3d204385
NK
146# ---
147# check availability of some header files
148
149cat > $TMPC << EOF
150#include <malloc.h>
151int main( void ) { return 0; }
152EOF
153
154_memalign=no
155_malloc_h=no
156if $cc -o $TMPO $TMPC 2> /dev/null ; then
157_malloc_h=yes
158_memalign=yes
159# check for memalign - atmos
160cat > $TMPC << EOF
161#include <malloc.h>
162int main ( void ) {
163char *string = NULL;
164string = memalign(64, sizeof(char));
165return 0;
166}
167EOF
168$cc -o $TMPO $TMPC 2> /dev/null || _memalign=no
169fi
170
0f3cb305
FB
171if test "$1" = "-h" -o "$1" = "--help" ; then
172cat << EOF
173
174Usage: configure [options]
175Options: [defaults in brackets after descriptions]
176
177EOF
178echo "Standard options:"
179echo " --help print this message"
180echo " --prefix=PREFIX install in PREFIX [$prefix]"
181echo " --disable-grab disable audio/video grabbing code"
182echo " --disable-simple_idct disable simple IDCT routines [default=no]"
183echo " --enable-mp3lame enable mp3 encoding via libmp3lame [default=no]"
184echo " --enable-win32 enable win32 cross compile"
185echo " --enable-a52bin open liba52.so.0 at runtime [default=no]"
186echo " --enable-shared build shared libraries [default=no]"
187echo ""
188echo "Advanced options (experts only):"
189echo " --source-path=PATH path of source code [$source_path]"
190echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]"
191echo " --cc=CC use C compiler CC [$cc]"
192echo " --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS [$CFLAGS]"
193echo " --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]"
194echo " --extra-libs=ELIBS add ELIBS [$ELIBS]"
195echo " --cpu=CPU force cpu to CPU [$cpu]"
196echo " --disable-mmx disable mmx usage"
197echo " --enable-gprof enable profiling with gprof [$gprof]"
198echo ""
199echo "NOTE: The object files are build at the place where configure is launched"
200exit 1
201fi
202
de6d9b64 203echo "Install prefix $prefix"
0f3cb305 204echo "Source path $source_path"
de6d9b64
FB
205echo "C compiler $cc"
206echo "CPU $cpu"
0f3cb305 207echo "Big Endian $bigendian"
de6d9b64
FB
208echo "MMX enabled $mmx"
209echo "gprof enabled $gprof"
6ed7422a 210echo "grab enabled $grab"
a6741398 211echo "mp3lame enabled $mp3lame"
57514323 212echo "a52 dlopened $a52bin"
de6d9b64 213
980fc7b8 214echo "Creating config.mak and config.h"
de6d9b64 215
980fc7b8 216echo "# Automatically generated by configure - do not modify" > config.mak
045ed63f 217echo "/* Automatically generated by configure - do not modify */" > $TMPH
de6d9b64 218
980fc7b8 219echo "prefix=$prefix" >> config.mak
2cc8ae96 220echo "MAKE=make" >> config.mak
980fc7b8
FB
221echo "CC=$cc" >> config.mak
222echo "AR=$ar" >> config.mak
0f3cb305 223echo "STRIP=$strip" >> config.mak
a9b3f630 224echo "OPTFLAGS=$CFLAGS" >> config.mak
0f3cb305 225echo "LDFLAGS=$LDFLAGS" >> config.mak
57514323 226if test "$cpu" = "x86" ; then
980fc7b8 227 echo "TARGET_ARCH_X86=yes" >> config.mak
045ed63f 228 echo "#define ARCH_X86 1" >> $TMPH
0f3cb305 229elif test "$cpu" = "armv4l" ; then
6ed7422a 230 echo "TARGET_ARCH_ARMV4L=yes" >> config.mak
045ed63f 231 echo "#define ARCH_ARMV4L 1" >> $TMPH
0f3cb305 232elif test "$cpu" = "alpha" ; then
91d1f1a4 233 echo "TARGET_ARCH_ALPHA=yes" >> config.mak
045ed63f 234 echo "#define ARCH_ALPHA 1" >> $TMPH
0f3cb305
FB
235elif test "$cpu" = "powerpc" ; then
236 echo "TARGET_ARCH_POWERPC=yes" >> config.mak
237 echo "#define ARCH_POWERPC 1" >> $TMPH
238fi
239if test "$bigendian" = "yes" ; then
240 echo "WORDS_BIGENDIAN=yes" >> config.mak
241 echo "#define WORDS_BIGENDIAN 1" >> $TMPH
91d1f1a4 242fi
57514323 243if test "$mmx" = "yes" ; then
980fc7b8 244 echo "TARGET_MMX=yes" >> config.mak
045ed63f 245 echo "#define HAVE_MMX 1" >> $TMPH
de6d9b64 246fi
57514323 247if test "$gprof" = "yes" ; then
980fc7b8 248 echo "TARGET_GPROF=yes" >> config.mak
045ed63f 249 echo "#define HAVE_GPROF 1" >> $TMPH
de6d9b64 250fi
57514323 251if test "$lshared" = "yes" ; then
0319c531
NK
252 echo "BUILD_SHARED=yes" >> config.mak
253else
254 echo "BUILD_SHARED=no" >> config.mak
255fi
ef0bc4c9 256echo "EXTRALIBS=$extralibs" >> config.mak
0319c531 257echo -n "VERSION=" >>config.mak
0f3cb305 258head $source_path/VERSION >>config.mak
0319c531 259echo "" >>config.mak
d771bcae 260# if you do not want to use encoders, disable that.
045ed63f 261echo "#define CONFIG_ENCODERS 1" >> $TMPH
d771bcae
FB
262echo "CONFIG_ENCODERS=yes" >> config.mak
263
264# if you do not want to use decoders, disable that.
045ed63f 265echo "#define CONFIG_DECODERS 1" >> $TMPH
d771bcae
FB
266echo "CONFIG_DECODERS=yes" >> config.mak
267
d2b7bcd2 268# special AC3 stuff in case you already have it
d771bcae 269# without libavcodec.
045ed63f 270echo "#define CONFIG_AC3 1" >> $TMPH
d771bcae
FB
271echo "CONFIG_AC3=yes" >> config.mak
272
57514323
ZK
273if test "$a52bin" = "yes" ; then
274 echo "#define CONFIG_A52BIN 1" >> $TMPH
275 echo "CONFIG_A52BIN=yes" >> config.mak
276else
277 echo "CONFIG_A52BIN=no" >> config.mak
278fi
279
280if test "$grab" = "yes" ; then
045ed63f 281 echo "#define CONFIG_GRAB 1" >> $TMPH
6ed7422a
FB
282 echo "CONFIG_GRAB=yes" >> config.mak
283fi
daf8e955 284
57514323 285if test "$mp3lame" = "yes" ; then
045ed63f 286 echo "#define CONFIG_MP3LAME 1" >> $TMPH
a6741398
J
287 echo "CONFIG_MP3LAME=yes" >> config.mak
288fi
289
57514323 290if test "$win32" = "yes" ; then
045ed63f 291 echo "#define CONFIG_WIN32 1" >> $TMPH
daf8e955
FB
292 echo "CONFIG_WIN32=yes" >> config.mak
293fi
3d204385 294
57514323 295if test "$_malloc_h" = "yes" ; then
045ed63f 296 echo "#define HAVE_MALLOC_H 1" >> $TMPH
3d204385 297else
045ed63f 298 echo "#undef HAVE_MALLOC_H" >> $TMPH
3d204385
NK
299fi
300
57514323 301if test "$_memalign" = "yes" ; then
045ed63f
ZK
302 echo "#define HAVE_MEMALIGN 1" >> $TMPH
303else
304 echo "#undef HAVE_MEMALIGN" >> $TMPH
305fi
306
57514323 307if test "$simpleidct" = "yes" ; then
045ed63f
ZK
308 echo "#define SIMPLE_IDCT 1" >> $TMPH
309fi
310
0f3cb305
FB
311# build tree in object directory if source path is different from current one
312if test "$source_path_used" = "yes" ; then
313 DIRS="libav libavcodec libavcodec/alpha libavcodec/armv4l libavcodec/i386 \
314 libavcodec/liba52 libavcodec/mlib tests"
315 FILES="Makefile libav/Makefile libavcodec/Makefile tests/Makefile"
316 for dir in $DIRS ; do
317 mkdir -p $dir
318 done
319 for f in $FILES ; do
320 ln -sf $source_path/$f $f
321 done
322fi
323echo "SRC_PATH=$source_path" >> config.mak
324
a7c02e25 325diff $TMPH config.h >/dev/null 2>&1
045ed63f
ZK
326if test $? -ne 0 ; then
327 mv -f $TMPH config.h
3d204385 328else
045ed63f 329 echo "config.h is unchanged"
3d204385
NK
330fi
331
045ed63f 332rm -f $TMPO $TMPC $TMPS $TMPH