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