build/linux/makefiles/vm.make

changeset 435
a61af66fc99e
child 535
c7c777385a15
equal deleted inserted replaced
-1:000000000000 435:a61af66fc99e
1 #
2 # Copyright 1999-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 # Rules to build JVM and related libraries, included from vm.make in the build
26 # directory.
27
28 # Common build rules.
29 MAKEFILES_DIR=$(GAMMADIR)/build/$(Platform_os_family)/makefiles
30 include $(MAKEFILES_DIR)/rules.make
31
32 default: build
33
34 #----------------------------------------------------------------------
35 # Defs
36
37 GENERATED = ../generated
38
39 # read a generated file defining the set of .o's and the .o .h dependencies
40 include $(GENERATED)/Dependencies
41
42 # read machine-specific adjustments (%%% should do this via buildtree.make?)
43 include $(MAKEFILES_DIR)/$(BUILDARCH).make
44
45 # set VPATH so make knows where to look for source files
46 # Src_Dirs is everything in src/share/vm/*, plus the right os/*/vm and cpu/*/vm
47 # The incls directory contains generated header file lists for inclusion.
48 # The adfiles directory contains ad_<arch>.[ch]pp.
49 # The jvmtifiles directory contains jvmti*.[ch]pp
50 Src_Dirs_V = $(GENERATED)/adfiles $(GENERATED)/jvmtifiles ${Src_Dirs} $(GENERATED)/incls
51 VPATH += $(Src_Dirs_V:%=%:)
52
53 # set INCLUDES for C preprocessor
54 Src_Dirs_I = $(PRECOMPILED_HEADER_DIR) $(GENERATED)/adfiles $(GENERATED)/jvmtifiles ${Src_Dirs} $(GENERATED)
55 INCLUDES += $(Src_Dirs_I:%=-I%)
56
57 ifeq (${VERSION}, debug)
58 SYMFLAG = -g
59 else
60 SYMFLAG =
61 endif
62
63 # HOTSPOT_RELEASE_VERSION and HOTSPOT_BUILD_VERSION are defined
64 # in $(GAMMADIR)/make/defs.make
65 ifeq ($(HOTSPOT_BUILD_VERSION),)
66 BUILD_VERSION = -DHOTSPOT_RELEASE_VERSION="\"$(HOTSPOT_RELEASE_VERSION)\""
67 else
68 BUILD_VERSION = -DHOTSPOT_RELEASE_VERSION="\"$(HOTSPOT_RELEASE_VERSION)-$(HOTSPOT_BUILD_VERSION)\""
69 endif
70
71 # The following variables are defined in the generated flags.make file.
72 BUILD_VERSION = -DHOTSPOT_RELEASE_VERSION="\"$(HS_BUILD_VER)\""
73 JRE_VERSION = -DJRE_RELEASE_VERSION="\"$(JRE_RELEASE_VER)\""
74 BUILD_TARGET = -DHOTSPOT_BUILD_TARGET="\"$(TARGET)\""
75 BUILD_USER = -DHOTSPOT_BUILD_USER="\"$(HOTSPOT_BUILD_USER)\""
76 VM_DISTRO = -DHOTSPOT_VM_DISTRO="\"$(HOTSPOT_VM_DISTRO)\""
77
78 CPPFLAGS = \
79 ${SYSDEFS} \
80 ${INCLUDES} \
81 ${BUILD_VERSION} \
82 ${BUILD_TARGET} \
83 ${BUILD_USER} \
84 ${JRE_VERSION} \
85 ${VM_DISTRO}
86
87 # CFLAGS_WARN holds compiler options to suppress/enable warnings.
88 CFLAGS += $(CFLAGS_WARN/BYFILE)
89
90 # Do not use C++ exception handling
91 CFLAGS += $(CFLAGS/NOEX)
92
93 # Extra flags from gnumake's invocation or environment
94 CFLAGS += $(EXTRA_CFLAGS)
95
96 LIBS += -lm -ldl -lpthread
97
98 # By default, link the *.o into the library, not the executable.
99 LINK_INTO$(LINK_INTO) = LIBJVM
100
101 JDK_LIBDIR = $(JAVA_HOME)/jre/lib/$(LIBARCH)
102
103 #----------------------------------------------------------------------
104 # jvm_db & dtrace
105 include $(MAKEFILES_DIR)/dtrace.make
106
107 #----------------------------------------------------------------------
108 # JVM
109
110 JVM = jvm$(G_SUFFIX)
111 LIBJVM = lib$(JVM).so
112
113 JVM_OBJ_FILES = $(Obj_Files)
114
115 vm_version.o: $(filter-out vm_version.o,$(JVM_OBJ_FILES))
116
117 mapfile : $(MAPFILE)
118 rm -f $@
119 cat $^ > $@
120
121 mapfile_reorder : mapfile $(REORDERFILE)
122 rm -f $@
123 cat $^ > $@
124
125 STATIC_CXX = true
126
127 ifeq ($(LINK_INTO),AOUT)
128 LIBJVM.o =
129 LIBJVM_MAPFILE =
130 LIBS_VM = $(LIBS)
131 else
132 LIBJVM.o = $(JVM_OBJ_FILES)
133 LIBJVM_MAPFILE$(LDNOMAP) = mapfile_reorder
134 LFLAGS_VM$(LDNOMAP) += $(MAPFLAG:FILENAME=$(LIBJVM_MAPFILE))
135 LFLAGS_VM += $(SONAMEFLAG:SONAME=$(LIBJVM))
136
137 # JVM is statically linked with libgcc[_s] and libstdc++; this is needed to
138 # get around library dependency and compatibility issues. Must use gcc not
139 # g++ to link.
140 ifeq ($(STATIC_CXX), true)
141 LFLAGS_VM += $(STATIC_LIBGCC)
142 LIBS_VM += $(STATIC_STDCXX)
143 else
144 LIBS_VM += -lstdc++
145 endif
146
147 LIBS_VM += $(LIBS)
148 endif
149
150 LINK_VM = $(LINK_LIB.c)
151
152 # rule for building precompiled header
153 $(PRECOMPILED_HEADER): $(Precompiled_Files)
154 $(QUIETLY) echo Generating precompiled header $@
155 $(QUIETLY) mkdir -p $(PRECOMPILED_HEADER_DIR)/incls
156 $(QUIETLY) $(COMPILE.CC) -x c++-header -c $(GENERATED)/incls/_precompiled.incl -o $@ $(COMPILE_DONE)
157
158 # making the library:
159
160 ifneq ($(JVM_BASE_ADDR),)
161 # By default shared library is linked at base address == 0. Modify the
162 # linker script if JVM prefers a different base location. It can also be
163 # implemented with 'prelink -r'. But 'prelink' is not (yet) available on
164 # our build platform (AS-2.1).
165 LD_SCRIPT = libjvm.so.lds
166 $(LD_SCRIPT): $(LIBJVM_MAPFILE)
167 $(QUIETLY) { \
168 rm -rf $@; \
169 $(LINK_VM) -Wl,--verbose $(LFLAGS_VM) 2>&1 | \
170 sed -e '/^======/,/^======/!d' \
171 -e '/^======/d' \
172 -e 's/0\( + SIZEOF_HEADERS\)/$(JVM_BASE_ADDR)\1/' \
173 > $@; \
174 }
175 LD_SCRIPT_FLAG = -Wl,-T,$(LD_SCRIPT)
176 endif
177
178 # With more recent Redhat releases (or the cutting edge version Fedora), if
179 # SELinux is configured to be enabled, the runtime linker will fail to apply
180 # the text relocation to libjvm.so considering that it is built as a non-PIC
181 # DSO. To workaround that, we run chcon to libjvm.so after it is built. See
182 # details in bug 6538311.
183 $(LIBJVM): $(LIBJVM.o) $(LIBJVM_MAPFILE) $(LD_SCRIPT)
184 $(QUIETLY) { \
185 echo Linking vm...; \
186 $(LINK_LIB.CC/PRE_HOOK) \
187 $(LINK_VM) $(LD_SCRIPT_FLAG) \
188 $(LFLAGS_VM) -o $@ $(LIBJVM.o) $(LIBS_VM); \
189 $(LINK_LIB.CC/POST_HOOK) \
190 rm -f $@.1; ln -s $@ $@.1; \
191 if [ -x /usr/sbin/selinuxenabled ] ; then \
192 /usr/sbin/selinuxenabled; \
193 if [ $$? = 0 ] ; then \
194 /usr/bin/chcon -t textrel_shlib_t $@; \
195 if [ $$? != 0 ]; then \
196 echo "ERROR: Cannot chcon $@"; exit 1; \
197 fi \
198 fi \
199 fi \
200 }
201
202 DEST_JVM = $(JDK_LIBDIR)/$(VM_SUBDIR)/$(LIBJVM)
203
204 install_jvm: $(LIBJVM)
205 @echo "Copying $(LIBJVM) to $(DEST_JVM)"
206 $(QUIETLY) cp -f $(LIBJVM) $(DEST_JVM) && echo "Done"
207
208 #----------------------------------------------------------------------
209 # Other files
210
211 # Gamma launcher
212 include $(MAKEFILES_DIR)/launcher.make
213
214 # Signal interposition library
215 include $(MAKEFILES_DIR)/jsig.make
216
217 # Serviceability agent
218 include $(MAKEFILES_DIR)/saproc.make
219
220 #----------------------------------------------------------------------
221
222 build: $(LIBJVM) $(LAUNCHER) $(LIBJSIG) $(LIBJVM_DB) checkAndBuildSA
223
224 install: install_jvm install_jsig install_saproc
225
226 .PHONY: default build install install_jvm

mercurial