From ffe96559663ddf2b60e4aae241baa7894a36bdea Mon Sep 17 00:00:00 2001
From: joerg_wunsch <joerg_wunsch@81a1dc3b-b13d-400b-aceb-764788c761c2>
Date: Tue, 19 Jan 2010 10:03:05 +0000
Subject: [PATCH] bug #28677: Cygwin's GCC no longer supports -mno-cygwin
 option * configure.ac: For Win32 environments, add a check whether the
 compiler understands the -mno-cygwin option.  If not, don't use it but
 suggest using a different compiler.

git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@930 81a1dc3b-b13d-400b-aceb-764788c761c2
---
 ChangeLog    |  7 +++++++
 NEWS         | 10 ++++++----
 configure.ac | 46 ++++++++++++++++++++++++++++++++++++----------
 3 files changed, 49 insertions(+), 14 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 7cd9a327..f71a5acf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2010-01-19  Joerg Wunsch <j.gnu@uriah.heep.sax.de>
+
+	bug #28677: Cygwin's GCC no longer supports -mno-cygwin option
+	* configure.ac: For Win32 environments, add a check whether the
+	compiler understands the -mno-cygwin option.  If not, don't use
+	it but suggest using a different compiler.
+
 2010-01-18  David Hoerl <dhoerl@mac.com>
 
 	bug #28660: Problem with loading intel hex rom files that exceed
diff --git a/NEWS b/NEWS
index 64bafd0e..f6f55651 100644
--- a/NEWS
+++ b/NEWS
@@ -7,12 +7,14 @@ Approximate change log for AVRDUDE by version.
 ----------------------------------------------------------------------
 Current:
 
-  * New devices supported:
-
-  * New programmers supported:
-
   * Bugfixes
+      - bug #28660: Problem with loading intel hex rom files that exceed
+        0x10000 bytes
+      - see ChangeLog for more details
 
+  * New Features
+      - (JTAG ICE / AVR Dragon) apply external reset if JTAG ID could
+        not be read
 
 Version 5.9:
 
diff --git a/configure.ac b/configure.ac
index 0d04c29a..15d6b8b8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -241,16 +241,6 @@ else
 fi
 export confsubst
 
-# See if we need to drop into the windows subdir.
-case $target in
-        *-*-mingw32* | *-*-cygwin* | *-*-windows*)
-		WINDOWS_DIRS="windows"
-		CFLAGS="${CFLAGS} -mno-cygwin -DWIN32NATIVE"
-		LDFLAGS="${LDFLAGS} -static"
-		;;
-esac
-AC_SUBST(WINDOWS_DIRS,$WINDOWS_DIRS)
-
 # If we are compiling with gcc, enable all warning and make warnings errors.
 if test "$GCC" = yes; then
     ENABLE_WARNINGS="-Wall"
@@ -276,6 +266,42 @@ if test "$GCC" = yes; then
 fi
 AC_SUBST(ENABLE_WARNINGS,$ENABLE_WARNINGS)
 
+# See if we need to drop into the windows subdir.
+case $target in
+        *-*-mingw32* | *-*-cygwin* | *-*-windows*)
+		if test "$GCC" = yes -a \( "$CC" = "cc" -o "$CC" = "gcc" \); then
+			# does this compiler support -mno-cygwin?
+			AC_MSG_CHECKING([if $CC accepts -mno-cygwin])
+
+			safe_CFLAGS=$CFLAGS
+			CFLAGS="$ENABLE_WARNINGS -mno-cygwin"
+
+			AC_TRY_COMPILE(, [ int main () { return 0 ; } ], [
+				no_cygwin=yes
+				AC_MSG_RESULT([yes])
+				], [
+				no_cygwin=no
+				AC_MSG_RESULT([no])
+				])
+			CFLAGS=$safe_CFLAGS
+
+			if test x$no_cygwin = xyes; then
+				CFLAGS="${CFLAGS} -mno-cygwin"
+			else
+				AC_MSG_NOTICE([Your compiler does not understand the -mno-cygwin option.])
+				AC_MSG_NOTICE([You might want to select an alternative compiler, like])
+				AC_MSG_NOTICE([])
+				AC_MSG_NOTICE([CC=mingw32-gcc ./configure])
+				AC_MSG_NOTICE([])
+			fi
+		fi
+		WINDOWS_DIRS="windows"
+		CFLAGS="${CFLAGS} -DWIN32NATIVE"
+		LDFLAGS="${LDFLAGS} -static"
+		;;
+esac
+AC_SUBST(WINDOWS_DIRS,$WINDOWS_DIRS)
+
 AC_CONFIG_FILES([
        doc/Makefile
        windows/Makefile