]> git.sesse.net Git - x264/commitdiff
configure: autodetect gpac, avis, pthread, vfw
authorLoren Merritt <pengvado@videolan.org>
Wed, 7 Dec 2005 17:29:20 +0000 (17:29 +0000)
committerLoren Merritt <pengvado@videolan.org>
Wed, 7 Dec 2005 17:29:20 +0000 (17:29 +0000)
git-svn-id: svn://svn.videolan.org/x264/trunk@385 df754926-b1dd-0310-bc7b-ec298dee348c

Makefile
configure
version.sh

index 93edb791cc94016ae6a75564c4585648897dbbfc..a6016db45a2f8c6e6ec0542f037d2c78a013c668 100644 (file)
--- 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)
index f1d09f69aa813a855428fe2abb31e309b32de85c..f2686330fec3a48e848b9877ed30768516db033e 100755 (executable)
--- 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
index f302be4544fa7c1674d9b9f3bf6c1b367b2ea740..75422f579674d8fdb39ef509cef80ba0b153febd 100755 (executable)
@@ -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