ohair | 92de566 | 2012-04-10 08:22:03 -0700 | [diff] [blame] | 1 | # |
| 2 | # Copyright (c) 2011, 2012, 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 | # Scan for all locale resources and extract for which locales there exists |
| 27 | # resources. Then put this meta information about exiting (supported?) locales |
| 28 | # into LocaleDataMetaInfo.java |
| 29 | |
| 30 | # First go look for all locale files |
| 31 | LOCALE_FILES:=$(shell $(FIND) $(JDK_TOPDIR)/src/share/classes \ |
| 32 | -name "FormatData_*.java" -o -name "FormatData_*.properties" -o \ |
| 33 | -name "CollationData_*.java" -o -name "CollationData_*.properties" -o \ |
| 34 | -name "TimeZoneNames_*.java" -o -name "TimeZoneNames_*.properties" -o \ |
| 35 | -name "LocaleNames_*.java" -o -name "LocaleNames_*.properties" -o \ |
| 36 | -name "CurrencyNames_*.java" -o -name "CurrencyNames_*.properties" -o \ |
| 37 | -name "CalendarData_*.java" -o -name "CalendarData_*.properties") |
| 38 | |
| 39 | # Then translate the locale files into for example: FormatData_sv |
| 40 | LOCALE_RESOURCES:=$(sort $(subst .properties,,$(subst .java,,$(notdir $(LOCALE_FILES))))) |
| 41 | |
| 42 | # Include the list of resources found during the previous compile. |
ohair | b71409c | 2012-10-26 14:23:29 -0700 | [diff] [blame] | 43 | -include $(JDK_OUTPUTDIR)/gensrc/_the.locale_resources |
ohair | 92de566 | 2012-04-10 08:22:03 -0700 | [diff] [blame] | 44 | |
| 45 | MISSING_RESOURCES:=$(filter-out $(LOCALE_RESOURCES),$(PREV_LOCALE_RESOURCES)) |
| 46 | NEW_RESOURCES:=$(filter-out $(PREV_LOCALE_RESOURCES),$(LOCALE_RESOURCES)) |
| 47 | |
| 48 | ifneq (,$(MISSING_RESOURCES)$(NEW_RESOURCES)) |
| 49 | # There is a difference in the number of supported resources. Trigger a regeneration. |
ohair | b71409c | 2012-10-26 14:23:29 -0700 | [diff] [blame] | 50 | $(shell $(RM) $(JDK_OUTPUTDIR)/gensrc/sun/util/locale/provider/LocaleDataMetaInfo.java) |
ohair | 92de566 | 2012-04-10 08:22:03 -0700 | [diff] [blame] | 51 | endif |
| 52 | |
naoto | 85d2c71 | 2012-10-31 11:33:36 -0700 | [diff] [blame] | 53 | # The US locales |
| 54 | US_LOCALES:=en en-US |
ohair | 92de566 | 2012-04-10 08:22:03 -0700 | [diff] [blame] | 55 | |
naoto | c378ffc | 2012-08-21 11:00:30 -0700 | [diff] [blame] | 56 | # ja-JP-JP and th-TH-TH need to be manually added, as they don't have any resource files. |
naoto | 85d2c71 | 2012-10-31 11:33:36 -0700 | [diff] [blame] | 57 | ALL_NON_US_LOCALES:=ja-JP-JP th-TH-TH |
ohair | 92de566 | 2012-04-10 08:22:03 -0700 | [diff] [blame] | 58 | |
| 59 | SED_ARGS:=-e 's|$(HASH)warn This file is preprocessed before being compiled|// -- This file was mechanically generated: Do not edit! -- //|g' |
naoto | c378ffc | 2012-08-21 11:00:30 -0700 | [diff] [blame] | 60 | |
| 61 | # This macro creates a sed expression that substitues for example: |
naoto | 85d2c71 | 2012-10-31 11:33:36 -0700 | [diff] [blame] | 62 | # #FormatData_USLocales# with: en and/or en_US. |
naoto | c378ffc | 2012-08-21 11:00:30 -0700 | [diff] [blame] | 63 | define CaptureLocale |
| 64 | $1_LOCALES := $$(subst _,-,$$(filter-out $1,$$(subst $1_,,$$(filter $1_%,$(LOCALE_RESOURCES))))) |
naoto | 85d2c71 | 2012-10-31 11:33:36 -0700 | [diff] [blame] | 65 | $1_US_LOCALES := $$(filter $(US_LOCALES),$$($1_LOCALES)) |
| 66 | $1_NON_US_LOCALES := $$(filter-out $(US_LOCALES),$$($1_LOCALES)) |
naoto | c378ffc | 2012-08-21 11:00:30 -0700 | [diff] [blame] | 67 | |
naoto | 85d2c71 | 2012-10-31 11:33:36 -0700 | [diff] [blame] | 68 | ALL_US_LOCALES += $$($1_US_LOCALES) |
| 69 | ALL_NON_US_LOCALES += $$($1_NON_US_LOCALES) |
naoto | c378ffc | 2012-08-21 11:00:30 -0700 | [diff] [blame] | 70 | |
tbell | 6e4e7b4 | 2012-11-12 10:49:44 -0800 | [diff] [blame] | 71 | # Don't sed in a space if there are no locales. |
| 72 | SED_ARGS+= -e 's/$$(HASH)$1_USLocales$$(HASH)/$$(if $$($1_US_LOCALES),$$(SPACE)$$($1_US_LOCALES),)/g' |
| 73 | SED_ARGS+= -e 's/$$(HASH)$1_NonUSLocales$$(HASH)/$$(if $$($1_NON_US_LOCALES),$$(SPACE)$$($1_NON_US_LOCALES),)/g' |
naoto | c378ffc | 2012-08-21 11:00:30 -0700 | [diff] [blame] | 74 | endef |
| 75 | |
ohair | 92de566 | 2012-04-10 08:22:03 -0700 | [diff] [blame] | 76 | #sun.text.resources.FormatData |
naoto | c378ffc | 2012-08-21 11:00:30 -0700 | [diff] [blame] | 77 | $(eval $(call CaptureLocale,FormatData)) |
ohair | 92de566 | 2012-04-10 08:22:03 -0700 | [diff] [blame] | 78 | |
| 79 | #sun.text.resources.CollationData |
naoto | c378ffc | 2012-08-21 11:00:30 -0700 | [diff] [blame] | 80 | $(eval $(call CaptureLocale,CollationData)) |
ohair | 92de566 | 2012-04-10 08:22:03 -0700 | [diff] [blame] | 81 | |
| 82 | #sun.util.resources.TimeZoneNames |
naoto | c378ffc | 2012-08-21 11:00:30 -0700 | [diff] [blame] | 83 | $(eval $(call CaptureLocale,TimeZoneNames)) |
ohair | 92de566 | 2012-04-10 08:22:03 -0700 | [diff] [blame] | 84 | |
| 85 | #sun.util.resources.LocaleNames |
naoto | c378ffc | 2012-08-21 11:00:30 -0700 | [diff] [blame] | 86 | $(eval $(call CaptureLocale,LocaleNames)) |
ohair | 92de566 | 2012-04-10 08:22:03 -0700 | [diff] [blame] | 87 | |
| 88 | #sun.util.resources.CurrencyNames |
naoto | c378ffc | 2012-08-21 11:00:30 -0700 | [diff] [blame] | 89 | $(eval $(call CaptureLocale,CurrencyNames)) |
ohair | 92de566 | 2012-04-10 08:22:03 -0700 | [diff] [blame] | 90 | |
| 91 | #sun.util.resources.CalendarData |
naoto | c378ffc | 2012-08-21 11:00:30 -0700 | [diff] [blame] | 92 | $(eval $(call CaptureLocale,CalendarData)) |
ohair | 92de566 | 2012-04-10 08:22:03 -0700 | [diff] [blame] | 93 | |
naoto | 85d2c71 | 2012-10-31 11:33:36 -0700 | [diff] [blame] | 94 | SED_ARGS+= -e 's/$(HASH)AvailableLocales_USLocales$(HASH)/$(sort $(ALL_US_LOCALES))/g' |
| 95 | SED_ARGS+= -e 's/$(HASH)AvailableLocales_NonUSLocales$(HASH)/$(sort $(ALL_NON_US_LOCALES))/g' |
naoto | c378ffc | 2012-08-21 11:00:30 -0700 | [diff] [blame] | 96 | |
ohair | b71409c | 2012-10-26 14:23:29 -0700 | [diff] [blame] | 97 | $(JDK_OUTPUTDIR)/gensrc/sun/util/locale/provider/LocaleDataMetaInfo.java: \ |
naoto | c378ffc | 2012-08-21 11:00:30 -0700 | [diff] [blame] | 98 | $(JDK_TOPDIR)/src/share/classes/sun/util/locale/provider/LocaleDataMetaInfo-XLocales.java.template |
erikj | e78df74 | 2012-06-07 20:40:50 -0700 | [diff] [blame] | 99 | $(MKDIR) -p $(@D) |
ohair | 92de566 | 2012-04-10 08:22:03 -0700 | [diff] [blame] | 100 | $(ECHO) Creating sun/util/LocaleDataMetaInfo.java from $(words $(LOCALE_RESOURCES)) found resources. |
ohair | b71409c | 2012-10-26 14:23:29 -0700 | [diff] [blame] | 101 | $(PRINTF) "PREV_LOCALE_RESOURCES:=$(LOCALE_RESOURCES)" > $(JDK_OUTPUTDIR)/gensrc/_the.locale_resources |
naoto | c378ffc | 2012-08-21 11:00:30 -0700 | [diff] [blame] | 102 | $(SED) $(SED_ARGS) $< > $@ |
ohair | 92de566 | 2012-04-10 08:22:03 -0700 | [diff] [blame] | 103 | |
ohair | b71409c | 2012-10-26 14:23:29 -0700 | [diff] [blame] | 104 | GENSRC_LOCALEDATAMETAINFO:=$(JDK_OUTPUTDIR)/gensrc/sun/util/locale/provider/LocaleDataMetaInfo.java |
erikj | e78df74 | 2012-06-07 20:40:50 -0700 | [diff] [blame] | 105 | |
| 106 | ### |
| 107 | |
ohair | b71409c | 2012-10-26 14:23:29 -0700 | [diff] [blame] | 108 | GENSRC_CRBC_DST := $(JDK_OUTPUTDIR)/gensrc/sun/util/CoreResourceBundleControl.java |
erikj | e78df74 | 2012-06-07 20:40:50 -0700 | [diff] [blame] | 109 | GENSRC_CRBC_CMD := $(JDK_TOPDIR)/makefiles/scripts/localelist.sh |
| 110 | |
| 111 | JRE_NONEXIST_LOCALES := en en_US de_DE es_ES fr_FR it_IT ja_JP ko_KR sv_SE zh |
| 112 | |
| 113 | $(GENSRC_CRBC_DST) : $(JDK_TOPDIR)/src/share/classes/sun/util/CoreResourceBundleControl-XLocales.java.template \ |
| 114 | $(GENSRC_CRBC_CMD) |
| 115 | $(MKDIR) -p $(@D) |
| 116 | NAWK="$(NAWK)" SED="$(SED)" $(SH) $(GENSRC_CRBC_CMD) "$(JRE_NONEXIST_LOCALES)" $< $@ |
| 117 | |
| 118 | GENSRC_LOCALEDATAMETAINFO += $(GENSRC_CRBC_DST) |
| 119 | |
| 120 | ### |