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