make/common/Defs-windows.gmk

Sun, 21 Jun 2009 23:50:28 -0700

author
tbell
date
Sun, 21 Jun 2009 23:50:28 -0700
changeset 85
65b66117dbd7
parent 49
e2f388853a9d
child 88
ffb590b42ed1
permissions
-rw-r--r--

Merge

duke@1 1 #
xdono@49 2 # Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved.
duke@1 3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@1 4 #
duke@1 5 # This code is free software; you can redistribute it and/or modify it
duke@1 6 # under the terms of the GNU General Public License version 2 only, as
duke@1 7 # published by the Free Software Foundation. Sun designates this
duke@1 8 # particular file as subject to the "Classpath" exception as provided
duke@1 9 # by Sun in the LICENSE file that accompanied this code.
duke@1 10 #
duke@1 11 # This code is distributed in the hope that it will be useful, but WITHOUT
duke@1 12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@1 13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@1 14 # version 2 for more details (a copy is included in the LICENSE file that
duke@1 15 # accompanied this code).
duke@1 16 #
duke@1 17 # You should have received a copy of the GNU General Public License version
duke@1 18 # 2 along with this work; if not, write to the Free Software Foundation,
duke@1 19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@1 20 #
duke@1 21 # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@1 22 # CA 95054 USA or visit www.sun.com if you need additional information or
duke@1 23 # have any questions.
duke@1 24 #
duke@1 25
duke@1 26 #
duke@1 27 # Makefile to specify compiler flags for programs and libraries
duke@1 28 # targeted to Windows builds. Should not contain any rules.
duke@1 29 #
duke@1 30
duke@1 31 # Get shared JDK settings
duke@1 32 include $(BUILDDIR)/common/shared/Defs.gmk
duke@1 33
duke@1 34 # CC compiler object code output directive flag value
duke@1 35 CC_OBJECT_OUTPUT_FLAG = -Fo
duke@1 36 CC_PROGRAM_OUTPUT_FLAG = -Fe
duke@1 37
duke@1 38 # The suffix applied to the library name for FDLIBM
duke@1 39 FDDLIBM_SUFFIX = lib
duke@1 40 # The suffix applied to scripts (.bat for windows, nothing for unix)
duke@1 41 SCRIPT_SUFFIX = .bat
duke@1 42
duke@1 43 HPIS = windows
duke@1 44 # LIB_LOCATION, which for windows identifies where .exe files go, may be
duke@1 45 # set by each GNUmakefile. The default is BINDIR.
duke@1 46 ifndef LIB_LOCATION
duke@1 47 LIB_LOCATION = $(BINDIR)
duke@1 48 endif # LIB_LOCATION
duke@1 49
duke@1 50 ifndef PLATFORM_SRC
duke@1 51 PLATFORM_SRC = $(TOPDIR)/src/windows
duke@1 52 endif # PLATFORM_SRC
duke@1 53
duke@1 54 # for backwards compatability, the old "win32" is used here instead of
duke@1 55 # the more proper "windows"
duke@1 56 PLATFORM_INCLUDE_NAME = win32
duke@1 57 PLATFORM_INCLUDE = $(INCLUDEDIR)/$(PLATFORM_INCLUDE_NAME)
duke@1 58
duke@1 59 # The following DLL's are considered MS runtime libraries and should
duke@1 60 # not to be REBASEd, see deploy/make/common/Release.gmk.
tbell@33 61 # msvcrt.dll, msvcrnn.dll [msvcr71 or msvcr80 or msvcr90] : Microsoft runtimes
duke@1 62 MS_RUNTIME_LIBRARIES = msvcrt.dll
tbell@33 63 MSVCRNN_DLL =
duke@1 64 ifeq ($(ARCH_DATA_MODEL), 32)
duke@1 65 ifeq ($(COMPILER_VERSION), VS2003)
tbell@33 66 MSVCRNN_DLL = msvcr71.dll
tbell@33 67 MSVCPNN_DLL = msvcp71.dll
tbell@33 68 MS_RUNTIME_LIBRARIES += $(MSVCRNN_DLL)
tbell@33 69 endif
tbell@33 70 ifeq ($(COMPILER_VERSION), VS2005)
tbell@33 71 MSVCRNN_DLL = msvcr80.dll
tbell@33 72 MSVCPNN_DLL = msvcp80.dll
tbell@33 73 MS_RUNTIME_LIBRARIES += $(MSVCRNN_DLL)
tbell@33 74 endif
tbell@33 75 ifeq ($(COMPILER_VERSION), VS2008)
tbell@33 76 MSVCRNN_DLL = msvcr90.dll
tbell@33 77 MSVCPNN_DLL = msvcp90.dll
tbell@33 78 MS_RUNTIME_LIBRARIES += $(MSVCRNN_DLL)
duke@1 79 endif
duke@1 80 endif
duke@1 81
duke@1 82 # C Compiler flag definitions
duke@1 83
duke@1 84 #
duke@1 85 # Default optimization
duke@1 86 #
duke@1 87 ifeq ($(CC_VERSION),msvc)
duke@1 88 # Visual Studio .NET 2003 or VS2003 compiler option definitions:
duke@1 89 # -O1 Favors reduced size over speed (-Og -Os -Oy -Ob2 -Gs -GF -Gy)
duke@1 90 # -O2 Favors speed over reduced size (-Og -Oi -Ot -Oy -Ob2 -Gs -GF -Gy)
duke@1 91 # -Ox Full optimization (use -O2) (-Og -Oi -Ot -Oy -Ob2)
duke@1 92 # (Removed in Visual Studio 2005 or VS2005)
duke@1 93 # -Ob2 More aggressive inlining
duke@1 94 # -Og Global optimizations
duke@1 95 # -Oi Replace some functions with intrinsic or special forms
duke@1 96 # -Op Improve floating point calculations (disables some optimizations)
duke@1 97 # (Replaced with -fp:precise in VS2005, /Op is default now)
duke@1 98 # -Os Favor small code
duke@1 99 # -Ot Favor faster code
duke@1 100 # -Oy Frame pointer omission
duke@1 101 # -GB Optimize for pentium (old VC6 option?)
duke@1 102 # -G6 VS2003 version of -GB?
duke@1 103 # -GF Pool strings in read-only memory
duke@1 104 # -Gf Pool strings in read-write memory (the default)
duke@1 105 # -Gs Controls stack probess
duke@1 106 # -GS Adds buffer overflow checks on stacks
duke@1 107 # (Default in VS2005)
duke@1 108 # -GX Enables exception handling
duke@1 109 # (Replaced with /EHsc in VS2005)
duke@1 110 # -Gy Function level linking only
duke@1 111 #
duke@1 112 # NOTE: With VC6, -Ox included -Gs.
duke@1 113 # NOTE: With VC6, -Ox, -O1, and -O2 used -Ob1, not -Ob2.
duke@1 114 # NOTE: With VC6, -O1 and -O2 used -Gf, not -GF.
duke@1 115 #
duke@1 116 ifeq ($(COMPILER_VERSION), VC6)
duke@1 117 # VC6 (6.2) msvc compiler (the way Tiger and early Mustang were built)
duke@1 118 # Automatic precompiled header option to use (if COMPILE_APPROACH=batch)
duke@1 119 AUTOMATIC_PCH_OPTION =
duke@1 120 GX_OPTION = -GX
duke@1 121 ifeq ($(ARCH_DATA_MODEL), 32)
duke@1 122 CC_HIGHEST_OPT = -Ox -Gy -Os -GB
duke@1 123 CC_HIGHER_OPT = -Ox -Gy -Os -GB
duke@1 124 CC_LOWER_OPT = -Ox -Gy -Os -GB
duke@1 125 else
duke@1 126 CC_HIGHEST_OPT = -Ox -Gy -Op
duke@1 127 CC_HIGHER_OPT = -Ox -Gy -Op
duke@1 128 CC_LOWER_OPT = -Ox -Gy -Op
duke@1 129 endif
duke@1 130 endif
duke@1 131 ifeq ($(COMPILER_VERSION), VS2003)
duke@1 132 # Automatic precompiled header option to use (if COMPILE_APPROACH=batch)
duke@1 133 AUTOMATIC_PCH_OPTION = -YX
duke@1 134 # Also known as VC7 compiler
duke@1 135 GX_OPTION = -GX
duke@1 136 ifeq ($(ARCH_DATA_MODEL), 32)
duke@1 137 # Lowered opt level to try and reduce footprint, dll size especially.
duke@1 138 # Was: CC_HIGHEST_OPT = -O2 -G6
duke@1 139 # Was: CC_HIGHER_OPT = -O2
duke@1 140 CC_HIGHEST_OPT = -O2
duke@1 141 CC_HIGHER_OPT = -O1
duke@1 142 CC_LOWER_OPT = -O1
duke@1 143 else
duke@1 144 CC_HIGHEST_OPT = -O2 -Op
duke@1 145 CC_HIGHER_OPT = -O2 -Op
duke@1 146 CC_LOWER_OPT = -O1 -Op
duke@1 147 endif
duke@1 148 endif
duke@1 149 ifeq ($(COMPILER_VERSION), VS2005)
duke@1 150 # Automatic precompiled header option to use (if COMPILE_APPROACH=batch)
duke@1 151 AUTOMATIC_PCH_OPTION =
duke@1 152 # VS2005 compiler, only with Platform SDK right now?
duke@1 153 GX_OPTION = -EHsc
duke@1 154 ifeq ($(ARCH_DATA_MODEL), 32)
duke@1 155 CC_HIGHEST_OPT = -O2
duke@1 156 CC_HIGHER_OPT = -O1
duke@1 157 CC_LOWER_OPT = -O1
duke@1 158 else
duke@1 159 CC_HIGHEST_OPT = -O2
duke@1 160 CC_HIGHER_OPT = -O1
duke@1 161 CC_LOWER_OPT = -O1
duke@1 162 endif
duke@1 163 endif
tbell@33 164 ifeq ($(COMPILER_VERSION), VS2008)
tbell@33 165 # Automatic precompiled header option to use (if COMPILE_APPROACH=batch)
tbell@33 166 AUTOMATIC_PCH_OPTION =
tbell@33 167 GX_OPTION = -EHsc
tbell@33 168 ifeq ($(ARCH_DATA_MODEL), 32)
tbell@33 169 CC_HIGHEST_OPT = -O2
tbell@33 170 CC_HIGHER_OPT = -O1
tbell@33 171 CC_LOWER_OPT = -O1
tbell@33 172 else
tbell@33 173 CC_HIGHEST_OPT = -O2
tbell@33 174 CC_HIGHER_OPT = -O1
tbell@33 175 CC_LOWER_OPT = -O1
tbell@33 176 endif
tbell@33 177 endif
duke@1 178 CC_NO_OPT = -Od
duke@1 179 else # CC_VERSION
duke@1 180 # GCC not supported, but left for historical reference...
duke@1 181 CC_HIGHEST_OPT = -O3
duke@1 182 CC_HIGHER_OPT = -O2
duke@1 183 CC_LOWER_OPT = -O2
duke@1 184 CC_NO_OPT =
duke@1 185 endif
duke@1 186
duke@1 187 # If NO_OPTIMIZATIONS is defined in the environment, turn all optimzations off
duke@1 188 ifdef NO_OPTIMIZATIONS
duke@1 189 CC_HIGHEST_OPT = $(CC_NO_OPT)
duke@1 190 CC_HIGHER_OPT = $(CC_NO_OPT)
duke@1 191 CC_LOWER_OPT = $(CC_NO_OPT)
duke@1 192 endif
duke@1 193
duke@1 194 ifeq ($(PRODUCT), java)
duke@1 195 _OPT = $(CC_HIGHER_OPT)
duke@1 196 else
duke@1 197 _OPT = $(CC_LOWER_OPT)
duke@1 198 endif
duke@1 199
duke@1 200 # Select the runtime support library carefully, need to be consistent
duke@1 201 #
duke@1 202 # VS2003 compiler option definitions:
duke@1 203 # -MD Use dynamic multi-threaded runtime library
duke@1 204 # -MDd Use debug version (don't use, doesn't mix with -MD DLL's)
duke@1 205 # -MT Use static multi-threaded runtime library (-ML is going away)
duke@1 206 # -MTd Use static debug version (better than -MDd, no runtime issues)
duke@1 207 # -D_DEBUG Change use of malloc/free/etc to use special debug ones (-MTd)
duke@1 208 #
tbell@33 209 # NOTE: We also will use /D _STATIC_CPPLIB so we don't need msvcpnn.dll
duke@1 210 #
duke@1 211 ifeq ($(MS_RUNTIME_STATIC),true)
duke@1 212 MS_RUNTIME_OPTION=-MT
duke@1 213 else
duke@1 214 MS_RUNTIME_OPTION=-MD
duke@1 215 endif
duke@1 216 # The _DEBUG macro option (changes things like malloc to use debug version)
duke@1 217 MS_RUNTIME_DEBUG_OPTION=
duke@1 218 MS_RC_DEBUG_OPTION=
duke@1 219 # Externally set environment variable can force any build to use the debug vers
duke@1 220 ifeq ($(MFC_DEBUG), true)
duke@1 221 ifeq ($(MS_RUNTIME_STATIC),true)
duke@1 222 MS_RUNTIME_OPTION=-MTd
duke@1 223 else
duke@1 224 # This MS debugging flag forces a dependence on the debug
duke@1 225 # version of the runtime library (MSVCRTD.DLL), as does -MDd.
duke@1 226 # We cannot re-distribute this debug runtime.
duke@1 227 MS_RUNTIME_OPTION=-MDd
duke@1 228 endif
duke@1 229 MS_RUNTIME_DEBUG_OPTION= -D_DEBUG
duke@1 230 MS_RC_DEBUG_OPTION= -d _DEBUG
duke@1 231 endif
duke@1 232
duke@1 233 # Always add _STATIC_CPPLIB definition
duke@1 234 STATIC_CPPLIB_OPTION = /D _STATIC_CPPLIB
duke@1 235 MS_RUNTIME_OPTION += $(STATIC_CPPLIB_OPTION)
duke@1 236
duke@1 237 ifeq ($(CC_VERSION),msvc)
duke@1 238 # VS2003 compiler option definitions:
duke@1 239 # -Zi Cause *.pdb file to be created, full debug information
duke@1 240 # -Z7 Full debug inside the .obj, no .pdb
duke@1 241 # -Zd Basic debug, no local variables? In the .obj
duke@1 242 # -Zl Don't add runtime library name to obj file?
duke@1 243 # -Od Turns off optimization and speeds compilation
duke@1 244 # -YX -Fp/.../foobar.pch Use precompiled headers (try someday?)
duke@1 245 # -nologo Don't print out startup message
duke@1 246 # /D _STATIC_CPPLIB
tbell@33 247 # Use static link for the C++ runtime (so msvcpnn.dll not needed)
duke@1 248 #
duke@1 249 CFLAGS_COMMON += -Zi -nologo
duke@1 250 CFLAGS_OPT = $(POPT)
duke@1 251 CFLAGS_DBG = -Od $(MS_RUNTIME_DEBUG_OPTION)
duke@1 252
duke@1 253 # Starting from VS2005 the wchar_t is handled as a built-in C/C++ data type
duke@1 254 # by default. However, we expect the wchar_t to be a typedef to the
duke@1 255 # unsigned short data type. The -Zc:wchar_t- option restores the old
duke@1 256 # behavior (as seen in VS2003) to avoid massive code modifications.
duke@1 257 # When/if our code will be "C/C++ Standard"-compliant (at least in the area
duke@1 258 # of handling the wchar_t type), the option won't be necessary.
duke@1 259 ifeq ($(ARCH_DATA_MODEL), 32)
duke@1 260 CFLAGS_VS2005 += -Zc:wchar_t-
duke@1 261 else
duke@1 262 # The 64bit Platform SDK we use (April 2005) doesn't like this option
duke@1 263 ifneq ($(CC_VER), 14.00.40310.41)
duke@1 264 CFLAGS_VS2005 += -Zc:wchar_t-
duke@1 265 endif
duke@1 266 endif
duke@1 267
duke@1 268 # All builds get the same runtime setting
duke@1 269 CFLAGS_COMMON += $(MS_RUNTIME_OPTION) $(CFLAGS_$(COMPILER_VERSION))
duke@1 270
duke@1 271
duke@1 272 LDEBUG = /debug
duke@1 273
duke@1 274 ifeq ($(VTUNE_SUPPORT), true)
duke@1 275 OTHER_CFLAGS = -Z7 -Ox
duke@1 276 LDEBUG += /pdb:NONE
duke@1 277 endif
duke@1 278
duke@1 279 # The new Platform SDK and VS2005 has /GS as a default and requires
duke@1 280 # bufferoverflowU.lib on the link command line, otherwise
duke@1 281 # we get missing __security_check_cookie externals at link time.
duke@1 282 BUFFEROVERFLOWLIB = bufferoverflowU.lib
duke@1 283 # Always add bufferoverflowU.lib to VS2005 link commands (pack uses LDDFLAGS)
duke@1 284 LFLAGS_VS2005 = $(BUFFEROVERFLOWLIB)
duke@1 285
duke@1 286 # LFLAGS are the flags given to $(LINK) and used to build the actual DLL file
duke@1 287 BASELFLAGS = -nologo /opt:REF /incremental:no
duke@1 288 LFLAGS = $(BASELFLAGS) $(LDEBUG) $(EXTRA_LFLAGS) $(LFLAGS_$(COMPILER_VERSION))
duke@1 289 LDDFLAGS += $(LFLAGS_$(COMPILER_VERSION))
duke@1 290
duke@1 291 endif
duke@1 292
duke@1 293 #
duke@1 294 # Preprocessor macro definitions
duke@1 295 #
duke@1 296 CPPFLAGS_COMMON = -DWIN32 -DIAL -D_LITTLE_ENDIAN
duke@1 297 ifeq ($(ARCH), amd64)
duke@1 298 CPPFLAGS_COMMON += -D_AMD64_ -Damd64
duke@1 299 else
duke@1 300 CPPFLAGS_COMMON += -DWIN32 -D_X86_ -Dx86
duke@1 301 endif
duke@1 302 CPPFLAGS_COMMON += -DWIN32_LEAN_AND_MEAN
duke@1 303
duke@1 304 #
duke@1 305 # Output options (use specific filenames to avoid parallel compile errors)
duke@1 306 #
duke@1 307 CFLAGS_COMMON += -Fd$(OBJDIR)/$(basename $(@F)).pdb -Fm$(OBJDIR)/$(basename $(@F)).map
duke@1 308
duke@1 309 #
duke@1 310 # Add warnings and extra on 64bit issues
duke@1 311 #
duke@1 312 ifeq ($(ARCH_DATA_MODEL), 64)
duke@1 313 CFLAGS_COMMON += -Wp64
duke@1 314 endif
duke@1 315 CFLAGS_COMMON += -W$(COMPILER_WARNING_LEVEL)
duke@1 316
duke@1 317 #
duke@1 318 # Treat compiler warnings as errors, if requested
duke@1 319 #
duke@1 320 ifeq ($(COMPILER_WARNINGS_FATAL),true)
duke@1 321 CFLAGS_COMMON += -WX
duke@1 322 endif
duke@1 323
duke@1 324 CPPFLAGS_OPT =
duke@1 325 CPPFLAGS_DBG = -DDEBUG -DLOGGING
duke@1 326
duke@1 327 CXXFLAGS_COMMON = $(CFLAGS_COMMON)
duke@1 328 CXXFLAGS_OPT = $(CFLAGS_OPT)
duke@1 329 CXXFLAGS_DBG = $(CFLAGS_DBG)
duke@1 330
duke@1 331 ifneq ($(LIBRARY),fdlibm)
duke@1 332 EXTRA_LIBS += advapi32.lib
duke@1 333 endif
duke@1 334
duke@1 335 #
duke@1 336 # Path and option to link against the VM, if you have to.
duke@1 337 #
duke@1 338 JVMLIB = $(BOOTDIR)/lib/jvm.lib
duke@1 339 JAVALIB =
duke@1 340
duke@1 341 ifeq ($(CC_VERSION), msvc)
duke@1 342 CC_DEPEND = -FD
duke@1 343 CC_DEPEND_FILTER =
duke@1 344 else # CC_VERSION
duke@1 345 # not supported, but left for historical reference...
duke@1 346 CC_DEPEND = -MM
duke@1 347 CC_DEPEND_FILTER = $(SED) -e 's!$*\.$(OBJECT_SUFFIX)!$(dir $@)&!g'
duke@1 348 endif # CC_VERSION
duke@1 349
duke@1 350 LIBRARY_SUFFIX = dll
duke@1 351 LIB_SUFFIX = lib
duke@1 352
duke@1 353 # Settings for the VERSIONINFO tap on windows.
duke@1 354 VERSIONINFO_RESOURCE = $(TOPDIR)/src/windows/resource/version.rc
duke@1 355
duke@1 356 RC_FLAGS = /l 0x409 /r
duke@1 357
duke@1 358 ifeq ($(VARIANT), OPT)
duke@1 359 RC_FLAGS += -d NDEBUG
duke@1 360 else
duke@1 361 RC_FLAGS += $(MS_RC_DEBUG_OPTION)
duke@1 362 endif
duke@1 363
duke@1 364 ifndef COPYRIGHT_YEAR
duke@1 365 COPYRIGHT_YEAR = 2007
duke@1 366 endif
duke@1 367
duke@1 368 RC_FLAGS += -d "J2SE_BUILD_ID=$(FULL_VERSION)" \
duke@1 369 -d "J2SE_COMPANY=$(COMPANY_NAME)" \
duke@1 370 -d "J2SE_COMPONENT=$(PRODUCT_NAME) Platform SE binary" \
duke@1 371 -d "J2SE_VER=$(JDK_MINOR_VERSION).$(JDK_MICRO_VERSION).$(J2SE_UPDATE_VER).$(COOKED_BUILD_NUMBER)" \
duke@1 372 -d "J2SE_COPYRIGHT=Copyright \xA9 $(COPYRIGHT_YEAR)" \
duke@1 373 -d "J2SE_NAME=$(PRODUCT_NAME) Platform SE $(JDK_MINOR_VERSION) $(J2SE_UPDATE_META_TAG)" \
duke@1 374 -d "J2SE_FVER=$(JDK_VERSION)"

mercurial