1 # 2 # Copyright (c) 1998, 2011, 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, CXX & AS 27 28 CXX = 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 ($CXX 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 $(CXX) -dumpversion | sed 's/egcs-//' | cut -d'.' -f1) 44 CC_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 # Allow the user to turn off precompiled headers from the command line. 51 ifneq ($(USE_PRECOMPILED_HEADER),0) 52 PRECOMPILED_HEADER_DIR=. 53 PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled/precompiled.hpp 54 PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.gch 55 endif 56 endif 57 58 59 #------------------------------------------------------------------------ 60 # Compiler flags 61 62 # position-independent code 63 PICFLAG = -fPIC 64 65 VM_PICFLAG/LIBJVM = $(PICFLAG) 66 VM_PICFLAG/AOUT = 67 VM_PICFLAG = $(VM_PICFLAG/$(LINK_INTO)) 68 69 CFLAGS += $(VM_PICFLAG) 70 CFLAGS += -fno-rtti 71 CFLAGS += -fno-exceptions 72 CFLAGS += -D_REENTRANT 73 CFLAGS += -fcheck-new 74 75 ARCHFLAG = $(ARCHFLAG/$(BUILDARCH)) 76 77 ARCHFLAG/sparc = -m32 -mcpu=v9 78 ARCHFLAG/sparcv9 = -m64 -mcpu=v9 79 ARCHFLAG/i486 = -m32 -march=i586 80 ARCHFLAG/amd64 = -m64 -march=k8 81 82 83 # Optional sub-directory in /usr/lib where BUILDARCH libraries are kept. 84 ISA_DIR=$(ISA_DIR/$(BUILDARCH)) 85 ISA_DIR/amd64=/amd64 86 ISA_DIR/i486= 87 ISA_DIR/sparcv9=/64 88 89 90 CFLAGS += $(ARCHFLAG) 91 AOUT_FLAGS += $(ARCHFLAG) 92 LFLAGS += $(ARCHFLAG) 93 ASFLAGS += $(ARCHFLAG) 94 95 ifeq ($(BUILDARCH), amd64) 96 ASFLAGS += -march=k8 -march=amd64 97 LFLAGS += -march=k8 98 endif 99 100 101 # Use C++ Interpreter 102 ifdef CC_INTERP 103 CFLAGS += -DCC_INTERP 104 endif 105 106 # Keep temporary files (.ii, .s) 107 ifdef NEED_ASM 108 CFLAGS += -save-temps 109 else 110 CFLAGS += -pipe 111 endif 112 113 114 # Compiler warnings are treated as errors 115 WARNINGS_ARE_ERRORS = -Werror 116 # Enable these warnings. See 'info gcc' about details on these options 117 ADDITIONAL_WARNINGS = -Wpointer-arith -Wconversion -Wsign-compare 118 CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(ADDITIONAL_WARNINGS) 119 # Special cases 120 CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@)) 121 122 # The flags to use for an Optimized g++ build 123 OPT_CFLAGS += -O3 124 125 # Hotspot uses very unstrict aliasing turn this optimization off 126 OPT_CFLAGS += -fno-strict-aliasing 127 128 # The gcc compiler segv's on ia64 when compiling bytecodeInterpreter.cpp 129 # if we use expensive-optimizations 130 # Note: all ia64 setting reflect the ones for linux 131 # No actial testing was performed: there is no Solaris on ia64 presently 132 ifeq ($(BUILDARCH), ia64) 133 OPT_CFLAGS/bytecodeInterpreter.o += -fno-expensive-optimizations 134 endif 135 136 OPT_CFLAGS/NOOPT=-O0 137 138 # Flags for generating make dependency flags. 139 ifneq ("${CC_VER_MAJOR}", "2") 140 DEPFLAGS = -MMD -MP -MF $(DEP_DIR)/$(@:%=%.d) 141 endif 142 143 # -DDONT_USE_PRECOMPILED_HEADER will exclude all includes in precompiled.hpp. 144 ifeq ($(USE_PRECOMPILED_HEADER),0) 145 CFLAGS += -DDONT_USE_PRECOMPILED_HEADER 146 endif 147 148 #------------------------------------------------------------------------ 149 # Linker flags 150 151 # statically link libstdc++.so, work with gcc but ignored by g++ 152 STATIC_STDCXX = -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic 153 154 # statically link libgcc and/or libgcc_s, libgcc does not exist before gcc-3.x. 155 ifneq ("${CC_VER_MAJOR}", "2") 156 STATIC_LIBGCC += -static-libgcc 157 endif 158 159 ifeq ($(BUILDARCH), ia64) 160 # Note: all ia64 setting reflect the ones for linux 161 # No actial testing was performed: there is no Solaris on ia64 presently 162 LFLAGS += -Wl,-relax 163 endif 164 165 ifdef USE_GNULD 166 # Enable linker optimization 167 LFLAGS += -Xlinker -O1 168 169 # Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file. 170 MAPFLAG = -Xlinker --version-script=FILENAME 171 else 172 MAPFLAG = -Xlinker -M -Xlinker FILENAME 173 endif 174 175 # Use $(SONAMEFLAG:SONAME=soname) to specify the intrinsic name of a shared obj 176 SONAMEFLAG = -Xlinker -soname=SONAME 177 178 # Build shared library 179 SHARED_FLAG = -shared 180 181 #------------------------------------------------------------------------ 182 # Debug flags 183 184 # Use the stabs format for debugging information (this is the default 185 # on gcc-2.91). It's good enough, has all the information about line 186 # numbers and local variables, and libjvm_g.so is only about 16M. 187 # Change this back to "-g" if you want the most expressive format. 188 # (warning: that could easily inflate libjvm_g.so to 150M!) 189 # Note: The Itanium gcc compiler crashes when using -gstabs. 190 DEBUG_CFLAGS/ia64 = -g 191 DEBUG_CFLAGS/amd64 = -g 192 DEBUG_CFLAGS += $(DEBUG_CFLAGS/$(BUILDARCH)) 193 ifeq ($(DEBUG_CFLAGS/$(BUILDARCH)),) 194 DEBUG_CFLAGS += -gstabs 195 endif 196 197 MCS = /usr/ccs/bin/mcs