7152336: Enable builds on Windows with MinGW/MSYS
authortbell
Tue, 23 Oct 2012 10:10:39 -0700
changeset 14095 ab1fb3836ddb
parent 14066 cdaa6122185f
child 14096 fbfe6a11980d
7152336: Enable builds on Windows with MinGW/MSYS Summary: Minimal makefile changes to enable building OpenJDK using MSYS on Windows7 Reviewed-by: ohair, tbell Contributed-by: volker.simonis@gmail.com
corba/make/common/shared/Defs-utils.gmk
corba/make/common/shared/Defs-windows.gmk
corba/make/common/shared/Platform.gmk
--- a/corba/make/common/shared/Defs-utils.gmk	Wed Jul 05 18:26:11 2017 +0200
+++ b/corba/make/common/shared/Defs-utils.gmk	Tue Oct 23 10:10:39 2012 -0700
@@ -151,16 +151,26 @@
 ifeq ($(PLATFORM),windows)
   ifdef USING_CYGWIN
     # Intrinsic unix command, with backslash-escaped character interpretation
-    ECHO = $(UNIXCOMMAND_PATH)echo -e
-    ZIPEXE = $(UNIXCOMMAND_PATH)zip
-    UNZIP  = $(UNIXCOMMAND_PATH)unzip
+    ECHO     = $(UNIXCOMMAND_PATH)echo -e
+    ZIPEXE   = $(UNIXCOMMAND_PATH)zip
+    UNZIP    = $(UNIXCOMMAND_PATH)unzip
+    # Some CYGWIN nawk versions require BINMODE=w for proper '\r' interpretation
+    NAWK     = $(UNIXCOMMAND_PATH)awk -v BINMODE=w
   else
-    ZIPEXE = $(UTILS_DEVTOOL_PATH)zip
-    UNZIP  = $(UTILS_DEVTOOL_PATH)unzip
+    ifdef USING_MSYS
+      ECHO   = $(UTILS_COMMAND_PATH)echo -e
+      ZIPEXE = $(UTILS_DEVTOOL_PATH)zip
+      UNZIP  = $(UTILS_DEVTOOL_PATH)unzip
+      NAWK   = $(UNIXCOMMAND_PATH)awk
+    else
+      ZIPEXE = $(UTILS_DEVTOOL_PATH)zip
+      UNZIP  = $(UTILS_DEVTOOL_PATH)unzip
+      NAWK   = $(UNIXCOMMAND_PATH)awk
+    endif
   endif
   # Re-define some utilities
   LEX            =# override GNU Make intrinsic: no lex on windows
-  NAWK           = $(UNIXCOMMAND_PATH)awk
+  SHA1SUM        = $(UNIXCOMMAND_PATH)openssl sha1
 endif
 
 # Linux specific
--- a/corba/make/common/shared/Defs-windows.gmk	Wed Jul 05 18:26:11 2017 +0200
+++ b/corba/make/common/shared/Defs-windows.gmk	Tue Oct 23 10:10:39 2012 -0700
@@ -91,6 +91,15 @@
 $(shell if [ "$1" != "" -a -d "$1" ]; then $(CYGPATH_CMD) "$1"; else echo "$1"; fi)
 endef
 else
+ifdef USING_MSYS
+DOSPATH_CMD:=$(shell cd $(JDK_TOPDIR) 2> $(DEV_NULL) && pwd)/make/tools/msys_build_scripts/dospath.sh
+define FullPath
+$(subst \,/,$(shell $(DOSPATH_CMD) $1))
+endef
+define OptFullPath
+$(shell if [ "$1" != "" -a -d "$1" ]; then (cd $1 && pwd); else echo "$1"; fi)
+endef
+else
 # Temporary until we upgrade to MKS 8.7, MKS pwd returns mixed mode path
 define FullPath
 $(shell cd $1 2> $(DEV_NULL) && pwd)
@@ -99,6 +108,7 @@
 $(shell if [ "$1" != "" -a -d "$1" ]; then (cd $1 && pwd); else echo "$1"; fi)
 endef
 endif
+endif
 
 # System drive
 ifdef SYSTEMDRIVE
@@ -112,14 +122,21 @@
 
 # UNIXCOMMAND_PATH: path to where the most common Unix commands are.
 #  NOTE: Must end with / so that it could be empty, allowing PATH usage.
-ifndef UNIXCOMMAND_PATH
-  ifdef ALT_UNIXCOMMAND_PATH
+#        With cygwin, use this as is; don't use FullPath on it.
+ifdef ALT_UNIXCOMMAND_PATH
+  ifdef USING_CYGWIN
+    UNIXCOMMAND_PATH       :=$(call PrefixPath,$(ALT_UNIXCOMMAND_PATH))
+  else
     xALT_UNIXCOMMAND_PATH  :="$(subst \,/,$(ALT_UNIXCOMMAND_PATH))"
     fxALT_UNIXCOMMAND_PATH :=$(call FullPath,$(xALT_UNIXCOMMAND_PATH))
     UNIXCOMMAND_PATH       :=$(call PrefixPath,$(fxALT_UNIXCOMMAND_PATH))
+  endif
+else
+  ifdef USING_CYGWIN
+    UNIXCOMMAND_PATH :=$(call PrefixPath,/usr/bin)
   else
-    ifdef USING_CYGWIN
-      UNIXCOMMAND_PATH :=$(call PrefixPath,/usr/bin)
+    ifdef USING_MSYS
+      UNIXCOMMAND_PATH :=$(call PrefixPath,/bin)
     else
       ifdef ROOTDIR
         xROOTDIR :="$(subst \,/,$(ROOTDIR))"
@@ -131,41 +148,35 @@
       ifneq ($(_rootdir),)
         UNIXCOMMAND_PATH :=$(call PrefixPath,$(_rootdir)/mksnt)
       endif
-    endif
-  endif
-  UNIXCOMMAND_PATH:=$(call AltCheckSpaces,UNIXCOMMAND_PATH)
-  export UNIXCOMMAND_PATH
+    endif # USING_MSYS
+  endif # USING_CYGWIN
 endif
+UNIXCOMMAND_PATH:=$(call AltCheckSpaces,UNIXCOMMAND_PATH)
+export UNIXCOMMAND_PATH
 
 # Get version of MKS or CYGWIN
-ifdef USING_CYGWIN
-  ifndef CYGWIN_VER
-    _CYGWIN_VER :=$(shell $(UNAME))
-    CYGWIN_VER  :=$(call GetVersion,$(_CYGWIN_VER))
-    export CYGWIN_VER
+ifdef USING_MKS
+  _MKS_VER :=$(shell $(MKSINFO) 2>&1 | $(GREP) Release | $(TAIL) -1 | $(SED) -e 's@.*\(Release.*\)@\1@')
+  MKS_VER  :=$(call GetVersion,$(_MKS_VER))
+  # At this point, we can re-define FullPath to use DOSNAME_CMD
+  CHECK_MKS87:=$(call CheckVersions,$(MKS_VER),8.7)
+  TRY_DOSNAME:=false
+  ifeq ($(CHECK_MKS87),same)
+    TRY_DOSNAME:=true
   endif
-else # MKS
-_MKS_VER :=$(shell $(MKSINFO) 2>&1 | $(GREP) Release | $(TAIL) -1 | $(SED) -e 's@.*\(Release.*\)@\1@')
-MKS_VER  :=$(call GetVersion,$(_MKS_VER))
-# At this point, we can re-define FullPath to use DOSNAME_CMD
-CHECK_MKS87:=$(call CheckVersions,$(MKS_VER),8.7)
-TRY_DOSNAME:=false
-ifeq ($(CHECK_MKS87),same)
-TRY_DOSNAME:=true
-endif
-# Newer should be ok
-ifeq ($(CHECK_MKS87),newer)
-TRY_DOSNAME:=true
-endif
-ifeq ($(TRY_DOSNAME),true)
-ifeq ($(shell $(UNIXCOMMAND_PATH)dosname -s $(_system_drive)/ 2> $(DEV_NULL)),$(_system_drive)/)
-_DOSNAME=$(UNIXCOMMAND_PATH)dosname
-DOSNAME_CMD:=$(_DOSNAME) -s
+  # Newer should be ok
+  ifeq ($(CHECK_MKS87),newer)
+    TRY_DOSNAME:=true
+  endif
+  ifeq ($(TRY_DOSNAME),true)
+    ifeq ($(shell $(UNIXCOMMAND_PATH)dosname -s $(_system_drive)/ 2> $(DEV_NULL)),$(_system_drive)/)
+      _DOSNAME=$(UNIXCOMMAND_PATH)dosname
+      DOSNAME_CMD:=$(_DOSNAME) -s
 define FullPath
 $(subst //,/,$(shell echo $1 | $(DOSNAME_CMD) 2> $(DEV_NULL)))
 endef
-endif # test dosname -s
-endif # TRY_DOSNAME
+    endif # test dosname -s
+  endif # TRY_DOSNAME
 endif # MKS
 
 # We try to get references to what we need via the default component
@@ -240,6 +251,8 @@
 # DEVTOOLS_PATH: for other tools required for building (such as zip, etc.)
 #  NOTE: Must end with / so that it could be empty, allowing PATH usage.
 ifndef DEVTOOLS_PATH
+  # DEVTOOLS_PATH: for other tools required for building (such as zip, etc.)
+  #  NOTE: Must end with / so that it could be empty, allowing PATH usage.
   ifdef ALT_DEVTOOLS_PATH
     xALT_DEVTOOLS_PATH  :="$(subst \,/,$(ALT_DEVTOOLS_PATH))"
     fxALT_DEVTOOLS_PATH :=$(call FullPath,$(xALT_DEVTOOLS_PATH))
@@ -248,10 +261,14 @@
     ifdef USING_CYGWIN
       DEVTOOLS_PATH :=$(UNIXCOMMAND_PATH)
     else
-      xDEVTOOLS_PATH  :="$(_system_drive)/utils"
-      fxDEVTOOLS_PATH :=$(call FullPath,$(xDEVTOOLS_PATH))
-      DEVTOOLS_PATH  :=$(call PrefixPath,$(fxDEVTOOLS_PATH))
-    endif
+      ifdef USING_MSYS
+        DEVTOOLS_PATH :=$(UNIXCOMMAND_PATH)
+      else
+        xDEVTOOLS_PATH  :="$(_system_drive)/utils"
+        fxDEVTOOLS_PATH :=$(call FullPath,$(xDEVTOOLS_PATH))
+        DEVTOOLS_PATH  :=$(call PrefixPath,$(fxDEVTOOLS_PATH))
+      endif # USING_MSYS
+    endif # USING_CYGWIN
   endif
   DEVTOOLS_PATH:=$(call AltCheckSpaces,DEVTOOLS_PATH)
   export DEVTOOLS_PATH
--- a/corba/make/common/shared/Platform.gmk	Wed Jul 05 18:26:11 2017 +0200
+++ b/corba/make/common/shared/Platform.gmk	Tue Oct 23 10:10:39 2012 -0700
@@ -65,6 +65,8 @@
 #     REQUIRED_WINDOWS_NAME       windows only: basic name of windows
 #     REQUIRED_WINDOWS_VERSION    windows only: specific version of windows
 #     USING_CYGWIN                windows only: true or false
+#     USING_MSYS                  windows only: true or false
+#     USING_MKS                   windows only: true or false
 #     WINDOWS_NT_VERSION_STRING   windows only: long version name
 #     REQUIRED_OS_VERSION         required OS version, e.g. 5.10, 2.4
 #     REQUIRED_FREE_SPACE         minimum disk space needed for outputdir
@@ -327,6 +329,8 @@
 # Windows with and without CYGWIN will be slightly different
 ifeq ($(SYSTEM_UNAME), Windows_NT)
   PLATFORM = windows
+  USING_MKS = true
+  export USING_MKS
   OS_VERSION := $(shell uname -r)
   WINDOWS_NT_VERSION_STRING=Windows_NT
   REQUIRED_MKS_VER=6.1
@@ -339,6 +343,11 @@
   WINDOWS_NT_VERSION_STRING=CYGWIN_NT
   REQUIRED_CYGWIN_VER=4.0
 endif
+ifneq (,$(findstring MINGW,$(SYSTEM_UNAME)))
+  PLATFORM = windows
+  USING_MSYS = true
+  export USING_MSYS
+endif
 
 # Platform settings specific to Windows
 ifeq ($(PLATFORM), windows)