2796N/A#
4575N/A# Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
2796N/A# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2796N/A#
2796N/A# This code is free software; you can redistribute it and/or modify it
2796N/A# under the terms of the GNU General Public License version 2 only, as
2796N/A# published by the Free Software Foundation.
2796N/A#
2796N/A# This code is distributed in the hope that it will be useful, but WITHOUT
2796N/A# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2796N/A# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
2796N/A# version 2 for more details (a copy is included in the LICENSE file that
2796N/A# accompanied this code).
2796N/A#
2796N/A# You should have received a copy of the GNU General Public License version
2796N/A# 2 along with this work; if not, write to the Free Software Foundation,
2796N/A# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2796N/A#
2796N/A# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2796N/A# or visit www.oracle.com if you need additional information or have any
2796N/A# questions.
2796N/A#
2796N/A#
2796N/A
2796N/AOS_VENDOR = $(shell uname -s)
2796N/A
2796N/A#------------------------------------------------------------------------
3178N/A# CC, CXX & AS
2796N/A
3568N/A# If a SPEC is not set already, then use these defaults.
3568N/Aifeq ($(SPEC),)
3568N/A # When cross-compiling the ALT_COMPILER_PATH points
3568N/A # to the cross-compilation toolset
3568N/A ifdef CROSS_COMPILE_ARCH
3568N/A CXX = $(ALT_COMPILER_PATH)/g++
3568N/A CC = $(ALT_COMPILER_PATH)/gcc
3568N/A HOSTCXX = g++
3568N/A HOSTCC = gcc
3568N/A else ifneq ($(OS_VENDOR), Darwin)
3568N/A CXX = g++
3568N/A CC = gcc
3568N/A HOSTCXX = $(CXX)
3568N/A HOSTCC = $(CC)
3568N/A endif
3568N/A
3568N/A # i486 hotspot requires -mstackrealign on Darwin.
3568N/A # llvm-gcc supports this in Xcode 3.2.6 and 4.0.
3568N/A # gcc-4.0 supports this on earlier versions.
3568N/A # Prefer llvm-gcc where available.
3568N/A ifeq ($(OS_VENDOR), Darwin)
3568N/A ifeq ($(origin CXX), default)
3568N/A CXX = llvm-g++
3568N/A endif
3568N/A ifeq ($(origin CC), default)
3568N/A CC = llvm-gcc
3568N/A endif
3568N/A
3568N/A ifeq ($(ARCH), i486)
3568N/A LLVM_SUPPORTS_STACKREALIGN := $(shell \
3568N/A [ "0"`llvm-gcc -v 2>&1 | grep LLVM | sed -E "s/.*LLVM build ([0-9]+).*/\1/"` -gt "2333" ] \
3568N/A && echo true || echo false)
3568N/A
3568N/A ifeq ($(LLVM_SUPPORTS_STACKREALIGN), true)
3568N/A CXX32 ?= llvm-g++
3568N/A CC32 ?= llvm-gcc
3568N/A else
3568N/A CXX32 ?= g++-4.0
3568N/A CC32 ?= gcc-4.0
3568N/A endif
3568N/A CXX = $(CXX32)
3568N/A CC = $(CC32)
3568N/A endif
3568N/A
3568N/A HOSTCXX = $(CXX)
3568N/A HOSTCC = $(CC)
3568N/A endif
3568N/A
3568N/A AS = $(CC) -c -x assembler-with-cpp
2842N/Aendif
2842N/A
2796N/A
2796N/A# -dumpversion in gcc-2.91 shows "egcs-2.91.66". In later version, it only
2796N/A# prints the numbers (e.g. "2.95", "3.2.1")
2796N/ACC_VER_MAJOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f1)
2796N/ACC_VER_MINOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f2)
2796N/A
2796N/A# check for precompiled headers support
2796N/Aifneq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) \| \( \( $(CC_VER_MAJOR) = 3 \) \& \( $(CC_VER_MINOR) \>= 4 \) \))" "0"
2796N/A# Allow the user to turn off precompiled headers from the command line.
2796N/Aifneq ($(USE_PRECOMPILED_HEADER),0)
2796N/APRECOMPILED_HEADER_DIR=.
2871N/APRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled/precompiled.hpp
2796N/APRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.gch
2796N/Aendif
2796N/Aendif
2796N/A
2796N/A
2796N/A#------------------------------------------------------------------------
2796N/A# Compiler flags
2796N/A
2796N/A# position-independent code
2796N/APICFLAG = -fPIC
2796N/A
2796N/AVM_PICFLAG/LIBJVM = $(PICFLAG)
2796N/AVM_PICFLAG/AOUT =
2796N/AVM_PICFLAG = $(VM_PICFLAG/$(LINK_INTO))
2796N/A
3617N/Aifeq ($(JVM_VARIANT_ZERO), true)
3617N/A CFLAGS += $(LIBFFI_CFLAGS)
2796N/Aendif
3617N/Aifeq ($(JVM_VARIANT_ZEROSHARK), true)
3617N/A CFLAGS += $(LIBFFI_CFLAGS)
3617N/A CFLAGS += $(LLVM_CFLAGS)
2796N/Aendif
2796N/ACFLAGS += $(VM_PICFLAG)
2796N/ACFLAGS += -fno-rtti
2796N/ACFLAGS += -fno-exceptions
2796N/ACFLAGS += -pthread
2796N/ACFLAGS += -fcheck-new
2796N/A# version 4 and above support fvisibility=hidden (matches jni_x86.h file)
2796N/A# except 4.1.2 gives pointless warnings that can't be disabled (afaik)
2796N/Aifneq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0"
2796N/ACFLAGS += -fvisibility=hidden
2796N/Aendif
2796N/A
2796N/AARCHFLAG = $(ARCHFLAG/$(BUILDARCH))
2796N/AARCHFLAG/i486 = -m32 -march=i586
2796N/AARCHFLAG/amd64 = -m64
2796N/AARCHFLAG/ia64 =
2796N/AARCHFLAG/sparc = -m32 -mcpu=v9
2796N/AARCHFLAG/sparcv9 = -m64 -mcpu=v9
2796N/AARCHFLAG/zero = $(ZERO_ARCHFLAG)
2796N/A
2796N/A# Darwin-specific build flags
2796N/Aifeq ($(OS_VENDOR), Darwin)
2796N/A # Ineffecient 16-byte stack re-alignment on Darwin/IA32
2796N/A ARCHFLAG/i486 += -mstackrealign
2796N/Aendif
2796N/A
2796N/ACFLAGS += $(ARCHFLAG)
2796N/AAOUT_FLAGS += $(ARCHFLAG)
2796N/ALFLAGS += $(ARCHFLAG)
2796N/AASFLAGS += $(ARCHFLAG)
2796N/A
2796N/Aifdef E500V2
2796N/ACFLAGS += -DE500V2
2796N/Aendif
2796N/A
2796N/A# Use C++ Interpreter
2796N/Aifdef CC_INTERP
2796N/A CFLAGS += -DCC_INTERP
2796N/Aendif
2796N/A
2796N/A# Build for embedded targets
2796N/Aifdef JAVASE_EMBEDDED
2796N/A CFLAGS += -DJAVASE_EMBEDDED
2796N/Aendif
2796N/A
2796N/A# Keep temporary files (.ii, .s)
2796N/Aifdef NEED_ASM
2796N/A CFLAGS += -save-temps
2796N/Aelse
2796N/A CFLAGS += -pipe
2796N/Aendif
2796N/A
2796N/A# Compiler warnings are treated as errors
2842N/Aifneq ($(COMPILER_WARNINGS_FATAL),false)
2842N/A WARNINGS_ARE_ERRORS = -Werror
2842N/Aendif
2796N/A
2796N/A# Except for a few acceptable ones
2796N/A# Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit
2796N/A# conversions which might affect the values. To avoid that, we need to turn
2796N/A# it off explicitly.
2796N/Aifneq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0"
2796N/AACCEPTABLE_WARNINGS = -Wpointer-arith -Wsign-compare
2796N/Aelse
2796N/AACCEPTABLE_WARNINGS = -Wpointer-arith -Wconversion -Wsign-compare
2796N/Aendif
2796N/A
2796N/ACFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(ACCEPTABLE_WARNINGS)
2796N/A# Special cases
2796N/ACFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@))
2796N/A# XXXDARWIN: for _dyld_bind_fully_image_containing_address
2796N/Aifeq ($(OS_VENDOR), Darwin)
2796N/A CFLAGS_WARN/os_bsd.o = $(CFLAGS_WARN/DEFAULT) -Wno-deprecated-declarations
2796N/Aendif
2796N/A
2796N/A
2796N/A# The flags to use for an Optimized g++ build
2842N/Aifeq ($(OS_VENDOR), Darwin)
2842N/A # use -Os by default, unless -O3 can be proved to be worth the cost, as per policy
2842N/A # <http://wikis.sun.com/display/OpenJDK/Mac+OS+X+Port+Compilers>
2842N/A OPT_CFLAGS += -Os
2842N/Aelse
2842N/A OPT_CFLAGS += -O3
2842N/Aendif
2796N/A
2796N/A# Hotspot uses very unstrict aliasing turn this optimization off
2796N/AOPT_CFLAGS += -fno-strict-aliasing
2796N/A
2796N/A# The gcc compiler segv's on ia64 when compiling bytecodeInterpreter.cpp
2796N/A# if we use expensive-optimizations
2796N/Aifeq ($(BUILDARCH), ia64)
2796N/AOPT_CFLAGS += -fno-expensive-optimizations
2796N/Aendif
2796N/A
2796N/AOPT_CFLAGS/NOOPT=-O0
2796N/A
2796N/A# 6835796. Problem in GCC 4.3.0 with mulnode.o optimized compilation.
2796N/Aifneq "$(shell expr \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) = 3 \) \))" "0"
2796N/AOPT_CFLAGS/mulnode.o += -O0
2796N/Aendif
2796N/A
2796N/A# Flags for generating make dependency flags.
2796N/Aifneq ("${CC_VER_MAJOR}", "2")
3796N/ADEPFLAGS = -fpch-deps -MMD -MP -MF $(DEP_DIR)/$(@:%=%.d)
2796N/Aendif
2796N/A
2796N/A# -DDONT_USE_PRECOMPILED_HEADER will exclude all includes in precompiled.hpp.
2972N/Aifeq ($(USE_PRECOMPILED_HEADER),0)
2796N/ACFLAGS += -DDONT_USE_PRECOMPILED_HEADER
2796N/Aendif
2796N/A
2796N/A#------------------------------------------------------------------------
2796N/A# Linker flags
2796N/A
2796N/A# statically link libstdc++.so, work with gcc but ignored by g++
2796N/ASTATIC_STDCXX = -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic
2796N/A
2796N/A# statically link libgcc and/or libgcc_s, libgcc does not exist before gcc-3.x.
2796N/Aifneq ("${CC_VER_MAJOR}", "2")
2796N/ASTATIC_LIBGCC += -static-libgcc
2796N/Aendif
2796N/A
2796N/Aifeq ($(BUILDARCH), ia64)
2796N/ALFLAGS += -Wl,-relax
2796N/Aendif
2796N/A
2796N/A# Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file.
2796N/AMAPFLAG = -Xlinker --version-script=FILENAME
2796N/A
2796N/A#
2796N/A# Shared Library
2796N/A#
2796N/Aifeq ($(OS_VENDOR), Darwin)
2796N/A # Standard linker flags
2796N/A LFLAGS +=
2796N/A
4575N/A # The apple linker has its own variant of mapfiles/version-scripts
4575N/A MAPFLAG = -Xlinker -exported_symbols_list -Xlinker FILENAME
2796N/A
2796N/A # Use $(SONAMEFLAG:SONAME=soname) to specify the intrinsic name of a shared obj
2796N/A SONAMEFLAG =
2796N/A
2796N/A # Build shared library
2842N/A SHARED_FLAG = -Wl,-install_name,@rpath/$(@F) -dynamiclib -compatibility_version 1.0.0 -current_version 1.0.0 $(VM_PICFLAG)
2796N/A
2796N/A # Keep symbols even they are not used
2796N/A #AOUT_FLAGS += -Xlinker -export-dynamic
2796N/Aelse
2796N/A # Enable linker optimization
2796N/A LFLAGS += -Xlinker -O1
2796N/A
2796N/A # Use $(SONAMEFLAG:SONAME=soname) to specify the intrinsic name of a shared obj
2796N/A SONAMEFLAG = -Xlinker -soname=SONAME
2796N/A
2796N/A # Build shared library
2796N/A SHARED_FLAG = -shared $(VM_PICFLAG)
2796N/A
2796N/A # Keep symbols even they are not used
2796N/A AOUT_FLAGS += -Xlinker -export-dynamic
2796N/Aendif
2796N/A
2796N/A#------------------------------------------------------------------------
2796N/A# Debug flags
2796N/A
2796N/A# Use the stabs format for debugging information (this is the default
2796N/A# on gcc-2.91). It's good enough, has all the information about line
2796N/A# numbers and local variables, and libjvm_g.so is only about 16M.
2796N/A# Change this back to "-g" if you want the most expressive format.
2796N/A# (warning: that could easily inflate libjvm_g.so to 150M!)
2796N/A# Note: The Itanium gcc compiler crashes when using -gstabs.
2796N/ADEBUG_CFLAGS/ia64 = -g
2796N/ADEBUG_CFLAGS/amd64 = -g
2796N/ADEBUG_CFLAGS/arm = -g
2796N/ADEBUG_CFLAGS/ppc = -g
2796N/ADEBUG_CFLAGS += $(DEBUG_CFLAGS/$(BUILDARCH))
2796N/Aifeq ($(DEBUG_CFLAGS/$(BUILDARCH)),)
2796N/ADEBUG_CFLAGS += -gstabs
2796N/Aendif
2796N/A
2796N/A# DEBUG_BINARIES overrides everything, use full -g debug information
2796N/Aifeq ($(DEBUG_BINARIES), true)
2796N/A DEBUG_CFLAGS = -g
2796N/A CFLAGS += $(DEBUG_CFLAGS)
2796N/Aendif
2796N/A
2796N/A# If we are building HEADLESS, pass on to VM
2796N/A# so it can set the java.awt.headless property
2796N/Aifdef HEADLESS
2796N/ACFLAGS += -DHEADLESS
2796N/Aendif
2796N/A
2796N/A# We are building Embedded for a small device
2796N/A# favor code space over speed
2796N/Aifdef MINIMIZE_RAM_USAGE
2796N/ACFLAGS += -DMINIMIZE_RAM_USAGE
2796N/Aendif