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