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