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