1 #
   2 # Copyright (c) 2011, 2013, 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 # All .properties files to be compiled are appended to this variable.
  27 ALL_COMPILED_PROPSOURCES :=
  28 # All generated .java files from compilation are appended to this variable.
  29 ALL_COMPILED_PROPJAVAS :=
  30 # The (very long) command line for compilation, stored in a file, prior to use.
  31 COMPILE_PROPCMDLINE :=
  32 
  33 define add_properties_to_compile
  34   # $1 is the name of the properties group
  35   # $2 is the files belonging to this group
  36   # $3 is the super class for the generated java file.
  37 
  38   # Convert <root>/jdk/src/<module>/share/classes/sun/util/resources/CurrencyNames_sv.properties
  39   # to <build>/jdk/gensrc/<module/sun/util/resources/CurrencyNames_sv.java
  40   $1_PROPJAVAS := $$(patsubst $(JDK_TOPDIR)/src/%.properties, \
  41       $(JDK_OUTPUTDIR)/gensrc/%.java, \
  42       $$(subst /share/classes,, \
  43       $$(subst /$(OPENJDK_TARGET_OS_API_DIR)/classes,, \
  44       $$(subst /$(OPENJDK_TARGET_OS)/classes,, $2))))
  45 
  46   # Accumulate all found properties files.
  47   ALL_COMPILED_PROPSOURCES += $2
  48 
  49   # Generate the list of to be created java files.
  50   ALL_COMPILED_PROPJAVAS += $$($1_PROPJAVAS)
  51 
  52   # Now generate a sequence of 
  53   # "-compile ...CurrencyNames_sv.properties ...CurrencyNames_sv.java ListResourceBundle"
  54   # suitable to be fed into the CompileProperties command.
  55   COMPILE_PROPCMDLINE += $$(subst _SPACE_,$(SPACE),$$(join $$(addprefix -compile_SPACE_, $2), \
  56       $$(addsuffix _SPACE_$(strip $3), \
  57       $$(addprefix _SPACE_, $$($1_PROPJAVAS)))))
  58 endef
  59 
  60 ################################################################################
  61 # Some packages have properties that need to be converted to java source files.
  62 COMPILE_PROP_SRC_FILES := \
  63     $(filter %.properties, $(call CacheFind, \
  64         $(JDK_TOPDIR)/src/java.desktop/share/classes/com/sun/accessibility/internal/resources \
  65         $(JDK_TOPDIR)/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/resources \
  66         $(JDK_TOPDIR)/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/resources \
  67         $(JDK_TOPDIR)/src/java.desktop/share/classes/com/sun/swing/internal/plaf/basic/resources \
  68         $(JDK_TOPDIR)/src/java.desktop/share/classes/com/sun/swing/internal/plaf/metal/resources \
  69         $(JDK_TOPDIR)/src/java.desktop/share/classes/com/sun/swing/internal/plaf/synth/resources \
  70         $(JDK_TOPDIR)/src/jdk.jdi/share/classes/com/sun/tools/jdi/resources \
  71         $(JDK_TOPDIR)/src/java.desktop/share/classes/sun/awt/resources \
  72         $(JDK_TOPDIR)/src/java.base/share/classes/sun/launcher/resources \
  73         $(JDK_TOPDIR)/src/java.management/share/classes/sun/management/resources \
  74         $(JDK_TOPDIR)/src/java.desktop/share/classes/sun/print/resources \
  75         $(JDK_TOPDIR)/src/jdk.dev/share/classes/sun/tools/jar/resources \
  76         $(JDK_TOPDIR)/src/java.logging/share/classes/sun/util/logging/resources)) \
  77     #
  78 
  79 ifeq ($(OPENJDK_TARGET_OS), macosx)
  80   COMPILE_PROP_SRC_FILES += \
  81       $(filter %.properties, $(call CacheFind, \
  82           $(JDK_TOPDIR)/src/java.desktop/macosx/classes/com/apple/laf/resources \
  83           $(JDK_TOPDIR)/src/java.desktop/macosx/classes/sun/awt/resources)) \
  84       #
  85 endif
  86 
  87 ifeq ($(OPENJDK_TARGET_OS), windows)
  88   COMPILE_PROP_SRC_FILES += \
  89       $(filter %.properties, $(call CacheFind, \
  90           $(JDK_TOPDIR)/src/java.desktop/windows/classes/sun/awt/windows)) \
  91       #
  92 else # ! windows
  93   COMPILE_PROP_SRC_FILES += \
  94       $(filter %.properties, $(call CacheFind, \
  95           $(JDK_TOPDIR)/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/resources)) \
  96       #
  97 endif
  98 
  99 $(eval $(call add_properties_to_compile,LIST_RESOURCE_BUNDLE, \
 100     $(COMPILE_PROP_SRC_FILES), ListResourceBundle))
 101 
 102 # sun/util/resources
 103 $(eval $(call add_properties_to_compile,SUN_UTIL, \
 104     $(filter %.properties, \
 105         $(call CacheFind, $(JDK_TOPDIR)/src/java.base/share/classes/sun/util/resources) \
 106         $(call CacheFind, $(JDK_TOPDIR)/src/jdk.localedata/share/classes/sun/util/resources)), \
 107     sun.util.resources.LocaleNamesBundle))
 108 
 109 ################################################################################
 110 # Now setup the rule for the generation of the resource bundles.
 111 $(JDK_OUTPUTDIR)/gensrc/_the.compiled_properties: $(ALL_COMPILED_PROPSOURCES) $(BUILD_TOOLS_JDK)
 112         # Generate all output directories in advance since the build tool does not do that...
 113         $(MKDIR) -p $(sort $(dir $(ALL_COMPILED_PROPJAVAS)))
 114         $(ECHO) Compiling $(words $(ALL_COMPILED_PROPSOURCES)) properties into resource bundles
 115         $(call ListPathsSafely,COMPILE_PROPCMDLINE,\n, >> $(JDK_OUTPUTDIR)/gensrc/_the.cmdline)
 116         $(TOOL_COMPILEPROPERTIES) -quiet @$(JDK_OUTPUTDIR)/gensrc/_the.cmdline
 117         $(TOUCH) $@
 118 
 119 $(ALL_COMPILED_PROPJAVAS): $(JDK_OUTPUTDIR)/gensrc/_the.compiled_properties
 120 
 121 ################################################################################
 122 # Some zh_HK resources are just copies of zh_TW
 123 
 124 define convert_tw_to_hk
 125   $(MKDIR) -p $(@D)
 126   $(CAT) $< | $(SED) -e '/class/s/_zh_TW/_zh_HK/' > $@
 127 endef
 128 
 129 # Some are copies of existing sources
 130 $(JDK_OUTPUTDIR)/gensrc/java.desktop/%_zh_HK.java: \
 131     $(JDK_TOPDIR)/src/java.desktop/share/classes/%_zh_TW.java
 132         $(call convert_tw_to_hk)
 133 
 134 $(JDK_OUTPUTDIR)/gensrc/java.base/%_zh_HK.java: \
 135     $(JDK_TOPDIR)/src/java.base/share/classes/%_zh_TW.java
 136         $(call convert_tw_to_hk)
 137 
 138 # Others are copies of sources generated by this makefile
 139 $(JDK_OUTPUTDIR)/gensrc/%_zh_HK.java: $(JDK_OUTPUTDIR)/gensrc/%_zh_TW.java
 140         $(call convert_tw_to_hk)
 141 
 142 # The existing sources
 143 ZH_HK_JAVA := java.desktop/sun/applet/resources/MsgAppletViewer_zh_HK.java \
 144     java.base/sun/misc/resources/Messages_zh_HK.java \
 145     java.base/sun/security/util/AuthResources_zh_HK.java \
 146     java.base/sun/security/util/Resources_zh_HK.java
 147 
 148 ZH_HK_JAVA_FILES := $(addprefix $(JDK_OUTPUTDIR)/gensrc/, $(ZH_HK_JAVA)) \
 149     $(filter-out $(JDK_OUTPUTDIR)/gensrc/jdk.localedata/sun/util/resources/zh/%, \
 150     $(subst _zh_TW,_zh_HK,$(filter %_zh_TW.java, $(ALL_COMPILED_PROPJAVAS))))
 151 
 152 ################################################################################
 153 
 154 GENSRC_PROPERTIES := $(ALL_COMPILED_PROPJAVAS) $(ZH_HK_JAVA_FILES)