1 # |
|
2 # Copyright (c) 1995, 2008, Oracle and/or its affiliates. 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. Oracle designates this |
|
8 # particular file as subject to the "Classpath" exception as provided |
|
9 # by Oracle 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 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. |
|
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 ifeq ($(PLATFORM), macosx) |
|
55 ifdef OPENJDK |
|
56 ALL_CLASSES_SRC = $(call JavaSrcDirList,,classes) |
|
57 else |
|
58 ALL_CLASSES_SRC = \ |
|
59 $(CLOSED_SHARE_SRC)/classes $(CLOSED_PLATFORM_SRC)/classes \ |
|
60 $(call JavaSrcDirList,,classes) |
|
61 endif |
|
62 else |
|
63 ifdef OPENJDK |
|
64 ALL_CLASSES_SRC = $(SHARE_SRC)/classes $(PLATFORM_SRC)/classes |
|
65 else |
|
66 ALL_CLASSES_SRC = \ |
|
67 $(CLOSED_SHARE_SRC)/classes $(CLOSED_PLATFORM_SRC)/classes \ |
|
68 $(SHARE_SRC)/classes $(PLATFORM_SRC)/classes |
|
69 endif |
|
70 endif |
|
71 |
|
72 # |
|
73 # If AUTO_FILES_PROPERTIES_DIRS used, automatically find properties files |
|
74 # |
|
75 ifdef AUTO_FILES_PROPERTIES_DIRS |
|
76 AUTO_FILES_PROPERTIES_FILTERS1 = $(SCM_DIRs) ',*' |
|
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)/makefiles/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 |
|
124 AUTO_FILES_JAVA_SOURCE_FILTERS1 = $(SCM_DIRs) ',*' |
|
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) |
|
213 |
|
214 ifeq ($(PLATFORM), macosx) |
|
215 $(CLASSDESTDIR)/%.class: $(JDK_TOPDIR)/src/macosx/classes/%.java |
|
216 $(add-java-file) |
|
217 endif |
|
218 $(CLASSDESTDIR)/%.class: $(PLATFORM_SRC)/classes/%.java |
|
219 $(add-java-file) |
|
220 |
|
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 -f $(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) |
|
250 $(RM) $<.filtered |
|
251 $(CAT) $< | $(NAWK) 'length>0' | $(SORT) -u > $<.filtered |
|
252 numfiles=`$(WC) -l < $<.filtered` ; \ |
|
253 if [ $$numfiles -ge 1 ] ; then \ |
|
254 $(ECHO) "# Java sources to be compiled: (listed in file $<)"; \ |
|
255 $(CAT) $<.filtered; \ |
|
256 $(ECHO) "# Running javac: $$numfiles files; in $(CURDIR)"; \ |
|
257 $(ECHO) $(JAVAC_CMD) -sourcepath "$(SOURCEPATH)" -d $(CLASSDESTDIR) @$<.filtered; \ |
|
258 $(JAVAC_CMD) -sourcepath "$(SOURCEPATH)" -d $(CLASSDESTDIR) @$<.filtered && \ |
|
259 $(ECHO) "# javac finished"; \ |
|
260 fi |
|
261 $(java-vm-cleanup) |
|
262 |
|
263 clobber clean:: |
|
264 rm -f $(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 -f -r $(CLASSDESTDIR)/$$sdir"; \ |
|
279 rm -f -r $(CLASSDESTDIR)/$$sdir; \ |
|
280 done |
|
281 else |
|
282 rm -f -r $(CLASSDESTDIR)/$(PKGDIR) |
|
283 endif |
|
284 endif |
|
285 |
|
286 ifdef DEMOS |
|
287 classes.clean: |
|
288 rm -f -r $(DEMODST) $(CLASSDESTDIR) |
|
289 else |
|
290 classes.clean: packages.clean |
|
291 rm -f $(JAVA_SOURCE_LIST) |
|
292 endif |
|
293 |
|
294 # |
|
295 # C and C++ make dependencies |
|
296 # |
|
297 include $(JDK_TOPDIR)/makefiles/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 echo $(UNCYGDRIVE) $(JAVAH_CMD) -d $(CLASSHDRDIR)/ \ |
|
323 $(CLASSES.export) $(subst $$,\$$,$(EXPORTED_inner)) |
|
324 $(UNCYGDRIVE) $(JAVAH_CMD) -d $(CLASSHDRDIR)/ \ |
|
325 $(CLASSES.export) $(subst $$,\$$,$(EXPORTED_inner)) |
|
326 $(java-vm-cleanup) |
|
327 touch $@ |
|
328 |
|
329 classheaders.clean: |
|
330 rm -f $(CLASSHDR_DOTFILE) |
|
331 rm -f -r $(CLASSHDRDIR) |
|
332 |
|
333 else # FILES_export |
|
334 |
|
335 classheaders: classes |
|
336 |
|
337 classheaders.clean: |
|
338 |
|
339 endif # FILES_export |
|
340 |
|
341 clean clobber:: classheaders.clean classes.clean .delete.classlist |
|
342 |
|
343 # |
|
344 # Default dependencies |
|
345 # |
|
346 |
|
347 all: build |
|
348 |
|
349 build: classheaders |
|
350 |
|
351 default: all |
|
352 |
|
353 .PHONY: all build clean clobber \ |
|
354 .delete.classlist classes .compile.classlist classes.clean \ |
|
355 classheaders classheaders.clean \ |
|
356 batch_compile |
|
357 |
|