10565
|
1 |
#
|
|
2 |
# Copyright (c) 1999, 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 |
OS_VENDOR = $(shell uname -s)
|
|
26 |
|
|
27 |
#------------------------------------------------------------------------
|
|
28 |
# CC, CPP & AS
|
|
29 |
|
|
30 |
# When cross-compiling the ALT_COMPILER_PATH points
|
|
31 |
# to the cross-compilation toolset
|
|
32 |
ifdef CROSS_COMPILE_ARCH
|
10739
|
33 |
CPP = $(ALT_COMPILER_PATH)/g++
|
|
34 |
CC = $(ALT_COMPILER_PATH)/gcc
|
|
35 |
HOSTCPP = g++
|
|
36 |
HOSTCC = gcc
|
|
37 |
else ifneq ($(OS_VENDOR), Darwin)
|
|
38 |
CXX = g++
|
|
39 |
CPP = $(CXX)
|
|
40 |
CC = gcc
|
|
41 |
HOSTCPP = $(CPP)
|
|
42 |
HOSTCC = $(CC)
|
|
43 |
endif
|
|
44 |
|
|
45 |
# i486 hotspot requires -mstackrealign on Darwin.
|
|
46 |
# llvm-gcc supports this in Xcode 3.2.6 and 4.0.
|
|
47 |
# gcc-4.0 supports this on earlier versions.
|
|
48 |
# Prefer llvm-gcc where available.
|
|
49 |
ifeq ($(OS_VENDOR), Darwin)
|
|
50 |
ifeq ($(origin CXX), default)
|
|
51 |
CXX = llvm-g++
|
|
52 |
endif
|
|
53 |
ifeq ($(origin CC), default)
|
|
54 |
CC = llvm-gcc
|
|
55 |
endif
|
|
56 |
CPP = $(CXX)
|
|
57 |
|
|
58 |
ifeq ($(ARCH), i486)
|
|
59 |
LLVM_SUPPORTS_STACKREALIGN := $(shell \
|
|
60 |
[ "0"`llvm-gcc -v 2>&1 | grep LLVM | sed -E "s/.*LLVM build ([0-9]+).*/\1/"` -gt "2333" ] \
|
|
61 |
&& echo true || echo false)
|
|
62 |
|
|
63 |
ifeq ($(LLVM_SUPPORTS_STACKREALIGN), true)
|
|
64 |
CXX32 ?= llvm-g++
|
|
65 |
CC32 ?= llvm-gcc
|
|
66 |
else
|
|
67 |
CXX32 ?= g++-4.0
|
|
68 |
CC32 ?= gcc-4.0
|
|
69 |
endif
|
|
70 |
CPP = $(CXX32)
|
|
71 |
CC = $(CC32)
|
|
72 |
endif
|
|
73 |
|
|
74 |
HOSTCPP = $(CPP)
|
|
75 |
HOSTCC = $(CC)
|
10565
|
76 |
endif
|
|
77 |
|
|
78 |
AS = $(CC) -c -x assembler-with-cpp
|
|
79 |
|
|
80 |
# -dumpversion in gcc-2.91 shows "egcs-2.91.66". In later version, it only
|
|
81 |
# prints the numbers (e.g. "2.95", "3.2.1")
|
|
82 |
CC_VER_MAJOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f1)
|
|
83 |
CC_VER_MINOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f2)
|
|
84 |
|
|
85 |
# check for precompiled headers support
|
|
86 |
ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) \| \( \( $(CC_VER_MAJOR) = 3 \) \& \( $(CC_VER_MINOR) \>= 4 \) \))" "0"
|
|
87 |
# Allow the user to turn off precompiled headers from the command line.
|
|
88 |
ifneq ($(USE_PRECOMPILED_HEADER),0)
|
|
89 |
USE_PRECOMPILED_HEADER=1
|
|
90 |
PRECOMPILED_HEADER_DIR=.
|
|
91 |
PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled.hpp
|
|
92 |
PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.gch
|
|
93 |
endif
|
|
94 |
endif
|
|
95 |
|
|
96 |
|
|
97 |
#------------------------------------------------------------------------
|
|
98 |
# Compiler flags
|
|
99 |
|
|
100 |
# position-independent code
|
|
101 |
PICFLAG = -fPIC
|
|
102 |
|
|
103 |
VM_PICFLAG/LIBJVM = $(PICFLAG)
|
|
104 |
VM_PICFLAG/AOUT =
|
|
105 |
VM_PICFLAG = $(VM_PICFLAG/$(LINK_INTO))
|
|
106 |
|
|
107 |
ifeq ($(ZERO_BUILD), true)
|
|
108 |
CFLAGS += $(LIBFFI_CFLAGS)
|
|
109 |
endif
|
|
110 |
ifeq ($(SHARK_BUILD), true)
|
|
111 |
CFLAGS += $(LLVM_CFLAGS)
|
|
112 |
endif
|
|
113 |
CFLAGS += $(VM_PICFLAG)
|
|
114 |
CFLAGS += -fno-rtti
|
|
115 |
CFLAGS += -fno-exceptions
|
|
116 |
CFLAGS += -pthread
|
|
117 |
CFLAGS += -fcheck-new
|
|
118 |
# version 4 and above support fvisibility=hidden (matches jni_x86.h file)
|
|
119 |
# except 4.1.2 gives pointless warnings that can't be disabled (afaik)
|
|
120 |
ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0"
|
|
121 |
CFLAGS += -fvisibility=hidden
|
|
122 |
endif
|
|
123 |
|
|
124 |
ARCHFLAG = $(ARCHFLAG/$(BUILDARCH))
|
|
125 |
ARCHFLAG/i486 = -m32 -march=i586
|
|
126 |
ARCHFLAG/amd64 = -m64
|
|
127 |
ARCHFLAG/ia64 =
|
|
128 |
ARCHFLAG/sparc = -m32 -mcpu=v9
|
|
129 |
ARCHFLAG/sparcv9 = -m64 -mcpu=v9
|
|
130 |
ARCHFLAG/zero = $(ZERO_ARCHFLAG)
|
|
131 |
|
|
132 |
# Darwin-specific build flags
|
|
133 |
ifeq ($(OS_VENDOR), Darwin)
|
|
134 |
# Ineffecient 16-byte stack re-alignment on Darwin/IA32
|
|
135 |
ARCHFLAG/i486 += -mstackrealign
|
|
136 |
endif
|
|
137 |
|
|
138 |
CFLAGS += $(ARCHFLAG)
|
|
139 |
AOUT_FLAGS += $(ARCHFLAG)
|
|
140 |
LFLAGS += $(ARCHFLAG)
|
|
141 |
ASFLAGS += $(ARCHFLAG)
|
|
142 |
|
|
143 |
ifdef E500V2
|
|
144 |
CFLAGS += -DE500V2
|
|
145 |
endif
|
|
146 |
|
|
147 |
# Use C++ Interpreter
|
|
148 |
ifdef CC_INTERP
|
|
149 |
CFLAGS += -DCC_INTERP
|
|
150 |
endif
|
|
151 |
|
|
152 |
# Build for embedded targets
|
|
153 |
ifdef JAVASE_EMBEDDED
|
|
154 |
CFLAGS += -DJAVASE_EMBEDDED
|
|
155 |
endif
|
|
156 |
|
|
157 |
# Keep temporary files (.ii, .s)
|
|
158 |
ifdef NEED_ASM
|
|
159 |
CFLAGS += -save-temps
|
|
160 |
else
|
|
161 |
CFLAGS += -pipe
|
|
162 |
endif
|
|
163 |
|
|
164 |
# Compiler warnings are treated as errors
|
10739
|
165 |
ifneq ($(COMPILER_WARNINGS_FATAL),false)
|
|
166 |
WARNINGS_ARE_ERRORS = -Werror
|
|
167 |
endif
|
10565
|
168 |
|
|
169 |
# Except for a few acceptable ones
|
|
170 |
# Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit
|
|
171 |
# conversions which might affect the values. To avoid that, we need to turn
|
|
172 |
# it off explicitly.
|
|
173 |
ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0"
|
|
174 |
ACCEPTABLE_WARNINGS = -Wpointer-arith -Wsign-compare
|
|
175 |
else
|
|
176 |
ACCEPTABLE_WARNINGS = -Wpointer-arith -Wconversion -Wsign-compare
|
|
177 |
endif
|
|
178 |
|
|
179 |
CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(ACCEPTABLE_WARNINGS)
|
|
180 |
# Special cases
|
|
181 |
CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@))
|
|
182 |
# XXXDARWIN: for _dyld_bind_fully_image_containing_address
|
|
183 |
ifeq ($(OS_VENDOR), Darwin)
|
|
184 |
CFLAGS_WARN/os_bsd.o = $(CFLAGS_WARN/DEFAULT) -Wno-deprecated-declarations
|
|
185 |
endif
|
|
186 |
|
|
187 |
|
|
188 |
# The flags to use for an Optimized g++ build
|
10739
|
189 |
ifeq ($(OS_VENDOR), Darwin)
|
|
190 |
# use -Os by default, unless -O3 can be proved to be worth the cost, as per policy
|
|
191 |
# <http://wikis.sun.com/display/OpenJDK/Mac+OS+X+Port+Compilers>
|
|
192 |
OPT_CFLAGS += -Os
|
|
193 |
else
|
|
194 |
OPT_CFLAGS += -O3
|
|
195 |
endif
|
10565
|
196 |
|
|
197 |
# Hotspot uses very unstrict aliasing turn this optimization off
|
|
198 |
OPT_CFLAGS += -fno-strict-aliasing
|
|
199 |
|
|
200 |
# The gcc compiler segv's on ia64 when compiling bytecodeInterpreter.cpp
|
|
201 |
# if we use expensive-optimizations
|
|
202 |
ifeq ($(BUILDARCH), ia64)
|
|
203 |
OPT_CFLAGS += -fno-expensive-optimizations
|
|
204 |
endif
|
|
205 |
|
|
206 |
OPT_CFLAGS/NOOPT=-O0
|
|
207 |
|
|
208 |
# 6835796. Problem in GCC 4.3.0 with mulnode.o optimized compilation.
|
|
209 |
ifneq "$(shell expr \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) = 3 \) \))" "0"
|
|
210 |
OPT_CFLAGS/mulnode.o += -O0
|
|
211 |
endif
|
|
212 |
|
|
213 |
# Flags for generating make dependency flags.
|
|
214 |
ifneq ("${CC_VER_MAJOR}", "2")
|
|
215 |
DEPFLAGS = -MMD -MP -MF $(DEP_DIR)/$(@:%=%.d)
|
|
216 |
endif
|
|
217 |
|
|
218 |
# -DDONT_USE_PRECOMPILED_HEADER will exclude all includes in precompiled.hpp.
|
|
219 |
ifneq ($(USE_PRECOMPILED_HEADER),1)
|
|
220 |
CFLAGS += -DDONT_USE_PRECOMPILED_HEADER
|
|
221 |
endif
|
|
222 |
|
|
223 |
#------------------------------------------------------------------------
|
|
224 |
# Linker flags
|
|
225 |
|
|
226 |
# statically link libstdc++.so, work with gcc but ignored by g++
|
|
227 |
STATIC_STDCXX = -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic
|
|
228 |
|
|
229 |
# statically link libgcc and/or libgcc_s, libgcc does not exist before gcc-3.x.
|
|
230 |
ifneq ("${CC_VER_MAJOR}", "2")
|
|
231 |
STATIC_LIBGCC += -static-libgcc
|
|
232 |
endif
|
|
233 |
|
|
234 |
ifeq ($(BUILDARCH), ia64)
|
|
235 |
LFLAGS += -Wl,-relax
|
|
236 |
endif
|
|
237 |
|
|
238 |
# Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file.
|
|
239 |
MAPFLAG = -Xlinker --version-script=FILENAME
|
|
240 |
|
|
241 |
#
|
|
242 |
# Shared Library
|
|
243 |
#
|
|
244 |
ifeq ($(OS_VENDOR), Darwin)
|
|
245 |
# Standard linker flags
|
|
246 |
LFLAGS +=
|
|
247 |
|
|
248 |
# Darwin doesn't use ELF and doesn't support version scripts
|
|
249 |
LDNOMAP = true
|
|
250 |
|
|
251 |
# Use $(SONAMEFLAG:SONAME=soname) to specify the intrinsic name of a shared obj
|
|
252 |
SONAMEFLAG =
|
|
253 |
|
|
254 |
# Build shared library
|
10739
|
255 |
SHARED_FLAG = -Wl,-install_name,@rpath/$(@F) -dynamiclib -compatibility_version 1.0.0 -current_version 1.0.0 $(VM_PICFLAG)
|
10565
|
256 |
|
|
257 |
# Keep symbols even they are not used
|
|
258 |
#AOUT_FLAGS += -Xlinker -export-dynamic
|
|
259 |
else
|
|
260 |
# Enable linker optimization
|
|
261 |
LFLAGS += -Xlinker -O1
|
|
262 |
|
|
263 |
# Use $(SONAMEFLAG:SONAME=soname) to specify the intrinsic name of a shared obj
|
|
264 |
SONAMEFLAG = -Xlinker -soname=SONAME
|
|
265 |
|
|
266 |
# Build shared library
|
|
267 |
SHARED_FLAG = -shared $(VM_PICFLAG)
|
|
268 |
|
|
269 |
# Keep symbols even they are not used
|
|
270 |
AOUT_FLAGS += -Xlinker -export-dynamic
|
|
271 |
endif
|
|
272 |
|
|
273 |
#------------------------------------------------------------------------
|
|
274 |
# Debug flags
|
|
275 |
|
|
276 |
# Use the stabs format for debugging information (this is the default
|
|
277 |
# on gcc-2.91). It's good enough, has all the information about line
|
|
278 |
# numbers and local variables, and libjvm_g.so is only about 16M.
|
|
279 |
# Change this back to "-g" if you want the most expressive format.
|
|
280 |
# (warning: that could easily inflate libjvm_g.so to 150M!)
|
|
281 |
# Note: The Itanium gcc compiler crashes when using -gstabs.
|
|
282 |
DEBUG_CFLAGS/ia64 = -g
|
|
283 |
DEBUG_CFLAGS/amd64 = -g
|
|
284 |
DEBUG_CFLAGS/arm = -g
|
|
285 |
DEBUG_CFLAGS/ppc = -g
|
|
286 |
DEBUG_CFLAGS += $(DEBUG_CFLAGS/$(BUILDARCH))
|
|
287 |
ifeq ($(DEBUG_CFLAGS/$(BUILDARCH)),)
|
|
288 |
DEBUG_CFLAGS += -gstabs
|
|
289 |
endif
|
|
290 |
|
|
291 |
# DEBUG_BINARIES overrides everything, use full -g debug information
|
|
292 |
ifeq ($(DEBUG_BINARIES), true)
|
|
293 |
DEBUG_CFLAGS = -g
|
|
294 |
CFLAGS += $(DEBUG_CFLAGS)
|
|
295 |
endif
|
|
296 |
|
|
297 |
# If we are building HEADLESS, pass on to VM
|
|
298 |
# so it can set the java.awt.headless property
|
|
299 |
ifdef HEADLESS
|
|
300 |
CFLAGS += -DHEADLESS
|
|
301 |
endif
|
|
302 |
|
|
303 |
# We are building Embedded for a small device
|
|
304 |
# favor code space over speed
|
|
305 |
ifdef MINIMIZE_RAM_USAGE
|
|
306 |
CFLAGS += -DMINIMIZE_RAM_USAGE
|
|
307 |
endif
|