From b6806fb0a13b424d7e697affd28a3c6d64b0e2d8 Mon Sep 17 00:00:00 2001
From: chrfranke <chrfranke@4ea69e1a-61f1-4043-bf83-b5c94c648137>
Date: Fri, 5 Mar 2010 23:00:30 +0000
Subject: [PATCH] Windows: Use '.win64' in names of 64-bit binary packages. Use
 correct 'strip' program when cross-compiling.

git-svn-id: https://smartmontools.svn.sourceforge.net/svnroot/smartmontools/trunk@3074 4ea69e1a-61f1-4043-bf83-b5c94c648137
---
 smartmontools/CHANGELOG    |  3 +++
 smartmontools/INSTALL      |  4 +---
 smartmontools/Makefile.am  | 14 ++++++++++----
 smartmontools/configure.in | 11 +++++++----
 4 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/smartmontools/CHANGELOG b/smartmontools/CHANGELOG
index bf93c91fd..5ded674f9 100644
--- a/smartmontools/CHANGELOG
+++ b/smartmontools/CHANGELOG
@@ -43,6 +43,9 @@ NOTES FOR FUTURE RELEASES: see TODO file.
 
 <DEVELOPERS: ADDITIONS TO THE CHANGE LOG GO JUST BELOW HERE, PLEASE>
 
+  [CF] Windows: Use '.win64' in names of 64-bit binary packages.
+       Use correct 'strip' program when cross-compiling.
+
   [CF] Add update script to make targets 'dist' and 'clean',
        set +x permission, update svn:ignore.
 
diff --git a/smartmontools/INSTALL b/smartmontools/INSTALL
index 136cf8a08..c03607b12 100644
--- a/smartmontools/INSTALL
+++ b/smartmontools/INSTALL
@@ -459,9 +459,7 @@ To cross-compile on Debian Linux with gcc-mingw32:
 To compile statically linked 64-bit version with MinGW-w64:
 
   ./configure --build=$(./config.guess)  \
-              --host=x86_64-pc-mingw32   \
-               CC=x86_64-w64-mingw32-gcc \
-              CXX=x86_64-w64-mingw32-g++ \
+              --host=x86_64-w64-mingw32   \
               LDFLAGS=-static
 
   Tested on Cygwin and Linux with MinGW-w64 from
diff --git a/smartmontools/Makefile.am b/smartmontools/Makefile.am
index 95fbaba36..40c71c68d 100644
--- a/smartmontools/Makefile.am
+++ b/smartmontools/Makefile.am
@@ -520,9 +520,15 @@ check:
 if OS_WIN32_MINGW
 # Definitions for Windows distribution
 
-distdir_win32 = $(PACKAGE)-$(VERSION).win32
-distzip_win32 = $(PACKAGE)-$(VERSION).win32.zip
-distinst_win32= $(PACKAGE)-$(VERSION).win32-setup.exe
+if OS_WIN64
+win_bits = 64
+else
+win_bits = 32
+endif
+
+distdir_win32  = $(PACKAGE)-$(VERSION).win$(win_bits)
+distzip_win32  = $(PACKAGE)-$(VERSION).win$(win_bits).zip
+distinst_win32 = $(PACKAGE)-$(VERSION).win$(win_bits)-setup.exe
 
 exedir_win32 = $(distdir_win32)/bin
 docdir_win32 = $(distdir_win32)/doc
@@ -605,7 +611,7 @@ syslogevt.check:
 
 $(exedir_win32)/%.exe: %.exe
 	cp -p $< $@
-	strip -s $@
+	if test -n '$(STRIP)'; then $(STRIP) -s $@; else strip -s $@; fi
 	touch -r $< $@
 
 $(docdir_win32)/%.html: %.html
diff --git a/smartmontools/configure.in b/smartmontools/configure.in
index 41876cad0..29880c215 100644
--- a/smartmontools/configure.in
+++ b/smartmontools/configure.in
@@ -38,7 +38,7 @@ case "${host}" in
 		# to select MinGW gcc. This does no longer work for gcc 4.x.
 		if test "${build}" = "${host}" && test -x /usr/bin/uname && \
 		   /usr/bin/uname | grep -i '^CYGWIN' >/dev/null; then
-		  AC_MSG_CHECKING([whether C and C++ compiler support -mno-cygwin])
+		  AC_MSG_CHECKING([whether $CC and $CXX support -mno-cygwin])
 		  gcc_support_m_no_cygwin=no
 		  if $CC  -v -mno-cygwin >/dev/null 2>&1 && \
 		     $CXX -v -mno-cygwin >/dev/null 2>&1; then
@@ -138,7 +138,7 @@ AC_MSG_RESULT([$libc_have_working_snprintf])
 
 # check for __attribute__((packed))
 AH_TEMPLATE(HAVE_ATTR_PACKED, [Define to 1 if C++ compiler supports __attribute__((packed))])
-AC_MSG_CHECKING([whether C++ compiler supports __attribute__((packed))])
+AC_MSG_CHECKING([whether $CXX supports __attribute__((packed))])
 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [[struct a { int b; } __attribute__((packed));]])],
                   [gcc_have_attr_packed=yes], [gcc_have_attr_packed=no])
 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [[#if defined(__SUNPRO_C) || defined(__SUNPRO_CC)
@@ -269,6 +269,7 @@ AC_SUBST(smartmontools_release_time)
 
 AC_MSG_CHECKING([for OS dependent modules and libraries])
 dnl if OS not recognized, then use the os_generic modules
+os_win64=no
 case "${host}" in
 	*-*-linux*)
 		AC_SUBST([os_deps], ['os_linux.o cciss.o']) 
@@ -302,7 +303,8 @@ case "${host}" in
 		AC_SUBST([os_libs], ['']) ;;
 	*-*-mingw*)
 		AC_SUBST([os_deps], ['os_win32.o'])
-		AC_SUBST([os_libs], ['']) ;;
+		AC_SUBST([os_libs], [''])
+		test "$host_cpu" = "x86_64" && os_win64=yes ;;
 	*-*-darwin*)
 		AC_SUBST([os_deps], ['os_darwin.o'])
 		AC_SUBST([os_libs], ['-framework CoreFoundation -framework IOKit']) ;;
@@ -345,6 +347,7 @@ dnl Define platform-specific symbol.
 AM_CONDITIONAL(OS_DARWIN, [echo $host_os | grep '^darwin' > /dev/null])
 AM_CONDITIONAL(OS_SOLARIS, [echo $host_os | grep '^solaris' > /dev/null])
 AM_CONDITIONAL(OS_WIN32_MINGW, [echo $host_os | grep '^mingw' > /dev/null])
+AM_CONDITIONAL(OS_WIN64, [test "$os_win64" = "yes"])
 AM_CONDITIONAL(OS_FREEBSD, [echo $host_os | grep '^freebsd' > /dev/null])
 
 dnl Add -Wall and -W if using g++ and its not already specified.
@@ -364,7 +367,7 @@ if test "$GXX" = "yes"; then
 
   # Disable strict aliasing rules by default (see ticket #23).
   if test -z "`echo "$CXXFLAGS" | grep "\-f[[no-]]*strict-aliasing" 2> /dev/null`" ; then
-    AC_MSG_CHECKING([whether g++ supports -fno-strict-aliasing])
+    AC_MSG_CHECKING([whether $CXX supports -fno-strict-aliasing])
     ac_save_CXXFLAGS="$CXXFLAGS"
     CXXFLAGS="-fno-strict-aliasing"
     AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
-- 
GitLab