3 # ffmpeg configure script (c) 2000, 2001, 2002 Fabrice Bellard
5 # set temporary file name
6 if test ! -z "$TMPDIR" ; then
8 elif test ! -z "$TEMPDIR" ; then
14 TMPC="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.c"
15 TMPO="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.o"
16 TMPE="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}"
17 TMPS="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.S"
18 TMPH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.h"
33 i386|i486|i586|i686|i86pc|BePC)
42 "Power Macintosh"|ppc)
79 LDFLAGS=-Wl,--warn-common
90 prefix="/boot/home/config"
91 # helps building libavcodec
92 CFLAGS="-O3 -DPIC -fomit-frame-pointer"
93 # 3 gcc releases known for BeOS, each with ugly bugs
94 gcc_version="$($cc -v 2>&1 | grep version | cut -d ' ' -f3-)"
95 case "$gcc_version" in
96 2.9-beos-991026*|2.9-beos-000224*) echo "R5/GG gcc"
99 *20010315*) echo "BeBits gcc"
100 CFLAGS="$CFLAGS -fno-expensive-optimizations"
104 # disable linux things
110 # no need for libm, but the inet stuff
112 if (echo $BEINCLUDES|grep 'headers/be/bone' >/dev/null); then
113 extralibs="-lbind -lsocket"
127 extralibs="$extralibs -lsocket -lnsl"
134 LDFLAGS="$LDFLAGS -export-dynamic"
140 extralibs="-lpoll -lgnugetopt -lm"
148 SHFLAGS="-dynamiclib"
153 FFSLDFLAGS=-Wl,-bind_at_load
154 gcc_version="$($cc -v 2>&1 | grep version | cut -d ' ' -f4-)"
155 case "$gcc_version" in
157 CFLAGS="-no-cpp-precomp -pipe -O3 -fomit-frame-pointer"
160 CFLAGS="-no-cpp-precomp -pipe -O3 -fomit-frame-pointer -mdynamic-no-pic"
178 test -f /usr/include/inttypes.h || \
179 test -f /usr/local/include/inttypes.h || \
180 echo "Missing inttypes.h, please copy cygwin_inttypes.h to" \
181 "/usr/include/inttypes.h !!!"
184 LDFLAGS="$LDFLAGS -rdynamic"
189 strip="echo ignore strip"
191 LDFLAGS="-Zomf -Zstack 16384"
209 # From mplayer configure. We need TARGET_OS available
210 # to the Makefile, so it can distinguish between flavors
211 # of AltiVec on PowerPC
212 TARGET_OS=`( uname -s ) 2>&1`
214 Linux|FreeBSD|NetBSD|BSD/OS|OpenBSD|SunOS|QNX|Darwin|GNU)
222 [cC][yY][gG][wW][iI][nN]*)
226 TARGET_OS="$TARGET_OS-UNKNOWN"
231 # XXX: we assume an absolute path is given when launching configure,
232 # except in './configure' case.
233 source_path=${0%configure}
234 source_path=${source_path%/}
235 source_path_used="yes"
236 if test -z "$source_path" -o "$source_path" = "." ; then
238 source_path_used="no"
243 --prefix=*) prefix=`echo $opt | cut -d '=' -f 2`
245 --source-path=*) source_path=`echo $opt | cut -d '=' -f 2`
247 --cross-prefix=*) cross_prefix=`echo $opt | cut -d '=' -f 2`
249 --cc=*) cc=`echo $opt | cut -d '=' -f 2`
251 --make=*) make=`echo $opt | cut -d '=' -f 2`
253 --extra-cflags=*) CFLAGS="${opt#--extra-cflags=}"
255 --extra-ldflags=*) LDFLAGS=${opt#--extra-ldflags=}
257 --extra-libs=*) extralibs=${opt#--extra-libs=}
259 --cpu=*) cpu=`echo $opt | cut -d '=' -f 2`
261 --disable-mmx) mmx="no"
263 --disable-altivec) altivec="no"
265 --enable-gprof) gprof="yes"
267 --disable-v4l) v4l="no"
269 --disable-audio-oss) audio_oss="no"
271 --disable-audio-beos) audio_beos="no"
273 --disable-dv1394) dv1394="no"
275 --disable-network) network="no"
277 --disable-zlib) zlib="no"
279 --disable-a52) a52="no"
281 --enable-a52bin) a52bin="yes" ; extralibs="$ldl $extralibs"
283 --enable-mp3lame) mp3lame="yes"
285 --enable-vorbis) vorbis="yes"
287 --disable-vhook) vhook="no"
289 --disable-simple_idct) simpleidct="no"
291 --enable-win32) win32="yes"
293 --enable-mingw32) mingw32="yes"
295 --enable-shared) lshared="yes"
297 --disable-mpegaudio-hp) mpegaudio_hp="no"
299 --disable-ffserver) ffserver="no"
305 if test $mmx = "default"; then
306 if test $cpu = "x86"; then
313 # Can only do AltiVec on PowerPC
314 if test $altivec = "default"; then
315 if test $cpu = "powerpc"; then
322 # See does our compiler support Motorola AltiVec C API
323 if test $altivec = "yes"; then
326 vector signed int v1, v2, v3;
331 $cc -o $TMPE $TMPC -faltivec 2> /dev/null || altivec="no"
334 # Can only do mmi on mips
335 if test $mmi = "default"; then
336 if test $cpu = "mips"; then
343 # See does our compiler support mmi
344 if test $mmi = "yes"; then
347 __asm__ ("lq \$2, 0(\$2)");
351 $cc -o $TMPE $TMPC 2> /dev/null || mmi="no"
354 # Checking for CFLAGS
355 if test -z "$CFLAGS"; then
359 if test "$win32" = "yes" ; then
360 cross_prefix="i386-mingw32msvc-"
367 if test "$mingw32" = "yes" ; then
375 cc="${cross_prefix}${cc}"
376 ar="${cross_prefix}${ar}"
377 ranlib="${cross_prefix}${ranlib}"
378 strip="${cross_prefix}${strip}"
380 if test -z "$cross_prefix" ; then
383 # big/little endian test
385 #include <inttypes.h>
386 int main(int argc, char ** argv){
387 volatile uint32_t i=0x01234567;
388 return (*((uint8_t*)(&i))) == 0x67;
392 if $cc -o $TMPE $TMPC 2>/dev/null ; then
393 $TMPE && bigendian="yes"
395 echo big/little test failed
400 # if cross compiling, cannot launch a program, so make a static guess
401 if test "$cpu" = "powerpc" -o "$cpu" = "mips" ; then
408 # check availability of some header files
412 int main( void ) { return 0; }
417 if $cc -o $TMPE $TMPC 2> /dev/null ; then
420 # check for memalign - atmos
425 string = memalign(64, sizeof(char));
429 $cc -o $TMPE $TMPC 2> /dev/null || _memalign=no
435 int main( void ) { return *strptime("", "", 0); }
439 if $cc -o $TMPE $TMPC 2> /dev/null ; then
443 if test "$zlib" = "yes"; then
444 # check for zlib - mmu_man
448 if (zlibVersion() != ZLIB_VERSION)
449 puts("zlib version differs !!!");
454 $cc -o $TMPE $TMPC -lz 2> /dev/null || zlib="no"
455 # $TMPE 2> /dev/null > /dev/null || zlib="no"
456 # XXX: more tests needed - runtime test
458 if test "$zlib" = "yes"; then
459 extralibs="$extralibs -lz"
462 # test for lrintf in math.h
464 #define _ISOC9X_SOURCE 1
466 int main( void ) { return (lrintf(3.999f) > 0)?0:1; }
470 if $cc $extralibs -o $TMPE $TMPC 2> /dev/null ; then
472 $TMPE 2> /dev/null > /dev/null || have_lrintf="no"
476 for restrict_keyword in restrict __restrict__ __restrict; do
477 echo "void foo(char * $restrict_keyword p);" > $TMPC
478 if $cc -c -o $TMPO $TMPC 2> /dev/null; then
479 _restrict=$restrict_keyword
484 # test gcc version to see if vector builtins can be used
485 # currently only used on i386 for MMX builtins
488 #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 2)
491 #error no vector builtins
497 if $cc -o $TMPO $TMPC 2> /dev/null ; then
501 # dlopen/dlfcn.h probing
505 int main( void ) { return (int) dlopen("foo", 0); }
510 if $cc -o $TMPE $TMPC -ldl 2> /dev/null ; then
515 if $cc -o $TMPE $TMPC 2> /dev/null ; then
522 int main( void ) { return (int) dlopen("foo", 0); }
525 if $cc -o $TMPE $TMPC -ldl 2> /dev/null ; then
529 if $cc -o $TMPE $TMPC 2> /dev/null ; then
534 if test "$vhook" = "default" ; then
539 #include <X11/Xlib.h>
541 int main( void ) { return (int) imlib_load_font("foo"); }
545 if $cc -o $TMPE $TMPC -lImlib2 2> /dev/null ; then
549 if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
552 Usage: configure [options]
553 Options: [defaults in brackets after descriptions]
556 echo "Standard options:"
557 echo " --help print this message"
558 echo " --prefix=PREFIX install in PREFIX [$prefix]"
559 echo " --enable-mp3lame enable mp3 encoding via libmp3lame [default=no]"
560 echo " --enable-vorbis enable vorbis support via libvorbisenc [default=no]"
561 echo " --enable-win32 enable win32 cross compile"
562 echo " --enable-mingw32 enable mingw32 native windows compile"
563 echo " --disable-a52 disable GPL'ed A52 support [default=no]"
564 echo " --enable-a52bin open liba52.so.0 at runtime [default=no]"
565 echo " --enable-shared build shared libraries [default=no]"
567 echo "Advanced options (experts only):"
568 echo " --source-path=PATH path of source code [$source_path]"
569 echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]"
570 echo " --cc=CC use C compiler CC [$cc]"
571 echo " --make=MAKE use specified make [$make]"
572 echo " --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS [$CFLAGS]"
573 echo " --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]"
574 echo " --extra-libs=ELIBS add ELIBS [$ELIBS]"
575 echo " --cpu=CPU force cpu to CPU [$cpu]"
576 echo " --disable-mmx disable mmx usage"
577 echo " --disable-altivec disable AltiVec usage"
578 echo " --disable-audio-oss disable OSS audio support [default=no]"
579 echo " --disable-audio-beos disable BeOS audio support [default=no]"
580 echo " --disable-v4l disable video4linux grabbing [default=no]"
581 echo " --disable-dv1394 disable DV1394 grabbing [default=no]"
582 echo " --disable-network disable network support [default=no]"
583 echo " --disable-zlib disable zlib [default=no]"
584 echo " --disable-simple_idct disable simple IDCT routines [default=no]"
585 echo " --disable-vhook disable video hooking support"
586 echo " --enable-gprof enable profiling with gprof [$gprof]"
587 echo " --disable-mpegaudio-hp faster (but less accurate)"
588 echo " mpegaudio decoding [default=no]"
589 echo " --disable-ffserver disable ffserver build"
591 echo "NOTE: The object files are build at the place where configure is launched"
595 echo "Install prefix $prefix"
596 echo "Source path $source_path"
597 echo "C compiler $cc"
600 echo "Big Endian $bigendian"
601 if test $cpu = "x86"; then
602 echo "MMX enabled $mmx"
603 echo "Vector Builtins $builtin_vector"
605 if test $cpu = "mips"; then
606 echo "MMI enabled $mmi"
608 if test $cpu = "powerpc"; then
609 echo "AltiVec enabled $altivec"
611 echo "gprof enabled $gprof"
612 echo "zlib enabled $zlib"
613 echo "mp3lame enabled $mp3lame"
614 echo "vorbis enabled $vorbis"
615 echo "a52 support $a52"
616 echo "a52 dlopened $a52bin"
617 echo "Video hooking $vhook"
619 if test "$vhook" = "yes" ; then
620 echo "Imlib2 support $imlib2"
623 echo "Creating config.mak and config.h"
625 echo "# Automatically generated by configure - do not modify" > config.mak
626 echo "/* Automatically generated by configure - do not modify */" > $TMPH
628 echo "prefix=$prefix" >> config.mak
629 echo "MAKE=$make" >> config.mak
630 echo "CC=$cc" >> config.mak
631 echo "AR=$ar" >> config.mak
632 echo "RANLIB=$ranlib" >> config.mak
633 echo "STRIP=$strip" >> config.mak
634 echo "OPTFLAGS=$CFLAGS" >> config.mak
635 echo "LDFLAGS=$LDFLAGS" >> config.mak
636 echo "FFSLDFLAGS=$FFSLDFLAGS" >> config.mak
637 echo "SHFLAGS=$SHFLAGS" >> config.mak
638 echo "LIBPREF=$LIBPREF" >> config.mak
639 echo "LIBSUF=$LIBSUF" >> config.mak
640 echo "SLIBPREF=$SLIBPREF" >> config.mak
641 echo "SLIBSUF=$SLIBSUF" >> config.mak
642 echo "TARGET_OS=$TARGET_OS" >> config.mak
643 if test "$cpu" = "x86" ; then
644 echo "TARGET_ARCH_X86=yes" >> config.mak
645 echo "#define ARCH_X86 1" >> $TMPH
646 elif test "$cpu" = "armv4l" ; then
647 echo "TARGET_ARCH_ARMV4L=yes" >> config.mak
648 echo "#define ARCH_ARMV4L 1" >> $TMPH
649 elif test "$cpu" = "alpha" ; then
650 echo "TARGET_ARCH_ALPHA=yes" >> config.mak
651 echo "#define ARCH_ALPHA 1" >> $TMPH
652 elif test "$cpu" = "sparc64" ; then
653 echo "TARGET_ARCH_SPARC64=yes" >> config.mak
654 echo "#define ARCH_SPARC64 1" >> $TMPH
655 elif test "$cpu" = "powerpc" ; then
656 echo "TARGET_ARCH_POWERPC=yes" >> config.mak
657 echo "#define ARCH_POWERPC 1" >> $TMPH
658 echo "// Enable the next line to get PowerPC performance report" >> $TMPH
659 echo "// #define POWERPC_TBL_PERFORMANCE_REPORT 1" >> $TMPH
660 echo "// Enable the next line to use PMC registers instead of TBL" >> $TMPH
661 echo "// #define POWERPC_PERF_USE_PMC 1" >> $TMPH
662 elif test "$cpu" = "mips" ; then
663 echo "TARGET_ARCH_MIPS=yes" >> config.mak
664 echo "#define ARCH_MIPS 1" >> $TMPH
666 if test "$bigendian" = "yes" ; then
667 echo "WORDS_BIGENDIAN=yes" >> config.mak
668 echo "#define WORDS_BIGENDIAN 1" >> $TMPH
670 if test "$mmx" = "yes" ; then
671 echo "TARGET_MMX=yes" >> config.mak
672 echo "#define HAVE_MMX 1" >> $TMPH
674 if test "$builtin_vector" = "yes" ; then
675 echo "TARGET_BUILTIN_VECTOR=yes" >> config.mak
676 echo "#define HAVE_BUILTIN_VECTOR 1" >> $TMPH
678 if test "$mmi" = "yes" ; then
679 echo "TARGET_MMI=yes" >> config.mak
680 echo "#define HAVE_MMI 1" >> $TMPH
682 if test "$altivec" = "yes" ; then
683 echo "TARGET_ALTIVEC=yes" >> config.mak
684 echo "#define HAVE_ALTIVEC 1" >> $TMPH
685 echo "// Enable the next line to use the reference C code instead of AltiVec" >> $TMPH
686 echo "// #define ALTIVEC_USE_REFERENCE_C_CODE 1" >> $TMPH
688 if test "$gprof" = "yes" ; then
689 echo "TARGET_GPROF=yes" >> config.mak
690 echo "#define HAVE_GPROF 1" >> $TMPH
692 if test "$strptime" = "yes" ; then
693 echo "#define HAVE_STRPTIME 1" >> $TMPH
695 echo "BUILD_STRPTIME=yes" >> config.mak
697 if test "$imlib2" = "yes" ; then
698 echo "HAVE_IMLIB2=yes" >> config.mak
700 if test "$have_lrintf" = "yes" ; then
701 echo "#define HAVE_LRINTF 1" >> $TMPH
703 if test "$vhook" = "yes" ; then
704 echo "BUILD_VHOOK=yes" >> config.mak
705 echo "#define HAVE_VHOOK 1" >> $TMPH
706 extralibs="$extralibs $ldl"
708 if test "$lshared" = "yes" ; then
709 echo "BUILD_SHARED=yes" >> config.mak
710 echo "PIC=-fPIC" >> config.mak
712 echo "EXTRALIBS=$extralibs" >> config.mak
713 echo -n "VERSION=" >>config.mak
714 head $source_path/VERSION >>config.mak
716 # if you do not want to use encoders, disable that.
717 echo "#define CONFIG_ENCODERS 1" >> $TMPH
718 echo "CONFIG_ENCODERS=yes" >> config.mak
720 # if you do not want to use decoders, disable that.
721 echo "#define CONFIG_DECODERS 1" >> $TMPH
722 echo "CONFIG_DECODERS=yes" >> config.mak
725 if test "$a52" = "yes" ; then
726 echo "#define CONFIG_AC3 1" >> $TMPH
727 echo "CONFIG_AC3=yes" >> config.mak
729 if test "$a52bin" = "yes" ; then
730 echo "#define CONFIG_A52BIN 1" >> $TMPH
731 echo "CONFIG_A52BIN=yes" >> config.mak
735 # mpeg audio high precision mode
736 if test "$mpegaudio_hp" = "yes" ; then
737 echo "#define CONFIG_MPEGAUDIO_HP 1" >> $TMPH
740 if test "$v4l" = "yes" ; then
741 echo "#define CONFIG_VIDEO4LINUX 1" >> $TMPH
742 echo "CONFIG_VIDEO4LINUX=yes" >> config.mak
745 if test "$dv1394" = "yes" ; then
746 echo "#define CONFIG_DV1394 1" >> $TMPH
747 echo "CONFIG_DV1394=yes" >> config.mak
750 if test "$dlopen" = "yes" ; then
751 echo "#define CONFIG_HAVE_DLOPEN 1" >> $TMPH
754 if test "$dlfcn" = "yes" ; then
755 echo "#define CONFIG_HAVE_DLFCN 1" >> $TMPH
758 if test "$audio_oss" = "yes" ; then
759 echo "#define CONFIG_AUDIO_OSS 1" >> $TMPH
760 echo "CONFIG_AUDIO_OSS=yes" >> config.mak
763 if test "$audio_beos" = "yes" ; then
764 echo "#define CONFIG_AUDIO_BEOS 1" >> $TMPH
765 echo "CONFIG_AUDIO_BEOS=yes" >> config.mak
768 if test "$network" = "yes" ; then
769 echo "#define CONFIG_NETWORK 1" >> $TMPH
770 echo "CONFIG_NETWORK=yes" >> config.mak
773 if test "$zlib" = "yes" ; then
774 echo "#define CONFIG_ZLIB 1" >> $TMPH
775 echo "CONFIG_ZLIB=yes" >> config.mak
778 if test "$mp3lame" = "yes" ; then
779 echo "#define CONFIG_MP3LAME 1" >> $TMPH
780 echo "CONFIG_MP3LAME=yes" >> config.mak
783 if test "$vorbis" = "yes" ; then
784 echo "#define CONFIG_VORBIS 1" >> $TMPH
785 echo "CONFIG_VORBIS=yes" >> config.mak
788 if test "$win32" = "yes" ; then
789 echo "#define CONFIG_WIN32 1" >> $TMPH
790 echo "CONFIG_WIN32=yes" >> config.mak
793 if test "$mingw32" = "yes" ; then
794 echo "#define CONFIG_WIN32 1" >> $TMPH
795 echo "CONFIG_WIN32=yes" >> config.mak
796 echo "#define __MINGW32__ 1" >> $TMPH
797 echo "__MINGW32__=1" >> config.mak
800 if test "$cygwin" = "yes" ; then
801 # setup correct exesuffix
802 echo "CONFIG_WIN32=yes" >> config.mak
805 if test "$os2" = "yes" ; then
806 echo "#define CONFIG_OS2 1" >> $TMPH
807 echo "CONFIG_OS2=yes" >> config.mak
810 if test "$darwin" = "yes"; then
811 echo "#define CONFIG_DARWIN 1" >> $TMPH
812 echo "CONFIG_DARWIN=yes" >> config.mak
815 if test "$_malloc_h" = "yes" ; then
816 echo "#define HAVE_MALLOC_H 1" >> $TMPH
818 echo "#undef HAVE_MALLOC_H" >> $TMPH
821 if test "$_memalign" = "yes" ; then
822 echo "#define HAVE_MEMALIGN 1" >> $TMPH
824 echo "#undef HAVE_MEMALIGN" >> $TMPH
827 if test "$netserver" = "yes" ; then
828 echo "#define CONFIG_BEOS_NETSERVER 1" >> $TMPH
829 echo "CONFIG_BEOS_NETSERVER=yes" >> config.mak
832 if test "$need_inet_aton" = "yes" ; then
833 echo "NEED_INET_ATON=yes" >> config.mak
836 if test "$simpleidct" = "yes" ; then
837 echo "#define SIMPLE_IDCT 1" >> $TMPH
840 if test "$ffserver" = "yes" ; then
841 echo "#define CONFIG_FFSERVER 1" >> $TMPH
842 echo "CONFIG_FFSERVER=yes" >> config.mak
845 echo "#define restrict $_restrict" >> $TMPH
847 # build tree in object directory if source path is different from current one
848 if test "$source_path_used" = "yes" ; then
849 DIRS="libavformat libavcodec libavcodec/alpha libavcodec/armv4l libavcodec/i386 \
850 libavcodec/ppc libavcodec/liba52 libavcodec/mlib tests vhook"
851 FILES="Makefile libavformat/Makefile libavcodec/Makefile tests/Makefile vhook/Makefile"
852 for dir in $DIRS ; do
856 ln -sf $source_path/$f $f
859 echo "SRC_PATH=$source_path" >> config.mak
861 diff $TMPH config.h >/dev/null 2>&1
862 if test $? -ne 0 ; then
865 echo "config.h is unchanged"
868 rm -f $TMPO $TMPC $TMPE $TMPS $TMPH