* fixed --enable-shared handling
[libav.git] / configure
1 #!/bin/sh
2
3 TMPC="ffmpeg-conf-${RANDOM}-$$-${RANDOM}.c"
4 TMPO="ffmpeg-conf-${RANDOM}-$$-${RANDOM}.o"
5 TMPS="ffmpeg-conf-${RANDOM}-$$-${RANDOM}.S"
6 TMPH="ffmpeg-conf-${RANDOM}-$$-${RANDOM}.h"
7
8 if test ! -z "$TMPDIR" ; then
9 TMPC="${TMPDIR}/${TMPC}"
10 TMPCPP="${TMPDIR}/${TMPCPP}"
11 TMPO="${TMPDIR}/${TMPO}"
12 TMPS="${TMPDIR}/${TMPS}"
13 TMPH="${TMPDIR}/${TMPH}"
14 elif test ! -z "$TEMPDIR" ; then
15 TMPC="${TEMPDIR}/${TMPC}"
16 TMPCPP="${TEMPDIR}/${TMPCPP}"
17 TMPO="${TEMPDIR}/${TMPO}"
18 TMPS="${TEMPDIR}/${TMPS}"
19 TMPH="${TEMPDIR}/${TMPH}"
20 else
21 TMPC="/tmp/${TMPC}"
22 TMPCPP="/tmp/${TMPCPP}"
23 TMPO="/tmp/${TMPO}"
24 TMPS="/tmp/${TMPS}"
25 TMPH="/tmp/${TMPH}"
26 fi
27
28 # default parameters
29 prefix="/usr/local"
30 cc="gcc"
31 ar="ar"
32 cpu=`uname -m`
33 case "$cpu" in
34 i386|i486|i586|i686|i86pc|BePC)
35 cpu="x86"
36 mmx="yes"
37 ;;
38 armv4l)
39 cpu="armv4l"
40 mmx="no"
41 ;;
42 alpha)
43 cpu="alpha"
44 mmx="no"
45 ;;
46 *)
47 mmx="no"
48 ;;
49 esac
50 gprof="no"
51 grab="yes"
52 mp3lame="no"
53 a52bin="no"
54 win32="no"
55 lshared="no"
56 extralibs="-lm"
57 simpleidct="yes"
58
59 # OS specific
60 targetos=`uname -s`
61 case $targetos in
62 BeOS)
63 prefix="/boot/home/config"
64 # helps building libavcodec
65 grab="no"
66 CFLAGS="-O2 -DPIC"
67 # no need for libm, but the inet stuff
68 # Check for BONE
69 if (echo $BEINCLUDES|grep 'headers/be/bone' >/dev/null); then
70 extralibs="-lbind -lsocket"
71 else
72 echo "Not sure building for net_server will succeed... good luck."
73 extralibs="-lsocket"
74 fi ;;
75 *) ;;
76 esac
77
78 if test "$1" = "-h" -o "$1" = "--help" ; then
79 cat << EOF
80
81 Usage: configure [options]
82 Options: [defaults in brackets after descriptions]
83
84 --help print this message
85 EOF
86 echo " --prefix=PREFIX install in PREFIX [$prefix]"
87 echo " --cc=CC use C compiler CC [$cc]"
88 echo " --cpu=CPU force cpu to CPU [$cpu]"
89 echo " --disable-mmx disable mmx usage"
90 echo " --enable-gprof enable profiling with gprof [$gprof]"
91 echo " --disable-grab disable audio/video grabbing code"
92 echo " --disable-simple_idct disable simple IDCT routines [default=no]"
93 echo " --enable-mp3lame enable mp3 encoding via libmp3lame [default=no]"
94 echo " --enable-win32 enable win32 cross compile"
95 echo " --enable-a52bin open liba52.so.0 at runtime [default=no]"
96 echo " --enable-shared build shared libraries [default=no]"
97 exit 1
98 fi
99
100 for opt do
101 case "$opt" in
102 --prefix=*) prefix=`echo $opt | cut -d '=' -f 2`
103 ;;
104 --cc=*) cc=`echo $opt | cut -d '=' -f 2`
105 ;;
106 --cpu=*) cpu=`echo $opt | cut -d '=' -f 2`
107 ;;
108 --disable-mmx) mmx="no"
109 ;;
110 --enable-gprof) gprof="yes"
111 ;;
112 --disable-grab) grab="no"
113 ;;
114 --enable-a52bin) a52bin="yes" ; extralibs="-ldl $extralibs"
115 ;;
116 --enable-mp3lame) mp3lame="yes"
117 ;;
118 --disable-simple_idct) simpleidct="no"
119 ;;
120 --enable-win32) win32="yes"
121 ;;
122 --enable-shared) lshared="yes"
123 ;;
124 esac
125 done
126
127 # Checking for CFLAGS
128 if test -z "$CFLAGS"; then
129 CFLAGS="-O2"
130 fi
131
132 if test "$win32" = "yes" ; then
133 cross_prefix="i386-mingw32msvc-"
134 cc="${cross_prefix}gcc"
135 ar="${cross_prefix}ar"
136 grab="no"
137 fi
138
139 # ---
140 # check availability of some header files
141
142 cat > $TMPC << EOF
143 #include <malloc.h>
144 int main( void ) { return 0; }
145 EOF
146
147 _memalign=no
148 _malloc_h=no
149 if $cc -o $TMPO $TMPC 2> /dev/null ; then
150 _malloc_h=yes
151 _memalign=yes
152 # check for memalign - atmos
153 cat > $TMPC << EOF
154 #include <malloc.h>
155 int main ( void ) {
156 char *string = NULL;
157 string = memalign(64, sizeof(char));
158 return 0;
159 }
160 EOF
161 $cc -o $TMPO $TMPC 2> /dev/null || _memalign=no
162 fi
163
164 echo "Install prefix $prefix"
165 echo "C compiler $cc"
166 echo "CPU $cpu"
167 echo "MMX enabled $mmx"
168 echo "gprof enabled $gprof"
169 echo "grab enabled $grab"
170 echo "mp3lame enabled $mp3lame"
171 echo "a52 dlopened $a52bin"
172
173 echo "Creating config.mak and config.h"
174
175 echo "# Automatically generated by configure - do not modify" > config.mak
176 echo "/* Automatically generated by configure - do not modify */" > $TMPH
177
178 echo "prefix=$prefix" >> config.mak
179 echo "MAKE=make" >> config.mak
180 echo "CC=$cc" >> config.mak
181 echo "AR=$ar" >> config.mak
182 echo "OPTFLAGS=$CFLAGS" >> config.mak
183 if test "$cpu" = "x86" ; then
184 echo "TARGET_ARCH_X86=yes" >> config.mak
185 echo "#define ARCH_X86 1" >> $TMPH
186 fi
187 if test "$cpu" = "armv4l" ; then
188 echo "TARGET_ARCH_ARMV4L=yes" >> config.mak
189 echo "#define ARCH_ARMV4L 1" >> $TMPH
190 fi
191 if test "$cpu" = "alpha" ; then
192 echo "TARGET_ARCH_ALPHA=yes" >> config.mak
193 echo "#define ARCH_ALPHA 1" >> $TMPH
194 fi
195 if test "$mmx" = "yes" ; then
196 echo "TARGET_MMX=yes" >> config.mak
197 echo "#define HAVE_MMX 1" >> $TMPH
198 fi
199 if test "$gprof" = "yes" ; then
200 echo "TARGET_GPROF=yes" >> config.mak
201 echo "#define HAVE_GPROF 1" >> $TMPH
202 fi
203 if test "$lshared" = "yes" ; then
204 echo "BUILD_SHARED=yes" >> config.mak
205 else
206 echo "BUILD_SHARED=no" >> config.mak
207 fi
208 echo "EXTRALIBS=$extralibs" >> config.mak
209 echo -n "VERSION=" >>config.mak
210 head VERSION >>config.mak
211 echo "" >>config.mak
212 # if you do not want to use encoders, disable that.
213 echo "#define CONFIG_ENCODERS 1" >> $TMPH
214 echo "CONFIG_ENCODERS=yes" >> config.mak
215
216 # if you do not want to use decoders, disable that.
217 echo "#define CONFIG_DECODERS 1" >> $TMPH
218 echo "CONFIG_DECODERS=yes" >> config.mak
219
220 # special AC3 stuff in case you already have it
221 # without libavcodec.
222 echo "#define CONFIG_AC3 1" >> $TMPH
223 echo "CONFIG_AC3=yes" >> config.mak
224
225 if test "$a52bin" = "yes" ; then
226 echo "#define CONFIG_A52BIN 1" >> $TMPH
227 echo "CONFIG_A52BIN=yes" >> config.mak
228 else
229 echo "CONFIG_A52BIN=no" >> config.mak
230 fi
231
232 if test "$grab" = "yes" ; then
233 echo "#define CONFIG_GRAB 1" >> $TMPH
234 echo "CONFIG_GRAB=yes" >> config.mak
235 fi
236
237 if test "$mp3lame" = "yes" ; then
238 echo "#define CONFIG_MP3LAME 1" >> $TMPH
239 echo "CONFIG_MP3LAME=yes" >> config.mak
240 fi
241
242 if test "$win32" = "yes" ; then
243 echo "#define CONFIG_WIN32 1" >> $TMPH
244 echo "CONFIG_WIN32=yes" >> config.mak
245 fi
246
247 if test "$_malloc_h" = "yes" ; then
248 echo "#define HAVE_MALLOC_H 1" >> $TMPH
249 else
250 echo "#undef HAVE_MALLOC_H" >> $TMPH
251 fi
252
253 if test "$_memalign" = "yes" ; then
254 echo "#define HAVE_MEMALIGN 1" >> $TMPH
255 else
256 echo "#undef HAVE_MEMALIGN" >> $TMPH
257 fi
258
259 if test "$simpleidct" = "yes" ; then
260 echo "#define SIMPLE_IDCT 1" >> $TMPH
261 fi
262
263 diff $TMPH config.h >/dev/null 2>&1
264 if test $? -ne 0 ; then
265 mv -f $TMPH config.h
266 else
267 echo "config.h is unchanged"
268 fi
269
270 rm -f $TMPO $TMPC $TMPS $TMPH