]> git.sesse.net Git - ffmpeg/blob - configure
10l found by RĂ©mi Guyomarch <rguyom at pobox dot com>
[ffmpeg] / 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 zlib="yes"
47 mp3lame="no"
48 a52="yes"
49 a52bin="no"
50 win32="no"
51 lshared="no"
52 extralibs="-lm"
53 simpleidct="yes"
54 bigendian="no"
55 vhook="no"
56 mpegaudio_hp="yes"
57 SHFLAGS=-shared
58
59 # OS specific
60 targetos=`uname -s`
61 case $targetos in
62 BeOS)
63 prefix="/boot/home/config"
64 # helps building libavcodec
65 CFLAGS="-O3 -DPIC -fomit-frame-pointer"
66 SHFLAGS=-nostart
67 # disable linux things
68 audio_oss="no"
69 v4l="no"
70 # no need for libm, but the inet stuff
71 # Check for BONE
72 if (echo $BEINCLUDES|grep 'headers/be/bone' >/dev/null); then
73 extralibs="-lbind -lsocket"
74 else
75 echo "Not sure building for net_server will succeed... good luck."
76 extralibs="-lsocket"
77 fi ;;
78 BSD/OS)
79 v4l="no"
80 audio_oss="yes"
81 extralibs="-lpoll -lgnugetopt -lm"
82 make="gmake"
83 ;;
84 *) ;;
85 esac
86
87 # find source path
88 # XXX: we assume an absolute path is given when launching configure, 
89 # except in './configure' case.
90 source_path=${0%configure}
91 source_path=${source_path%/}
92 source_path_used="yes"
93 if test -z "$source_path" -o "$source_path" = "." ; then
94     source_path=`pwd`
95     source_path_used="no"
96 fi
97
98 cat > $TMPC << EOF
99 #include <dlfcn.h>
100 int main( void ) { return (int) dlopen("foo", 0); }
101 EOF
102
103 if $cc -o $TMPO $TMPC -ldl 2> /dev/null  ; then
104 : vhook=yes
105 fi
106
107 cat > $TMPC << EOF
108 #include <X11/Xlib.h>
109 #include <Imlib2.h>
110 int main( void ) { return (int) imlib_load_font("foo"); }
111 EOF
112
113 imlib2=no
114 if $cc -o $TMPO $TMPC -lImlib2 2> /dev/null  ; then
115 imlib2=yes
116 fi
117
118 for opt do
119   case "$opt" in
120   --prefix=*) prefix=`echo $opt | cut -d '=' -f 2`
121   ;;
122   --source-path=*) source_path=`echo $opt | cut -d '=' -f 2`
123   ;;
124   --cross-prefix=*) cross_prefix=`echo $opt | cut -d '=' -f 2`
125   ;;
126   --cc=*) cc=`echo $opt | cut -d '=' -f 2`
127   ;;
128   --make=*) make=`echo $opt | cut -d '=' -f 2`
129   ;;
130   --extra-cflags=*) CFLAGS="${opt#--extra-cflags=}"
131   ;;
132   --extra-ldflags=*) LDFLAGS=${opt#--extra-ldflags=}
133   ;;
134   --extra-libs=*) extralibs=${opt#--extra-libs=}
135   ;;
136   --cpu=*) cpu=`echo $opt | cut -d '=' -f 2`
137   ;;
138   --disable-mmx) mmx="no"
139   ;;
140   --enable-gprof) gprof="yes"
141   ;;
142   --disable-v4l) v4l="no"
143   ;;
144   --disable-audio-oss) audio_oss="no"
145   ;;
146   --disable-network) network="no"
147   ;;
148   --disable-zlib) zlib="no"
149   ;;
150   --disable-a52) a52="no"
151   ;;
152   --enable-a52bin) a52bin="yes" ; extralibs="-ldl $extralibs"
153   ;;
154   --enable-mp3lame) mp3lame="yes"
155   ;;
156   --disable-vhook) vhook="no"
157   ;;
158   --disable-simple_idct) simpleidct="no"
159   ;;
160   --enable-win32) win32="yes"
161   ;;
162   --enable-shared) lshared="yes"
163   ;;
164   --disable-mpegaudio-hp) mpegaudio_hp="no"
165   ;;
166   esac
167 done
168
169 # compute mmx state
170 if test $mmx = "default"; then
171     if test $cpu = "x86"; then
172         mmx="yes"
173     else
174         mmx="no"
175     fi
176 fi
177
178 # Checking for CFLAGS
179 if test -z "$CFLAGS"; then
180     CFLAGS="-O3"
181 fi
182
183 if test "$win32" = "yes" ; then
184     cross_prefix="i386-mingw32msvc-"
185     v4l="no"
186     audio_oss="no"
187     network="no"
188 fi
189
190 cc="${cross_prefix}${cc}"
191 ar="${cross_prefix}${ar}"
192 strip="${cross_prefix}${strip}"
193
194 # ---
195 # big/little endian test
196 cat > $TMPC << EOF
197 #include <inttypes.h>
198 int main(int argc, char ** argv){
199         volatile uint32_t i=0x01234567;
200         return (*((uint8_t*)(&i))) == 0x67;
201 }
202 EOF
203
204 if $cc -o $TMPO $TMPC 2>/dev/null ; then
205 $TMPO && bigendian="yes"
206 else
207 echo big/little test failed
208 fi
209
210 # ---
211 # check availability of some header files
212
213 cat > $TMPC << EOF
214 #include <malloc.h>
215 int main( void ) { return 0; }
216 EOF
217
218 _memalign=no
219 _malloc_h=no
220 if $cc -o $TMPO $TMPC 2> /dev/null ; then
221 _malloc_h=yes
222 _memalign=yes
223 # check for memalign - atmos
224 cat > $TMPC << EOF
225 #include <malloc.h>
226 int main ( void ) {
227 char *string = NULL;
228 string = memalign(64, sizeof(char));
229 return 0;
230 }
231 EOF
232 $cc -o $TMPO $TMPC 2> /dev/null || _memalign=no
233 fi
234
235 cat > $TMPC << EOF
236 #define _GNU_SOURCE
237 #include <time.h>
238 int main( void ) { return *strptime("", "", 0); }
239 EOF
240
241 strptime=no
242 if $cc -o $TMPO $TMPC 2> /dev/null ; then
243   strptime=yes
244 fi
245
246 if test "$zlib" = "yes"; then
247 # check for zlib - mmu_man
248 cat > $TMPC << EOF
249 #include <zlib.h>
250 int main ( void ) {
251 if (zlibVersion() != ZLIB_VERSION)
252    puts("zlib version differs !!!");
253    return 1;
254 return 0;
255 }
256 EOF
257 $cc -o $TMPO $TMPC -lz 2> /dev/null || zlib="no"
258 # $TMPO 2> /dev/null > /dev/null || zlib="no"
259 # XXX: more tests needed - runtime test
260 fi
261 if test "$zlib" = "yes"; then
262 extralibs="$extralibs -lz"
263 fi
264
265 _restrict=
266 for restrict_keyword in restrict __restrict__ __restrict; do
267   echo "void foo(char * $restrict_keyword p);" > $TMPC
268   if $cc -c -o $TMPO $TMPC 2> /dev/null; then
269     _restrict=$restrict_keyword
270     break;
271   fi
272 done
273
274 if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
275 cat << EOF
276
277 Usage: configure [options]
278 Options: [defaults in brackets after descriptions]
279
280 EOF
281 echo "Standard options:"
282 echo "  --help                   print this message"
283 echo "  --prefix=PREFIX          install in PREFIX [$prefix]"
284 echo "  --enable-mp3lame         enable mp3 encoding via libmp3lame [default=no]"
285 echo "  --enable-win32           enable win32 cross compile"
286 echo "  --disable-a52            disable GPL'ed A52 support [default=no]"
287 echo "  --enable-a52bin          open liba52.so.0 at runtime [default=no]"
288 echo "  --enable-shared          build shared libraries [default=no]"
289 echo ""
290 echo "Advanced options (experts only):"
291 echo "  --source-path=PATH       path of source code [$source_path]"
292 echo "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
293 echo "  --cc=CC                  use C compiler CC [$cc]"
294 echo "  --make=MAKE              use specified make [$make]"
295 echo "  --extra-cflags=ECFLAGS   add ECFLAGS to CFLAGS [$CFLAGS]"
296 echo "  --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]"
297 echo "  --extra-libs=ELIBS       add ELIBS [$ELIBS]"
298 echo "  --cpu=CPU                force cpu to CPU  [$cpu]"
299 echo "  --disable-mmx            disable mmx usage"
300 echo "  --disable-audio-oss      disable OSS audio support [default=no]"
301 echo "  --disable-v4l            disable video4linux grabbing [default=no]"
302 echo "  --disable-network        disable network support [default=no]"
303 echo "  --disable-zlib           disable zlib [default=no]"
304 echo "  --disable-simple_idct    disable simple IDCT routines [default=no]"
305 # echo "  --disable-vhook          disable video hooking support"
306 echo "  --enable-gprof           enable profiling with gprof [$gprof]"
307 echo "  --disable-mpegaudio-hp   faster (but less accurate)"
308 echo "                           mpegaudio decoding [default=no]"
309 echo ""
310 echo "NOTE: The object files are build at the place where configure is launched"
311 exit 1
312 fi
313
314 echo "Install prefix   $prefix"
315 echo "Source path      $source_path"
316 echo "C compiler       $cc"
317 echo "make             $make"
318 echo "CPU              $cpu"
319 echo "Big Endian       $bigendian"
320 echo "MMX enabled      $mmx"
321 echo "gprof enabled    $gprof"
322 echo "zlib enabled     $zlib"
323 echo "mp3lame enabled  $mp3lame"
324 echo "a52 support      $a52"
325 echo "a52 dlopened     $a52bin"
326 # echo "Video hooking    $vhook"
327
328 if test "$vhook" = "yes" ; then
329 : echo "Imlib2 support   $imlib2"
330 fi
331
332 echo "Creating config.mak and config.h"
333
334 echo "# Automatically generated by configure - do not modify" > config.mak
335 echo "/* Automatically generated by configure - do not modify */" > $TMPH
336
337 echo "prefix=$prefix" >> config.mak
338 echo "MAKE=$make" >> config.mak
339 echo "CC=$cc" >> config.mak
340 echo "AR=$ar" >> config.mak
341 echo "STRIP=$strip" >> config.mak
342 echo "OPTFLAGS=$CFLAGS" >> config.mak
343 echo "LDFLAGS=$LDFLAGS" >> config.mak
344 echo "SHFLAGS=$SHFLAGS" >> config.mak
345 if test "$cpu" = "x86" ; then
346   echo "TARGET_ARCH_X86=yes" >> config.mak
347   echo "#define ARCH_X86 1" >> $TMPH
348 elif test "$cpu" = "armv4l" ; then
349   echo "TARGET_ARCH_ARMV4L=yes" >> config.mak
350   echo "#define ARCH_ARMV4L 1" >> $TMPH
351 elif test "$cpu" = "alpha" ; then
352   echo "TARGET_ARCH_ALPHA=yes" >> config.mak
353   echo "#define ARCH_ALPHA 1" >> $TMPH
354 elif test "$cpu" = "powerpc" ; then
355   echo "TARGET_ARCH_POWERPC=yes" >> config.mak
356   echo "#define ARCH_POWERPC 1" >> $TMPH
357 fi
358 if test "$bigendian" = "yes" ; then
359   echo "WORDS_BIGENDIAN=yes" >> config.mak
360   echo "#define WORDS_BIGENDIAN 1" >> $TMPH
361 fi
362 if test "$mmx" = "yes" ; then
363   echo "TARGET_MMX=yes" >> config.mak
364   echo "#define HAVE_MMX 1" >> $TMPH
365 fi
366 if test "$gprof" = "yes" ; then
367   echo "TARGET_GPROF=yes" >> config.mak
368   echo "#define HAVE_GPROF 1" >> $TMPH
369 fi
370 if test "$strptime" = "yes" ; then
371   echo "#define HAVE_STRPTIME 1" >> $TMPH
372 else
373   echo "BUILD_STRPTIME=yes" >> config.mak
374 fi
375 if test "$imlib2" = "yes" ; then
376   echo "HAVE_IMLIB2=yes" >> config.mak
377 fi
378 if test "$vhook" = "yes" ; then
379   echo "BUILD_VHOOK=yes" >> config.mak
380   echo "#define HAVE_VHOOK 1" >> $TMPH
381   extralibs="$extralibs -ldl"
382 fi
383 if test "$lshared" = "yes" ; then
384   echo "BUILD_SHARED=yes" >> config.mak
385   echo "PIC=-fPIC" >> config.mak
386 fi
387 echo "EXTRALIBS=$extralibs" >> config.mak
388 echo -n "VERSION=" >>config.mak
389 head $source_path/VERSION >>config.mak
390 echo "" >>config.mak
391 # if you do not want to use encoders, disable that.
392 echo "#define CONFIG_ENCODERS 1" >> $TMPH
393 echo "CONFIG_ENCODERS=yes" >> config.mak
394
395 # if you do not want to use decoders, disable that.
396 echo "#define CONFIG_DECODERS 1" >> $TMPH
397 echo "CONFIG_DECODERS=yes" >> config.mak
398
399 # AC3
400 if test "$a52" = "yes" ; then
401   echo "#define CONFIG_AC3 1" >> $TMPH
402   echo "CONFIG_AC3=yes" >> config.mak
403
404   if test "$a52bin" = "yes" ; then
405     echo "#define CONFIG_A52BIN 1" >> $TMPH
406     echo "CONFIG_A52BIN=yes" >> config.mak
407   fi
408 fi
409
410 # mpeg audio high precision mode
411 if test "$mpegaudio_hp" = "yes" ; then
412   echo "#define CONFIG_MPEGAUDIO_HP 1" >> $TMPH
413 fi
414
415 if test "$v4l" = "yes" ; then
416   echo "#define CONFIG_VIDEO4LINUX 1" >> $TMPH
417   echo "CONFIG_VIDEO4LINUX=yes" >> config.mak
418 fi
419
420 if test "$audio_oss" = "yes" ; then
421   echo "#define CONFIG_AUDIO_OSS 1" >> $TMPH
422   echo "CONFIG_AUDIO_OSS=yes" >> config.mak
423 fi
424
425 if test "$network" = "yes" ; then
426   echo "#define CONFIG_NETWORK 1" >> $TMPH
427   echo "CONFIG_NETWORK=yes" >> config.mak
428 fi
429
430 if test "$zlib" = "yes" ; then
431   echo "#define CONFIG_ZLIB 1" >> $TMPH
432   echo "CONFIG_ZLIB=yes" >> config.mak
433 fi
434
435 if test "$mp3lame" = "yes" ; then
436   echo "#define CONFIG_MP3LAME 1" >> $TMPH
437   echo "CONFIG_MP3LAME=yes" >> config.mak
438 fi
439
440 if test "$win32" = "yes" ; then
441   echo "#define CONFIG_WIN32 1" >> $TMPH
442   echo "CONFIG_WIN32=yes" >> config.mak
443 fi
444
445 if test "$_malloc_h" = "yes" ; then
446   echo "#define HAVE_MALLOC_H 1" >> $TMPH
447 else
448   echo "#undef  HAVE_MALLOC_H" >> $TMPH
449 fi
450
451 if test "$_memalign" = "yes" ; then
452   echo "#define HAVE_MEMALIGN 1" >> $TMPH
453 else
454   echo "#undef  HAVE_MEMALIGN" >> $TMPH
455 fi
456
457 if test "$simpleidct" = "yes" ; then
458   echo "#define SIMPLE_IDCT 1" >> $TMPH
459 fi
460
461 echo "#define restrict $_restrict" >> $TMPH
462
463 # build tree in object directory if source path is different from current one
464 if test "$source_path_used" = "yes" ; then
465     DIRS="libav libavcodec libavcodec/alpha libavcodec/armv4l libavcodec/i386 \
466           libavcodec/liba52 libavcodec/mlib tests"
467     FILES="Makefile libav/Makefile libavcodec/Makefile tests/Makefile"
468     for dir in $DIRS ; do
469             mkdir -p $dir
470     done
471     for f in $FILES ; do
472         ln -sf $source_path/$f $f
473     done
474 fi
475 echo "SRC_PATH=$source_path" >> config.mak
476
477 diff $TMPH config.h >/dev/null 2>&1
478 if test $? -ne 0 ; then
479         mv -f $TMPH config.h
480 else
481         echo "config.h is unchanged"
482 fi
483
484 rm -f $TMPO $TMPC $TMPS $TMPH