Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
[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
7 if [ ! -z "$TMPDIR" ]; then
8 TMPC="${TMPDIR}/${TMPC}"
9 TMPCPP="${TMPDIR}/${TMPCPP}"
10 TMPO="${TMPDIR}/${TMPO}"
11 TMPS="${TMPDIR}/${TMPS}"
12 elif [ ! -z "$TEMPDIR" ]; then
13 TMPC="${TEMPDIR}/${TMPC}"
14 TMPCPP="${TEMPDIR}/${TMPCPP}"
15 TMPO="${TEMPDIR}/${TMPO}"
16 TMPS="${TEMPDIR}/${TMPS}"
17 else
18 TMPC="/tmp/${TMPC}"
19 TMPCPP="/tmp/${TMPCPP}"
20 TMPO="/tmp/${TMPO}"
21 TMPS="/tmp/${TMPS}"
22 fi
23
24 # default parameters
25 prefix="/usr/local"
26 cc="gcc"
27 ar="ar"
28 cpu=`uname -m`
29 case "$cpu" in
30 i386|i486|i586|i686|i86pc)
31 cpu="x86"
32 mmx="yes"
33 ;;
34 armv4l)
35 cpu="armv4l"
36 mmx="no"
37 ;;
38 alpha)
39 cpu="alpha"
40 mmx="no"
41 ;;
42 *)
43 mmx="no"
44 ;;
45 esac
46 gprof="no"
47 grab="yes"
48 win32="no"
49
50 if [ "$1" = "-h" -o "$1" = "--help" ] ; then
51 cat << EOF
52
53 Usage: configure [options]
54 Options: [defaults in brackets after descriptions]
55
56 --help print this message
57 EOF
58 echo " --prefix=PREFIX install in PREFIX [$prefix]"
59 echo " --cc=CC use C compiler CC [$cc]"
60 echo " --cpu=CPU force cpu to CPU [$cpu]"
61 echo " --disable-mmx disable mmx usage"
62 echo " --enable-gprof enable profiling with gprof [$gprof]"
63 echo " --disable-grab disable audio/video grabbing code"
64 echo " --enable-win32 enable win32 cross compile"
65 echo " --enable-shared build shared libraries [default=no]"
66 exit 1
67 fi
68
69 lshared=no
70 for opt do
71 case "$opt" in
72 --prefix=*) prefix=`echo $opt | cut -d '=' -f 2`
73 ;;
74 --cc=*) cc=`echo $opt | cut -d '=' -f 2`
75 ;;
76 --cpu=*) cpu=`echo $opt | cut -d '=' -f 2`
77 ;;
78 --disable-mmx) mmx="no"
79 ;;
80 --enable-gprof) gprof="yes"
81 ;;
82 --disable-grab) grab="no"
83 ;;
84 --enable-win32) win32="yes"
85 ;;
86 --enable-shared=*) lshared=`echo $opt | cut -d '=' -f 2`
87 ;;
88 esac
89 done
90
91 # Checking for CFLAGS
92 if test -z "$CFLAGS"; then
93 CFLAGS="-O2"
94 fi
95
96 if [ "$win32" = "yes" ] ; then
97 cross_prefix="i386-mingw32msvc-"
98 cc="${cross_prefix}gcc"
99 ar="${cross_prefix}ar"
100 grab="no"
101 fi
102
103 # ---
104 # check availability of some header files
105
106 cat > $TMPC << EOF
107 #include <malloc.h>
108 int main( void ) { return 0; }
109 EOF
110
111 _memalign=no
112 _malloc_h=no
113 if $cc -o $TMPO $TMPC 2> /dev/null ; then
114 _malloc_h=yes
115 _memalign=yes
116 # check for memalign - atmos
117 cat > $TMPC << EOF
118 #include <malloc.h>
119 int main ( void ) {
120 char *string = NULL;
121 string = memalign(64, sizeof(char));
122 return 0;
123 }
124 EOF
125 $cc -o $TMPO $TMPC 2> /dev/null || _memalign=no
126 fi
127
128 echo "Install prefix $prefix"
129 echo "C compiler $cc"
130 echo "CPU $cpu"
131 echo "MMX enabled $mmx"
132 echo "gprof enabled $gprof"
133 echo "grab enabled $grab"
134
135 echo "Creating config.mak and config.h"
136
137 echo "# Automatically generated by configure - do not modify" > config.mak
138 echo "/* Automatically generated by configure - do not modify */" > config.h
139
140 echo "prefix=$prefix" >> config.mak
141 echo "MAKE=make" >> config.mak
142 echo "CC=$cc" >> config.mak
143 echo "AR=$ar" >> config.mak
144 echo "OPTFLAGS=$CFLAGS" >> config.mak
145 if [ "$cpu" = "x86" ] ; then
146 echo "TARGET_ARCH_X86=yes" >> config.mak
147 echo "#define ARCH_X86 1" >> config.h
148 fi
149 if [ "$cpu" = "armv4l" ]; then
150 echo "TARGET_ARCH_ARMV4L=yes" >> config.mak
151 echo "#define ARCH_ARMV4L 1" >> config.h
152 fi
153 if [ "$cpu" = "alpha" ]; then
154 echo "TARGET_ARCH_ALPHA=yes" >> config.mak
155 echo "#define ARCH_ALPHA 1" >> config.h
156 fi
157 if [ "$mmx" = "yes" ] ; then
158 echo "TARGET_MMX=yes" >> config.mak
159 echo "#define HAVE_MMX 1" >> config.h
160 fi
161 if [ "$gprof" = "yes" ] ; then
162 echo "TARGET_GPROF=yes" >> config.mak
163 echo "#define HAVE_GPROF 1" >> config.h
164 fi
165 if [ "$lshared" = "yes" ] ; then
166 echo "BUILD_SHARED=yes" >> config.mak
167 else
168 echo "BUILD_SHARED=no" >> config.mak
169 fi
170 echo -n "VERSION=" >>config.mak
171 head VERSION >>config.mak
172 echo "" >>config.mak
173 # if you do not want to use encoders, disable that.
174 echo "#define CONFIG_ENCODERS 1" >> config.h
175 echo "CONFIG_ENCODERS=yes" >> config.mak
176
177 # if you do not want to use decoders, disable that.
178 echo "#define CONFIG_DECODERS 1" >> config.h
179 echo "CONFIG_DECODERS=yes" >> config.mak
180
181 # special AC3 stuff in case you already have it
182 # without libavcodec.
183 echo "#define CONFIG_AC3 1" >> config.h
184 echo "CONFIG_AC3=yes" >> config.mak
185
186 if [ "$grab" = "yes" ] ; then
187 echo "#define CONFIG_GRAB 1" >> config.h
188 echo "CONFIG_GRAB=yes" >> config.mak
189 fi
190
191 if [ "$win32" = "yes" ] ; then
192 echo "#define CONFIG_WIN32 1" >> config.h
193 echo "CONFIG_WIN32=yes" >> config.mak
194 fi
195
196 if [ "$_malloc_h" = "yes" ]; then
197 echo "#define HAVE_MALLOC_H 1" >> config.h
198 else
199 echo "#undef HAVE_MALLOC_H" >> config.h
200 fi
201
202 if [ "$_memalign" = "yes" ]; then
203 echo "#define HAVE_MEMALIGN 1" >> config.h
204 else
205 echo "#undef HAVE_MEMALIGN" >> config.h
206 fi
207
208 rm -f $TMPO $TMPC $TMPS