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