author | smarks |
Sat, 17 Dec 2011 08:21:23 -0800 | |
changeset 11285 | ba471669d352 |
parent 11118 | 5935bcaa1e5c |
child 12047 | 320a714614e9 |
permissions | -rw-r--r-- |
2 | 1 |
# |
5506 | 2 |
# Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved. |
2 | 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 |
|
5506 | 7 |
# published by the Free Software Foundation. Oracle designates this |
2 | 8 |
# particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
# by Oracle in the LICENSE file that accompanied this code. |
2 | 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 |
# |
|
5506 | 21 |
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
# or visit www.oracle.com if you need additional information or have any |
|
23 |
# questions. |
|
2 | 24 |
# |
25 |
||
26 |
# |
|
27 |
# |
|
28 |
# Rules shared by all Java makefiles. |
|
29 |
# |
|
30 |
# Used to apply to source file $<, checks code conventions, issues warnings. |
|
31 |
define check-conventions |
|
32 |
if [ "$(CONVENTION_WATCH)" = "true" ] ; then \ |
|
33 |
if [ "`$(CAT) -n -v -t $< | $(EGREP) -v '\@\(\#\)' | $(EGREP) '\^[MLI]'`" != "" ] ; then \ |
|
34 |
$(ECHO) "WARNING: File contains tabs, ^M, or ^L characters: $<"; \ |
|
35 |
if [ "$(CONVENTION_DETAILS)" = "true" ] ; then \ |
|
36 |
$(CAT) -n -v -t $< | $(EGREP) -v '\@\(\#\)' | $(EGREP) '\^[MLI]' ; \ |
|
37 |
fi; \ |
|
38 |
fi; \ |
|
39 |
fi |
|
40 |
endef |
|
41 |
||
42 |
# Make sure the default rule is all |
|
43 |
rules_default_rule: all |
|
44 |
||
45 |
# |
|
46 |
# Directory set up. (Needed by deploy workspace) |
|
47 |
# |
|
48 |
$(CLASSDESTDIR) $(CLASSHDRDIR) $(OBJDIR) $(OUTPUTDIR) $(BINDIR) $(LIBDIR) $(LIBDIR)/$(LIBARCH) $(TEMPDIR) $(EXTDIR): |
|
49 |
$(MKDIR) -p $@ |
|
50 |
||
51 |
# |
|
52 |
# All source tree areas for java/properties files (a few may be closed) |
|
53 |
# |
|
54 |
ifdef OPENJDK |
|
55 |
ALL_CLASSES_SRC = $(SHARE_SRC)/classes $(PLATFORM_SRC)/classes |
|
56 |
else |
|
57 |
ALL_CLASSES_SRC = \ |
|
58 |
$(CLOSED_SHARE_SRC)/classes $(CLOSED_PLATFORM_SRC)/classes \ |
|
59 |
$(SHARE_SRC)/classes $(PLATFORM_SRC)/classes |
|
60 |
endif |
|
61 |
||
62 |
# |
|
63 |
# If AUTO_FILES_PROPERTIES_DIRS used, automatically find properties files |
|
64 |
# |
|
65 |
ifdef AUTO_FILES_PROPERTIES_DIRS |
|
4115
e09be02771b6
6888701: Change all template java source files to a .java-template file suffix
ohair
parents:
715
diff
changeset
|
66 |
AUTO_FILES_PROPERTIES_FILTERS1 = $(SCM_DIRs) ',*' |
2 | 67 |
AUTO_FILES_PROPERTIES_FILTERS1 += $(AUTO_PROPERTIES_PRUNE) |
68 |
FILES_properties_find_filters1 = $(AUTO_FILES_PROPERTIES_FILTERS1:%=-name % -prune -o) |
|
69 |
FILES_properties_auto1 := \ |
|
70 |
$(shell \ |
|
71 |
for dir in $(ALL_CLASSES_SRC) ; do \ |
|
72 |
if [ -d $$dir ] ; then \ |
|
73 |
( $(CD) $$dir; \ |
|
74 |
for sdir in $(AUTO_FILES_PROPERTIES_DIRS); do \ |
|
75 |
if [ -d $$sdir ] ; then \ |
|
76 |
$(FIND) $$sdir $(FILES_properties_find_filters1) \ |
|
77 |
-name '*.properties' -print ; \ |
|
78 |
fi ; \ |
|
79 |
done \ |
|
80 |
); \ |
|
81 |
fi; \ |
|
82 |
done \ |
|
83 |
) |
|
84 |
else |
|
85 |
FILES_properties_auto1 = |
|
86 |
endif # AUTO_FILES_PROPERTIES_DIRS |
|
87 |
||
88 |
# Add any automatically found properties files to the properties file list |
|
89 |
FILES_properties += $(FILES_properties_auto1) |
|
90 |
||
91 |
# |
|
92 |
# Get Resources help |
|
93 |
# |
|
94 |
include $(JDK_TOPDIR)/make/common/internal/Resources.gmk |
|
95 |
||
96 |
# |
|
97 |
# Compiling .java files. |
|
98 |
# |
|
99 |
||
100 |
# |
|
101 |
# Automatically add to FILES_java if AUTO_FILES_JAVA_DIRS is defined |
|
102 |
# |
|
103 |
# There are two basic types of sources, normal source files and the |
|
104 |
# generated ones. The Normal sources will be located in: |
|
105 |
# $(ALL_CLASSES_SRC) |
|
106 |
# The generated sources, which might show up late to dinner, are at: |
|
107 |
# $(GENSRCDIR) |
|
108 |
# and since they could be generated late, we need to be careful that |
|
109 |
# we look for these sources late and not use the ':=' assignment which |
|
110 |
# might miss their generation. |
|
111 |
||
112 |
ifdef AUTO_FILES_JAVA_DIRS |
|
113 |
# Filter out these files or directories |
|
4115
e09be02771b6
6888701: Change all template java source files to a .java-template file suffix
ohair
parents:
715
diff
changeset
|
114 |
AUTO_FILES_JAVA_SOURCE_FILTERS1 = $(SCM_DIRs) ',*' |
2 | 115 |
AUTO_FILES_JAVA_SOURCE_FILTERS2 = |
116 |
AUTO_FILES_JAVA_SOURCE_FILTERS1 += $(AUTO_JAVA_PRUNE) |
|
117 |
AUTO_FILES_JAVA_SOURCE_FILTERS2 += $(AUTO_JAVA_PRUNE) |
|
118 |
||
119 |
# First list is the normal sources that should always be there, |
|
120 |
# by using the ':=', which means we do this processing once. |
|
121 |
FILES_java_find_filters1 = $(AUTO_FILES_JAVA_SOURCE_FILTERS1:%=-name % -prune -o) |
|
122 |
FILES_java_auto1 := \ |
|
123 |
$(shell \ |
|
124 |
for dir in $(ALL_CLASSES_SRC) ; do \ |
|
125 |
if [ -d $$dir ] ; then \ |
|
126 |
( $(CD) $$dir; \ |
|
127 |
for sdir in $(AUTO_FILES_JAVA_DIRS); do \ |
|
128 |
if [ -d $$sdir ] ; then \ |
|
129 |
$(FIND) $$sdir $(FILES_java_find_filters1) \ |
|
130 |
-name '*.java' -print ; \ |
|
131 |
fi ; \ |
|
132 |
done \ |
|
133 |
); \ |
|
134 |
fi; \ |
|
135 |
done \ |
|
136 |
) |
|
137 |
# Second list is the generated sources that should be rare, but will likely |
|
138 |
# show up late and we need to look for them at the last minute, so we |
|
139 |
# cannot use the ':=' assigment here. But if this gets expanded multiple |
|
140 |
# times, the if tests should make them relatively cheap. |
|
141 |
FILES_java_find_filters2 = $(AUTO_FILES_JAVA_SOURCE_FILTERS2:%=-name % -prune -o) |
|
142 |
FILES_java_auto2 = \ |
|
143 |
$(shell \ |
|
144 |
for dir in $(GENSRCDIR); do \ |
|
145 |
if [ -d $$dir ] ; then \ |
|
146 |
( $(CD) $$dir; \ |
|
147 |
for sdir in $(AUTO_FILES_JAVA_DIRS); do \ |
|
148 |
if [ -d $$sdir ] ; then \ |
|
149 |
$(FIND) $$sdir $(FILES_java_find_filters2) \ |
|
150 |
-name '*.java' -print ; \ |
|
151 |
fi ; \ |
|
152 |
done \ |
|
153 |
); \ |
|
154 |
fi; \ |
|
155 |
done \ |
|
156 |
) |
|
157 |
else |
|
158 |
FILES_java_auto1 = |
|
159 |
FILES_java_auto2 = |
|
160 |
endif |
|
161 |
||
162 |
# Add all found java sources to FILES_java macro (if AUTO_FILES_JAVA_DIRS used) |
|
163 |
FILES_java += $(FILES_java_auto1) $(FILES_java_auto2) |
|
164 |
||
165 |
# File that will hold java source names that need compiling |
|
166 |
JAVA_SOURCE_LIST=$(TEMPDIR)/.classes.list |
|
167 |
||
168 |
# Add a java source to the list |
|
169 |
define add-java-file |
|
170 |
$(ECHO) "$?" >> $(JAVA_SOURCE_LIST) |
|
171 |
$(check-conventions) |
|
172 |
endef |
|
173 |
||
174 |
ifdef DEMOS |
|
175 |
$(CLASSDESTDIR)/%.class: $(SOURCEPATH)/%.java |
|
176 |
@$(add-java-file) |
|
177 |
#Redirect zh_HK java files to tmp directory which created from zh_TW |
|
178 |
#$(CLASSDESTDIR)/%_zh_HK.class: $(JDK_L10N_TMP_OUTPUTDIR)/%_zh_HK.java |
|
179 |
# @$(add-java-file) |
|
180 |
else |
|
181 |
||
182 |
# |
|
183 |
# Rules for closed files |
|
184 |
# |
|
185 |
# If filenames are duplicated between open/closed workspaces, prefer |
|
186 |
# the closed files. |
|
187 |
# |
|
188 |
# Rule ordering in this Makefile is important: some targets depend |
|
189 |
# on closed files replacing open ones, and thus the closed file rules |
|
190 |
# must be found before the open ones. |
|
191 |
# |
|
192 |
# Don't reorder without consulting teams that depend on this behavior. |
|
193 |
# |
|
194 |
ifndef OPENJDK |
|
195 |
$(CLASSDESTDIR)/%.class: $(CLOSED_PLATFORM_SRC)/classes/%.java |
|
196 |
@$(add-java-file) |
|
197 |
$(CLASSDESTDIR)/%.class: $(CLOSED_SHARE_SRC)/classes/%.java |
|
198 |
@$(add-java-file) |
|
199 |
endif |
|
200 |
||
201 |
$(CLASSDESTDIR)/%.class: $(GENSRCDIR)/%.java |
|
202 |
@$(add-java-file) |
|
203 |
$(CLASSDESTDIR)/%.class: $(PLATFORM_SRC)/classes/%.java |
|
204 |
@$(add-java-file) |
|
205 |
$(CLASSDESTDIR)/%.class: $(SHARE_SRC)/classes/%.java |
|
206 |
@$(add-java-file) |
|
207 |
||
208 |
#Redirect zh_HK java files to tmp directory which created from zh_TW |
|
209 |
$(CLASSDESTDIR)/%_zh_HK.class: $(JDK_L10N_TMP_OUTPUTDIR)/%_zh_HK.java |
|
210 |
@$(add-java-file) |
|
211 |
endif |
|
212 |
||
213 |
# List of class files needed |
|
214 |
FILES_class = $(FILES_java:%.java=$(CLASSDESTDIR)/%.class) |
|
215 |
||
216 |
# Got to include exported files. |
|
217 |
FILES_class += $(FILES_export:%.java=$(CLASSDESTDIR)/%.class) |
|
218 |
||
219 |
# Construct list of java sources we need to compile |
|
220 |
source_list_prime: |
|
221 |
@$(MKDIR) -p $(TEMPDIR) |
|
222 |
# Note that we slip resources in so that compiled properties files get created: |
|
223 |
$(JAVA_SOURCE_LIST) : source_list_prime resources $(FILES_class) |
|
224 |
@$(TOUCH) $@ |
|
225 |
||
226 |
.delete.classlist: |
|
227 |
@$(RM) $(JAVA_SOURCE_LIST) |
|
228 |
||
229 |
# Make sure all newer sources are compiled (in a batch) |
|
230 |
classes : $(CLASSES_INIT) .delete.classlist .compile.classlist |
|
231 |
||
232 |
.compile.classlist : $(JAVA_SOURCE_LIST) |
|
233 |
@$(MKDIR) -p $(CLASSDESTDIR) |
|
313
4ca328b9cf83
6641585: jdk/make/javax/Makefile should not have both SUBDIRS and AUTO_FILES_JAVA_DIRS
ohair
parents:
2
diff
changeset
|
234 |
@$(RM) $<.filtered |
4ca328b9cf83
6641585: jdk/make/javax/Makefile should not have both SUBDIRS and AUTO_FILES_JAVA_DIRS
ohair
parents:
2
diff
changeset
|
235 |
@$(CAT) $< | $(NAWK) 'length>0' | $(SORT) -u > $<.filtered |
11118
5935bcaa1e5c
7116322: enhance javac make rule with a little bit of instrumentation
smarks
parents:
5506
diff
changeset
|
236 |
@numfiles=`$(WC) -l < $<.filtered` ; \ |
5935bcaa1e5c
7116322: enhance javac make rule with a little bit of instrumentation
smarks
parents:
5506
diff
changeset
|
237 |
if [ $$numfiles -ge 1 ] ; then \ |
5935bcaa1e5c
7116322: enhance javac make rule with a little bit of instrumentation
smarks
parents:
5506
diff
changeset
|
238 |
$(ECHO) "# Java sources to be compiled: (listed in file $<)"; \ |
5935bcaa1e5c
7116322: enhance javac make rule with a little bit of instrumentation
smarks
parents:
5506
diff
changeset
|
239 |
$(CAT) $<.filtered; \ |
5935bcaa1e5c
7116322: enhance javac make rule with a little bit of instrumentation
smarks
parents:
5506
diff
changeset
|
240 |
$(ECHO) "# Running javac: $$numfiles files; in $(CURDIR)"; \ |
5935bcaa1e5c
7116322: enhance javac make rule with a little bit of instrumentation
smarks
parents:
5506
diff
changeset
|
241 |
$(ECHO) $(JAVAC_CMD) -sourcepath "$(SOURCEPATH)" -d $(CLASSDESTDIR) @$<.filtered; \ |
11285 | 242 |
$(JAVAC_CMD) -sourcepath "$(SOURCEPATH)" -d $(CLASSDESTDIR) @$<.filtered && \ |
11118
5935bcaa1e5c
7116322: enhance javac make rule with a little bit of instrumentation
smarks
parents:
5506
diff
changeset
|
243 |
$(ECHO) "# javac finished"; \ |
5935bcaa1e5c
7116322: enhance javac make rule with a little bit of instrumentation
smarks
parents:
5506
diff
changeset
|
244 |
fi |
2 | 245 |
@$(java-vm-cleanup) |
246 |
||
247 |
clobber clean:: |
|
248 |
$(RM) $(JAVA_SOURCE_LIST) |
|
249 |
||
250 |
ifndef DONT_CLOBBER_CLASSES |
|
251 |
ifndef PACKAGE |
|
252 |
DONT_CLOBBER_CLASSES = true |
|
253 |
else |
|
254 |
DONT_CLOBBER_CLASSES = false |
|
255 |
endif |
|
256 |
endif |
|
257 |
||
258 |
packages.clean: |
|
259 |
ifeq ($(DONT_CLOBBER_CLASSES),false) |
|
260 |
ifdef AUTO_FILES_JAVA_DIRS |
|
261 |
@for sdir in $(AUTO_FILES_JAVA_DIRS); do \ |
|
262 |
$(ECHO) "$(RM) -r $(CLASSDESTDIR)/$$sdir"; \ |
|
263 |
$(RM) -r $(CLASSDESTDIR)/$$sdir; \ |
|
264 |
done |
|
265 |
else |
|
266 |
$(RM) -r $(CLASSDESTDIR)/$(PKGDIR) |
|
267 |
endif |
|
268 |
endif |
|
269 |
||
270 |
ifdef DEMOS |
|
271 |
classes.clean: |
|
272 |
$(RM) -r $(DEMODST) $(CLASSDESTDIR) |
|
273 |
else |
|
274 |
classes.clean: packages.clean |
|
275 |
$(RM) $(JAVA_SOURCE_LIST) |
|
276 |
endif |
|
277 |
||
278 |
# |
|
279 |
# C and C++ make dependencies |
|
280 |
# |
|
281 |
include $(JDK_TOPDIR)/make/common/internal/NativeCompileRules.gmk |
|
282 |
||
283 |
# |
|
284 |
# Running Javah to generate stuff into CClassHeaders. |
|
285 |
# |
|
286 |
||
287 |
ifdef FILES_export |
|
288 |
||
289 |
CLASSES.export = $(subst /,.,$(FILES_export:%.java=%)) |
|
290 |
CLASSES.export += $(subst /,.,$(FILES_export2:%.java=%)) |
|
291 |
CLASSES.export += $(subst /,.,$(FILES_export3:%.java=%)) |
|
292 |
CLASSES_export = $(FILES_export:%.java=$(CLASSDESTDIR)/%.class) |
|
293 |
CLASSES_export += $(FILES_export2:%.java=$(CLASSDESTDIR)/%.class) |
|
294 |
CLASSES_export += $(FILES_export3:%.java=$(CLASSDESTDIR)/%.class) |
|
295 |
||
296 |
# Fix when deploy workspace makefiles don't depend on this name |
|
297 |
#CLASSHDR_DOTFILE=$(CLASSHDRDIR)/.classheaders |
|
298 |
||
299 |
CLASSHDR_DOTFILE=$(OBJDIR)/.class.headers.$(ARCH) |
|
300 |
||
301 |
classheaders: classes $(CLASSHDR_DOTFILE) |
|
302 |
||
303 |
$(CLASSHDR_DOTFILE): $(CLASSES_export) |
|
304 |
$(prep-target) |
|
305 |
@$(ECHO) "# Running javah:" |
|
306 |
$(JAVAH_CMD) -d $(CLASSHDRDIR)/ \ |
|
307 |
$(CLASSES.export) $(subst $$,\$$,$(EXPORTED_inner)) |
|
308 |
@$(java-vm-cleanup) |
|
309 |
@$(TOUCH) $@ |
|
310 |
||
311 |
classheaders.clean: |
|
312 |
$(RM) $(CLASSHDR_DOTFILE) |
|
313 |
$(RM) -r $(CLASSHDRDIR) |
|
314 |
||
315 |
else # FILES_export |
|
316 |
||
317 |
classheaders: classes |
|
318 |
||
319 |
classheaders.clean: |
|
320 |
||
321 |
endif # FILES_export |
|
322 |
||
323 |
clean clobber:: classheaders.clean classes.clean .delete.classlist |
|
324 |
||
325 |
# |
|
326 |
# Default dependencies |
|
327 |
# |
|
328 |
||
329 |
all: build |
|
330 |
||
331 |
build: classheaders |
|
332 |
||
333 |
default: all |
|
334 |
||
335 |
.PHONY: all build clean clobber \ |
|
336 |
.delete.classlist classes .compile.classlist classes.clean \ |
|
337 |
classheaders classheaders.clean \ |
|
338 |
batch_compile |
|
339 |