duke@435: # twisti@2047: # Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. duke@435: # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: # duke@435: # This code is free software; you can redistribute it and/or modify it duke@435: # under the terms of the GNU General Public License version 2 only, as duke@435: # published by the Free Software Foundation. duke@435: # duke@435: # This code is distributed in the hope that it will be useful, but WITHOUT duke@435: # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: # version 2 for more details (a copy is included in the LICENSE file that duke@435: # accompanied this code). duke@435: # duke@435: # You should have received a copy of the GNU General Public License version duke@435: # 2 along with this work; if not, write to the Free Software Foundation, duke@435: # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: # trims@1907: # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA trims@1907: # or visit www.oracle.com if you need additional information or have any trims@1907: # questions. duke@435: # duke@435: # duke@435: duke@435: #------------------------------------------------------------------------ duke@435: # CC, CPP & AS duke@435: dholmes@2362: # When cross-compiling the ALT_COMPILER_PATH points dholmes@2362: # to the cross-compilation toolset dholmes@2362: ifdef CROSS_COMPILE_ARCH bobv@2036: CPP = $(ALT_COMPILER_PATH)/g++ bobv@2036: CC = $(ALT_COMPILER_PATH)/gcc bobv@2036: else duke@435: CPP = g++ duke@435: CC = gcc bobv@2036: endif bobv@2036: duke@435: AS = $(CC) -c duke@435: duke@435: # -dumpversion in gcc-2.91 shows "egcs-2.91.66". In later version, it only duke@435: # prints the numbers (e.g. "2.95", "3.2.1") duke@435: CC_VER_MAJOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f1) duke@435: CC_VER_MINOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f2) duke@435: duke@435: # check for precompiled headers support duke@435: ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) \| \( \( $(CC_VER_MAJOR) = 3 \) \& \( $(CC_VER_MINOR) \>= 4 \) \))" "0" stefank@2325: # Allow the user to turn off precompiled headers from the command line. stefank@2325: ifneq ($(USE_PRECOMPILED_HEADER),0) duke@435: USE_PRECOMPILED_HEADER=1 duke@435: PRECOMPILED_HEADER_DIR=. stefank@2314: PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled.hpp stefank@2314: PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.gch duke@435: endif stefank@2325: endif duke@435: duke@435: duke@435: #------------------------------------------------------------------------ duke@435: # Compiler flags duke@435: duke@435: # position-independent code duke@435: PICFLAG = -fPIC duke@435: duke@435: VM_PICFLAG/LIBJVM = $(PICFLAG) duke@435: VM_PICFLAG/AOUT = duke@435: VM_PICFLAG = $(VM_PICFLAG/$(LINK_INTO)) duke@435: never@1445: ifeq ($(ZERO_BUILD), true) never@1445: CFLAGS += $(LIBFFI_CFLAGS) never@1445: endif twisti@2047: ifeq ($(SHARK_BUILD), true) twisti@2047: CFLAGS += $(LLVM_CFLAGS) twisti@2047: endif duke@435: CFLAGS += $(VM_PICFLAG) duke@435: CFLAGS += -fno-rtti duke@435: CFLAGS += -fno-exceptions duke@435: CFLAGS += -D_REENTRANT duke@435: CFLAGS += -fcheck-new duke@435: duke@435: ARCHFLAG = $(ARCHFLAG/$(BUILDARCH)) duke@435: ARCHFLAG/i486 = -m32 -march=i586 duke@435: ARCHFLAG/amd64 = -m64 duke@435: ARCHFLAG/ia64 = duke@435: ARCHFLAG/sparc = -m32 -mcpu=v9 duke@435: ARCHFLAG/sparcv9 = -m64 -mcpu=v9 bobv@2036: ARCHFLAG/arm = -fsigned-char never@1445: ARCHFLAG/zero = $(ZERO_ARCHFLAG) bobv@2036: ifndef E500V2 bobv@2036: ARCHFLAG/ppc = -mcpu=powerpc bobv@2036: endif duke@435: duke@435: CFLAGS += $(ARCHFLAG) duke@435: AOUT_FLAGS += $(ARCHFLAG) duke@435: LFLAGS += $(ARCHFLAG) duke@435: ASFLAGS += $(ARCHFLAG) duke@435: bobv@2036: ifdef E500V2 bobv@2036: CFLAGS += -DE500V2 bobv@2036: endif bobv@2036: duke@435: # Use C++ Interpreter duke@435: ifdef CC_INTERP duke@435: CFLAGS += -DCC_INTERP duke@435: endif duke@435: bobv@2036: # Build for embedded targets bobv@2036: ifdef JAVASE_EMBEDDED bobv@2036: CFLAGS += -DJAVASE_EMBEDDED bobv@2036: endif bobv@2036: duke@435: # Keep temporary files (.ii, .s) duke@435: ifdef NEED_ASM duke@435: CFLAGS += -save-temps duke@435: else duke@435: CFLAGS += -pipe duke@435: endif duke@435: duke@435: # Compiler warnings are treated as errors duke@435: WARNINGS_ARE_ERRORS = -Werror xlu@664: duke@435: # Except for a few acceptable ones xlu@664: # Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit xlu@664: # conversions which might affect the values. To avoid that, we need to turn xlu@664: # it off explicitly. xlu@664: ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0" xlu@664: ACCEPTABLE_WARNINGS = -Wpointer-arith -Wsign-compare xlu@664: else duke@435: ACCEPTABLE_WARNINGS = -Wpointer-arith -Wconversion -Wsign-compare xlu@664: endif xlu@664: duke@435: CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(ACCEPTABLE_WARNINGS) duke@435: # Special cases duke@435: CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@)) duke@435: duke@435: # The flags to use for an Optimized g++ build duke@435: OPT_CFLAGS += -O3 duke@435: duke@435: # Hotspot uses very unstrict aliasing turn this optimization off duke@435: OPT_CFLAGS += -fno-strict-aliasing duke@435: duke@435: # The gcc compiler segv's on ia64 when compiling bytecodeInterpreter.cpp duke@435: # if we use expensive-optimizations duke@435: ifeq ($(BUILDARCH), ia64) duke@435: OPT_CFLAGS += -fno-expensive-optimizations duke@435: endif duke@435: duke@435: OPT_CFLAGS/NOOPT=-O0 duke@435: kvn@1179: # 6835796. Problem in GCC 4.3.0 with mulnode.o optimized compilation. kvn@1179: ifneq "$(shell expr \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) = 3 \) \))" "0" kvn@1179: OPT_CFLAGS/mulnode.o += -O0 kvn@1179: endif kvn@1179: stefank@2314: # Flags for generating make dependency flags. stefank@2314: ifneq ("${CC_VER_MAJOR}", "2") stefank@2314: DEPFLAGS = -MMD -MP -MF $(DEP_DIR)/$(@:%=%.d) stefank@2314: endif stefank@2314: stefank@2325: # -DDONT_USE_PRECOMPILED_HEADER will exclude all includes in precompiled.hpp. stefank@2325: ifneq ($(USE_PRECOMPILED_HEADER),1) stefank@2325: CFLAGS += -DDONT_USE_PRECOMPILED_HEADER stefank@2325: endif stefank@2325: duke@435: #------------------------------------------------------------------------ duke@435: # Linker flags duke@435: duke@435: # statically link libstdc++.so, work with gcc but ignored by g++ duke@435: STATIC_STDCXX = -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic duke@435: duke@435: # statically link libgcc and/or libgcc_s, libgcc does not exist before gcc-3.x. duke@435: ifneq ("${CC_VER_MAJOR}", "2") duke@435: STATIC_LIBGCC += -static-libgcc duke@435: endif duke@435: duke@435: ifeq ($(BUILDARCH), ia64) duke@435: LFLAGS += -Wl,-relax duke@435: endif duke@435: duke@435: # Enable linker optimization duke@435: LFLAGS += -Xlinker -O1 duke@435: ohair@1011: # If this is a --hash-style=gnu system, use --hash-style=both ohair@1011: # The gnu .hash section won't work on some Linux systems like SuSE 10. ohair@1011: _HAS_HASH_STYLE_GNU:=$(shell $(CC) -dumpspecs | grep -- '--hash-style=gnu') ohair@1011: ifneq ($(_HAS_HASH_STYLE_GNU),) ohair@1011: LDFLAGS_HASH_STYLE = -Wl,--hash-style=both ohair@1011: endif ohair@1011: LFLAGS += $(LDFLAGS_HASH_STYLE) ohair@1011: duke@435: # Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file. duke@435: MAPFLAG = -Xlinker --version-script=FILENAME duke@435: duke@435: # Use $(SONAMEFLAG:SONAME=soname) to specify the intrinsic name of a shared obj duke@435: SONAMEFLAG = -Xlinker -soname=SONAME duke@435: duke@435: # Build shared library duke@435: SHARED_FLAG = -shared duke@435: duke@435: # Keep symbols even they are not used duke@435: AOUT_FLAGS += -export-dynamic duke@435: duke@435: #------------------------------------------------------------------------ duke@435: # Debug flags duke@435: duke@435: # Use the stabs format for debugging information (this is the default duke@435: # on gcc-2.91). It's good enough, has all the information about line duke@435: # numbers and local variables, and libjvm_g.so is only about 16M. duke@435: # Change this back to "-g" if you want the most expressive format. duke@435: # (warning: that could easily inflate libjvm_g.so to 150M!) duke@435: # Note: The Itanium gcc compiler crashes when using -gstabs. duke@435: DEBUG_CFLAGS/ia64 = -g duke@435: DEBUG_CFLAGS/amd64 = -g bobv@2036: DEBUG_CFLAGS/arm = -g bobv@2036: DEBUG_CFLAGS/ppc = -g duke@435: DEBUG_CFLAGS += $(DEBUG_CFLAGS/$(BUILDARCH)) duke@435: ifeq ($(DEBUG_CFLAGS/$(BUILDARCH)),) duke@435: DEBUG_CFLAGS += -gstabs duke@435: endif aph@1202: aph@1202: # DEBUG_BINARIES overrides everything, use full -g debug information aph@1202: ifeq ($(DEBUG_BINARIES), true) aph@1202: DEBUG_CFLAGS = -g aph@1202: CFLAGS += $(DEBUG_CFLAGS) aph@1202: endif bobv@2036: bobv@2036: # If we are building HEADLESS, pass on to VM bobv@2036: # so it can set the java.awt.headless property bobv@2036: ifdef HEADLESS bobv@2036: CFLAGS += -DHEADLESS bobv@2036: endif bobv@2036: bobv@2036: # We are building Embedded for a small device bobv@2036: # favor code space over speed bobv@2036: ifdef MINIMIZE_RAM_USAGE bobv@2036: CFLAGS += -DMINIMIZE_RAM_USAGE bobv@2036: endif