author | lana |
Sun, 29 Aug 2010 22:42:08 -0700 | |
changeset 6358 | 5f588b83d6b9 |
parent 5506 | 202f599c92aa |
child 11118 | 5935bcaa1e5c |
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 |
4ca328b9cf83
6641585: jdk/make/javax/Makefile should not have both SUBDIRS and AUTO_FILES_JAVA_DIRS
ohair
parents:
2
diff
changeset
|
236 |
@if [ `$(CAT) $<.filtered | $(WC) -l` -ge 1 ] ; then \ |
4ca328b9cf83
6641585: jdk/make/javax/Makefile should not have both SUBDIRS and AUTO_FILES_JAVA_DIRS
ohair
parents:
2
diff
changeset
|
237 |
$(ECHO) "# Java sources to be compiled: (listed in file $<)"; \ |
4ca328b9cf83
6641585: jdk/make/javax/Makefile should not have both SUBDIRS and AUTO_FILES_JAVA_DIRS
ohair
parents:
2
diff
changeset
|
238 |
$(CAT) $<.filtered; \ |
2 | 239 |
$(ECHO) "# Running javac:"; \ |
313
4ca328b9cf83
6641585: jdk/make/javax/Makefile should not have both SUBDIRS and AUTO_FILES_JAVA_DIRS
ohair
parents:
2
diff
changeset
|
240 |
$(ECHO) $(JAVAC_CMD) -sourcepath "$(SOURCEPATH)" -d $(CLASSDESTDIR) @$<.filtered; \ |
4ca328b9cf83
6641585: jdk/make/javax/Makefile should not have both SUBDIRS and AUTO_FILES_JAVA_DIRS
ohair
parents:
2
diff
changeset
|
241 |
$(JAVAC_CMD) -sourcepath "$(SOURCEPATH)" -d $(CLASSDESTDIR) @$<.filtered; \ |
2 | 242 |
fi |
243 |
@$(java-vm-cleanup) |
|
244 |
||
245 |
clobber clean:: |
|
246 |
$(RM) $(JAVA_SOURCE_LIST) |
|
247 |
||
248 |
ifndef DONT_CLOBBER_CLASSES |
|
249 |
ifndef PACKAGE |
|
250 |
DONT_CLOBBER_CLASSES = true |
|
251 |
else |
|
252 |
DONT_CLOBBER_CLASSES = false |
|
253 |
endif |
|
254 |
endif |
|
255 |
||
256 |
packages.clean: |
|
257 |
ifeq ($(DONT_CLOBBER_CLASSES),false) |
|
258 |
ifdef AUTO_FILES_JAVA_DIRS |
|
259 |
@for sdir in $(AUTO_FILES_JAVA_DIRS); do \ |
|
260 |
$(ECHO) "$(RM) -r $(CLASSDESTDIR)/$$sdir"; \ |
|
261 |
$(RM) -r $(CLASSDESTDIR)/$$sdir; \ |
|
262 |
done |
|
263 |
else |
|
264 |
$(RM) -r $(CLASSDESTDIR)/$(PKGDIR) |
|
265 |
endif |
|
266 |
endif |
|
267 |
||
268 |
ifdef DEMOS |
|
269 |
classes.clean: |
|
270 |
$(RM) -r $(DEMODST) $(CLASSDESTDIR) |
|
271 |
else |
|
272 |
classes.clean: packages.clean |
|
273 |
$(RM) $(JAVA_SOURCE_LIST) |
|
274 |
endif |
|
275 |
||
276 |
# |
|
277 |
# C and C++ make dependencies |
|
278 |
# |
|
279 |
include $(JDK_TOPDIR)/make/common/internal/NativeCompileRules.gmk |
|
280 |
||
281 |
# |
|
282 |
# Running Javah to generate stuff into CClassHeaders. |
|
283 |
# |
|
284 |
||
285 |
ifdef FILES_export |
|
286 |
||
287 |
CLASSES.export = $(subst /,.,$(FILES_export:%.java=%)) |
|
288 |
CLASSES.export += $(subst /,.,$(FILES_export2:%.java=%)) |
|
289 |
CLASSES.export += $(subst /,.,$(FILES_export3:%.java=%)) |
|
290 |
CLASSES_export = $(FILES_export:%.java=$(CLASSDESTDIR)/%.class) |
|
291 |
CLASSES_export += $(FILES_export2:%.java=$(CLASSDESTDIR)/%.class) |
|
292 |
CLASSES_export += $(FILES_export3:%.java=$(CLASSDESTDIR)/%.class) |
|
293 |
||
294 |
# Fix when deploy workspace makefiles don't depend on this name |
|
295 |
#CLASSHDR_DOTFILE=$(CLASSHDRDIR)/.classheaders |
|
296 |
||
297 |
CLASSHDR_DOTFILE=$(OBJDIR)/.class.headers.$(ARCH) |
|
298 |
||
299 |
classheaders: classes $(CLASSHDR_DOTFILE) |
|
300 |
||
301 |
$(CLASSHDR_DOTFILE): $(CLASSES_export) |
|
302 |
$(prep-target) |
|
303 |
@$(ECHO) "# Running javah:" |
|
304 |
$(JAVAH_CMD) -d $(CLASSHDRDIR)/ \ |
|
305 |
$(CLASSES.export) $(subst $$,\$$,$(EXPORTED_inner)) |
|
306 |
@$(java-vm-cleanup) |
|
307 |
@$(TOUCH) $@ |
|
308 |
||
309 |
classheaders.clean: |
|
310 |
$(RM) $(CLASSHDR_DOTFILE) |
|
311 |
$(RM) -r $(CLASSHDRDIR) |
|
312 |
||
313 |
else # FILES_export |
|
314 |
||
315 |
classheaders: classes |
|
316 |
||
317 |
classheaders.clean: |
|
318 |
||
319 |
endif # FILES_export |
|
320 |
||
321 |
clean clobber:: classheaders.clean classes.clean .delete.classlist |
|
322 |
||
323 |
# |
|
324 |
# Default dependencies |
|
325 |
# |
|
326 |
||
327 |
all: build |
|
328 |
||
329 |
build: classheaders |
|
330 |
||
331 |
default: all |
|
332 |
||
333 |
.PHONY: all build clean clobber \ |
|
334 |
.delete.classlist classes .compile.classlist classes.clean \ |
|
335 |
classheaders classheaders.clean \ |
|
336 |
batch_compile |
|
337 |