changeset 6453:a0a2b186ae28

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
author tbell
date Tue, 23 Oct 2012 10:10:23 -0700
parents 61ddb3fd000a
children 50b8b17449d2
files make/com/sun/java/pack/Makefile make/common/Defs-windows.gmk make/common/Demo.gmk make/common/Library.gmk make/common/Program.gmk make/common/Release.gmk make/common/shared/Defs-utils.gmk make/common/shared/Defs-windows.gmk make/common/shared/Platform.gmk make/common/shared/Sanity-Settings.gmk make/common/shared/Sanity.gmk make/jdk_generic_profile.sh make/tools/freetypecheck/Makefile make/tools/msys_build_scripts/dospath.sh make/tools/msys_build_scripts/dospath.vbs
diffstat 15 files changed, 263 insertions(+), 116 deletions(-) [+]
line wrap: on
line diff
--- a/make/com/sun/java/pack/Makefile	Thu Oct 11 16:59:50 2012 -0700
+++ b/make/com/sun/java/pack/Makefile	Tue Oct 23 10:10:23 2012 -0700
@@ -94,9 +94,9 @@
   LDOUTPUT = -Fe
 
   # JDK name required here
-  RC_FLAGS += /D "JDK_FNAME=$(PGRM).exe" \
-	/D "JDK_INTERNAL_NAME=$(PGRM)" \
-	/D "JDK_FTYPE=0x1L"
+  RC_FLAGS += -D "JDK_FNAME=$(PGRM).exe" \
+	-D "JDK_INTERNAL_NAME=$(PGRM)" \
+	-D "JDK_FTYPE=0x1L"
 
   RES = $(OBJDIR)/$(PGRM).res
 else
@@ -161,7 +161,7 @@
 	$(CP) mapfile-vers-unpack200 $(TEMPDIR)/mapfile-vers
 	$(LINKER)  $(LDDFLAGS) $(sort $(UNPACK_EXE_FILES_o)) $(RES) $(LIBCXX) $(LDOUTPUT)$(TEMPDIR)/unpack200$(EXE_SUFFIX)
 ifdef MT
-	$(MT) /manifest $(OBJDIR)/unpack200$(EXE_SUFFIX).manifest /outputresource:$(TEMPDIR)/unpack200$(EXE_SUFFIX);#1
+	$(MT) -manifest $(OBJDIR)/unpack200$(EXE_SUFFIX).manifest -outputresource:$(TEMPDIR)/unpack200$(EXE_SUFFIX);#1
 endif
 	$(CP) $(TEMPDIR)/unpack200$(EXE_SUFFIX) $(UNPACK_EXE)
 	@$(call binary_file_verification,$@)
--- a/make/common/Defs-windows.gmk	Thu Oct 11 16:59:50 2012 -0700
+++ b/make/common/Defs-windows.gmk	Tue Oct 23 10:10:23 2012 -0700
@@ -78,7 +78,7 @@
   MS_RUNTIME_LIBRARIES = $(MSVCRNN_DLL)
 endif
 
-EXTRA_LFLAGS += /LIBPATH:$(DXSDK_LIB_PATH)
+EXTRA_LFLAGS += -LIBPATH:$(DXSDK_LIB_PATH)
 
 # Full Debug Symbols has been enabled on Windows since JDK1.4.1.
 # The Full Debug Symbols (FDS) default for VARIANT == OPT builds is
@@ -198,7 +198,7 @@
 #   -MTd       Use static debug version (better than -MDd, no runtime issues)
 #   -D_DEBUG   Change use of malloc/free/etc to use special debug ones (-MTd)
 #
-#      NOTE: We also will use /D _STATIC_CPPLIB  so we don't need msvcpnn.dll
+#      NOTE: We also will use -D _STATIC_CPPLIB  so we don't need msvcpnn.dll
 #
 # If MS_RUNTIME_STATIC is requested we may have a problem, it is no longer
 #     supported by VS2010
@@ -223,12 +223,12 @@
 endif
 
 # Always add _STATIC_CPPLIB definition
-STATIC_CPPLIB_OPTION = /D _STATIC_CPPLIB
+STATIC_CPPLIB_OPTION = -D _STATIC_CPPLIB
 
 # Silence the warning about using _STATIC_CPPLIB
 ifneq ($(SHOW_ALL_WARNINGS),true)
   # Needed with VS2010 to turn off the deprecated warning.
-  STATIC_CPPLIB_OPTION += /D _DISABLE_DEPRECATE_STATIC_CPPLIB
+  STATIC_CPPLIB_OPTION += -D _DISABLE_DEPRECATE_STATIC_CPPLIB
 endif
 
 MS_RUNTIME_OPTION += $(STATIC_CPPLIB_OPTION)
@@ -242,7 +242,7 @@
   #   -Od      Turns off optimization and speeds compilation
   #   -YX -Fp/.../foobar.pch   Use precompiled headers (try someday?)
   #   -nologo  Don't print out startup message
-  #   /D _STATIC_CPPLIB
+  #  -D _STATIC_CPPLIB
   #            Use static link for the C++ runtime (so msvcpnn.dll not needed)
   #   
   ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
@@ -258,12 +258,12 @@
   CFLAGS_COMMON += $(MS_RUNTIME_OPTION) $(CFLAGS_$(COMPILER_VERSION))
 
   ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-    LDEBUG = /debug
+    LDEBUG = -debug
   endif
   
   ifeq ($(VTUNE_SUPPORT), true)
     OTHER_CFLAGS = -Z7 -Ox 
-    LDEBUG += /pdb:NONE
+    LDEBUG += -pdb:NONE
   endif
   
   # VS2010, always need safe exception handlers, not needed on 64bit
@@ -272,7 +272,7 @@
   endif
 
   # LFLAGS are the flags given to $(LINK) and used to build the actual DLL file
-  BASELFLAGS = -nologo /opt:REF /incremental:no
+  BASELFLAGS = -nologo -opt:REF -incremental:no
 
   LFLAGS = $(BASELFLAGS) $(LDEBUG) $(EXTRA_LFLAGS) $(LFLAGS_$(COMPILER_VERSION))
   LDDFLAGS += $(LFLAGS_$(COMPILER_VERSION))
@@ -404,7 +404,7 @@
   JDK_UPDATE_VER := 0
 endif
 
-RC_FLAGS = /l 0x409 /r
+RC_FLAGS = -l 0x409 -r
 
 ifeq ($(VARIANT), OPT)
   RC_FLAGS += -d NDEBUG 
--- a/make/common/Demo.gmk	Thu Oct 11 16:59:50 2012 -0700
+++ b/make/common/Demo.gmk	Tue Oct 23 10:10:23 2012 -0700
@@ -292,9 +292,9 @@
 
 ifeq ($(PLATFORM),windows)
 # JDK name required here
-RC_FLAGS += /D "JDK_FNAME=$(LIBRARY).dll" \
-            /D "JDK_INTERNAL_NAME=$(LIBRARY)" \
-            /D "JDK_FTYPE=0x2L"
+RC_FLAGS += -D "JDK_FNAME=$(LIBRARY).dll" \
+            -D "JDK_INTERNAL_NAME=$(LIBRARY)" \
+            -D "JDK_FTYPE=0x2L"
 endif
 
 # Native library building
--- a/make/common/Library.gmk	Thu Oct 11 16:59:50 2012 -0700
+++ b/make/common/Library.gmk	Tue Oct 23 10:10:23 2012 -0700
@@ -206,9 +206,9 @@
 	@$(ECHO) Created $@ 
 
 # JDK name required here
-RC_FLAGS += /D "JDK_FNAME=$(LIBRARY).dll" \
-            /D "JDK_INTERNAL_NAME=$(LIBRARY)" \
-            /D "JDK_FTYPE=0x2L"
+RC_FLAGS += -D "JDK_FNAME=$(LIBRARY).dll" \
+            -D "JDK_INTERNAL_NAME=$(LIBRARY)" \
+            -D "JDK_FTYPE=0x2L"
 
 $(OBJDIR)/$(LIBRARY).res: $(VERSIONINFO_RESOURCE)
 ifndef LOCAL_RESOURCE_FILE
--- a/make/common/Program.gmk	Thu Oct 11 16:59:50 2012 -0700
+++ b/make/common/Program.gmk	Tue Oct 23 10:10:23 2012 -0700
@@ -157,9 +157,9 @@
 #
 ifeq ($(PLATFORM), windows)
   # JDK name required here
-  RC_FLAGS += /D "JDK_FNAME=$(PROGRAM)$(EXE_SUFFIX)" \
-              /D "JDK_INTERNAL_NAME=$(PROGRAM)" \
-              /D "JDK_FTYPE=0x1L"
+  RC_FLAGS += -D "JDK_FNAME=$(PROGRAM)$(EXE_SUFFIX)" \
+              -D "JDK_INTERNAL_NAME=$(PROGRAM)" \
+              -D "JDK_FTYPE=0x1L"
 
   $(OBJDIR)/$(PROGRAM).res: $(VERSIONINFO_RESOURCE)
 	@$(prep-target)
@@ -201,11 +201,11 @@
 	@$(prep-target)
 	@set -- $?; \
 	    $(ECHO) Rebuilding $@ because of $$1 $$2 $$3 $$4 $$5 $$6 $${7:+...};
-	$(LINK) -out:$@ /STACK:$(STACK_SIZE) \
+	$(LINK) -out:$@ -STACK:$(STACK_SIZE) \
 	    $(MAP_OPTION) $(LFLAGS) $(LDFLAGS) \
 	    @$(OBJDIR)/$(PROGRAM).lcf $(LDLIBS)
   ifdef MT
-	$(MT) /manifest $(OBJDIR)/$(PROGRAM).exe.manifest /outputresource:$@;#1
+	$(MT) -manifest $(OBJDIR)/$(PROGRAM).exe.manifest /outputresource:$@;#1
   endif
 	@$(call binary_file_verification,$@)
   ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
--- a/make/common/Release.gmk	Thu Oct 11 16:59:50 2012 -0700
+++ b/make/common/Release.gmk	Tue Oct 23 10:10:23 2012 -0700
@@ -784,11 +784,22 @@
 		    $(RT_JAR) $(RESOURCES_JAR) $(JSSE_JAR) $(JFR_JAR) \
 		    $(BUILDMETAINDEX_JARFILE)
 	@# Copy in bin directory
+ifeq ($(USING_MSYS),true)
+        # No cpio in MinGW/MSYS
+	$(CD) $(OUTPUTDIR) && $(TAR) -cf - bin | ($(CD) $(JRE_IMAGE_DIR) && $(TAR) -xpf -)
+else
 	$(CD) $(OUTPUTDIR) && $(FIND) bin -depth | $(CPIO) -pdum $(JRE_IMAGE_DIR)
+endif
 	@# CTE plugin security change require new empty directory lib/applet
 	$(MKDIR) -p $(JRE_IMAGE_DIR)/lib/applet
 	@# Copy in lib directory
+ifeq ($(USING_MSYS),true)
+        # No cpio in MinGW/MSYS
+	$(CD) $(OUTPUTDIR) && $(TAR) -cf - lib | ($(CD) $(JRE_IMAGE_DIR) && $(TAR) -xpf -)
+else
 	$(CD) $(OUTPUTDIR) && $(FIND) lib -depth | $(CPIO) -pdum $(JRE_IMAGE_DIR)
+endif
+
   ifeq ($(USING_CYGWIN),true)
 	  $(RM) -rf $(JRE_IMAGE_DIR)/[A-Za-z]:
 	  $(RM) -rf $(OUTPUTDIR)/[A-Za-z]:
@@ -919,11 +930,17 @@
 # only places from which we copy everything), but because the presence
 # of this file causes cygwin's find to bomb out, thus breaking the build
 # in "install".
+
 initial-image-jdk-setup:
 	$(RM) -r $(JDK_IMAGE_DIR)
 	$(MKDIR) -p $(JDK_IMAGE_DIR)/jre
+ifeq ($(USING_MSYS),true)
+	($(CD) $(JRE_IMAGE_DIR) && $(TAR) -cf - . \
+	      | ($(CD) $(JDK_IMAGE_DIR)/jre && $(TAR) -xpf -))
+else
 	($(CD) $(JRE_IMAGE_DIR) && $(FIND) . -depth -print \
 	      | $(CPIO) -pdum $(JDK_IMAGE_DIR)/jre )
+endif
   ifeq ($(USING_CYGWIN),true)
 	  $(RM) -rf $(JRE_IMAGE_DIR)/[A-Za-z]:
 	  $(RM) -rf $(JDK_IMAGE_DIR)/jre/[A-Za-z]:
--- a/make/common/shared/Defs-utils.gmk	Thu Oct 11 16:59:50 2012 -0700
+++ b/make/common/shared/Defs-utils.gmk	Tue Oct 23 10:10:23 2012 -0700
@@ -169,15 +169,19 @@
 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
+    NAWK     = $(UNIXCOMMAND_PATH)awk -v BINMODE=w
   else
     ZIPEXE = $(UTILS_DEVTOOL_PATH)zip
     UNZIP  = $(UTILS_DEVTOOL_PATH)unzip
     NAWK   = $(UNIXCOMMAND_PATH)awk
+    ifdef USING_MSYS
+      ECHO   = $(UTILS_COMMAND_PATH)echo -e
+      AR     = $(UTILS_DEVTOOL_PATH)ar
+    endif
   endif
   # Re-define some utilities
   LEX            =# override GNU Make intrinsic: no lex on windows
--- a/make/common/shared/Defs-windows.gmk	Thu Oct 11 16:59:50 2012 -0700
+++ b/make/common/shared/Defs-windows.gmk	Tue Oct 23 10:10:23 2012 -0700
@@ -112,6 +112,15 @@
 $(shell if [ "$1" != "" -a -d "$1" ]; then $(CYGPATH_CMD) "$1" 2> $(DEV_NULL); 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)
@@ -120,6 +129,7 @@
 $(shell if [ "$1" != "" -a -d "$1" ]; then (cd $1 && pwd); else echo "$1"; fi)
 endef
 endif
+endif
 
 # System drive
 ifdef SYSTEMDRIVE
@@ -146,43 +156,47 @@
   ifdef USING_CYGWIN
     UNIXCOMMAND_PATH :=$(call PrefixPath,/usr/bin)
   else
-    ifdef ROOTDIR
-      xROOTDIR :="$(subst \,/,$(ROOTDIR))"
-      _rootdir :=$(call FullPath,$(xROOTDIR))
+    ifdef USING_MSYS
+      UNIXCOMMAND_PATH :=$(call PrefixPath,/bin)
     else
-      xROOTDIR :="$(_system_drive)/mksnt"
-      _rootdir :=$(call FullPath,$(xROOTDIR))
-    endif
-    ifneq ($(_rootdir),)
-      UNIXCOMMAND_PATH :=$(call PrefixPath,$(_rootdir)/mksnt)
-    endif
-  endif
+      ifdef ROOTDIR
+        xROOTDIR :="$(subst \,/,$(ROOTDIR))"
+        _rootdir :=$(call FullPath,$(xROOTDIR))
+      else
+        xROOTDIR :="$(_system_drive)/mksnt"
+        _rootdir :=$(call FullPath,$(xROOTDIR))
+      endif
+      ifneq ($(_rootdir),)
+        UNIXCOMMAND_PATH :=$(call PrefixPath,$(_rootdir)/mksnt)
+      endif
+    endif # USING_MSYS
+  endif # USING_CYGWIN
 endif
 UNIXCOMMAND_PATH:=$(call AltCheckSpaces,UNIXCOMMAND_PATH)
 
 # Get version of MKS or CYGWIN
-ifndef USING_CYGWIN
-_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
+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
+  # 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
@@ -440,10 +454,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)
 
@@ -636,7 +654,7 @@
 
 # Special define for checking the binaries
 
-# All windows dll and exe files should have been built with /NXCOMPAT
+# All windows dll and exe files should have been built with -NXCOMPAT
 #   and be setup for dynamic base addresses.
 #   In addition, we should not be dependent on certain dll files that
 #   we do not or cannot redistribute.
@@ -648,37 +666,37 @@
   BANNED_DLLS=msvcp100[.]dll|msvcr100d[.]dll|msvcrtd[.]dll
 endif
 
-# Check for /safeseh (only used on 32bit)
+# Check for -safeseh (only used on 32bit)
 define binary_file_safeseh_verification # binary_file
 ( \
-  $(ECHO) "Checking for /SAFESEH usage in: $1" && \
-  if [ "`$(DUMPBIN) /loadconfig $1 | $(EGREP) -i 'Safe Exception Handler Table'`" = "" ] ; then \
+  $(ECHO) "Checking for -SAFESEH usage in: $1" && \
+  if [ "`$(DUMPBIN) -loadconfig $1 | $(EGREP) -i 'Safe Exception Handler Table'`" = "" ] ; then \
     $(ECHO) "ERROR: Did not find 'Safe Exception Handler Table' in loadconfig: $1" ; \
-    $(DUMPBIN) /loadconfig $1 ; \
+    $(DUMPBIN) -loadconfig $1 ; \
     exit 6 ; \
   fi ; \
 )
 endef
 
-# Check for /NXCOMPAT usage
+# Check for -NXCOMPAT usage
 define binary_file_nxcompat_verification # binary_file
 ( \
-  $(ECHO) "Checking for /NXCOMPAT usage in: $1" && \
-  if [ "`$(DUMPBIN) /headers $1 | $(EGREP) -i 'NX compatible'`" = "" ] ; then \
+  $(ECHO) "Checking for -NXCOMPAT usage in: $1" && \
+  if [ "`$(DUMPBIN) -headers $1 | $(EGREP) -i 'NX compatible'`" = "" ] ; then \
     $(ECHO) "ERROR: Did not find 'NX compatible' in headers: $1" ; \
-    $(DUMPBIN) /headers $1 ; \
+    $(DUMPBIN) -headers $1 ; \
     exit 7 ; \
   fi ; \
 )
 endef
 
-# Check for /DYNAMICBASE usage
+# Check for -DYNAMICBASE usage
 define binary_file_dynamicbase_verification # binary_file
 ( \
-  $(ECHO) "Checking for /DYNAMICBASE usage in: $1" && \
-  if [ "`$(DUMPBIN) /headers $1 | $(EGREP) -i 'Dynamic base'`" = "" ] ; then \
+  $(ECHO) "Checking for -DYNAMICBASE usage in: $1" && \
+  if [ "`$(DUMPBIN) -headers $1 | $(EGREP) -i 'Dynamic base'`" = "" ] ; then \
     $(ECHO) "ERROR: Did not find 'Dynamic base' in headers: $1" ; \
-    $(DUMPBIN) /headers $1 ; \
+    $(DUMPBIN) -headers $1 ; \
     exit 8 ; \
   fi ; \
 )
@@ -688,9 +706,9 @@
 define binary_file_dll_verification # binary_file
 ( \
   $(ECHO) "Checking for banned dependencies in: $1" && \
-  if [ "`$(DUMPBIN) /dependents $1 | $(EGREP) -i '$(BANNED_DLLS)'`" != "" ] ; then \
+  if [ "`$(DUMPBIN) -dependents $1 | $(EGREP) -i '$(BANNED_DLLS)'`" != "" ] ; then \
     $(ECHO) "ERROR: Found use of $(BANNED_DLLS)"; \
-    $(DUMPBIN) /dependents $1 ; \
+    $(DUMPBIN) -dependents $1 ; \
     exit 9 ; \
   fi ; \
 )
--- a/make/common/shared/Platform.gmk	Thu Oct 11 16:59:50 2012 -0700
+++ b/make/common/shared/Platform.gmk	Tue Oct 23 10:10:23 2012 -0700
@@ -70,6 +70,8 @@
 #     LIBARCH32                   solaris only: sparc or i386
 #     LIBARCH64                   solaris only: sparcv9 or amd64
 #     USING_CYGWIN                windows only: true or false
+#     USING_MSYS                  windows only: true or false
+#     USING_MKS                   windows only: true or false
 #     ISHIELD_TEMP_MIN            windows only: minimum disk space in temp area
 
 # Only run uname once in this make session.
@@ -306,6 +308,8 @@
 # Windows with and without CYGWIN will be slightly different
 ifeq ($(SYSTEM_UNAME), Windows_NT)
   PLATFORM = windows
+  USING_MKS = true
+  export USING_MKS
 endif
 ifneq (,$(findstring CYGWIN,$(SYSTEM_UNAME)))
   PLATFORM = windows
@@ -318,6 +322,11 @@
     export CYGWIN_HOME
   endif
 endif
+ifneq (,$(findstring MINGW,$(SYSTEM_UNAME)))
+  PLATFORM = windows
+  USING_MSYS = true
+  export USING_MSYS
+endif
 
 # Platform settings specific to Windows
 ifeq ($(PLATFORM), windows)
@@ -395,11 +404,12 @@
   endif
   ARCH_FAMILY = $(ARCH)
   # Where is unwanted output to be delivered?
-  # MKS uses the special file "NUL", cygwin uses the customary unix file.
-  ifeq ($(USING_CYGWIN),true)
+  # MKS uses the special file "NUL"; Cygwin and MinGW/MSYS use the
+  # customary unix file.
+  ifeq ($(USING_MKS),true)
+    DEV_NULL = NUL
+  else
     DEV_NULL = /dev/null
-  else
-    DEV_NULL = NUL
   endif
   export DEV_NULL
   # Classpath separator
@@ -440,28 +450,11 @@
       _MB_OF_MEMORY := \
 	   $(shell free -m | grep Mem: | awk '{print $$2;}' )
     else
-      # Windows 2000 has the mem utility, but two memory areas
-      #    extended memory is what is beyond 1024M
-      _B_OF_EXT_MEMORY := \
-	   $(shell mem 2> $(DEV_NULL) | \
-		   grep 'total contiguous extended memory' | awk '{print $$1;}')
-      ifeq ($(_B_OF_EXT_MEMORY),)
-          _B_OF_MEMORY := \
-	   $(shell mem 2> $(DEV_NULL) | \
-		   grep 'total conventional memory' | awk '{print $$1;}')
-      else
-        _B_OF_MEMORY := \
-           $(shell expr 1048576 '+' $(_B_OF_EXT_MEMORY) 2> $(DEV_NULL))
-      endif
-      ifeq ($(_B_OF_MEMORY),)
-        # Windows 2003 has the systeminfo utility use it if mem doesn't work
-        _MB_OF_MEMORY := \
-	    $(shell systeminfo 2> $(DEV_NULL) | \
-		    grep 'Total Physical Memory:' | \
-		    awk '{print $$4;}' | sed -e 's@,@@')
-      else
-        _MB_OF_MEMORY := $(shell expr $(_B_OF_MEMORY) '/' 1024 2> $(DEV_NULL))
-      endif
+      # Windows XP and higher has the systeminfo utility
+      _MB_OF_MEMORY := \
+            $(shell systeminfo 2> $(DEV_NULL) | \
+                    grep 'Total Physical Memory:' | \
+                    awk '{print $$4;}' | sed -e 's@,@@')
     endif
     ifeq ($(shell expr $(_MB_OF_MEMORY) '+' 0 2> $(DEV_NULL)), $(_MB_OF_MEMORY))
       MB_OF_MEMORY := $(_MB_OF_MEMORY)
--- a/make/common/shared/Sanity-Settings.gmk	Thu Oct 11 16:59:50 2012 -0700
+++ b/make/common/shared/Sanity-Settings.gmk	Tue Oct 23 10:10:23 2012 -0700
@@ -182,8 +182,13 @@
     ALL_SETTINGS+=$(call addRequiredVersionSetting,CYGWIN_VER)
     ALL_SETTINGS+=$(call addRequiredSetting,CYGPATH_CMD)
   else
-    ALL_SETTINGS+=$(call addRequiredVersionSetting,MKS_VER)
-    ALL_SETTINGS+=$(call addOptionalSetting,DOSNAME_CMD)
+    ifdef USING_MSYS
+      ALL_SETTINGS+=$(call addRequiredSetting,USING_MSYS)
+      ALL_SETTINGS+=$(call addRequiredSetting,DOSPATH_CMD)
+    else
+      ALL_SETTINGS+=$(call addRequiredVersionSetting,MKS_VER)
+      ALL_SETTINGS+=$(call addOptionalSetting,DOSNAME_CMD)
+    endif
   endif
 endif
 ifeq ($(PLATFORM),linux)
--- a/make/common/shared/Sanity.gmk	Thu Oct 11 16:59:50 2012 -0700
+++ b/make/common/shared/Sanity.gmk	Tue Oct 23 10:10:23 2012 -0700
@@ -395,7 +395,7 @@
 ifeq ($(PLATFORM), windows)
     MKS_CHECK :=$(call CheckVersions,$(MKS_VER),$(REQUIRED_MKS_VER))
 sane-mks:
-  ifndef USING_CYGWIN
+  ifdef USING_MKS
     ifeq ($(MKS_CHECK),missing)
 	@$(call OfficialErrorMessage,MKS version,$(MKS_VER),$(REQUIRED_MKS_VER))
     endif
@@ -905,14 +905,25 @@
 	    "" >> $(ERROR_FILE) ; \
 	fi
 ifeq ($(PLATFORM), windows)
-	@for utility in cpio ar file m4 ; do \
+ifeq ($(USING_MSYS), true)
+	@for utility in $(AR) $(FILE) $(M4) ; do \
 	  if [ ! -r "`$(WHICH) $${utility}`" ]; then \
 	    $(ECHO) "WARNING: You do not have the utility $${utility} in the \n" \
 	      "      directory $(UNIXCOMMAND_PATH). \n" \
-	      "      The utilities cpio, ar, file, and m4 are required. \n" \
+	      "      The utilities ar, file and m4 are required. \n" \
 	      "" >> $(WARNING_FILE) ; \
 	  fi; \
 	done
+else
+	@for utility in $(AR) $(CPIO) $(FILE) $(M4) ; do \
+	  if [ ! -r "`$(WHICH) $${utility}`" ]; then \
+	    $(ECHO) "WARNING: You do not have the utility $${utility} in the \n" \
+	      "      directory $(UNIXCOMMAND_PATH). \n" \
+	      "      The utilities ar, cpio, file and m4 are required. \n" \
+	      "" >> $(WARNING_FILE) ; \
+	  fi; \
+	done
+endif
 endif
 
 ######################################################
@@ -999,7 +1010,8 @@
 	    "      This is normally obtained from the WINDOWSSDKDIR." \
 	    "" >> $(ERROR_FILE)
   endif
-  ifeq ($(wildcard $(DUMPBIN)),)
+  # MinGW/MSYS make 3.81 will not tolerate a path with a quoted substring
+  ifeq ($(wildcard $(subst ",,$(DUMPBIN))),)
 	@$(ECHO) "ERROR: Cannot find the DUMPBIN utility from path: $(DUMPBIN)\n" \
 	    "      This is normally obtained from the COMPILER_PATH." \
 	    "" >> $(ERROR_FILE)
--- a/make/jdk_generic_profile.sh	Thu Oct 11 16:59:50 2012 -0700
+++ b/make/jdk_generic_profile.sh	Tue Oct 23 10:10:23 2012 -0700
@@ -176,17 +176,38 @@
   else
     windows_arch=i586
   fi
+
+  repo=`hg root | sed -e 's@\\\\@/@g'`
   # We need to check if we are running a CYGWIN shell
-  if [ "$(uname -a | fgrep Cygwin)" != "" -a -f /bin/cygpath ] ; then
+  if [ "$(echo ${osname} | fgrep Cygwin)" != "" -a -f /bin/cygpath ] ; then
     # For CYGWIN, uname will have "Cygwin" in it, and /bin/cygpath should exist
     # Utility to convert to short pathnames without spaces
     cygpath="/usr/bin/cygpath -a -m -s"
+    cygpathp="/usr/bin/cygpath -p"
     # Most unix utilities are in the /usr/bin
     unixcommand_path="/usr/bin"
     # Make the prompt tell you CYGWIN
     export PS1="CYGWIN:${COMPUTERNAME}:${USERNAME}[\!] "
+  elif [ "$(echo ${osname} | fgrep MINGW)" != "" ] ; then
+    # Utility to convert to short pathnames without spaces
+    cygpath="${repo}/make/tools/msys_build_scripts/dospath.sh"
+    if [ ! -f ${cygpath} ] ; then
+        echo "ERROR: Cannot find cygpath or equivalent on this machine"
+        exit 1
+    fi
+    # Utility to fix a path to MinGW/MSYS format - the equivalent of 'cygpath -p'
+    for tfile in "${repo}/make/scripts/fixpath.pl" "${repo}/../make/scripts/fixpath.pl"; do
+        if [ -f ${tfile} ] ; then
+            cygpathp="/bin/perl ${tfile} -m"
+        fi
+    done;
+    if [ -z "${cygpathp}" ] ; then
+        echo "ERROR: Cannot find make/scripts/fixpath.pl on this machine"
+        exit 1
+    fi
+    unixcommand_path="/usr/bin"
   else
-    echo "ERROR: Cannot find CYGWIN on this machine"
+    echo "ERROR: Cannot find CYGWIN or MinGW/MSYS on this machine"
     exit 1
   fi
   if [ "${ALT_UNIXCOMMAND_PATH}" != "" ] ; then
@@ -204,17 +225,18 @@
   else
     sys_root=$(${cygpath} "C:/WINNT")
   fi
-  path4sdk="${unixcommand_path};${sys_root}/system32;${sys_root};${sys_root}/System32/Wbem"
   if [ ! -d "${sys_root}" ] ; then
     echo "WARNING: No system root found at: ${sys_root}"
   fi
 
+  # Build a : separated path making sure each segment is acceptable to ${osname}
+  path4sdk="${unixcommand_path}:"`${cygpathp} "${sys_root}/system32;${sys_root};${sys_root}/System32/Wbem"`
+
   # Compiler setup (nasty part)
   #   NOTE: You can use vcvars32.bat to set PATH, LIB, and INCLUDE.
   #   NOTE: CYGWIN has a link.exe too, make sure the compilers are first
 
   # Use supplied vsvars.sh
-  repo=`hg root`
   if [ -f "${repo}/make/scripts/vsvars.sh" ] ; then
     eval `sh ${repo}/make/scripts/vsvars.sh -v10`
   elif [ -f "${repo}/../make/scripts/vsvars.sh" ] ; then
--- a/make/tools/freetypecheck/Makefile	Thu Oct 11 16:59:50 2012 -0700
+++ b/make/tools/freetypecheck/Makefile	Tue Oct 23 10:10:23 2012 -0700
@@ -37,11 +37,11 @@
 
 # Start with CFLAGS (which gets us the required -xarch setting on solaris)
 ifeq ($(PLATFORM), windows)
-  FT_OPTIONS  = /nologo /c
+  FT_OPTIONS  = -nologo -c
   FREETYPE_DLL = $(FREETYPE_LIB_PATH)/freetype.dll
   FT_LD_OPTIONS  = $(FREETYPE_LIB_PATH)/freetype.lib
   ifdef MT
-    FT_LD_OPTIONS += /manifest
+    FT_LD_OPTIONS += -manifest
   endif
 else
   FT_OPTIONS  = $(CFLAGS)
@@ -72,11 +72,11 @@
 	$(prep-target)
 ifeq ($(PLATFORM), windows)
 	$(CC) $(FT_OPTIONS) $(CC_OBJECT_OUTPUT_FLAG)$(FT_OBJ) $<
-	$(LINK) $(FT_LD_OPTIONS) /OUT:$(FT_TEST) $(FT_OBJ)
+	$(LINK) $(FT_LD_OPTIONS) -OUT:$(FT_TEST) $(FT_OBJ)
 	$(CP) $(FREETYPE_DLL) $(@D)/
   ifdef MT
 	$(CP) $(MSVCRNN_DLL_PATH)/$(MSVCRNN_DLL) $(@D)/
-	$(MT) /manifest $(FT_TEST).manifest /outputresource:$(FT_TEST);#1
+	$(MT) -manifest $(FT_TEST).manifest -outputresource:$(FT_TEST);#1
   endif
 else
 	@$(CC) $(FT_OPTIONS) -o $@ $< $(FT_LD_OPTIONS)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/make/tools/msys_build_scripts/dospath.sh	Tue Oct 23 10:10:23 2012 -0700
@@ -0,0 +1,42 @@
+#
+# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+# A shell script which converts its first argument, which must be an existing 
+# path name, into a DOS (aka 8.3) path name. If the path is a file, only the 
+# directory part of the whole path will be converted.
+# This shell script executes the Visual Basic helper script 'dospath.vbs'
+# which must be located in the same directory as this script itself.
+# The Visual Basic script will be invoked trough the "Windows Script Host"
+# which is available by default on Windows since Windows 98.
+
+pushd `dirname "$0"` > /dev/null
+ABS_PATH=`pwd`
+popd > /dev/null
+if [ -d "$1" ]; then
+  echo `cd "$1" && cscript.exe -nologo $ABS_PATH/dospath.vbs`;
+elif [ -f "$1" ]; then
+  DIR=`dirname "$1"`;
+  echo `cd "$DIR" && cscript.exe -nologo $ABS_PATH/dospath.vbs`\\`basename "$1"`;
+fi
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/make/tools/msys_build_scripts/dospath.vbs	Tue Oct 23 10:10:23 2012 -0700
@@ -0,0 +1,34 @@
+'
+' Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+'
+' This code is free software; you can redistribute it and/or modify it
+' under the terms of the GNU General Public License version 2 only, as
+' published by the Free Software Foundation.  Oracle designates this
+' particular file as subject to the "Classpath" exception as provided
+' by Oracle in the LICENSE file that accompanied this code.
+'
+' This code is distributed in the hope that it will be useful, but WITHOUT
+' ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+' FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+' version 2 for more details (a copy is included in the LICENSE file that
+' accompanied this code).
+'
+' You should have received a copy of the GNU General Public License version
+' 2 along with this work; if not, write to the Free Software Foundation,
+' Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+'
+' Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+' or visit www.oracle.com if you need additional information or have any
+' questions.
+'
+
+'
+' Visual Basic Script which returns the DOS (aka 8.3) filename of the current
+' directory.
+' Only called from 'dospath.sh' during a Windows build under MinGW/MSYS.
+'
+
+Set fso=CreateObject("Scripting.FileSystemObject")
+Set path = fso.GetFolder(".")
+WScript.Echo path.ShortPath