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