configure 55 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
show_help(){
  echo "Usage: configure [options]"
  echo "Options: [defaults in brackets after descriptions]"
  echo
  echo "Standard options:"
  echo "  --help                   print this message"
12
  echo "  --log                    log tests and output to config.err"
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
  echo "  --prefix=PREFIX          install in PREFIX [$prefix]"
  echo "  --libdir=DIR             install libs in DIR [PREFIX/lib]"
  echo "  --incdir=DIR             install includes in DIR [PREFIX/include/ffmpeg]"
  echo "  --mandir=DIR             install man page in DIR [PREFIX/man]"
  echo "  --enable-mp3lame         enable MP3 encoding via libmp3lame [default=no]"
  echo "  --enable-libogg          enable Ogg support via libogg [default=no]"
  echo "  --enable-vorbis          enable Vorbis support via libvorbis [default=no]"
  echo "  --enable-theora          enable Theora support via libtheora [default=no]"
  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]"
  echo "  --enable-libgsm          enable GSM support via libgsm [default=no]"
  echo "  --enable-xvid            enable XviD support via xvidcore [default=no]"
  echo "  --enable-x264            enable H.264 encoding via x264 [default=no]"
  echo "  --enable-mingw32         enable MinGW native/cross Windows compile"
  echo "  --enable-mingwce         enable MinGW native/cross WinCE compile"
  echo "  --enable-a52             enable GPLed A52 support [default=no]"
  echo "  --enable-a52bin          open liba52.so.0 at runtime [default=no]"
  echo "  --enable-dts             enable GPLed DTS support [default=no]"
  echo "  --enable-pp              enable GPLed postprocessing support [default=no]"
  echo "  --enable-static          build static libraries [default=yes]"
  echo "  --disable-static         do not build static libraries [default=no]"
  echo "  --enable-shared          build shared libraries [default=no]"
  echo "  --disable-shared         do not build shared libraries [default=yes]"
  echo "  --enable-amr_nb          enable amr_nb float audio codec"
  echo "  --enable-amr_nb-fixed    use fixed point for amr-nb codec"
  echo "  --enable-amr_wb          enable amr_wb float audio codec"
  echo "  --enable-amr_if2         enable amr_wb IF2 audio codec"
  echo "  --enable-sunmlib         use Sun medialib [default=no]"
  echo "  --enable-pthreads        use pthreads [default=no]"
  echo "  --enable-dc1394          enable IIDC-1394 grabbing using libdc1394"
  echo "                           and libraw1394 [default=no]"
  echo "  --enable-gpl             allow use of GPL code, the resulting libav*"
  echo "                           and ffmpeg will be under GPL [default=no]"
  echo ""
  echo "Advanced options (experts only):"
  echo "  --source-path=PATH       path to source code [$source_path]"
  echo "  --cross-prefix=PREFIX    use PREFIX for compilation 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]"
  echo "  --build-suffix=SUFFIX    suffix for application specific build []"
  echo "  --cpu=CPU                force cpu to CPU  [$cpu]"
  echo "  --tune=CPU               tune code for a particular CPU"
  echo "                           (may fail or perform badly on other CPUs)"
  echo "  --powerpc-perf-enable    enable performance report on PPC"
  echo "                           (requires enabling PMC)"
  echo "  --disable-mmx            disable MMX usage"
  echo "  --disable-iwmmxt         disable iwmmxt 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]"
  echo "  --disable-v4l2           disable video4linux2 grabbing [default=no]"
  echo "  --disable-bktr           disable bktr video grabbing [default=no]"
  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-lzo            disable lzo [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 "                           MPEG audio decoding [default=no]"
  echo "  --disable-protocols      disable I/O protocols support [default=no]"
  echo "  --disable-ffserver       disable ffserver build"
  echo "  --disable-ffplay         disable ffplay build"
  echo "  --enable-small           optimize for size instead of speed"
  echo "  --enable-memalign-hack   emulate memalign, interferes with memory debuggers"
  echo "  --disable-strip          disable stripping of executables and shared libraries"
  echo "  --disable-encoder=NAME   disables encoder NAME"
  echo "  --enable-encoder=NAME    enables encoder NAME"
  echo "  --disable-decoder=NAME   disables decoder NAME"
  echo "  --enable-decoder=NAME    enables decoder NAME"
  echo "  --disable-encoders       disables all encoders"
  echo "  --disable-decoders       disables all decoders"
  echo "  --disable-muxers         disables all muxers"
  echo "  --disable-demuxers       disables all demuxers"
  echo ""
  echo "NOTE: Object files are built at the place where configure is launched."
  exit 1
}
99

100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
log(){
    echo "$@" >>$logfile
}

die(){
    echo "$@"
    rm -f $TMPC $TMPO $TMPE $TMPS $TMPH
    exit 1
}

enabled(){
    eval test "\$$1" = "yes"
}

flags_saved(){
    (: ${SAVE_CFLAGS?}) 2>/dev/null
}

118
save_flags(){
119
    flags_saved && return
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
    SAVE_CFLAGS="$CFLAGS"
    SAVE_LDFLAGS="$LDFLAGS"
    SAVE_extralibs="$extralibs"
}

restore_flags(){
    CFLAGS="$SAVE_CFLAGS"
    LDFLAGS="$SAVE_LDFLAGS"
    extralibs="$SAVE_extralibs"
    unset SAVE_CFLAGS
    unset SAVE_LDFLAGS
    unset SAVE_extralibs
}

temp_cflags(){
    save_flags
    CFLAGS="$CFLAGS $*"
}

temp_ldflags(){
    save_flags
    LDFLAGS="$LDFLAGS $*"
}

temp_extralibs(){
    save_flags
    extralibs="$extralibs $*"
}

149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
append(){
    var=$1
    shift
    flags_saved && eval "SAVE_$var=\"\$SAVE_$var $*\""
    eval "$var=\"\$$var $*\""
}

add_cflags(){
    append CFLAGS "$@"
}

add_ldflags(){
    append LDFLAGS "$@"
}

add_extralibs(){
    append extralibs "$@"
}

168
check_cc(){
169 170 171 172 173 174 175 176
    log check_cc "$@"
    cat >$TMPC
    log $cc $CFLAGS "$@" -c -o $TMPO $TMPC
    $cc $CFLAGS "$@" -c -o $TMPO $TMPC >>$logfile 2>&1
}

check_cpp(){
    log check_cpp "$@"
177
    cat >$TMPC
178 179
    log $cc $CFLAGS "$@" -E -o $TMPO $TMPC
    $cc $CFLAGS "$@" -E -o $TMPO $TMPC >>$logfile 2>&1
180 181 182
}

check_ld(){
183
    log check_ld "$@"
184
    cat >$TMPC
185 186
    log $cc $CFLAGS $LDFLAGS "$@" -o $TMPE $TMPC $extralibs
    $cc $CFLAGS $LDFLAGS "$@" -o $TMPE $TMPC $extralibs >>/dev/null 2>&1
187 188 189
}

check_cflags(){
190 191
    log check_cflags "$@"
    check_cc "$@" <<EOF && add_cflags "$@"
192 193 194 195 196
int x;
EOF
}

check_ldflags(){
197 198 199 200 201
    log check_ldflags "$@"
    check_ld "$@" <<EOF && add_ldflags "$@"
int main(){
    return 0;
}
202 203 204 205
EOF
}

check_header(){
206
    log check_header "$@"
207 208
    header=$1
    shift
209
    check_cpp "$@" <<EOF
210 211 212 213 214 215
#include <$header>
int x;
EOF
}

check_func(){
216
    log check_func "$@"
217 218 219 220 221 222 223 224 225 226
    func=$1
    shift
    check_ld "$@" <<EOF
extern int $func();
int main(){
    $func();
}
EOF
}

227 228 229 230 231 232 233 234 235 236 237 238
check_lib(){
    log check_lib "$@"
    header="$1"
    func="$2"
    shift 2
    temp_extralibs "$@"
    check_header $header && check_func $func && add_extralibs "$@"
    err=$?
    restore_flags
    return $err
}

239
check_exec(){
240 241 242 243 244 245 246 247 248
    check_ld "$@" && { test -n "$cross_prefix" || $TMPE; }
}

require(){
    name="$1"
    header="$2"
    func="$3"
    shift 3
    check_lib $header $func "$@" || die "ERROR: $name not found"
249 250
}

251 252
if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
    show_help
253 254
fi

255
# set temporary file name
Zdenek Kabelac's avatar
Zdenek Kabelac committed
256
if test ! -z "$TMPDIR" ; then
257
    TMPDIR1="${TMPDIR}"
Zdenek Kabelac's avatar
Zdenek Kabelac committed
258
elif test ! -z "$TEMPDIR" ; then
259
    TMPDIR1="${TEMPDIR}"
Nick Kurshev's avatar
Nick Kurshev committed
260
else
261
    TMPDIR1="/tmp"
Nick Kurshev's avatar
Nick Kurshev committed
262 263
fi

264 265
TMPC="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.c"
TMPO="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.o"
266
TMPE="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}"
267 268 269
TMPS="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.S"
TMPH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.h"

Fabrice Bellard's avatar
Fabrice Bellard committed
270
# default parameters
271 272
log="no"
logfile="/dev/null"
Fabrice Bellard's avatar
Fabrice Bellard committed
273
prefix="/usr/local"
274
libdir=""
Diego Biurrun's avatar
Diego Biurrun committed
275
incdir=""
276
mandir=""
Fabrice Bellard's avatar
Fabrice Bellard committed
277
bindir=""
278
cross_prefix=""
Fabrice Bellard's avatar
Fabrice Bellard committed
279 280
cc="gcc"
ar="ar"
Michael Niedermayer's avatar
Michael Niedermayer committed
281
ranlib="ranlib"
282
make="make"
283
strip="strip"
Fabrice Bellard's avatar
Fabrice Bellard committed
284
cpu=`uname -m`
285
tune="generic"
286
powerpc_perf="no"
287
mmx="default"
288
iwmmxt="default"
289
altivec="default"
290
mmi="default"
Fabrice Bellard's avatar
Fabrice Bellard committed
291
case "$cpu" in
292
  i386|i486|i586|i686|i86pc|BePC)
Fabrice Bellard's avatar
Fabrice Bellard committed
293 294
    cpu="x86"
  ;;
295 296 297 298 299 300 301
  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
302 303
    fi
  ;;
304 305
  # armv4l is a subset of armv5tel
  armv4l|armv5tel)
306 307
    cpu="armv4l"
  ;;
308 309 310
  alpha)
    cpu="alpha"
  ;;
Alex Beregszaszi's avatar
Alex Beregszaszi committed
311
  "Power Macintosh"|ppc|powerpc)
312 313
    cpu="powerpc"
  ;;
314
  mips|mipsel)
315 316
    cpu="mips"
  ;;
317
  sun4u|sparc64)
318 319
    cpu="sparc64"
  ;;
320 321 322
  sparc)
    cpu="sparc"
  ;;
Alex Beregszaszi's avatar
Alex Beregszaszi committed
323 324 325
  sh4)
    cpu="sh4"
  ;;
326 327 328 329 330 331 332 333 334 335 336 337
  parisc|parisc64)
    cpu="parisc"
  ;;
  s390|s390x)
    cpu="s390"
  ;;
  m68k)
    cpu="m68k"
  ;;
  ia64)
    cpu="ia64"
  ;;
Fabrice Bellard's avatar
Fabrice Bellard committed
338
  *)
339
    cpu="unknown"
Fabrice Bellard's avatar
Fabrice Bellard committed
340 341 342
  ;;
esac
gprof="no"
Fabrice Bellard's avatar
Fabrice Bellard committed
343
v4l="yes"
Luca Abeni's avatar
Luca Abeni committed
344
v4l2="yes"
345
bktr="no"
Fabrice Bellard's avatar
Fabrice Bellard committed
346
audio_oss="yes"
347
audio_beos="no"
348
dv1394="yes"
349
dc1394="no"
Fabrice Bellard's avatar
Fabrice Bellard committed
350
network="yes"
351
zlib="yes"
352
lzo="yes"
353
libgsm="no"
354
mp3lame="no"
355
libogg="no"
356
vorbis="no"
Nilesh Bansal's avatar
Nilesh Bansal committed
357
theora="no"
358 359
faad="no"
faadbin="no"
360
faac="no"
361
xvid="no"
362
x264="no"
363
a52="no"
Zdenek Kabelac's avatar
Zdenek Kabelac committed
364
a52bin="no"
365
dts="no"
366
pp="no"
367
mingw32="no"
Gildas Bazin's avatar
Gildas Bazin committed
368
mingwce="no"
369
cygwin="no"
370
os2="no"
371
lstatic="yes"
372
lshared="no"
373 374
optimize="yes"
debug="yes"
375
dostrip="yes"
376
installstrip="-s"
377
extralibs="-lm"
378
simpleidct="yes"
379
bigendian="no"
380
inttypes="yes"
381
emu_fast_int="no"
382
vhook="default"
383 384
dlfcn="no"
dlopen="no"
385
mpegaudio_hp="yes"
386
SHFLAGS='-shared -Wl,-soname,$@'
387
netserver="no"
388
need_inet_aton="no"
389
protocols="yes"
390
ffserver="yes"
391
ffplay="yes"
392
LIBOBJFLAGS=""
393
FFLDFLAGS=-Wl,--warn-common
394
FFSLDFLAGS=-Wl,-E
395
LDCONFIG="ldconfig"
396 397
LIBPREF="lib"
LIBSUF=".a"
398
LIB='$(LIBPREF)$(NAME)$(LIBSUF)'
399 400
SLIBPREF="lib"
SLIBSUF=".so"
401
SLIBNAME='$(SLIBPREF)$(NAME)$(SLIBSUF)'
402 403
SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
Fabrice Bellard's avatar
Fabrice Bellard committed
404
EXESUF=""
405
BUILDSUF=""
406
amr_nb="no"
407
amr_wb="no"
Zdenek Kabelac's avatar
Zdenek Kabelac committed
408
amr_nb_fixed="no"
409
amr_if2="no"
410
sunmlib="no"
411
pthreads="no"
412
gpl="no"
413
memalignhack="no"
414 415
muxers="yes"
demuxers="yes"
416 417 418 419 420 421 422

# OS specific
targetos=`uname -s`
case $targetos in
BeOS)
prefix="/boot/home/config"
# helps building libavcodec
423
CFLAGS="$CFLAGS -DPIC -fomit-frame-pointer"
424
# 3 gcc releases known for BeOS, each with ugly bugs
425
gcc_version="`$cc -v 2>&1 | grep version | cut -d ' ' -f3-`"
426 427 428 429 430 431 432 433
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
434
SHFLAGS=-nostart
Diego Biurrun's avatar
Diego Biurrun committed
435
# disable Linux things
436
audio_oss="no"
Fabrice Bellard's avatar
Fabrice Bellard committed
437
v4l="no"
Luca Abeni's avatar
Luca Abeni committed
438
v4l2="no"
439
dv1394="no"
Diego Biurrun's avatar
Diego Biurrun committed
440
# enable BeOS things
441
audio_beos="yes"
442 443 444 445 446
# 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
447
netserver="yes"
448
need_inet_aton="yes"
449
extralibs="-lnet"
450
fi ;;
451 452
SunOS)
v4l="no"
Luca Abeni's avatar
Luca Abeni committed
453
v4l2="no"
454
audio_oss="no"
455
dv1394="no"
456
make="gmake"
457
FFLDFLAGS=""
458 459 460 461
FFSLDFLAGS=""
need_inet_aton="yes"
extralibs="$extralibs -lsocket -lnsl"
;;
462 463
NetBSD)
v4l="no"
Luca Abeni's avatar
Luca Abeni committed
464
v4l2="no"
465
bktr="yes"
466 467 468
audio_oss="yes"
dv1394="no"
make="gmake"
469
FFLDFLAGS="$FFLDFLAGS -export-dynamic"
470
extralibs="$extralibs -lossaudio"
471
;;
472 473
OpenBSD)
v4l="no"
Luca Abeni's avatar
Luca Abeni committed
474
v4l2="no"
475
bktr="yes"
476 477 478
audio_oss="yes"
dv1394="no"
make="gmake"
479
LIBOBJFLAGS="\$(PIC)"
480
FFLDFLAGS="$FFLDFLAGS -export-dynamic -pthread"
481
LDCONFIG="ldconfig -m \$(libdir)"
482 483
extralibs="$extralibs -lossaudio"
;;
484 485
FreeBSD)
v4l="no"
Luca Abeni's avatar
Luca Abeni committed
486
v4l2="no"
487
bktr="yes"
488
audio_oss="yes"
489
dv1394="no"
490
make="gmake"
491
CFLAGS="$CFLAGS -pthread"
492
FFLDFLAGS="$FFLDFLAGS -export-dynamic -pthread"
493
;;
494 495 496 497 498 499 500 501 502
GNU/kFreeBSD)
v4l="no"
v4l2="no"
bktr="yes"
audio_oss="yes"
dv1394="no"
CFLAGS="$CFLAGS -pthread"
LDFLAGS="$LDFLAGS -rdynamic"
;;
503
BSD/OS)
Fabrice Bellard's avatar
Fabrice Bellard committed
504
v4l="no"
Luca Abeni's avatar
Luca Abeni committed
505
v4l2="no"
506
bktr="yes"
Fabrice Bellard's avatar
Fabrice Bellard committed
507
audio_oss="yes"
508
dv1394="no"
509 510
extralibs="-lpoll -lgnugetopt -lm"
make="gmake"
511 512
strip="strip -d"
installstrip=""
513
;;
514
Darwin)
515
cc="cc"
516
v4l="no"
Luca Abeni's avatar
Luca Abeni committed
517
v4l2="no"
518
audio_oss="no"
519
dv1394="no"
520
SHFLAGS="-dynamiclib -Wl,-single_module -Wl,-install_name,\$(libdir)/\$(SLIBNAME),-current_version,\$(SPPVERSION),-compatibility_version,\$(SPPVERSION)"
521
extralibs=""
522
darwin="yes"
523
strip="strip -x"
524
installstrip=""
525
FFLDFLAGS="-Wl,-dynamic,-search_paths_first"
526
SLIBSUF=".dylib"
527 528
SLIBNAME_WITH_FULLVERSION='$(SLIBPREF)$(NAME).$(LIBVERSION)$(SLIBSUF)'
SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(NAME).$(LIBMAJOR)$(SLIBSUF)'
529
FFSLDFLAGS=-Wl,-bind_at_load
530
;;
531
MINGW32*)
Fabrice Bellard's avatar
Fabrice Bellard committed
532
# Note: the rest of the mingw32 config is done afterwards as mingw32
Diego Biurrun's avatar
Diego Biurrun committed
533
# can be forced on the command line for Linux cross compilation.
534 535
mingw32="yes"
;;
536 537
CYGWIN*)
v4l="no"
Luca Abeni's avatar
Luca Abeni committed
538
v4l2="no"
539
audio_oss="yes"
540
dv1394="no"
541
vhook="no"
542 543
extralibs=""
cygwin="yes"
544
EXESUF=".exe"
545
;;
546
Linux)
547
FFLDFLAGS="$FFLDFLAGS -rdynamic"
548
;;
549 550 551
IRIX*)
ranlib="echo ignoring ranlib"
v4l="no"
Luca Abeni's avatar
Luca Abeni committed
552
v4l2="no"
553 554 555
audio_oss="no"
make="gmake"
;;
556 557
OS/2)
TMPE=$TMPE".exe"
558
ar="emxomfar -p128"
559 560
ranlib="echo ignoring ranlib"
strip="echo ignoring strip"
561
CFLAGS="$CFLAGS -Zomf"
562
FFLDFLAGS="-Zomf -Zstack 16384 -s"
563
SHFLAGS="-Zdll -Zomf"
564 565 566 567 568
FFSLDFLAGS=""
LIBPREF=""
LIBSUF=".lib"
SLIBPREF=""
SLIBSUF=".dll"
Fabrice Bellard's avatar
Fabrice Bellard committed
569
EXESUF=".exe"
570
extralibs=""
571
pkg_requires=""
572
v4l="no"
Luca Abeni's avatar
Luca Abeni committed
573
v4l2="no"
574
audio_oss="no"
575
dv1394="no"
576
ffserver="no"
577
vhook="no"
578
os2="yes"
579

580
;;
581 582
*) ;;
esac
Fabrice Bellard's avatar
Fabrice Bellard committed
583

Diego Biurrun's avatar
Diego Biurrun committed
584
# From MPlayer configure. We need TARGET_OS available
585
# to the Makefile, so it can distinguish between flavors
Diego Biurrun's avatar
Diego Biurrun committed
586
# of AltiVec on PowerPC.
587 588
TARGET_OS=`( uname -s ) 2>&1`
  case "$TARGET_OS" in
Alex Beregszaszi's avatar
Alex Beregszaszi committed
589
  Linux|FreeBSD|NetBSD|BSD/OS|OpenBSD|SunOS|QNX|Darwin|GNU|BeOS|MorphOS)
590 591 592 593 594 595 596 597 598 599 600 601 602 603 604
    ;;
  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

605
# find source path
606
source_path="`dirname $0`"
607 608 609 610
source_path_used="yes"
if test -z "$source_path" -o "$source_path" = "." ; then
    source_path=`pwd`
    source_path_used="no"
611 612
else
    source_path="`cd \"$source_path\"; pwd`"
Fabrice Bellard's avatar
Fabrice Bellard committed
613 614
fi

615 616 617 618 619
FFMPEG_CONFIGURATION=" "
for opt do
  FFMPEG_CONFIGURATION="$FFMPEG_CONFIGURATION""$opt "
done

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

Fabrice Bellard's avatar
Fabrice Bellard committed
622 623
for opt do
  case "$opt" in
624 625
  --log) log=yes
  ;;
626
  --prefix=*) prefix=`echo $opt | cut -d '=' -f 2`; force_prefix=yes
Fabrice Bellard's avatar
Fabrice Bellard committed
627
  ;;
628
  --libdir=*) libdir=`echo $opt | cut -d '=' -f 2`; force_libdir=yes
629
  ;;
Diego Biurrun's avatar
Diego Biurrun committed
630 631
  --incdir=*) incdir=`echo $opt | cut -d '=' -f 2`;
  ;;
632 633
  --mandir=*) mandir=`echo $opt | cut -d '=' -f 2`
  ;;
634 635 636 637
  --source-path=*) source_path=`echo $opt | cut -d '=' -f 2`
  ;;
  --cross-prefix=*) cross_prefix=`echo $opt | cut -d '=' -f 2`
  ;;
638
  --cc=*) cc=`echo $opt | cut -d '=' -f 2-`
Fabrice Bellard's avatar
Fabrice Bellard committed
639
  ;;
640 641
  --make=*) make=`echo $opt | cut -d '=' -f 2`
  ;;
642
  --extra-cflags=*) CFLAGS="$CFLAGS ${opt#--extra-cflags=}"
643
  ;;
644
  --extra-ldflags=*) FFLDFLAGS="$FFLDFLAGS ${opt#--extra-ldflags=}"
645 646 647
  ;;
  --extra-libs=*) extralibs=${opt#--extra-libs=}
  ;;
648 649
  --build-suffix=*) BUILDSUF=${opt#--build-suffix=}
  ;;
Fabrice Bellard's avatar
Fabrice Bellard committed
650 651
  --cpu=*) cpu=`echo $opt | cut -d '=' -f 2`
  ;;
652 653
  --tune=*) tune=`echo $opt | cut -d '=' -f 2`
  ;;
654 655
  --powerpc-perf-enable) powerpc_perf="yes"
  ;;
Fabrice Bellard's avatar
Fabrice Bellard committed
656 657
  --disable-mmx) mmx="no"
  ;;
658 659
  --disable-iwmmxt) iwmmxt="no"
  ;;
660 661
  --disable-altivec) altivec="no"
  ;;
Fabrice Bellard's avatar
Fabrice Bellard committed
662 663
  --enable-gprof) gprof="yes"
  ;;
Fabrice Bellard's avatar
Fabrice Bellard committed
664 665
  --disable-v4l) v4l="no"
  ;;
Luca Abeni's avatar
Luca Abeni committed
666 667
  --disable-v4l2) v4l2="no"
  ;;
668 669
  --disable-bktr) bktr="no"
  ;;
Fabrice Bellard's avatar
Fabrice Bellard committed
670 671
  --disable-audio-oss) audio_oss="no"
  ;;
672 673
  --disable-audio-beos) audio_beos="no"
  ;;
674 675
  --disable-dv1394) dv1394="no"
  ;;
676
  --disable-network) network="no"; ffserver="no"
Fabrice Bellard's avatar
Fabrice Bellard committed
677
  ;;
678 679
  --disable-zlib) zlib="no"
  ;;
680 681
  --disable-lzo) lzo="no"
  ;;
682
  --enable-a52) a52="yes"
683
  ;;
Michael Niedermayer's avatar
Michael Niedermayer committed
684
  --enable-a52bin) a52bin="yes"
Zdenek Kabelac's avatar
Zdenek Kabelac committed
685
  ;;
686
  --enable-dts) dts="yes"
687
  ;;
688
  --enable-pp) pp="yes"
689
  ;;
690 691
  --enable-libgsm) libgsm="yes"
  ;;
692
  --enable-mp3lame) mp3lame="yes"
693
  ;;
694
  --enable-libogg) libogg="yes"
695
    pkg_requires="$pkg_requires ogg >= 1.1"
Nilesh Bansal's avatar
Nilesh Bansal committed
696
  ;;
697
  --enable-vorbis) vorbis="yes"
698
    pkg_requires="$pkg_requires vorbis vorbisenc"
699
  ;;
Nilesh Bansal's avatar
Nilesh Bansal committed
700
  --enable-theora) theora="yes"
701
    pkg_requires="$pkg_requires theora"
Nilesh Bansal's avatar
Nilesh Bansal committed
702
  ;;
Zdenek Kabelac's avatar
Zdenek Kabelac committed
703 704 705 706
  --enable-faad) faad="yes"
  ;;
  --enable-faadbin) faadbin="yes"
  ;;
707
  --enable-faac) faac="yes"
708
  ;;
709 710
  --enable-xvid) xvid="yes"
  ;;
711
  --enable-x264) x264="yes"
712
  ;;
713
  --enable-dc1394) dc1394="yes"
714
    pkg_requires="$pkg_requires libraw1394"
715
  ;;
716 717
  --disable-vhook) vhook="no"
  ;;
718
  --disable-simple_idct) simpleidct="no"
719
  ;;
720 721
  --enable-mingw32) mingw32="yes"
  ;;
Gildas Bazin's avatar
Gildas Bazin committed
722 723
  --enable-mingwce) mingwce="yes"
  ;;
724 725 726 727
  --enable-static) lstatic="yes"
  ;;
  --disable-static) lstatic="no"
  ;;
728
  --enable-shared) lshared="yes"
Nick Kurshev's avatar
Nick Kurshev committed
729
  ;;
730 731
  --disable-shared) lshared="no"
  ;;
732 733 734 735
  --disable-debug) debug="no"
  ;;
  --disable-opts) optimize="no"
  ;;
736 737
  --disable-mpegaudio-hp) mpegaudio_hp="no"
  ;;
738 739
  --disable-protocols) protocols="no"; network="no"; ffserver="no"
  ;;
740 741
  --disable-ffserver) ffserver="no"
  ;;
742 743
  --disable-ffplay) ffplay="no"
  ;;
744
  --enable-small) optimize="small"
745
  ;;
Diego Biurrun's avatar
Diego Biurrun committed
746
  --enable-amr_nb) amr="yes"; amr_nb="yes"; amr_nb_fixed="no"
747
  ;;
Diego Biurrun's avatar
Diego Biurrun committed
748
  --enable-amr_nb-fixed) amr="yes"; amr_nb_fixed="yes"; amr_nb="no"
Zdenek Kabelac's avatar
Zdenek Kabelac committed
749
  ;;
Diego Biurrun's avatar
Diego Biurrun committed
750
  --enable-amr_wb) amr="yes"; amr_wb="yes"
751
  ;;
Diego Biurrun's avatar
Diego Biurrun committed
752
  --enable-amr_if2) amr="yes"; amr_if2="yes"
753
  ;;
754 755
  --enable-sunmlib) sunmlib="yes"
  ;;
756 757
  --enable-pthreads) pthreads="yes"
  ;;
758 759
  --enable-gpl) gpl="yes"
  ;;
760 761
  --enable-memalign-hack) memalignhack="yes"
  ;;
762 763
  --disable-strip) dostrip="no"
  ;;
764
  --enable-encoder=*) CODEC_LIST="$CODEC_LIST ${opt#--enable-encoder=}_encoder"
765
  ;;
766 767 768 769 770
  --enable-decoder=*) CODEC_LIST="$CODEC_LIST ${opt#--enable-decoder=}_decoder"
  ;;
  --disable-encoder=*) CODEC_LIST="`echo $CODEC_LIST | sed -e \"s#${opt#--disable-encoder=}_encoder##\"`"
  ;;
  --disable-decoder=*) CODEC_LIST="`echo $CODEC_LIST | sed -e \"s#${opt#--disable-decoder=}_decoder##\"`"
771 772 773
  ;;
  --disable-encoders) CODEC_LIST="`echo $CODEC_LIST | sed 's/[-_a-zA-Z0-9]*encoder//g'`"
  ;;
774 775
  --disable-decoders) CODEC_LIST="`echo $CODEC_LIST | sed 's/[-_a-zA-Z0-9]*decoder//g'`"
  ;;
776
  --disable-muxers) muxers="no"; ffserver="no"
777 778 779
  ;;
  --disable-demuxers) demuxers="no"
  ;;
780 781
  --help) show_help
  ;;
782 783 784 785 786
  *)
  echo "Unknown option \"$opt\"."
  echo "See $0 --help for available options."
  exit 1
  ;;
Fabrice Bellard's avatar
Fabrice Bellard committed
787 788 789
  esac
done

790 791 792 793 794
if enabled log; then
    logfile=config.err
    echo "# $0 $@" >$logfile
    set >>$logfile
fi
795 796 797 798

# Combine FFLDFLAGS and the LDFLAGS environment variable
LDFLAGS="$FFLDFLAGS $LDFLAGS"

799 800 801 802 803
cc="${cross_prefix}${cc}"
ar="${cross_prefix}${ar}"
ranlib="${cross_prefix}${ranlib}"
strip="${cross_prefix}${strip}"

804 805 806 807 808 809 810 811 812 813 814
# we need to build at least one lib type
if test "$lstatic" = "no" && test "$lshared" = "no" ; then
    cat <<EOF
At least one library type must be built.
Specify --enable-static to build the static libraries or --enable-shared to
build the shared libraries as well. To only build the shared libraries specify
--disable-static in addition to --enable-shared.
EOF
    exit 1;
fi

Nilesh Bansal's avatar
Nilesh Bansal committed
815
if test "$theora" = "yes" ; then
816
    if test "$libogg" = "no"; then
Diego Biurrun's avatar
Diego Biurrun committed
817
        echo "libogg must be enabled to enable Theora."
Nilesh Bansal's avatar
Nilesh Bansal committed
818 819 820 821 822 823
        fail="yes"
        theora="no"
    fi
fi

if test "$vorbis" = "yes" ; then
824
    if test "$libogg" = "no"; then
Diego Biurrun's avatar
Diego Biurrun committed
825
        echo "libogg must be enabled to enable Vorbis."
Nilesh Bansal's avatar
Nilesh Bansal committed
826 827 828 829 830
        fail="yes"
        vorbis="no"
    fi
fi

831
if test "$gpl" != "yes"; then
832
    if test "$pp" != "no"; then
Diego Biurrun's avatar
Diego Biurrun committed
833
        echo "The Postprocessing code is under GPL and --enable-gpl is not specified."
834 835 836 837
        fail="yes"
    fi

    if test "$a52" != "no" -o "$a52bin" != "no"; then
Diego Biurrun's avatar
Diego Biurrun committed
838
        echo "liba52 is under GPL and --enable-gpl is not specified."