aoqi@0: # aoqi@0: # Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. aoqi@0: # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: # aoqi@0: # This code is free software; you can redistribute it and/or modify it aoqi@0: # under the terms of the GNU General Public License version 2 only, as aoqi@0: # published by the Free Software Foundation. aoqi@0: # aoqi@0: # This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: # version 2 for more details (a copy is included in the LICENSE file that aoqi@0: # accompanied this code). aoqi@0: # aoqi@0: # You should have received a copy of the GNU General Public License version aoqi@0: # 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: # aoqi@0: # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: # or visit www.oracle.com if you need additional information or have any aoqi@0: # questions. aoqi@0: # aoqi@0: # aoqi@0: aoqi@0: #------------------------------------------------------------------------ aoqi@0: # CC, CXX & AS aoqi@0: aoqi@0: # If a SPEC is not set already, then use these defaults. aoqi@0: ifeq ($(SPEC),) aoqi@0: CXX = g++ aoqi@0: CC = gcc aoqi@0: AS = $(CC) -c aoqi@0: MCS = /usr/ccs/bin/mcs aoqi@0: endif aoqi@0: aoqi@0: Compiler = gcc aoqi@0: aoqi@0: # -dumpversion in gcc-2.91 shows "egcs-2.91.66". In later version, it only aoqi@0: # prints the numbers (e.g. "2.95", "3.2.1") aoqi@0: CC_VER_MAJOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f1) aoqi@0: CC_VER_MINOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f2) aoqi@0: aoqi@0: # Check for the versions of C++ and C compilers ($CXX and $CC) used. aoqi@0: aoqi@0: # Get the last thing on the line that looks like x.x+ (x is a digit). aoqi@0: COMPILER_REV := \ aoqi@0: $(shell $(CXX) -dumpversion | sed 's/egcs-//' | cut -d'.' -f1) aoqi@0: CC_COMPILER_REV := \ aoqi@0: $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f2) aoqi@0: aoqi@0: aoqi@0: # check for precompiled headers support aoqi@0: ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) \| \( \( $(CC_VER_MAJOR) = 3 \) \& \( $(CC_VER_MINOR) \>= 4 \) \))" "0" aoqi@0: # Allow the user to turn off precompiled headers from the command line. aoqi@0: ifneq ($(USE_PRECOMPILED_HEADER),0) aoqi@0: PRECOMPILED_HEADER_DIR=. aoqi@0: PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled/precompiled.hpp aoqi@0: PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.gch aoqi@0: endif aoqi@0: endif aoqi@0: aoqi@0: aoqi@0: #------------------------------------------------------------------------ aoqi@0: # Compiler flags aoqi@0: aoqi@0: # position-independent code aoqi@0: PICFLAG = -fPIC aoqi@0: aoqi@0: VM_PICFLAG/LIBJVM = $(PICFLAG) aoqi@0: VM_PICFLAG/AOUT = aoqi@0: VM_PICFLAG = $(VM_PICFLAG/$(LINK_INTO)) aoqi@0: aoqi@0: CFLAGS += $(VM_PICFLAG) aoqi@0: CFLAGS += -fno-rtti aoqi@0: CFLAGS += -fno-exceptions aoqi@0: CFLAGS += -D_REENTRANT aoqi@0: CFLAGS += -fcheck-new aoqi@0: aoqi@0: ARCHFLAG = $(ARCHFLAG/$(BUILDARCH)) aoqi@0: aoqi@0: ARCHFLAG/sparc = -m32 -mcpu=v9 aoqi@0: ARCHFLAG/sparcv9 = -m64 -mcpu=v9 aoqi@0: ARCHFLAG/i486 = -m32 -march=i586 aoqi@0: ARCHFLAG/amd64 = -m64 -march=k8 aoqi@0: aoqi@0: aoqi@0: # Optional sub-directory in /usr/lib where BUILDARCH libraries are kept. aoqi@0: ISA_DIR=$(ISA_DIR/$(BUILDARCH)) aoqi@0: ISA_DIR/amd64=/amd64 aoqi@0: ISA_DIR/i486= aoqi@0: ISA_DIR/sparcv9=/64 aoqi@0: aoqi@0: aoqi@0: CFLAGS += $(ARCHFLAG) aoqi@0: AOUT_FLAGS += $(ARCHFLAG) aoqi@0: LFLAGS += $(ARCHFLAG) aoqi@0: ASFLAGS += $(ARCHFLAG) aoqi@0: aoqi@0: ifeq ($(BUILDARCH), amd64) aoqi@0: ASFLAGS += -march=k8 -march=amd64 aoqi@0: LFLAGS += -march=k8 aoqi@0: endif aoqi@0: aoqi@0: aoqi@0: # Use C++ Interpreter aoqi@0: ifdef CC_INTERP aoqi@0: CFLAGS += -DCC_INTERP aoqi@0: endif aoqi@0: aoqi@0: # Keep temporary files (.ii, .s) aoqi@0: ifdef NEED_ASM aoqi@0: CFLAGS += -save-temps aoqi@0: else aoqi@0: CFLAGS += -pipe aoqi@0: endif aoqi@0: aoqi@0: aoqi@0: # Compiler warnings are treated as errors aoqi@0: WARNINGS_ARE_ERRORS = -Werror aoqi@0: # Enable these warnings. See 'info gcc' about details on these options aoqi@0: WARNING_FLAGS = -Wpointer-arith -Wconversion -Wsign-compare -Wundef aoqi@0: CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(WARNING_FLAGS) aoqi@0: # Special cases aoqi@0: CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@)) aoqi@0: aoqi@0: # The flags to use for an Optimized g++ build aoqi@0: OPT_CFLAGS += -O3 aoqi@0: aoqi@0: # Hotspot uses very unstrict aliasing turn this optimization off aoqi@0: OPT_CFLAGS += -fno-strict-aliasing aoqi@0: aoqi@0: # The gcc compiler segv's on ia64 when compiling bytecodeInterpreter.cpp aoqi@0: # if we use expensive-optimizations aoqi@0: # Note: all ia64 setting reflect the ones for linux aoqi@0: # No actial testing was performed: there is no Solaris on ia64 presently aoqi@0: ifeq ($(BUILDARCH), ia64) aoqi@0: OPT_CFLAGS/bytecodeInterpreter.o += -fno-expensive-optimizations aoqi@0: endif aoqi@0: aoqi@0: OPT_CFLAGS/NOOPT=-O0 aoqi@0: aoqi@0: # Flags for generating make dependency flags. aoqi@0: ifneq ("${CC_VER_MAJOR}", "2") aoqi@0: DEPFLAGS = -fpch-deps -MMD -MP -MF $(DEP_DIR)/$(@:%=%.d) aoqi@0: endif aoqi@0: aoqi@0: # -DDONT_USE_PRECOMPILED_HEADER will exclude all includes in precompiled.hpp. aoqi@0: ifeq ($(USE_PRECOMPILED_HEADER),0) aoqi@0: CFLAGS += -DDONT_USE_PRECOMPILED_HEADER aoqi@0: endif aoqi@0: aoqi@0: #------------------------------------------------------------------------ aoqi@0: # Linker flags aoqi@0: aoqi@0: # statically link libstdc++.so, work with gcc but ignored by g++ aoqi@0: STATIC_STDCXX = -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic aoqi@0: aoqi@0: # statically link libgcc and/or libgcc_s, libgcc does not exist before gcc-3.x. aoqi@0: ifneq ("${CC_VER_MAJOR}", "2") aoqi@0: STATIC_LIBGCC += -static-libgcc aoqi@0: endif aoqi@0: aoqi@0: ifeq ($(BUILDARCH), ia64) aoqi@0: # Note: all ia64 setting reflect the ones for linux aoqi@0: # No actial testing was performed: there is no Solaris on ia64 presently aoqi@0: LFLAGS += -Wl,-relax aoqi@0: endif aoqi@0: aoqi@0: ifdef USE_GNULD aoqi@0: # Enable linker optimization aoqi@0: LFLAGS += -Xlinker -O1 aoqi@0: aoqi@0: # Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file. aoqi@0: MAPFLAG = -Xlinker --version-script=FILENAME aoqi@0: else aoqi@0: MAPFLAG = -Xlinker -M -Xlinker FILENAME aoqi@0: endif aoqi@0: aoqi@0: # Use $(SONAMEFLAG:SONAME=soname) to specify the intrinsic name of a shared obj aoqi@0: SONAMEFLAG = -Xlinker -soname=SONAME aoqi@0: aoqi@0: # Build shared library aoqi@0: SHARED_FLAG = -shared aoqi@0: aoqi@0: #------------------------------------------------------------------------ aoqi@0: # Debug flags aoqi@0: aoqi@0: # Use the stabs format for debugging information (this is the default aoqi@0: # on gcc-2.91). It's good enough, has all the information about line aoqi@0: # numbers and local variables, and libjvm.so is only about 16M. aoqi@0: # Change this back to "-g" if you want the most expressive format. aoqi@0: # (warning: that could easily inflate libjvm.so to 150M!) aoqi@0: # Note: The Itanium gcc compiler crashes when using -gstabs. aoqi@0: DEBUG_CFLAGS/ia64 = -g aoqi@0: DEBUG_CFLAGS/amd64 = -g aoqi@0: DEBUG_CFLAGS += $(DEBUG_CFLAGS/$(BUILDARCH)) aoqi@0: ifeq ($(DEBUG_CFLAGS/$(BUILDARCH)),) aoqi@0: DEBUG_CFLAGS += -gstabs aoqi@0: endif