author | duke |
Wed, 05 Jul 2017 18:16:12 +0200 | |
changeset 13187 | b820143a6f1c |
parent 12047 | 320a714614e9 |
child 14342 | 8435a30053c1 |
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 |
# |
|
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11285
diff
changeset
|
54 |
ifeq ($(PLATFORM), macosx) |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11285
diff
changeset
|
55 |
ifdef OPENJDK |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11285
diff
changeset
|
56 |
ALL_CLASSES_SRC = $(call JavaSrcDirList,,classes) |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11285
diff
changeset
|
57 |
else |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11285
diff
changeset
|
58 |
ALL_CLASSES_SRC = \ |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11285
diff
changeset
|
59 |
$(CLOSED_SHARE_SRC)/classes $(CLOSED_PLATFORM_SRC)/classes \ |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11285
diff
changeset
|
60 |
$(call JavaSrcDirList,,classes) |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11285
diff
changeset
|
61 |
endif |
2 | 62 |
else |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11285
diff
changeset
|
63 |
ifdef OPENJDK |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11285
diff
changeset
|
64 |
ALL_CLASSES_SRC = $(SHARE_SRC)/classes $(PLATFORM_SRC)/classes |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11285
diff
changeset
|
65 |
else |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11285
diff
changeset
|
66 |
ALL_CLASSES_SRC = \ |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11285
diff
changeset
|
67 |
$(CLOSED_SHARE_SRC)/classes $(CLOSED_PLATFORM_SRC)/classes \ |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11285
diff
changeset
|
68 |
$(SHARE_SRC)/classes $(PLATFORM_SRC)/classes |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11285
diff
changeset
|
69 |
endif |
2 | 70 |
endif |
71 |
||
72 |
# |
|
73 |
# If AUTO_FILES_PROPERTIES_DIRS used, automatically find properties files |
|
74 |
# |
|
75 |
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
|
76 |
AUTO_FILES_PROPERTIES_FILTERS1 = $(SCM_DIRs) ',*' |
2 | 77 |
AUTO_FILES_PROPERTIES_FILTERS1 += $(AUTO_PROPERTIES_PRUNE) |
78 |
FILES_properties_find_filters1 = $(AUTO_FILES_PROPERTIES_FILTERS1:%=-name % -prune -o) |
|
79 |
FILES_properties_auto1 := \ |
|
80 |
$(shell \ |
|
81 |
for dir in $(ALL_CLASSES_SRC) ; do \ |
|
82 |
if [ -d $$dir ] ; then \ |
|
83 |
( $(CD) $$dir; \ |
|
84 |
for sdir in $(AUTO_FILES_PROPERTIES_DIRS); do \ |
|
85 |
if [ -d $$sdir ] ; then \ |
|
86 |
$(FIND) $$sdir $(FILES_properties_find_filters1) \ |
|
87 |
-name '*.properties' -print ; \ |
|
88 |
fi ; \ |
|
89 |
done \ |
|
90 |
); \ |
|
91 |
fi; \ |
|
92 |
done \ |
|
93 |
) |
|
94 |
else |
|
95 |
FILES_properties_auto1 = |
|
96 |
endif # AUTO_FILES_PROPERTIES_DIRS |
|
97 |
||
98 |
# Add any automatically found properties files to the properties file list |
|
99 |
FILES_properties += $(FILES_properties_auto1) |
|
100 |
||
101 |
# |
|
102 |
# Get Resources help |
|
103 |
# |
|
104 |
include $(JDK_TOPDIR)/make/common/internal/Resources.gmk |
|
105 |
||
106 |
# |
|
107 |
# Compiling .java files. |
|
108 |
# |
|
109 |
||
110 |
# |
|
111 |
# Automatically add to FILES_java if AUTO_FILES_JAVA_DIRS is defined |
|
112 |
# |
|
113 |
# There are two basic types of sources, normal source files and the |
|
114 |
# generated ones. The Normal sources will be located in: |
|
115 |
# $(ALL_CLASSES_SRC) |
|
116 |
# The generated sources, which might show up late to dinner, are at: |
|
117 |
# $(GENSRCDIR) |
|
118 |
# and since they could be generated late, we need to be careful that |
|
119 |
# we look for these sources late and not use the ':=' assignment which |
|
120 |
# might miss their generation. |
|
121 |
||
122 |
ifdef AUTO_FILES_JAVA_DIRS |
|
123 |
# 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
|
124 |
AUTO_FILES_JAVA_SOURCE_FILTERS1 = $(SCM_DIRs) ',*' |
2 | 125 |
AUTO_FILES_JAVA_SOURCE_FILTERS2 = |
126 |
AUTO_FILES_JAVA_SOURCE_FILTERS1 += $(AUTO_JAVA_PRUNE) |
|
127 |
AUTO_FILES_JAVA_SOURCE_FILTERS2 += $(AUTO_JAVA_PRUNE) |
|
128 |
||
129 |
# First list is the normal sources that should always be there, |
|
130 |
# by using the ':=', which means we do this processing once. |
|
131 |
FILES_java_find_filters1 = $(AUTO_FILES_JAVA_SOURCE_FILTERS1:%=-name % -prune -o) |
|
132 |
FILES_java_auto1 := \ |
|
133 |
$(shell \ |
|
134 |
for dir in $(ALL_CLASSES_SRC) ; do \ |
|
135 |
if [ -d $$dir ] ; then \ |
|
136 |
( $(CD) $$dir; \ |
|
137 |
for sdir in $(AUTO_FILES_JAVA_DIRS); do \ |
|
138 |
if [ -d $$sdir ] ; then \ |
|
139 |
$(FIND) $$sdir $(FILES_java_find_filters1) \ |
|
140 |
-name '*.java' -print ; \ |
|
141 |
fi ; \ |
|
142 |
done \ |
|
143 |
); \ |
|
144 |
fi; \ |
|
145 |
done \ |
|
146 |
) |
|
147 |
# Second list is the generated sources that should be rare, but will likely |
|
148 |
# show up late and we need to look for them at the last minute, so we |
|
149 |
# cannot use the ':=' assigment here. But if this gets expanded multiple |
|
150 |
# times, the if tests should make them relatively cheap. |
|
151 |
FILES_java_find_filters2 = $(AUTO_FILES_JAVA_SOURCE_FILTERS2:%=-name % -prune -o) |
|
152 |
FILES_java_auto2 = \ |
|
153 |
$(shell \ |
|
154 |
for dir in $(GENSRCDIR); do \ |
|
155 |
if [ -d $$dir ] ; then \ |
|
156 |
( $(CD) $$dir; \ |
|
157 |
for sdir in $(AUTO_FILES_JAVA_DIRS); do \ |
|
158 |
if [ -d $$sdir ] ; then \ |
|
159 |
$(FIND) $$sdir $(FILES_java_find_filters2) \ |
|
160 |
-name '*.java' -print ; \ |
|
161 |
fi ; \ |
|
162 |
done \ |
|
163 |
); \ |
|
164 |
fi; \ |
|
165 |
done \ |
|
166 |
) |
|
167 |
else |
|
168 |
FILES_java_auto1 = |
|
169 |
FILES_java_auto2 = |
|
170 |
endif |
|
171 |
||
172 |
# Add all found java sources to FILES_java macro (if AUTO_FILES_JAVA_DIRS used) |
|
173 |
FILES_java += $(FILES_java_auto1) $(FILES_java_auto2) |
|
174 |
||
175 |
# File that will hold java source names that need compiling |
|
176 |
JAVA_SOURCE_LIST=$(TEMPDIR)/.classes.list |
|
177 |
||
178 |
# Add a java source to the list |
|
179 |
define add-java-file |
|
180 |
$(ECHO) "$?" >> $(JAVA_SOURCE_LIST) |
|
181 |
$(check-conventions) |
|
182 |
endef |
|
183 |
||
184 |
ifdef DEMOS |
|
185 |
$(CLASSDESTDIR)/%.class: $(SOURCEPATH)/%.java |
|
186 |
@$(add-java-file) |
|
187 |
#Redirect zh_HK java files to tmp directory which created from zh_TW |
|
188 |
#$(CLASSDESTDIR)/%_zh_HK.class: $(JDK_L10N_TMP_OUTPUTDIR)/%_zh_HK.java |
|
189 |
# @$(add-java-file) |
|
190 |
else |
|
191 |
||
192 |
# |
|
193 |
# Rules for closed files |
|
194 |
# |
|
195 |
# If filenames are duplicated between open/closed workspaces, prefer |
|
196 |
# the closed files. |
|
197 |
# |
|
198 |
# Rule ordering in this Makefile is important: some targets depend |
|
199 |
# on closed files replacing open ones, and thus the closed file rules |
|
200 |
# must be found before the open ones. |
|
201 |
# |
|
202 |
# Don't reorder without consulting teams that depend on this behavior. |
|
203 |
# |
|
204 |
ifndef OPENJDK |
|
205 |
$(CLASSDESTDIR)/%.class: $(CLOSED_PLATFORM_SRC)/classes/%.java |
|
206 |
@$(add-java-file) |
|
207 |
$(CLASSDESTDIR)/%.class: $(CLOSED_SHARE_SRC)/classes/%.java |
|
208 |
@$(add-java-file) |
|
209 |
endif |
|
210 |
||
211 |
$(CLASSDESTDIR)/%.class: $(GENSRCDIR)/%.java |
|
212 |
@$(add-java-file) |
|
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11285
diff
changeset
|
213 |
|
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11285
diff
changeset
|
214 |
ifeq ($(PLATFORM), macosx) |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11285
diff
changeset
|
215 |
$(CLASSDESTDIR)/%.class: $(JDK_TOPDIR)/src/macosx/classes/%.java |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11285
diff
changeset
|
216 |
@$(add-java-file) |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11285
diff
changeset
|
217 |
endif |
2 | 218 |
$(CLASSDESTDIR)/%.class: $(PLATFORM_SRC)/classes/%.java |
219 |
@$(add-java-file) |
|
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11285
diff
changeset
|
220 |
|
2 | 221 |
$(CLASSDESTDIR)/%.class: $(SHARE_SRC)/classes/%.java |
222 |
@$(add-java-file) |
|
223 |
||
224 |
#Redirect zh_HK java files to tmp directory which created from zh_TW |
|
225 |
$(CLASSDESTDIR)/%_zh_HK.class: $(JDK_L10N_TMP_OUTPUTDIR)/%_zh_HK.java |
|
226 |
@$(add-java-file) |
|
227 |
endif |
|
228 |
||
229 |
# List of class files needed |
|
230 |
FILES_class = $(FILES_java:%.java=$(CLASSDESTDIR)/%.class) |
|
231 |
||
232 |
# Got to include exported files. |
|
233 |
FILES_class += $(FILES_export:%.java=$(CLASSDESTDIR)/%.class) |
|
234 |
||
235 |
# Construct list of java sources we need to compile |
|
236 |
source_list_prime: |
|
237 |
@$(MKDIR) -p $(TEMPDIR) |
|
238 |
# Note that we slip resources in so that compiled properties files get created: |
|
239 |
$(JAVA_SOURCE_LIST) : source_list_prime resources $(FILES_class) |
|
240 |
@$(TOUCH) $@ |
|
241 |
||
242 |
.delete.classlist: |
|
243 |
@$(RM) $(JAVA_SOURCE_LIST) |
|
244 |
||
245 |
# Make sure all newer sources are compiled (in a batch) |
|
246 |
classes : $(CLASSES_INIT) .delete.classlist .compile.classlist |
|
247 |
||
248 |
.compile.classlist : $(JAVA_SOURCE_LIST) |
|
249 |
@$(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
|
250 |
@$(RM) $<.filtered |
4ca328b9cf83
6641585: jdk/make/javax/Makefile should not have both SUBDIRS and AUTO_FILES_JAVA_DIRS
ohair
parents:
2
diff
changeset
|
251 |
@$(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
|
252 |
@numfiles=`$(WC) -l < $<.filtered` ; \ |
5935bcaa1e5c
7116322: enhance javac make rule with a little bit of instrumentation
smarks
parents:
5506
diff
changeset
|
253 |
if [ $$numfiles -ge 1 ] ; then \ |
5935bcaa1e5c
7116322: enhance javac make rule with a little bit of instrumentation
smarks
parents:
5506
diff
changeset
|
254 |
$(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
|
255 |
$(CAT) $<.filtered; \ |
5935bcaa1e5c
7116322: enhance javac make rule with a little bit of instrumentation
smarks
parents:
5506
diff
changeset
|
256 |
$(ECHO) "# Running javac: $$numfiles files; in $(CURDIR)"; \ |
5935bcaa1e5c
7116322: enhance javac make rule with a little bit of instrumentation
smarks
parents:
5506
diff
changeset
|
257 |
$(ECHO) $(JAVAC_CMD) -sourcepath "$(SOURCEPATH)" -d $(CLASSDESTDIR) @$<.filtered; \ |
11285 | 258 |
$(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
|
259 |
$(ECHO) "# javac finished"; \ |
5935bcaa1e5c
7116322: enhance javac make rule with a little bit of instrumentation
smarks
parents:
5506
diff
changeset
|
260 |
fi |
2 | 261 |
@$(java-vm-cleanup) |
262 |
||
263 |
clobber clean:: |
|
264 |
$(RM) $(JAVA_SOURCE_LIST) |
|
265 |
||
266 |
ifndef DONT_CLOBBER_CLASSES |
|
267 |
ifndef PACKAGE |
|
268 |
DONT_CLOBBER_CLASSES = true |
|
269 |
else |
|
270 |
DONT_CLOBBER_CLASSES = false |
|
271 |
endif |
|
272 |
endif |
|
273 |
||
274 |
packages.clean: |
|
275 |
ifeq ($(DONT_CLOBBER_CLASSES),false) |
|
276 |
ifdef AUTO_FILES_JAVA_DIRS |
|
277 |
@for sdir in $(AUTO_FILES_JAVA_DIRS); do \ |
|
278 |
$(ECHO) "$(RM) -r $(CLASSDESTDIR)/$$sdir"; \ |
|
279 |
$(RM) -r $(CLASSDESTDIR)/$$sdir; \ |
|
280 |
done |
|
281 |
else |
|
282 |
$(RM) -r $(CLASSDESTDIR)/$(PKGDIR) |
|
283 |
endif |
|
284 |
endif |
|
285 |
||
286 |
ifdef DEMOS |
|
287 |
classes.clean: |
|
288 |
$(RM) -r $(DEMODST) $(CLASSDESTDIR) |
|
289 |
else |
|
290 |
classes.clean: packages.clean |
|
291 |
$(RM) $(JAVA_SOURCE_LIST) |
|
292 |
endif |
|
293 |
||
294 |
# |
|
295 |
# C and C++ make dependencies |
|
296 |
# |
|
297 |
include $(JDK_TOPDIR)/make/common/internal/NativeCompileRules.gmk |
|
298 |
||
299 |
# |
|
300 |
# Running Javah to generate stuff into CClassHeaders. |
|
301 |
# |
|
302 |
||
303 |
ifdef FILES_export |
|
304 |
||
305 |
CLASSES.export = $(subst /,.,$(FILES_export:%.java=%)) |
|
306 |
CLASSES.export += $(subst /,.,$(FILES_export2:%.java=%)) |
|
307 |
CLASSES.export += $(subst /,.,$(FILES_export3:%.java=%)) |
|
308 |
CLASSES_export = $(FILES_export:%.java=$(CLASSDESTDIR)/%.class) |
|
309 |
CLASSES_export += $(FILES_export2:%.java=$(CLASSDESTDIR)/%.class) |
|
310 |
CLASSES_export += $(FILES_export3:%.java=$(CLASSDESTDIR)/%.class) |
|
311 |
||
312 |
# Fix when deploy workspace makefiles don't depend on this name |
|
313 |
#CLASSHDR_DOTFILE=$(CLASSHDRDIR)/.classheaders |
|
314 |
||
315 |
CLASSHDR_DOTFILE=$(OBJDIR)/.class.headers.$(ARCH) |
|
316 |
||
317 |
classheaders: classes $(CLASSHDR_DOTFILE) |
|
318 |
||
319 |
$(CLASSHDR_DOTFILE): $(CLASSES_export) |
|
320 |
$(prep-target) |
|
321 |
@$(ECHO) "# Running javah:" |
|
322 |
$(JAVAH_CMD) -d $(CLASSHDRDIR)/ \ |
|
323 |
$(CLASSES.export) $(subst $$,\$$,$(EXPORTED_inner)) |
|
324 |
@$(java-vm-cleanup) |
|
325 |
@$(TOUCH) $@ |
|
326 |
||
327 |
classheaders.clean: |
|
328 |
$(RM) $(CLASSHDR_DOTFILE) |
|
329 |
$(RM) -r $(CLASSHDRDIR) |
|
330 |
||
331 |
else # FILES_export |
|
332 |
||
333 |
classheaders: classes |
|
334 |
||
335 |
classheaders.clean: |
|
336 |
||
337 |
endif # FILES_export |
|
338 |
||
339 |
clean clobber:: classheaders.clean classes.clean .delete.classlist |
|
340 |
||
341 |
# |
|
342 |
# Default dependencies |
|
343 |
# |
|
344 |
||
345 |
all: build |
|
346 |
||
347 |
build: classheaders |
|
348 |
||
349 |
default: all |
|
350 |
||
351 |
.PHONY: all build clean clobber \ |
|
352 |
.delete.classlist classes .compile.classlist classes.clean \ |
|
353 |
classheaders classheaders.clean \ |
|
354 |
batch_compile |
|
355 |