* made by Juergen - should be useful for Solaris
[ffmpeg.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 exit 1
62 fi
63
64 for opt do
65   case "$opt" in
66   --prefix=*) prefix=`echo $opt | cut -d '=' -f 2`
67   ;;
68   --cc=*) cc=`echo $opt | cut -d '=' -f 2`
69   ;;
70   --cpu=*) cpu=`echo $opt | cut -d '=' -f 2`
71   ;;
72   --disable-mmx) mmx="no"
73   ;;
74   --enable-gprof) gprof="yes"
75   ;;
76   --disable-grab) grab="no"
77   ;;
78   --enable-win32) win32="yes"
79   ;;
80   esac
81 done
82
83 # Checking for CFLAGS
84 if test -z "$CFLAGS"; then
85     CFLAGS="-O2"
86 fi
87
88 if [ "$win32" = "yes" ] ; then
89     cross_prefix="i386-mingw32msvc-"
90     cc="${cross_prefix}gcc"
91     ar="${cross_prefix}ar"
92     grab="no"
93 fi
94
95 # ---
96 # check availability of some header files
97
98 cat > $TMPC << EOF
99 #include <malloc.h>
100 int main( void ) { return 0; }
101 EOF
102
103 _memalign=no
104 _malloc_h=no
105 if $cc -o $TMPO $TMPC 2> /dev/null ; then
106 _malloc_h=yes
107 _memalign=yes
108 # check for memalign - atmos
109 cat > $TMPC << EOF
110 #include <malloc.h>
111 int main ( void ) {
112 char *string = NULL;
113 string = memalign(64, sizeof(char));
114 return 0;
115 }
116 EOF
117 $cc -o $TMPO $TMPC 2> /dev/null || _memalign=no
118 fi
119
120 echo "Install prefix   $prefix"
121 echo "C compiler       $cc"
122 echo "CPU              $cpu"
123 echo "MMX enabled      $mmx"
124 echo "gprof enabled    $gprof"
125 echo "grab enabled     $grab"
126
127 echo "Creating config.mak and config.h"
128
129 echo "# Automatically generated by configure - do not modify" > config.mak
130 echo "/* Automatically generated by configure - do not modify */" > config.h
131
132 echo "prefix=$prefix" >> config.mak
133 echo "MAKE=make" >> config.mak
134 echo "CC=$cc" >> config.mak
135 echo "AR=$ar" >> config.mak
136 echo "OPTFLAGS=$CFLAGS" >> config.mak
137 if [ "$cpu" = "x86" ] ; then
138   echo "TARGET_ARCH_X86=yes" >> config.mak
139   echo "#define ARCH_X86 1" >> config.h
140 fi
141 if [ "$cpu" = "armv4l" ]; then
142   echo "TARGET_ARCH_ARMV4L=yes" >> config.mak
143   echo "#define ARCH_ARMV4L 1" >> config.h
144 fi
145 if [ "$mmx" = "yes" ] ; then
146   echo "TARGET_MMX=yes" >> config.mak
147   echo "#define HAVE_MMX 1" >> config.h
148 fi
149 if [ "$gprof" = "yes" ] ; then
150   echo "TARGET_GPROF=yes" >> config.mak
151   echo "#define HAVE_GPROF 1" >> config.h
152 fi
153
154 # if you do not want to use encoders, disable that.
155 echo "#define CONFIG_ENCODERS 1" >> config.h
156 echo "CONFIG_ENCODERS=yes" >> config.mak
157
158 # if you do not want to use decoders, disable that.
159 echo "#define CONFIG_DECODERS 1" >> config.h
160 echo "CONFIG_DECODERS=yes" >> config.mak
161
162 # special AC3 stuff in case you already have it
163 # without libavcodec.
164 echo "#define CONFIG_AC3 1" >> config.h
165 echo "CONFIG_AC3=yes" >> config.mak
166
167 if [ "$grab" = "yes" ] ; then
168   echo "#define CONFIG_GRAB 1" >> config.h
169   echo "CONFIG_GRAB=yes" >> config.mak
170 fi
171
172 if [ "$win32" = "yes" ] ; then
173   echo "#define CONFIG_WIN32 1" >> config.h
174   echo "CONFIG_WIN32=yes" >> config.mak
175 fi
176
177 if [ "$_malloc_h" = "yes" ]; then
178   echo "#define HAVE_MALLOC_H 1" >> config.h
179 else
180   echo "#undef  HAVE_MALLOC_H" >> config.h
181 fi
182
183 if [ "$_memalign" = "yes" ]; then
184   echo "#define HAVE_MEMALIGN 1" >> config.h
185 else
186   echo "#undef  HAVE_MEMALIGN" >> config.h
187 fi
188
189 rm -f $TMPO $TMPC $TMPS