From cc3308878925bf33c0e2707c9177dd345ed238a5 Mon Sep 17 00:00:00 2001 From: Loren Merritt Date: Wed, 7 Dec 2005 17:29:20 +0000 Subject: [PATCH] configure: autodetect gpac, avis, pthread, vfw git-svn-id: svn://svn.videolan.org/x264/trunk@385 df754926-b1dd-0310-bc7b-ec298dee348c --- Makefile | 4 +-- configure | 103 +++++++++++++++++++++++++++++++++++++++++------------ version.sh | 6 ++-- 3 files changed, 85 insertions(+), 28 deletions(-) diff --git a/Makefile b/Makefile index 93edb791..a6016db4 100644 --- a/Makefile +++ b/Makefile @@ -118,7 +118,7 @@ fprofiled: endif clean: - rm -f $(OBJS) $(OBJASM) config.h *.a x264.o matroska.o x264 x264.exe .depend TAGS + rm -f $(OBJS) $(OBJASM) *.a x264.o matroska.o x264 x264.exe .depend TAGS rm -f checkasm checkasm.exe tools/checkasm.o rm -f tools/avc2avi tools/avc2avi.exe tools/avc2avi.o rm -rf vfw/build/cygwin/bin @@ -126,7 +126,7 @@ clean: - sed -e 's/ *-fprofile-\(generate\|use\)//g' config.mak > config.mak2 && mv config.mak2 config.mak distclean: clean - rm -f config.mak vfw/build/cygwin/config.mak x264.pc + rm -f config.mak config.h vfw/build/cygwin/config.mak x264.pc install: x264 install -d $(DESTDIR)$(bindir) $(DESTDIR)$(includedir) diff --git a/configure b/configure index f1d09f69..f2686330 100755 --- a/configure +++ b/configure @@ -21,6 +21,18 @@ echo "" exit 1 fi +cc_check() { + rm -f conftest* + cat > conftest.c << EOF +#include <$1> +int main () { return 0; } +EOF + $CC $CFLAGS $LDFLAGS $2 conftest.c -o $DEVNULL 2>$DEVNULL + TMP="$?" + rm -f conftest.c + return $TMP +} + prefix='/usr/local' exec_prefix='${prefix}' bindir='${exec_prefix}/bin' @@ -28,9 +40,9 @@ libdir='${exec_prefix}/lib' includedir='${prefix}/include' DEVNULL='/dev/null' -avis_input="no" -mp4_output="no" -pthread="no" +avis_input="auto" +mp4_output="auto" +pthread="auto" debug="no" gprof="no" vfw="no" @@ -77,12 +89,14 @@ case "$UNAMES" in ASFLAGS="-f win32 -DPREFIX" EXE=".exe" DEVNULL="NUL" + vfw="yes" ;; MINGW*) SYS="MINGW" ASFLAGS="-f win32 -DPREFIX" EXE=".exe" DEVNULL="NUL" + vfw="yes" ;; SunOS) SYS="SunOS" @@ -177,20 +191,17 @@ for opt do includedir="$optarg" ;; --enable-avis-input) - if [ $SYS = CYGWIN -o $SYS = MINGW ]; then - CFLAGS="$CFLAGS -DAVIS_INPUT" - LDFLAGS="$LDFLAGS -lvfw32" - avis_input="yes" - fi + avis_input="yes" + ;; + --disable-avis-input) + avis_input="no" ;; --enable-mp4-output) - CFLAGS="$CFLAGS -DMP4_OUTPUT" - LDFLAGS="$LDFLAGS -lgpac_static" - if [ $SYS = CYGWIN -o $SYS = MINGW ]; then - LDFLAGS="$LDFLAGS -lwinmm" - fi mp4_output="yes" ;; + --disable-mp4-output) + mp4_output="no" + ;; --extra-asflags=*) ASFLAGS="$ASFLAGS ${opt#--extra-asflags=}" ;; @@ -203,15 +214,10 @@ for opt do VFW_LDFLAGS="${opt#--extra-ldflags=}" ;; --enable-pthread) - CFLAGS="$CFLAGS -DHAVE_PTHREAD=1" pthread="yes" - case $SYS in - MINGW|CYGWIN|BEOS) - ;; - *) - LDFLAGS="$LDFLAGS -lpthread" - ;; - esac + ;; + --disable-pthread) + pthread="no" ;; --enable-debug) CFLAGS="$CFLAGS -g" @@ -225,6 +231,9 @@ for opt do --enable-vfw) vfw="yes" ;; + --disable-vfw) + vfw="no" + ;; --enable-visualize) LDFLAGS="$LDFLAGS -L/usr/X11R6/lib -lX11" CFLAGS="$CFLAGS -DVISUALIZE=1" @@ -236,13 +245,62 @@ for opt do esac done -VFWFLAGS= +# autodetect options that weren't forced nor disabled + +if test "$pthread" = "auto" ; then + case $SYS in + MINGW|CYGWIN|BEOS) + pthread="yes" + ;; + *) + pthread="no" + cc_check pthread.h -lpthread && pthread="yes" + ;; + esac +fi +if test "$pthread" = "yes" ; then + CFLAGS="$CFLAGS -DHAVE_PTHREAD=1" + case $SYS in + MINGW|CYGWIN|BEOS) + ;; + *) LDFLAGS="$LDFLAGS -lpthread" + ;; + esac +fi + +MP4_LDFLAGS="-lgpac_static" +if [ $SYS = CYGWIN -o $SYS = MINGW ]; then + MP4_LDFLAGS="$MP4_LDFLAGS -lwinmm" +fi +if [ "$mp4_output" = "auto" ] ; then + mp4_output="no" + cc_check gpac/isomedia.h "$MP4_LDFLAGS" && mp4_output="yes" +fi +if [ "$mp4_output" = "yes" ] ; then + CFLAGS="$CFLAGS -DMP4_OUTPUT" + LDFLAGS="$LDFLAGS $MP4_LDFLAGS" +fi + +if [ "$avis_input" = "auto" ] ; then + if [ $SYS = CYGWIN -o $SYS = MINGW ]; then + avis_input="yes" + else + avis_input="no"; + fi +fi +if [ "$avis_input" = "yes" ] ; then + CFLAGS="$CFLAGS -DAVIS_INPUT" + LDFLAGS="$LDFLAGS -lvfw32" +fi + if [ "$debug" != "yes" -a "$gprof" != "yes" ]; then CFLAGS="$CFLAGS -s -fomit-frame-pointer" LDFLAGS="$LDFLAGS -s" VFW_LDFLAGS="$VFW_LDFLAGS -s" fi +# generate config files + rm -f config.mak cat > config.mak << EOF prefix=$prefix @@ -276,7 +334,6 @@ fi ./version.sh -# x264.pc file creation rm -f x264.pc cat > x264.pc << EOF prefix=$prefix diff --git a/version.sh b/version.sh index f302be45..75422f57 100755 --- a/version.sh +++ b/version.sh @@ -3,10 +3,10 @@ VER=`svnversion .` if [ "x$VER" != x -a "$VER" != exported ] then echo "#define X264_VERSION \" svn-$VER\"" > config.h - API=`grep '#define X264_BUILD' < x264.h | sed -e 's/.* \([1-9][0-9]*\).*/\1/'` VER=`echo $VER | sed -e 's/[^0-9].*//'` - echo "#define X264_POINTVER \"0.$API.$VER\"" >> config.h else echo "#define X264_VERSION \"\"" > config.h - echo "#define X264_POINTVER \"\"" >> config.h + VER="x" fi +API=`grep '#define X264_BUILD' < x264.h | sed -e 's/.* \([1-9][0-9]*\).*/\1/'` +echo "#define X264_POINTVER \"0.$API.$VER\"" >> config.h -- 2.47.3