compile.make 10.7 KB
Newer Older
D
duke 已提交
1
#
2
# Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
D
duke 已提交
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
19 20 21
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
D
duke 已提交
22 23 24 25
#  
#

# Generic compiler settings
26
!if "x$(CXX)" == "x"
27
CXX=cl.exe
28
!endif
D
duke 已提交
29

30
# CXX Flags: (these vary slightly from VC6->VS2003->VS2005 compilers)
D
duke 已提交
31 32 33 34
#   /nologo   Supress copyright message at every cl.exe startup
#   /W3       Warning level 3
#   /Zi       Include debugging information
#   /WX       Treat any warning error as a fatal error
35
#   /MD       Use dynamic multi-threaded runtime (msvcrt.dll or msvc*NN.dll)
D
duke 已提交
36 37 38 39 40 41 42 43 44 45 46
#   /MTd      Use static multi-threaded runtime debug versions
#   /O1       Optimize for size (/Os), skips /Oi
#   /O2       Optimize for speed (/Ot), adds /Oi to /O1
#   /Ox       Old "all optimizations flag" for VC6 (in /O1)
#   /Oy       Use frame pointer register as GP reg (in /Ox and /O1)
#   /GF       Merge string constants and put in read-only memory (in /O1)
#   /Gy       Func level link (in /O1, allows for link-time func ordering)
#   /Gs       Inserts stack probes (in /O1)
#   /GS       Inserts security stack checks in some functions (VS2005 default)
#   /Oi       Use intrinsics (in /O2)
#   /Od       Disable all optimizations
47
#   /MP       Use multiple cores for compilation
D
duke 已提交
48 49
#
# NOTE: Normally following any of the above with a '-' will turn off that flag
50 51 52 53
#
# 6655385: For VS2003/2005 we now specify /Oy- (disable frame pointer
# omission.)  This has little to no effect on performance while vastly
# improving the quality of crash log stack traces involving jvm.dll.
D
duke 已提交
54 55

# These are always used in all compiles
S
sla 已提交
56
CXX_FLAGS=$(EXTRA_CFLAGS) /nologo /W3 /WX
D
duke 已提交
57

58 59
# Let's add debug information when Full Debug Symbols is enabled
!if "$(ENABLE_FULL_DEBUG_SYMBOLS)" == "1"
60
CXX_FLAGS=$(CXX_FLAGS) /Zi
61
!endif
D
duke 已提交
62 63 64 65 66

# Based on BUILDARCH we add some flags and select the default compiler name
!if "$(BUILDARCH)" == "ia64"
MACHINE=IA64
DEFAULT_COMPILER_NAME=VS2003
67
CXX_FLAGS=$(CXX_FLAGS) /D "CC_INTERP" /D "_LP64" /D "IA64"
D
duke 已提交
68 69 70 71 72
!endif

!if "$(BUILDARCH)" == "amd64"
MACHINE=AMD64
DEFAULT_COMPILER_NAME=VS2005
73
CXX_FLAGS=$(CXX_FLAGS) /D "_LP64" /D "AMD64"
D
duke 已提交
74 75 76 77 78 79
LP64=1
!endif

!if "$(BUILDARCH)" == "i486"
MACHINE=I386
DEFAULT_COMPILER_NAME=VS2003
80
CXX_FLAGS=$(CXX_FLAGS) /D "IA32"
D
duke 已提交
81 82 83 84
!endif

# Sanity check, this is the default if not amd64, ia64, or i486
!ifndef DEFAULT_COMPILER_NAME
85
CXX=ARCH_ERROR
D
duke 已提交
86 87
!endif

88
CXX_FLAGS=$(CXX_FLAGS) /D "WIN32" /D "_WINDOWS"
89
# Must specify this for sharedRuntimeTrig.cpp
90
CXX_FLAGS=$(CXX_FLAGS) /D "VM_LITTLE_ENDIAN"
91 92

# Used for platform dispatching
93 94 95 96 97 98
CXX_FLAGS=$(CXX_FLAGS) /D TARGET_OS_FAMILY_windows
CXX_FLAGS=$(CXX_FLAGS) /D TARGET_ARCH_$(Platform_arch)
CXX_FLAGS=$(CXX_FLAGS) /D TARGET_ARCH_MODEL_$(Platform_arch_model)
CXX_FLAGS=$(CXX_FLAGS) /D TARGET_OS_ARCH_windows_$(Platform_arch)
CXX_FLAGS=$(CXX_FLAGS) /D TARGET_OS_ARCH_MODEL_windows_$(Platform_arch_model)
CXX_FLAGS=$(CXX_FLAGS) /D TARGET_COMPILER_visCPP
99 100


101 102 103 104
# MSC_VER is a 4 digit number that tells us what compiler is being used
#    and is generated when the local.make file is created by build.make
#    via the script get_msc_ver.sh
#
D
duke 已提交
105 106 107 108 109 110 111
#    If MSC_VER is set, it overrides the above default setting.
#    But it should be set.
#    Possible values:
#      1200 is for VC6
#      1300 and 1310 is VS2003 or VC7
#      1399 is our fake number for the VS2005 compiler that really isn't 1400
#      1400 is for VS2005
112
#      1500 is for VS2008
113
#      1600 is for VS2010
114
#      1700 is for VS2012
D
duke 已提交
115 116 117 118 119 120
#    Do not confuse this MSC_VER with the predefined macro _MSC_VER that the
#    compiler provides, when MSC_VER==1399, _MSC_VER will be 1400.
#    Normally they are the same, but a pre-release of the VS2005 compilers
#    in the Windows 64bit Platform SDK said it was 1400 when it was really
#    closer to VS2003 in terms of option spellings, so we use 1399 for that
#    1400 version that really isn't 1400.
121
#    See the file get_msc_ver.sh for more info.
D
duke 已提交
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
!if "x$(MSC_VER)" == "x"
COMPILER_NAME=$(DEFAULT_COMPILER_NAME)
!else
!if "$(MSC_VER)" == "1200"
COMPILER_NAME=VC6
!endif
!if "$(MSC_VER)" == "1300"
COMPILER_NAME=VS2003
!endif
!if "$(MSC_VER)" == "1310"
COMPILER_NAME=VS2003
!endif
!if "$(MSC_VER)" == "1399"
# Compiler might say 1400, but if it's 14.00.30701, it isn't really VS2005
COMPILER_NAME=VS2003
!endif
!if "$(MSC_VER)" == "1400"
COMPILER_NAME=VS2005
!endif
141 142 143
!if "$(MSC_VER)" == "1500"
COMPILER_NAME=VS2008
!endif
144 145 146
!if "$(MSC_VER)" == "1600"
COMPILER_NAME=VS2010
!endif
147 148 149
!if "$(MSC_VER)" == "1700"
COMPILER_NAME=VS2012
!endif
150 151 152 153 154 155 156 157 158
!if "$(MSC_VER)" == "1800"
COMPILER_NAME=VS2013
!endif
!if "$(MSC_VER)" == "1900"
COMPILER_NAME=VS2015
!endif
!if "$(MSC_VER)" == "1912"
COMPILER_NAME=VS2017
!endif
159 160 161
!if "$(MSC_VER)" == "1913"
COMPILER_NAME=VS2017
!endif
D
duke 已提交
162 163 164 165 166 167 168 169 170
!endif

# By default, we do not want to use the debug version of the msvcrt.dll file
#   but if MFC_DEBUG is defined in the environment it will be used.
MS_RUNTIME_OPTION = /MD
!if "$(MFC_DEBUG)" == "true"
MS_RUNTIME_OPTION = /MTd /D "_DEBUG"
!endif

171 172 173
# VS2012 and later won't work with:
#     /D _STATIC_CPPLIB /D _DISABLE_DEPRECATE_STATIC_CPPLIB
!if "$(MSC_VER)" < "1700"
D
duke 已提交
174
# Always add the _STATIC_CPPLIB flag
175
STATIC_CPPLIB_OPTION = /D _STATIC_CPPLIB /D _DISABLE_DEPRECATE_STATIC_CPPLIB
D
duke 已提交
176
MS_RUNTIME_OPTION = $(MS_RUNTIME_OPTION) $(STATIC_CPPLIB_OPTION)
177
!endif
178
CXX_FLAGS=$(CXX_FLAGS) $(MS_RUNTIME_OPTION)
D
duke 已提交
179 180 181 182 183 184

# How /GX option is spelled
GX_OPTION = /GX

# Optimization settings for various versions of the compilers and types of
#    builds. Three basic sets of settings: product, fastdebug, and debug.
185
#    These get added into CXX_FLAGS as needed by other makefiles.
D
duke 已提交
186 187 188 189 190 191 192
!if "$(COMPILER_NAME)" == "VC6"
PRODUCT_OPT_OPTION   = /Ox /Os /Gy /GF
FASTDEBUG_OPT_OPTION = /Ox /Os /Gy /GF
DEBUG_OPT_OPTION     = /Od
!endif

!if "$(COMPILER_NAME)" == "VS2003"
193 194
PRODUCT_OPT_OPTION   = /O2 /Oy-
FASTDEBUG_OPT_OPTION = /O2 /Oy-
D
duke 已提交
195
DEBUG_OPT_OPTION     = /Od
E
erikj 已提交
196
SAFESEH_FLAG = /SAFESEH
D
duke 已提交
197 198 199
!endif

!if "$(COMPILER_NAME)" == "VS2005"
200 201
PRODUCT_OPT_OPTION   = /O2 /Oy-
FASTDEBUG_OPT_OPTION = /O2 /Oy-
D
duke 已提交
202 203 204 205 206 207 208
DEBUG_OPT_OPTION     = /Od
GX_OPTION = /EHsc
# This VS2005 compiler has /GS as a default and requires bufferoverflowU.lib 
#    on the link command line, otherwise we get missing __security_check_cookie
#    externals at link time. Even with /GS-, you need bufferoverflowU.lib.
#    NOTE: Currently we decided to not use /GS-
BUFFEROVERFLOWLIB = bufferoverflowU.lib
209
LD_FLAGS = /manifest $(LD_FLAGS) $(BUFFEROVERFLOWLIB)
210 211
# Manifest Tool - used in VS2005 and later to adjust manifests stored
# as resources inside build artifacts.
212
!if "x$(MT)" == "x"
213 214
MT=mt.exe
!endif
E
erikj 已提交
215
SAFESEH_FLAG = /SAFESEH
216
!endif
217 218 219 220 221 222

!if "$(COMPILER_NAME)" == "VS2008"
PRODUCT_OPT_OPTION   = /O2 /Oy-
FASTDEBUG_OPT_OPTION = /O2 /Oy-
DEBUG_OPT_OPTION     = /Od
GX_OPTION = /EHsc
223
LD_FLAGS = /manifest $(LD_FLAGS)
224
MP_FLAG = /MP
225 226
# Manifest Tool - used in VS2005 and later to adjust manifests stored
# as resources inside build artifacts.
227
!if "x$(MT)" == "x"
228
MT=mt.exe
D
duke 已提交
229
!endif
E
erikj 已提交
230
SAFESEH_FLAG = /SAFESEH
231
!endif
D
duke 已提交
232

233 234 235 236 237
!if "$(COMPILER_NAME)" == "VS2010"
PRODUCT_OPT_OPTION   = /O2 /Oy-
FASTDEBUG_OPT_OPTION = /O2 /Oy-
DEBUG_OPT_OPTION     = /Od
GX_OPTION = /EHsc
238
LD_FLAGS = /manifest $(LD_FLAGS)
239
MP_FLAG = /MP
240 241
# Manifest Tool - used in VS2005 and later to adjust manifests stored
# as resources inside build artifacts.
242
!if "x$(MT)" == "x"
243
MT=mt.exe
244
!endif
245
!if "$(BUILDARCH)" == "i486"
246
LD_FLAGS = /SAFESEH $(LD_FLAGS)
247
!endif
248 249
!endif

250 251 252 253 254 255
!if "$(COMPILER_NAME)" == "VS2012"
PRODUCT_OPT_OPTION   = /O2 /Oy-
FASTDEBUG_OPT_OPTION = /O2 /Oy-
DEBUG_OPT_OPTION     = /Od
GX_OPTION = /EHsc
LD_FLAGS = /manifest $(LD_FLAGS)
256
MP_FLAG = /MP
257 258 259 260 261
# Manifest Tool - used in VS2005 and later to adjust manifests stored
# as resources inside build artifacts.
!if "x$(MT)" == "x"
MT=mt.exe
!endif
E
erikj 已提交
262
SAFESEH_FLAG = /SAFESEH
263
!endif
E
erikj 已提交
264

265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310
!if "$(COMPILER_NAME)" == "VS2013"
PRODUCT_OPT_OPTION   = /O2 /Oy-
FASTDEBUG_OPT_OPTION = /O2 /Oy-
DEBUG_OPT_OPTION     = /Od
GX_OPTION = /EHsc
LD_FLAGS = /manifest $(LD_FLAGS)
MP_FLAG = /MP
# Manifest Tool - used in VS2005 and later to adjust manifests stored
# as resources inside build artifacts.
!if "x$(MT)" == "x"
MT=mt.exe
!endif
SAFESEH_FLAG = /SAFESEH
!endif


!if "$(COMPILER_NAME)" == "VS2015"
PRODUCT_OPT_OPTION   = /O2 /Oy-
FASTDEBUG_OPT_OPTION = /O2 /Oy-
DEBUG_OPT_OPTION     = /Od
GX_OPTION = /EHsc
LD_FLAGS = /manifest $(LD_FLAGS)
MP_FLAG = /MP
# Manifest Tool - used in VS2005 and later to adjust manifests stored
# as resources inside build artifacts.
!if "x$(MT)" == "x"
MT=mt.exe
!endif
SAFESEH_FLAG = /SAFESEH
!endif

!if "$(COMPILER_NAME)" == "VS2017"
PRODUCT_OPT_OPTION   = /O2 /Oy-
FASTDEBUG_OPT_OPTION = /O2 /Oy-
DEBUG_OPT_OPTION     = /Od
GX_OPTION = /EHsc
LD_FLAGS = /manifest $(LD_FLAGS)
MP_FLAG = /MP
# Manifest Tool - used in VS2005 and later to adjust manifests stored
# as resources inside build artifacts.
!if "x$(MT)" == "x"
MT=mt.exe
!endif
SAFESEH_FLAG = /SAFESEH
!endif

E
erikj 已提交
311 312
!if "$(BUILDARCH)" == "i486"
LD_FLAGS = $(SAFESEH_FLAG) $(LD_FLAGS)
313 314
!endif

315 316
CXX_FLAGS = $(CXX_FLAGS) $(MP_FLAG)

D
duke 已提交
317 318 319 320 321 322 323
# If NO_OPTIMIZATIONS is defined in the environment, turn everything off
!ifdef NO_OPTIMIZATIONS
PRODUCT_OPT_OPTION   = $(DEBUG_OPT_OPTION)
FASTDEBUG_OPT_OPTION = $(DEBUG_OPT_OPTION)
!endif

# Generic linker settings
324
!if "x$(LD)" == "x"
325
LD=link.exe
326
!endif
327
LD_FLAGS= $(LD_FLAGS) kernel32.lib user32.lib gdi32.lib winspool.lib \
D
duke 已提交
328
 comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib \
329
 uuid.lib Wsock32.lib winmm.lib version.lib /nologo /machine:$(MACHINE) /opt:REF \
330 331 332 333
 /opt:ICF,8
!if "$(ENABLE_FULL_DEBUG_SYMBOLS)" == "1"
LD_FLAGS= $(LD_FLAGS) /map /debug
!endif
D
duke 已提交
334

335 336

!if $(MSC_VER) >= 1600 
337
LD_FLAGS= $(LD_FLAGS) psapi.lib
338 339
!endif

D
duke 已提交
340
# Resource compiler settings
341
!if "x$(RC)" == "x"
D
duke 已提交
342
RC=rc.exe
343
!endif
D
duke 已提交
344 345 346 347 348
RC_FLAGS=/D "HS_VER=$(HS_VER)" \
	 /D "HS_DOTVER=$(HS_DOTVER)" \
	 /D "HS_BUILD_ID=$(HS_BUILD_ID)" \
	 /D "JDK_VER=$(JDK_VER)" \
	 /D "JDK_DOTVER=$(JDK_DOTVER)" \
349
	 /D "HS_COMPANY=$(COMPANY_NAME)" \
D
duke 已提交
350 351 352 353 354 355
	 /D "HS_FILEDESC=$(HS_FILEDESC)" \
	 /D "HS_COPYRIGHT=$(HS_COPYRIGHT)" \
	 /D "HS_FNAME=$(HS_FNAME)" \
	 /D "HS_INTERNAL_NAME=$(HS_INTERNAL_NAME)" \
	 /D "HS_NAME=$(HS_NAME)"

356
# Need this to match the CXX_FLAGS settings
D
duke 已提交
357 358 359 360
!if "$(MFC_DEBUG)" == "true"
RC_FLAGS = $(RC_FLAGS) /D "_DEBUG"
!endif