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