Statistics
| Branch: | Revision:

ffmpeg / configure @ be7109c1

History | View | Annotate | Download (13.4 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
case "$cpu" in
31
  i386|i486|i586|i686|i86pc|BePC)
32
    cpu="x86"
33
  ;;
34
  armv4l)
35
    cpu="armv4l"
36
  ;;
37
  alpha)
38
    cpu="alpha"
39
  ;;
40
  "Power Macintosh"|ppc)
41
    cpu="powerpc"
42
  ;;
43
  *)
44
    cpu="unknown"
45
  ;;
46
esac
47
gprof="no"
48
v4l="yes"
49
audio_oss="yes"
50
network="yes"
51
zlib="yes"
52
mp3lame="no"
53
vorbis="no"
54
a52="yes"
55
a52bin="no"
56
win32="no"
57
cygwin="no"
58
lshared="no"
59
extralibs="-lm"
60
simpleidct="yes"
61
bigendian="no"
62
vhook="no"
63
mpegaudio_hp="yes"
64
SHFLAGS=-shared
65

    
66
# OS specific
67
targetos=`uname -s`
68
case $targetos in
69
BeOS)
70
prefix="/boot/home/config"
71
# helps building libavcodec
72
CFLAGS="-O3 -DPIC -fomit-frame-pointer"
73
SHFLAGS=-nostart
74
# disable linux things
75
audio_oss="no"
76
v4l="no"
77
# no need for libm, but the inet stuff
78
# Check for BONE
79
if (echo $BEINCLUDES|grep 'headers/be/bone' >/dev/null); then
80
extralibs="-lbind -lsocket"
81
else
82
echo "Not sure building for net_server will succeed... good luck."
83
extralibs="-lsocket"
84
fi ;;
85
BSD/OS)
86
v4l="no"
87
audio_oss="yes"
88
extralibs="-lpoll -lgnugetopt -lm"
89
make="gmake"
90
;;
91
Darwin)
92
cc="cc"
93
v4l="no"
94
audio_oss="no"
95
CFLAGS="-no-cpp-precomp -pipe -O3 -fomit-frame-pointer"
96
SHFLAGS="-dynamiclib"
97
extralibs=""
98
darwin="yes"
99
;;
100
CYGWIN*)
101
v4l="no"
102
audio_oss="yes"
103
extralibs=""
104
cygwin="yes"
105
test -f /usr/include/inttypes.h || \
106
test -f /usr/local/include/inttypes.h || \
107
echo "Missing inttypes.h, please copy cygwin_inttypes.h to" \
108
     "/usr/include/inttypes.h !!!"
109
;;
110
*) ;;
111
esac
112

    
113
# find source path
114
# XXX: we assume an absolute path is given when launching configure, 
115
# except in './configure' case.
116
source_path=${0%configure}
117
source_path=${source_path%/}
118
source_path_used="yes"
119
if test -z "$source_path" -o "$source_path" = "." ; then
120
    source_path=`pwd`
121
    source_path_used="no"
122
fi
123

    
124
cat > $TMPC << EOF
125
#include <dlfcn.h>
126
int main( void ) { return (int) dlopen("foo", 0); }
127
EOF
128

    
129
if $cc -o $TMPO $TMPC -ldl 2> /dev/null  ; then
130
: vhook=yes
131
fi
132

    
133
cat > $TMPC << EOF
134
#include <X11/Xlib.h>
135
#include <Imlib2.h>
136
int main( void ) { return (int) imlib_load_font("foo"); }
137
EOF
138

    
139
imlib2=no
140
if $cc -o $TMPO $TMPC -lImlib2 2> /dev/null  ; then
141
imlib2=yes
142
fi
143

    
144
for opt do
145
  case "$opt" in
146
  --prefix=*) prefix=`echo $opt | cut -d '=' -f 2`
147
  ;;
148
  --source-path=*) source_path=`echo $opt | cut -d '=' -f 2`
149
  ;;
150
  --cross-prefix=*) cross_prefix=`echo $opt | cut -d '=' -f 2`
151
  ;;
152
  --cc=*) cc=`echo $opt | cut -d '=' -f 2`
153
  ;;
154
  --make=*) make=`echo $opt | cut -d '=' -f 2`
155
  ;;
156
  --extra-cflags=*) CFLAGS="${opt#--extra-cflags=}"
157
  ;;
158
  --extra-ldflags=*) LDFLAGS=${opt#--extra-ldflags=}
159
  ;;
160
  --extra-libs=*) extralibs=${opt#--extra-libs=}
161
  ;;
162
  --cpu=*) cpu=`echo $opt | cut -d '=' -f 2`
163
  ;;
164
  --disable-mmx) mmx="no"
165
  ;;
166
  --disable-altivec) altivec="no"
167
  ;;
168
  --enable-gprof) gprof="yes"
169
  ;;
170
  --disable-v4l) v4l="no"
171
  ;;
172
  --disable-audio-oss) audio_oss="no"
173
  ;;
174
  --disable-network) network="no"
175
  ;;
176
  --disable-zlib) zlib="no"
177
  ;;
178
  --disable-a52) a52="no"
179
  ;;
180
  --enable-a52bin) a52bin="yes" ; extralibs="-ldl $extralibs"
181
  ;;
182
  --enable-mp3lame) mp3lame="yes"
183
  ;;
184
  --enable-vorbis) vorbis="yes"
185
  ;;
186
  --disable-vhook) vhook="no"
187
  ;;
188
  --disable-simple_idct) simpleidct="no"
189
  ;;
190
  --enable-win32) win32="yes"
191
  ;;
192
  --enable-shared) lshared="yes"
193
  ;;
194
  --disable-mpegaudio-hp) mpegaudio_hp="no"
195
  ;;
196
  esac
197
done
198

    
199
# compute mmx state
200
if test $mmx = "default"; then
201
    if test $cpu = "x86"; then
202
        mmx="yes"
203
    else
204
        mmx="no"
205
    fi
206
fi
207

    
208
# Can only do AltiVec on PowerPC
209
if test $altivec = "default"; then
210
    if test $cpu = "powerpc"; then
211
        altivec="yes"
212
    else
213
        altivec="no"
214
    fi
215
fi
216

    
217
# See does our compiler support Motorola AltiVec C API
218
if test $altivec = "yes"; then
219
cat > $TMPC << EOF
220
int main(void) {
221
    vector signed int v1, v2, v3;
222
    v1 = vec_add(v2,v3);
223
    return 0;
224
}
225
EOF
226
$cc -o $TMPO $TMPC -faltivec 2> /dev/null || altivec="no"
227
fi
228

    
229
# Checking for CFLAGS
230
if test -z "$CFLAGS"; then
231
    CFLAGS="-O3"
232
fi
233

    
234
if test "$win32" = "yes" ; then
235
    cross_prefix="i386-mingw32msvc-"
236
    v4l="no"
237
    audio_oss="no"
238
    network="no"
239
fi
240

    
241
cc="${cross_prefix}${cc}"
242
ar="${cross_prefix}${ar}"
243
ranlib="${cross_prefix}${ranlib}"
244
strip="${cross_prefix}${strip}"
245

    
246
# ---
247
# big/little endian test
248
cat > $TMPC << EOF
249
#include <inttypes.h>
250
int main(int argc, char ** argv){
251
	volatile uint32_t i=0x01234567;
252
	return (*((uint8_t*)(&i))) == 0x67;
253
}
254
EOF
255

    
256
if $cc -o $TMPO $TMPC 2>/dev/null ; then
257
$TMPO && bigendian="yes"
258
else
259
echo big/little test failed
260
fi
261

    
262
# ---
263
# check availability of some header files
264

    
265
cat > $TMPC << EOF
266
#include <malloc.h>
267
int main( void ) { return 0; }
268
EOF
269

    
270
_memalign=no
271
_malloc_h=no
272
if $cc -o $TMPO $TMPC 2> /dev/null ; then
273
_malloc_h=yes
274
_memalign=yes
275
# check for memalign - atmos
276
cat > $TMPC << EOF
277
#include <malloc.h>
278
int main ( void ) {
279
char *string = NULL;
280
string = memalign(64, sizeof(char));
281
return 0;
282
}
283
EOF
284
$cc -o $TMPO $TMPC 2> /dev/null || _memalign=no
285
fi
286

    
287
cat > $TMPC << EOF
288
#define _GNU_SOURCE
289
#include <time.h>
290
int main( void ) { return *strptime("", "", 0); }
291
EOF
292

    
293
strptime=no
294
if $cc -o $TMPO $TMPC 2> /dev/null ; then
295
  strptime=yes
296
fi
297

    
298
if test "$zlib" = "yes"; then
299
# check for zlib - mmu_man
300
cat > $TMPC << EOF
301
#include <zlib.h>
302
int main ( void ) {
303
if (zlibVersion() != ZLIB_VERSION)
304
   puts("zlib version differs !!!");
305
   return 1;
306
return 0;
307
}
308
EOF
309
$cc -o $TMPO $TMPC -lz 2> /dev/null || zlib="no"
310
# $TMPO 2> /dev/null > /dev/null || zlib="no"
311
# XXX: more tests needed - runtime test
312
fi
313
if test "$zlib" = "yes"; then
314
extralibs="$extralibs -lz"
315
fi
316

    
317
_restrict=
318
for restrict_keyword in restrict __restrict__ __restrict; do
319
  echo "void foo(char * $restrict_keyword p);" > $TMPC
320
  if $cc -c -o $TMPO $TMPC 2> /dev/null; then
321
    _restrict=$restrict_keyword
322
    break;
323
  fi
324
done
325

    
326
if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
327
cat << EOF
328

    
329
Usage: configure [options]
330
Options: [defaults in brackets after descriptions]
331

    
332
EOF
333
echo "Standard options:"
334
echo "  --help                   print this message"
335
echo "  --prefix=PREFIX          install in PREFIX [$prefix]"
336
echo "  --enable-mp3lame         enable mp3 encoding via libmp3lame [default=no]"
337
echo "  --enable-vorbis          enable vorbis support via libvorbisenc [default=no]"
338
echo "  --enable-win32           enable win32 cross compile"
339
echo "  --disable-a52            disable GPL'ed A52 support [default=no]"
340
echo "  --enable-a52bin          open liba52.so.0 at runtime [default=no]"
341
echo "  --enable-shared          build shared libraries [default=no]"
342
echo ""
343
echo "Advanced options (experts only):"
344
echo "  --source-path=PATH       path of source code [$source_path]"
345
echo "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
346
echo "  --cc=CC                  use C compiler CC [$cc]"
347
echo "  --make=MAKE              use specified make [$make]"
348
echo "  --extra-cflags=ECFLAGS   add ECFLAGS to CFLAGS [$CFLAGS]"
349
echo "  --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]"
350
echo "  --extra-libs=ELIBS       add ELIBS [$ELIBS]"
351
echo "  --cpu=CPU                force cpu to CPU  [$cpu]"
352
echo "  --disable-mmx            disable mmx usage"
353
echo "  --disable-altivec        disable AltiVec usage"
354
echo "  --disable-audio-oss      disable OSS audio support [default=no]"
355
echo "  --disable-v4l            disable video4linux grabbing [default=no]"
356
echo "  --disable-network        disable network support [default=no]"
357
echo "  --disable-zlib           disable zlib [default=no]"
358
echo "  --disable-simple_idct    disable simple IDCT routines [default=no]"
359
# echo "  --disable-vhook          disable video hooking support"
360
echo "  --enable-gprof           enable profiling with gprof [$gprof]"
361
echo "  --disable-mpegaudio-hp   faster (but less accurate)"
362
echo "                           mpegaudio decoding [default=no]"
363
echo ""
364
echo "NOTE: The object files are build at the place where configure is launched"
365
exit 1
366
fi
367

    
368
echo "Install prefix   $prefix"
369
echo "Source path      $source_path"
370
echo "C compiler       $cc"
371
echo "make             $make"
372
echo "CPU              $cpu"
373
echo "Big Endian       $bigendian"
374
echo "MMX enabled      $mmx"
375
echo "AltiVec enabled  $altivec"
376
echo "gprof enabled    $gprof"
377
echo "zlib enabled     $zlib"
378
echo "mp3lame enabled  $mp3lame"
379
echo "vorbis enabled   $vorbis"
380
echo "a52 support      $a52"
381
echo "a52 dlopened     $a52bin"
382
# echo "Video hooking    $vhook"
383

    
384
if test "$vhook" = "yes" ; then
385
: echo "Imlib2 support   $imlib2"
386
fi
387

    
388
echo "Creating config.mak and config.h"
389

    
390
echo "# Automatically generated by configure - do not modify" > config.mak
391
echo "/* Automatically generated by configure - do not modify */" > $TMPH
392

    
393
echo "prefix=$prefix" >> config.mak
394
echo "MAKE=$make" >> config.mak
395
echo "CC=$cc" >> config.mak
396
echo "AR=$ar" >> config.mak
397
echo "RANLIB=$ranlib" >> config.mak
398
echo "STRIP=$strip" >> config.mak
399
echo "OPTFLAGS=$CFLAGS" >> config.mak
400
echo "LDFLAGS=$LDFLAGS" >> config.mak
401
echo "SHFLAGS=$SHFLAGS" >> config.mak
402
if test "$cpu" = "x86" ; then
403
  echo "TARGET_ARCH_X86=yes" >> config.mak
404
  echo "#define ARCH_X86 1" >> $TMPH
405
elif test "$cpu" = "armv4l" ; then
406
  echo "TARGET_ARCH_ARMV4L=yes" >> config.mak
407
  echo "#define ARCH_ARMV4L 1" >> $TMPH
408
elif test "$cpu" = "alpha" ; then
409
  echo "TARGET_ARCH_ALPHA=yes" >> config.mak
410
  echo "#define ARCH_ALPHA 1" >> $TMPH
411
elif test "$cpu" = "powerpc" ; then
412
  echo "TARGET_ARCH_POWERPC=yes" >> config.mak
413
  echo "#define ARCH_POWERPC 1" >> $TMPH
414
fi
415
if test "$bigendian" = "yes" ; then
416
  echo "WORDS_BIGENDIAN=yes" >> config.mak
417
  echo "#define WORDS_BIGENDIAN 1" >> $TMPH
418
fi
419
if test "$mmx" = "yes" ; then
420
  echo "TARGET_MMX=yes" >> config.mak
421
  echo "#define HAVE_MMX 1" >> $TMPH
422
fi
423
if test "$altivec" = "yes" ; then
424
  echo "TARGET_ALTIVEC=yes" >> config.mak
425
  echo "#define HAVE_ALTIVEC 1" >> $TMPH
426
fi
427
if test "$gprof" = "yes" ; then
428
  echo "TARGET_GPROF=yes" >> config.mak
429
  echo "#define HAVE_GPROF 1" >> $TMPH
430
fi
431
if test "$strptime" = "yes" ; then
432
  echo "#define HAVE_STRPTIME 1" >> $TMPH
433
else
434
  echo "BUILD_STRPTIME=yes" >> config.mak
435
fi
436
if test "$imlib2" = "yes" ; then
437
  echo "HAVE_IMLIB2=yes" >> config.mak
438
fi
439
if test "$vhook" = "yes" ; then
440
  echo "BUILD_VHOOK=yes" >> config.mak
441
  echo "#define HAVE_VHOOK 1" >> $TMPH
442
  extralibs="$extralibs -ldl"
443
fi
444
if test "$lshared" = "yes" ; then
445
  echo "BUILD_SHARED=yes" >> config.mak
446
  echo "PIC=-fPIC" >> config.mak
447
fi
448
echo "EXTRALIBS=$extralibs" >> config.mak
449
echo -n "VERSION=" >>config.mak
450
head $source_path/VERSION >>config.mak
451
echo "" >>config.mak
452
# if you do not want to use encoders, disable that.
453
echo "#define CONFIG_ENCODERS 1" >> $TMPH
454
echo "CONFIG_ENCODERS=yes" >> config.mak
455

    
456
# if you do not want to use decoders, disable that.
457
echo "#define CONFIG_DECODERS 1" >> $TMPH
458
echo "CONFIG_DECODERS=yes" >> config.mak
459

    
460
# AC3
461
if test "$a52" = "yes" ; then
462
  echo "#define CONFIG_AC3 1" >> $TMPH
463
  echo "CONFIG_AC3=yes" >> config.mak
464

    
465
  if test "$a52bin" = "yes" ; then
466
    echo "#define CONFIG_A52BIN 1" >> $TMPH
467
    echo "CONFIG_A52BIN=yes" >> config.mak
468
  fi
469
fi
470

    
471
# mpeg audio high precision mode
472
if test "$mpegaudio_hp" = "yes" ; then
473
  echo "#define CONFIG_MPEGAUDIO_HP 1" >> $TMPH
474
fi
475

    
476
if test "$v4l" = "yes" ; then
477
  echo "#define CONFIG_VIDEO4LINUX 1" >> $TMPH
478
  echo "CONFIG_VIDEO4LINUX=yes" >> config.mak
479
fi
480

    
481
if test "$audio_oss" = "yes" ; then
482
  echo "#define CONFIG_AUDIO_OSS 1" >> $TMPH
483
  echo "CONFIG_AUDIO_OSS=yes" >> config.mak
484
fi
485

    
486
if test "$network" = "yes" ; then
487
  echo "#define CONFIG_NETWORK 1" >> $TMPH
488
  echo "CONFIG_NETWORK=yes" >> config.mak
489
fi
490

    
491
if test "$zlib" = "yes" ; then
492
  echo "#define CONFIG_ZLIB 1" >> $TMPH
493
  echo "CONFIG_ZLIB=yes" >> config.mak
494
fi
495

    
496
if test "$mp3lame" = "yes" ; then
497
  echo "#define CONFIG_MP3LAME 1" >> $TMPH
498
  echo "CONFIG_MP3LAME=yes" >> config.mak
499
fi
500

    
501
if test "$vorbis" = "yes" ; then
502
  echo "#define CONFIG_VORBIS 1" >> $TMPH
503
  echo "CONFIG_VORBIS=yes" >> config.mak
504
fi
505

    
506
if test "$win32" = "yes" ; then
507
  echo "#define CONFIG_WIN32 1" >> $TMPH
508
  echo "CONFIG_WIN32=yes" >> config.mak
509
fi
510

    
511
if test "$cygwin" = "yes" ; then
512
  # setup correct exesuffix
513
  echo "CONFIG_WIN32=yes" >> config.mak
514
fi
515

    
516
if test "$darwin" = "yes"; then
517
  echo "#define CONFIG_DARWIN 1"  >> $TMPH
518
  echo "CONFIG_DARWIN=yes" >> config.mak
519
fi
520

    
521
if test "$_malloc_h" = "yes" ; then
522
  echo "#define HAVE_MALLOC_H 1" >> $TMPH
523
else
524
  echo "#undef  HAVE_MALLOC_H" >> $TMPH
525
fi
526

    
527
if test "$_memalign" = "yes" ; then
528
  echo "#define HAVE_MEMALIGN 1" >> $TMPH
529
else
530
  echo "#undef  HAVE_MEMALIGN" >> $TMPH
531
fi
532

    
533
if test "$simpleidct" = "yes" ; then
534
  echo "#define SIMPLE_IDCT 1" >> $TMPH
535
fi
536

    
537
echo "#define restrict $_restrict" >> $TMPH
538

    
539
# build tree in object directory if source path is different from current one
540
if test "$source_path_used" = "yes" ; then
541
    DIRS="libav libavcodec libavcodec/alpha libavcodec/armv4l libavcodec/i386 \
542
          libavcodec/ppc libavcodec/liba52 libavcodec/mlib tests"
543
    FILES="Makefile libav/Makefile libavcodec/Makefile tests/Makefile"
544
    for dir in $DIRS ; do
545
            mkdir -p $dir
546
    done
547
    for f in $FILES ; do
548
        ln -sf $source_path/$f $f
549
    done
550
fi
551
echo "SRC_PATH=$source_path" >> config.mak
552

    
553
diff $TMPH config.h >/dev/null 2>&1
554
if test $? -ne 0 ; then
555
	mv -f $TMPH config.h
556
else
557
	echo "config.h is unchanged"
558
fi
559

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