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