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