source: trunk/openjdk/jdk/make/common/Rules.gmk

Last change on this file was 278, checked in by dmik, 14 years ago

trunk: Merged in openjdk6 b22 from branches/vendor/oracle.

File size: 10.2 KB
Line 
1#
2# Copyright (c) 1995, 2007, 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.
31define 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
40endef
41
42# Make sure the default rule is all
43rules_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#
54ifdef OPENJDK
55 ALL_CLASSES_SRC = $(SHARE_SRC)/classes $(PLATFORM_SRC)/classes
56else
57 ALL_CLASSES_SRC = \
58 $(CLOSED_SHARE_SRC)/classes $(CLOSED_PLATFORM_SRC)/classes \
59 $(SHARE_SRC)/classes $(PLATFORM_SRC)/classes
60endif
61
62#
63# If AUTO_FILES_PROPERTIES_DIRS used, automatically find properties files
64#
65ifdef AUTO_FILES_PROPERTIES_DIRS
66 AUTO_FILES_PROPERTIES_FILTERS1 = $(SCM_DIRs) 'X-*' '*-X-*' ',*'
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 )
84else
85 FILES_properties_auto1 =
86endif # AUTO_FILES_PROPERTIES_DIRS
87
88# Add any automatically found properties files to the properties file list
89FILES_properties += $(FILES_properties_auto1)
90
91#
92# Get Resources help
93#
94include $(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
112ifdef AUTO_FILES_JAVA_DIRS
113 # Filter out these files or directories
114 AUTO_FILES_JAVA_SOURCE_FILTERS1 = $(SCM_DIRs) 'X-*' '*-X-*' '*-template.java' ',*'
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 )
157else
158 FILES_java_auto1 =
159 FILES_java_auto2 =
160endif
161
162# Add all found java sources to FILES_java macro (if AUTO_FILES_JAVA_DIRS used)
163FILES_java += $(FILES_java_auto1) $(FILES_java_auto2)
164
165# File that will hold java source names that need compiling
166JAVA_SOURCE_LIST=$(TEMPDIR)/.classes.list
167
168# Add a java source to the list
169define add-java-file
170$(ECHO) "$?" >> $(JAVA_SOURCE_LIST)
171$(check-conventions)
172endef
173
174ifdef 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)
180else
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#
194ifndef 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)
199endif
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)
211endif
212
213# List of class files needed
214FILES_class = $(FILES_java:%.java=$(CLASSDESTDIR)/%.class)
215
216# Got to include exported files.
217FILES_class += $(FILES_export:%.java=$(CLASSDESTDIR)/%.class)
218
219# Construct list of java sources we need to compile
220source_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)
230classes : $(CLASSES_INIT) .delete.classlist .compile.classlist
231
232.compile.classlist : $(JAVA_SOURCE_LIST)
233 @$(MKDIR) -p $(CLASSDESTDIR)
234 @if [ `$(CAT) $(JAVA_SOURCE_LIST) | $(WC) -l` -ge 1 ] ; then \
235 $(ECHO) "# Java sources to be compiled: (listed in file $(JAVA_SOURCE_LIST))"; \
236 $(CAT) $(JAVA_SOURCE_LIST); \
237 $(ECHO) "# Running javac:"; \
238 $(ECHO) $(JAVAC_CMD) -sourcepath "$(SOURCEPATH)" -d $(CLASSDESTDIR) @$(JAVA_SOURCE_LIST); \
239 $(JAVAC_CMD) -sourcepath "$(SOURCEPATH)" -d $(CLASSDESTDIR) @$(JAVA_SOURCE_LIST); \
240 fi
241 @$(java-vm-cleanup)
242
243clobber clean::
244 $(RM) $(JAVA_SOURCE_LIST)
245
246ifndef DONT_CLOBBER_CLASSES
247 ifndef PACKAGE
248 DONT_CLOBBER_CLASSES = true
249 else
250 DONT_CLOBBER_CLASSES = false
251 endif
252endif
253
254packages.clean:
255ifeq ($(DONT_CLOBBER_CLASSES),false)
256 ifdef AUTO_FILES_JAVA_DIRS
257 @for sdir in $(AUTO_FILES_JAVA_DIRS); do \
258 $(ECHO) "$(RM) -r $(CLASSDESTDIR)/$$sdir"; \
259 $(RM) -r $(CLASSDESTDIR)/$$sdir; \
260 done
261 else
262 $(RM) -r $(CLASSDESTDIR)/$(PKGDIR)
263 endif
264endif
265
266ifdef DEMOS
267classes.clean:
268 $(RM) -r $(DEMODST) $(CLASSDESTDIR)
269else
270classes.clean: packages.clean
271 $(RM) $(JAVA_SOURCE_LIST)
272endif
273
274#
275# C and C++ make dependencies
276#
277include $(JDK_TOPDIR)/make/common/internal/NativeCompileRules.gmk
278
279#
280# Running Javah to generate stuff into CClassHeaders.
281#
282
283ifdef FILES_export
284
285CLASSES.export = $(subst /,.,$(FILES_export:%.java=%))
286CLASSES.export += $(subst /,.,$(FILES_export2:%.java=%))
287CLASSES.export += $(subst /,.,$(FILES_export3:%.java=%))
288CLASSES_export = $(FILES_export:%.java=$(CLASSDESTDIR)/%.class)
289CLASSES_export += $(FILES_export2:%.java=$(CLASSDESTDIR)/%.class)
290CLASSES_export += $(FILES_export3:%.java=$(CLASSDESTDIR)/%.class)
291
292# Fix when deploy workspace makefiles don't depend on this name
293#CLASSHDR_DOTFILE=$(CLASSHDRDIR)/.classheaders
294
295CLASSHDR_DOTFILE=$(OBJDIR)/.class.headers.$(ARCH)
296
297classheaders: classes $(CLASSHDR_DOTFILE)
298
299$(CLASSHDR_DOTFILE): $(CLASSES_export)
300 $(prep-target)
301 @$(ECHO) "# Running javah:"
302 $(JAVAH_CMD) -d $(CLASSHDRDIR)/ \
303 $(CLASSES.export) $(subst $$,\$$,$(EXPORTED_inner))
304 @$(java-vm-cleanup)
305 @$(TOUCH) $@
306
307classheaders.clean:
308 $(RM) $(CLASSHDR_DOTFILE)
309 $(RM) -r $(CLASSHDRDIR)
310
311else # FILES_export
312
313classheaders: classes
314
315classheaders.clean:
316
317endif # FILES_export
318
319clean clobber:: classheaders.clean classes.clean .delete.classlist
320
321#
322# Default dependencies
323#
324
325all: build
326
327build: classheaders
328
329default: all
330
331.PHONY: all build clean clobber \
332 .delete.classlist classes .compile.classlist classes.clean \
333 classheaders classheaders.clean \
334 batch_compile
335
Note: See TracBrowser for help on using the repository browser.