duke@1: # xdono@49: # Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved. duke@1: # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@1: # duke@1: # This code is free software; you can redistribute it and/or modify it duke@1: # under the terms of the GNU General Public License version 2 only, as duke@1: # published by the Free Software Foundation. Sun designates this duke@1: # particular file as subject to the "Classpath" exception as provided duke@1: # by Sun in the LICENSE file that accompanied this code. duke@1: # duke@1: # This code is distributed in the hope that it will be useful, but WITHOUT duke@1: # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@1: # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@1: # version 2 for more details (a copy is included in the LICENSE file that duke@1: # accompanied this code). duke@1: # duke@1: # You should have received a copy of the GNU General Public License version duke@1: # 2 along with this work; if not, write to the Free Software Foundation, duke@1: # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@1: # duke@1: # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, duke@1: # CA 95054 USA or visit www.sun.com if you need additional information or duke@1: # have any questions. duke@1: # duke@1: duke@1: # duke@1: # Makefile to specify compiler flags for programs and libraries duke@1: # targeted to Windows builds. Should not contain any rules. duke@1: # duke@1: duke@1: # Get shared JDK settings duke@1: include $(BUILDDIR)/common/shared/Defs.gmk duke@1: duke@1: # CC compiler object code output directive flag value duke@1: CC_OBJECT_OUTPUT_FLAG = -Fo duke@1: CC_PROGRAM_OUTPUT_FLAG = -Fe duke@1: duke@1: # The suffix applied to the library name for FDLIBM duke@1: FDDLIBM_SUFFIX = lib duke@1: # The suffix applied to scripts (.bat for windows, nothing for unix) duke@1: SCRIPT_SUFFIX = .bat duke@1: duke@1: HPIS = windows duke@1: # LIB_LOCATION, which for windows identifies where .exe files go, may be duke@1: # set by each GNUmakefile. The default is BINDIR. duke@1: ifndef LIB_LOCATION duke@1: LIB_LOCATION = $(BINDIR) duke@1: endif # LIB_LOCATION duke@1: duke@1: ifndef PLATFORM_SRC duke@1: PLATFORM_SRC = $(TOPDIR)/src/windows duke@1: endif # PLATFORM_SRC duke@1: duke@1: # for backwards compatability, the old "win32" is used here instead of duke@1: # the more proper "windows" duke@1: PLATFORM_INCLUDE_NAME = win32 duke@1: PLATFORM_INCLUDE = $(INCLUDEDIR)/$(PLATFORM_INCLUDE_NAME) duke@1: duke@1: # The following DLL's are considered MS runtime libraries and should duke@1: # not to be REBASEd, see deploy/make/common/Release.gmk. tbell@33: # msvcrt.dll, msvcrnn.dll [msvcr71 or msvcr80 or msvcr90] : Microsoft runtimes duke@1: MS_RUNTIME_LIBRARIES = msvcrt.dll tbell@33: MSVCRNN_DLL = duke@1: ifeq ($(ARCH_DATA_MODEL), 32) duke@1: ifeq ($(COMPILER_VERSION), VS2003) tbell@33: MSVCRNN_DLL = msvcr71.dll tbell@33: MSVCPNN_DLL = msvcp71.dll tbell@33: MS_RUNTIME_LIBRARIES += $(MSVCRNN_DLL) tbell@33: endif tbell@33: ifeq ($(COMPILER_VERSION), VS2005) tbell@33: MSVCRNN_DLL = msvcr80.dll tbell@33: MSVCPNN_DLL = msvcp80.dll tbell@33: MS_RUNTIME_LIBRARIES += $(MSVCRNN_DLL) tbell@33: endif tbell@33: ifeq ($(COMPILER_VERSION), VS2008) tbell@33: MSVCRNN_DLL = msvcr90.dll tbell@33: MSVCPNN_DLL = msvcp90.dll tbell@33: MS_RUNTIME_LIBRARIES += $(MSVCRNN_DLL) duke@1: endif duke@1: endif duke@1: duke@1: # C Compiler flag definitions duke@1: duke@1: # duke@1: # Default optimization duke@1: # duke@1: ifeq ($(CC_VERSION),msvc) duke@1: # Visual Studio .NET 2003 or VS2003 compiler option definitions: duke@1: # -O1 Favors reduced size over speed (-Og -Os -Oy -Ob2 -Gs -GF -Gy) duke@1: # -O2 Favors speed over reduced size (-Og -Oi -Ot -Oy -Ob2 -Gs -GF -Gy) duke@1: # -Ox Full optimization (use -O2) (-Og -Oi -Ot -Oy -Ob2) duke@1: # (Removed in Visual Studio 2005 or VS2005) duke@1: # -Ob2 More aggressive inlining duke@1: # -Og Global optimizations duke@1: # -Oi Replace some functions with intrinsic or special forms duke@1: # -Op Improve floating point calculations (disables some optimizations) duke@1: # (Replaced with -fp:precise in VS2005, /Op is default now) duke@1: # -Os Favor small code duke@1: # -Ot Favor faster code duke@1: # -Oy Frame pointer omission duke@1: # -GB Optimize for pentium (old VC6 option?) duke@1: # -G6 VS2003 version of -GB? duke@1: # -GF Pool strings in read-only memory duke@1: # -Gf Pool strings in read-write memory (the default) duke@1: # -Gs Controls stack probess duke@1: # -GS Adds buffer overflow checks on stacks duke@1: # (Default in VS2005) duke@1: # -GX Enables exception handling duke@1: # (Replaced with /EHsc in VS2005) duke@1: # -Gy Function level linking only duke@1: # duke@1: # NOTE: With VC6, -Ox included -Gs. duke@1: # NOTE: With VC6, -Ox, -O1, and -O2 used -Ob1, not -Ob2. duke@1: # NOTE: With VC6, -O1 and -O2 used -Gf, not -GF. duke@1: # duke@1: ifeq ($(COMPILER_VERSION), VC6) duke@1: # VC6 (6.2) msvc compiler (the way Tiger and early Mustang were built) duke@1: # Automatic precompiled header option to use (if COMPILE_APPROACH=batch) duke@1: AUTOMATIC_PCH_OPTION = duke@1: GX_OPTION = -GX duke@1: ifeq ($(ARCH_DATA_MODEL), 32) duke@1: CC_HIGHEST_OPT = -Ox -Gy -Os -GB duke@1: CC_HIGHER_OPT = -Ox -Gy -Os -GB duke@1: CC_LOWER_OPT = -Ox -Gy -Os -GB duke@1: else duke@1: CC_HIGHEST_OPT = -Ox -Gy -Op duke@1: CC_HIGHER_OPT = -Ox -Gy -Op duke@1: CC_LOWER_OPT = -Ox -Gy -Op duke@1: endif duke@1: endif duke@1: ifeq ($(COMPILER_VERSION), VS2003) duke@1: # Automatic precompiled header option to use (if COMPILE_APPROACH=batch) duke@1: AUTOMATIC_PCH_OPTION = -YX duke@1: # Also known as VC7 compiler duke@1: GX_OPTION = -GX duke@1: ifeq ($(ARCH_DATA_MODEL), 32) duke@1: # Lowered opt level to try and reduce footprint, dll size especially. duke@1: # Was: CC_HIGHEST_OPT = -O2 -G6 duke@1: # Was: CC_HIGHER_OPT = -O2 duke@1: CC_HIGHEST_OPT = -O2 duke@1: CC_HIGHER_OPT = -O1 duke@1: CC_LOWER_OPT = -O1 duke@1: else duke@1: CC_HIGHEST_OPT = -O2 -Op duke@1: CC_HIGHER_OPT = -O2 -Op duke@1: CC_LOWER_OPT = -O1 -Op duke@1: endif duke@1: endif duke@1: ifeq ($(COMPILER_VERSION), VS2005) duke@1: # Automatic precompiled header option to use (if COMPILE_APPROACH=batch) duke@1: AUTOMATIC_PCH_OPTION = duke@1: # VS2005 compiler, only with Platform SDK right now? duke@1: GX_OPTION = -EHsc duke@1: ifeq ($(ARCH_DATA_MODEL), 32) duke@1: CC_HIGHEST_OPT = -O2 duke@1: CC_HIGHER_OPT = -O1 duke@1: CC_LOWER_OPT = -O1 duke@1: else duke@1: CC_HIGHEST_OPT = -O2 duke@1: CC_HIGHER_OPT = -O1 duke@1: CC_LOWER_OPT = -O1 duke@1: endif duke@1: endif tbell@33: ifeq ($(COMPILER_VERSION), VS2008) tbell@33: # Automatic precompiled header option to use (if COMPILE_APPROACH=batch) tbell@33: AUTOMATIC_PCH_OPTION = tbell@33: GX_OPTION = -EHsc tbell@33: ifeq ($(ARCH_DATA_MODEL), 32) tbell@33: CC_HIGHEST_OPT = -O2 tbell@33: CC_HIGHER_OPT = -O1 tbell@33: CC_LOWER_OPT = -O1 tbell@33: else tbell@33: CC_HIGHEST_OPT = -O2 tbell@33: CC_HIGHER_OPT = -O1 tbell@33: CC_LOWER_OPT = -O1 tbell@33: endif tbell@33: endif duke@1: CC_NO_OPT = -Od duke@1: else # CC_VERSION duke@1: # GCC not supported, but left for historical reference... duke@1: CC_HIGHEST_OPT = -O3 duke@1: CC_HIGHER_OPT = -O2 duke@1: CC_LOWER_OPT = -O2 duke@1: CC_NO_OPT = duke@1: endif duke@1: duke@1: # If NO_OPTIMIZATIONS is defined in the environment, turn all optimzations off duke@1: ifdef NO_OPTIMIZATIONS duke@1: CC_HIGHEST_OPT = $(CC_NO_OPT) duke@1: CC_HIGHER_OPT = $(CC_NO_OPT) duke@1: CC_LOWER_OPT = $(CC_NO_OPT) duke@1: endif duke@1: duke@1: ifeq ($(PRODUCT), java) duke@1: _OPT = $(CC_HIGHER_OPT) duke@1: else duke@1: _OPT = $(CC_LOWER_OPT) duke@1: endif duke@1: duke@1: # Select the runtime support library carefully, need to be consistent duke@1: # duke@1: # VS2003 compiler option definitions: duke@1: # -MD Use dynamic multi-threaded runtime library duke@1: # -MDd Use debug version (don't use, doesn't mix with -MD DLL's) duke@1: # -MT Use static multi-threaded runtime library (-ML is going away) duke@1: # -MTd Use static debug version (better than -MDd, no runtime issues) duke@1: # -D_DEBUG Change use of malloc/free/etc to use special debug ones (-MTd) duke@1: # tbell@33: # NOTE: We also will use /D _STATIC_CPPLIB so we don't need msvcpnn.dll duke@1: # duke@1: ifeq ($(MS_RUNTIME_STATIC),true) duke@1: MS_RUNTIME_OPTION=-MT duke@1: else duke@1: MS_RUNTIME_OPTION=-MD duke@1: endif duke@1: # The _DEBUG macro option (changes things like malloc to use debug version) duke@1: MS_RUNTIME_DEBUG_OPTION= duke@1: MS_RC_DEBUG_OPTION= duke@1: # Externally set environment variable can force any build to use the debug vers duke@1: ifeq ($(MFC_DEBUG), true) duke@1: ifeq ($(MS_RUNTIME_STATIC),true) duke@1: MS_RUNTIME_OPTION=-MTd duke@1: else duke@1: # This MS debugging flag forces a dependence on the debug duke@1: # version of the runtime library (MSVCRTD.DLL), as does -MDd. duke@1: # We cannot re-distribute this debug runtime. duke@1: MS_RUNTIME_OPTION=-MDd duke@1: endif duke@1: MS_RUNTIME_DEBUG_OPTION= -D_DEBUG duke@1: MS_RC_DEBUG_OPTION= -d _DEBUG duke@1: endif duke@1: duke@1: # Always add _STATIC_CPPLIB definition duke@1: STATIC_CPPLIB_OPTION = /D _STATIC_CPPLIB duke@1: MS_RUNTIME_OPTION += $(STATIC_CPPLIB_OPTION) duke@1: duke@1: ifeq ($(CC_VERSION),msvc) duke@1: # VS2003 compiler option definitions: duke@1: # -Zi Cause *.pdb file to be created, full debug information duke@1: # -Z7 Full debug inside the .obj, no .pdb duke@1: # -Zd Basic debug, no local variables? In the .obj duke@1: # -Zl Don't add runtime library name to obj file? duke@1: # -Od Turns off optimization and speeds compilation duke@1: # -YX -Fp/.../foobar.pch Use precompiled headers (try someday?) duke@1: # -nologo Don't print out startup message duke@1: # /D _STATIC_CPPLIB tbell@33: # Use static link for the C++ runtime (so msvcpnn.dll not needed) duke@1: # duke@1: CFLAGS_COMMON += -Zi -nologo duke@1: CFLAGS_OPT = $(POPT) duke@1: CFLAGS_DBG = -Od $(MS_RUNTIME_DEBUG_OPTION) duke@1: duke@1: # Starting from VS2005 the wchar_t is handled as a built-in C/C++ data type duke@1: # by default. However, we expect the wchar_t to be a typedef to the duke@1: # unsigned short data type. The -Zc:wchar_t- option restores the old duke@1: # behavior (as seen in VS2003) to avoid massive code modifications. duke@1: # When/if our code will be "C/C++ Standard"-compliant (at least in the area duke@1: # of handling the wchar_t type), the option won't be necessary. duke@1: ifeq ($(ARCH_DATA_MODEL), 32) duke@1: CFLAGS_VS2005 += -Zc:wchar_t- duke@1: else duke@1: # The 64bit Platform SDK we use (April 2005) doesn't like this option duke@1: ifneq ($(CC_VER), 14.00.40310.41) duke@1: CFLAGS_VS2005 += -Zc:wchar_t- duke@1: endif duke@1: endif duke@1: duke@1: # All builds get the same runtime setting duke@1: CFLAGS_COMMON += $(MS_RUNTIME_OPTION) $(CFLAGS_$(COMPILER_VERSION)) duke@1: duke@1: duke@1: LDEBUG = /debug duke@1: duke@1: ifeq ($(VTUNE_SUPPORT), true) duke@1: OTHER_CFLAGS = -Z7 -Ox duke@1: LDEBUG += /pdb:NONE duke@1: endif duke@1: duke@1: # The new Platform SDK and VS2005 has /GS as a default and requires duke@1: # bufferoverflowU.lib on the link command line, otherwise duke@1: # we get missing __security_check_cookie externals at link time. duke@1: BUFFEROVERFLOWLIB = bufferoverflowU.lib duke@1: # Always add bufferoverflowU.lib to VS2005 link commands (pack uses LDDFLAGS) duke@1: LFLAGS_VS2005 = $(BUFFEROVERFLOWLIB) duke@1: duke@1: # LFLAGS are the flags given to $(LINK) and used to build the actual DLL file duke@1: BASELFLAGS = -nologo /opt:REF /incremental:no duke@1: LFLAGS = $(BASELFLAGS) $(LDEBUG) $(EXTRA_LFLAGS) $(LFLAGS_$(COMPILER_VERSION)) duke@1: LDDFLAGS += $(LFLAGS_$(COMPILER_VERSION)) duke@1: duke@1: endif duke@1: duke@1: # duke@1: # Preprocessor macro definitions duke@1: # duke@1: CPPFLAGS_COMMON = -DWIN32 -DIAL -D_LITTLE_ENDIAN duke@1: ifeq ($(ARCH), amd64) duke@1: CPPFLAGS_COMMON += -D_AMD64_ -Damd64 duke@1: else duke@1: CPPFLAGS_COMMON += -DWIN32 -D_X86_ -Dx86 duke@1: endif duke@1: CPPFLAGS_COMMON += -DWIN32_LEAN_AND_MEAN duke@1: duke@1: # duke@1: # Output options (use specific filenames to avoid parallel compile errors) duke@1: # duke@1: CFLAGS_COMMON += -Fd$(OBJDIR)/$(basename $(@F)).pdb -Fm$(OBJDIR)/$(basename $(@F)).map duke@1: duke@1: # duke@1: # Add warnings and extra on 64bit issues duke@1: # duke@1: ifeq ($(ARCH_DATA_MODEL), 64) duke@1: CFLAGS_COMMON += -Wp64 duke@1: endif duke@1: CFLAGS_COMMON += -W$(COMPILER_WARNING_LEVEL) duke@1: duke@1: # duke@1: # Treat compiler warnings as errors, if requested duke@1: # duke@1: ifeq ($(COMPILER_WARNINGS_FATAL),true) duke@1: CFLAGS_COMMON += -WX duke@1: endif duke@1: duke@1: CPPFLAGS_OPT = duke@1: CPPFLAGS_DBG = -DDEBUG -DLOGGING duke@1: duke@1: CXXFLAGS_COMMON = $(CFLAGS_COMMON) duke@1: CXXFLAGS_OPT = $(CFLAGS_OPT) duke@1: CXXFLAGS_DBG = $(CFLAGS_DBG) duke@1: duke@1: ifneq ($(LIBRARY),fdlibm) duke@1: EXTRA_LIBS += advapi32.lib duke@1: endif duke@1: duke@1: # duke@1: # Path and option to link against the VM, if you have to. duke@1: # duke@1: JVMLIB = $(BOOTDIR)/lib/jvm.lib duke@1: JAVALIB = duke@1: duke@1: ifeq ($(CC_VERSION), msvc) duke@1: CC_DEPEND = -FD duke@1: CC_DEPEND_FILTER = duke@1: else # CC_VERSION duke@1: # not supported, but left for historical reference... duke@1: CC_DEPEND = -MM duke@1: CC_DEPEND_FILTER = $(SED) -e 's!$*\.$(OBJECT_SUFFIX)!$(dir $@)&!g' duke@1: endif # CC_VERSION duke@1: duke@1: LIBRARY_SUFFIX = dll duke@1: LIB_SUFFIX = lib duke@1: duke@1: # Settings for the VERSIONINFO tap on windows. duke@1: VERSIONINFO_RESOURCE = $(TOPDIR)/src/windows/resource/version.rc duke@1: duke@1: RC_FLAGS = /l 0x409 /r duke@1: duke@1: ifeq ($(VARIANT), OPT) duke@1: RC_FLAGS += -d NDEBUG duke@1: else duke@1: RC_FLAGS += $(MS_RC_DEBUG_OPTION) duke@1: endif duke@1: duke@1: ifndef COPYRIGHT_YEAR duke@1: COPYRIGHT_YEAR = 2007 duke@1: endif duke@1: duke@1: RC_FLAGS += -d "J2SE_BUILD_ID=$(FULL_VERSION)" \ duke@1: -d "J2SE_COMPANY=$(COMPANY_NAME)" \ duke@1: -d "J2SE_COMPONENT=$(PRODUCT_NAME) Platform SE binary" \ duke@1: -d "J2SE_VER=$(JDK_MINOR_VERSION).$(JDK_MICRO_VERSION).$(J2SE_UPDATE_VER).$(COOKED_BUILD_NUMBER)" \ duke@1: -d "J2SE_COPYRIGHT=Copyright \xA9 $(COPYRIGHT_YEAR)" \ duke@1: -d "J2SE_NAME=$(PRODUCT_NAME) Platform SE $(JDK_MINOR_VERSION) $(J2SE_UPDATE_META_TAG)" \ duke@1: -d "J2SE_FVER=$(JDK_VERSION)"