1 #
   2 # Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
   3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4 #
   5 # This code is free software; you can redistribute it and/or modify it
   6 # under the terms of the GNU General Public License version 2 only, as
   7 # published by the Free Software Foundation.
   8 #
   9 # This code is distributed in the hope that it will be useful, but WITHOUT
  10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12 # version 2 for more details (a copy is included in the LICENSE file that
  13 # accompanied this code).
  14 #
  15 # You should have received a copy of the GNU General Public License version
  16 # 2 along with this work; if not, write to the Free Software Foundation,
  17 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18 #
  19 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20 # or visit www.oracle.com if you need additional information or have any
  21 # questions.
  22 #  
  23 #
  24 
  25 #------------------------------------------------------------------------
  26 # CC, CPP & AS
  27 
  28 CPP = g++
  29 CC  = gcc
  30 AS  = $(CC) -c
  31 
  32 Compiler = gcc
  33 
  34 # -dumpversion in gcc-2.91 shows "egcs-2.91.66". In later version, it only
  35 # prints the numbers (e.g. "2.95", "3.2.1")
  36 CC_VER_MAJOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f1)
  37 CC_VER_MINOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f2)
  38 
  39 # Check for the versions of C++ and C compilers ($CPP and $CC) used. 
  40 
  41 # Get the last thing on the line that looks like x.x+ (x is a digit).
  42 COMPILER_REV := \
  43 $(shell $(CPP) -dumpversion | sed 's/egcs-//' | cut -d'.' -f1)
  44 C_COMPILER_REV := \
  45 $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f2)
  46 
  47 
  48 # check for precompiled headers support
  49 ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) \| \( \( $(CC_VER_MAJOR) = 3 \) \& \( $(CC_VER_MINOR) \>= 4 \) \))" "0"
  50 USE_PRECOMPILED_HEADER=1
  51 PRECOMPILED_HEADER_DIR=.
  52 PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled.hpp
  53 PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.gch
  54 endif
  55 
  56 
  57 #------------------------------------------------------------------------
  58 # Compiler flags
  59 
  60 # position-independent code
  61 PICFLAG = -fPIC
  62 
  63 VM_PICFLAG/LIBJVM = $(PICFLAG)
  64 VM_PICFLAG/AOUT   =
  65 VM_PICFLAG        = $(VM_PICFLAG/$(LINK_INTO))
  66 
  67 CFLAGS += $(VM_PICFLAG)
  68 CFLAGS += -fno-rtti
  69 CFLAGS += -fno-exceptions
  70 CFLAGS += -D_REENTRANT
  71 CFLAGS += -fcheck-new
  72 
  73 ARCHFLAG = $(ARCHFLAG/$(BUILDARCH))
  74 
  75 ARCHFLAG/sparc   = -m32 -mcpu=v9
  76 ARCHFLAG/sparcv9 = -m64 -mcpu=v9
  77 ARCHFLAG/i486    = -m32 -march=i586
  78 ARCHFLAG/amd64   = -m64 -march=k8
  79 
  80 
  81 # Optional sub-directory in /usr/lib where BUILDARCH libraries are kept.
  82 ISA_DIR=$(ISA_DIR/$(BUILDARCH))
  83 ISA_DIR/amd64=/amd64
  84 ISA_DIR/i486=
  85 ISA_DIR/sparcv9=/64
  86 
  87 
  88 CFLAGS     += $(ARCHFLAG)
  89 AOUT_FLAGS += $(ARCHFLAG)
  90 LFLAGS     += $(ARCHFLAG)
  91 ASFLAGS    += $(ARCHFLAG)
  92 
  93 ifeq ($(BUILDARCH), amd64)
  94 ASFLAGS += -march=k8  -march=amd64
  95 LFLAGS += -march=k8 
  96 endif
  97 
  98 
  99 # Use C++ Interpreter
 100 ifdef CC_INTERP
 101   CFLAGS += -DCC_INTERP
 102 endif
 103 
 104 # Keep temporary files (.ii, .s)
 105 ifdef NEED_ASM
 106   CFLAGS += -save-temps
 107 else
 108   CFLAGS += -pipe
 109 endif
 110 
 111 
 112 # Compiler warnings are treated as errors 
 113 WARNINGS_ARE_ERRORS = -Werror 
 114 # Enable these warnings. See 'info gcc' about details on these options
 115 ADDITIONAL_WARNINGS = -Wpointer-arith -Wconversion -Wsign-compare 
 116 CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(ADDITIONAL_WARNINGS) 
 117 # Special cases 
 118 CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@))  
 119 
 120 # The flags to use for an Optimized g++ build
 121 OPT_CFLAGS += -O3
 122 
 123 # Hotspot uses very unstrict aliasing turn this optimization off
 124 OPT_CFLAGS += -fno-strict-aliasing
 125 
 126 # The gcc compiler segv's on ia64 when compiling bytecodeInterpreter.cpp 
 127 # if we use expensive-optimizations
 128 # Note: all ia64 setting reflect the ones for linux
 129 # No actial testing was performed: there is no Solaris on ia64 presently
 130 ifeq ($(BUILDARCH), ia64)
 131 OPT_CFLAGS/bytecodeInterpreter.o += -fno-expensive-optimizations
 132 endif
 133 
 134 OPT_CFLAGS/NOOPT=-O0
 135 
 136 # Flags for generating make dependency flags.
 137 ifneq ("${CC_VER_MAJOR}", "2")
 138 DEPFLAGS = -MMD -MP -MF $(DEP_DIR)/$(@:%=%.d)
 139 endif
 140 
 141 #------------------------------------------------------------------------
 142 # Linker flags
 143 
 144 # statically link libstdc++.so, work with gcc but ignored by g++
 145 STATIC_STDCXX = -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic
 146 
 147 # statically link libgcc and/or libgcc_s, libgcc does not exist before gcc-3.x.
 148 ifneq ("${CC_VER_MAJOR}", "2")
 149 STATIC_LIBGCC += -static-libgcc
 150 endif
 151 
 152 ifeq ($(BUILDARCH), ia64)
 153 # Note: all ia64 setting reflect the ones for linux
 154 # No actial testing was performed: there is no Solaris on ia64 presently
 155 LFLAGS += -Wl,-relax
 156 endif
 157 
 158 ifdef USE_GNULD
 159 # Enable linker optimization
 160 LFLAGS += -Xlinker -O1
 161 
 162 # Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file.
 163 MAPFLAG = -Xlinker --version-script=FILENAME 
 164 else 
 165 MAPFLAG = -Xlinker -M -Xlinker FILENAME 
 166 endif 
 167 
 168 # Use $(SONAMEFLAG:SONAME=soname) to specify the intrinsic name of a shared obj
 169 SONAMEFLAG = -Xlinker -soname=SONAME
 170 
 171 # Build shared library
 172 SHARED_FLAG = -shared
 173 
 174 #------------------------------------------------------------------------
 175 # Debug flags
 176 
 177 # Use the stabs format for debugging information (this is the default 
 178 # on gcc-2.91). It's good enough, has all the information about line 
 179 # numbers and local variables, and libjvm_g.so is only about 16M. 
 180 # Change this back to "-g" if you want the most expressive format. 
 181 # (warning: that could easily inflate libjvm_g.so to 150M!) 
 182 # Note: The Itanium gcc compiler crashes when using -gstabs. 
 183 DEBUG_CFLAGS/ia64  = -g 
 184 DEBUG_CFLAGS/amd64 = -g 
 185 DEBUG_CFLAGS += $(DEBUG_CFLAGS/$(BUILDARCH)) 
 186 ifeq ($(DEBUG_CFLAGS/$(BUILDARCH)),) 
 187 DEBUG_CFLAGS += -gstabs 
 188 endif 
 189 
 190 MCS = /usr/ccs/bin/mcs