Hello,

Among the many packages Cygwin provides are MinGW builds of GCC and the
associated libraries and tools, making this a convenient alternative to
MSYS and the packages provided directly by the MinGW project.

When one is using the MinGW compiler in this environment, however,
config.guess still identifies the system as *-*-cygwin, instead of the
more appropriate *-*-mingw* which will typically enable Windows-specific
build settings (such as linking against -lws2_32 for networking
functions).

The attached patch (against git master) consolidates the three separate
Cygwin cases in the big case statement, and adds a compiler check. The
output is changed only if the MinGW compiler is in use; otherwise,
*-*-cygwin is returned as before.

Two open questions remain on my part, however:

* I have the 32/64-bit mode of the compiler affect the OS part of the
  triplet ("mingw32" versus "mingw64"); should it also affect the CPU?
  (Is it sensible to return e.g. i686-pc-mingw64 or
  x86_64-unknown-mingw32?)

* The vendor part of the triplet is "pc" for iX86 systems, and "unknown"
  for x86_64; this seems arbitrary. Is there a good reason not to return
  "pc" consistently for 32- and 64-bit x86?


--Daniel


P.S.: Please Cc: any replies to me, as I am not subscribed to this list.


-- 
Daniel Richard G. || sk...@iskunk.org
My ASCII-art .sig got a bad case of Times New Roman.
diff --git a/ChangeLog b/ChangeLog
index cc122de..4b2ef36 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2013-10-19  Daniel Richard G.  <sk...@iskunk.org>
+
+	* config.guess (*:CYGWIN*:*): Consolidated the three Cygwin
+	cases, and added a check in case we're using one of the MinGW
+	compilers that Cygwin ships.
+
 2013-10-01  Ben Elliston  <b...@gnu.org>
 
 	Reported by Jö Fahlke <jor...@jorrit.de>.
diff --git a/config.guess b/config.guess
index b79252d..d867b79 100755
--- a/config.guess
+++ b/config.guess
@@ -817,8 +817,33 @@ EOF
 		echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
 	esac
 	exit ;;
-    i*:CYGWIN*:*)
-	echo ${UNAME_MACHINE}-pc-cygwin
+    *:CYGWIN*:*)
+	case "${UNAME_MACHINE}" in
+	    amd64 | x86_64)
+		cpu_vendor=x86_64-unknown ;;
+	    p*)
+		cpu_vendor=powerpcle-unknown ;;
+	    *)
+		cpu_vendor=${UNAME_MACHINE}-pc ;;
+	esac
+	eval $set_cc_for_build
+	if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
+	    # Cygwin ships the MinGW compilers, so check for those.
+	    cat <<-EOF > $dummy.c
+		#if defined(__MINGW64__)
+		MINGW=64
+		#elif defined(__MINGW32__)
+		MINGW=32
+		#endif
+		EOF
+	    MINGW=
+	    eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^MINGW'`
+	    if [ -n "$MINGW" ]; then
+		echo ${cpu_vendor}-mingw$MINGW
+		exit
+	    fi
+	fi
+	echo ${cpu_vendor}-cygwin
 	exit ;;
     *:MINGW64*:*)
 	echo ${UNAME_MACHINE}-pc-mingw64
@@ -863,12 +888,6 @@ EOF
     i*:UWIN*:*)
 	echo ${UNAME_MACHINE}-pc-uwin
 	exit ;;
-    amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
-	echo x86_64-unknown-cygwin
-	exit ;;
-    p*:CYGWIN*:*)
-	echo powerpcle-unknown-cygwin
-	exit ;;
     prep*:SunOS:5.*:*)
 	echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
 	exit ;;
_______________________________________________
config-patches mailing list
config-patches@gnu.org
https://lists.gnu.org/mailman/listinfo/config-patches

Reply via email to