2
|
1 |
#
|
|
2 |
# Copyright 2000-2005 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. Sun designates this
|
|
8 |
# particular file as subject to the "Classpath" exception as provided
|
|
9 |
# by Sun in the LICENSE file that accompanied this code.
|
|
10 |
#
|
|
11 |
# This code is distributed in the hope that it will be useful, but WITHOUT
|
|
12 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
13 |
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
14 |
# version 2 for more details (a copy is included in the LICENSE file that
|
|
15 |
# accompanied this code).
|
|
16 |
#
|
|
17 |
# You should have received a copy of the GNU General Public License version
|
|
18 |
# 2 along with this work; if not, write to the Free Software Foundation,
|
|
19 |
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
20 |
#
|
|
21 |
# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
22 |
# CA 95054 USA or visit www.sun.com if you need additional information or
|
|
23 |
# have any questions.
|
|
24 |
#
|
|
25 |
|
|
26 |
# This Makefile is intended to produce new reordering files for the
|
|
27 |
# reordering of jar files and shared libraries. This is not part of the
|
|
28 |
# standard build. The objects produced by this Makefile must be copied
|
|
29 |
# into their standard locations and checked in.
|
|
30 |
|
|
31 |
BUILDDIR = ../..
|
|
32 |
PACKAGE = tools.reorder
|
|
33 |
PRODUCT = tools
|
|
34 |
include $(BUILDDIR)/common/Defs.gmk
|
|
35 |
|
|
36 |
OUTDIR = $(OUTPUTDIR)/reorder
|
|
37 |
PRELOAD_DIR = $(ABS_OUTPUTDIR)/reorder/$(ARCH)
|
|
38 |
|
|
39 |
ifeq ($(PLATFORM), windows)
|
|
40 |
SEP = \\
|
|
41 |
else
|
|
42 |
SEP = /
|
|
43 |
endif
|
|
44 |
|
|
45 |
CLASSDIR = $(OUTDIR)/classes
|
|
46 |
OBJDIR = $(OUTDIR)/$(ARCH)
|
|
47 |
TESTS = Null Exit Hello Sleep IntToString \
|
|
48 |
LoadToolkit LoadFrame LoadJFrame JHello
|
|
49 |
TEST_CLASSES = $(TESTS:%=$(CLASSDIR)/%.class)
|
|
50 |
SWINGSET2 = $(OUTPUTDIR)/demo/jfc/SwingSet2/SwingSet2.jar
|
|
51 |
|
|
52 |
# Run java from the JRE image because using rt.jar requires a
|
|
53 |
# larger list of classes, and these should appear in the list.
|
|
54 |
# FIXUP: adding rt.jar into bootclasspath?
|
|
55 |
JRE_LIB = $(JRE_IMAGE_DIR)/lib
|
|
56 |
BOOTPATH = -Xbootclasspath:$(JRE_LIB)/rt.jar:$(JRE_LIB)/charsets.jar
|
|
57 |
JRE_JAVA = $(JRE_IMAGE_DIR)/bin/java
|
|
58 |
|
|
59 |
JAVA_BIN = $(BINDIR)/java
|
|
60 |
|
|
61 |
all : jars.reorder libs.reorder
|
|
62 |
|
|
63 |
tools : $(OBJDIR) $(OBJDIR)/libmcount.so $(OBJDIR)/remove_mcount
|
|
64 |
|
|
65 |
copy : jars.copy libs.copy
|
|
66 |
|
|
67 |
clean :
|
|
68 |
$(RM) $(REORDER_JAR)
|
|
69 |
|
|
70 |
clobber : clean
|
|
71 |
$(RM) -r $(OUTDIR)
|
|
72 |
|
|
73 |
|
|
74 |
jars.reorder :
|
|
75 |
$(MAKE) JARFILE=rt.jar reorder.jar
|
|
76 |
$(MAKE) JARFILE=charsets.jar reorder.jar
|
|
77 |
|
|
78 |
jars.copy:
|
|
79 |
$(CP) $(OUTDIR)/reorder_rt_jar-$(PLATFORM) reorder_rt_jar-$(PLATFORM)
|
|
80 |
$(CP) $(OUTDIR)/reorder_charsets_jar-$(PLATFORM) reorder_charsets_jar-$(PLATFORM)
|
|
81 |
|
|
82 |
REORDER_JAR = $(OUTDIR)/reorder_$(subst .,_,$(JARFILE))-$(PLATFORM)
|
|
83 |
reorder.jar : $(REORDER_JAR)
|
|
84 |
|
|
85 |
libs.reorder :
|
|
86 |
ifeq ($(PLATFORM), solaris)
|
|
87 |
$(MAKE) LIBBLDDIR=java/zip LIBTMPDIR=sun/java.util.zip/zip reorder.lib
|
|
88 |
$(MAKE) LIBBLDDIR=java/hpi/native LIBTMPDIR=java/hpi/native_threads reorder.lib
|
|
89 |
$(MAKE) LIBBLDDIR=java/java LIBTMPDIR=java/java.lang/java reorder.lib
|
|
90 |
$(MAKE) LIBBLDDIR=java/nio LIBTMPDIR=java/java.nio/nio reorder.lib
|
|
91 |
$(MAKE) LIBBLDDIR=sun/font LIBTMPDIR=sun/sun.awt.font/fontmanager reorder.lib
|
|
92 |
$(MAKE) LIBBLDDIR=sun/jpeg LIBTMPDIR=sun/sun.awt/jpeg reorder.lib
|
|
93 |
$(MAKE) LIBBLDDIR=java/verify LIBTMPDIR=java/verify reorder.lib
|
|
94 |
endif
|
|
95 |
|
|
96 |
libs.copy:
|
|
97 |
ifeq ($(PLATFORM), solaris)
|
|
98 |
$(CP) $(OUTDIR)/reorder_java_zip-$(ARCH) ../../java/zip/reorder-$(ARCH)
|
|
99 |
$(CP) $(OUTDIR)/reorder_java_hpi_native-$(ARCH) ../../java/hpi/native/reorder-$(ARCH)
|
|
100 |
$(CP) $(OUTDIR)/reorder_java_java-$(ARCH) ../../java/java/reorder-$(ARCH)
|
|
101 |
$(CP) $(OUTDIR)/reorder_sun_font-$(ARCH) ../../sun/font/reorder-$(ARCH)
|
|
102 |
$(CP) $(OUTDIR)/reorder_sun_jpeg-$(ARCH) ../../sun/jpeg/reorder-$(ARCH)
|
|
103 |
$(CP) $(OUTDIR)/reorder_java_verify-$(ARCH) ../../java/verify/reorder-$(ARCH)
|
|
104 |
endif
|
|
105 |
|
|
106 |
REORDER_LIB = $(OUTDIR)/reorder_$(subst /,_,$(LIBBLDDIR))-$(ARCH)
|
|
107 |
reorder.lib : $(OBJDIR) $(REORDER_LIB)
|
|
108 |
|
|
109 |
|
|
110 |
# This target 'test_classes' also used by hotspot reordering.
|
|
111 |
test_classes : $(TEST_CLASSES)
|
|
112 |
|
|
113 |
# This target 'tool_classes' also used by hotspot reordering.
|
|
114 |
tool_classes : $(CLASSDIR) $(CLASSDIR)/Combine.class $(CLASSDIR)/MaxTime.class
|
|
115 |
|
|
116 |
$(REORDER_JAR) : $(CLASSDIR) test_classes tool_classes
|
|
117 |
$(RM) $(REORDER_JAR)
|
|
118 |
|
|
119 |
@$(ECHO) "# Ordered list of files to include in $(JARFILE)." > $(REORDER_JAR)
|
|
120 |
@$(ECHO) "# This is a generated file - do not edit." >> $(REORDER_JAR)
|
|
121 |
@$(ECHO) "#" >> $(REORDER_JAR)
|
|
122 |
|
|
123 |
@# Run each of a set of tests, extract the classes required and
|
|
124 |
@# append the new classes to the ClassList.
|
|
125 |
|
|
126 |
@for f in $(TESTS) ; do \
|
|
127 |
$(ECHO) Running test $$f.; \
|
|
128 |
$(RM) $(REORDER_JAR)_tmp1; \
|
|
129 |
echo "# Test $$f" >> $(REORDER_JAR); \
|
|
130 |
$(JRE_JAVA) -verbose -classpath $(CLASSDIR) $$f | \
|
|
131 |
$(SED) -n -e 's=\[Loaded \(.*\) from .*$(SEP)lib$(SEP)$(JARFILE)]=\1=p' | \
|
|
132 |
$(SED) -e 's=\.=/=g' -e 's=$$=.class=' \
|
|
133 |
> $(REORDER_JAR)_tmp1; \
|
|
134 |
$(JRE_JAVA) -classpath $(CLASSDIR) Combine \
|
|
135 |
$(REORDER_JAR) $(REORDER_JAR)_tmp1 \
|
|
136 |
> $(REORDER_JAR)_tmp2; \
|
|
137 |
$(MV) $(REORDER_JAR)_tmp2 $(REORDER_JAR); \
|
|
138 |
$(RM) $(REORDER_JAR)_tmp1; \
|
|
139 |
done
|
|
140 |
|
|
141 |
@# Run SwingSet2, extract the classes required and
|
|
142 |
@# append the new classes to the ClassList.
|
|
143 |
|
|
144 |
@$(RM) $(REORDER_JAR)_tmp1
|
|
145 |
@$(RM) $(REORDER_JAR)_tmp2
|
|
146 |
@$(ECHO) "# SwingSet2" >> $(REORDER_JAR)
|
|
147 |
|
|
148 |
@$(ECHO) ""
|
|
149 |
@$(ECHO) ""
|
|
150 |
@$(ECHO) "When SwingSet2 has finished drawing, " \
|
|
151 |
"you may terminate it (with your mouse)."
|
|
152 |
@$(ECHO) "Otherwise, it should be automatically terminated in 2 minutes."
|
|
153 |
@$(ECHO) ""
|
|
154 |
@$(ECHO) ""
|
|
155 |
|
|
156 |
$(JRE_JAVA) -verbose -classpath $(CLASSDIR) MaxTime $(SWINGSET2) 120 \
|
|
157 |
> $(REORDER_JAR)_tmp2
|
|
158 |
|
|
159 |
$(SED) -n -e 's=\[Loaded \(.*\) from .*$(SEP)lib$(SEP)$(JARFILE)]=\1=p' \
|
|
160 |
< $(REORDER_JAR)_tmp2 | \
|
|
161 |
$(SED) -e 's=\.=/=g' -e 's=$$=.class=' > $(REORDER_JAR)_tmp1
|
|
162 |
|
|
163 |
$(RM) $(REORDER_JAR)_tmp2
|
|
164 |
$(JRE_JAVA) -classpath $(CLASSDIR) Combine \
|
|
165 |
$(REORDER_JAR) $(REORDER_JAR)_tmp1 > $(REORDER_JAR)_tmp2
|
|
166 |
$(MV) $(REORDER_JAR)_tmp2 $(REORDER_JAR)
|
|
167 |
$(RM) $(REORDER_JAR)_tmp1
|
|
168 |
|
|
169 |
$(CLASSDIR) :
|
|
170 |
$(MKDIR) -p $(CLASSDIR)
|
|
171 |
|
|
172 |
$(CLASSDIR)/%.class : tools/%.java
|
|
173 |
$(JAVAC_CMD) -d $(CLASSDIR) $<
|
|
174 |
$(CLASSDIR)/%.class : tests/%.java
|
|
175 |
$(JAVAC_CMD) -d $(CLASSDIR) $<
|
|
176 |
|
|
177 |
$(OBJDIR) :
|
|
178 |
$(MKDIR) -p $(OBJDIR)
|
|
179 |
|
|
180 |
|
|
181 |
MCOUNT_SRC = mcount.c
|
|
182 |
MCOUNT_OBJ = $(MCOUNT_SRC:%.c=$(OBJDIR)/%.o)
|
|
183 |
vpath %.c tools
|
|
184 |
|
|
185 |
$(OBJDIR)/%.o : %.c tools/util-$(ARCH).il
|
|
186 |
$(COMPILE.c) $(CC_OBJECT_OUTPUT_FLAG)$@ $^
|
|
187 |
|
|
188 |
# This library 'libmcount.so' also used by hotspot reordering.
|
|
189 |
$(OBJDIR)/libmcount.so : $(MCOUNT_OBJ)
|
|
190 |
$(CC) -G -mt -zdefs -o $@ $^ -ldl -lelf $(EXTRA_LIBS)
|
|
191 |
|
|
192 |
# This library 'libmcount.so' also used by hotspot reordering.
|
|
193 |
$(OBJDIR)/remove_mcount : remove_mcount.c
|
|
194 |
$(CC) -g -o $@ $^ -ldl -lelf $(EXTRA_LIBS)
|
|
195 |
|
|
196 |
|
|
197 |
# Reorder libraries.
|
|
198 |
# + Delete all of the library's object files, and recompile them for profiling.
|
|
199 |
# + Run the test sequence using libmcount to produce the mapfile.
|
|
200 |
# + Delete all of the library's object files, and recompile them normally.
|
|
201 |
|
|
202 |
$(REORDER_LIB): $(OBJDIR)/libmcount.so $(OBJDIR)/remove_mcount \
|
|
203 |
test_classes tool_classes
|
|
204 |
|
|
205 |
ifeq ($(ARCH), i586)
|
|
206 |
@# On Solaris-i586 we need to remove the symbol _mcount from the command
|
|
207 |
$(OBJDIR)/remove_mcount $(BINDIR)/java
|
|
208 |
endif
|
|
209 |
|
|
210 |
$(RM) $(OUTPUTDIR)/tmp/$(LIBTMPDIR)/$(OBJDIRNAME)/*.o
|
|
211 |
$(CD) $(BUILDDIR)/$(LIBBLDDIR) ; \
|
|
212 |
$(MAKE) PARTIAL_GPROF=true LDNOMAP=true NO_ROBOT=true all
|
|
213 |
|
|
214 |
$(RM) $(REORDER_LIB)
|
|
215 |
@$(ECHO) "data = R0x2000;" > $(REORDER_LIB)
|
|
216 |
@$(ECHO) "text = LOAD ?RXO;" >> $(REORDER_LIB)
|
|
217 |
|
|
218 |
@# Run each of a set of tests, extract the classes required and
|
|
219 |
@# append the new classes to the ClassList.
|
|
220 |
|
|
221 |
for f in $(TESTS) ; do \
|
|
222 |
$(ECHO) Running test $$f.; \
|
|
223 |
$(RM) $(REORDER_LIB)_tmp1; \
|
|
224 |
$(ECHO) "# Test $$f" >> $(REORDER_LIB); \
|
|
225 |
LD_PRELOAD=$(PRELOAD_DIR)/libmcount.so \
|
|
226 |
$(SETENV) \
|
|
227 |
$(JAVA_BIN) $(BOOTPATH) -classpath $(CLASSDIR) $$f \
|
|
228 |
2> $(REORDER_LIB)_tmp1; \
|
|
229 |
$(SED) -n -e 's=[./]*$(OUTPUTDIR)=OUTPUTDIR=' -e '/^text:/p' \
|
|
230 |
$(REORDER_LIB)_tmp1 > $(REORDER_LIB)_tmp2; \
|
|
231 |
$(SED) -e '/^text:/d' $(REORDER_LIB)_tmp1; \
|
|
232 |
$(JRE_JAVA) -classpath $(CLASSDIR) Combine \
|
|
233 |
$(REORDER_LIB) $(REORDER_LIB)_tmp2 \
|
|
234 |
> $(REORDER_LIB)_tmp3; \
|
|
235 |
$(MV) $(REORDER_LIB)_tmp3 $(REORDER_LIB); \
|
|
236 |
$(RM) $(REORDER_LIB)_tmp2; \
|
|
237 |
$(RM) $(REORDER_LIB)_tmp1; \
|
|
238 |
done
|
|
239 |
|
|
240 |
@# Run SwingSet2, extract the classes required and
|
|
241 |
@# append the new classes to the ClassList.
|
|
242 |
|
|
243 |
@$(RM) $(REORDER_LIB)_tmp1
|
|
244 |
@$(RM) $(REORDER_JAR)_tmp2
|
|
245 |
@$(ECHO) "# SwingSet2" >> $(REORDER_LIB)
|
|
246 |
|
|
247 |
@$(ECHO) ""
|
|
248 |
@$(ECHO) ""
|
|
249 |
@$(ECHO) "When SwingSet2 has finished drawing, " \
|
|
250 |
"you may terminate it (with your mouse)."
|
|
251 |
@$(ECHO) "Otherwise, it should be automatically terminated in 2 minutes."
|
|
252 |
@$(ECHO) ""
|
|
253 |
@$(ECHO) ""
|
|
254 |
|
|
255 |
LD_PRELOAD=$(PRELOAD_DIR)/libmcount.so \
|
|
256 |
$(SETENV) \
|
|
257 |
$(JAVA_BIN) $(BOOTPATH) -classpath $(CLASSDIR) MaxTime \
|
|
258 |
$(SWINGSET2) 120 2> $(REORDER_LIB)_tmp1
|
|
259 |
|
|
260 |
$(SED) -n -e 's=[./]*$(OUTPUTDIR)=OUTPUTDIR=' -e '/^text:/p' \
|
|
261 |
$(REORDER_LIB)_tmp1 > $(REORDER_LIB)_tmp2
|
|
262 |
$(SED) -e '/^text:/d' $(REORDER_LIB)_tmp1
|
|
263 |
$(JRE_JAVA) -classpath $(CLASSDIR) Combine \
|
|
264 |
$(REORDER_LIB) $(REORDER_LIB)_tmp2 \
|
|
265 |
> $(REORDER_LIB)_tmp3
|
|
266 |
$(MV) $(REORDER_LIB)_tmp3 $(REORDER_LIB)
|
|
267 |
$(RM) $(REORDER_LIB)_tmp2
|
|
268 |
$(RM) $(REORDER_LIB)_tmp1
|
|
269 |
|
|
270 |
$(RM) $(OUTPUTDIR)/tmp/$(LIBTMPDIR)/$(OBJDIRNAME)/*.o
|
|
271 |
$(CD) $(BUILDDIR)/$(LIBBLDDIR) ; $(MAKE) all
|
|
272 |
|
|
273 |
.PHONY: test_classes tool_classes
|