duke@435: # brutisso@3229: # Copyright (c) 1998, 2011, 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: duke@435: CPP = g++ duke@435: CC = gcc duke@435: AS = $(CC) -c duke@435: duke@435: Compiler = gcc 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 the versions of C++ and C compilers ($CPP and $CC) used. duke@435: duke@435: # Get the last thing on the line that looks like x.x+ (x is a digit). duke@435: COMPILER_REV := \ duke@435: $(shell $(CPP) -dumpversion | sed 's/egcs-//' | cut -d'.' -f1) duke@435: C_COMPILER_REV := \ duke@435: $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f2) duke@435: 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: PRECOMPILED_HEADER_DIR=. brutisso@3229: PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled/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: 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: duke@435: ARCHFLAG/sparc = -m32 -mcpu=v9 duke@435: ARCHFLAG/sparcv9 = -m64 -mcpu=v9 duke@435: ARCHFLAG/i486 = -m32 -march=i586 duke@435: ARCHFLAG/amd64 = -m64 -march=k8 duke@435: duke@435: duke@435: # Optional sub-directory in /usr/lib where BUILDARCH libraries are kept. duke@435: ISA_DIR=$(ISA_DIR/$(BUILDARCH)) duke@435: ISA_DIR/amd64=/amd64 duke@435: ISA_DIR/i486= duke@435: ISA_DIR/sparcv9=/64 duke@435: duke@435: duke@435: CFLAGS += $(ARCHFLAG) duke@435: AOUT_FLAGS += $(ARCHFLAG) duke@435: LFLAGS += $(ARCHFLAG) duke@435: ASFLAGS += $(ARCHFLAG) duke@435: duke@435: ifeq ($(BUILDARCH), amd64) duke@435: ASFLAGS += -march=k8 -march=amd64 duke@435: LFLAGS += -march=k8 duke@435: endif duke@435: duke@435: duke@435: # Use C++ Interpreter duke@435: ifdef CC_INTERP duke@435: CFLAGS += -DCC_INTERP duke@435: endif duke@435: 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: duke@435: # Compiler warnings are treated as errors duke@435: WARNINGS_ARE_ERRORS = -Werror duke@435: # Enable these warnings. See 'info gcc' about details on these options duke@435: ADDITIONAL_WARNINGS = -Wpointer-arith -Wconversion -Wsign-compare duke@435: CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(ADDITIONAL_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: # Note: all ia64 setting reflect the ones for linux duke@435: # No actial testing was performed: there is no Solaris on ia64 presently duke@435: ifeq ($(BUILDARCH), ia64) duke@435: OPT_CFLAGS/bytecodeInterpreter.o += -fno-expensive-optimizations duke@435: endif duke@435: duke@435: OPT_CFLAGS/NOOPT=-O0 stefank@2314: 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@3325: ifeq ($(USE_PRECOMPILED_HEADER),0) 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: # Note: all ia64 setting reflect the ones for linux duke@435: # No actial testing was performed: there is no Solaris on ia64 presently duke@435: LFLAGS += -Wl,-relax duke@435: endif duke@435: duke@435: ifdef USE_GNULD duke@435: # Enable linker optimization duke@435: LFLAGS += -Xlinker -O1 duke@435: duke@435: # Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file. duke@435: MAPFLAG = -Xlinker --version-script=FILENAME duke@435: else duke@435: MAPFLAG = -Xlinker -M -Xlinker FILENAME duke@435: endif 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: #------------------------------------------------------------------------ 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 duke@435: DEBUG_CFLAGS += $(DEBUG_CFLAGS/$(BUILDARCH)) duke@435: ifeq ($(DEBUG_CFLAGS/$(BUILDARCH)),) duke@435: DEBUG_CFLAGS += -gstabs duke@435: endif duke@435: duke@435: MCS = /usr/ccs/bin/mcs