Statistics
| Branch: | Revision:

ffmpeg / configure @ 31ba0b4d

History | View | Annotate | Download (14.7 KB)

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
ranlib="ranlib"
25
make="make"
26
strip="strip"
27
cpu=`uname -m`
28
mmx="default"
29
altivec="default"
30
mmi="default"
31
case "$cpu" in
32
  i386|i486|i586|i686|i86pc|BePC)
33
    cpu="x86"
34
  ;;
35
  armv4l)
36
    cpu="armv4l"
37
  ;;
38
  alpha)
39
    cpu="alpha"
40
  ;;
41
  "Power Macintosh"|ppc)
42
    cpu="powerpc"
43
  ;;
44
  mips)
45
    cpu="mips"
46
  ;;
47
  *)
48
    cpu="unknown"
49
  ;;
50
esac
51
gprof="no"
52
v4l="yes"
53
audio_oss="yes"
54
network="yes"
55
zlib="yes"
56
mp3lame="no"
57
vorbis="no"
58
a52="yes"
59
a52bin="no"
60
win32="no"
61
cygwin="no"
62
lshared="no"
63
extralibs="-lm"
64
simpleidct="yes"
65
bigendian="no"
66
vhook="no"
67
mpegaudio_hp="yes"
68
SHFLAGS=-shared
69
netserver="no"
70

    
71
# OS specific
72
targetos=`uname -s`
73
case $targetos in
74
BeOS)
75
prefix="/boot/home/config"
76
# helps building libavcodec
77
CFLAGS="-O3 -DPIC -fomit-frame-pointer"
78
# 3 gcc releases known for BeOS, each with ugly bugs
79
gcc_version="$($cc -v 2>&1 | grep version | cut -d ' ' -f3-)"
80
case "$gcc_version" in
81
2.9-beos-991026*|2.9-beos-000224*) echo "R5/GG gcc"
82
mmx="no"
83
;;
84
*20010315*) echo "BeBits gcc"
85
CFLAGS="$CFLAGS -fno-expensive-optimizations"
86
;;
87
esac
88
SHFLAGS=-nostart
89
# disable linux things
90
audio_oss="no"
91
v4l="no"
92
# no need for libm, but the inet stuff
93
# Check for BONE
94
if (echo $BEINCLUDES|grep 'headers/be/bone' >/dev/null); then
95
extralibs="-lbind -lsocket"
96
else
97
netserver="yes"
98
extralibs="-lnet"
99
fi ;;
100
BSD/OS)
101
v4l="no"
102
audio_oss="yes"
103
extralibs="-lpoll -lgnugetopt -lm"
104
make="gmake"
105
;;
106
Darwin)
107
cc="cc"
108
v4l="no"
109
audio_oss="no"
110
CFLAGS="-no-cpp-precomp -pipe -O3 -fomit-frame-pointer -mdynamic-no-pic"
111
SHFLAGS="-dynamiclib"
112
extralibs=""
113
darwin="yes"
114
;;
115
CYGWIN*)
116
v4l="no"
117
audio_oss="yes"
118
extralibs=""
119
cygwin="yes"
120
test -f /usr/include/inttypes.h || \
121
test -f /usr/local/include/inttypes.h || \
122
echo "Missing inttypes.h, please copy cygwin_inttypes.h to" \
123
     "/usr/include/inttypes.h !!!"
124
;;
125
*) ;;
126
esac
127

    
128
# find source path
129
# XXX: we assume an absolute path is given when launching configure, 
130
# except in './configure' case.
131
source_path=${0%configure}
132
source_path=${source_path%/}
133
source_path_used="yes"
134
if test -z "$source_path" -o "$source_path" = "." ; then
135
    source_path=`pwd`
136
    source_path_used="no"
137
fi
138

    
139
cat > $TMPC << EOF
140
#include <dlfcn.h>
141
int main( void ) { return (int) dlopen("foo", 0); }
142
EOF
143

    
144
if $cc -o $TMPO $TMPC -ldl 2> /dev/null  ; then
145
: vhook=yes
146
fi
147

    
148
cat > $TMPC << EOF
149
#include <X11/Xlib.h>
150
#include <Imlib2.h>
151
int main( void ) { return (int) imlib_load_font("foo"); }
152
EOF
153

    
154
imlib2=no
155
if $cc -o $TMPO $TMPC -lImlib2 2> /dev/null  ; then
156
imlib2=yes
157
fi
158

    
159
for opt do
160
  case "$opt" in
161
  --prefix=*) prefix=`echo $opt | cut -d '=' -f 2`
162
  ;;
163
  --source-path=*) source_path=`echo $opt | cut -d '=' -f 2`
164
  ;;
165
  --cross-prefix=*) cross_prefix=`echo $opt | cut -d '=' -f 2`
166
  ;;
167
  --cc=*) cc=`echo $opt | cut -d '=' -f 2`
168
  ;;
169
  --make=*) make=`echo $opt | cut -d '=' -f 2`
170
  ;;
171
  --extra-cflags=*) CFLAGS="${opt#--extra-cflags=}"
172
  ;;
173
  --extra-ldflags=*) LDFLAGS=${opt#--extra-ldflags=}
174
  ;;
175
  --extra-libs=*) extralibs=${opt#--extra-libs=}
176
  ;;
177
  --cpu=*) cpu=`echo $opt | cut -d '=' -f 2`
178
  ;;
179
  --disable-mmx) mmx="no"
180
  ;;
181
  --disable-altivec) altivec="no"
182
  ;;
183
  --enable-gprof) gprof="yes"
184
  ;;
185
  --disable-v4l) v4l="no"
186
  ;;
187
  --disable-audio-oss) audio_oss="no"
188
  ;;
189
  --disable-network) network="no"
190
  ;;
191
  --disable-zlib) zlib="no"
192
  ;;
193
  --disable-a52) a52="no"
194
  ;;
195
  --enable-a52bin) a52bin="yes" ; extralibs="-ldl $extralibs"
196
  ;;
197
  --enable-mp3lame) mp3lame="yes"
198
  ;;
199
  --enable-vorbis) vorbis="yes"
200
  ;;
201
  --disable-vhook) vhook="no"
202
  ;;
203
  --disable-simple_idct) simpleidct="no"
204
  ;;
205
  --enable-win32) win32="yes"
206
  ;;
207
  --enable-shared) lshared="yes"
208
  ;;
209
  --disable-mpegaudio-hp) mpegaudio_hp="no"
210
  ;;
211
  esac
212
done
213

    
214
# compute mmx state
215
if test $mmx = "default"; then
216
    if test $cpu = "x86"; then
217
        mmx="yes"
218
    else
219
        mmx="no"
220
    fi
221
fi
222

    
223
# Can only do AltiVec on PowerPC
224
if test $altivec = "default"; then
225
    if test $cpu = "powerpc"; then
226
        altivec="yes"
227
    else
228
        altivec="no"
229
    fi
230
fi
231

    
232
# See does our compiler support Motorola AltiVec C API
233
if test $altivec = "yes"; then
234
cat > $TMPC << EOF
235
int main(void) {
236
    vector signed int v1, v2, v3;
237
    v1 = vec_add(v2,v3);
238
    return 0;
239
}
240
EOF
241
$cc -o $TMPO $TMPC -faltivec 2> /dev/null || altivec="no"
242
fi
243

    
244
# Can only do mmi on mips
245
if test $mmi = "default"; then
246
    if test $cpu = "mips"; then
247
        mmi="yes"
248
    else
249
        mmi="no"
250
    fi
251
fi
252

    
253
# See does our compiler support mmi
254
if test $mmi = "yes"; then
255
cat > $TMPC << EOF
256
int main(void) {
257
    __asm__ ("lq \$2, 0(\$2)");
258
    return 0;
259
}
260
EOF
261
$cc -o $TMPO $TMPC 2> /dev/null || mmi="no"
262
fi
263

    
264
# Checking for CFLAGS
265
if test -z "$CFLAGS"; then
266
    CFLAGS="-O3"
267
fi
268

    
269
if test "$win32" = "yes" ; then
270
    cross_prefix="i386-mingw32msvc-"
271
    v4l="no"
272
    audio_oss="no"
273
    network="no"
274
fi
275

    
276
cc="${cross_prefix}${cc}"
277
ar="${cross_prefix}${ar}"
278
ranlib="${cross_prefix}${ranlib}"
279
strip="${cross_prefix}${strip}"
280

    
281
if test -z "$cross_prefix" ; then
282

    
283
# ---
284
# big/little endian test
285
cat > $TMPC << EOF
286
#include <inttypes.h>
287
int main(int argc, char ** argv){
288
	volatile uint32_t i=0x01234567;
289
	return (*((uint8_t*)(&i))) == 0x67;
290
}
291
EOF
292

    
293
if $cc -o $TMPO $TMPC 2>/dev/null ; then
294
$TMPO && bigendian="yes"
295
else
296
echo big/little test failed
297
fi
298

    
299
else
300

    
301
# if cross compiling, cannot launch a program, so make a static guess
302
if test "$cpu" = "powerpc" -o "$cpu" = "mips" ; then
303
    bigendian="yes"
304
fi
305

    
306
fi
307

    
308
# ---
309
# check availability of some header files
310

    
311
cat > $TMPC << EOF
312
#include <malloc.h>
313
int main( void ) { return 0; }
314
EOF
315

    
316
_memalign=no
317
_malloc_h=no
318
if $cc -o $TMPO $TMPC 2> /dev/null ; then
319
_malloc_h=yes
320
_memalign=yes
321
# check for memalign - atmos
322
cat > $TMPC << EOF
323
#include <malloc.h>
324
int main ( void ) {
325
char *string = NULL;
326
string = memalign(64, sizeof(char));
327
return 0;
328
}
329
EOF
330
$cc -o $TMPO $TMPC 2> /dev/null || _memalign=no
331
fi
332

    
333
cat > $TMPC << EOF
334
#define _GNU_SOURCE
335
#include <time.h>
336
int main( void ) { return *strptime("", "", 0); }
337
EOF
338

    
339
strptime=no
340
if $cc -o $TMPO $TMPC 2> /dev/null ; then
341
  strptime=yes
342
fi
343

    
344
if test "$zlib" = "yes"; then
345
# check for zlib - mmu_man
346
cat > $TMPC << EOF
347
#include <zlib.h>
348
int main ( void ) {
349
if (zlibVersion() != ZLIB_VERSION)
350
   puts("zlib version differs !!!");
351
   return 1;
352
return 0;
353
}
354
EOF
355
$cc -o $TMPO $TMPC -lz 2> /dev/null || zlib="no"
356
# $TMPO 2> /dev/null > /dev/null || zlib="no"
357
# XXX: more tests needed - runtime test
358
fi
359
if test "$zlib" = "yes"; then
360
extralibs="$extralibs -lz"
361
fi
362

    
363
_restrict=
364
for restrict_keyword in restrict __restrict__ __restrict; do
365
  echo "void foo(char * $restrict_keyword p);" > $TMPC
366
  if $cc -c -o $TMPO $TMPC 2> /dev/null; then
367
    _restrict=$restrict_keyword
368
    break;
369
  fi
370
done
371

    
372
if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
373
cat << EOF
374

    
375
Usage: configure [options]
376
Options: [defaults in brackets after descriptions]
377

    
378
EOF
379
echo "Standard options:"
380
echo "  --help                   print this message"
381
echo "  --prefix=PREFIX          install in PREFIX [$prefix]"
382
echo "  --enable-mp3lame         enable mp3 encoding via libmp3lame [default=no]"
383
echo "  --enable-vorbis          enable vorbis support via libvorbisenc [default=no]"
384
echo "  --enable-win32           enable win32 cross compile"
385
echo "  --disable-a52            disable GPL'ed A52 support [default=no]"
386
echo "  --enable-a52bin          open liba52.so.0 at runtime [default=no]"
387
echo "  --enable-shared          build shared libraries [default=no]"
388
echo ""
389
echo "Advanced options (experts only):"
390
echo "  --source-path=PATH       path of source code [$source_path]"
391
echo "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
392
echo "  --cc=CC                  use C compiler CC [$cc]"
393
echo "  --make=MAKE              use specified make [$make]"
394
echo "  --extra-cflags=ECFLAGS   add ECFLAGS to CFLAGS [$CFLAGS]"
395
echo "  --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]"
396
echo "  --extra-libs=ELIBS       add ELIBS [$ELIBS]"
397
echo "  --cpu=CPU                force cpu to CPU  [$cpu]"
398
echo "  --disable-mmx            disable mmx usage"
399
echo "  --disable-altivec        disable AltiVec usage"
400
echo "  --disable-audio-oss      disable OSS audio support [default=no]"
401
echo "  --disable-v4l            disable video4linux grabbing [default=no]"
402
echo "  --disable-network        disable network support [default=no]"
403
echo "  --disable-zlib           disable zlib [default=no]"
404
echo "  --disable-simple_idct    disable simple IDCT routines [default=no]"
405
# echo "  --disable-vhook          disable video hooking support"
406
echo "  --enable-gprof           enable profiling with gprof [$gprof]"
407
echo "  --disable-mpegaudio-hp   faster (but less accurate)"
408
echo "                           mpegaudio decoding [default=no]"
409
echo ""
410
echo "NOTE: The object files are build at the place where configure is launched"
411
exit 1
412
fi
413

    
414
echo "Install prefix   $prefix"
415
echo "Source path      $source_path"
416
echo "C compiler       $cc"
417
echo "make             $make"
418
echo "CPU              $cpu"
419
echo "Big Endian       $bigendian"
420
if test $cpu = "x86"; then
421
echo "MMX enabled      $mmx"
422
fi
423
if test $cpu = "mips"; then
424
echo "MMI enabled      $mmi"
425
fi
426
if test $cpu = "powerpc"; then
427
echo "AltiVec enabled  $altivec"
428
fi
429
echo "gprof enabled    $gprof"
430
echo "zlib enabled     $zlib"
431
echo "mp3lame enabled  $mp3lame"
432
echo "vorbis enabled   $vorbis"
433
echo "a52 support      $a52"
434
echo "a52 dlopened     $a52bin"
435
# echo "Video hooking    $vhook"
436

    
437
if test "$vhook" = "yes" ; then
438
: echo "Imlib2 support   $imlib2"
439
fi
440

    
441
echo "Creating config.mak and config.h"
442

    
443
echo "# Automatically generated by configure - do not modify" > config.mak
444
echo "/* Automatically generated by configure - do not modify */" > $TMPH
445

    
446
echo "prefix=$prefix" >> config.mak
447
echo "MAKE=$make" >> config.mak
448
echo "CC=$cc" >> config.mak
449
echo "AR=$ar" >> config.mak
450
echo "RANLIB=$ranlib" >> config.mak
451
echo "STRIP=$strip" >> config.mak
452
echo "OPTFLAGS=$CFLAGS" >> config.mak
453
echo "LDFLAGS=$LDFLAGS" >> config.mak
454
echo "SHFLAGS=$SHFLAGS" >> config.mak
455
if test "$cpu" = "x86" ; then
456
  echo "TARGET_ARCH_X86=yes" >> config.mak
457
  echo "#define ARCH_X86 1" >> $TMPH
458
elif test "$cpu" = "armv4l" ; then
459
  echo "TARGET_ARCH_ARMV4L=yes" >> config.mak
460
  echo "#define ARCH_ARMV4L 1" >> $TMPH
461
elif test "$cpu" = "alpha" ; then
462
  echo "TARGET_ARCH_ALPHA=yes" >> config.mak
463
  echo "#define ARCH_ALPHA 1" >> $TMPH
464
elif test "$cpu" = "powerpc" ; then
465
  echo "TARGET_ARCH_POWERPC=yes" >> config.mak
466
  echo "#define ARCH_POWERPC 1" >> $TMPH
467
elif test "$cpu" = "mips" ; then
468
  echo "TARGET_ARCH_MIPS=yes" >> config.mak
469
  echo "#define ARCH_MIPS 1" >> $TMPH
470
fi
471
if test "$bigendian" = "yes" ; then
472
  echo "WORDS_BIGENDIAN=yes" >> config.mak
473
  echo "#define WORDS_BIGENDIAN 1" >> $TMPH
474
fi
475
if test "$mmx" = "yes" ; then
476
  echo "TARGET_MMX=yes" >> config.mak
477
  echo "#define HAVE_MMX 1" >> $TMPH
478
fi
479
if test "$mmi" = "yes" ; then
480
  echo "TARGET_MMI=yes" >> config.mak
481
  echo "#define HAVE_MMI 1" >> $TMPH
482
fi
483
if test "$altivec" = "yes" ; then
484
  echo "TARGET_ALTIVEC=yes" >> config.mak
485
  echo "#define HAVE_ALTIVEC 1" >> $TMPH
486
fi
487
if test "$gprof" = "yes" ; then
488
  echo "TARGET_GPROF=yes" >> config.mak
489
  echo "#define HAVE_GPROF 1" >> $TMPH
490
fi
491
if test "$strptime" = "yes" ; then
492
  echo "#define HAVE_STRPTIME 1" >> $TMPH
493
else
494
  echo "BUILD_STRPTIME=yes" >> config.mak
495
fi
496
if test "$imlib2" = "yes" ; then
497
  echo "HAVE_IMLIB2=yes" >> config.mak
498
fi
499
if test "$vhook" = "yes" ; then
500
  echo "BUILD_VHOOK=yes" >> config.mak
501
  echo "#define HAVE_VHOOK 1" >> $TMPH
502
  extralibs="$extralibs -ldl"
503
fi
504
if test "$lshared" = "yes" ; then
505
  echo "BUILD_SHARED=yes" >> config.mak
506
  echo "PIC=-fPIC" >> config.mak
507
fi
508
echo "EXTRALIBS=$extralibs" >> config.mak
509
echo -n "VERSION=" >>config.mak
510
head $source_path/VERSION >>config.mak
511
echo "" >>config.mak
512
# if you do not want to use encoders, disable that.
513
echo "#define CONFIG_ENCODERS 1" >> $TMPH
514
echo "CONFIG_ENCODERS=yes" >> config.mak
515

    
516
# if you do not want to use decoders, disable that.
517
echo "#define CONFIG_DECODERS 1" >> $TMPH
518
echo "CONFIG_DECODERS=yes" >> config.mak
519

    
520
# AC3
521
if test "$a52" = "yes" ; then
522
  echo "#define CONFIG_AC3 1" >> $TMPH
523
  echo "CONFIG_AC3=yes" >> config.mak
524

    
525
  if test "$a52bin" = "yes" ; then
526
    echo "#define CONFIG_A52BIN 1" >> $TMPH
527
    echo "CONFIG_A52BIN=yes" >> config.mak
528
  fi
529
fi
530

    
531
# mpeg audio high precision mode
532
if test "$mpegaudio_hp" = "yes" ; then
533
  echo "#define CONFIG_MPEGAUDIO_HP 1" >> $TMPH
534
fi
535

    
536
if test "$v4l" = "yes" ; then
537
  echo "#define CONFIG_VIDEO4LINUX 1" >> $TMPH
538
  echo "CONFIG_VIDEO4LINUX=yes" >> config.mak
539
fi
540

    
541
if test "$audio_oss" = "yes" ; then
542
  echo "#define CONFIG_AUDIO_OSS 1" >> $TMPH
543
  echo "CONFIG_AUDIO_OSS=yes" >> config.mak
544
fi
545

    
546
if test "$network" = "yes" ; then
547
  echo "#define CONFIG_NETWORK 1" >> $TMPH
548
  echo "CONFIG_NETWORK=yes" >> config.mak
549
fi
550

    
551
if test "$zlib" = "yes" ; then
552
  echo "#define CONFIG_ZLIB 1" >> $TMPH
553
  echo "CONFIG_ZLIB=yes" >> config.mak
554
fi
555

    
556
if test "$mp3lame" = "yes" ; then
557
  echo "#define CONFIG_MP3LAME 1" >> $TMPH
558
  echo "CONFIG_MP3LAME=yes" >> config.mak
559
fi
560

    
561
if test "$vorbis" = "yes" ; then
562
  echo "#define CONFIG_VORBIS 1" >> $TMPH
563
  echo "CONFIG_VORBIS=yes" >> config.mak
564
fi
565

    
566
if test "$win32" = "yes" ; then
567
  echo "#define CONFIG_WIN32 1" >> $TMPH
568
  echo "CONFIG_WIN32=yes" >> config.mak
569
fi
570

    
571
if test "$cygwin" = "yes" ; then
572
  # setup correct exesuffix
573
  echo "CONFIG_WIN32=yes" >> config.mak
574
fi
575

    
576
if test "$darwin" = "yes"; then
577
  echo "#define CONFIG_DARWIN 1"  >> $TMPH
578
  echo "CONFIG_DARWIN=yes" >> config.mak
579
fi
580

    
581
if test "$_malloc_h" = "yes" ; then
582
  echo "#define HAVE_MALLOC_H 1" >> $TMPH
583
else
584
  echo "#undef  HAVE_MALLOC_H" >> $TMPH
585
fi
586

    
587
if test "$_memalign" = "yes" ; then
588
  echo "#define HAVE_MEMALIGN 1" >> $TMPH
589
else
590
  echo "#undef  HAVE_MEMALIGN" >> $TMPH
591
fi
592

    
593
if test "$netserver" = "yes" ; then
594
  echo "#define CONFIG_BEOS_NETSERVER 1" >> $TMPH
595
  echo "CONFIG_BEOS_NETSERVER=yes" >> config.mak
596
fi
597

    
598
if test "$simpleidct" = "yes" ; then
599
  echo "#define SIMPLE_IDCT 1" >> $TMPH
600
fi
601

    
602
echo "#define restrict $_restrict" >> $TMPH
603

    
604
# build tree in object directory if source path is different from current one
605
if test "$source_path_used" = "yes" ; then
606
    DIRS="libav libavcodec libavcodec/alpha libavcodec/armv4l libavcodec/i386 \
607
          libavcodec/ppc libavcodec/liba52 libavcodec/mlib tests"
608
    FILES="Makefile libav/Makefile libavcodec/Makefile tests/Makefile"
609
    for dir in $DIRS ; do
610
            mkdir -p $dir
611
    done
612
    for f in $FILES ; do
613
        ln -sf $source_path/$f $f
614
    done
615
fi
616
echo "SRC_PATH=$source_path" >> config.mak
617

    
618
diff $TMPH config.h >/dev/null 2>&1
619
if test $? -ne 0 ; then
620
	mv -f $TMPH config.h
621
else
622
	echo "config.h is unchanged"
623
fi
624

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