# # Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License version 2 only, as # published by the Free Software Foundation. Oracle designates this # particular file as subject to the "Classpath" exception as provided # by Oracle in the LICENSE file that accompanied this code. # # This code is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # version 2 for more details (a copy is included in the LICENSE file that # accompanied this code). # # You should have received a copy of the GNU General Public License version # 2 along with this work; if not, write to the Free Software Foundation, # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. # # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA # or visit www.oracle.com if you need additional information or have any # questions. # # # Generic mechanism for installing properties files, resource bundles, # and other resource files. # # FILES_properties should be defined. # FILES_compiled_properties should be defined. # # If COMPILED_PROPERTIES_SUPERCLASS is defined, ALL the FILES_properties # files will be compiled into java with this super class. # # You can add locales to LOCALE_SUFFIXES explicitly, or use the # LOCALE_SET_DEFINITION variable to add some pre-defined locale lists. # The LOCALE_SET_DEFINITION can have the value: jre, plugin, or jdk. # # Resource bundles to be installed are identified using the following variables. # Note that only the file name of the base bundle is given; localized versions # are added automatically. For Java files, use a format suitable for inclusion # in the FILES_java list; dito for properties, all relative paths. # # NEW_RESOURCE_BUNDLES_JAVA - new resource bundles implemented in # Java, not localized # NEW_RESOURCE_BUNDLES_PROPERTIES - new resource bundles implemented as # properties files, not localized # RESOURCE_BUNDLES_JAVA - resource bundles implemented in # Java, localized # RESOURCE_BUNDLES_PROPERTIES - new resource bundles implemented as # properties files, localized # # The following variable is now used for most .properties files in the JDK. # These properties files are converted into java and compiled with javac. # The resulting .class files are usually smaller and are always faster to load. # The relative path to the properties file becomes a relative path to a # java source file. # # RESOURCE_BUNDLES_COMPILED_PROPERTIES - resource bundles implemented as # properties files, localized # NEW_RESOURCE_BUNDLES_COMPILED_PROPERTIES - same as above, not localized # # Other properties files to be installed are identified using the variable: # # OTHER_PROPERTIES # # Compile properties files into java source? ifdef COMPILED_PROPERTIES_SUPERCLASS # Add all properties files to the compiled properties list (all or nothing) COMPILED_PROPERTIES += $(FILES_compiled_properties) $(FILES_properties) else COMPILED_PROPERTIES_SUPERCLASS = ListResourceBundle COMPILED_PROPERTIES += $(FILES_compiled_properties) endif # Determine the locale suffixes needed beyond the base bundle ifeq ($(LOCALE_SET_DEFINITION), plugin) LOCALE_SUFFIXES += $(PLUGIN_LOCALES) endif ifeq ($(LOCALE_SET_DEFINITION), jdk) LOCALE_SUFFIXES += $(JDK_LOCALES) endif ifeq ($(LOCALE_SET_DEFINITION), jre) LOCALE_SUFFIXES += $(JRE_LOCALES) endif # Java files get tacked onto the standard list of files to compile RESOURCE_BUNDLE_FILES_java += $(NEW_RESOURCE_BUNDLES_JAVA) RESOURCE_BUNDLE_FILES_java += $(RESOURCE_BUNDLES_JAVA) \ $(foreach file,$(RESOURCE_BUNDLES_JAVA), \ $(foreach locale,$(LOCALE_SUFFIXES), \ $(basename $(file))_$(locale).java)) # Add to java sources list FILES_java += $(RESOURCE_BUNDLE_FILES_java) # Compiled properties files are translated to .java. # The .java files are generated into GENSRCDIR. COMPILED_PROPERTIES += $(NEW_RESOURCE_BUNDLES_COMPILED_PROPERTIES) COMPILED_PROPERTIES += $(RESOURCE_BUNDLES_COMPILED_PROPERTIES) \ $(foreach file,$(RESOURCE_BUNDLES_COMPILED_PROPERTIES),\ $(foreach locale,$(LOCALE_SUFFIXES),\ $(basename $(file))_$(locale)$(suffix $(file)))) # Add to java sources list FILES_java += $(COMPILED_PROPERTIES:%.properties=%.java) # Non-compiled files PROPERTIES_FILES += $(NEW_RESOURCE_BUNDLES_PROPERTIES) PROPERTIES_FILES += $(RESOURCE_BUNDLES_PROPERTIES) \ $(foreach file,$(RESOURCE_BUNDLES_PROPERTIES), \ $(foreach locale,$(LOCALE_SUFFIXES), \ $(basename $(file))_$(locale)$(suffix $(file)))) PROPERTIES_FILES += $(OTHER_PROPERTIES) # # Compile Properties tool # COMPILEPROPERTIES_JARFILE = $(BUILDTOOLJARDIR)/compileproperties.jar # # Strip Properties tool # STRIPPROPERTIES_JARFILE = $(BUILDTOOLJARDIR)/stripproperties.jar # # Process and strip all non-compiled properties files (in a batch mode) # STRIP_PROP_FILES = $(PROPERTIES_FILES:%=$(CLASSDESTDIR)/%) # To efficiently strip properties we use one run of StripProperties. # This macro gathers an option for use later. STRIP_PROP_options=$(TEMPDIR)/strip_prop_options define install-properties-file $(install-file) $(CHMOD) a+rw $@ @$(ECHO) "# Adding to strip properties list: $@" $(ECHO) "$@" >> $(STRIP_PROP_options) endef # Constructs command line options file $(STRIP_PROP_options): $(STRIP_PROP_FILES) @$(TOUCH) $@ strip_prop_options_clean: @$(RM) $(STRIP_PROP_options) # Strip the properties files strip_all_props: $(STRIPPROPERTIES_JARFILE) $(STRIP_PROP_options) @if [ -s $(STRIP_PROP_options) ] ; then \ $(ECHO) "$(BOOT_JAVA_CMD) -jar $(STRIPPROPERTIES_JARFILE) @$(STRIP_PROP_options)" ; \ $(BOOT_JAVA_CMD) -jar $(STRIPPROPERTIES_JARFILE) @$(STRIP_PROP_options) ; \ fi @$(java-vm-cleanup) # # Creates files in CLASSDESTDIR # # In some cases, we move files from package to resources subdir $(CLASSDESTDIR)/$(PKGDIR)/resources/%.properties: \ $(SHARE_SRC)/classes/$(PKGDIR)/%.properties $(install-properties-file) $(CLASSDESTDIR)/%.properties: $(SHARE_SRC)/classes/%.properties $(install-properties-file) $(CLASSDESTDIR)/%.res: $(SHARE_SRC)/classes/%.res $(install-file) $(CLASSDESTDIR)/%.dtd: $(SHARE_SRC)/classes/%.dtd $(install-file) $(CLASSDESTDIR)/%.xml: $(SHARE_SRC)/classes/%.xml $(install-file) $(CLASSDESTDIR)/%.prp: $(SHARE_SRC)/classes/%.prp $(install-file) $(GENSRCDIR)/%.java: $(PLATFORM_SRC)/classes/%.properties $(add-property-java-file) $(GENSRCDIR)/%.java: $(SHARE_SRC)/classes/%.properties $(add-property-java-file) $(GENSRCDIR)/%.java: $(GENSRCDIR)/%.properties $(add-property-java-file) # Create HK java file from zh_TW (explicit resource bundles only) define create-hk-java-file @$(prep-target) $(CAT) $< | $(SED) -e '/class/s/_zh_TW/_zh_HK/' > $@ endef # Explicit resource bundles $(GENSRCDIR)/%_zh_HK.java: $(PLATFORM_SRC)/classes/%_zh_TW.java $(create-hk-java-file) $(GENSRCDIR)/%_zh_HK.java: $(SHARE_SRC)/classes/%_zh_TW.java $(create-hk-java-file) # Compile of zh_HK properties just uses the zh_TW properties files $(GENSRCDIR)/%_zh_HK.java: $(PLATFORM_SRC)/classes/%_zh_TW.properties $(add-property-java-file) $(GENSRCDIR)/%_zh_HK.java: $(SHARE_SRC)/classes/%_zh_TW.properties $(add-property-java-file) # Simple delivery of zh_HK properties files just copies zh_TW properties files $(CLASSDESTDIR)/%_zh_HK.properties: \ $(PLATFORM_SRC)/classes/%_zh_TW.properties $(install-properties-file) $(CLASSDESTDIR)/%_zh_HK.properties: \ $(SHARE_SRC)/classes/%_zh_TW.properties $(install-properties-file) # List of java files converted from properties files needed COMPILE_PROP_JAVA_FILES = $(COMPILED_PROPERTIES:%.properties=$(GENSRCDIR)/%.java) # Make sure the build rule creates all the properties resources: ifneq ($(PROPERTIES_FILES),) resources: strip_prop_options_clean strip_all_props clobber clean:: $(RM) $(STRIP_PROP_FILES) $(RM) $(STRIP_PROP_options) endif .PHONY: resources \ strip_prop_options_clean strip_all_props