make/common/Defs-windows.gmk

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

mercurial