1 # |
|
2 # Copyright (c) 1997, 2010, 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 # Generic mechanism for installing properties files, resource bundles, |
|
28 # and other resource files. |
|
29 # |
|
30 # FILES_properties should be defined. |
|
31 # FILES_compiled_properties should be defined. |
|
32 # |
|
33 # If COMPILED_PROPERTIES_SUPERCLASS is defined, ALL the FILES_properties |
|
34 # files will be compiled into java with this super class. |
|
35 # |
|
36 # You can add locales to LOCALE_SUFFIXES explicitly, or use the |
|
37 # LOCALE_SET_DEFINITION variable to add some pre-defined locale lists. |
|
38 # The LOCALE_SET_DEFINITION can have the value: jre, plugin, or jdk. |
|
39 # |
|
40 # Resource bundles to be installed are identified using the following variables. |
|
41 # Note that only the file name of the base bundle is given; localized versions |
|
42 # are added automatically. For Java files, use a format suitable for inclusion |
|
43 # in the FILES_java list; dito for properties, all relative paths. |
|
44 # |
|
45 # NEW_RESOURCE_BUNDLES_JAVA - new resource bundles implemented in |
|
46 # Java, not localized |
|
47 # RESOURCE_BUNDLES_JAVA - resource bundles implemented in |
|
48 # Java, localized |
|
49 # |
|
50 # The following variable is now used for most .properties files in the JDK. |
|
51 # These properties files are converted into java and compiled with javac. |
|
52 # The resulting .class files are usually smaller and are always faster to load. |
|
53 # The relative path to the properties file becomes a relative path to a |
|
54 # java source file. |
|
55 # |
|
56 # RESOURCE_BUNDLES_COMPILED_PROPERTIES - resource bundles implemented as |
|
57 # properties files, localized |
|
58 # NEW_RESOURCE_BUNDLES_COMPILED_PROPERTIES - same as above, not localized |
|
59 # |
|
60 # For non-compiled properties files, use the following variables: |
|
61 # |
|
62 # NEW_RESOURCE_BUNDLES_UNCOMPILED_PROPERTIES - new resource bundles implemented as |
|
63 # properties files, not localized |
|
64 # RESOURCE_BUNDLES_UNCOMPILED_PROPERTIES - resource bundles implemented as |
|
65 # properties files, localized |
|
66 # |
|
67 # Other properties files to be installed are identified using the variable: |
|
68 # |
|
69 # OTHER_PROPERTIES |
|
70 # |
|
71 |
|
72 include $(SPEC) |
|
73 include $(SRC_ROOT)/jdk/makefiles/Tools.gmk |
|
74 |
|
75 # Compile properties files into java source? |
|
76 ifdef COMPILED_PROPERTIES_SUPERCLASS |
|
77 # Add all properties files to the compiled properties list (all or nothing) |
|
78 COMPILED_PROPERTIES += $(FILES_compiled_properties) $(FILES_properties) |
|
79 else |
|
80 COMPILED_PROPERTIES_SUPERCLASS = ListResourceBundle |
|
81 COMPILED_PROPERTIES += $(FILES_compiled_properties) |
|
82 endif |
|
83 |
|
84 # Determine the locale suffixes needed beyond the base bundle |
|
85 |
|
86 ifeq ($(LOCALE_SET_DEFINITION), plugin) |
|
87 LOCALE_SUFFIXES += $(PLUGIN_LOCALES) |
|
88 endif |
|
89 ifeq ($(LOCALE_SET_DEFINITION), jdk) |
|
90 LOCALE_SUFFIXES += $(JDK_LOCALES) |
|
91 endif |
|
92 ifeq ($(LOCALE_SET_DEFINITION), jre) |
|
93 LOCALE_SUFFIXES += $(JRE_LOCALES) |
|
94 endif |
|
95 |
|
96 # Java files get tacked onto the standard list of files to compile |
|
97 RESOURCE_BUNDLE_FILES_java += $(NEW_RESOURCE_BUNDLES_JAVA) |
|
98 RESOURCE_BUNDLE_FILES_java += $(RESOURCE_BUNDLES_JAVA) \ |
|
99 $(foreach file,$(RESOURCE_BUNDLES_JAVA), \ |
|
100 $(foreach locale,$(LOCALE_SUFFIXES), \ |
|
101 $(basename $(file))_$(locale).java)) |
|
102 |
|
103 # Add to java sources list |
|
104 FILES_java += $(RESOURCE_BUNDLE_FILES_java) |
|
105 |
|
106 # Compiled properties files are translated to .java. |
|
107 # The .java files are generated into GENSRCDIR. |
|
108 COMPILED_PROPERTIES += $(NEW_RESOURCE_BUNDLES_COMPILED_PROPERTIES) |
|
109 COMPILED_PROPERTIES += $(RESOURCE_BUNDLES_COMPILED_PROPERTIES) \ |
|
110 $(foreach file,$(RESOURCE_BUNDLES_COMPILED_PROPERTIES),\ |
|
111 $(foreach locale,$(LOCALE_SUFFIXES),\ |
|
112 $(basename $(file))_$(locale)$(suffix $(file)))) |
|
113 |
|
114 # Add to java sources list |
|
115 FILES_java += $(COMPILED_PROPERTIES:%.properties=%.java) |
|
116 |
|
117 # Non-compiled files |
|
118 PROPERTIES_FILES += $(NEW_RESOURCE_BUNDLES_UNCOMPILED_PROPERTIES) |
|
119 PROPERTIES_FILES += $(RESOURCE_BUNDLES_UNCOMPILED_PROPERTIES) \ |
|
120 $(foreach file,$(RESOURCE_BUNDLES_UNCOMPILED_PROPERTIES), \ |
|
121 $(foreach locale,$(LOCALE_SUFFIXES), \ |
|
122 $(basename $(file))_$(locale)$(suffix $(file)))) |
|
123 # other properties |
|
124 PROPERTIES_FILES += $(OTHER_PROPERTIES) |
|
125 |
|
126 # |
|
127 # Process and strip all non-compiled properties files (in a batch mode) |
|
128 # |
|
129 STRIP_PROP_FILES = $(PROPERTIES_FILES:%=$(CLASSDESTDIR)/%) |
|
130 # To efficiently strip properties we use one run of StripProperties. |
|
131 # This macro gathers an option for use later. |
|
132 STRIP_PROP_options=$(TEMPDIR)/strip_prop_options |
|
133 define install-properties-file |
|
134 $(install-file) |
|
135 $(call chmod-file, a+rw) |
|
136 @$(ECHO) "# Adding to strip properties list: $@" |
|
137 $(ECHO) "$@" >> $(STRIP_PROP_options) |
|
138 endef |
|
139 |
|
140 # Constructs command line options file |
|
141 $(STRIP_PROP_options): $(STRIP_PROP_FILES) |
|
142 @$(TOUCH) $@ |
|
143 strip_prop_options_clean: |
|
144 @$(RM) $(STRIP_PROP_options) |
|
145 |
|
146 # Strip the properties files |
|
147 strip_all_props: $(BUILD_TOOLS) $(STRIP_PROP_options) |
|
148 @if [ -s $(STRIP_PROP_options) ] ; then \ |
|
149 $(ECHO) "$(TOOL_STRIPPROPERTIES) @$(STRIP_PROP_options)" ; \ |
|
150 $(TOOL_STRIPPROPERTIES) @$(STRIP_PROP_options) ; \ |
|
151 fi |
|
152 @$(java-vm-cleanup) |
|
153 |
|
154 # |
|
155 # Creates files in CLASSDESTDIR |
|
156 # |
|
157 |
|
158 # In some cases, we move files from package to resources subdir |
|
159 $(CLASSDESTDIR)/$(PKGDIR)/resources/%.properties: \ |
|
160 $(SHARE_SRC)/classes/$(PKGDIR)/%.properties |
|
161 $(install-properties-file) |
|
162 $(CLASSDESTDIR)/%.properties: $(SHARE_SRC)/classes/%.properties |
|
163 $(install-properties-file) |
|
164 $(CLASSDESTDIR)/%.res: $(SHARE_SRC)/classes/%.res |
|
165 $(install-file) |
|
166 $(CLASSDESTDIR)/%.dtd: $(SHARE_SRC)/classes/%.dtd |
|
167 $(install-file) |
|
168 $(CLASSDESTDIR)/%.xml: $(SHARE_SRC)/classes/%.xml |
|
169 $(install-file) |
|
170 $(CLASSDESTDIR)/%.prp: $(SHARE_SRC)/classes/%.prp |
|
171 $(install-file) |
|
172 |
|
173 # |
|
174 # To efficiently compile properties into java sources we use one run |
|
175 # of compileproperties. This macro gathers an option for use later. |
|
176 # Note: The properties file and java source name can be different |
|
177 # locales, e.g. zh_TW and zh_HK. The java source filename |
|
178 # determines the name of the class. |
|
179 COMPILE_PROP_options=$(TEMPDIR)/compile_prop_options |
|
180 define add-property-java-file |
|
181 @$(prep-target) |
|
182 @$(ECHO) "# Adding to compile properties list: $? -> $@" |
|
183 $(ECHO) "-compile $? $@ $(COMPILED_PROPERTIES_SUPERCLASS)" \ |
|
184 >> $(COMPILE_PROP_options) |
|
185 endef |
|
186 |
|
187 $(GENSRCDIR)/%.java: $(PLATFORM_SRC)/classes/%.properties |
|
188 $(add-property-java-file) |
|
189 $(GENSRCDIR)/%.java: $(SHARE_SRC)/classes/%.properties |
|
190 $(add-property-java-file) |
|
191 $(GENSRCDIR)/%.java: $(GENSRCDIR)/%.properties |
|
192 $(add-property-java-file) |
|
193 ifndef OPENJDK |
|
194 $(GENSRCDIR)/%.java: $(CLOSED_PLATFORM_SRC)/classes/%.properties |
|
195 $(add-property-java-file) |
|
196 $(GENSRCDIR)/%.java: $(CLOSED_SHARE_SRC)/classes/%.properties |
|
197 $(add-property-java-file) |
|
198 endif |
|
199 |
|
200 # Create HK java file from zh_TW (explicit resource bundles only) |
|
201 define create-hk-java-file |
|
202 @$(prep-target) |
|
203 $(CAT) $< | $(SED) -e '/class/s/_zh_TW/_zh_HK/' > $@ |
|
204 endef |
|
205 |
|
206 # Explicit resource bundles |
|
207 $(GENSRCDIR)/%_zh_HK.java: $(PLATFORM_SRC)/classes/%_zh_TW.java |
|
208 $(create-hk-java-file) |
|
209 $(GENSRCDIR)/%_zh_HK.java: $(SHARE_SRC)/classes/%_zh_TW.java |
|
210 $(create-hk-java-file) |
|
211 |
|
212 # Compile of zh_HK properties just uses the zh_TW properties files |
|
213 $(GENSRCDIR)/%_zh_HK.java: $(PLATFORM_SRC)/classes/%_zh_TW.properties |
|
214 $(add-property-java-file) |
|
215 $(GENSRCDIR)/%_zh_HK.java: $(SHARE_SRC)/classes/%_zh_TW.properties |
|
216 $(add-property-java-file) |
|
217 |
|
218 # Simple delivery of zh_HK properties files just copies zh_TW properties files |
|
219 $(CLASSDESTDIR)/%_zh_HK.properties: \ |
|
220 $(PLATFORM_SRC)/classes/%_zh_TW.properties |
|
221 $(install-properties-file) |
|
222 $(CLASSDESTDIR)/%_zh_HK.properties: \ |
|
223 $(SHARE_SRC)/classes/%_zh_TW.properties |
|
224 $(install-properties-file) |
|
225 |
|
226 # List of java files converted from properties files needed |
|
227 COMPILE_PROP_JAVA_FILES = $(COMPILED_PROPERTIES:%.properties=$(GENSRCDIR)/%.java) |
|
228 |
|
229 # Constructs command line options file |
|
230 $(COMPILE_PROP_options): $(COMPILE_PROP_JAVA_FILES) |
|
231 @$(TOUCH) $@ |
|
232 compile_prop_options_clean: |
|
233 @$(RM) $(COMPILE_PROP_options) |
|
234 |
|
235 # Make sure all are compiled, one compiler run |
|
236 compile_all_props: $(BUILD_TOOLS) $(COMPILE_PROP_options) |
|
237 @if [ `$(CAT) $(COMPILE_PROP_options) | $(WC) -l` -ge 1 ] ; then \ |
|
238 $(MKDIR) -p $(GENSRCDIR); \ |
|
239 $(ECHO) "$(TOOL_COMPILEPROPERTIES) @$(COMPILE_PROP_options)";\ |
|
240 $(TOOL_COMPILEPROPERTIES) @$(COMPILE_PROP_options) ; \ |
|
241 $(java-vm-cleanup); \ |
|
242 fi |
|
243 |
|
244 # Make sure the build rule creates all the properties |
|
245 resources: |
|
246 |
|
247 ifneq ($(strip $(PROPERTIES_FILES)),) |
|
248 resources: strip_prop_options_clean strip_all_props |
|
249 clobber clean:: |
|
250 $(RM) $(STRIP_PROP_FILES) $(STRIP_PROP_options) |
|
251 endif |
|
252 |
|
253 ifneq ($(strip $(COMPILED_PROPERTIES)),) |
|
254 resources: compile_prop_options_clean compile_all_props |
|
255 clobber clean:: |
|
256 $(RM) $(COMPILE_PROP_JAVA_FILES) $(COMPILE_PROP_options) |
|
257 endif |
|
258 |
|
259 .PHONY: resources \ |
|
260 compile_prop_options_clean compile_all_props \ |
|
261 strip_prop_options_clean strip_all_props |
|
262 |
|