]> git.sesse.net Git - x264/blobdiff - configure
Fix bug in b-adapt 1
[x264] / configure
index f02d3e70eb229c4ad1e40bec5b3694f57c917670..53198e85a8d64924d19fc665032e4c07181bc1e7 100755 (executable)
--- a/configure
+++ b/configure
@@ -26,10 +26,9 @@ exit 1
 fi
 
 cc_check() {
-    cat > conftest.c << EOF
-#include <$1>
-int main () { $3 return 0; }
-EOF
+    rm -f conftest.c
+    [ -n "$1" ] && echo "#include <$1>" > conftest.c
+    echo "int main () { $3 return 0; }" >> conftest.c
     $CC conftest.c $CFLAGS $LDFLAGS $2 -o conftest 2>$DEVNULL
 }
 
@@ -38,6 +37,11 @@ as_check() {
     $AS conftest.asm $ASFLAGS $2 -o conftest.o 2>$DEVNULL
 }
 
+die() {
+    echo "$@"
+    exit 1
+}
+
 rm -f config.h config.mak x264.pc conftest*
 
 prefix='/usr/local'
@@ -198,17 +202,19 @@ case $host_os in
     CFLAGS="$CFLAGS -I/usr/X11R6/include"
     LDFLAGS="$LDFLAGS -lm"
     ;;
-  linux*)
+  *linux*)
     SYS="LINUX"
     CFLAGS="$CFLAGS -DHAVE_MALLOC_H"
     LDFLAGS="$LDFLAGS -lm"
     ;;
   cygwin*)
     SYS="MINGW"
-    CFLAGS="$CFLAGS -mno-cygwin"
-    LDFLAGS="$LDFLAGS -mno-cygwin"
     EXE=".exe"
     DEVNULL="NUL"
+    if cc_check "" -mno-cygwin; then
+        CFLAGS="$CFLAGS -mno-cygwin"
+        LDFLAGS="$LDFLAGS -mno-cygwin"
+    fi
     ;;
   mingw*)
     SYS="MINGW"
@@ -222,8 +228,7 @@ case $host_os in
     HAVE_GETOPT_LONG=0
     ;;
   *)
-    echo "Unknown system $host, edit the configure"
-    exit 1
+    die "Unknown system $host, edit the configure"
     ;;
 esac
 
@@ -295,20 +300,29 @@ esac
 
 # check requirements
 
+cc_check || die "No working C compiler found."
+
 if [ $shared = yes -a \( $ARCH = "X86_64" -o $ARCH = "PPC" -o $ARCH = "ALPHA" \) ] ; then
     pic="yes"
 fi
 
 if [ $asm = yes -a \( $ARCH = X86 -o $ARCH = X86_64 \) ] ; then
-    if as_check "pinsrd xmm0, [esp], 0" ; then
-        CFLAGS="$CFLAGS -DHAVE_MMX"
-    else
+    if ! as_check "pinsrd xmm0, [esp], 0" ; then
         VER=`($AS --version || echo no assembler) 2>$DEVNULL | head -n 1`
         echo "Found $VER"
         echo "Minimum version is yasm-0.6.1"
         echo "If you really want to compile without asm, configure with --disable-asm."
         exit 1
     fi
+    if ! cc_check '' '' 'asm("pabsw %xmm0, %xmm0");' ; then
+        VER=`(as --version || echo no gnu as) 2>$DEVNULL | head -n 1`
+        echo "Found $VER"
+        echo "Minimum version is binutils-2.17"
+        echo "Your compiler can't handle inline SSSE3 asm."
+        echo "If you really want to compile without asm, configure with --disable-asm."
+        exit 1
+    fi
+    CFLAGS="$CFLAGS -DHAVE_MMX"
 fi
 [ $asm = no ] && AS=""
 [ "x$AS" = x ] && asm="no"