blob: 2b5c1e7bd16d7acab1ee277dc064a3f5177e66f2 [file] [log] [blame]
#
# Copyright (c) 1997, 2010, 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
# RESOURCE_BUNDLES_JAVA - resource bundles implemented in
# Java, 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
#
# For non-compiled properties files, use the following variables:
#
# NEW_RESOURCE_BUNDLES_UNCOMPILED_PROPERTIES - new resource bundles implemented as
# properties files, not localized
# RESOURCE_BUNDLES_UNCOMPILED_PROPERTIES - resource bundles implemented as
# properties files, localized
#
# Other properties files to be installed are identified using the variable:
#
# OTHER_PROPERTIES
#
include $(SPEC)
include $(SRC_ROOT)/jdk/makefiles/Tools.gmk
# 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_UNCOMPILED_PROPERTIES)
PROPERTIES_FILES += $(RESOURCE_BUNDLES_UNCOMPILED_PROPERTIES) \
$(foreach file,$(RESOURCE_BUNDLES_UNCOMPILED_PROPERTIES), \
$(foreach locale,$(LOCALE_SUFFIXES), \
$(basename $(file))_$(locale)$(suffix $(file))))
# other properties
PROPERTIES_FILES += $(OTHER_PROPERTIES)
#
# 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)
$(call chmod-file, 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: $(BUILD_TOOLS) $(STRIP_PROP_options)
@if [ -s $(STRIP_PROP_options) ] ; then \
$(ECHO) "$(TOOL_STRIPPROPERTIES) @$(STRIP_PROP_options)" ; \
$(TOOL_STRIPPROPERTIES) @$(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)
#
# To efficiently compile properties into java sources we use one run
# of compileproperties. This macro gathers an option for use later.
# Note: The properties file and java source name can be different
# locales, e.g. zh_TW and zh_HK. The java source filename
# determines the name of the class.
COMPILE_PROP_options=$(TEMPDIR)/compile_prop_options
define add-property-java-file
@$(prep-target)
@$(ECHO) "# Adding to compile properties list: $? -> $@"
$(ECHO) "-compile $? $@ $(COMPILED_PROPERTIES_SUPERCLASS)" \
>> $(COMPILE_PROP_options)
endef
$(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)
ifndef OPENJDK
$(GENSRCDIR)/%.java: $(CLOSED_PLATFORM_SRC)/classes/%.properties
$(add-property-java-file)
$(GENSRCDIR)/%.java: $(CLOSED_SHARE_SRC)/classes/%.properties
$(add-property-java-file)
endif
# 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)
# Constructs command line options file
$(COMPILE_PROP_options): $(COMPILE_PROP_JAVA_FILES)
@$(TOUCH) $@
compile_prop_options_clean:
@$(RM) $(COMPILE_PROP_options)
# Make sure all are compiled, one compiler run
compile_all_props: $(BUILD_TOOLS) $(COMPILE_PROP_options)
@if [ `$(CAT) $(COMPILE_PROP_options) | $(WC) -l` -ge 1 ] ; then \
$(MKDIR) -p $(GENSRCDIR); \
$(ECHO) "$(TOOL_COMPILEPROPERTIES) @$(COMPILE_PROP_options)";\
$(TOOL_COMPILEPROPERTIES) @$(COMPILE_PROP_options) ; \
$(java-vm-cleanup); \
fi
# Make sure the build rule creates all the properties
resources:
ifneq ($(strip $(PROPERTIES_FILES)),)
resources: strip_prop_options_clean strip_all_props
clobber clean::
$(RM) $(STRIP_PROP_FILES) $(STRIP_PROP_options)
endif
ifneq ($(strip $(COMPILED_PROPERTIES)),)
resources: compile_prop_options_clean compile_all_props
clobber clean::
$(RM) $(COMPILE_PROP_JAVA_FILES) $(COMPILE_PROP_options)
endif
.PHONY: resources \
compile_prop_options_clean compile_all_props \
strip_prop_options_clean strip_all_props