]> git.sesse.net Git - x264/blobdiff - configure
compile fix for GCC-3.3 on OSX, based on a patch by
[x264] / configure
index 41c48bca06afa9caff4a0df0a5e691eb948a1433..c16a3293e752cc76d7535a5c00bfe73112aa3ff1 100755 (executable)
--- a/configure
+++ b/configure
@@ -29,9 +29,9 @@ cc_check() {
 #include <$1>
 int main () { $3 return 0; }
 EOF
-    $CC $CFLAGS $LDFLAGS $2 conftest.c -o conftest 2>$DEVNULL
+    $CC conftest.c $CFLAGS $LDFLAGS $2 -o conftest 2>$DEVNULL
     TMP="$?"
-    rm -f conftest.c conftest*
+    rm -f conftest*
     return $TMP
 }
 
@@ -55,8 +55,8 @@ vis="no"
 shared="no"
 
 CC="${CC-gcc}"
-CFLAGS="-Wall -I. -D__X264__"
-LDFLAGS=""
+CFLAGS="$CFLAGS -Wall -I. -D__X264__"
+LDFLAGS="$LDFLAGS"
 HAVE_GETOPT_LONG=1
 
 AS="nasm"
@@ -64,6 +64,18 @@ ASFLAGS=""
 
 EXE=""
 
+# check whether 'echo -n' works as expected, otherwise try printf
+if [ "x`echo -n houba`" = xhouba ]
+then
+  ECHON="echo -n"
+elif [ "x`printf houba`" = xhouba ]
+then
+  ECHON="printf"
+else
+  echo "Neither 'echo -n' nor 'printf' are working with your shell!"
+  exit 1
+fi
+
 MACHINE="$(./config.guess)"
 
 case "${MACHINE#*-*-}" in
@@ -182,6 +194,21 @@ case "${MACHINE%%-*}" in
     ;;
 esac
 
+# check requirements
+
+if [ $SYS = MACOSX -a $ARCH = X86 ]
+then
+  # we want Apple's nasm from Xcode 2.4.1 or later
+  NASM_BUILD_REQUIRED=11
+  NASM_BUILD=`nasm -v|grep "Apple Computer"|sed 's/.*build \([0-9]*\).*/\1/'`
+  if [ $NASM_BUILD -lt $NASM_BUILD_REQUIRED ]
+  then
+    echo "Your version of 'nasm' is too old."
+    echo "Please install Xcode 2.4.1 or later."
+    exit 1
+  fi
+fi
+
 CFLAGS="$CFLAGS -DARCH_$ARCH -DSYS_$SYS"
 
 # parse options
@@ -226,7 +253,7 @@ for opt do
             LDFLAGS="$LDFLAGS ${opt#--extra-ldflags=}"
             ;;
         --enable-pthread)
-            pthread="yes"
+            pthread="auto" # can't skip detection, since it differs by OS
             ;;
         --disable-pthread)
             pthread="no"
@@ -267,25 +294,34 @@ done
 
 # autodetect options that weren't forced nor disabled
 
+libpthread=""
 if test "$pthread" = "auto" ; then
+    pthread="no"
     case $SYS in
-        MINGW|CYGWIN|BEOS)
+        BEOS)
             pthread="yes"
             ;;
+        MINGW|CYGWIN)
+            if cc_check pthread.h -lpthread "pthread_create(0,0,0,0);" ; then
+                pthread="yes"
+                libpthread="-lpthread"
+            elif cc_check pthread.h -lpthreadGC2 "pthread_create(0,0,0,0);" ; then
+                pthread="yes"
+                libpthread="-lpthreadGC2"
+            elif cc_check pthread.h "-lpthreadGC2 -lwsock32 -DPTW32_STATIC_LIB" "pthread_create(0,0,0,0);" ; then
+                pthread="yes"
+                libpthread="-lpthreadGC2 -lwsock32"\
+                CFLAGS="$CFLAGS -DPTW32_STATIC_LIB"
+            fi
+            ;;
         *)
-            pthread="no"
-            cc_check pthread.h -lpthread && pthread="yes"
+            cc_check pthread.h -lpthread && pthread="yes" && libpthread="-lpthread"
             ;;
     esac
 fi
 if test "$pthread" = "yes" ; then
     CFLAGS="$CFLAGS -DHAVE_PTHREAD"
-    case $SYS in
-        MINGW|CYGWIN|BEOS)
-            ;;
-        *) LDFLAGS="$LDFLAGS -lpthread"
-            ;;
-    esac
+    LDFLAGS="$LDFLAGS $libpthread"
 fi
 
 MP4_LDFLAGS="-lgpac_static"
@@ -357,11 +393,12 @@ EXE=$EXE
 VIS=$vis
 HAVE_GETOPT_LONG=$HAVE_GETOPT_LONG
 DEVNULL=$DEVNULL
+ECHON=$ECHON
 EOF
 
-echo -n 'CONFIGURE_ARGS=' >> config.mak
+$ECHON 'CONFIGURE_ARGS=' >> config.mak
 for A in "$@" ; do
-    echo -n " '$A'" >> config.mak
+    $ECHON " '$A'" >> config.mak
 done
 echo '' >> config.mak
 
@@ -383,15 +420,7 @@ fi
 
 ./version.sh
 
-pclibs="-L$libdir -lx264"
-if test "$pthread" = "yes" ; then
-  case $SYS in
-    MINGW|CYGWIN|BEOS)
-      ;;
-    *) pclibs="$pclibs -lpthread"
-      ;;
-  esac
-fi
+pclibs="-L$libdir -lx264 $libpthread"
 
 cat > x264.pc << EOF
 prefix=$prefix