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