Statistics
| Branch: | Revision:

ffmpeg / configure @ a7c02e25

History | View | Annotate | Download (5.8 KB)

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
TMPH="ffmpeg-conf-${RANDOM}-$$-${RANDOM}.h"
7

    
8
if [ ! -z "$TMPDIR" ]; then
9
	TMPC="${TMPDIR}/${TMPC}"
10
	TMPCPP="${TMPDIR}/${TMPCPP}"
11
	TMPO="${TMPDIR}/${TMPO}"
12
	TMPS="${TMPDIR}/${TMPS}"
13
	TMPH="${TMPDIR}/${TMPH}"
14
elif [ ! -z "$TEMPDIR" ]; then
15
	TMPC="${TEMPDIR}/${TMPC}"
16
	TMPCPP="${TEMPDIR}/${TMPCPP}"
17
	TMPO="${TEMPDIR}/${TMPO}"
18
	TMPS="${TEMPDIR}/${TMPS}"
19
	TMPH="${TEMPDIR}/${TMPH}"
20
else
21
	TMPC="/tmp/${TMPC}"
22
	TMPCPP="/tmp/${TMPCPP}"
23
	TMPO="/tmp/${TMPO}"
24
	TMPS="/tmp/${TMPS}"
25
	TMPH="/tmp/${TMPH}"
26
fi
27

    
28
# default parameters
29
prefix="/usr/local"
30
cc="gcc"
31
ar="ar"
32
cpu=`uname -m`
33
case "$cpu" in
34
  i386|i486|i586|i686|i86pc|BePC)
35
    cpu="x86"
36
    mmx="yes"
37
  ;;
38
  armv4l)
39
    cpu="armv4l"
40
    mmx="no"
41
  ;;
42
  alpha)
43
    cpu="alpha"
44
    mmx="no"
45
  ;;
46
  *)
47
    mmx="no"
48
  ;;
49
esac
50
gprof="no"
51
grab="yes"
52
mp3lame="no"
53
win32="no"
54
extralibs="-lm"
55

    
56
# OS specific
57
targetos=`uname -s`
58
case $targetos in
59
BeOS)
60
prefix="/boot/home/config"
61
# helps building libavcodec
62
grab="no"
63
CFLAGS="-O2 -DPIC"
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
*) ;;
73
esac
74

    
75
if [ "$1" = "-h" -o "$1" = "--help" ] ; then
76
cat << EOF
77

    
78
Usage: configure [options]
79
Options: [defaults in brackets after descriptions]
80

    
81
  --help                  print this message
82
EOF
83
echo "  --prefix=PREFIX         install in PREFIX [$prefix]"
84
echo "  --cc=CC                 use C compiler CC [$cc]"
85
echo "  --cpu=CPU               force cpu to CPU  [$cpu]"
86
echo "  --disable-mmx           disable mmx usage"
87
echo "  --enable-gprof          enable profiling with gprof [$gprof]"
88
echo "  --disable-grab          disable audio/video grabbing code"
89
echo "  --enable-simple_idct    use simple IDCT routines"
90
echo "  --enable-mp3lame        enable mp3 encoding via libmp3lame"
91
echo "  --enable-win32          enable win32 cross compile"
92
echo "  --enable-shared         build shared libraries [default=no]"
93
exit 1
94
fi
95

    
96
lshared=no
97
for opt do
98
  case "$opt" in
99
  --prefix=*) prefix=`echo $opt | cut -d '=' -f 2`
100
  ;;
101
  --cc=*) cc=`echo $opt | cut -d '=' -f 2`
102
  ;;
103
  --cpu=*) cpu=`echo $opt | cut -d '=' -f 2`
104
  ;;
105
  --disable-mmx) mmx="no"
106
  ;;
107
  --enable-gprof) gprof="yes"
108
  ;;
109
  --disable-grab) grab="no"
110
  ;;
111
  --enable-mp3lame) mp3lame="yes"
112
  ;;
113
  --enable-simple_idct) simpleidct="yes"
114
  ;;
115
  --enable-win32) win32="yes"
116
  ;;
117
  --enable-shared=*) lshared=`echo $opt | cut -d '=' -f 2`
118
  ;;
119
  esac
120
done
121

    
122
# Checking for CFLAGS
123
if test -z "$CFLAGS"; then
124
    CFLAGS="-O2"
125
fi
126

    
127
if [ "$win32" = "yes" ] ; then
128
    cross_prefix="i386-mingw32msvc-"
129
    cc="${cross_prefix}gcc"
130
    ar="${cross_prefix}ar"
131
    grab="no"
132
fi
133

    
134
# ---
135
# check availability of some header files
136

    
137
cat > $TMPC << EOF
138
#include <malloc.h>
139
int main( void ) { return 0; }
140
EOF
141

    
142
_memalign=no
143
_malloc_h=no
144
if $cc -o $TMPO $TMPC 2> /dev/null ; then
145
_malloc_h=yes
146
_memalign=yes
147
# check for memalign - atmos
148
cat > $TMPC << EOF
149
#include <malloc.h>
150
int main ( void ) {
151
char *string = NULL;
152
string = memalign(64, sizeof(char));
153
return 0;
154
}
155
EOF
156
$cc -o $TMPO $TMPC 2> /dev/null || _memalign=no
157
fi
158

    
159
echo "Install prefix   $prefix"
160
echo "C compiler       $cc"
161
echo "CPU              $cpu"
162
echo "MMX enabled      $mmx"
163
echo "gprof enabled    $gprof"
164
echo "grab enabled     $grab"
165
echo "mp3lame enabled  $mp3lame"
166

    
167
echo "Creating config.mak and config.h"
168

    
169
echo "# Automatically generated by configure - do not modify" > config.mak
170
echo "/* Automatically generated by configure - do not modify */" > $TMPH
171

    
172
echo "prefix=$prefix" >> config.mak
173
echo "MAKE=make" >> config.mak
174
echo "CC=$cc" >> config.mak
175
echo "AR=$ar" >> config.mak
176
echo "OPTFLAGS=$CFLAGS" >> config.mak
177
if [ "$cpu" = "x86" ] ; then
178
  echo "TARGET_ARCH_X86=yes" >> config.mak
179
  echo "#define ARCH_X86 1" >> $TMPH
180
fi
181
if [ "$cpu" = "armv4l" ]; then
182
  echo "TARGET_ARCH_ARMV4L=yes" >> config.mak
183
  echo "#define ARCH_ARMV4L 1" >> $TMPH
184
fi
185
if [ "$cpu" = "alpha" ]; then
186
  echo "TARGET_ARCH_ALPHA=yes" >> config.mak
187
  echo "#define ARCH_ALPHA 1" >> $TMPH
188
fi
189
if [ "$mmx" = "yes" ] ; then
190
  echo "TARGET_MMX=yes" >> config.mak
191
  echo "#define HAVE_MMX 1" >> $TMPH
192
fi
193
if [ "$gprof" = "yes" ] ; then
194
  echo "TARGET_GPROF=yes" >> config.mak
195
  echo "#define HAVE_GPROF 1" >> $TMPH
196
fi
197
if [ "$lshared" = "yes" ] ; then
198
  echo "BUILD_SHARED=yes" >> config.mak
199
else
200
  echo "BUILD_SHARED=no" >> config.mak
201
fi
202
echo "EXTRALIBS=$extralibs" >> config.mak
203
echo -n "VERSION=" >>config.mak
204
head VERSION >>config.mak
205
echo "" >>config.mak
206
# if you do not want to use encoders, disable that.
207
echo "#define CONFIG_ENCODERS 1" >> $TMPH
208
echo "CONFIG_ENCODERS=yes" >> config.mak
209

    
210
# if you do not want to use decoders, disable that.
211
echo "#define CONFIG_DECODERS 1" >> $TMPH
212
echo "CONFIG_DECODERS=yes" >> config.mak
213

    
214
# special AC3 stuff in case you already have it
215
# without libavcodec.
216
echo "#define CONFIG_AC3 1" >> $TMPH
217
echo "CONFIG_AC3=yes" >> config.mak
218

    
219
if [ "$grab" = "yes" ] ; then
220
  echo "#define CONFIG_GRAB 1" >> $TMPH
221
  echo "CONFIG_GRAB=yes" >> config.mak
222
fi
223

    
224
if [ "$mp3lame" = "yes" ] ; then
225
  echo "#define CONFIG_MP3LAME 1" >> $TMPH
226
  echo "CONFIG_MP3LAME=yes" >> config.mak
227
fi
228

    
229
if [ "$win32" = "yes" ] ; then
230
  echo "#define CONFIG_WIN32 1" >> $TMPH
231
  echo "CONFIG_WIN32=yes" >> config.mak
232
fi
233

    
234
if [ "$_malloc_h" = "yes" ]; then
235
  echo "#define HAVE_MALLOC_H 1" >> $TMPH
236
else
237
  echo "#undef  HAVE_MALLOC_H" >> $TMPH
238
fi
239

    
240
if [ "$_memalign" = "yes" ]; then
241
  echo "#define HAVE_MEMALIGN 1" >> $TMPH
242
else
243
  echo "#undef  HAVE_MEMALIGN" >> $TMPH
244
fi
245

    
246
if [ "$simpleidct" = "yes" ]; then
247
  echo "#define SIMPLE_IDCT 1" >> $TMPH
248
fi
249

    
250
diff $TMPH config.h >/dev/null 2>&1
251
if test $? -ne 0 ; then
252
	mv -f $TMPH config.h
253
else
254
	echo "config.h is unchanged"
255
fi
256

    
257
rm -f $TMPO $TMPC $TMPS $TMPH