1 #
   2 # Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
   3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4 #
   5 # This code is free software; you can redistribute it and/or modify it
   6 # under the terms of the GNU General Public License version 2 only, as
   7 # published by the Free Software Foundation.  Oracle designates this
   8 # particular file as subject to the "Classpath" exception as provided
   9 # by Oracle in the LICENSE file that accompanied this code.
  10 #
  11 # This code is distributed in the hope that it will be useful, but WITHOUT
  12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14 # version 2 for more details (a copy is included in the LICENSE file that
  15 # accompanied this code).
  16 #
  17 # You should have received a copy of the GNU General Public License version
  18 # 2 along with this work; if not, write to the Free Software Foundation,
  19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20 #
  21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22 # or visit www.oracle.com if you need additional information or have any
  23 # questions.
  24 #
  25 
  26 #
  27 # Definitions for Windows.
  28 #
  29 
  30 # Default for COMPILER_WARNINGS_FATAL on Windows (C++ compiler warnings)
  31 #    Level: Default is 3, 0 means none, 4 is the most but may be unreliable
  32 #    Some makefiles may have set this to 0 to turn off warnings completely,
  33 #    which also effectively creates a COMPILER_WARNINGS_FATAL=false situation.
  34 #    Windows 64bit platforms are less likely to be warning free.
  35 #    Historically, Windows 32bit builds should be mostly warning free.
  36 ifndef COMPILER_WARNING_LEVEL
  37   COMPILER_WARNING_LEVEL=3
  38 endif
  39 ifndef COMPILER_WARNINGS_FATAL
  40   COMPILER_WARNINGS_FATAL=false
  41 endif
  42 
  43 # Windows should use parallel compilation for best build times
  44 ifndef COMPILE_APPROACH
  45   COMPILE_APPROACH = normal
  46 endif
  47 
  48 # Indication that we are doing an incremental build.
  49 #    This may trigger the creation of make depend files.
  50 #    (This may not be working on windows yet, always force to false.)
  51 override INCREMENTAL_BUILD = false
  52 
  53 # WARNING: This is extremely touch stuff, between CYGWIN vs. MKS and all
  54 #          variations of MKS and CYGWIN releases, and 32bit vs 64bit,
  55 #          this file can give you nightmares.
  56 #
  57 # Notes:
  58 #   Keep all paths in the windows "mixed" style except CYGWIN UNXIXCOMMAND_PATH.
  59 #   Use of PrefixPath is critical, some variables must end with / (see NOTE).
  60 #   Use of quotes is critical due to possible spaces in paths coming from
  61 #     the environment variables, be careful.
  62 #   First convert \ to / with subst, keep it quoted due to blanks, then
  63 #     use cygpath -s or dosname -s to get the short non-blank name.
  64 #   If the MKS is old and doesn't have a dosname -s, you will be forced
  65 #     to set ALT variables with the short non-space directory names.
  66 #     If dosname doesn't appear to work, we won't use it.
  67 #     The dosname utility also wants to accept stdin if it is not supplied
  68 #     any path on the command line, this is really dangerous when using
  69 #     make variables that can easily become empty, so I use:
  70 #        echo $1 | dosname -s     instead of    dosname -s $1
  71 #     to prevent dosname from hanging up the make process when $1 is empty.
  72 #     The cygpath utility does not have this problem.
  73 #   The ALT values should never really have spaces or use \.
  74 #   Suspect these environment variables to have spaces and/or \ characters:
  75 #     SYSTEMROOT, SystemRoot, WINDIR, windir, PROGRAMFILES, ProgramFiles,
  76 #     VC71COMNTOOLS, 
  77 #     MSVCDIR, MSVCDir.
  78 #     So use $(subst \,/,) on them first adding quotes and placing them in
  79 #         their own variable assigned with :=, then use FullPath.
  80 #
  81 
  82 # Use FullPath to get C:/ style non-spaces path. Never ends with a /!
  83 ifdef USING_CYGWIN
  84 # We assume cygpath is available in the search path
  85 #    NOTE: Use of 'pwd' with CYGWIN will not get you a mixed style path!
  86 CYGPATH_CMD=cygpath -a -s -m
  87 define FullPath
  88 $(shell $(CYGPATH_CMD) $1 2> $(DEV_NULL))
  89 endef
  90 define OptFullPath
  91 $(shell if [ "$1" != "" -a -d "$1" ]; then $(CYGPATH_CMD) "$1"; else echo "$1"; fi)
  92 endef
  93 else
  94 # Temporary until we upgrade to MKS 8.7, MKS pwd returns mixed mode path
  95 define FullPath
  96 $(shell cd $1 2> $(DEV_NULL) && pwd)
  97 endef
  98 define OptFullPath
  99 $(shell if [ "$1" != "" -a -d "$1" ]; then (cd $1 && pwd); else echo "$1"; fi)
 100 endef
 101 endif
 102 
 103 # System drive
 104 ifdef SYSTEMDRIVE
 105   _system_drive =$(SYSTEMDRIVE)
 106 else
 107   ifdef SystemDrive
 108     _system_drive =$(SystemDrive)
 109   endif
 110 endif
 111 _system_drive:=$(call CheckValue,_system_drive,C:)
 112 
 113 # UNIXCOMMAND_PATH: path to where the most common Unix commands are.
 114 #  NOTE: Must end with / so that it could be empty, allowing PATH usage.
 115 ifndef UNIXCOMMAND_PATH
 116   ifdef ALT_UNIXCOMMAND_PATH
 117     xALT_UNIXCOMMAND_PATH  :="$(subst \,/,$(ALT_UNIXCOMMAND_PATH))"
 118     fxALT_UNIXCOMMAND_PATH :=$(call FullPath,$(xALT_UNIXCOMMAND_PATH))
 119     UNIXCOMMAND_PATH       :=$(call PrefixPath,$(fxALT_UNIXCOMMAND_PATH))
 120   else
 121     ifdef USING_CYGWIN
 122       UNIXCOMMAND_PATH :=$(call PrefixPath,/usr/bin)
 123     else
 124       ifdef ROOTDIR
 125         xROOTDIR :="$(subst \,/,$(ROOTDIR))"
 126         _rootdir :=$(call FullPath,$(xROOTDIR))
 127       else
 128         xROOTDIR :="$(_system_drive)/mksnt"
 129         _rootdir :=$(call FullPath,$(xROOTDIR))
 130       endif
 131       ifneq ($(_rootdir),)
 132         UNIXCOMMAND_PATH :=$(call PrefixPath,$(_rootdir)/mksnt)
 133       endif
 134     endif
 135   endif
 136   UNIXCOMMAND_PATH:=$(call AltCheckSpaces,UNIXCOMMAND_PATH)
 137   export UNIXCOMMAND_PATH
 138 endif
 139 
 140 # Get version of MKS or CYGWIN
 141 ifdef USING_CYGWIN
 142   ifndef CYGWIN_VER
 143     _CYGWIN_VER :=$(shell $(UNAME))
 144     CYGWIN_VER  :=$(call GetVersion,$(_CYGWIN_VER))
 145     export CYGWIN_VER
 146   endif
 147 else # MKS
 148 _MKS_VER :=$(shell $(MKSINFO) 2>&1 | $(GREP) Release | $(TAIL) -1 | $(SED) -e 's@.*\(Release.*\)@\1@')
 149 MKS_VER  :=$(call GetVersion,$(_MKS_VER))
 150 # At this point, we can re-define FullPath to use DOSNAME_CMD
 151 CHECK_MKS87:=$(call CheckVersions,$(MKS_VER),8.7)
 152 TRY_DOSNAME:=false
 153 ifeq ($(CHECK_MKS87),same)
 154 TRY_DOSNAME:=true
 155 endif
 156 # Newer should be ok
 157 ifeq ($(CHECK_MKS87),newer)
 158 TRY_DOSNAME:=true
 159 endif
 160 ifeq ($(TRY_DOSNAME),true)
 161 ifeq ($(shell $(UNIXCOMMAND_PATH)dosname -s $(_system_drive)/ 2> $(DEV_NULL)),$(_system_drive)/)
 162 _DOSNAME=$(UNIXCOMMAND_PATH)dosname
 163 DOSNAME_CMD:=$(_DOSNAME) -s
 164 define FullPath
 165 $(subst //,/,$(shell echo $1 | $(DOSNAME_CMD) 2> $(DEV_NULL)))
 166 endef
 167 endif # test dosname -s
 168 endif # TRY_DOSNAME
 169 endif # MKS
 170 
 171 # We try to get references to what we need via the default component
 172 #    environment variables, or what was used historically.
 173 
 174 # Process Windows values into FullPath values, these paths may have \ chars
 175 
 176 # Program Files directory
 177 ifndef SHORTPROGRAMFILES
 178   ifdef PROGRAMFILES
 179     xPROGRAMFILES      :="$(subst \,/,$(PROGRAMFILES))"
 180   else
 181     ifeq ($(ARCH_DATA_MODEL), 32)
 182       xPROGRAMFILES    :="$(_system_drive)/Program Files"
 183     else
 184       xPROGRAMFILES    :="$(_system_drive)/Program Files (x86)"
 185     endif
 186   endif
 187   ifeq ($(ARCH_DATA_MODEL), 32)
 188     SHORTPROGRAMFILES  :=$(call FullPath,$(xPROGRAMFILES))
 189   else
 190     ifdef PROGRAMW6432
 191       xPROGRAMW6432    :="$(subst \,/,$(PROGRAMW6432))"
 192     else
 193       xPROGRAMW6432    :="$(_system_drive)/Program Files"
 194     endif
 195     SHORTPROGRAMFILES  :=$(call FullPath,$(xPROGRAMW6432))
 196   endif
 197   ifneq ($(word 1,$(SHORTPROGRAMFILES)),$(SHORTPROGRAMFILES))
 198     SHORTPROGRAMFILES  :=
 199   endif
 200   export SHORTPROGRAMFILES
 201 endif
 202 
 203 # Location on system where jdk installs might be
 204 ifneq ($(SHORTPROGRAMFILES),)
 205   USRJDKINSTANCES_PATH =$(SHORTPROGRAMFILES)/Java
 206 else
 207   USRJDKINSTANCES_PATH =$(_system_drive)/
 208 endif
 209 
 210 # SLASH_JAVA: location of all network accessable files
 211 ifndef SLASH_JAVA
 212   ifdef ALT_SLASH_JAVA
 213     xALT_SLASH_JAVA :="$(subst \,/,$(ALT_SLASH_JAVA))"
 214     SLASH_JAVA      :=$(call FullPath,$(xALT_SLASH_JAVA))
 215   else
 216     ifdef ALT_JDK_JAVA_DRIVE
 217       SLASH_JAVA  =$(JDK_JAVA_DRIVE)
 218     else
 219       SLASH_JAVA  =J:
 220     endif
 221   endif
 222   SLASH_JAVA:=$(call AltCheckSpaces,SLASH_JAVA)
 223   SLASH_JAVA:=$(call AltCheckValue,SLASH_JAVA)
 224   export SLASH_JAVA
 225 endif
 226 
 227 # JDK_DEVTOOLS_DIR: common path for all the java devtools
 228 ifndef JDK_DEVTOOLS_DIR
 229   ifdef ALT_JDK_DEVTOOLS_DIR
 230     xALT_JDK_DEVTOOLS_DIR :="$(subst \,/,$(ALT_JDK_DEVTOOLS_DIR))"
 231     JDK_DEVTOOLS_DIR      :=$(call FullPath,$(xALT_JDK_DEVTOOLS_DIR))
 232   else
 233     JDK_DEVTOOLS_DIR =$(SLASH_JAVA)/devtools
 234   endif
 235   JDK_DEVTOOLS_DIR:=$(call AltCheckSpaces,JDK_DEVTOOLS_DIR)
 236   JDK_DEVTOOLS_DIR:=$(call AltCheckValue,JDK_DEVTOOLS_DIR)
 237   export JDK_DEVTOOLS_DIR
 238 endif
 239 
 240 # DEVTOOLS_PATH: for other tools required for building (such as zip, etc.)
 241 #  NOTE: Must end with / so that it could be empty, allowing PATH usage.
 242 ifndef DEVTOOLS_PATH
 243   ifdef ALT_DEVTOOLS_PATH
 244     xALT_DEVTOOLS_PATH  :="$(subst \,/,$(ALT_DEVTOOLS_PATH))"
 245     fxALT_DEVTOOLS_PATH :=$(call FullPath,$(xALT_DEVTOOLS_PATH))
 246     DEVTOOLS_PATH       :=$(call PrefixPath,$(fxALT_DEVTOOLS_PATH))
 247   else
 248     ifdef USING_CYGWIN
 249       DEVTOOLS_PATH :=$(UNIXCOMMAND_PATH)
 250     else
 251       xDEVTOOLS_PATH  :="$(_system_drive)/utils"
 252       fxDEVTOOLS_PATH :=$(call FullPath,$(xDEVTOOLS_PATH))
 253       DEVTOOLS_PATH  :=$(call PrefixPath,$(fxDEVTOOLS_PATH))
 254     endif
 255   endif
 256   DEVTOOLS_PATH:=$(call AltCheckSpaces,DEVTOOLS_PATH)
 257   export DEVTOOLS_PATH
 258 endif
 259 
 260 # _BOOTDIR1: First choice for a Bootstrap JDK, previous released JDK.
 261 # _BOOTDIR2: Second choice
 262 ifndef ALT_BOOTDIR
 263   _BOOTDIR1  =$(_system_drive)/jdk$(PREVIOUS_JDK_VERSION)
 264   _BOOTDIR2  =$(USRJDKINSTANCES_PATH)/jdk$(PREVIOUS_JDK_VERSION)
 265 endif
 266 
 267 # Import JDK images allow for partial builds, components not built are
 268 #    imported (or copied from) these import areas when needed.
 269 
 270 # BUILD_JDK_IMPORT_PATH: location of JDK install trees to import for
 271 #   multiple platforms, e.g. windows-i586, solaris-sparc, linux-586, etc.
 272 ifndef BUILD_JDK_IMPORT_PATH
 273   ifdef ALT_BUILD_JDK_IMPORT_PATH
 274     BUILD_JDK_IMPORT_PATH  :=$(call FullPath,$(ALT_BUILD_JDK_IMPORT_PATH))
 275   else
 276     BUILD_JDK_IMPORT_PATH   = $(PROMOTED_BUILD_BINARIES)
 277   endif
 278   BUILD_JDK_IMPORT_PATH:=$(call AltCheckSpaces,BUILD_JDK_IMPORT_PATH)
 279   BUILD_JDK_IMPORT_PATH:=$(call AltCheckValue,BUILD_JDK_IMPORT_PATH)
 280   export BUILD_JDK_IMPORT_PATH
 281 endif
 282 
 283 # JDK_IMPORT_PATH: location of previously built JDK (this version) to import
 284 ifndef JDK_IMPORT_PATH
 285   ifdef ALT_JDK_IMPORT_PATH
 286     JDK_IMPORT_PATH  :=$(call FullPath,$(ALT_JDK_IMPORT_PATH))
 287   else
 288     JDK_IMPORT_PATH   = $(BUILD_JDK_IMPORT_PATH)/$(PLATFORM)-$(ARCH)$(_JDK_IMPORT_VARIANT)
 289   endif
 290   JDK_IMPORT_PATH:=$(call AltCheckSpaces,JDK_IMPORT_PATH)
 291   JDK_IMPORT_PATH:=$(call AltCheckValue,JDK_IMPORT_PATH)
 292   export JDK_IMPORT_PATH
 293 endif
 294