blob: 7afe0b515e079f8b91a27e02d542bb709147645f [file] [log] [blame]
#
# Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
# 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. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# 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.
#
# 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.
#
#
# Makefile to specify compiler flags for programs and libraries
# targeted to Windows builds. Should not contain any rules.
#
# WARNING: This file is shared with other workspaces.
# So when it includes other files, it must use JDK_TOPDIR.
#
# Get shared JDK settings
include $(JDK_MAKE_SHARED_DIR)/Defs.gmk
# CC compiler object code output directive flag value
CC_OBJECT_OUTPUT_FLAG = -Fo
# The suffix applied to the library name for FDLIBM
FDDLIBM_SUFFIX = lib
# The suffix applied to scripts (.bat for windows, nothing for unix)
SCRIPT_SUFFIX = .bat
# LIB_LOCATION, which for windows identifies where .exe files go, may be
# set by each GNUmakefile. The default is BINDIR.
ifndef LIB_LOCATION
LIB_LOCATION = $(BINDIR)
endif # LIB_LOCATION
ifndef PLATFORM_SRC
PLATFORM_SRC = $(BUILDDIR)/../src/windows
endif # PLATFORM_SRC
# Location of the various .properties files specific to Windows platform
ifndef PLATFORM_PROPERTIES
PLATFORM_PROPERTIES = $(BUILDDIR)/../src/windows/lib
endif # PLATFORM_SRC
# Platform specific closed sources
ifndef OPENJDK
ifndef CLOSED_PLATFORM_SRC
CLOSED_PLATFORM_SRC = $(BUILDDIR)/../src/closed/windows
endif
endif
# for backwards compatability, the old "win32" is used here instead of
# the more proper "windows"
PLATFORM_INCLUDE_NAME = win32
PLATFORM_INCLUDE = $(INCLUDEDIR)/$(PLATFORM_INCLUDE_NAME)
# The following DLL's are considered MS runtime libraries and should
# not to be REBASEd, see deploy/make/common/Release.gmk.
# msvcr*.dll: Microsoft runtimes
ifeq ($(COMPILER_VERSION), VS2010)
MSVCRNN_DLL = msvcr100.dll
MSVCPNN_DLL = msvcp100.dll
MS_RUNTIME_LIBRARIES = $(MSVCRNN_DLL)
endif
EXTRA_LFLAGS += /LIBPATH:$(DXSDK_LIB_PATH)
# Full Debug Symbols has been enabled on Windows since JDK1.4.1.
# The Full Debug Symbols (FDS) default for VARIANT == OPT builds is
# enabled with debug info files ZIP'ed to save space. For VARIANT !=
# OPT builds, FDS is always enabled, after all a debug build without
# debug info isn't very useful. The ZIP_DEBUGINFO_FILES option only has
# meaning when FDS is enabled.
#
# If you invoke a build with FULL_DEBUG_SYMBOLS=0, then FDS will be
# disabled for a VARIANT == OPT build.
#
# Note: Use of a different variable name for the FDS override option
# versus the FDS enabled check is intentional (FULL_DEBUG_SYMBOLS
# versus ENABLE_FULL_DEBUG_SYMBOLS). For auto build systems that pass
# in options via environment variables, use of distinct variables
# prevents strange behaviours. For example, in a VARIANT != OPT build,
# the FULL_DEBUG_SYMBOLS environment variable will be 0, but the
# ENABLE_FULL_DEBUG_SYMBOLS make variable will be 1. If the same
# variable name is used, then different values can be picked up by
# different parts of the build. Just to be clear, we only need two
# variable names because the incoming option value can be overridden
# in some situations, e.g., a VARIANT != OPT build.
ifeq ($(VARIANT), OPT)
FULL_DEBUG_SYMBOLS ?= 1
ENABLE_FULL_DEBUG_SYMBOLS = $(FULL_DEBUG_SYMBOLS)
else
# debug variants always get Full Debug Symbols (if available)
ENABLE_FULL_DEBUG_SYMBOLS = 1
endif
_JUNK_ := $(shell \
echo >&2 "INFO: ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS)")
ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
ZIP_DEBUGINFO_FILES ?= 1
else
ZIP_DEBUGINFO_FILES=0
endif
_JUNK_ := $(shell echo >&2 "INFO: ZIP_DEBUGINFO_FILES=$(ZIP_DEBUGINFO_FILES)")
# C Compiler flag definitions
#
# Default optimization
#
ifndef OPTIMIZATION_LEVEL
ifeq ($(PRODUCT), java)
OPTIMIZATION_LEVEL = HIGHER
else
OPTIMIZATION_LEVEL = LOWER
endif
endif
ifndef FASTDEBUG_OPTIMIZATION_LEVEL
FASTDEBUG_OPTIMIZATION_LEVEL = LOWER
endif
ifeq ($(CC_VERSION),msvc)
# Visual Studio compiler option definitions:
# -O1 Favors reduced size over speed (-Og -Os -Oy -Ob2 -Gs -GF -Gy)
# -O2 Favors speed over reduced size (-Og -Oi -Ot -Oy -Ob2 -Gs -GF -Gy)
# -Ob2 More aggressive inlining
# -Og Global optimizations
# -Oi Replace some functions with intrinsic or special forms
# -fp:precise (should be the default)
# Improve floating point calculations (disables some optimizations)
# -Os Favor small code
# -Ot Favor faster code
# -Oy Frame pointer omission
# -G6 Used to be -GB?
# -GF Pool strings in read-only memory
# -Gf Pool strings in read-write memory (the default)
# -Gs Controls stack probess
# -GS Adds buffer overflow checks on stacks (the default)
# -EHsc Enables exception handling
# -Gy Function level linking only
#
CC_OPT/NONE = -Od
CC_OPT/LOWER = -O2
CC_OPT/HIGHER = -O3
CC_OPT/HIGHEST = -O3
ifeq ($(COMPILER_VERSION), VS2010)
# Automatic precompiled header option to use (if COMPILE_APPROACH=batch)
AUTOMATIC_PCH_OPTION =
GX_OPTION = -EHsc
GZ_OPTION = -RTC1
ifeq ($(ARCH_DATA_MODEL), 32)
CC_OPT/HIGHEST = -O2
CC_OPT/HIGHER = -O1
CC_OPT/LOWER = -O1
else
CC_OPT/HIGHEST = -O2
CC_OPT/HIGHER = -O1
CC_OPT/LOWER = -O1
endif
endif
else # CC_VERSION
# GCC not supported, but left for historical reference...
CC_OPT/NONE =
CC_OPT/LOWER = -O2
CC_OPT/HIGHER = -O2
CC_OPT/HIGHEST = -O3
endif
CC_OPT = $(CC_OPT/$(OPTIMIZATION_LEVEL))
# Select the runtime support library carefully, need to be consistent
#
# Visual Studio Runtime compiler option definitions:
# -MD Use dynamic multi-threaded runtime library
# -MDd Use debug version (don't use, doesn't mix with -MD DLL's)
# -MT Use static multi-threaded runtime library (-ML is going away)
# -MTd Use static debug version (better than -MDd, no runtime issues)
# -D_DEBUG Change use of malloc/free/etc to use special debug ones (-MTd)
#
# NOTE: We also will use /D _STATIC_CPPLIB so we don't need msvcpnn.dll
#
# If MS_RUNTIME_STATIC is requested we may have a problem, it is no longer
# supported by VS2010
ifneq ($(MS_RUNTIME_STATIC),true)
MS_RUNTIME_OPTION=-MD
endif
# The _DEBUG macro option (changes things like malloc to use debug version)
MS_RUNTIME_DEBUG_OPTION=
MS_RC_DEBUG_OPTION=
# Externally set environment variable can force any build to use the debug vers
ifeq ($(MFC_DEBUG), true)
ifeq ($(MS_RUNTIME_STATIC),true)
MS_RUNTIME_OPTION=-MTd
else
# This MS debugging flag forces a dependence on the debug
# version of the runtime library (MSVCR*D.DLL), as does -MDd.
# We cannot re-distribute this debug runtime.
MS_RUNTIME_OPTION=-MDd
endif
MS_RUNTIME_DEBUG_OPTION= -D_DEBUG
MS_RC_DEBUG_OPTION= -d _DEBUG
endif
# Always add _STATIC_CPPLIB definition
STATIC_CPPLIB_OPTION = /D _STATIC_CPPLIB
# Silence the warning about using _STATIC_CPPLIB
ifneq ($(SHOW_ALL_WARNINGS),true)
# Needed with VS2010 to turn off the deprecated warning.
STATIC_CPPLIB_OPTION += /D _DISABLE_DEPRECATE_STATIC_CPPLIB
endif
MS_RUNTIME_OPTION += $(STATIC_CPPLIB_OPTION)
ifeq ($(CC_VERSION),msvc)
# Visual Studio compiler option definitions:
# -Zi Cause *.pdb file to be created, full debug information
# -Z7 Full debug inside the .obj, no .pdb
# -Zd Basic debug, no local variables? In the .obj
# -Zl Don't add runtime library name to obj file?
# -Od Turns off optimization and speeds compilation
# -YX -Fp/.../foobar.pch Use precompiled headers (try someday?)
# -nologo Don't print out startup message
# /D _STATIC_CPPLIB
# Use static link for the C++ runtime (so msvcpnn.dll not needed)
#
ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
CFLAGS_COMMON += -Zi
endif
CFLAGS_COMMON += -nologo
CFLAGS_OPT = $(CC_OPT)
CFLAGS_DBG = -Od $(MS_RUNTIME_DEBUG_OPTION)
CFLAGS_VS2010 += -Zc:wchar_t-
# All builds get the same runtime setting
CFLAGS_COMMON += $(MS_RUNTIME_OPTION) $(CFLAGS_$(COMPILER_VERSION))
ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
LDEBUG = /debug
endif
ifeq ($(VTUNE_SUPPORT), true)
OTHER_CFLAGS = -Z7 -Ox
LDEBUG += /pdb:NONE
endif
# VS2010, always need safe exception handlers, not needed on 64bit
ifeq ($(ARCH_DATA_MODEL), 32)
LFLAGS_VS2010 += -SAFESEH
endif
# LFLAGS are the flags given to $(LINK) and used to build the actual DLL file
BASELFLAGS = -nologo /opt:REF /incremental:no
LFLAGS = $(BASELFLAGS) $(LDEBUG) $(EXTRA_LFLAGS) $(LFLAGS_$(COMPILER_VERSION))
LDDFLAGS += $(LFLAGS_$(COMPILER_VERSION))
endif
#
# Preprocessor macro definitions
#
CPPFLAGS_COMMON = -DWIN32 -DIAL -D_LITTLE_ENDIAN
ifeq ($(ARCH), amd64)
CPPFLAGS_COMMON += -D_AMD64_ -Damd64
else
CPPFLAGS_COMMON += -D_X86_ -Dx86
endif
CPPFLAGS_COMMON += -DWIN32_LEAN_AND_MEAN
#
# Output options (use specific filenames to avoid parallel compile errors)
#
ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
CFLAGS_COMMON += -Fd$(OBJDIR)/$(basename $(@F)).pdb -Fm$(OBJDIR)/$(basename $(@F)).map
endif
#
# Use -wdNNNN to disable warning NNNN.
# C4800 is a warning about bool performance casts (can't make go away)
#
COMPILER_WARNINGS_TO_IGNORE = 4800
CFLAGS_COMMON += $(COMPILER_WARNINGS_TO_IGNORE:%=-wd%)
#
# Treat compiler warnings as errors, if requested
#
CFLAGS_COMMON += -W$(COMPILER_WARNING_LEVEL)
ifeq ($(COMPILER_WARNINGS_FATAL),true)
CFLAGS_COMMON += -WX
endif
# Turn off some warnings by default, enable them all if asked.
ifneq ($(SHOW_ALL_WARNINGS),true)
# The -D _CRT_SECURE_NO_DEPRECATE turns off security/deprecated warnings on
# the standard C library functions like strcpy.
CFLAGS_COMMON += -D _CRT_SECURE_NO_DEPRECATE
# The -D _CRT_NONSTDC_NO_DEPRECATE turns off deprecation warnings about using
# non-standard C POSIX functions.
CFLAGS_COMMON += -D _CRT_NONSTDC_NO_DEPRECATE
endif
CPPFLAGS_OPT = -DNDEBUG
CPPFLAGS_DBG = -DDEBUG -DLOGGING
CXXFLAGS_COMMON = $(CFLAGS_COMMON)
CXXFLAGS_OPT = $(CFLAGS_OPT)
CXXFLAGS_DBG = $(CFLAGS_DBG)
ifneq ($(LIBRARY),fdlibm)
EXTRA_LIBS += advapi32.lib
endif
#
# Path and option to link against the VM, if you have to.
#
JVMLIB = $(LIBDIR)/jvm.lib
JAVALIB = $(LIBDIR)/java.lib
ifeq ($(CC_VERSION), msvc)
CC_DEPEND = -FD
CC_DEPEND_FILTER =
else # CC_VERSION
# not supported, but left for historical reference...
CC_DEPEND = -MM
CC_DEPEND_FILTER = $(SED) -e 's!$*\.$(OBJECT_SUFFIX)!$(dir $@)&!g'
endif # CC_VERSION
LIBRARY_SUFFIX = dll
LIB_SUFFIX = lib
# Settings for the JDI - Serviceability Agent binding.
HOTSPOT_SALIB_PATH = $(HOTSPOT_IMPORT_PATH)/jre/bin
SALIB_NAME = $(LIB_PREFIX)sawindbg.$(LIBRARY_SUFFIX)
SAMAP_NAME = $(LIB_PREFIX)sawindbg.map
SAPDB_NAME = $(LIB_PREFIX)sawindbg.pdb
SA_DIZ_NAME = $(LIB_PREFIX)sawindbg.diz
ifeq ($(ARCH), ia64)
# SA will never be supported here.
INCLUDE_SA = false
else
INCLUDE_SA = true
endif
# Settings for the VERSIONINFO tap on windows.
VERSIONINFO_RESOURCE = $(BUILDDIR)/../src/windows/resource/version.rc
ifneq ($(JDK_BUILD_NUMBER),)
COOKED_BUILD_NUMBER = $(shell $(ECHO) $(JDK_BUILD_NUMBER) | $(SED) -e 's/^b//' -e 's/^0//')
else
COOKED_BUILD_NUMBER = 0
endif
# If the update version contains non-numeric characters, we need
# to massage it into a numeric format.
# We use the following formula:
# JDK_UPDATE_VER = JDK_UPDATE_VERSION * 10 + EXCEPTION_VERSION
#
# Here are some examples:
# 1.5.0 b01 -> 5,0,0,1
# 1.5.0_10 b01 -> 5,0,100,1
# 1.4.2 b01 -> 4,2,0,1
# 1.4.2_02 b01 -> 4,2,20,1
# 1.4.2_02a b01 -> 4,2,21,1
# 1.4.2_02b b01 -> 4,2,22,1
ifdef JDK_UPDATE_VERSION
VTMP := $(shell $(ECHO) $(JDK_UPDATE_VERSION) | $(TR) "abcde" "12345")
CAB_CHAR1 := $(shell $(ECHO) $(VTMP) | $(NAWK) '{print substr($$1, 1, 1);}')
CAB_CHAR2 := $(shell $(ECHO) $(VTMP) | $(NAWK) '{print substr($$1, 2, 1);}')
CAB_CHAR3 := $(shell $(ECHO) $(VTMP) | $(NAWK) '{print substr($$1, 3, 1);}')
JDK_UPDATE_META_TAG := U$(MARKETING_NUMBER)
ifeq ($(CAB_CHAR3),)
CAB_CHAR3 := 0
endif
ifeq ($(CAB_CHAR1), 0)
JDK_UPDATE_VER := $(CAB_CHAR2)$(CAB_CHAR3)
else
JDK_UPDATE_VER := $(CAB_CHAR1)$(CAB_CHAR2)$(CAB_CHAR3)
endif
else
JDK_UPDATE_VER := 0
endif
RC_FLAGS = /l 0x409 /r
ifeq ($(VARIANT), OPT)
RC_FLAGS += -d NDEBUG
else
RC_FLAGS += $(MS_RC_DEBUG_OPTION)
endif
# Values for the RC variables defined in RC_FLAGS
JDK_RC_BUILD_ID = $(FULL_VERSION)
JDK_RC_COMPANY = $(COMPANY_NAME)
JDK_RC_COMPONENT = $(PRODUCT_NAME) $(JDK_RC_PLATFORM_NAME) binary
JDK_RC_VER = \
$(JDK_MINOR_VERSION).$(JDK_MICRO_VERSION).$(JDK_UPDATE_VER).$(COOKED_BUILD_NUMBER)
JDK_RC_COPYRIGHT = Copyright \xA9 $(COPYRIGHT_YEAR)
JDK_RC_NAME = \
$(PRODUCT_NAME) $(JDK_RC_PLATFORM_NAME) $(JDK_MINOR_VERSION) $(JDK_UPDATE_META_TAG)
JDK_RC_FVER = \
$(JDK_MINOR_VERSION),$(JDK_MICRO_VERSION),$(JDK_UPDATE_VER),$(COOKED_BUILD_NUMBER)
# JDK name required here
RC_FLAGS += -d "JDK_BUILD_ID=$(JDK_RC_BUILD_ID)" \
-d "JDK_COMPANY=$(JDK_RC_COMPANY)" \
-d "JDK_COMPONENT=$(JDK_RC_COMPONENT)" \
-d "JDK_VER=$(JDK_RC_VER)" \
-d "JDK_COPYRIGHT=$(JDK_RC_COPYRIGHT)" \
-d "JDK_NAME=$(JDK_RC_NAME)" \
-d "JDK_FVER=$(JDK_RC_FVER)"
# Enable 7-Zip LZMA file (de)compression for Java Kernel if it is available
ifeq ($(ARCH_DATA_MODEL), 32)
ifneq ($(KERNEL), off)
# This is a hack to use until 7-Zip (and UPX) bundles can be put
# under /java/devtools.
ifndef DEPLOY_TOPDIR
DEPLOY_TOPDIR=$(JDK_TOPDIR)/../deploy
endif
# Uncomment this block to cause build failure if above assumption false
#DCHK = $(shell if [ ! -d $(DEPLOY_TOPDIR) ] ; then \
# $(ECHO) deploy_not_a_peer_of_j2se ; \
#fi )
#ifeq ($(DCHK), deploy_not_a_peer_of_j2se)
# If a build failure points to control coming here it means
# it means deploy is not in the same directory
# as j2se. Java Kernel can't tolerate that for the time being.
#endif
EC_TMP = $(shell if [ -d $(DEPLOY_TOPDIR)/make/lzma ] ; then \
$(ECHO) true ; \
else \
$(ECHO) false ; \
fi )
ifeq ($(EC_TMP), true)
EXTRA_COMP_INSTALL_PATH = lib\\\\deploy\\\\lzma.dll
# Crazy but true: deploy/make/plugin/jinstall/Makefile.jkernel does
# not include deploy/make/common/Defs-windows.gmk, either directly
# or indirectly. But it does include this file, so redundantly declare
# these variables that are in deploy/make/common/Defs-windows.gmk for
# the sake of the Java Kernel part of the deploy build. Whew!
EXTRA_COMP_LIB_NAME = lzma.dll
EXTRA_COMP_PATH = $(OUTPUTDIR)/tmp/deploy/lzma/win32/obj
EXTRA_COMP_CMD_PATH = $(EXTRA_COMP_PATH)/lzma.exe
EXTRA_COMP_LIB_PATH = $(EXTRA_COMP_PATH)/$(EXTRA_COMP_LIB_NAME)
endif
endif
endif