Defs-windows.gmk 15.1 KB
Newer Older
D
duke 已提交
1
#
X
xdono 已提交
2
# Copyright 1999-2008 Sun Microsystems, Inc.  All Rights Reserved.
D
duke 已提交
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
# 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.  Sun designates this
# particular file as subject to the "Classpath" exception as provided
# by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
# CA 95054 USA or visit www.sun.com if you need additional information or
# have any questions.
#

#
# Makefile to specify compiler flags for programs and libraries
# targeted to Windows builds.  Should not contain any rules.
#
# WARNING: This file is shared with other workspaces. 
#          So when it includes other files, it must use JDK_TOPDIR.
#

# Get shared JDK settings
include $(JDK_MAKE_SHARED_DIR)/Defs.gmk

# CC compiler object code output directive flag value
CC_OBJECT_OUTPUT_FLAG = -Fo
CC_PROGRAM_OUTPUT_FLAG = -Fe

# The suffix applied to the library name for FDLIBM
FDDLIBM_SUFFIX = lib
# The suffix applied to scripts (.bat for windows, nothing for unix)
SCRIPT_SUFFIX = .bat

HPIS = windows
# LIB_LOCATION, which for windows identifies where .exe files go, may be
# set by each GNUmakefile. The default is BINDIR.
ifndef LIB_LOCATION
  LIB_LOCATION = $(BINDIR)
endif # LIB_LOCATION

ifndef PLATFORM_SRC
54
  PLATFORM_SRC  = $(BUILDDIR)/../src/windows
D
duke 已提交
55 56 57 58 59
endif # PLATFORM_SRC

# Platform specific closed sources
ifndef OPENJDK
  ifndef CLOSED_PLATFORM_SRC
60
    CLOSED_PLATFORM_SRC  = $(BUILDDIR)/../src/closed/windows
D
duke 已提交
61 62 63 64 65 66 67 68 69 70
  endif
endif

# for backwards compatability, the old "win32" is used here instead of 
# the more proper "windows"
PLATFORM_INCLUDE_NAME = win32
PLATFORM_INCLUDE      = $(INCLUDEDIR)/$(PLATFORM_INCLUDE_NAME)

# The following DLL's are considered MS runtime libraries and should
#     not to be REBASEd, see deploy/make/common/Release.gmk.
71
#     msvcrt.dll, msvcrnn.dll [msvcr71 or msvcr80 or msvcr90] : Microsoft runtimes
D
duke 已提交
72
MS_RUNTIME_LIBRARIES = msvcrt.dll
73
MSVCRNN_DLL =
D
duke 已提交
74 75
ifeq ($(ARCH_DATA_MODEL), 32)
  ifeq ($(COMPILER_VERSION), VS2003)
76 77 78 79 80 81 82 83 84 85 86 87 88
    MSVCRNN_DLL = msvcr71.dll
    MSVCPNN_DLL = msvcp71.dll
    MS_RUNTIME_LIBRARIES += $(MSVCRNN_DLL)
  endif
  ifeq ($(COMPILER_VERSION), VS2005)
    MSVCRNN_DLL = msvcr80.dll
    MSVCPNN_DLL = msvcp80.dll
    MS_RUNTIME_LIBRARIES += $(MSVCRNN_DLL)
  endif
  ifeq ($(COMPILER_VERSION), VS2008)
    MSVCRNN_DLL = msvcr90.dll
    MSVCPNN_DLL = msvcp90.dll
    MS_RUNTIME_LIBRARIES += $(MSVCRNN_DLL)
D
duke 已提交
89 90 91 92 93 94 95 96 97 98 99
  endif
endif


EXTRA_LFLAGS += /LIBPATH:$(DXSDK_LIB_PATH)

# C Compiler flag definitions

#
# Default optimization
#
100 101 102 103 104 105 106 107 108

ifndef OPTIMIZATION_LEVEL
  ifeq ($(PRODUCT), java)
    OPTIMIZATION_LEVEL = HIGHER
  else
    OPTIMIZATION_LEVEL = LOWER
  endif
endif

D
duke 已提交
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
ifeq ($(CC_VERSION),msvc)
  # Visual Studio .NET 2003 or VS2003 compiler option definitions:
  #   -O1      Favors reduced size over speed (-Og     -Os -Oy -Ob2 -Gs -GF -Gy)
  #   -O2      Favors speed over reduced size (-Og -Oi -Ot -Oy -Ob2 -Gs -GF -Gy)
  #   -Ox      Full optimization (use -O2)    (-Og -Oi -Ot -Oy -Ob2)
  #              (Removed in Visual Studio 2005 or VS2005)
  #   -Ob2     More aggressive inlining
  #   -Og      Global optimizations
  #   -Oi      Replace some functions with intrinsic or special forms
  #   -Op      Improve floating point calculations (disables some optimizations)
  #              (Replaced with -fp:precise in VS2005, /Op is default now)
  #   -Os      Favor small code
  #   -Ot      Favor faster code
  #   -Oy      Frame pointer omission
  #   -GB      Optimize for pentium (old VC6 option?)
  #   -G6      VS2003 version of -GB?
  #   -GF      Pool strings in read-only memory
  #   -Gf      Pool strings in read-write memory (the default)
  #   -Gs      Controls stack probess
  #   -GS      Adds buffer overflow checks on stacks
  #              (Default in VS2005)
  #   -GX      Enables exception handling 
  #              (Replaced with /EHsc in VS2005)
  #   -Gy      Function level linking only
  #
  # NOTE: With VC6, -Ox included -Gs.
  # NOTE: With VC6, -Ox, -O1, and -O2 used -Ob1, not -Ob2.
  # NOTE: With VC6, -O1 and -O2 used -Gf, not -GF.
  #
138 139 140 141 142 143

  CC_OPT/NONE    = -Od
  CC_OPT/LOWER   = -O2
  CC_OPT/HIGHER  = -O3
  CC_OPT/HIGHEST = -O3
  
D
duke 已提交
144 145 146 147 148 149
  ifeq ($(COMPILER_VERSION), VC6)
    # VC6 (6.2) msvc compiler (the way Tiger and early Mustang were built)
    # Automatic precompiled header option to use (if COMPILE_APPROACH=batch)
    AUTOMATIC_PCH_OPTION =
    GX_OPTION = -GX
    ifeq ($(ARCH_DATA_MODEL), 32)
150 151 152
      CC_OPT/HIGHEST = -Ox -Gy -Os -GB
      CC_OPT/HIGHER  = -Ox -Gy -Os -GB
      CC_OPT/LOWER   = -Ox -Gy -Os -GB
D
duke 已提交
153
    else
154 155 156
      CC_OPT/HIGHEST = -Ox -Gy -Op
      CC_OPT/HIGHER  = -Ox -Gy -Op
      CC_OPT/LOWER   = -Ox -Gy -Op
D
duke 已提交
157 158
    endif
  endif
159
  
D
duke 已提交
160 161 162 163 164 165 166
  ifeq ($(COMPILER_VERSION), VS2003)
    # Automatic precompiled header option to use (if COMPILE_APPROACH=batch)
    AUTOMATIC_PCH_OPTION = -YX
    # Also known as VC7 compiler
    GX_OPTION = -GX
    ifeq ($(ARCH_DATA_MODEL), 32)
      # Lowered opt level to try and reduce footprint, dll size especially.
167 168 169 170 171
      #     Was: CC_OPT/HIGHEST = -O2 -G6
      #     Was: CC_OPT/HIGHER  = -O2
      CC_OPT/HIGHEST = -O2
      CC_OPT/HIGHER  = -O1
      CC_OPT/LOWER   = -O1
D
duke 已提交
172
    else
173 174 175
      CC_OPT/HIGHEST = -O2 -Op
      CC_OPT/HIGHER  = -O2 -Op
      CC_OPT/LOWER   = -O1 -Op
D
duke 已提交
176 177
    endif
  endif
178
  
D
duke 已提交
179 180 181 182 183 184
  ifeq ($(COMPILER_VERSION), VS2005)
    # Automatic precompiled header option to use (if COMPILE_APPROACH=batch)
    AUTOMATIC_PCH_OPTION =
    # VS2005 compiler, only with Platform SDK right now?
    GX_OPTION = -EHsc
    ifeq ($(ARCH_DATA_MODEL), 32)
185 186 187
      CC_OPT/HIGHEST = -O2
      CC_OPT/HIGHER  = -O1
      CC_OPT/LOWER   = -O1
D
duke 已提交
188
    else
189 190 191
      CC_OPT/HIGHEST = -O2
      CC_OPT/HIGHER  = -O1
      CC_OPT/LOWER   = -O1
D
duke 已提交
192 193
    endif
  endif
194 195 196 197 198 199 200 201 202 203 204 205 206 207
  ifeq ($(COMPILER_VERSION), VS2008)
    # Automatic precompiled header option to use (if COMPILE_APPROACH=batch)
    AUTOMATIC_PCH_OPTION =
    GX_OPTION = -EHsc
    ifeq ($(ARCH_DATA_MODEL), 32)
      CC_OPT/HIGHEST = -O2
      CC_OPT/HIGHER  = -O1
      CC_OPT/LOWER   = -O1
    else
      CC_OPT/HIGHEST = -O2
      CC_OPT/HIGHER  = -O1
      CC_OPT/LOWER   = -O1
    endif
  endif
208

D
duke 已提交
209 210
else # CC_VERSION
  # GCC not supported, but left for historical reference...
211 212 213 214
  CC_OPT/NONE     =
  CC_OPT/LOWER    = -O2
  CC_OPT/HIGHER   = -O2
  CC_OPT/HIGHEST  = -O3
D
duke 已提交
215 216 217

endif

218
CC_OPT = $(CC_OPT/$(OPTIMIZATION_LEVEL))
D
duke 已提交
219 220 221 222 223 224 225 226 227 228

# Select the runtime support library carefully, need to be consistent
#
# VS2003 compiler option definitions:
#   -MD        Use dynamic multi-threaded runtime library
#   -MDd       Use debug version (don't use, doesn't mix with -MD DLL's)
#   -MT        Use static multi-threaded runtime library (-ML is going away)
#   -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)
#
229
#      NOTE: We also will use /D _STATIC_CPPLIB  so we don't need msvcpnn.dll
D
duke 已提交
230
#
231
# If MS_RUNTIME_STATIC is requested, use -MT only with VS2003.
D
duke 已提交
232
ifeq ($(MS_RUNTIME_STATIC),true)
233 234 235
  ifeq ($(COMPILER_VERSION), VS2003)
    MS_RUNTIME_OPTION=-MT
  endif
D
duke 已提交
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269
else
  MS_RUNTIME_OPTION=-MD
endif
# The _DEBUG macro option (changes things like malloc to use debug version)
MS_RUNTIME_DEBUG_OPTION=
MS_RC_DEBUG_OPTION=
# Externally set environment variable can force any build to use the debug vers
ifeq ($(MFC_DEBUG), true)
  ifeq ($(MS_RUNTIME_STATIC),true)
    MS_RUNTIME_OPTION=-MTd
  else
    # This MS debugging flag forces a dependence on the debug
    #     version of the runtime library (MSVCRTD.DLL), as does -MDd.
    #     We cannot re-distribute this debug runtime.
    MS_RUNTIME_OPTION=-MDd
  endif
  MS_RUNTIME_DEBUG_OPTION= -D_DEBUG
  MS_RC_DEBUG_OPTION= -d _DEBUG
endif

# Always add _STATIC_CPPLIB definition
STATIC_CPPLIB_OPTION = /D _STATIC_CPPLIB
MS_RUNTIME_OPTION += $(STATIC_CPPLIB_OPTION)

ifeq ($(CC_VERSION),msvc)
  # VS2003 compiler option definitions:
  #   -Zi      Cause *.pdb file to be created, full debug information
  #   -Z7      Full debug inside the .obj, no .pdb
  #   -Zd      Basic debug, no local variables? In the .obj
  #   -Zl      Don't add runtime library name to obj file?
  #   -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  
270
  #            Use static link for the C++ runtime (so msvcpnn.dll not needed)
D
duke 已提交
271 272
  #   
  CFLAGS_COMMON  += -Zi -nologo
273
  CFLAGS_OPT      = $(CC_OPT)
D
duke 已提交
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308
  CFLAGS_DBG      = -Od $(MS_RUNTIME_DEBUG_OPTION)

  # Starting from VS2005 the wchar_t is handled as a built-in C/C++ data type
  # by default. However, we expect the wchar_t to be a typedef to the
  # unsigned short data type. The -Zc:wchar_t- option restores the old
  # behavior (as seen in VS2003) to avoid massive code modifications.
  # When/if our code will be "C/C++ Standard"-compliant (at least in the area
  # of handling the wchar_t type), the option won't be necessary.
  ifeq ($(ARCH_DATA_MODEL), 32)
    CFLAGS_VS2005 += -Zc:wchar_t-
  else
    # The 64bit Platform SDK we use (April 2005) doesn't like this option
    ifneq ($(CC_VER), 14.00.40310.41)
      CFLAGS_VS2005 += -Zc:wchar_t-
    endif
  endif

  # All builds get the same runtime setting
  CFLAGS_COMMON += $(MS_RUNTIME_OPTION) $(CFLAGS_$(COMPILER_VERSION))
  

  LDEBUG = /debug
  
  ifeq ($(VTUNE_SUPPORT), true)
    OTHER_CFLAGS = -Z7 -Ox 
    LDEBUG += /pdb:NONE
  endif
  
  # The new Platform SDK and VS2005 has /GS as a default and requires 
  #    bufferoverflowU.lib on the link command line, otherwise 
  #    we get missing __security_check_cookie externals at link time. 
  BUFFEROVERFLOWLIB = bufferoverflowU.lib
  # Always add bufferoverflowU.lib to VS2005 link commands (pack uses LDDFLAGS)
  LFLAGS_VS2005 = $(BUFFEROVERFLOWLIB)

309 310 311
  # VS2008 has bufferoverflow baked in:
  LFLAGS_VS2008 = 

D
duke 已提交
312 313
  # LFLAGS are the flags given to $(LINK) and used to build the actual DLL file
  BASELFLAGS = -nologo /opt:REF /incremental:no
314 315 316 317 318
ifdef MT
    # VS2005, VS2008, and beyond: ask LINK to generate manifests for .dll & .exe
    BASELFLAGS += /manifest
endif

D
duke 已提交
319 320 321 322 323 324 325 326 327 328 329 330
  LFLAGS = $(BASELFLAGS) $(LDEBUG) $(EXTRA_LFLAGS) $(LFLAGS_$(COMPILER_VERSION))
  LDDFLAGS += $(LFLAGS_$(COMPILER_VERSION))
  
endif

#
# Preprocessor macro definitions
#
CPPFLAGS_COMMON = -DWIN32 -DIAL -D_LITTLE_ENDIAN
ifeq ($(ARCH), amd64)
  CPPFLAGS_COMMON += -D_AMD64_ -Damd64
else
331
  CPPFLAGS_COMMON += -D_X86_ -Dx86 
D
duke 已提交
332 333 334 335 336 337 338 339
endif
CPPFLAGS_COMMON += -DWIN32_LEAN_AND_MEAN

#
# Output options (use specific filenames to avoid parallel compile errors)
#
CFLAGS_COMMON += -Fd$(OBJDIR)/$(basename $(@F)).pdb -Fm$(OBJDIR)/$(basename $(@F)).map

340 341 342 343 344 345 346
#
# Use -wdNNNN to disable warning NNNN.
#   C4800 is a warning about bool performance casts (can't make go away)
#
COMPILER_WARNINGS_TO_IGNORE = 4800
CFLAGS_COMMON += $(COMPILER_WARNINGS_TO_IGNORE:%=-wd%)

D
duke 已提交
347 348 349 350 351 352 353 354 355 356
#
# Add warnings and extra on 64bit issues
#
ifeq ($(ARCH_DATA_MODEL), 64)
  CFLAGS_COMMON += -Wp64 
endif

#
# Treat compiler warnings as errors, if requested
#
357
CFLAGS_COMMON += -W$(COMPILER_WARNING_LEVEL)
D
duke 已提交
358 359 360 361 362 363 364 365 366 367 368 369 370 371 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
ifeq ($(COMPILER_WARNINGS_FATAL),true)
  CFLAGS_COMMON += -WX
endif

CPPFLAGS_OPT    = 
CPPFLAGS_DBG    = -DDEBUG -DLOGGING

CXXFLAGS_COMMON = $(CFLAGS_COMMON)
CXXFLAGS_OPT    = $(CFLAGS_OPT)
CXXFLAGS_DBG    = $(CFLAGS_DBG)

ifneq ($(LIBRARY),fdlibm)
  EXTRA_LIBS += advapi32.lib
endif

#
# Path and option to link against the VM, if you have to. 
#
JVMLIB = $(LIBDIR)/jvm.lib
JAVALIB = $(LIBDIR)/java.lib

ifeq ($(CC_VERSION), msvc)
  CC_DEPEND        = -FD
  CC_DEPEND_FILTER = 
else # CC_VERSION
# not supported, but left for historical reference...
  CC_DEPEND        = -MM
  CC_DEPEND_FILTER = $(SED) -e 's!$*\.$(OBJECT_SUFFIX)!$(dir $@)&!g'
endif # CC_VERSION

LIBRARY_SUFFIX = dll
LIB_SUFFIX     = lib

# Settings for the JDI - Serviceability Agent binding.
HOTSPOT_SALIB_PATH   = $(HOTSPOT_IMPORT_PATH)/jre/bin
SALIB_NAME = $(LIB_PREFIX)sawindbg.$(LIBRARY_SUFFIX)
SAMAP_NAME = $(LIB_PREFIX)sawindbg.map
SAPDB_NAME = $(LIB_PREFIX)sawindbg.pdb

ifeq ($(ARCH), ia64)
  # SA will never be supported here.
  INCLUDE_SA = false
else
  # Hopefully, SA will be supported here one of these days,
  # and these will be changed to true.  Until then,
  # to build SA on windows, do a control build with
  #    BUILD_WIN_SA=1
  # on the make command.
  ifdef BUILD_WIN_SA
407
    INCLUDE_SA = true
D
duke 已提交
408
  else
409
    INCLUDE_SA = false
D
duke 已提交
410 411 412 413
  endif
endif

# Settings for the VERSIONINFO tap on windows. 
414
VERSIONINFO_RESOURCE = $(BUILDDIR)/../src/windows/resource/version.rc
D
duke 已提交
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 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459

ifneq ($(JDK_BUILD_NUMBER),)
 COOKED_BUILD_NUMBER = $(shell $(ECHO) $(JDK_BUILD_NUMBER) | $(SED) -e 's/^b//' -e 's/^0//')
else
 COOKED_BUILD_NUMBER = 0
endif

# If the update version contains non-numeric characters, we need
# to massage it into a numeric format. 
# We use the following formula:
# JDK_UPDATE_VER = JDK_UPDATE_VERSION * 10 + EXCEPTION_VERSION
#
# Here are some examples:
#     1.5.0    b01  ->  5,0,0,1
#     1.5.0_10 b01  ->  5,0,100,1
#     1.4.2 b01     ->  4,2,0,1
#     1.4.2_02 b01  ->  4,2,20,1
#     1.4.2_02a b01 ->  4,2,21,1
#     1.4.2_02b b01 ->  4,2,22,1
ifdef JDK_UPDATE_VERSION
  VTMP := $(shell $(ECHO) $(JDK_UPDATE_VERSION) | $(TR) "abcde" "12345")
  CAB_CHAR1 := $(shell $(ECHO) $(VTMP) | $(NAWK) '{print substr($$1, 1, 1);}')
  CAB_CHAR2 := $(shell $(ECHO) $(VTMP) | $(NAWK) '{print substr($$1, 2, 1);}')
  CAB_CHAR3 := $(shell $(ECHO) $(VTMP) | $(NAWK) '{print substr($$1, 3, 1);}')
  JDK_UPDATE_META_TAG := U$(MARKETING_NUMBER)
  ifeq ($(CAB_CHAR3),)
    CAB_CHAR3 := 0
  endif
  ifeq ($(CAB_CHAR1), 0)
    JDK_UPDATE_VER := $(CAB_CHAR2)$(CAB_CHAR3)
  else
    JDK_UPDATE_VER := $(CAB_CHAR1)$(CAB_CHAR2)$(CAB_CHAR3)
  endif
else
  JDK_UPDATE_VER := 0
endif

RC_FLAGS = /l 0x409 /r

ifeq ($(VARIANT), OPT)
  RC_FLAGS += -d NDEBUG 
else
  RC_FLAGS += $(MS_RC_DEBUG_OPTION)
endif 

460 461 462 463 464 465 466 467 468 469 470
# Values for the RC variables defined in RC_FLAGS
JDK_RC_BUILD_ID = $(FULL_VERSION)
JDK_RC_COMPANY = $(COMPANY_NAME)
JDK_RC_COMPONENT = $(PRODUCT_NAME) $(JDK_RC_PLATFORM_NAME) binary
JDK_RC_VER = \
    $(JDK_MINOR_VERSION).$(JDK_MICRO_VERSION).$(JDK_UPDATE_VER).$(COOKED_BUILD_NUMBER)
JDK_RC_COPYRIGHT = Copyright \xA9 $(COPYRIGHT_YEAR)
JDK_RC_NAME = \
    $(PRODUCT_NAME) $(JDK_RC_PLATFORM_NAME) $(JDK_MINOR_VERSION) $(JDK_UPDATE_META_TAG)
JDK_RC_FVER = \
    $(JDK_MINOR_VERSION),$(JDK_MICRO_VERSION),$(JDK_UPDATE_VER),$(COOKED_BUILD_NUMBER)
D
duke 已提交
471 472

# J2SE name required here
473 474 475 476 477 478 479
RC_FLAGS += -d "J2SE_BUILD_ID=$(JDK_RC_BUILD_ID)" \
            -d "J2SE_COMPANY=$(JDK_RC_COMPANY)" \
            -d "J2SE_COMPONENT=$(JDK_RC_COMPONENT)" \
            -d "J2SE_VER=$(JDK_RC_VER)" \
            -d "J2SE_COPYRIGHT=$(JDK_RC_COPYRIGHT)" \
            -d "J2SE_NAME=$(JDK_RC_NAME)" \
            -d "J2SE_FVER=$(JDK_RC_FVER)"