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