Defs-windows.gmk 25.0 KB
Newer Older
D
duke 已提交
1
#
2
# Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
D
duke 已提交
3 4 5 6
# 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
7
# published by the Free Software Foundation.  Oracle designates this
D
duke 已提交
8
# particular file as subject to the "Classpath" exception as provided
9
# by Oracle in the LICENSE file that accompanied this code.
D
duke 已提交
10 11 12 13 14 15 16 17 18 19 20
#
# 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.
#
21 22 23
# 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.
D
duke 已提交
24 25 26 27 28 29 30 31 32 33 34 35 36
#

#
# Definitions for Windows.
#

# Default for COMPILER_WARNINGS_FATAL on Windows (C++ compiler warnings)
#    Level: Default is 3, 0 means none, 4 is the most but may be unreliable
#    Some makefiles may have set this to 0 to turn off warnings completely,
#    which also effectively creates a COMPILER_WARNINGS_FATAL=false situation.
#    Program.gmk may turn this down to 2 (building .exe's).
#    Windows 64bit platforms are less likely to be warning free.
#    Historically, Windows 32bit builds should be mostly warning free.
37 38
#    VS2010 introduced a large number of security warnings that are off by
#    default but will be turned back on with SHOW_ALL_WARNINGS=true.
D
duke 已提交
39 40 41 42 43 44
ifndef COMPILER_WARNING_LEVEL
  COMPILER_WARNING_LEVEL=3
endif
ifndef COMPILER_WARNINGS_FATAL
  COMPILER_WARNINGS_FATAL=false
endif
45 46 47
ifndef SHOW_ALL_WARNINGS
  SHOW_ALL_WARNINGS = false
endif
D
duke 已提交
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81

# Windows should use parallel compilation for best build times
ifndef COMPILE_APPROACH
  COMPILE_APPROACH = normal
endif

# Indication that we are doing an incremental build.
#    This may trigger the creation of make depend files.
#    (This may not be working on windows yet, always force to false.)
override INCREMENTAL_BUILD = false

# WARNING: This is extremely touch stuff, between CYGWIN vs. MKS and all
#          variations of MKS and CYGWIN releases, and 32bit vs 64bit,
#          this file can give you nightmares.
#
# Notes:
#   Keep all paths in the windows "mixed" style except CYGWIN UNXIXCOMMAND_PATH.
#   Use of PrefixPath is critical, some variables must end with / (see NOTE).
#   Use of quotes is critical due to possible spaces in paths coming from
#     the environment variables, be careful.
#   First convert \ to / with subst, keep it quoted due to blanks, then
#     use cygpath -s or dosname -s to get the short non-blank name.
#   If the MKS is old and doesn't have a dosname -s, you will be forced
#     to set ALT variables with the short non-space directory names.
#     If dosname doesn't appear to work, we won't use it.
#     The dosname utility also wants to accept stdin if it is not supplied
#     any path on the command line, this is really dangerous when using
#     make variables that can easily become empty, so I use:
#        echo $1 | dosname -s     instead of    dosname -s $1
#     to prevent dosname from hanging up the make process when $1 is empty.
#     The cygpath utility does not have this problem.
#   The ALT values should never really have spaces or use \.
#   Suspect these environment variables to have spaces and/or \ characters:
#     SYSTEMROOT, SystemRoot, WINDIR, windir, PROGRAMFILES, ProgramFiles,
82
#     MSTOOLS, Mstools, MSSDK, MSSdk, VCnnCOMNTOOLS, 
D
duke 已提交
83 84 85 86 87 88
#     MSVCDIR, MSVCDir.
#     So use $(subst \,/,) on them first adding quotes and placing them in
#         their own variable assigned with :=, then use FullPath.
#

ifdef USING_CYGWIN
89 90 91 92 93 94 95 96
# Macro to effectively do a toupper without an exec
define ToUpper
$(subst a,A,$(subst b,B,$(subst c,C,$(subst d,D,$(subst e,E,$(subst f,F,\
$(subst g,G,$(subst h,H,$(subst i,I,$(subst j,J,$(subst k,K,$(subst l,L,\
$(subst m,M,$(subst n,N,$(subst o,O,$(subst p,P,$(subst q,Q,$(subst r,R,\
$(subst s,S,$(subst t,T,$(subst u,U,$(subst v,V,$(subst w,W,$(subst x,X,\
$(subst y,Y,$(subst z,Z,$1))))))))))))))))))))))))))
endef
97 98 99
# All possible drive letters
drives=a b c d e f g h i j k l m n o p q r s t v u w x y z
# Convert /cygdrive/ paths to the mixed style without an exec of cygpath
100 101
#   Must be a path with no spaces. /cygdrive/letter is always lowercase
#   and letter:/ is always uppercase coming from cygpath.
102
define MixedPath
103
$(patsubst /%,$(CYGWIN_HOME)/%,$(sort $(filter-out /cygdrive/%,$(foreach drive,$(drives),$(patsubst /cygdrive/$(drive)/%,$(call ToUpper,$(drive)):/%,$1)))))
104 105
endef
# Use FullPath to get C:/ style non-spaces path. Never ends with a /!
D
duke 已提交
106 107 108
# We assume cygpath is available in the search path
#    NOTE: Use of 'pwd' with CYGWIN will not get you a mixed style path!
define FullPath
109
$(if $(word 2,$1),$(shell $(CYGPATH_CMD) $1 2> $(DEV_NULL)),$(call MixedPath,$(realpath $(subst ",,$1))))
D
duke 已提交
110 111
endef
define OptFullPath
112
$(shell if [ "$1" != "" -a -d "$1" ]; then $(CYGPATH_CMD) "$1" 2> $(DEV_NULL); else echo "$1"; fi)
D
duke 已提交
113 114
endef
else
115 116 117 118 119 120 121 122 123
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
D
duke 已提交
124 125 126 127 128 129 130 131
# Temporary until we upgrade to MKS 8.7, MKS pwd returns mixed mode path
define FullPath
$(shell cd $1 2> $(DEV_NULL) && pwd)
endef
define OptFullPath
$(shell if [ "$1" != "" -a -d "$1" ]; then (cd $1 && pwd); else echo "$1"; fi)
endef
endif
132
endif
D
duke 已提交
133 134 135 136 137 138 139 140 141 142 143 144 145

# System drive
ifdef SYSTEMDRIVE
  _system_drive =$(SYSTEMDRIVE)
else
  ifdef SystemDrive
    _system_drive =$(SystemDrive)
  endif
endif
_system_drive:=$(call CheckValue,_system_drive,C:)

# UNIXCOMMAND_PATH: path to where the most common Unix commands are.
#  NOTE: Must end with / so that it could be empty, allowing PATH usage.
146
#        With cygwin, just use this as is don't use FullPath on it.
D
duke 已提交
147
ifdef ALT_UNIXCOMMAND_PATH
148 149 150 151 152 153 154
  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
D
duke 已提交
155 156 157 158
else
  ifdef USING_CYGWIN
    UNIXCOMMAND_PATH :=$(call PrefixPath,/usr/bin)
  else
159 160
    ifdef USING_MSYS
      UNIXCOMMAND_PATH :=$(call PrefixPath,/bin)
D
duke 已提交
161
    else
162 163 164 165 166 167 168 169 170 171 172 173
      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
D
duke 已提交
174 175 176 177
endif
UNIXCOMMAND_PATH:=$(call AltCheckSpaces,UNIXCOMMAND_PATH)

# Get version of MKS or CYGWIN
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
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
D
duke 已提交
195 196 197
define FullPath
$(subst //,/,$(shell echo $1 | $(DOSNAME_CMD) 2> $(DEV_NULL)))
endef
198 199
    endif # test dosname -s
  endif # TRY_DOSNAME
D
duke 已提交
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240
endif # MKS

# We try to get references to what we need via the default component
#    environment variables, or what was used historically.

# Process Windows values into FullPath values, these paths may have \ chars

# System root
ifdef SYSTEMROOT
  xSYSTEMROOT  :="$(subst \,/,$(SYSTEMROOT))"
  _system_root :=$(call FullPath,$(xSYSTEMROOT))
else
  ifdef SystemRoot
     xSYSTEMROOT :="$(subst \,/,$(SystemRoot))"
    _system_root :=$(call FullPath,$(xSYSTEMROOT))
  else
    ifdef WINDIR
      xWINDIR      :="$(subst \,/,$(WINDIR))"
      _system_root :=$(call FullPath,$(xWINDIR))
    else
      ifdef windir
        xWINDIR      :="$(subst \,/,$(windir))"
        _system_root :=$(call FullPath,$(xWINDIR))
      endif
    endif
  endif
endif
_system_root:=$(call CheckValue,_system_root,$(_system_drive)/WINNT)

# Program Files directory
ifdef PROGRAMFILES
  xPROGRAMFILES      :="$(subst \,/,$(PROGRAMFILES))"
else
  ifeq ($(ARCH_DATA_MODEL), 32)
    xPROGRAMFILES    :="$(_system_drive)/Program Files"
  else
    xPROGRAMFILES    :="$(_system_drive)/Program Files (x86)"
  endif
endif
ifeq ($(ARCH_DATA_MODEL), 32)
  _program_files     :=$(call FullPath,$(xPROGRAMFILES))
241
  _program_files32   :=$(_program_files)
D
duke 已提交
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257
else
  ifdef PROGRAMW6432
    xPROGRAMW6432    :="$(subst \,/,$(PROGRAMW6432))"
  else
    xPROGRAMW6432    :="$(_system_drive)/Program Files"
  endif
  _program_files     :=$(call FullPath,$(xPROGRAMW6432))
  _program_files32   :=$(call FullPath,$(xPROGRAMFILES))
  ifneq ($(word 1,$(_program_files32)),$(_program_files32))
    _program_files32:=
  endif
endif
ifneq ($(word 1,$(_program_files)),$(_program_files))
  _program_files:=
endif

258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290
# Use of the Visual Studio compilers requires certain env variables be set:
#   PATH should include the path to cl.exe
#   INCLUDE should be defined
#   LIB     should be defined
#   LIBPATH should be defined
#   VS100COMNTOOLS should be defined
#   WINDOWSSDKDIR should be defined
#     The 7.0a path is from VS2010 Pro, the 7.1 path is the standalone SDK.
#     For 64bit either will work for us.
#     If a developer chooses to install the standalone SDK in some other
#     location, then they need to set WINDOWSSDKDIR.
#
# Compilers for 64bit may be from the free SDK, or Visual Studio Professional.
#   The free Express compilers don't contain 64 bit compilers, which is why
#   you instead need the SDK.
#   Release enginering will use VS2010 Pro, so the frequency of testing of
#     SDK based builds will depend entirely on individual usage.

# We only need to do this once
ifndef VS2010_EXISTS
  # The 2 key paths we need are WINDOWSSDKDIR and VS100COMNTOOLS.
  #   If not defined try to see if default location exists.
  #   If defined make sure that the path has no spaces.
  #   Finally, export path with no spaces so logic minimizes FullPath calls.
  ifndef WINDOWSSDKDIR
    # The 7.0a SDK is the second choice.
    xWINDOWSSDKDIR :="$(_program_files32)/Microsoft SDKs/Windows/v7.0a/"
    fWINDOWSSDKDIR :=$(call FullPath,$(xWINDOWSSDKDIR))
    # The 7.1 SDK is the second choice.
    ifeq ($(fWINDOWSSDKDIR),)
      xWINDOWSSDKDIR :="$(_program_files32)/Microsoft SDKs/Windows/v7.1/"
      fWINDOWSSDKDIR :=$(call FullPath,$(xWINDOWSSDKDIR))
    endif
D
duke 已提交
291
  else
292 293 294 295 296
    ifneq ($(word 2,$(WINDOWSSDKDIR)),)
      xWINDOWSSDKDIR :="$(subst \,/,$(WINDOWSSDKDIR))"
      fWINDOWSSDKDIR :=$(call FullPath,$(xWINDOWSSDKDIR))
    else
      fWINDOWSSDKDIR :=$(WINDOWSSDKDIR)
D
duke 已提交
297 298
    endif
  endif
299 300 301 302 303 304 305
  ifneq ($(fWINDOWSSDKDIR),)
    WINDOWSSDKDIR  :=$(fWINDOWSSDKDIR)/
  endif
  ifndef VS100COMNTOOLS
    xVS100COMNTOOLS :="$(_program_files32)/Microsoft Visual Studio 10.0/Common7/Tools/"
    fVS100COMNTOOLS :=$(call FullPath,$(xVS100COMNTOOLS))
  else
306
    xVS100COMNTOOLS :="$(subst \,/,$(VS100COMNTOOLS))"
307 308 309 310
    ifneq ($(word 2,$(VS100COMNTOOLS)),)
      fVS100COMNTOOLS :=$(call FullPath,$(xVS100COMNTOOLS))
    else
      fVS100COMNTOOLS :=$(xVS100COMNTOOLS)
311
    endif
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337
  endif
  ifneq ($(fVS100COMNTOOLS),)
    VS100COMNTOOLS :=$(fVS100COMNTOOLS)/
  endif
  # Check to see that both exist
  ifeq ($(WINDOWSSDKDIR),)
    _vs2010_message := No WINDOWSSDKDIR found on system. $(_vs2010_message)
    VS2010_EXISTS   := false
  endif
  ifeq ($(VS100COMNTOOLS),)
    _vs2010_message := No VS100COMNTOOLS found on system. $(_vs2010_message)
    VS2010_EXISTS   := false
  endif
  ifeq ($(VS2010_EXISTS),false)
    x:=$(warning WARNING: No VS2010 available. $(_vs2010_message))
    VS100COMNTOOLS :=
    WINDOWSSDKDIR  :=
  else
    VS2010_EXISTS := true
    _msvc_dir     :=$(VS100COMNTOOLS)/../../Vc
  endif
  export VS2010_EXISTS
  export VS100COMNTOOLS
  export WINDOWSSDKDIR
endif

338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357
ifneq ($(VS2010_EXISTS),true)
  x:=$(error ERROR: No VS2010 found on system.)
endif 

# VS2010 Compiler root directory
_msvc_dir :=$(VS100COMNTOOLS)/../../Vc
# SDK root directory
_ms_sdk   :=$(WINDOWSSDKDIR)
# Compiler bin directory and redist directory
ifeq ($(ARCH_DATA_MODEL), 32)
  _compiler_bin :=$(_msvc_dir)/Bin
  _redist_sdk   :=$(call FullPath,$(_msvc_dir)/redist/x86/Microsoft.VC100.CRT)
endif
ifeq ($(ARCH_DATA_MODEL), 64)
  _compiler_bin :=$(_msvc_dir)/bin/amd64
  _redist_sdk   :=$(call FullPath,$(_msvc_dir)/redist/x64/Microsoft.VC100.CRT)
endif
ifeq ($(_redist_sdk),)
  _redist_sdk   :=$(_system_root)/system32
endif
D
duke 已提交
358 359 360 361 362 363 364 365 366

# Location on system where jdk installs might be
ifneq ($(_program_files),)
  USRJDKINSTANCES_PATH =$(_program_files)/Java
else
  USRJDKINSTANCES_PATH =$(_system_drive)/
endif

# SLASH_JAVA: location of all network accessable files
367 368
# NOTE: Do not use FullPath on this because it's often a drive letter and
#       plain drive letters are ambiguous, so just use this 'as is'.
D
duke 已提交
369 370
ifdef ALT_SLASH_JAVA
  xALT_SLASH_JAVA :="$(subst \,/,$(ALT_SLASH_JAVA))"
371
  SLASH_JAVA      :=$(xALT_SLASH_JAVA)
D
duke 已提交
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444
else
  ifdef ALT_JDK_JAVA_DRIVE
    SLASH_JAVA  =$(JDK_JAVA_DRIVE)
  else
    SLASH_JAVA  =J:
  endif
endif
SLASH_JAVA:=$(call AltCheckSpaces,SLASH_JAVA)
SLASH_JAVA:=$(call AltCheckValue,SLASH_JAVA)

# JDK_DEVTOOLS_DIR: common path for all the java devtools
ifdef ALT_JDK_DEVTOOLS_DIR
  xALT_JDK_DEVTOOLS_DIR :="$(subst \,/,$(ALT_JDK_DEVTOOLS_DIR))"
  JDK_DEVTOOLS_DIR      :=$(call FullPath,$(xALT_JDK_DEVTOOLS_DIR))
else
  JDK_DEVTOOLS_DIR =$(SLASH_JAVA)/devtools
endif
JDK_DEVTOOLS_DIR:=$(call AltCheckSpaces,JDK_DEVTOOLS_DIR)
JDK_DEVTOOLS_DIR:=$(call AltCheckValue,JDK_DEVTOOLS_DIR)

# COMPILER_PATH: path to where the compiler and tools are installed.
#  NOTE: Must end with / so that it could be empty, allowing PATH usage.
ifdef ALT_COMPILER_PATH
  xALT_COMPILER_PATH  :="$(subst \,/,$(ALT_COMPILER_PATH))"
  fxALT_COMPILER_PATH :=$(call FullPath,$(xALT_COMPILER_PATH))
  COMPILER_PATH       :=$(call PrefixPath,$(fxALT_COMPILER_PATH))
else
  COMPILER_PATH :=$(call PrefixPath,$(_compiler_bin))
endif
COMPILER_PATH :=$(call AltCheckSpaces,COMPILER_PATH)

# MSDEVTOOLS_PATH: path to where the additional MS Compiler tools are.
#  NOTE: Must end with / so that it could be empty, allowing PATH usage.
ifdef ALT_MSDEVTOOLS_PATH
  xALT_MSDEVTOOLS_PATH  :="$(subst \,/,$(ALT_MSDEVTOOLS_PATH))"
  fxALT_MSDEVTOOLS_PATH :=$(call FullPath,$(xALT_MSDEVTOOLS_PATH))
  MSDEVTOOLS_PATH       :=$(call PrefixPath,$(fxALT_MSDEVTOOLS_PATH))
else
  ifeq ($(ARCH_DATA_MODEL), 64)
    ifdef MSTOOLS
      xMSTOOLS  :="$(subst \,/,$(MSTOOLS))"
      _ms_tools :=$(call FullPath,$(xMSTOOLS))
    else
      ifdef Mstools
        xMSTOOLS  :="$(subst \,/,$(Mstools))"
        _ms_tools :=$(call FullPath,$(xMSTOOLS))
      else
        _ms_tools :=
      endif
    endif
    ifneq ($(_ms_tools),)
      _ms_tools_bin :=$(_ms_tools)/Bin
    else
      # Assumes compiler bin is .../Bin/win64/x86/AMD64, rc.exe is 3 levels up
      _ms_tools_bin :=$(_compiler_bin)/../../..
    endif
  else
    _ms_tools_bin :=$(_compiler_bin)
  endif
  MSDEVTOOLS_PATH :=$(call PrefixPath,$(_ms_tools_bin))
endif
MSDEVTOOLS_PATH:=$(call AltCheckSpaces,MSDEVTOOLS_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))
  DEVTOOLS_PATH       :=$(call PrefixPath,$(fxALT_DEVTOOLS_PATH))
else
  ifdef USING_CYGWIN
    DEVTOOLS_PATH :=$(UNIXCOMMAND_PATH)
  else
445 446 447 448 449 450 451 452
    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
D
duke 已提交
453 454 455 456 457
endif
DEVTOOLS_PATH:=$(call AltCheckSpaces,DEVTOOLS_PATH)

# _BOOTDIR1: First choice for a Bootstrap JDK, previous released JDK.
# _BOOTDIR2: Second choice
458
# The _BOOTDIR3 is defind optionally.
D
duke 已提交
459 460 461
ifndef ALT_BOOTDIR
  _BOOTDIR1  =$(_system_drive)/jdk$(PREVIOUS_JDK_VERSION)
  _BOOTDIR2  =$(USRJDKINSTANCES_PATH)/jdk$(PREVIOUS_JDK_VERSION)
462
  _BOOTDIR3  =$(SLASH_JAVA)/re/jdk/$(PREVIOUS_JDK_VERSION)/archive/fcs/binaries/$(PLATFORM)-$(ARCH)
D
duke 已提交
463 464
endif

465 466
# Everybody needs the MSVCRNN runtime starting with VS2010
_NEEDS_MSVCRNN = true
467 468

ifeq ($(_NEEDS_MSVCRNN), true)
469 470 471 472
  # MSVCRNN_DLL_PATH: location of msvcrnn.dll that will be re-distributed
  ifdef ALT_MSVCRNN_DLL_PATH
    xALT_MSVCRNN_DLL_PATH :="$(subst \,/,$(ALT_MSVCRNN_DLL_PATH))"
    MSVCRNN_DLL_PATH      :=$(call FullPath,$(xALT_MSVCRNN_DLL_PATH))
D
duke 已提交
473
  else
474
    MSVCRNN_DLL_PATH :=$(_redist_sdk)
D
duke 已提交
475
  endif
476 477
  MSVCRNN_DLL_PATH :=$(call AltCheckSpaces,MSVCRNN_DLL_PATH)
  MSVCRNN_DLL_PATH:=$(call AltCheckValue,MSVCRNN_DLL_PATH)
D
duke 已提交
478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493
endif

# DEPLOY_MSSDK: Microsoft SDK for this platform (for deploy)
ifdef ALT_DEPLOY_MSSDK
  xALT_DEPLOY_MSSDK :="$(subst \,/,$(ALT_DEPLOY_MSSDK))"
  DEPLOY_MSSDK      :=$(call FullPath,$(xALT_DEPLOY_MSSDK))
else
  DEPLOY_MSSDK      :=$(_ms_sdk)
endif
DEPLOY_MSSDK:=$(call AltCheckSpaces,DEPLOY_MSSDK)

# INSTALL_MSSDK: Microsoft Installer SDK for this platform (for install)
ifdef ALT_INSTALL_MSSDK
  xALT_INSTALL_MSSDK :="$(subst \,/,$(ALT_INSTALL_MSSDK))"
  INSTALL_MSSDK      :=$(call FullPath,$(xALT_INSTALL_MSSDK))
else
494
  INSTALL_MSSDK      :=$(_ms_sdk)
D
duke 已提交
495 496 497 498 499 500 501 502 503 504 505 506
endif
INSTALL_MSSDK:=$(call AltCheckSpaces,INSTALL_MSSDK)

# WSCRIPT: path to wscript.exe (used in creating install bundles)
ifdef ALT_WSCRIPT
  xALT_WSCRIPT :="$(subst \,/,$(ALT_WSCRIPT))"
  WSCRIPT  =$(xALT_WSCRIPT)
else
  _WSCRIPT1 :=$(_system_root)/system32/wscript.exe
  _WSCRIPT2 :=$(DEVTOOLS_PATH)wscript.exe
  WSCRIPT  :=$(call FileExists,$(_WSCRIPT1),$(_WSCRIPT2))
endif
507 508
# If CONFIGURE_BUILD is defined, checks were already done by configure.
ifndef CONFIGURE_BUILD
D
duke 已提交
509
WSCRIPT:=$(call AltCheckSpaces,WSCRIPT)
510
endif #! CONFIGURE_BUILD
511 512
# batch mode no modal dialogs on errors, please.
WSCRIPT += -B
D
duke 已提交
513 514 515 516 517 518 519 520 521 522

# CSCRIPT: path to cscript.exe (used in creating install bundles)
ifdef ALT_CSCRIPT
  xALT_CSCRIPT :="$(subst \,/,$(ALT_CSCRIPT))"
  CSCRIPT  =$(xALT_CSCRIPT)
else
  _CSCRIPT1 :=$(_system_root)/system32/cscript.exe
  _CSCRIPT2 :=$(DEVTOOLS_PATH)cscript.exe
  CSCRIPT  :=$(call FileExists,$(_CSCRIPT1),$(_CSCRIPT2))
endif
523 524
# If CONFIGURE_BUILD is defined, checks were already done by configure.
ifndef CONFIGURE_BUILD
D
duke 已提交
525
CSCRIPT:=$(call AltCheckSpaces,CSCRIPT)
526
endif #! CONFIGURE_BUILD
D
duke 已提交
527

528 529 530 531 532 533 534 535 536 537 538
# CABARC: path to cabarc.exe (used in creating install bundles)
ifdef ALT_CABARC
  xALT_CABARC :="$(subst \,/,$(ALT_CABARC))"
  CABARC  =$(xALT_CABARC)
else
  _CABARC1 :=$(_system_root)/system32/cabarc.exe
  _CABARC2 :=$(DEVTOOLS_PATH)cabarc.exe
  CABARC  :=$(call FileExists,$(_CABARC1),$(_CABARC2))
endif
CABARC:=$(call AltCheckSpaces,CABARC)

D
duke 已提交
539 540 541 542 543 544 545 546 547
# MSICERT: path to msicert.exe (used in creating install bundles)
ifdef ALT_MSICERT
  xALT_MSICERT :="$(subst \,/,$(ALT_MSICERT))"
  MSICERT  =$(xALT_MSICERT)
else
  _MSICERT1 :=$(INSTALL_MSSDK)/Bin/msicert.exe
  _MSICERT2 :=$(DEVTOOLS_PATH)msicert.exe
  MSICERT   :=$(call FileExists,$(_MSICERT1),$(_MSICERT2))
endif
548 549
# If CONFIGURE_BUILD is defined, checks were already done by configure.
ifndef CONFIGURE_BUILD
D
duke 已提交
550
MSICERT:=$(call AltCheckSpaces,MSICERT)
551
endif #! CONFIGURE_BUILD
D
duke 已提交
552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578

# Import JDK images allow for partial builds, components not built are
#    imported (or copied from) these import areas when needed.

# BUILD_JDK_IMPORT_PATH: location of JDK install trees to import for
#   multiple platforms, e.g. windows-i586, solaris-sparc, linux-586, etc.
ifdef ALT_BUILD_JDK_IMPORT_PATH
  BUILD_JDK_IMPORT_PATH  :=$(call FullPath,$(ALT_BUILD_JDK_IMPORT_PATH))
else
  BUILD_JDK_IMPORT_PATH   = $(PROMOTED_BUILD_BINARIES)
endif
BUILD_JDK_IMPORT_PATH:=$(call AltCheckSpaces,BUILD_JDK_IMPORT_PATH)
BUILD_JDK_IMPORT_PATH:=$(call AltCheckValue,BUILD_JDK_IMPORT_PATH)

# JDK_IMPORT_PATH: location of previously built JDK (this version) to import
ifdef ALT_JDK_IMPORT_PATH
  JDK_IMPORT_PATH  :=$(call FullPath,$(ALT_JDK_IMPORT_PATH))
else
  JDK_IMPORT_PATH   = $(BUILD_JDK_IMPORT_PATH)/$(PLATFORM)-$(ARCH)$(_JDK_IMPORT_VARIANT)
endif
JDK_IMPORT_PATH:=$(call AltCheckSpaces,JDK_IMPORT_PATH)
JDK_IMPORT_PATH:=$(call AltCheckValue,JDK_IMPORT_PATH)

# HOTSPOT_IMPORT_PATH: location of hotspot pre-built files
ifdef ALT_HOTSPOT_IMPORT_PATH
  HOTSPOT_IMPORT_PATH :=$(call FullPath,$(ALT_HOTSPOT_IMPORT_PATH))
else
579 580 581 582 583 584
  # Default locations include the current $OUTPUTDIR, RE Promotions,
  # and a JDK.  Please be aware the JDK does not include a Kernel VM.
  _HOTSPOT_IMPORT_PATH1 = $(OUTPUTDIR)/hotspot/import
  _HOTSPOT_IMPORT_PATH2 = $(PROMOTED_BUILD_DISTDIR)/hotspot/import
  _HOTSPOT_IMPORT_PATH3 = $(JDK_IMPORT_PATH)
   HOTSPOT_IMPORT_PATH := $(call DirExists,$(_HOTSPOT_IMPORT_PATH1),$(_HOTSPOT_IMPORT_PATH2),$(_HOTSPOT_IMPORT_PATH3))
D
duke 已提交
585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617
endif
HOTSPOT_IMPORT_PATH:=$(call AltCheckSpaces,HOTSPOT_IMPORT_PATH)
HOTSPOT_IMPORT_PATH:=$(call AltCheckValue,HOTSPOT_IMPORT_PATH)

# HOTSPOT_CLIENT_PATH: location of client jvm library file.
ifeq ($(ARCH_DATA_MODEL), 32)
  ifdef ALT_HOTSPOT_CLIENT_PATH
    HOTSPOT_CLIENT_PATH :=$(call FullPath,$(ALT_HOTSPOT_CLIENT_PATH))
  else
    HOTSPOT_CLIENT_PATH   =$(HOTSPOT_IMPORT_PATH)/$(ARCH_VM_SUBDIR)/client
  endif
  HOTSPOT_CLIENT_PATH:=$(call AltCheckSpaces,HOTSPOT_CLIENT_PATH)
  HOTSPOT_CLIENT_PATH:=$(call AltCheckValue,HOTSPOT_CLIENT_PATH)
endif

# HOTSPOT_SERVER_PATH: location of server jvm library file.
ifdef ALT_HOTSPOT_SERVER_PATH
  HOTSPOT_SERVER_PATH :=$(call FullPath,$(ALT_HOTSPOT_SERVER_PATH))
else
  HOTSPOT_SERVER_PATH   =$(HOTSPOT_IMPORT_PATH)/$(ARCH_VM_SUBDIR)/server
endif
HOTSPOT_SERVER_PATH:=$(call AltCheckSpaces,HOTSPOT_SERVER_PATH)
HOTSPOT_SERVER_PATH:=$(call AltCheckValue,HOTSPOT_SERVER_PATH)

# HOTSPOT_LIB_PATH: location of jvm.lib file.
ifdef ALT_HOTSPOT_LIB_PATH
  xALT_HOTSPOT_LIB_PATH :="$(subst \,/,$(ALT_HOTSPOT_LIB_PATH))"
  HOTSPOT_LIB_PATH      :=$(call FullPath,$(xALT_HOTSPOT_LIB_PATH))
else
  HOTSPOT_LIB_PATH  =$(HOTSPOT_IMPORT_PATH)/lib
endif
HOTSPOT_LIB_PATH:=$(call AltCheckSpaces,HOTSPOT_LIB_PATH)
HOTSPOT_LIB_PATH:=$(call AltCheckValue,HOTSPOT_LIB_PATH)
618 619 620

# Special define for checking the binaries

621
# All windows dll and exe files should have been built with -NXCOMPAT
622 623 624 625 626
#   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.

# List of filenames we should NOT be dependent on
627 628 629 630 631
ifeq ($(MFC_DEBUG),true)
  BANNED_DLLS=msvcp100[.]dll
else
  BANNED_DLLS=msvcp100[.]dll|msvcr100d[.]dll|msvcrtd[.]dll
endif
632

633
# Check for -safeseh (only used on 32bit)
634 635
define binary_file_safeseh_verification # binary_file
( \
636 637
  $(ECHO) "Checking for -SAFESEH usage in: $1" && \
  if [ "`$(DUMPBIN) -loadconfig $1 | $(EGREP) -i 'Safe Exception Handler Table'`" = "" ] ; then \
638
    $(ECHO) "ERROR: Did not find 'Safe Exception Handler Table' in loadconfig: $1" ; \
639
    $(DUMPBIN) -loadconfig $1 ; \
640 641 642 643 644
    exit 6 ; \
  fi ; \
)
endef

645
# Check for -NXCOMPAT usage
646
define binary_file_nxcompat_verification # binary_file
647
( \
648 649
  $(ECHO) "Checking for -NXCOMPAT usage in: $1" && \
  if [ "`$(DUMPBIN) -headers $1 | $(EGREP) -i 'NX compatible'`" = "" ] ; then \
650
    $(ECHO) "ERROR: Did not find 'NX compatible' in headers: $1" ; \
651
    $(DUMPBIN) -headers $1 ; \
652 653
    exit 7 ; \
  fi ; \
654 655 656
)
endef

657
# Check for -DYNAMICBASE usage
658 659
define binary_file_dynamicbase_verification # binary_file
( \
660 661
  $(ECHO) "Checking for -DYNAMICBASE usage in: $1" && \
  if [ "`$(DUMPBIN) -headers $1 | $(EGREP) -i 'Dynamic base'`" = "" ] ; then \
662
    $(ECHO) "ERROR: Did not find 'Dynamic base' in headers: $1" ; \
663
    $(DUMPBIN) -headers $1 ; \
664 665
    exit 8 ; \
  fi ; \
666 667 668 669 670 671
)
endef

# Check for banned dll usage
define binary_file_dll_verification # binary_file
( \
672
  $(ECHO) "Checking for banned dependencies in: $1" && \
673
  if [ "`$(DUMPBIN) -dependents $1 | $(EGREP) -i '$(BANNED_DLLS)'`" != "" ] ; then \
674
    $(ECHO) "ERROR: Found use of $(BANNED_DLLS)"; \
675
    $(DUMPBIN) -dependents $1 ; \
676 677 678 679 680
    exit 9 ; \
  fi ; \
)
endef

681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701
# Macro to check it's input file for properly built executables.
#   Relies on process exit code. Different for 32bit vs 64bit.
ifeq ($(ARCH_DATA_MODEL),32)
define binary_file_verification # binary_file
( \
  $(call binary_file_safeseh_verification,$1); \
  $(call binary_file_nxcompat_verification,$1); \
  $(call binary_file_dynamicbase_verification,$1); \
  $(call binary_file_dll_verification,$1); \
)
endef
else
define binary_file_verification # binary_file
( \
  $(call binary_file_nxcompat_verification,$1); \
  $(call binary_file_dynamicbase_verification,$1); \
  $(call binary_file_dll_verification,$1); \
)
endef
endif