--- a/configure	2010-04-11 01:22:04.000000000 +0300
+++ b/configure	2010-04-11 10:47:55.000000000 +0300
@@ -43,7 +43,7 @@
 fi
 
 if [ -n "${CHOST}" ]; then
-    uname="$(echo "${CHOST}" | sed 's/.*-.*-\(.*\)-.*/\1/')"
+    uname="$(echo "${CHOST}" | sed -e 's/.*-.*-\(.*\)-.*$/\1/' -e 's/.*-\(.*\)-.*/\1/' -e 's/.*-\(.*\)$/\1/')"
     CROSS_PREFIX="${CHOST}-"
 fi
 
@@ -53,18 +53,18 @@
 VER3=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\\.[0-9]*\).*/\1/p' < zlib.h`
 VER2=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\)\\..*/\1/p' < zlib.h`
 VER1=`sed -n -e '/VERSION "/s/.*"\([0-9]*\)\\..*/\1/p' < zlib.h`
-if [ -x "${CROSS_PREFIX}ar" ]; then
+if "${CROSS_PREFIX}ar" --version >/dev/null 2>/dev/null; then
     AR=${AR-"${CROSS_PREFIX}ar"}
 else
     AR=${AR-"ar"}
 fi
 AR_RC="${AR} rc"
-if [ -x "${CROSS_PREFIX}ranlib" ]; then
+if "${CROSS_PREFIX}ranlib" --version >/dev/null 2>/dev/null; then
     RANLIB=${RANLIB-"${CROSS_PREFIX}ranlib"}
 else
     RANLIB=${RANLIB-"ranlib"}
 fi
-if [ -x "${CROSS_PREFIX}nm" ]; then
+if "${CROSS_PREFIX}nm" --version >/dev/null 2>/dev/null; then
     NM=${NM-"${CROSS_PREFIX}nm"}
 else
     NM=${NM-"nm"}
@@ -143,7 +143,7 @@
   Linux* | linux* | GNU | GNU/* | *BSD | DragonFly) LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map"} ;;
   CYGWIN* | Cygwin* | cygwin* | OS/2*)
         EXE='.exe' ;;
-  MINGW*)
+  MINGW*|mingw*)
         LDSHARED=${LDSHARED-"$cc -shared"}
         LDSHAREDLIBC=""
         EXE='.exe' ;;
