1 #
   2 # Copyright (c) 1999, 2013, 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 # Makefile to specify compiler flags for programs and libraries
  28 # targeted to Windows builds.  Should not contain any rules.
  29 #
  30 # WARNING: This file is shared with other workspaces. 
  31 #          So when it includes other files, it must use JDK_TOPDIR.
  32 #
  33 
  34 # Get shared JDK settings
  35 include $(JDK_MAKE_SHARED_DIR)/Defs.gmk
  36 
  37 # CC compiler object code output directive flag value
  38 CC_OBJECT_OUTPUT_FLAG = -Fo
  39 CC_PROGRAM_OUTPUT_FLAG = -Fe
  40 
  41 # The suffix applied to the library name for FDLIBM
  42 FDDLIBM_SUFFIX = lib
  43 # The suffix applied to scripts (.bat for windows, nothing for unix)
  44 SCRIPT_SUFFIX = .bat
  45 
  46 # LIB_LOCATION, which for windows identifies where .exe files go, may be
  47 # set by each GNUmakefile. The default is BINDIR.
  48 ifndef LIB_LOCATION
  49   LIB_LOCATION = $(BINDIR)
  50 endif # LIB_LOCATION
  51 
  52 ifndef PLATFORM_SRC
  53   PLATFORM_SRC  = $(BUILDDIR)/../src/windows
  54 endif # PLATFORM_SRC
  55 
  56 # Location of the various .properties files specific to Windows platform
  57 ifndef PLATFORM_PROPERTIES
  58   PLATFORM_PROPERTIES  = $(BUILDDIR)/../src/windows/lib
  59 endif # PLATFORM_SRC
  60 
  61 # Platform specific closed sources
  62 ifndef OPENJDK
  63   ifndef CLOSED_PLATFORM_SRC
  64     CLOSED_PLATFORM_SRC  = $(BUILDDIR)/../src/closed/windows
  65   endif
  66 endif
  67 
  68 # for backwards compatability, the old "win32" is used here instead of 
  69 # the more proper "windows"
  70 PLATFORM_INCLUDE_NAME = win32
  71 PLATFORM_INCLUDE      = $(INCLUDEDIR)/$(PLATFORM_INCLUDE_NAME)
  72 
  73 # The following DLL's are considered MS runtime libraries and should
  74 #     not to be REBASEd, see deploy/make/common/Release.gmk.
  75 #     msvcr*.dll: Microsoft runtimes
  76 ifeq ($(COMPILER_VERSION), VS2010)
  77   MSVCRNN_DLL = msvcr100.dll
  78   MSVCPNN_DLL = msvcp100.dll
  79   MS_RUNTIME_LIBRARIES = $(MSVCRNN_DLL)
  80 endif
  81 
  82 EXTRA_LFLAGS += /LIBPATH:$(DXSDK_LIB_PATH)
  83 
  84 # Full Debug Symbols has been enabled on Windows since JDK1.4.1.
  85 # The Full Debug Symbols (FDS) default for VARIANT == OPT builds is
  86 # enabled with debug info files ZIP'ed to save space. For VARIANT !=
  87 # OPT builds, FDS is always enabled, after all a debug build without
  88 # debug info isn't very useful. The ZIP_DEBUGINFO_FILES option only has
  89 # meaning when FDS is enabled.
  90 #
  91 # If you invoke a build with FULL_DEBUG_SYMBOLS=0, then FDS will be
  92 # disabled for a VARIANT == OPT build.
  93 #
  94 # Note: Use of a different variable name for the FDS override option
  95 # versus the FDS enabled check is intentional (FULL_DEBUG_SYMBOLS
  96 # versus ENABLE_FULL_DEBUG_SYMBOLS). For auto build systems that pass
  97 # in options via environment variables, use of distinct variables
  98 # prevents strange behaviours. For example, in a VARIANT != OPT build,
  99 # the FULL_DEBUG_SYMBOLS environment variable will be 0, but the
 100 # ENABLE_FULL_DEBUG_SYMBOLS make variable will be 1. If the same
 101 # variable name is used, then different values can be picked up by
 102 # different parts of the build. Just to be clear, we only need two
 103 # variable names because the incoming option value can be overridden
 104 # in some situations, e.g., a VARIANT != OPT build.
 105 
 106 ifeq ($(VARIANT), OPT)
 107   FULL_DEBUG_SYMBOLS ?= 1
 108   ENABLE_FULL_DEBUG_SYMBOLS = $(FULL_DEBUG_SYMBOLS)
 109 else
 110   # debug variants always get Full Debug Symbols (if available)
 111   ENABLE_FULL_DEBUG_SYMBOLS = 1
 112 endif
 113 _JUNK_ := $(shell \
 114   echo >&2 "INFO: ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS)")
 115 
 116 ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
 117   ZIP_DEBUGINFO_FILES ?= 1
 118 else
 119   ZIP_DEBUGINFO_FILES=0
 120 endif
 121 _JUNK_ := $(shell echo >&2 "INFO: ZIP_DEBUGINFO_FILES=$(ZIP_DEBUGINFO_FILES)")
 122 
 123 # C Compiler flag definitions
 124 
 125 #
 126 # Default optimization
 127 #
 128 
 129 ifndef OPTIMIZATION_LEVEL
 130   ifeq ($(PRODUCT), java)
 131     OPTIMIZATION_LEVEL = HIGHER
 132   else
 133     OPTIMIZATION_LEVEL = LOWER
 134   endif
 135 endif
 136 ifndef FASTDEBUG_OPTIMIZATION_LEVEL
 137   FASTDEBUG_OPTIMIZATION_LEVEL = LOWER
 138 endif
 139 
 140 ifeq ($(CC_VERSION),msvc)
 141   # Visual Studio compiler option definitions:
 142   #   -O1      Favors reduced size over speed (-Og     -Os -Oy -Ob2 -Gs -GF -Gy)
 143   #   -O2      Favors speed over reduced size (-Og -Oi -Ot -Oy -Ob2 -Gs -GF -Gy)
 144   #   -Ob2     More aggressive inlining
 145   #   -Og      Global optimizations
 146   #   -Oi      Replace some functions with intrinsic or special forms
 147   #   -fp:precise (should be the default)
 148   #            Improve floating point calculations (disables some optimizations)
 149   #   -Os      Favor small code
 150   #   -Ot      Favor faster code
 151   #   -Oy      Frame pointer omission
 152   #   -G6      Used to be -GB?
 153   #   -GF      Pool strings in read-only memory
 154   #   -Gf      Pool strings in read-write memory (the default)
 155   #   -Gs      Controls stack probess
 156   #   -GS      Adds buffer overflow checks on stacks (the default)
 157   #   -EHsc    Enables exception handling 
 158   #   -Gy      Function level linking only
 159   #
 160 
 161   CC_OPT/NONE    = -Od
 162   CC_OPT/LOWER   = -O2
 163   CC_OPT/HIGHER  = -O3
 164   CC_OPT/HIGHEST = -O3
 165   
 166   ifeq ($(COMPILER_VERSION), VS2010)
 167     # Automatic precompiled header option to use (if COMPILE_APPROACH=batch)
 168     AUTOMATIC_PCH_OPTION =
 169     GX_OPTION = -EHsc
 170     GZ_OPTION = -RTC1
 171     ifeq ($(ARCH_DATA_MODEL), 32)
 172       CC_OPT/HIGHEST = -O2
 173       CC_OPT/HIGHER  = -O1
 174       CC_OPT/LOWER   = -O1
 175     else
 176       CC_OPT/HIGHEST = -O2
 177       CC_OPT/HIGHER  = -O1
 178       CC_OPT/LOWER   = -O1
 179     endif
 180   endif
 181 
 182 else # CC_VERSION
 183   # GCC not supported, but left for historical reference...
 184   CC_OPT/NONE     =
 185   CC_OPT/LOWER    = -O2
 186   CC_OPT/HIGHER   = -O2
 187   CC_OPT/HIGHEST  = -O3
 188 
 189 endif
 190 
 191 CC_OPT = $(CC_OPT/$(OPTIMIZATION_LEVEL))
 192 
 193 # Select the runtime support library carefully, need to be consistent
 194 #
 195 # Visual Studio Runtime compiler option definitions:
 196 #   -MD        Use dynamic multi-threaded runtime library
 197 #   -MDd       Use debug version (don't use, doesn't mix with -MD DLL's)
 198 #   -MT        Use static multi-threaded runtime library (-ML is going away)
 199 #   -MTd       Use static debug version (better than -MDd, no runtime issues)
 200 #   -D_DEBUG   Change use of malloc/free/etc to use special debug ones (-MTd)
 201 #
 202 #      NOTE: We also will use /D _STATIC_CPPLIB  so we don't need msvcpnn.dll
 203 #
 204 # If MS_RUNTIME_STATIC is requested we may have a problem, it is no longer
 205 #     supported by VS2010
 206 ifneq ($(MS_RUNTIME_STATIC),true)
 207   MS_RUNTIME_OPTION=-MD
 208 endif
 209 # The _DEBUG macro option (changes things like malloc to use debug version)
 210 MS_RUNTIME_DEBUG_OPTION=
 211 MS_RC_DEBUG_OPTION=
 212 # Externally set environment variable can force any build to use the debug vers
 213 ifeq ($(MFC_DEBUG), true)
 214   ifeq ($(MS_RUNTIME_STATIC),true)
 215     MS_RUNTIME_OPTION=-MTd
 216   else
 217     # This MS debugging flag forces a dependence on the debug
 218     #     version of the runtime library (MSVCR*D.DLL), as does -MDd.
 219     #     We cannot re-distribute this debug runtime.
 220     MS_RUNTIME_OPTION=-MDd
 221   endif
 222   MS_RUNTIME_DEBUG_OPTION= -D_DEBUG
 223   MS_RC_DEBUG_OPTION= -d _DEBUG
 224 endif
 225 
 226 # Always add _STATIC_CPPLIB definition
 227 STATIC_CPPLIB_OPTION = /D _STATIC_CPPLIB
 228 
 229 # Silence the warning about using _STATIC_CPPLIB
 230 ifneq ($(SHOW_ALL_WARNINGS),true)
 231   # Needed with VS2010 to turn off the deprecated warning.
 232   STATIC_CPPLIB_OPTION += /D _DISABLE_DEPRECATE_STATIC_CPPLIB
 233 endif
 234 
 235 MS_RUNTIME_OPTION += $(STATIC_CPPLIB_OPTION)
 236 
 237 ifeq ($(CC_VERSION),msvc)
 238   # Visual Studio compiler option definitions:
 239   #   -Zi      Cause *.pdb file to be created, full debug information
 240   #   -Z7      Full debug inside the .obj, no .pdb
 241   #   -Zd      Basic debug, no local variables? In the .obj
 242   #   -Zl      Don't add runtime library name to obj file?
 243   #   -Od      Turns off optimization and speeds compilation
 244   #   -YX -Fp/.../foobar.pch   Use precompiled headers (try someday?)
 245   #   -nologo  Don't print out startup message
 246   #   /D _STATIC_CPPLIB
 247   #            Use static link for the C++ runtime (so msvcpnn.dll not needed)
 248   #   
 249   ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
 250     CFLAGS_COMMON  += -Zi
 251   endif
 252   CFLAGS_COMMON  += -nologo
 253   CFLAGS_OPT      = $(CC_OPT)
 254   CFLAGS_DBG      = -Od $(MS_RUNTIME_DEBUG_OPTION)
 255 
 256   CFLAGS_VS2010 += -Zc:wchar_t-
 257 
 258   # All builds get the same runtime setting
 259   CFLAGS_COMMON += $(MS_RUNTIME_OPTION) $(CFLAGS_$(COMPILER_VERSION))
 260 
 261   ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
 262     LDEBUG = /debug
 263   endif
 264   
 265   ifeq ($(VTUNE_SUPPORT), true)
 266     OTHER_CFLAGS = -Z7 -Ox 
 267     LDEBUG += /pdb:NONE
 268   endif
 269   
 270   # VS2010, always need safe exception handlers, not needed on 64bit
 271   ifeq ($(ARCH_DATA_MODEL), 32)
 272     LFLAGS_VS2010 +=  -SAFESEH
 273   endif
 274 
 275   # LFLAGS are the flags given to $(LINK) and used to build the actual DLL file
 276   BASELFLAGS = -nologo /opt:REF /incremental:no
 277 
 278   LFLAGS = $(BASELFLAGS) $(LDEBUG) $(EXTRA_LFLAGS) $(LFLAGS_$(COMPILER_VERSION))
 279   LDDFLAGS += $(LFLAGS_$(COMPILER_VERSION))
 280   
 281 endif
 282 
 283 #
 284 # Preprocessor macro definitions
 285 #
 286 CPPFLAGS_COMMON = -DWIN32 -DIAL -D_LITTLE_ENDIAN
 287 ifeq ($(ARCH), amd64)
 288   CPPFLAGS_COMMON += -D_AMD64_ -Damd64
 289 else
 290   CPPFLAGS_COMMON += -D_X86_ -Dx86 
 291 endif
 292 CPPFLAGS_COMMON += -DWIN32_LEAN_AND_MEAN
 293 
 294 #
 295 # Output options (use specific filenames to avoid parallel compile errors)
 296 #
 297 ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
 298   CFLAGS_COMMON += -Fd$(OBJDIR)/$(basename $(@F)).pdb -Fm$(OBJDIR)/$(basename $(@F)).map
 299 endif
 300 
 301 #
 302 # Use -wdNNNN to disable warning NNNN.
 303 #   C4800 is a warning about bool performance casts (can't make go away)
 304 #
 305 COMPILER_WARNINGS_TO_IGNORE = 4800
 306 CFLAGS_COMMON += $(COMPILER_WARNINGS_TO_IGNORE:%=-wd%)
 307 
 308 #
 309 # Treat compiler warnings as errors, if requested
 310 #
 311 CFLAGS_COMMON += -W$(COMPILER_WARNING_LEVEL)
 312 ifeq ($(COMPILER_WARNINGS_FATAL),true)
 313   CFLAGS_COMMON += -WX
 314 endif
 315 
 316 # Turn off some warnings by default, enable them all if asked.
 317 ifneq ($(SHOW_ALL_WARNINGS),true)
 318   # The -D _CRT_SECURE_NO_DEPRECATE turns off security/deprecated warnings on
 319   #    the standard C library functions like strcpy.
 320   CFLAGS_COMMON += -D _CRT_SECURE_NO_DEPRECATE
 321   # The -D _CRT_NONSTDC_NO_DEPRECATE turns off deprecation warnings about using
 322   #    non-standard C POSIX functions.
 323   CFLAGS_COMMON += -D _CRT_NONSTDC_NO_DEPRECATE
 324 endif
 325 
 326 CPPFLAGS_OPT    = -DNDEBUG
 327 CPPFLAGS_DBG    = -DDEBUG -DLOGGING
 328 
 329 CXXFLAGS_COMMON = $(CFLAGS_COMMON)
 330 CXXFLAGS_OPT    = $(CFLAGS_OPT)
 331 CXXFLAGS_DBG    = $(CFLAGS_DBG)
 332 
 333 ifneq ($(LIBRARY),fdlibm)
 334   EXTRA_LIBS += advapi32.lib
 335 endif
 336 
 337 #
 338 # Path and option to link against the VM, if you have to. 
 339 #
 340 JVMLIB = $(LIBDIR)/jvm.lib
 341 JAVALIB = $(LIBDIR)/java.lib
 342 
 343 ifeq ($(CC_VERSION), msvc)
 344   CC_DEPEND        = -FD
 345   CC_DEPEND_FILTER = 
 346 else # CC_VERSION
 347 # not supported, but left for historical reference...
 348   CC_DEPEND        = -MM
 349   CC_DEPEND_FILTER = $(SED) -e 's!$*\.$(OBJECT_SUFFIX)!$(dir $@)&!g'
 350 endif # CC_VERSION
 351 
 352 LIBRARY_SUFFIX = dll
 353 LIB_SUFFIX     = lib
 354 
 355 # Settings for the JDI - Serviceability Agent binding.
 356 HOTSPOT_SALIB_PATH   = $(HOTSPOT_IMPORT_PATH)/jre/bin
 357 SALIB_NAME = $(LIB_PREFIX)sawindbg.$(LIBRARY_SUFFIX)
 358 SAMAP_NAME = $(LIB_PREFIX)sawindbg.map
 359 SAPDB_NAME = $(LIB_PREFIX)sawindbg.pdb
 360 SA_DIZ_NAME = $(LIB_PREFIX)sawindbg.diz
 361 
 362 ifeq ($(ARCH), ia64)
 363   # SA will never be supported here.
 364   INCLUDE_SA = false
 365 else
 366   INCLUDE_SA = true
 367 endif
 368 
 369 # Settings for the VERSIONINFO tap on windows. 
 370 VERSIONINFO_RESOURCE = $(BUILDDIR)/../src/windows/resource/version.rc
 371 
 372 ifneq ($(JDK_BUILD_NUMBER),)
 373  COOKED_BUILD_NUMBER = $(shell $(ECHO) $(JDK_BUILD_NUMBER) | $(SED) -e 's/^b//' -e 's/^0//')
 374 else
 375  COOKED_BUILD_NUMBER = 0
 376 endif
 377 
 378 # If the update version contains non-numeric characters, we need
 379 # to massage it into a numeric format. 
 380 # We use the following formula:
 381 # JDK_UPDATE_VER = JDK_UPDATE_VERSION * 10 + EXCEPTION_VERSION
 382 #
 383 # Here are some examples:
 384 #     1.5.0    b01  ->  5,0,0,1
 385 #     1.5.0_10 b01  ->  5,0,100,1
 386 #     1.4.2 b01     ->  4,2,0,1
 387 #     1.4.2_02 b01  ->  4,2,20,1
 388 #     1.4.2_02a b01 ->  4,2,21,1
 389 #     1.4.2_02b b01 ->  4,2,22,1
 390 ifdef JDK_UPDATE_VERSION
 391   VTMP := $(shell $(ECHO) $(JDK_UPDATE_VERSION) | $(TR) "abcde" "12345")
 392   CAB_CHAR1 := $(shell $(ECHO) $(VTMP) | $(NAWK) '{print substr($$1, 1, 1);}')
 393   CAB_CHAR2 := $(shell $(ECHO) $(VTMP) | $(NAWK) '{print substr($$1, 2, 1);}')
 394   CAB_CHAR3 := $(shell $(ECHO) $(VTMP) | $(NAWK) '{print substr($$1, 3, 1);}')
 395   JDK_UPDATE_META_TAG := U$(MARKETING_NUMBER)
 396   ifeq ($(CAB_CHAR3),)
 397     CAB_CHAR3 := 0
 398   endif
 399   ifeq ($(CAB_CHAR1), 0)
 400     JDK_UPDATE_VER := $(CAB_CHAR2)$(CAB_CHAR3)
 401   else
 402     JDK_UPDATE_VER := $(CAB_CHAR1)$(CAB_CHAR2)$(CAB_CHAR3)
 403   endif
 404 else
 405   JDK_UPDATE_VER := 0
 406 endif
 407 
 408 RC_FLAGS = /l 0x409 /r
 409 
 410 ifeq ($(VARIANT), OPT)
 411   RC_FLAGS += -d NDEBUG 
 412 else
 413   RC_FLAGS += $(MS_RC_DEBUG_OPTION)
 414 endif 
 415 
 416 # Values for the RC variables defined in RC_FLAGS
 417 JDK_RC_BUILD_ID = $(FULL_VERSION)
 418 JDK_RC_COMPANY = $(COMPANY_NAME)
 419 JDK_RC_COMPONENT = $(PRODUCT_NAME) $(JDK_RC_PLATFORM_NAME) binary
 420 JDK_RC_VER = \
 421     $(JDK_MINOR_VERSION).$(JDK_MICRO_VERSION).$(JDK_UPDATE_VER).$(COOKED_BUILD_NUMBER)
 422 JDK_RC_COPYRIGHT = Copyright \xA9 $(COPYRIGHT_YEAR)
 423 JDK_RC_NAME = \
 424     $(PRODUCT_NAME) $(JDK_RC_PLATFORM_NAME) $(JDK_MINOR_VERSION) $(JDK_UPDATE_META_TAG)
 425 JDK_RC_FVER = \
 426     $(JDK_MINOR_VERSION),$(JDK_MICRO_VERSION),$(JDK_UPDATE_VER),$(COOKED_BUILD_NUMBER)
 427 
 428 # JDK name required here
 429 RC_FLAGS += -d "JDK_BUILD_ID=$(JDK_RC_BUILD_ID)" \
 430             -d "JDK_COMPANY=$(JDK_RC_COMPANY)" \
 431             -d "JDK_COMPONENT=$(JDK_RC_COMPONENT)" \
 432             -d "JDK_VER=$(JDK_RC_VER)" \
 433             -d "JDK_COPYRIGHT=$(JDK_RC_COPYRIGHT)" \
 434             -d "JDK_NAME=$(JDK_RC_NAME)" \
 435             -d "JDK_FVER=$(JDK_RC_FVER)"