configure 42.9 KB
Newer Older
Fabrice Bellard's avatar
Fabrice Bellard committed
1
#!/bin/sh
2
#
Fabrice Bellard's avatar
Fabrice Bellard committed
3
# ffmpeg configure script (c) 2000, 2001, 2002 Fabrice Bellard
4
#
5 6 7 8 9 10 11 12 13 14 15

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

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

EOF
echo "Standard options:"
echo "  --help                   print this message"
echo "  --prefix=PREFIX          install in PREFIX [$prefix]"
16
echo "  --libdir=DIR             install libs in DIR [PREFIX/lib]"
17 18
echo "  --mandir=DIR             man documentation in DIR [PREFIX/man]"
echo "  --enable-mp3lame         enable mp3 encoding via libmp3lame [default=no]"
19
echo "  --enable-libogg          enable ogg support via libogg [default=no]"
Nilesh Bansal's avatar
Nilesh Bansal committed
20 21
echo "  --enable-vorbis          enable vorbis support via libvorbis [default=no]"
echo "  --enable-theora          enable theora support via libtheora [default=no]"
22 23 24
echo "  --enable-faad            enable faad support via libfaad [default=no]"
echo "  --enable-faadbin         build faad support with runtime linking [default=no]"
echo "  --enable-faac            enable faac support via libfaac [default=no]"
25
echo "  --enable-libgsm          enable gsm support via libgsm [default=no]"
26
echo "  --enable-xvid            enable xvid support via xvidcore [default=no]"
27
echo "  --enable-x264            enable H.264 encoding via x264 [default=no]"
28 29 30
echo "  --enable-mingw32         enable mingw32 native/cross windows compile"
echo "  --enable-a52             enable GPL'ed A52 support [default=no]"
echo "  --enable-a52bin          open liba52.so.0 at runtime [default=no]"
31
echo "  --enable-dts             enable GPL'ed DTS support [default=no]"
32 33 34 35 36
echo "  --enable-pp              enable GPL'ed post processing support [default=no]"
echo "  --enable-shared-pp       use libpostproc.so [default=no]"
echo "  --enable-shared          build shared libraries [default=no]"
echo "  --enable-amr_nb          enable amr_nb float audio codec"
echo "  --enable-amr_nb-fixed    use fixed point for amr-nb codec"
37
echo "  --enable-amr_wb          enable amr_wb float audio codec"
38
echo "  --enable-sunmlib         use Sun medialib [default=no]"
39
echo "  --enable-pthreads        use pthreads [default=no]"
40
echo "  --enable-dc1394          enable IIDC-1394 grabbing using libdc1394 and libraw1394 [default=no]"
41
echo "  --enable-gpl             allow use of gpl code, the resulting libav* and ffmpeg will be under gpl [default=no]"
42 43 44 45 46 47 48 49 50
echo ""
echo "Advanced options (experts only):"
echo "  --source-path=PATH       path of source code [$source_path]"
echo "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
echo "  --cc=CC                  use C compiler CC [$cc]"
echo "  --make=MAKE              use specified make [$make]"
echo "  --extra-cflags=ECFLAGS   add ECFLAGS to CFLAGS [$CFLAGS]"
echo "  --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]"
echo "  --extra-libs=ELIBS       add ELIBS [$ELIBS]"
51
echo "  --build-suffix=SUFFIX    suffix for application specific build []"
52 53 54 55 56 57 58 59
echo "  --cpu=CPU                force cpu to CPU  [$cpu]"
echo "  --tune=PROCESSOR         tune code for a particular CPU (may fails or misperforms on other CPUs)"
echo "  --powerpc-perf-enable    enable performance report on PPC (requires enabling PMC)"
echo "  --disable-mmx            disable mmx usage"
echo "  --disable-altivec        disable AltiVec usage"
echo "  --disable-audio-oss      disable OSS audio support [default=no]"
echo "  --disable-audio-beos     disable BeOS audio support [default=no]"
echo "  --disable-v4l            disable video4linux grabbing [default=no]"
60
echo "  --disable-bktr           disable bktr video grabbing [default=no]"
61 62 63 64 65 66 67 68 69 70 71 72 73
echo "  --disable-dv1394         disable DV1394 grabbing [default=no]"
echo "  --disable-network        disable network support [default=no]"
echo "  --disable-zlib           disable zlib [default=no]"
echo "  --disable-simple_idct    disable simple IDCT routines [default=no]"
echo "  --disable-vhook          disable video hooking support"
echo "  --enable-gprof           enable profiling with gprof [$gprof]"
echo "  --disable-debug          disable debugging symbols"
echo "  --disable-opts           disable compiler optimizations"
echo "  --disable-mpegaudio-hp   faster (but less accurate)"
echo "                           mpegaudio decoding [default=no]"
echo "  --disable-ffserver       disable ffserver build"
echo "  --disable-ffplay         disable ffplay build"
echo "  --enable-small           optimize for size instead of speed"
74
echo "  --enable-memalign-hack   emulate memalign, interferes with memory debuggers"
75
echo "  --disable-strip          disable stripping of executables and shared libraries"
Michael Niedermayer's avatar
typo  
Michael Niedermayer committed
76 77
echo "  --enable-codec=codec     enables codec"
echo "  --disable-codec=codec    disables codec"
78
echo "  --disable-encoders       disables all encoders"
79 80 81 82 83
echo ""
echo "NOTE: The object files are build at the place where configure is launched"
exit 1
fi

84
# set temporary file name
Zdenek Kabelac's avatar
Zdenek Kabelac committed
85
if test ! -z "$TMPDIR" ; then
86
    TMPDIR1="${TMPDIR}"
Zdenek Kabelac's avatar
Zdenek Kabelac committed
87
elif test ! -z "$TEMPDIR" ; then
88
    TMPDIR1="${TEMPDIR}"
Nick Kurshev's avatar
Nick Kurshev committed
89
else
90
    TMPDIR1="/tmp"
Nick Kurshev's avatar
Nick Kurshev committed
91 92
fi

93 94
TMPC="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.c"
TMPO="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.o"
95
TMPE="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}"
96 97 98
TMPS="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.S"
TMPH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.h"

Fabrice Bellard's avatar
Fabrice Bellard committed
99 100
# default parameters
prefix="/usr/local"
101
libdir=""
102
mandir=""
Fabrice Bellard's avatar
Fabrice Bellard committed
103
bindir=""
104
cross_prefix=""
Fabrice Bellard's avatar
Fabrice Bellard committed
105 106
cc="gcc"
ar="ar"
Michael Niedermayer's avatar
Michael Niedermayer committed
107
ranlib="ranlib"
108
make="make"
109
strip="strip"
Fabrice Bellard's avatar
Fabrice Bellard committed
110
cpu=`uname -m`
111
tune="generic"
112
powerpc_perf="no"
113
mmx="default"
114
altivec="default"
115
mmi="default"
Fabrice Bellard's avatar
Fabrice Bellard committed
116
case "$cpu" in
117
  i386|i486|i586|i686|i86pc|BePC)
Fabrice Bellard's avatar
Fabrice Bellard committed
118 119
    cpu="x86"
  ;;
120 121 122 123 124 125 126
  x86_64|amd64)
    cpu="x86"
    canon_arch="`cc -dumpmachine | sed -e 's,\([^-]*\)-.*,\1,'`"
    if [ x"$canon_arch" = x"x86_64" -o x"$canon_arch" = x"amd64" ]; then
      if [ -z "`echo $CFLAGS | grep -- -m32`"  ]; then
        cpu="x86_64"
      fi
127 128
    fi
  ;;
129 130
  # armv4l is a subset of armv5tel
  armv4l|armv5tel)
131 132
    cpu="armv4l"
  ;;
133 134 135
  alpha)
    cpu="alpha"
  ;;
136
  "Power Macintosh"|ppc)
137 138
    cpu="powerpc"
  ;;
139 140 141
  mips)
    cpu="mips"
  ;;
142
  sun4u|sparc64)
143 144
    cpu="sparc64"
  ;;
145 146 147
  sparc)
    cpu="sparc"
  ;;
Alex Beregszaszi's avatar
Alex Beregszaszi committed
148 149 150
  sh4)
    cpu="sh4"
  ;;
Fabrice Bellard's avatar
Fabrice Bellard committed
151
  *)
152
    cpu="unknown"
Fabrice Bellard's avatar
Fabrice Bellard committed
153 154 155
  ;;
esac
gprof="no"
Fabrice Bellard's avatar
Fabrice Bellard committed
156
v4l="yes"
157
bktr="no"
Fabrice Bellard's avatar
Fabrice Bellard committed
158
audio_oss="yes"
159
audio_beos="no"
160
dv1394="yes"
161
dc1394="no"
Fabrice Bellard's avatar
Fabrice Bellard committed
162
network="yes"
163
zlib="yes"
164
libgsm="no"
165
mp3lame="no"
166
libogg="no"
167
vorbis="no"
Nilesh Bansal's avatar
Nilesh Bansal committed
168
theora="no"
169 170
faad="no"
faadbin="no"
171
faac="no"
172
xvid="no"
173
x264="no"
174
a52="no"
Zdenek Kabelac's avatar
Zdenek Kabelac committed
175
a52bin="no"
176
dts="no"
177
pp="no"
178
shared_pp="no"
179
mingw32="no"
180
cygwin="no"
181
os2="no"
182
lshared="no"
183 184
optimize="yes"
debug="yes"
185
dostrip="yes"
186
extralibs="-lm"
187
simpleidct="yes"
188
bigendian="no"
189
inttypes="yes"
190
emu_fast_int="no"
191
vhook="default"
192 193
dlfcn="no"
dlopen="no"
194
mpegaudio_hp="yes"
195
SHFLAGS=-shared
196
netserver="no"
197
need_inet_aton="no"
198
ffserver="yes"
199
ffplay="yes"
200 201
LDFLAGS=-Wl,--warn-common
FFSLDFLAGS=-Wl,-E
202
LDCONFIG="ldconfig"
203 204 205 206
LIBPREF="lib"
LIBSUF=".a"
SLIBPREF="lib"
SLIBSUF=".so"
Fabrice Bellard's avatar
Fabrice Bellard committed
207
EXESUF=""
208
BUILDSUF=""
209
amr_nb="no"
210
amr_wb="no"
Zdenek Kabelac's avatar
Zdenek Kabelac committed
211
amr_nb_fixed="no"
212
amr_if2="no"
213
sunmlib="no"
214
pthreads="no"
215
gpl="no"
216
memalignhack="no"
217 218 219 220 221 222 223

# OS specific
targetos=`uname -s`
case $targetos in
BeOS)
prefix="/boot/home/config"
# helps building libavcodec
224
CFLAGS="-DPIC -fomit-frame-pointer"
225
# 3 gcc releases known for BeOS, each with ugly bugs
226
gcc_version="`$cc -v 2>&1 | grep version | cut -d ' ' -f3-`"
227 228 229 230 231 232 233 234
case "$gcc_version" in
2.9-beos-991026*|2.9-beos-000224*) echo "R5/GG gcc"
mmx="no"
;;
*20010315*) echo "BeBits gcc"
CFLAGS="$CFLAGS -fno-expensive-optimizations"
;;
esac
235 236 237
SHFLAGS=-nostart
# disable linux things
audio_oss="no"
Fabrice Bellard's avatar
Fabrice Bellard committed
238
v4l="no"
239
dv1394="no"
240 241
# enable beos things
audio_beos="yes"
242 243 244 245 246
# no need for libm, but the inet stuff
# Check for BONE
if (echo $BEINCLUDES|grep 'headers/be/bone' >/dev/null); then
extralibs="-lbind -lsocket"
else
247
netserver="yes"
248
need_inet_aton="yes"
249
extralibs="-lnet"
250
fi ;;
251 252 253
SunOS)
v4l="no"
audio_oss="no"
254
dv1394="no"
255 256 257 258 259 260
make="gmake"
LDFLAGS=""
FFSLDFLAGS=""
need_inet_aton="yes"
extralibs="$extralibs -lsocket -lnsl"
;;
261 262
NetBSD)
v4l="no"
263
bktr="yes"
264 265 266 267 268 269 270 271 272
audio_oss="yes"
dv1394="no"
make="gmake"
LDFLAGS="$LDFLAGS -export-dynamic"
case `uname -r` in
2.*) extralibs="-lossaudio"
;;
esac
;;
273 274
OpenBSD)
v4l="no"
275
bktr="yes"
276 277 278 279 280
audio_oss="yes"
dv1394="no"
make="gmake"
CFLAGS="$CFLAGS \$(PIC)"
LDFLAGS="$LDFLAGS -export-dynamic -pthread"
281
LDCONFIG="ldconfig -m \$(libdir)"
282 283
extralibs="$extralibs -lossaudio"
;;
284 285
FreeBSD)
v4l="no"
286
bktr="yes"
287
audio_oss="yes"
288
dv1394="no"
289
make="gmake"
290 291
CFLAGS="-pthread"
LDFLAGS="$LDFLAGS -export-dynamic -pthread"
292
;;
293
BSD/OS)
Fabrice Bellard's avatar
Fabrice Bellard committed
294
v4l="no"
295
bktr="yes"
Fabrice Bellard's avatar
Fabrice Bellard committed
296
audio_oss="yes"
297
dv1394="no"
298 299 300
extralibs="-lpoll -lgnugetopt -lm"
make="gmake"
;;
301
Darwin)
302
cc="cc"
303 304
v4l="no"
audio_oss="no"
305
dv1394="no"
306
ffserver="no"
307
SHFLAGS="-dynamiclib"
308
extralibs=""
309
darwin="yes"
310
strip="strip -x"
311
LDFLAGS="-Wl,-d,-search_paths_first"
312
FFSLDFLAGS=-Wl,-bind_at_load
313
;;
314
MINGW32*)
Fabrice Bellard's avatar
Fabrice Bellard committed
315 316
# Note: the rest of the mingw32 config is done afterwards as mingw32
# can be forced on command line for linux cross compilation
317 318
mingw32="yes"
;;
319 320 321
CYGWIN*)
v4l="no"
audio_oss="yes"
322
dv1394="no"
323
ffserver="no"
324 325
extralibs=""
cygwin="yes"
326
EXESUF=".exe"
327
;;
328
Linux)
329
LDFLAGS="$LDFLAGS -rdynamic"
330
;;
331 332 333 334 335 336
IRIX*)
ranlib="echo ignoring ranlib"
v4l="no"
audio_oss="no"
make="gmake"
;;
337 338
OS/2)
TMPE=$TMPE".exe"
339
ar="emxomfar -p128"
340 341
ranlib="echo ignoring ranlib"
strip="echo ignoring strip"
342
CFLAGS="-Zomf"
343
LDFLAGS="-Zomf -Zstack 16384 -s"
344
SHFLAGS="-Zdll -Zomf"
345 346 347 348 349
FFSLDFLAGS=""
LIBPREF=""
LIBSUF=".lib"
SLIBPREF=""
SLIBSUF=".dll"
Fabrice Bellard's avatar
Fabrice Bellard committed
350
EXESUF=".exe"
351 352 353
extralibs=""
v4l="no"
audio_oss="no"
354
dv1394="no"
355 356
network="no"
ffserver="no"
357
vhook="no"
358
os2="yes"
359

360
;;
361 362
*) ;;
esac
Fabrice Bellard's avatar
Fabrice Bellard committed
363

364 365 366 367 368
# From mplayer configure. We need TARGET_OS available
# to the Makefile, so it can distinguish between flavors
# of AltiVec on PowerPC
TARGET_OS=`( uname -s ) 2>&1`
  case "$TARGET_OS" in
369
  Linux|FreeBSD|NetBSD|BSD/OS|OpenBSD|SunOS|QNX|Darwin|GNU|BeOS)
370 371 372 373 374 375 376 377 378 379 380 381 382 383 384
    ;;
  IRIX*)
    TARGET_OS=IRIX
    ;;
  HP-UX*)
    TARGET_OS=HP-UX
    ;;
  [cC][yY][gG][wW][iI][nN]*)
    TARGET_OS=CYGWIN
    ;;
  *)
    TARGET_OS="$TARGET_OS-UNKNOWN"
    ;;
  esac

385
# find source path
386
source_path="`echo $0 | sed -e 's#/configure##'`"
387 388 389 390
source_path_used="yes"
if test -z "$source_path" -o "$source_path" = "." ; then
    source_path=`pwd`
    source_path_used="no"
391 392
else
    source_path="`cd \"$source_path\"; pwd`"
Fabrice Bellard's avatar
Fabrice Bellard committed
393 394
fi

395 396 397 398 399
FFMPEG_CONFIGURATION=" "
for opt do
  FFMPEG_CONFIGURATION="$FFMPEG_CONFIGURATION""$opt "
done

400
CODEC_LIST=`grep 'register_avcodec(&[a-z]' $source_path/libavcodec/allcodecs.c  | sed 's/.*&\(.*\)).*/\1/'`
401

Fabrice Bellard's avatar
Fabrice Bellard committed
402 403 404 405
for opt do
  case "$opt" in
  --prefix=*) prefix=`echo $opt | cut -d '=' -f 2`
  ;;
406 407
  --libdir=*) libdir=`echo $opt | cut -d '=' -f 2`
  ;;
408 409
  --mandir=*) mandir=`echo $opt | cut -d '=' -f 2`
  ;;
410 411 412 413
  --source-path=*) source_path=`echo $opt | cut -d '=' -f 2`
  ;;
  --cross-prefix=*) cross_prefix=`echo $opt | cut -d '=' -f 2`
  ;;
Fabrice Bellard's avatar
Fabrice Bellard committed
414 415
  --cc=*) cc=`echo $opt | cut -d '=' -f 2`
  ;;
416 417
  --make=*) make=`echo $opt | cut -d '=' -f 2`
  ;;
418
  --extra-cflags=*) CFLAGS="$CFLAGS ${opt#--extra-cflags=}"
419
  ;;
420
  --extra-ldflags=*) LDFLAGS="$LDFLAGS ${opt#--extra-ldflags=}"
421 422 423
  ;;
  --extra-libs=*) extralibs=${opt#--extra-libs=}
  ;;
424 425
  --build-suffix=*) BUILDSUF=${opt#--build-suffix=}
  ;;
Fabrice Bellard's avatar
Fabrice Bellard committed
426 427
  --cpu=*) cpu=`echo $opt | cut -d '=' -f 2`
  ;;
428 429
  --tune=*) tune=`echo $opt | cut -d '=' -f 2`
  ;;
430 431
  --powerpc-perf-enable) powerpc_perf="yes"
  ;;
Fabrice Bellard's avatar
Fabrice Bellard committed
432 433
  --disable-mmx) mmx="no"
  ;;
434 435
  --disable-altivec) altivec="no"
  ;;
Fabrice Bellard's avatar
Fabrice Bellard committed
436 437
  --enable-gprof) gprof="yes"
  ;;
Fabrice Bellard's avatar
Fabrice Bellard committed
438 439
  --disable-v4l) v4l="no"
  ;;
440 441
  --disable-bktr) bktr="no"
  ;;
Fabrice Bellard's avatar
Fabrice Bellard committed
442 443
  --disable-audio-oss) audio_oss="no"
  ;;
444 445
  --disable-audio-beos) audio_beos="no"
  ;;
446 447
  --disable-dv1394) dv1394="no"
  ;;
448
  --disable-network) network="no"; ffserver="no"
Fabrice Bellard's avatar
Fabrice Bellard committed
449
  ;;
450 451
  --disable-zlib) zlib="no"
  ;;
452
  --enable-a52) a52="yes"
453
  ;;
454
  --enable-a52bin) a52bin="yes" ; extralibs="$ldl $extralibs"
Zdenek Kabelac's avatar
Zdenek Kabelac committed
455
  ;;
456 457
  --enable-dts) dts="yes" ; extralibs="$extralibs -ldts"
  ;;
458
  --enable-pp) pp="yes"
459 460 461
  ;;
  --enable-shared-pp) shared_pp="yes"
  ;;
462 463
  --enable-libgsm) libgsm="yes"
  ;;
464 465
  --enable-mp3lame) mp3lame="yes"
  ;;
466
  --enable-libogg) libogg="yes"
Nilesh Bansal's avatar
Nilesh Bansal committed
467
  ;;
468 469
  --enable-vorbis) vorbis="yes"
  ;;
Nilesh Bansal's avatar
Nilesh Bansal committed
470 471
  --enable-theora) theora="yes"
  ;;
Zdenek Kabelac's avatar
Zdenek Kabelac committed
472 473 474 475
  --enable-faad) faad="yes"
  ;;
  --enable-faadbin) faadbin="yes"
  ;;
476 477
  --enable-faac) faac="yes"
  ;;
478 479
  --enable-xvid) xvid="yes"
  ;;
480 481
  --enable-x264) x264="yes"; extralibs="$extralibs -lx264"
  ;;
482 483
  --enable-dc1394) dc1394="yes"
  ;;
484 485
  --disable-vhook) vhook="no"
  ;;
486
  --disable-simple_idct) simpleidct="no"
487
  ;;
488 489
  --enable-mingw32) mingw32="yes"
  ;;
490
  --enable-shared) lshared="yes"
Nick Kurshev's avatar
Nick Kurshev committed
491
  ;;
492 493 494 495
  --disable-debug) debug="no"
  ;;
  --disable-opts) optimize="no"
  ;;
496 497
  --disable-mpegaudio-hp) mpegaudio_hp="no"
  ;;
498 499
  --disable-ffserver) ffserver="no"
  ;;
500 501
  --disable-ffplay) ffplay="no"
  ;;
502
  --enable-small) optimize="small"
503
  ;;
504 505
  --enable-amr_nb) amr_nb="yes"
  ;;
Zdenek Kabelac's avatar
Zdenek Kabelac committed
506 507
  --enable-amr_nb-fixed) amr_nb_fixed="yes"
  ;;
508 509
  --enable-amr_wb) amr_wb="yes"
  ;; 
510 511
  --enable-amr_if2) amr_if2="yes"
  ;;
512 513
  --enable-sunmlib) sunmlib="yes"
  ;;
514 515
  --enable-pthreads) pthreads="yes"
  ;;
516 517
  --enable-gpl) gpl="yes"
  ;;
518 519
  --enable-memalign-hack) memalignhack="yes"
  ;;
520 521
  --disable-strip) dostrip="no"
  ;;
522 523 524 525 526 527
  --enable-codec=*) CODEC_LIST="$CODEC_LIST ${opt#--enable-codec=}"
  ;;
  --disable-codec=*) CODEC_LIST="`echo $CODEC_LIST | sed -e \"s#${opt#--disable-codec=}##\"`"
  ;;
  --disable-encoders) CODEC_LIST="`echo $CODEC_LIST | sed 's/[-_a-zA-Z0-9]*encoder//g'`"
  ;;
Fabrice Bellard's avatar
Fabrice Bellard committed
528 529 530
  esac
done

Nilesh Bansal's avatar
Nilesh Bansal committed
531
if test "$theora" = "yes" ; then
532 533
    if test "$libogg" = "no"; then
        echo "libogg must be enabled to enable Theora"     
Nilesh Bansal's avatar
Nilesh Bansal committed
534 535 536 537 538 539
        fail="yes"
        theora="no"
    fi
fi

if test "$vorbis" = "yes" ; then
540 541
    if test "$libogg" = "no"; then
        echo "libogg must be enabled to enable Vorbis"
Nilesh Bansal's avatar
Nilesh Bansal committed
542 543 544 545 546
        fail="yes"
        vorbis="no"
    fi
fi

547 548 549 550 551 552 553 554 555 556
if test "$gpl" != "yes"; then
    if test "$pp" != "no" -o "$shared_pp" != "no"; then
        echo "The Postprocessing code is under GPL and --enable-gpl is not specified"
        fail="yes"
    fi

    if test "$a52" != "no" -o "$a52bin" != "no"; then
        echo "liba52 is under GPL and --enable-gpl is not specified"
        fail="yes"
    fi
557

558 559 560 561 562
    if test "$xvid" != "no"; then
        echo "libxvidcore is under GPL and --enable-gpl is not specified"
        fail="yes"
    fi

563 564 565 566 567
    if test "$x264" != "no"; then
        echo "x264 is under GPL and --enable-gpl is not specified"
        fail="yes"
    fi

568 569 570 571
    if test "$dts" != "no"; then
        echo "libdts is under GPL and --enable-gpl is not specified"
        fail="yes"
    fi
572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598
    
    if test "$faad" != "no" -o "$faadbin" != "no"; then
        cat > $TMPC << EOF
            #include <faad.h>
            int main( void ) { return 0; }
EOF
    
        if $cc $CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
            cat > $TMPC << EOF
                #include <faad.h>
                #ifndef FAAD2_VERSION
                ok faad1
                #endif
                int main( void ) { return 0; }
EOF
            if $cc $CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
                echo "faad2 is under GPL and --enable-gpl is not specified"
                fail="yes"
            fi
        else
            faad="no"
            faadbin="no"
            echo "faad test failed"
        fi
    fi
   

Michael Niedermayer's avatar
10l  
Michael Niedermayer committed
599
    if test "$fail" = "yes"; then
600 601 602 603
        exit 1
    fi
fi

604 605
# compute mmx state
if test $mmx = "default"; then
606
    if test $cpu = "x86" -o $cpu = "x86_64"; then
607 608 609 610 611 612
        mmx="yes"
    else
        mmx="no"
    fi
fi

613
#Darwin CC versions
614
needmdynamicnopic="no"
615
if test $targetos = Darwin; then
616
    if test -n "`$cc -v 2>&1 | grep xlc`"; then
617
	CFLAGS="$CFLAGS -qpdf2 -qlanglvl=extc99 -qmaxmem=-1 -qarch=auto -qtune=auto"
618
    else
619
	gcc_version="`$cc -v 2>&1 | grep version | cut -d ' ' -f3-`"
620 621
	case "$gcc_version" in
	    *2.95*) 
622
		CFLAGS="$CFLAGS -no-cpp-precomp -pipe -fomit-frame-pointer"
623
		;;
624
	    *[34].*)
625
		CFLAGS="$CFLAGS -no-cpp-precomp -pipe -fomit-frame-pointer -force_cpusubtype_ALL -Wno-sign-compare"
626 627 628
		if test "$lshared" = no; then
		   needmdynamicnopic="yes"
		fi
629 630
		;;
	    *)
631
		CFLAGS="$CFLAGS -no-cpp-precomp -pipe -fomit-frame-pointer"
632 633 634
		if test "$lshared" = no; then
		   needmdynamicnopic="yes"
		fi
635 636 637 638 639
		;;
	esac
    fi
fi

640 641 642 643 644 645 646 647 648
# Can only do AltiVec on PowerPC
if test $altivec = "default"; then
    if test $cpu = "powerpc"; then
        altivec="yes"
    else
        altivec="no"
    fi
fi

649 650
# Add processor-specific flags
TUNECPU="generic"
651
POWERPCMODE="32bits"
652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674
if test $tune != "generic"; then
    case $tune in
	601|ppc601|PowerPC601)
	    CFLAGS="$CFLAGS -mcpu=601"
	    if test $altivec = "yes"; then
		echo "WARNING: tuning for PPC601 but altivec enabled !";
	    fi
	    TUNECPU=ppc601
	;;
	603*|ppc603*|PowerPC603*)
	    CFLAGS="$CFLAGS -mcpu=603"
	    if test $altivec = "yes"; then
		echo "WARNING: tuning for PPC603 but altivec enabled !";
	    fi
	    TUNECPU=ppc603
	;;
	604*|ppc604*|PowerPC604*)
	    CFLAGS="$CFLAGS -mcpu=604"
	    if test $altivec = "yes"; then
		echo "WARNING: tuning for PPC604 but altivec enabled !";
	    fi
	    TUNECPU=ppc604
	;;
675
	G3|g3|75*|ppc75*|PowerPC75*)
676
	    CFLAGS="$CFLAGS -mcpu=750 -mtune=750 -mpowerpc-gfxopt"
677 678 679 680 681
	    if test $altivec = "yes"; then
		echo "WARNING: tuning for PPC75x but altivec enabled !";
	    fi
	    TUNECPU=ppc750
	;;
682
	G4|g4|745*|ppc745*|PowerPC745*)
683
	    CFLAGS="$CFLAGS -mcpu=7450 -mtune=7450 -mpowerpc-gfxopt"
684 685 686 687 688 689
	    if test $altivec = "no"; then
		echo "WARNING: tuning for PPC745x but altivec disabled !";
	    fi
	    TUNECPU=ppc7450
	;;
	74*|ppc74*|PowerPC74*)
690
	    CFLAGS="$CFLAGS -mcpu=7400 -mtune=7400 -mpowerpc-gfxopt"
691 692 693
	    if test $altivec = "no"; then
		echo "WARNING: tuning for PPC74xx but altivec disabled !";
	    fi
694
	    TUNECPU=ppc7400
695
	;;
696
	G5|g5|970|ppc970|PowerPC970|power4*|Power4*)
697
	    CFLAGS="$CFLAGS -mcpu=970 -mtune=970 -mpowerpc-gfxopt -mpowerpc64"
698 699 700 701
	    if test $altivec = "no"; then
		echo "WARNING: tuning for PPC970 but altivec disabled !";
	    fi
	    TUNECPU=ppc970
702
            POWERPCMODE="64bits"
703
	;;
704 705 706
	i[3456]86|pentium|pentiumpro|pentium-mmx|pentium[234]|prescott|k6|k6-[23]|athlon|athlon-tbird|athlon-4|athlon-[mx]p|winchip-c6|winchip2|c3|nocona)
	    CFLAGS="$CFLAGS -march=$tune"
	;;
707
	*)
708
	echo "WARNING: unknown CPU \"$tune\", ignored"
709 710 711 712
	;;
    esac
fi

713
# AltiVec flags: The FSF version of GCC differs from the Apple version 
714 715
if test $cpu = "powerpc"; then
    if test $altivec = "yes"; then
716
        if test -n "`$cc -v 2>&1 | grep version | grep Apple`"; then
717 718 719 720 721 722 723
            CFLAGS="$CFLAGS -faltivec"
        else
            CFLAGS="$CFLAGS -maltivec -mabi=altivec"
        fi
    fi
fi

724 725 726 727 728 729 730
# See if we have <altivec.h>
cat > $TMPC << EOF
#include <altivec.h>
int main( void ) { return 0; }
EOF

_altivec_h="no"
731
if $cc $CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
732 733 734
_altivec_h="yes"
fi

735 736
# See does our compiler support Motorola AltiVec C API
if test $altivec = "yes"; then
737
if test $_altivec_h = "yes"; then
738
cat > $TMPC << EOF
739
#include <altivec.h>
740 741 742 743 744 745
int main(void) {
    vector signed int v1, v2, v3;
    v1 = vec_add(v2,v3);
    return 0;
}
EOF
746 747 748 749 750 751 752 753 754
else
cat > $TMPC << EOF
int main(void) {
    vector signed int v1, v2, v3;
    v1 = vec_add(v2,v3);
    return 0;
}
EOF
fi
755
$cc $CFLAGS -o $TMPE $TMPC 2> /dev/null || altivec="no"
756 757
fi

758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774
# Can only do mmi on mips
if test $mmi = "default"; then
    if test $cpu = "mips"; then
        mmi="yes"
    else
        mmi="no"
    fi
fi

# See does our compiler support mmi
if test $mmi = "yes"; then
cat > $TMPC << EOF
int main(void) {
    __asm__ ("lq \$2, 0(\$2)");
    return 0;
}
EOF
775
$cc -o $TMPE $TMPC 2> /dev/null || mmi="no"
776 777
fi

778 779
if test "$mingw32" = "yes" ; then
    v4l="no"
780
    bktr="no"
781
    audio_oss="no"
782
    dv1394="no"
783
    dc1394="no"
Fabrice Bellard's avatar
Fabrice Bellard committed
784
    ffserver="no"
785
    network="no"
Fabrice Bellard's avatar
Fabrice Bellard committed
786 787 788 789 790 791 792
    LIBPREF=""
    LIBSUF=".lib"
    SLIBPREF=""
    SLIBSUF=".dll"
    EXESUF=".exe"
    prefix="/c/Program Files/FFmpeg"
    bindir="$prefix"
793 794
fi

795 796
cc="${cross_prefix}${cc}"
ar="${cross_prefix}${ar}"
Michael Niedermayer's avatar
Michael Niedermayer committed
797
ranlib="${cross_prefix}${ranlib}"
798 799
strip="${cross_prefix}${strip}"

Fabrice Bellard's avatar
Fabrice Bellard committed
800 801
if test -z "$cross_prefix" ; then

802 803 804 805 806 807 808 809 810 811
# ---
# big/little endian test
cat > $TMPC << EOF
#include <inttypes.h>
int main(int argc, char ** argv){
	volatile uint32_t i=0x01234567;
	return (*((uint8_t*)(&i))) == 0x67;
}
EOF

812 813
if $cc -o $TMPE $TMPC 2>/dev/null ; then
$TMPE && bigendian="yes"
814 815 816 817
else
echo big/little test failed
fi

Fabrice Bellard's avatar
Fabrice Bellard committed
818 819 820 821 822 823 824 825 826
else

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

fi

827 828 829 830 831 832 833 834 835 836 837
# ---
# *inttypes.h* test
cat > $TMPC << EOF
#include <inttypes.h>
int main(int argc, char ** argv){
    return 0;
}
EOF

$cc -o $TMPE $TMPC 2>/dev/null || inttypes="no"

838 839 840 841 842 843 844 845 846 847 848 849
# ---
# *int_fast* test
cat > $TMPC << EOF
#include <inttypes.h>
int main(int argc, char ** argv){
	volatile uint_fast64_t i=0x01234567;
	return 0;
}
EOF

$cc -o $TMPE $TMPC 2>/dev/null || emu_fast_int="yes"

Nick Kurshev's avatar
Nick Kurshev committed
850 851 852 853 854 855 856 857 858 859
# ---
# check availability of some header files

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

_memalign=no
_malloc_h=no
860
if $cc -o $TMPE $TMPC 2> /dev/null ; then
Nick Kurshev's avatar
Nick Kurshev committed
861 8