]> git.sesse.net Git - x264/blobdiff - configure
if --threads > 1, then read the input stream in its own thread.
[x264] / configure
index 943ea2cf39d547588f8eefc7298827b44af02b3a..74d445f5cd6133a15b46e07ab28d566786a39f2d 100755 (executable)
--- a/configure
+++ b/configure
@@ -14,6 +14,8 @@ echo "  --enable-pthread         enables multithreaded encoding"
 echo "  --enable-debug           adds -g, doesn't strip"
 echo "  --enable-gprof           adds -pg, doesn't strip"
 echo "  --enable-visualize       enables visualization (X11 only)"
+echo "  --enable-pic             build position-independent code"
+echo "  --enable-shared          build libx264.so"
 echo "  --extra-asflags=EASFLAGS add EASFLAGS to ASFLAGS"
 echo "  --extra-cflags=ECFLAGS   add ECFLAGS to CFLAGS"
 echo "  --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS"
@@ -21,19 +23,36 @@ echo ""
 exit 1
 fi
 
+cc_check() {
+    rm -f conftest*
+    cat > conftest.c << EOF
+#include <$1>
+int main () { $3 return 0; }
+EOF
+    $CC $CFLAGS $LDFLAGS $2 conftest.c -o conftest 2>$DEVNULL
+    TMP="$?"
+    rm -f conftest.c conftest*
+    return $TMP
+}
+
+rm -f config.h config.mak x264.pc
+
 prefix='/usr/local'
 exec_prefix='${prefix}'
 bindir='${exec_prefix}/bin'
 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"
+pic="no"
 vfw="no"
 vis="no"
+shared="no"
 
 CC="gcc"
 CFLAGS="-Wall -I. -O4 -ffast-math -D__X264__"
@@ -41,7 +60,7 @@ LDFLAGS=""
 HAVE_GETOPT_LONG=1
 
 AS="nasm"
-ASFLAGS="-f elf"
+ASFLAGS=""
 
 EXE=""
 
@@ -73,13 +92,13 @@ case "$UNAMES" in
     SYS="CYGWIN"
     CFLAGS="$CFLAGS -mno-cygwin"
     LDFLAGS="$LDFLAGS -mno-cygwin"
-    ASFLAGS="-f win32 -DPREFIX"
     EXE=".exe"
+    DEVNULL="NUL"
     ;;
   MINGW*)
     SYS="MINGW"
-    ASFLAGS="-f win32 -DPREFIX"
     EXE=".exe"
+    DEVNULL="NUL"
     ;;
   SunOS)
     SYS="SunOS"
@@ -98,6 +117,17 @@ case "$UNAMEM" in
   i386|i486|i586|i686|BePC)
     ARCH="X86"
     CFLAGS="$CFLAGS -DHAVE_MMXEXT -DHAVE_SSE2"
+    AS="nasm"
+    ASFLAGS="-O2"
+    if [ "$SYS" = MACOSX ]; then
+      ASFLAGS="$ASFLAGS -f macho -DPREFIX"
+    elif [ "$SYS" = CYGWIN -o "$SYS" = MINGW ]; then
+      ASFLAGS="$ASFLAGS -f win32 -DPREFIX"
+    elif [ "$SYS" = NETBSD ]; then
+      ASFLAGS="$ASFLAGS -f aoutb"
+    else
+      ASFLAGS="$ASFLAGS -f elf"
+    fi
     ;;
   x86_64)
     ARCH="X86_64"
@@ -136,7 +166,7 @@ case "$UNAMEM" in
   m68k)
     ARCH="M68K"
     ;;
-  arm)
+  arm|armv5tel)
     ARCH="ARM"
     ;;
   s390|s390x)
@@ -174,20 +204,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=}"
             ;;
@@ -200,15 +227,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"
@@ -219,9 +241,21 @@ for opt do
             LDFLAGS="$LDFLAGS -pg"
             gprof="yes"
             ;;
+        --enable-pic)
+            pic="yes"
+            ;;
         --enable-vfw)
             vfw="yes"
             ;;
+        --disable-vfw)
+            vfw="no"
+            ;;
+        --enable-shared)
+            shared="yes"
+            if [ $ARCH = "X86_64" -o $ARCH = "PPC" -o $ARCH = "ALPHA" ] ; then
+                pic="yes"
+            fi
+            ;;
         --enable-visualize)
             LDFLAGS="$LDFLAGS -L/usr/X11R6/lib -lX11"
             CFLAGS="$CFLAGS -DVISUALIZE=1"
@@ -233,14 +267,75 @@ 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"
+    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
+    echo "#define MP4_OUTPUT" >> config.h
+    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
+    echo "#define AVIS_INPUT" >> config.h
+    LDFLAGS="$LDFLAGS -lvfw32"
+fi
+
+if [ "$pic" = "yes" ] ; then
+    CFLAGS="$CFLAGS -fPIC"
+    ASFLAGS="$ASFLAGS -D__PIC__"
+fi
+
 if [ "$debug" != "yes" -a "$gprof" != "yes" ]; then
     CFLAGS="$CFLAGS -s -fomit-frame-pointer"
     LDFLAGS="$LDFLAGS -s"
     VFW_LDFLAGS="$VFW_LDFLAGS -s"
 fi
 
-rm -f config.mak
+if cc_check "stdio.h" "" "fseeko(stdin,0,0);" ; then
+    echo "#define fseek fseeko" >> config.h
+    echo "#define ftell ftello" >> config.h
+elif cc_check "stdio.h" "" "fseeko64(stdin,0,0);" ; then
+    echo "#define fseek fseeko64" >> config.h
+    echo "#define ftell ftello64" >> config.h
+fi
+
+# generate config files
+
 cat > config.mak << EOF
 prefix=$prefix
 exec_prefix=$exec_prefix
@@ -258,6 +353,8 @@ VFW=$vfw
 EXE=$EXE
 VIS=$vis
 HAVE_GETOPT_LONG=$HAVE_GETOPT_LONG
+DEVNULL=$DEVNULL
+CONFIGURE_ARGS=$@
 EOF
 
 if [ "$vfw" = "yes" ]; then
@@ -269,8 +366,14 @@ EOF
     echo "default: x264vfw.dll" >> config.mak
 fi
 
-# x264.pc file creation
-rm -f x264.pc
+if [ "$shared" = "yes" ]; then
+    API=`grep '#define X264_BUILD' < x264.h | cut -f 3 -d ' '`
+    echo "SONAME=libx264.so.$API" >> config.mak
+    echo 'default: $(SONAME)' >> config.mak
+fi
+
+./version.sh
+
 cat > x264.pc << EOF
 prefix=$prefix
 exec_prefix=$exec_prefix
@@ -279,7 +382,7 @@ includedir=$includedir
 
 Name: x264
 Description: H.264 (MPEG4 AVC) encoder library
-Version:
+Version: $(grep POINTVER < config.h | sed -e 's/.* "//; s/".*//')
 Libs: -L$libdir -lx264
 Cflags: -I$includedir
 EOF
@@ -293,7 +396,9 @@ echo "pthread:    $pthread"
 echo "vfw:        $vfw"
 echo "debug:      $debug"
 echo "gprof:      $gprof"
+echo "PIC:        $pic"
+echo "shared:     $shared"
 echo "visualize:  $vis"
 echo
-echo "You can run 'make' now."
+echo "You can run 'make' or 'make fprofiled' now."