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