4
|
1 |
#
|
|
2 |
# Copyright 1995-2007 Sun Microsystems, Inc. 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. Sun designates this
|
|
8 |
# particular file as subject to the "Classpath" exception as provided
|
|
9 |
# by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
22 |
# CA 95054 USA or visit www.sun.com if you need additional information or
|
|
23 |
# have any 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
|
|
53 |
#
|
|
54 |
ALL_CLASSES_SRC = $(SHARE_SRC)/classes $(PLATFORM_SRC)/classes
|
|
55 |
|
|
56 |
#
|
|
57 |
# If AUTO_FILES_PROPERTIES_DIRS used, automatically find properties files
|
|
58 |
#
|
|
59 |
ifdef AUTO_FILES_PROPERTIES_DIRS
|
|
60 |
AUTO_FILES_PROPERTIES_FILTERS1 = $(SCM_DIRs) 'X-*' '*-X-*' ',*'
|
|
61 |
AUTO_FILES_PROPERTIES_FILTERS1 += $(AUTO_PROPERTIES_PRUNE)
|
|
62 |
FILES_properties_find_filters1 = $(AUTO_FILES_PROPERTIES_FILTERS1:%=-name % -prune -o)
|
|
63 |
FILES_properties_auto1 := \
|
|
64 |
$(shell \
|
|
65 |
for dir in $(ALL_CLASSES_SRC) ; do \
|
|
66 |
if [ -d $$dir ] ; then \
|
|
67 |
( $(CD) $$dir; \
|
|
68 |
for sdir in $(AUTO_FILES_PROPERTIES_DIRS); do \
|
|
69 |
if [ -d $$sdir ] ; then \
|
|
70 |
$(FIND) $$sdir $(FILES_properties_find_filters1) \
|
|
71 |
-name '*.properties' -print ; \
|
|
72 |
fi ; \
|
|
73 |
done \
|
|
74 |
); \
|
|
75 |
fi; \
|
|
76 |
done \
|
|
77 |
)
|
|
78 |
else
|
|
79 |
FILES_properties_auto1 =
|
|
80 |
endif # AUTO_FILES_PROPERTIES_DIRS
|
|
81 |
|
|
82 |
# Add any automatically found properties files to the properties file list
|
|
83 |
FILES_properties += $(FILES_properties_auto1)
|
|
84 |
|
|
85 |
#
|
|
86 |
# Get Resources help
|
|
87 |
#
|
|
88 |
include $(TOPDIR)/make/common/internal/Resources.gmk
|
|
89 |
|
|
90 |
#
|
|
91 |
# Compiling .java files.
|
|
92 |
#
|
|
93 |
|
|
94 |
#
|
|
95 |
# Automatically add to FILES_java if AUTO_FILES_JAVA_DIRS is defined
|
|
96 |
#
|
|
97 |
# There are two basic types of sources, normal source files and the
|
|
98 |
# generated ones. The Normal sources will be located in:
|
|
99 |
# $(ALL_CLASSES_SRC)
|
|
100 |
# The generated sources, which might show up late to dinner, are at:
|
|
101 |
# $(GENSRCDIR)
|
|
102 |
# and since they could be generated late, we need to be careful that
|
|
103 |
# we look for these sources late and not use the ':=' assignment which
|
|
104 |
# might miss their generation.
|
|
105 |
|
|
106 |
ifdef AUTO_FILES_JAVA_DIRS
|
|
107 |
# Filter out these files or directories
|
|
108 |
AUTO_FILES_JAVA_SOURCE_FILTERS1 = $(SCM_DIRs) 'X-*' '*-X-*' '*-template.java' ',*'
|
|
109 |
AUTO_FILES_JAVA_SOURCE_FILTERS2 =
|
|
110 |
AUTO_FILES_JAVA_SOURCE_FILTERS1 += $(AUTO_JAVA_PRUNE)
|
|
111 |
AUTO_FILES_JAVA_SOURCE_FILTERS2 += $(AUTO_JAVA_PRUNE)
|
|
112 |
|
|
113 |
# First list is the normal sources that should always be there,
|
|
114 |
# by using the ':=', which means we do this processing once.
|
|
115 |
FILES_java_find_filters1 = $(AUTO_FILES_JAVA_SOURCE_FILTERS1:%=-name % -prune -o)
|
|
116 |
FILES_java_auto1 := \
|
|
117 |
$(shell \
|
|
118 |
for dir in $(ALL_CLASSES_SRC) ; do \
|
|
119 |
if [ -d $$dir ] ; then \
|
|
120 |
( $(CD) $$dir; \
|
|
121 |
for sdir in $(AUTO_FILES_JAVA_DIRS); do \
|
|
122 |
if [ -d $$sdir ] ; then \
|
|
123 |
$(FIND) $$sdir $(FILES_java_find_filters1) \
|
|
124 |
-name '*.java' -print ; \
|
|
125 |
fi ; \
|
|
126 |
done \
|
|
127 |
); \
|
|
128 |
fi; \
|
|
129 |
done \
|
|
130 |
)
|
|
131 |
# Second list is the generated sources that should be rare, but will likely
|
|
132 |
# show up late and we need to look for them at the last minute, so we
|
|
133 |
# cannot use the ':=' assigment here. But if this gets expanded multiple
|
|
134 |
# times, the if tests should make them relatively cheap.
|
|
135 |
FILES_java_find_filters2 = $(AUTO_FILES_JAVA_SOURCE_FILTERS2:%=-name % -prune -o)
|
|
136 |
FILES_java_auto2 = \
|
|
137 |
$(shell \
|
|
138 |
for dir in $(GENSRCDIR); do \
|
|
139 |
if [ -d $$dir ] ; then \
|
|
140 |
( $(CD) $$dir; \
|
|
141 |
for sdir in $(AUTO_FILES_JAVA_DIRS); do \
|
|
142 |
if [ -d $$sdir ] ; then \
|
|
143 |
$(FIND) $$sdir $(FILES_java_find_filters2) \
|
|
144 |
-name '*.java' -print ; \
|
|
145 |
fi ; \
|
|
146 |
done \
|
|
147 |
); \
|
|
148 |
fi; \
|
|
149 |
done \
|
|
150 |
)
|
|
151 |
else
|
|
152 |
FILES_java_auto1 =
|
|
153 |
FILES_java_auto2 =
|
|
154 |
endif
|
|
155 |
|
|
156 |
# Add all found java sources to FILES_java macro (if AUTO_FILES_JAVA_DIRS used)
|
|
157 |
FILES_java += $(FILES_java_auto1) $(FILES_java_auto2)
|
|
158 |
|
|
159 |
# File that will hold java source names that need compiling
|
|
160 |
JAVA_SOURCE_LIST=$(TEMPDIR)/.classes.list
|
|
161 |
|
|
162 |
# Add a java source to the list
|
|
163 |
define add-java-file
|
|
164 |
$(ECHO) "$?" >> $(JAVA_SOURCE_LIST)
|
|
165 |
$(check-conventions)
|
|
166 |
endef
|
|
167 |
|
|
168 |
$(CLASSDESTDIR)/%.class: $(GENSRCDIR)/%.java
|
|
169 |
@$(add-java-file)
|
|
170 |
$(CLASSDESTDIR)/%.class: $(PLATFORM_SRC)/classes/%.java
|
|
171 |
@$(add-java-file)
|
|
172 |
$(CLASSDESTDIR)/%.class: $(SHARE_SRC)/classes/%.java
|
|
173 |
@$(add-java-file)
|
|
174 |
|
|
175 |
# List of class files needed
|
|
176 |
FILES_class = $(FILES_java:%.java=$(CLASSDESTDIR)/%.class)
|
|
177 |
|
|
178 |
# Got to include exported files.
|
|
179 |
FILES_class += $(FILES_export:%.java=$(CLASSDESTDIR)/%.class)
|
|
180 |
|
|
181 |
# Construct list of java sources we need to compile
|
|
182 |
source_list_prime:
|
|
183 |
@$(MKDIR) -p $(TEMPDIR)
|
|
184 |
# Note that we slip resources in so that compiled properties files get created:
|
|
185 |
$(JAVA_SOURCE_LIST) : source_list_prime resources $(FILES_class)
|
|
186 |
@$(TOUCH) $@
|
|
187 |
|
|
188 |
.delete.classlist:
|
|
189 |
@$(RM) $(JAVA_SOURCE_LIST)
|
|
190 |
|
|
191 |
# Make sure all newer sources are compiled (in a batch)
|
|
192 |
classes : $(CLASSES_INIT) .delete.classlist .compile.classlist
|
|
193 |
|
|
194 |
.compile.classlist : $(JAVA_SOURCE_LIST)
|
|
195 |
@$(MKDIR) -p $(CLASSDESTDIR)
|
|
196 |
@if [ `$(CAT) $(JAVA_SOURCE_LIST) | $(WC) -l` -ge 1 ] ; then \
|
|
197 |
$(ECHO) "# Java sources to be compiled: (listed in file $(JAVA_SOURCE_LIST))"; \
|
|
198 |
$(CAT) $(JAVA_SOURCE_LIST); \
|
|
199 |
$(ECHO) "# Running javac:"; \
|
|
200 |
$(ECHO) $(JAVAC_CMD) -sourcepath "$(SOURCEPATH)" -d $(CLASSDESTDIR) @$(JAVA_SOURCE_LIST); \
|
|
201 |
$(JAVAC_CMD) -sourcepath "$(SOURCEPATH)" -d $(CLASSDESTDIR) @$(JAVA_SOURCE_LIST); \
|
|
202 |
fi
|
|
203 |
@$(java-vm-cleanup)
|
|
204 |
|
|
205 |
clobber clean::
|
|
206 |
$(RM) $(JAVA_SOURCE_LIST)
|
|
207 |
|
|
208 |
ifndef DONT_CLOBBER_CLASSES
|
|
209 |
ifndef PACKAGE
|
|
210 |
DONT_CLOBBER_CLASSES = true
|
|
211 |
else
|
|
212 |
DONT_CLOBBER_CLASSES = false
|
|
213 |
endif
|
|
214 |
endif
|
|
215 |
|
|
216 |
packages.clean:
|
|
217 |
ifeq ($(DONT_CLOBBER_CLASSES),false)
|
|
218 |
ifdef AUTO_FILES_JAVA_DIRS
|
|
219 |
@for sdir in $(AUTO_FILES_JAVA_DIRS); do \
|
|
220 |
$(ECHO) "$(RM) -r $(CLASSDESTDIR)/$$sdir"; \
|
|
221 |
$(RM) -r $(CLASSDESTDIR)/$$sdir; \
|
|
222 |
done
|
|
223 |
else
|
|
224 |
$(RM) -r $(CLASSDESTDIR)/$(PKGDIR)
|
|
225 |
endif
|
|
226 |
endif
|
|
227 |
|
|
228 |
classes.clean: packages.clean
|
|
229 |
$(RM) $(JAVA_SOURCE_LIST)
|
|
230 |
|
|
231 |
#
|
|
232 |
# C and C++ make dependencies
|
|
233 |
#
|
|
234 |
include $(TOPDIR)/make/common/internal/NativeCompileRules.gmk
|
|
235 |
|
|
236 |
#
|
|
237 |
# Running Javah to generate stuff into CClassHeaders.
|
|
238 |
#
|
|
239 |
|
|
240 |
ifdef FILES_export
|
|
241 |
|
|
242 |
CLASSES.export = $(subst /,.,$(FILES_export:%.java=%))
|
|
243 |
CLASSES.export += $(subst /,.,$(FILES_export2:%.java=%))
|
|
244 |
CLASSES.export += $(subst /,.,$(FILES_export3:%.java=%))
|
|
245 |
CLASSES_export = $(FILES_export:%.java=$(CLASSDESTDIR)/%.class)
|
|
246 |
CLASSES_export += $(FILES_export2:%.java=$(CLASSDESTDIR)/%.class)
|
|
247 |
CLASSES_export += $(FILES_export3:%.java=$(CLASSDESTDIR)/%.class)
|
|
248 |
|
|
249 |
# Fix when deploy workspace makefiles don't depend on this name
|
|
250 |
#CLASSHDR_DOTFILE=$(CLASSHDRDIR)/.classheaders
|
|
251 |
|
|
252 |
CLASSHDR_DOTFILE=$(OBJDIR)/.class.headers.$(ARCH)
|
|
253 |
|
|
254 |
classheaders: classes $(CLASSHDR_DOTFILE)
|
|
255 |
|
|
256 |
$(CLASSHDR_DOTFILE): $(CLASSES_export)
|
|
257 |
$(prep-target)
|
|
258 |
@$(ECHO) "# Running javah:"
|
|
259 |
$(JAVAH_CMD) -d $(CLASSHDRDIR)/ \
|
|
260 |
$(CLASSES.export) $(subst $$,\$$,$(EXPORTED_inner))
|
|
261 |
@$(java-vm-cleanup)
|
|
262 |
@$(TOUCH) $@
|
|
263 |
|
|
264 |
classheaders.clean:
|
|
265 |
$(RM) $(CLASSHDR_DOTFILE)
|
|
266 |
$(RM) -r $(CLASSHDRDIR)
|
|
267 |
|
|
268 |
else # FILES_export
|
|
269 |
|
|
270 |
classheaders: classes
|
|
271 |
|
|
272 |
classheaders.clean:
|
|
273 |
|
|
274 |
endif # FILES_export
|
|
275 |
|
|
276 |
clean clobber:: classheaders.clean classes.clean .delete.classlist
|
|
277 |
|
|
278 |
#
|
|
279 |
# Default dependencies
|
|
280 |
#
|
|
281 |
|
|
282 |
all: build
|
|
283 |
|
|
284 |
build: classheaders
|
|
285 |
|
|
286 |
default: all
|
|
287 |
|
|
288 |
.PHONY: all build clean clobber \
|
|
289 |
.delete.classlist classes .compile.classlist classes.clean \
|
|
290 |
classheaders classheaders.clean \
|
|
291 |
batch_compile
|
|
292 |
|