few more error checks
[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"
f3ec2d46 16TMPE="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}"
0f3cb305
FB
17TMPS="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.S"
18TMPH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.h"
19
de6d9b64
FB
20# default parameters
21prefix="/usr/local"
0f3cb305 22cross_prefix=""
de6d9b64
FB
23cc="gcc"
24ar="ar"
be7109c1 25ranlib="ranlib"
4a908fbc 26make="make"
0f3cb305 27strip="strip"
de6d9b64 28cpu=`uname -m`
a4adb608 29tune="generic"
0f3cb305 30mmx="default"
ab6c65f6 31altivec="default"
d46aba26 32mmi="default"
de6d9b64 33case "$cpu" in
ef0bc4c9 34 i386|i486|i586|i686|i86pc|BePC)
de6d9b64 35 cpu="x86"
de6d9b64 36 ;;
93caefc7
AB
37 # armv4l is a subset of armv5tel
38 armv4l|armv5tel)
6ed7422a 39 cpu="armv4l"
6ed7422a 40 ;;
91d1f1a4
NK
41 alpha)
42 cpu="alpha"
91d1f1a4 43 ;;
a43bd1d7 44 "Power Macintosh"|ppc)
90cee0c3
MN
45 cpu="powerpc"
46 ;;
d46aba26
LS
47 mips)
48 cpu="mips"
49 ;;
a7beab73
RS
50 sun4u)
51 cpu="sparc64"
52 ;;
de6d9b64 53 *)
0f3cb305 54 cpu="unknown"
de6d9b64
FB
55 ;;
56esac
57gprof="no"
5cbcf02c
FB
58v4l="yes"
59audio_oss="yes"
dfdfa47c 60audio_beos="no"
8aa3ee32 61dv1394="yes"
5cbcf02c 62network="yes"
0147f198 63zlib="yes"
a6741398 64mp3lame="no"
81e0d0b4 65vorbis="no"
0fc50e58
ZK
66faad="no"
67faadbin="no"
5cbcf02c 68a52="yes"
57514323 69a52bin="no"
bba9b16c
MN
70pp="yes"
71shared_pp="no"
daf8e955 72win32="no"
732d9245 73mingw32="no"
3f027ca7 74cygwin="no"
f3ec2d46 75os2="no"
83286d2a 76lshared="no"
ef0bc4c9 77extralibs="-lm"
c02dbee1 78simpleidct="yes"
0f3cb305 79bigendian="no"
a8721c09 80vhook="default"
adbc0510
PG
81dlfcn="no"
82dlopen="no"
1eb2212e 83mpegaudio_hp="yes"
e1707f52 84SHFLAGS=-shared
26b35efb 85netserver="no"
4baca069 86need_inet_aton="no"
8154d2e0 87ffserver="yes"
a86b921c 88ffplay="yes"
4baca069
PG
89LDFLAGS=-Wl,--warn-common
90FFSLDFLAGS=-Wl,-E
f3ec2d46
SG
91LIBPREF="lib"
92LIBSUF=".a"
93SLIBPREF="lib"
94SLIBSUF=".so"
1d0d55da 95risky="yes"
553a6284 96small="no"
891f64b3 97amr_nb="no"
bc634f6f 98amr_nb_fixed="no"
ef0bc4c9
FR
99
100# OS specific
101targetos=`uname -s`
102case $targetos in
103BeOS)
104prefix="/boot/home/config"
105# helps building libavcodec
e1707f52 106CFLAGS="-O3 -DPIC -fomit-frame-pointer"
31ba0b4d
FR
107# 3 gcc releases known for BeOS, each with ugly bugs
108gcc_version="$($cc -v 2>&1 | grep version | cut -d ' ' -f3-)"
109case "$gcc_version" in
1102.9-beos-991026*|2.9-beos-000224*) echo "R5/GG gcc"
111mmx="no"
112;;
113*20010315*) echo "BeBits gcc"
114CFLAGS="$CFLAGS -fno-expensive-optimizations"
115;;
116esac
e1707f52
MN
117SHFLAGS=-nostart
118# disable linux things
119audio_oss="no"
5cbcf02c 120v4l="no"
8aa3ee32 121dv1394="no"
dfdfa47c
FR
122# enable beos things
123audio_beos="yes"
ef0bc4c9
FR
124# no need for libm, but the inet stuff
125# Check for BONE
126if (echo $BEINCLUDES|grep 'headers/be/bone' >/dev/null); then
127extralibs="-lbind -lsocket"
128else
26b35efb 129netserver="yes"
4baca069 130need_inet_aton="yes"
26b35efb 131extralibs="-lnet"
ef0bc4c9 132fi ;;
4baca069
PG
133SunOS)
134v4l="no"
135audio_oss="no"
8aa3ee32 136dv1394="no"
4baca069
PG
137make="gmake"
138LDFLAGS=""
139FFSLDFLAGS=""
140need_inet_aton="yes"
141extralibs="$extralibs -lsocket -lnsl"
142;;
9c938e77
PG
143FreeBSD)
144v4l="no"
145audio_oss="yes"
8aa3ee32 146dv1394="no"
9c938e77 147make="gmake"
4baca069 148LDFLAGS="$LDFLAGS -export-dynamic"
9c938e77 149;;
4a908fbc 150BSD/OS)
5cbcf02c 151v4l="no"
6063bce7 152audio_oss="yes"
8aa3ee32 153dv1394="no"
4a908fbc
AB
154extralibs="-lpoll -lgnugetopt -lm"
155make="gmake"
156;;
90cee0c3 157Darwin)
a43bd1d7 158cc="cc"
90cee0c3
MN
159v4l="no"
160audio_oss="no"
8aa3ee32 161dv1394="no"
d3b15036 162ffserver="no"
a43bd1d7 163SHFLAGS="-dynamiclib"
90cee0c3 164extralibs=""
a43bd1d7 165darwin="yes"
47930f09 166strip="strip -x"
6207ba95 167LDFLAGS="-d"
4baca069
PG
168FFSLDFLAGS=-Wl,-bind_at_load
169gcc_version="$($cc -v 2>&1 | grep version | cut -d ' ' -f4-)"
170case "$gcc_version" in
171*2.95*)
172CFLAGS="-no-cpp-precomp -pipe -O3 -fomit-frame-pointer"
173;;
174*)
175CFLAGS="-no-cpp-precomp -pipe -O3 -fomit-frame-pointer -mdynamic-no-pic"
176;;
177esac
90cee0c3 178;;
732d9245
BE
179MINGW32*)
180v4l="no"
181audio_oss="no"
8aa3ee32 182dv1394="no"
732d9245
BE
183ffserver="no"
184network="no"
185mingw32="yes"
186;;
3f027ca7
FB
187CYGWIN*)
188v4l="no"
189audio_oss="yes"
8aa3ee32 190dv1394="no"
3f027ca7
FB
191extralibs=""
192cygwin="yes"
193test -f /usr/include/inttypes.h || \
194test -f /usr/local/include/inttypes.h || \
195echo "Missing inttypes.h, please copy cygwin_inttypes.h to" \
196 "/usr/include/inttypes.h !!!"
197;;
b55e4ef4 198Linux)
4baca069 199LDFLAGS="$LDFLAGS -rdynamic"
b55e4ef4 200;;
f3ec2d46
SG
201OS/2)
202TMPE=$TMPE".exe"
69db4e10
SG
203ar="emxomfar -p64"
204ranlib="echo ignoring ranlib"
205strip="echo ignoring strip"
206CFLAGS="-Zomf -O3"
207LDFLAGS="-Zomf -Zstack 16384 -s"
f3ec2d46
SG
208SHFLAGS=""
209FFSLDFLAGS=""
210LIBPREF=""
211LIBSUF=".lib"
212SLIBPREF=""
213SLIBSUF=".dll"
214extralibs=""
215v4l="no"
216audio_oss="no"
8aa3ee32 217dv1394="no"
f3ec2d46
SG
218network="no"
219ffserver="no"
220os2="yes"
221;;
ef0bc4c9
FR
222*) ;;
223esac
de6d9b64 224
6852ac95
RD
225# From mplayer configure. We need TARGET_OS available
226# to the Makefile, so it can distinguish between flavors
227# of AltiVec on PowerPC
228TARGET_OS=`( uname -s ) 2>&1`
229 case "$TARGET_OS" in
230 Linux|FreeBSD|NetBSD|BSD/OS|OpenBSD|SunOS|QNX|Darwin|GNU)
231 ;;
232 IRIX*)
233 TARGET_OS=IRIX
234 ;;
235 HP-UX*)
236 TARGET_OS=HP-UX
237 ;;
238 [cC][yY][gG][wW][iI][nN]*)
239 TARGET_OS=CYGWIN
240 ;;
241 *)
242 TARGET_OS="$TARGET_OS-UNKNOWN"
243 ;;
244 esac
245
0f3cb305
FB
246# find source path
247# XXX: we assume an absolute path is given when launching configure,
248# except in './configure' case.
586bc755 249source_path="`echo $0 | sed -e 's#/configure##'`"
0f3cb305
FB
250source_path_used="yes"
251if test -z "$source_path" -o "$source_path" = "." ; then
252 source_path=`pwd`
253 source_path_used="no"
de6d9b64
FB
254fi
255
256for opt do
257 case "$opt" in
258 --prefix=*) prefix=`echo $opt | cut -d '=' -f 2`
259 ;;
0f3cb305
FB
260 --source-path=*) source_path=`echo $opt | cut -d '=' -f 2`
261 ;;
262 --cross-prefix=*) cross_prefix=`echo $opt | cut -d '=' -f 2`
263 ;;
de6d9b64
FB
264 --cc=*) cc=`echo $opt | cut -d '=' -f 2`
265 ;;
4a908fbc
AB
266 --make=*) make=`echo $opt | cut -d '=' -f 2`
267 ;;
0f3cb305
FB
268 --extra-cflags=*) CFLAGS="${opt#--extra-cflags=}"
269 ;;
270 --extra-ldflags=*) LDFLAGS=${opt#--extra-ldflags=}
271 ;;
272 --extra-libs=*) extralibs=${opt#--extra-libs=}
273 ;;
de6d9b64
FB
274 --cpu=*) cpu=`echo $opt | cut -d '=' -f 2`
275 ;;
a4adb608
MN
276 --tune=*) tune=`echo $opt | cut -d '=' -f 2`
277 ;;
de6d9b64
FB
278 --disable-mmx) mmx="no"
279 ;;
ab6c65f6
BF
280 --disable-altivec) altivec="no"
281 ;;
de6d9b64
FB
282 --enable-gprof) gprof="yes"
283 ;;
5cbcf02c
FB
284 --disable-v4l) v4l="no"
285 ;;
286 --disable-audio-oss) audio_oss="no"
287 ;;
dfdfa47c
FR
288 --disable-audio-beos) audio_beos="no"
289 ;;
8aa3ee32
MK
290 --disable-dv1394) dv1394="no"
291 ;;
5cbcf02c
FB
292 --disable-network) network="no"
293 ;;
0147f198
FR
294 --disable-zlib) zlib="no"
295 ;;
5cbcf02c 296 --disable-a52) a52="no"
6ed7422a 297 ;;
9c938e77 298 --enable-a52bin) a52bin="yes" ; extralibs="$ldl $extralibs"
57514323 299 ;;
bba9b16c
MN
300 --disable-pp) pp="no"
301 ;;
302 --enable-shared-pp) shared_pp="yes"
303 ;;
a6741398
J
304 --enable-mp3lame) mp3lame="yes"
305 ;;
81e0d0b4
MH
306 --enable-vorbis) vorbis="yes"
307 ;;
445ad18d
ZK
308 --enable-faad) faad="yes"
309 ;;
310 --enable-faadbin) faadbin="yes"
311 ;;
68892110
PG
312 --disable-vhook) vhook="no"
313 ;;
c02dbee1 314 --disable-simple_idct) simpleidct="no"
045ed63f 315 ;;
daf8e955
FB
316 --enable-win32) win32="yes"
317 ;;
732d9245
BE
318 --enable-mingw32) mingw32="yes"
319 ;;
83286d2a 320 --enable-shared) lshared="yes"
0319c531 321 ;;
1eb2212e
FB
322 --disable-mpegaudio-hp) mpegaudio_hp="no"
323 ;;
8154d2e0
FB
324 --disable-ffserver) ffserver="no"
325 ;;
a86b921c
FB
326 --disable-ffplay) ffplay="no"
327 ;;
1d0d55da
MN
328 --disable-risky) risky="no"
329 ;;
553a6284
MN
330 --enable-small) small="yes"
331 ;;
891f64b3 332 --enable-amr_nb) amr_nb="yes"
333 ;;
bc634f6f
ZK
334 --enable-amr_nb-fixed) amr_nb_fixed="yes"
335 ;;
de6d9b64
FB
336 esac
337done
338
0f3cb305
FB
339# compute mmx state
340if test $mmx = "default"; then
341 if test $cpu = "x86"; then
342 mmx="yes"
343 else
344 mmx="no"
345 fi
346fi
347
ab6c65f6
BF
348# Can only do AltiVec on PowerPC
349if test $altivec = "default"; then
350 if test $cpu = "powerpc"; then
351 altivec="yes"
352 else
353 altivec="no"
354 fi
355fi
356
a4adb608
MN
357# Add processor-specific flags
358TUNECPU="generic"
359if test $tune != "generic"; then
360 case $tune in
361 601|ppc601|PowerPC601)
362 CFLAGS="$CFLAGS -mcpu=601"
363 if test $altivec = "yes"; then
364 echo "WARNING: tuning for PPC601 but altivec enabled !";
365 fi
366 TUNECPU=ppc601
367 ;;
368 603*|ppc603*|PowerPC603*)
369 CFLAGS="$CFLAGS -mcpu=603"
370 if test $altivec = "yes"; then
371 echo "WARNING: tuning for PPC603 but altivec enabled !";
372 fi
373 TUNECPU=ppc603
374 ;;
375 604*|ppc604*|PowerPC604*)
376 CFLAGS="$CFLAGS -mcpu=604"
377 if test $altivec = "yes"; then
378 echo "WARNING: tuning for PPC604 but altivec enabled !";
379 fi
380 TUNECPU=ppc604
381 ;;
382 G3|75*|ppc75*|PowerPC75*)
3efd4952 383 CFLAGS="$CFLAGS -mcpu=750 -mtune=750"
a4adb608
MN
384 if test $altivec = "yes"; then
385 echo "WARNING: tuning for PPC75x but altivec enabled !";
386 fi
387 TUNECPU=ppc750
388 ;;
3efd4952
RD
389 G4|745*|ppc745*|PowerPC745*)
390 CFLAGS="$CFLAGS -mcpu=7450 -mtune=7450"
391 if test $altivec = "no"; then
392 echo "WARNING: tuning for PPC745x but altivec disabled !";
393 fi
394 TUNECPU=ppc7450
395 ;;
396 74*|ppc74*|PowerPC74*)
397 CFLAGS="$CFLAGS -mcpu=7400 -mtune=7400"
a4adb608
MN
398 if test $altivec = "no"; then
399 echo "WARNING: tuning for PPC74xx but altivec disabled !";
400 fi
3efd4952 401 TUNECPU=ppc7450
a4adb608
MN
402 ;;
403 G5|970|ppc970|PowerPC970|power4*|Power4*)
404 CFLAGS="$CFLAGS -mcpu=970 -mtune=970 -mpowerpc64 -force_cpusubtype_ALL "
405 if test $altivec = "no"; then
406 echo "WARNING: tuning for PPC970 but altivec disabled !";
407 fi
408 TUNECPU=ppc970
409 ;;
410 *)
411 echo "WARNING: unknown CPU "$tune", ignored"
412 ;;
413 esac
414fi
415
a9a07762
MN
416# See if we have <altivec.h>
417cat > $TMPC << EOF
418#include <altivec.h>
419int main( void ) { return 0; }
420EOF
421
422_altivec_h="no"
423if $cc -o $TMPE $TMPC 2> /dev/null ; then
424_altivec_h="yes"
425fi
426
ab6c65f6
BF
427# See does our compiler support Motorola AltiVec C API
428if test $altivec = "yes"; then
a9a07762 429if test $_altivec_h = "yes"; then
ab6c65f6 430cat > $TMPC << EOF
a9a07762 431#include <altivec.h>
ab6c65f6
BF
432int main(void) {
433 vector signed int v1, v2, v3;
434 v1 = vec_add(v2,v3);
435 return 0;
436}
437EOF
a9a07762
MN
438else
439cat > $TMPC << EOF
440int main(void) {
441 vector signed int v1, v2, v3;
442 v1 = vec_add(v2,v3);
443 return 0;
444}
445EOF
446fi
447if test "$darwin" = "yes"; then
f3ec2d46 448$cc -o $TMPE $TMPC -faltivec 2> /dev/null || altivec="no"
a9a07762
MN
449else
450$cc -o $TMPE $TMPC -maltivec -mabi=altivec 2> /dev/null || altivec="no"
451fi
ab6c65f6
BF
452fi
453
d46aba26
LS
454# Can only do mmi on mips
455if test $mmi = "default"; then
456 if test $cpu = "mips"; then
457 mmi="yes"
458 else
459 mmi="no"
460 fi
461fi
462
463# See does our compiler support mmi
464if test $mmi = "yes"; then
465cat > $TMPC << EOF
466int main(void) {
467 __asm__ ("lq \$2, 0(\$2)");
468 return 0;
469}
470EOF
f3ec2d46 471$cc -o $TMPE $TMPC 2> /dev/null || mmi="no"
d46aba26
LS
472fi
473
daf8e955
FB
474# Checking for CFLAGS
475if test -z "$CFLAGS"; then
29482cb4 476 CFLAGS="-O3"
daf8e955
FB
477fi
478
57514323 479if test "$win32" = "yes" ; then
daf8e955 480 cross_prefix="i386-mingw32msvc-"
5cbcf02c
FB
481 v4l="no"
482 audio_oss="no"
8aa3ee32 483 dv1394="no"
5cbcf02c 484 network="no"
daf8e955
FB
485fi
486
732d9245
BE
487if test "$mingw32" = "yes" ; then
488 cross_prefix=""
489 v4l="no"
490 audio_oss="no"
8aa3ee32 491 dv1394="no"
732d9245
BE
492 network="no"
493fi
494
0f3cb305
FB
495cc="${cross_prefix}${cc}"
496ar="${cross_prefix}${ar}"
be7109c1 497ranlib="${cross_prefix}${ranlib}"
0f3cb305
FB
498strip="${cross_prefix}${strip}"
499
487a54d7
FB
500if test -z "$cross_prefix" ; then
501
3d204385 502# ---
a3999908
MN
503# big/little endian test
504cat > $TMPC << EOF
505#include <inttypes.h>
506int main(int argc, char ** argv){
507 volatile uint32_t i=0x01234567;
508 return (*((uint8_t*)(&i))) == 0x67;
509}
510EOF
511
f3ec2d46
SG
512if $cc -o $TMPE $TMPC 2>/dev/null ; then
513$TMPE && bigendian="yes"
a3999908
MN
514else
515echo big/little test failed
516fi
517
487a54d7
FB
518else
519
520# if cross compiling, cannot launch a program, so make a static guess
521if test "$cpu" = "powerpc" -o "$cpu" = "mips" ; then
522 bigendian="yes"
523fi
524
525fi
526
a3999908 527# ---
3d204385
NK
528# check availability of some header files
529
530cat > $TMPC << EOF
531#include <malloc.h>
532int main( void ) { return 0; }
533EOF
534
535_memalign=no
536_malloc_h=no
f3ec2d46 537if $cc -o $TMPE $TMPC 2> /dev/null ; then
3d204385
NK
538_malloc_h=yes
539_memalign=yes
540# check for memalign - atmos
541cat > $TMPC << EOF
542#include <malloc.h>
543int main ( void ) {
544char *string = NULL;
545string = memalign(64, sizeof(char));
546return 0;
547}
548EOF
f3ec2d46 549$cc -o $TMPE $TMPC 2> /dev/null || _memalign=no
3d204385
NK
550fi
551
68892110
PG
552cat > $TMPC << EOF
553#define _GNU_SOURCE
554#include <time.h>
555int main( void ) { return *strptime("", "", 0); }
556EOF
557
558strptime=no
f3ec2d46 559if $cc -o $TMPE $TMPC 2> /dev/null ; then
68892110
PG
560 strptime=yes
561fi
562
0147f198
FR
563if test "$zlib" = "yes"; then
564# check for zlib - mmu_man
565cat > $TMPC << EOF
566#include <zlib.h>
567int main ( void ) {
568if (zlibVersion() != ZLIB_VERSION)
569 puts("zlib version differs !!!");
570 return 1;
571return 0;
572}
573EOF
f3ec2d46
SG
574$cc -o $TMPE $TMPC -lz 2> /dev/null || zlib="no"
575# $TMPE 2> /dev/null > /dev/null || zlib="no"
0147f198
FR
576# XXX: more tests needed - runtime test
577fi
578if test "$zlib" = "yes"; then
579extralibs="$extralibs -lz"
580fi
581
95e2ce4a
MN
582# test for lrintf in math.h
583cat > $TMPC << EOF
584#define _ISOC9X_SOURCE 1
585#include <math.h>
586int main( void ) { return (lrintf(3.999f) > 0)?0:1; }
587EOF
588
589have_lrintf="no"
f3ec2d46 590if $cc $extralibs -o $TMPE $TMPC 2> /dev/null ; then
95e2ce4a 591 have_lrintf="yes"
f3ec2d46 592 $TMPE 2> /dev/null > /dev/null || have_lrintf="no"
95e2ce4a
MN
593fi
594
c13e1abd
FH
595_restrict=
596for restrict_keyword in restrict __restrict__ __restrict; do
597 echo "void foo(char * $restrict_keyword p);" > $TMPC
598 if $cc -c -o $TMPO $TMPC 2> /dev/null; then
599 _restrict=$restrict_keyword
600 break;
601 fi
602done
603
52b41d7f
FB
604# test gcc version to see if vector builtins can be used
605# currently only used on i386 for MMX builtins
606cat > $TMPC << EOF
607int main(void) {
608#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 2)
609return 0;
610#else
611#error no vector builtins
612#endif
613}
614EOF
615
616builtin_vector=no
617if $cc -o $TMPO $TMPC 2> /dev/null ; then
618 builtin_vector=yes
a8721c09
FB
619fi
620
621# dlopen/dlfcn.h probing
622
623cat > $TMPC << EOF
624#include <dlfcn.h>
625int main( void ) { return (int) dlopen("foo", 0); }
626EOF
627
628ldl=-ldl
629
630if $cc -o $TMPE $TMPC -ldl 2> /dev/null ; then
631dlfcn=yes
632dlopen=yes
633fi
634
635if $cc -o $TMPE $TMPC 2> /dev/null ; then
636dlfcn=yes
637dlopen=yes
638ldl=""
639fi
640
641cat > $TMPC << EOF
642int main( void ) { return (int) dlopen("foo", 0); }
643EOF
644
645if $cc -o $TMPE $TMPC -ldl 2> /dev/null ; then
646dlopen=yes
647fi
648
649if $cc -o $TMPE $TMPC 2> /dev/null ; then
650dlopen=yes
651ldl=""
652fi
653
654if test "$vhook" = "default" ; then
655 vhook="$dlopen"
656fi
657
a86b921c
FB
658##########################################
659# imlib probe
660
a8721c09
FB
661cat > $TMPC << EOF
662#include <X11/Xlib.h>
663#include <Imlib2.h>
664int main( void ) { return (int) imlib_load_font("foo"); }
665EOF
666
667imlib2=no
668if $cc -o $TMPE $TMPC -lImlib2 2> /dev/null ; then
669imlib2=yes
52b41d7f
FB
670fi
671
a86b921c
FB
672##########################################
673# freetype probe
674
04511d53
PG
675cat > $TMPC << EOF
676#include <ft2build.h>
677int main( void ) { return (int) FT_Init_FreeType(0); }
678EOF
679
680freetype2=no
69db4e10 681if test "x$targetos" != "xBeOS" && test "$os2" != "yes"; then
6e023978 682 if test "`which freetype-config`" != ""; then
04511d53 683 if $cc -o $TMPE $TMPC `freetype-config --cflags` `freetype-config --libs` 2> /dev/null ; then
dee076fc 684 freetype2=yes
04511d53 685 fi
dee076fc 686 fi
04511d53
PG
687fi
688
a86b921c
FB
689##########################################
690# SDL probe
691
692cat > $TMPC << EOF
693#include <SDL.h>
31319a8c 694#undef main /* We don't want SDL to override our main() */
a86b921c
FB
695int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
696EOF
697
698sdl_too_old=no
699sdl=no
700if $cc -o $TMPE `sdl-config --cflags` $TMPC `sdl-config --libs` 2> /dev/null ; then
701_sdlversion=`sdl-config --version | sed 's/[^0-9]//g'`
702if test "$_sdlversion" -lt 121 ; then
703sdl_too_old=yes
704else
705sdl=yes
706fi
707fi
708
94a3401e
FB
709if test "$sdl" = "no" ; then
710 ffplay=no
711fi
712
c9f97d82 713if test "$small" = "yes"; then
98ca7790 714# CFLAGS=${CFLAGS//-O3/-Os}
553a6284
MN
715 CFLAGS="$CFLAGS -Os"
716fi
717
6063bce7 718if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
0f3cb305
FB
719cat << EOF
720
721Usage: configure [options]
722Options: [defaults in brackets after descriptions]
723
724EOF
725echo "Standard options:"
726echo " --help print this message"
727echo " --prefix=PREFIX install in PREFIX [$prefix]"
0f3cb305 728echo " --enable-mp3lame enable mp3 encoding via libmp3lame [default=no]"
81e0d0b4 729echo " --enable-vorbis enable vorbis support via libvorbisenc [default=no]"
0fc50e58
ZK
730echo " --enable-faad enable faad support via libfaad [default=no]"
731echo " --enable-faadbin build faad support with runtime linking [default=no]"
0f3cb305 732echo " --enable-win32 enable win32 cross compile"
732d9245 733echo " --enable-mingw32 enable mingw32 native windows compile"
5cbcf02c 734echo " --disable-a52 disable GPL'ed A52 support [default=no]"
0f3cb305 735echo " --enable-a52bin open liba52.so.0 at runtime [default=no]"
bba9b16c
MN
736echo " --disable-pp disable GPL'ed post processing support [default=no]"
737echo " --enable-shared-pp use libpostproc.so [default=no]"
0f3cb305 738echo " --enable-shared build shared libraries [default=no]"
bc634f6f
ZK
739echo " --enable-amr_nb enable amr_nb float audio codec"
740echo " --enable-amr_nb-fixed use fixed point for amr-nb codec"
0f3cb305
FB
741echo ""
742echo "Advanced options (experts only):"
743echo " --source-path=PATH path of source code [$source_path]"
744echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]"
745echo " --cc=CC use C compiler CC [$cc]"
4a908fbc 746echo " --make=MAKE use specified make [$make]"
0f3cb305
FB
747echo " --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS [$CFLAGS]"
748echo " --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]"
749echo " --extra-libs=ELIBS add ELIBS [$ELIBS]"
750echo " --cpu=CPU force cpu to CPU [$cpu]"
a4adb608 751echo " --tune=PROCESSOR tune code for a particular CPU (may fails or misperforms on other CPUs)"
0f3cb305 752echo " --disable-mmx disable mmx usage"
ab6c65f6 753echo " --disable-altivec disable AltiVec usage"
5cbcf02c 754echo " --disable-audio-oss disable OSS audio support [default=no]"
dfdfa47c 755echo " --disable-audio-beos disable BeOS audio support [default=no]"
6063bce7 756echo " --disable-v4l disable video4linux grabbing [default=no]"
8aa3ee32 757echo " --disable-dv1394 disable DV1394 grabbing [default=no]"
5cbcf02c 758echo " --disable-network disable network support [default=no]"
0147f198 759echo " --disable-zlib disable zlib [default=no]"
5cbcf02c 760echo " --disable-simple_idct disable simple IDCT routines [default=no]"
47930f09 761echo " --disable-vhook disable video hooking support"
0f3cb305 762echo " --enable-gprof enable profiling with gprof [$gprof]"
1eb2212e
FB
763echo " --disable-mpegaudio-hp faster (but less accurate)"
764echo " mpegaudio decoding [default=no]"
8154d2e0 765echo " --disable-ffserver disable ffserver build"
a86b921c 766echo " --disable-ffplay disable ffplay build"
1d0d55da 767echo " --disable-risky disables patent encumbered codecs"
553a6284 768echo " --enable-small optimize for size instead of speed"
0f3cb305
FB
769echo ""
770echo "NOTE: The object files are build at the place where configure is launched"
771exit 1
772fi
773
de6d9b64 774echo "Install prefix $prefix"
0f3cb305 775echo "Source path $source_path"
de6d9b64 776echo "C compiler $cc"
4a908fbc 777echo "make $make"
a4adb608 778echo "CPU $cpu ($tune)"
0f3cb305 779echo "Big Endian $bigendian"
e41e8342 780if test $cpu = "x86"; then
de6d9b64 781echo "MMX enabled $mmx"
52b41d7f 782echo "Vector Builtins $builtin_vector"
e41e8342
FB
783fi
784if test $cpu = "mips"; then
d46aba26 785echo "MMI enabled $mmi"
e41e8342
FB
786fi
787if test $cpu = "powerpc"; then
ab6c65f6 788echo "AltiVec enabled $altivec"
e41e8342 789fi
de6d9b64 790echo "gprof enabled $gprof"
0147f198 791echo "zlib enabled $zlib"
a6741398 792echo "mp3lame enabled $mp3lame"
81e0d0b4 793echo "vorbis enabled $vorbis"
445ad18d
ZK
794echo "faad enabled $faad"
795echo "faadbin enabled $faadbin"
5cbcf02c 796echo "a52 support $a52"
57514323 797echo "a52 dlopened $a52bin"
bba9b16c
MN
798echo "pp support $pp"
799echo "shared pp $shared_pp"
47930f09 800echo "Video hooking $vhook"
a86b921c
FB
801echo "SDL support $sdl"
802if test $sdl_too_old = "yes"; then
803echo "-> Your SDL version is too old - please upgrade to have FFplay/SDL support"
804fi
1d0d55da 805echo "risky / patent encumbered codecs $risky"
553a6284 806echo "optimize for size $small"
68892110
PG
807
808if test "$vhook" = "yes" ; then
47930f09 809echo "Imlib2 support $imlib2"
04511d53 810echo "freetype support $freetype2"
68892110 811fi
bc634f6f
ZK
812echo "AMR-NB float support" $amr_nb
813echo "AMR-NB fixed support" $amr_nb_fixed
de6d9b64 814
980fc7b8 815echo "Creating config.mak and config.h"
de6d9b64 816
980fc7b8 817echo "# Automatically generated by configure - do not modify" > config.mak
045ed63f 818echo "/* Automatically generated by configure - do not modify */" > $TMPH
de6d9b64 819
980fc7b8 820echo "prefix=$prefix" >> config.mak
4a908fbc 821echo "MAKE=$make" >> config.mak
980fc7b8
FB
822echo "CC=$cc" >> config.mak
823echo "AR=$ar" >> config.mak
be7109c1 824echo "RANLIB=$ranlib" >> config.mak
0f3cb305 825echo "STRIP=$strip" >> config.mak
a9b3f630 826echo "OPTFLAGS=$CFLAGS" >> config.mak
0f3cb305 827echo "LDFLAGS=$LDFLAGS" >> config.mak
4baca069 828echo "FFSLDFLAGS=$FFSLDFLAGS" >> config.mak
e1707f52 829echo "SHFLAGS=$SHFLAGS" >> config.mak
f3ec2d46
SG
830echo "LIBPREF=$LIBPREF" >> config.mak
831echo "LIBSUF=$LIBSUF" >> config.mak
832echo "SLIBPREF=$SLIBPREF" >> config.mak
833echo "SLIBSUF=$SLIBSUF" >> config.mak
6852ac95 834echo "TARGET_OS=$TARGET_OS" >> config.mak
57514323 835if test "$cpu" = "x86" ; then
980fc7b8 836 echo "TARGET_ARCH_X86=yes" >> config.mak
045ed63f 837 echo "#define ARCH_X86 1" >> $TMPH
0f3cb305 838elif test "$cpu" = "armv4l" ; then
6ed7422a 839 echo "TARGET_ARCH_ARMV4L=yes" >> config.mak
045ed63f 840 echo "#define ARCH_ARMV4L 1" >> $TMPH
0f3cb305 841elif test "$cpu" = "alpha" ; then
91d1f1a4 842 echo "TARGET_ARCH_ALPHA=yes" >> config.mak
045ed63f 843 echo "#define ARCH_ALPHA 1" >> $TMPH
35fedfc3
PG
844elif test "$cpu" = "sparc64" ; then
845 echo "TARGET_ARCH_SPARC64=yes" >> config.mak
846 echo "#define ARCH_SPARC64 1" >> $TMPH
0f3cb305
FB
847elif test "$cpu" = "powerpc" ; then
848 echo "TARGET_ARCH_POWERPC=yes" >> config.mak
849 echo "#define ARCH_POWERPC 1" >> $TMPH
35e5fb06
RD
850 echo "// Enable the next line to get PowerPC performance report" >> $TMPH
851 echo "// #define POWERPC_TBL_PERFORMANCE_REPORT 1" >> $TMPH
852 echo "// Enable the next line to use PMC registers instead of TBL" >> $TMPH
853 echo "// #define POWERPC_PERF_USE_PMC 1" >> $TMPH
d46aba26
LS
854elif test "$cpu" = "mips" ; then
855 echo "TARGET_ARCH_MIPS=yes" >> config.mak
856 echo "#define ARCH_MIPS 1" >> $TMPH
0f3cb305 857fi
a4adb608 858echo "#define TUNECPU $TUNECPU" >> $TMPH
0f3cb305
FB
859if test "$bigendian" = "yes" ; then
860 echo "WORDS_BIGENDIAN=yes" >> config.mak
861 echo "#define WORDS_BIGENDIAN 1" >> $TMPH
91d1f1a4 862fi
57514323 863if test "$mmx" = "yes" ; then
980fc7b8 864 echo "TARGET_MMX=yes" >> config.mak
045ed63f 865 echo "#define HAVE_MMX 1" >> $TMPH
e82c5a8c 866 echo "#define __CPU__ 586" >> $TMPH
de6d9b64 867fi
52b41d7f
FB
868if test "$builtin_vector" = "yes" ; then
869 echo "TARGET_BUILTIN_VECTOR=yes" >> config.mak
870 echo "#define HAVE_BUILTIN_VECTOR 1" >> $TMPH
871fi
d46aba26
LS
872if test "$mmi" = "yes" ; then
873 echo "TARGET_MMI=yes" >> config.mak
874 echo "#define HAVE_MMI 1" >> $TMPH
875fi
ab6c65f6
BF
876if test "$altivec" = "yes" ; then
877 echo "TARGET_ALTIVEC=yes" >> config.mak
878 echo "#define HAVE_ALTIVEC 1" >> $TMPH
db40a39a
MN
879 echo "// Enable the next line to use the reference C code instead of AltiVec" >> $TMPH
880 echo "// #define ALTIVEC_USE_REFERENCE_C_CODE 1" >> $TMPH
a9a07762
MN
881 if test "$_altivec_h" = "yes" ; then
882 echo "#define HAVE_ALTIVEC_H 1" >> $TMPH
883 else
e67e14d5 884 echo "#undef HAVE_ALTIVEC_H" >> $TMPH
a9a07762 885 fi
ab6c65f6 886fi
57514323 887if test "$gprof" = "yes" ; then
980fc7b8 888 echo "TARGET_GPROF=yes" >> config.mak
045ed63f 889 echo "#define HAVE_GPROF 1" >> $TMPH
de6d9b64 890fi
68892110
PG
891if test "$strptime" = "yes" ; then
892 echo "#define HAVE_STRPTIME 1" >> $TMPH
893else
894 echo "BUILD_STRPTIME=yes" >> config.mak
895fi
896if test "$imlib2" = "yes" ; then
897 echo "HAVE_IMLIB2=yes" >> config.mak
898fi
04511d53
PG
899if test "$freetype2" = "yes" ; then
900 echo "HAVE_FREETYPE2=yes" >> config.mak
901fi
a86b921c
FB
902if test "$sdl" = "yes" ; then
903 echo "CONFIG_SDL=yes" >> config.mak
904 echo "SDL_LIBS=`sdl-config --libs`" >> config.mak
905 echo "SDL_CFLAGS=`sdl-config --cflags`" >> config.mak
906fi
95e2ce4a
MN
907if test "$have_lrintf" = "yes" ; then
908 echo "#define HAVE_LRINTF 1" >> $TMPH
909fi
68892110
PG
910if test "$vhook" = "yes" ; then
911 echo "BUILD_VHOOK=yes" >> config.mak
912 echo "#define HAVE_VHOOK 1" >> $TMPH
9c938e77 913 extralibs="$extralibs $ldl"
68892110 914fi
57514323 915if test "$lshared" = "yes" ; then
0319c531 916 echo "BUILD_SHARED=yes" >> config.mak
5cbcf02c 917 echo "PIC=-fPIC" >> config.mak
0319c531 918fi
ef0bc4c9 919echo "EXTRALIBS=$extralibs" >> config.mak
586bc755 920echo "VERSION=`head $source_path/VERSION`" >>config.mak
0319c531 921echo "" >>config.mak
d771bcae 922# if you do not want to use encoders, disable that.
045ed63f 923echo "#define CONFIG_ENCODERS 1" >> $TMPH
d771bcae
FB
924echo "CONFIG_ENCODERS=yes" >> config.mak
925
926# if you do not want to use decoders, disable that.
045ed63f 927echo "#define CONFIG_DECODERS 1" >> $TMPH
d771bcae
FB
928echo "CONFIG_DECODERS=yes" >> config.mak
929
5cbcf02c
FB
930# AC3
931if test "$a52" = "yes" ; then
932 echo "#define CONFIG_AC3 1" >> $TMPH
933 echo "CONFIG_AC3=yes" >> config.mak
d771bcae 934
5cbcf02c
FB
935 if test "$a52bin" = "yes" ; then
936 echo "#define CONFIG_A52BIN 1" >> $TMPH
937 echo "CONFIG_A52BIN=yes" >> config.mak
938 fi
939fi
940
bba9b16c
MN
941# PP
942if test "$pp" = "yes" ; then
943 echo "#define CONFIG_PP 1" >> $TMPH
944 echo "CONFIG_PP=yes" >> config.mak
945
946 if test "$shared_pp" = "yes" ; then
947 echo "#define SHARED_PP 1" >> $TMPH
948 echo "SHARED_PP=yes" >> config.mak
949 fi
950fi
951
1eb2212e
FB
952# mpeg audio high precision mode
953if test "$mpegaudio_hp" = "yes" ; then
954 echo "#define CONFIG_MPEGAUDIO_HP 1" >> $TMPH
955fi
956
5cbcf02c
FB
957if test "$v4l" = "yes" ; then
958 echo "#define CONFIG_VIDEO4LINUX 1" >> $TMPH
959 echo "CONFIG_VIDEO4LINUX=yes" >> config.mak
960fi
961
8aa3ee32
MK
962if test "$dv1394" = "yes" ; then
963 echo "#define CONFIG_DV1394 1" >> $TMPH
964 echo "CONFIG_DV1394=yes" >> config.mak
965fi
966
adbc0510
PG
967if test "$dlopen" = "yes" ; then
968 echo "#define CONFIG_HAVE_DLOPEN 1" >> $TMPH
969fi
970
971if test "$dlfcn" = "yes" ; then
972 echo "#define CONFIG_HAVE_DLFCN 1" >> $TMPH
973fi
974
5cbcf02c
FB
975if test "$audio_oss" = "yes" ; then
976 echo "#define CONFIG_AUDIO_OSS 1" >> $TMPH
977 echo "CONFIG_AUDIO_OSS=yes" >> config.mak
57514323
ZK
978fi
979
dfdfa47c
FR
980if test "$audio_beos" = "yes" ; then
981 echo "#define CONFIG_AUDIO_BEOS 1" >> $TMPH
982 echo "CONFIG_AUDIO_BEOS=yes" >> config.mak
983fi
984
5cbcf02c
FB
985if test "$network" = "yes" ; then
986 echo "#define CONFIG_NETWORK 1" >> $TMPH
987 echo "CONFIG_NETWORK=yes" >> config.mak
6ed7422a 988fi
daf8e955 989
0147f198
FR
990if test "$zlib" = "yes" ; then
991 echo "#define CONFIG_ZLIB 1" >> $TMPH
992 echo "CONFIG_ZLIB=yes" >> config.mak
993fi
994
57514323 995if test "$mp3lame" = "yes" ; then
045ed63f 996 echo "#define CONFIG_MP3LAME 1" >> $TMPH
a6741398
J
997 echo "CONFIG_MP3LAME=yes" >> config.mak
998fi
999
81e0d0b4
MH
1000if test "$vorbis" = "yes" ; then
1001 echo "#define CONFIG_VORBIS 1" >> $TMPH
1002 echo "CONFIG_VORBIS=yes" >> config.mak
1003fi
1004
0fc50e58
ZK
1005if test "$faad" = "yes" ; then
1006 echo "#define CONFIG_FAAD 1" >> $TMPH
1007 echo "CONFIG_FAAD=yes" >> config.mak
1008fi
1009
1010if test "$faadbin" = "yes" ; then
1011 echo "#define CONFIG_FAADBIN 1" >> $TMPH
445ad18d 1012 echo "CONFIG_FAADBIN=yes" >> config.mak
0fc50e58
ZK
1013fi
1014
57514323 1015if test "$win32" = "yes" ; then
045ed63f 1016 echo "#define CONFIG_WIN32 1" >> $TMPH
daf8e955
FB
1017 echo "CONFIG_WIN32=yes" >> config.mak
1018fi
3d204385 1019
732d9245
BE
1020if test "$mingw32" = "yes" ; then
1021 echo "#define CONFIG_WIN32 1" >> $TMPH
1022 echo "CONFIG_WIN32=yes" >> config.mak
1023 echo "#define __MINGW32__ 1" >> $TMPH
1024 echo "__MINGW32__=1" >> config.mak
1025fi
1026
3f027ca7
FB
1027if test "$cygwin" = "yes" ; then
1028 # setup correct exesuffix
1029 echo "CONFIG_WIN32=yes" >> config.mak
1030fi
1031
f3ec2d46
SG
1032if test "$os2" = "yes" ; then
1033 echo "#define CONFIG_OS2 1" >> $TMPH
1034 echo "CONFIG_OS2=yes" >> config.mak
1035fi
1036
6e023978
RS
1037if test "$TARGET_OS" = "SunOS" ; then
1038 echo "#define CONFIG_SUNOS 1" >> $TMPH
1039fi
1040
90cee0c3
MN
1041if test "$darwin" = "yes"; then
1042 echo "#define CONFIG_DARWIN 1" >> $TMPH
1043 echo "CONFIG_DARWIN=yes" >> config.mak
1044fi
1045
57514323 1046if test "$_malloc_h" = "yes" ; then
045ed63f 1047 echo "#define HAVE_MALLOC_H 1" >> $TMPH
3d204385 1048else
045ed63f 1049 echo "#undef HAVE_MALLOC_H" >> $TMPH
3d204385
NK
1050fi
1051
57514323 1052if test "$_memalign" = "yes" ; then
045ed63f
ZK
1053 echo "#define HAVE_MEMALIGN 1" >> $TMPH
1054else
1055 echo "#undef HAVE_MEMALIGN" >> $TMPH
1056fi
1057
26b35efb
FR
1058if test "$netserver" = "yes" ; then
1059 echo "#define CONFIG_BEOS_NETSERVER 1" >> $TMPH
1060 echo "CONFIG_BEOS_NETSERVER=yes" >> config.mak
1061fi
1062
4baca069
PG
1063if test "$need_inet_aton" = "yes" ; then
1064 echo "NEED_INET_ATON=yes" >> config.mak
1065fi
1066
57514323 1067if test "$simpleidct" = "yes" ; then
045ed63f
ZK
1068 echo "#define SIMPLE_IDCT 1" >> $TMPH
1069fi
1070
8154d2e0
FB
1071if test "$ffserver" = "yes" ; then
1072 echo "#define CONFIG_FFSERVER 1" >> $TMPH
1073 echo "CONFIG_FFSERVER=yes" >> config.mak
1074fi
1075
a86b921c
FB
1076if test "$ffplay" = "yes" ; then
1077 echo "CONFIG_FFPLAY=yes" >> config.mak
1078fi
1079
1d0d55da
MN
1080if test "$risky" = "yes" ; then
1081 echo "#define CONFIG_RISKY 1" >> $TMPH
1082 echo "CONFIG_RISKY=yes" >> config.mak
1083fi
1084
c13e1abd
FH
1085echo "#define restrict $_restrict" >> $TMPH
1086
0f3cb305
FB
1087# build tree in object directory if source path is different from current one
1088if test "$source_path_used" = "yes" ; then
a382b927 1089 DIRS="libavformat libavcodec libavcodec/alpha libavcodec/armv4l libavcodec/i386 \
5f6b58de
MR
1090 libavcodec/ppc libavcodec/liba52 libavcodec/mlib libavcodec/libpostproc tests vhook"
1091 FILES="Makefile libavformat/Makefile libavcodec/Makefile libavcodec/libpostproc/Makefile tests/Makefile vhook/Makefile"
0f3cb305
FB
1092 for dir in $DIRS ; do
1093 mkdir -p $dir
1094 done
1095 for f in $FILES ; do
1096 ln -sf $source_path/$f $f
1097 done
1098fi
1099echo "SRC_PATH=$source_path" >> config.mak
1100
891f64b3 1101if test "$amr_nb" = "yes" ; then
1102 echo "#define AMR_NB 1" >> $TMPH
1103 echo "AMR_NB=yes" >> config.mak
1104 echo
bc634f6f
ZK
1105if test "$amr_nb_fixed" = "yes" ; then
1106 echo "AMR_NB_FIXED=yes" >> config.mak
1107 echo "#define AMR_NB_FIXED 1" >> $TMPH
1108 echo "AMR NB FIXED POINT NOTICE! Make sure you have downloaded TS26.073 "
1109 echo "REL-5 version 5.1.0 from "
891f64b3 1110 echo "http://www.3gpp.org/ftp/Specs/latest/Rel-5/26_series/26073-510.zip"
1111 echo "and extracted src to libavcodec/amr"
bc634f6f
ZK
1112 echo "You must also add -DMMS_IO and remove -pedantic-errors to/from CFLAGS in libavcodec/amr/makefile."
1113 echo "i.e. CFLAGS = -Wall -I. \$(CFLAGS_\$(MODE)) -D\$(VAD) -DMMS_IO"
1114 echo
1115else
1116 echo "AMR NB FLOAT NOTICE ! Make sure you have downloaded TS26.104"
1117 echo "REL-5 V5.1.0 from "
1118 echo "http://www.3gpp.org/ftp/Specs/latest/Rel-5/26_series/26104-510.zip"
1119 echo "and extracted the source to libavcodec/amr_float"
891f64b3 1120 echo
1121fi
1122
bc634f6f
ZK
1123fi
1124
a7c02e25 1125diff $TMPH config.h >/dev/null 2>&1
045ed63f
ZK
1126if test $? -ne 0 ; then
1127 mv -f $TMPH config.h
3d204385 1128else
045ed63f 1129 echo "config.h is unchanged"
3d204385
NK
1130fi
1131
f3ec2d46 1132rm -f $TMPO $TMPC $TMPE $TMPS $TMPH