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