]> git.sesse.net Git - x264/commitdiff
Recognize cygwin as itself when not targeting mingw
authorSteven Walters <kemuri9@gmail.com>
Thu, 3 Mar 2011 02:31:27 +0000 (21:31 -0500)
committerFiona Glaser <fiona@x264.com>
Thu, 24 Mar 2011 04:04:35 +0000 (21:04 -0700)
Also fix broken thread detection on cygwin.

common/cpu.c
configure

index 1a233a78dffff6540bfa5bcd5f2c1d917f2d72d1..7fffc4dbdf158493e7b4043c240d28a9f9901cf1 100644 (file)
@@ -358,9 +358,12 @@ int x264_cpu_num_processors( void )
 #if !HAVE_THREAD
     return 1;
 
-#elif defined(_WIN32)
+#elif SYS_WINDOWS
     return x264_pthread_num_processors_np();
 
+#elif SYS_CYGWIN
+    return sysconf( _SC_NPROCESSORS_ONLN );
+
 #elif SYS_LINUX
     unsigned int bit;
     int np;
index e4c7729945fcc746f5c8d83db88fa9fdbdf8c83e..aea03673f003da31d127901585f36c168e113597 100755 (executable)
--- a/configure
+++ b/configure
@@ -395,13 +395,18 @@ case $host_os in
         LDFLAGS="$LDFLAGS -lm"
         ;;
     cygwin*)
-        SYS="WINDOWS"
         EXE=".exe"
-        DEVNULL="NUL"
         if cc_check "" -mno-cygwin; then
             CFLAGS="$CFLAGS -mno-cygwin"
             LDFLAGS="$LDFLAGS -mno-cygwin"
         fi
+        if cpp_check "" "" "defined(__CYGWIN32__)" ; then
+            define HAVE_MALLOC_H
+            SYS="CYGWIN"
+        else
+            SYS="WINDOWS"
+            DEVNULL="NUL"
+        fi
         ;;
     mingw*)
         SYS="WINDOWS"
@@ -454,7 +459,7 @@ case $host_cpu in
         fi
         if [ "$SYS" = MACOSX ]; then
             ASFLAGS="$ASFLAGS -f macho -DPREFIX"
-        elif [ "$SYS" = WINDOWS ]; then
+        elif [ "$SYS" = WINDOWS -o "$SYS" = CYGWIN ]; then
             ASFLAGS="$ASFLAGS -f win32 -DPREFIX"
             LDFLAGS="$LDFLAGS -Wl,--large-address-aware"
         else
@@ -566,14 +571,14 @@ fi
 
 if [ $asm = auto -a \( $ARCH = X86 -o $ARCH = X86_64 \) ] ; then
     if ! as_check "vpaddw xmm0, xmm0, xmm0" ; then
-        VER=`($AS --version || echo no assembler) 2>$DEVNULL | head -n 1`
+        VER=`($AS --version || echo no assembler) 2>/dev/null | head -n 1`
         echo "Found $VER"
         echo "Minimum version is yasm-0.7.0"
         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=`(${cross_prefix}as --version || echo no gnu as) 2>$DEVNULL | head -n 1`
+        VER=`(${cross_prefix}as --version || echo no gnu as) 2>/dev/null | head -n 1`
         echo "Found $VER"
         echo "Minimum version is binutils-2.17"
         echo "Your compiler can't handle inline SSSE3 asm."
@@ -607,7 +612,7 @@ define SYS_$SYS
 # skip endianness check for Intel Compiler, as all supported platforms are little. the -ipo flag will also cause the check to fail
 if [ $compiler = GNU ]; then
     echo "int i[2] = {0x42494745,0}; double f[2] = {0x1.0656e6469616ep+102,0};" > conftest.c
-    $CC $CFLAGS conftest.c -c -o conftest.o 2>$DEVNULL || die "endian test failed"
+    $CC $CFLAGS conftest.c -c -o conftest.o 2>/dev/null || die "endian test failed"
     if (${cross_prefix}strings -a conftest.o | grep -q BIGE) && (${cross_prefix}strings -a conftest.o | grep -q FPendian) ; then
         define WORDS_BIGENDIAN
     elif !(${cross_prefix}strings -a conftest.o | grep -q EGIB && ${cross_prefix}strings -a conftest.o | grep -q naidnePF) ; then
@@ -661,6 +666,7 @@ if [ "$thread" = "posix" ]; then
     define HAVE_POSIXTHREAD
 fi
 if [ "$thread" = "win32" ]; then
+    # cygwin does not support win32 threads
     if [ "$SYS" = "WINDOWS" ]; then
         define HAVE_WIN32THREAD
     else
@@ -687,7 +693,7 @@ fi
 
 if [ "$swscale" = "auto" ] ; then
     swscale="no"
-    if ${cross_prefix}pkg-config --exists libswscale 2>$DEVNULL; then
+    if ${cross_prefix}pkg-config --exists libswscale 2>/dev/null; then
         SWSCALE_LIBS="$SWSCALE_LIBS $(${cross_prefix}pkg-config --libs libswscale)"
         SWSCALE_CFLAGS="$SWSCALE_CFLAGS $(${cross_prefix}pkg-config --cflags libswscale)"
     fi
@@ -710,7 +716,7 @@ fi
 
 if [ "$lavf" = "auto" ] ; then
     lavf="no"
-    if ${cross_prefix}pkg-config --exists libavformat libavcodec libswscale 2>$DEVNULL; then
+    if ${cross_prefix}pkg-config --exists libavformat libavcodec libswscale 2>/dev/null; then
         LAVF_LIBS="$LAVF_LIBS $(${cross_prefix}pkg-config --libs libavformat libavcodec libavutil libswscale)"
         LAVF_CFLAGS="$LAVF_CFLAGS $(${cross_prefix}pkg-config --cflags libavformat libavcodec libavutil libswscale)"
     fi
@@ -739,7 +745,7 @@ if [ "$ffms" = "auto" ] ; then
     ffms_major="2"; ffms_minor="14"; ffms_micro="0"; ffms_bump="0"
     ffms="no"
 
-    if ${cross_prefix}pkg-config --exists ffms2 2>$DEVNULL; then
+    if ${cross_prefix}pkg-config --exists ffms2 2>/dev/null; then
         FFMS2_LIBS="$FFMS2_LIBS $(${cross_prefix}pkg-config --libs ffms2)"
         FFMS2_CFLAGS="$FFMS2_CFLAGS $(${cross_prefix}pkg-config --cflags ffms2)"
     fi
@@ -803,7 +809,8 @@ fi
 
 if [ "$avs" = "auto" ] ; then
     avs="no"
-    if [ $SYS = WINDOWS ] && cc_check extras/avisynth_c.h ; then
+    # cygwin can use avisynth if it can use LoadLibrary
+    if [ $SYS = WINDOWS ] || ([ $SYS = CYGWIN ] && cc_check windows.h "" "LoadLibrary(0);") ; then
         avs="yes"
         define HAVE_AVS
     fi
@@ -956,7 +963,7 @@ fi
 
 if [ "$shared" = "yes" ]; then
     API=$(grep '#define X264_BUILD' < x264.h | cut -f 3 -d ' ')
-    if [ "$SYS" = "WINDOWS" ]; then
+    if [ "$SYS" = "WINDOWS" -o "$SYS" = "CYGWIN" ]; then
         echo "SONAME=libx264-$API.dll" >> config.mak
         if [ $compiler = ICL ]; then
             echo 'IMPLIBNAME=libx264.dll.lib' >> config.mak