blob: 5f88ec04d243a4f9ba4f67082df5aea8f95de04d [file] [log] [blame]
ohair92de5662012-04-10 08:22:03 -07001#
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
31LOCALE_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
40LOCALE_RESOURCES:=$(sort $(subst .properties,,$(subst .java,,$(notdir $(LOCALE_FILES)))))
41
42# Include the list of resources found during the previous compile.
ohairb71409c2012-10-26 14:23:29 -070043-include $(JDK_OUTPUTDIR)/gensrc/_the.locale_resources
ohair92de5662012-04-10 08:22:03 -070044
45MISSING_RESOURCES:=$(filter-out $(LOCALE_RESOURCES),$(PREV_LOCALE_RESOURCES))
46NEW_RESOURCES:=$(filter-out $(PREV_LOCALE_RESOURCES),$(LOCALE_RESOURCES))
47
48ifneq (,$(MISSING_RESOURCES)$(NEW_RESOURCES))
49 # There is a difference in the number of supported resources. Trigger a regeneration.
ohairb71409c2012-10-26 14:23:29 -070050 $(shell $(RM) $(JDK_OUTPUTDIR)/gensrc/sun/util/locale/provider/LocaleDataMetaInfo.java)
ohair92de5662012-04-10 08:22:03 -070051endif
52
53# The non-euro zone locales have to be separated from the euro-zone locales.
54NON_EURO_LOCALES:=ar% hi% iw% ja% ko% th% vi% zh%
55
naotoc378ffc2012-08-21 11:00:30 -070056# ja-JP-JP and th-TH-TH need to be manually added, as they don't have any resource files.
57ALL_NON_EURO_LOCALES:=ja-JP-JP th-TH-TH
ohair92de5662012-04-10 08:22:03 -070058
59SED_ARGS:=-e 's|$(HASH)warn This file is preprocessed before being compiled|// -- This file was mechanically generated: Do not edit! -- //|g'
naotoc378ffc2012-08-21 11:00:30 -070060
61# This macro creates a sed expression that substitues for example:
62# #FormatData_EuroLocales# with: be be_BY bg bg_BG ca ca_ES... and some more.
63define CaptureLocale
64 $1_LOCALES := $$(subst _,-,$$(filter-out $1,$$(subst $1_,,$$(filter $1_%,$(LOCALE_RESOURCES)))))
65 $1_EURO_LOCALES := $$(filter-out $(NON_EURO_LOCALES),$$($1_LOCALES))
66 $1_NON_EURO_LOCALES := $$(filter $(NON_EURO_LOCALES),$$($1_LOCALES))
67
68 ALL_EURO_LOCALES += $$($1_EURO_LOCALES)
69 ALL_NON_EURO_LOCALES += $$($1_NON_EURO_LOCALES)
70
71 SED_ARGS+= -e 's/$$(HASH)$1_EuroLocales$$(HASH)/ $$($1_EURO_LOCALES)/g'
72 SED_ARGS+= -e 's/$$(HASH)$1_NonEuroLocales$$(HASH)/ $$($1_NON_EURO_LOCALES)/g'
73endef
74
ohair92de5662012-04-10 08:22:03 -070075#sun.text.resources.FormatData
naotoc378ffc2012-08-21 11:00:30 -070076$(eval $(call CaptureLocale,FormatData))
ohair92de5662012-04-10 08:22:03 -070077
78#sun.text.resources.CollationData
naotoc378ffc2012-08-21 11:00:30 -070079$(eval $(call CaptureLocale,CollationData))
ohair92de5662012-04-10 08:22:03 -070080
81#sun.util.resources.TimeZoneNames
naotoc378ffc2012-08-21 11:00:30 -070082$(eval $(call CaptureLocale,TimeZoneNames))
ohair92de5662012-04-10 08:22:03 -070083
84#sun.util.resources.LocaleNames
naotoc378ffc2012-08-21 11:00:30 -070085$(eval $(call CaptureLocale,LocaleNames))
ohair92de5662012-04-10 08:22:03 -070086
87#sun.util.resources.CurrencyNames
naotoc378ffc2012-08-21 11:00:30 -070088$(eval $(call CaptureLocale,CurrencyNames))
ohair92de5662012-04-10 08:22:03 -070089
90#sun.util.resources.CalendarData
naotoc378ffc2012-08-21 11:00:30 -070091$(eval $(call CaptureLocale,CalendarData))
ohair92de5662012-04-10 08:22:03 -070092
naotoc378ffc2012-08-21 11:00:30 -070093SED_ARGS+= -e 's/$(HASH)AvailableLocales_EuroLocales$(HASH)/$(sort $(ALL_EURO_LOCALES))/g'
94SED_ARGS+= -e 's/$(HASH)AvailableLocales_NonEuroLocales$(HASH)/$(sort $(ALL_NON_EURO_LOCALES))/g'
95
ohairb71409c2012-10-26 14:23:29 -070096$(JDK_OUTPUTDIR)/gensrc/sun/util/locale/provider/LocaleDataMetaInfo.java: \
naotoc378ffc2012-08-21 11:00:30 -070097 $(JDK_TOPDIR)/src/share/classes/sun/util/locale/provider/LocaleDataMetaInfo-XLocales.java.template
erikje78df742012-06-07 20:40:50 -070098 $(MKDIR) -p $(@D)
ohair92de5662012-04-10 08:22:03 -070099 $(ECHO) Creating sun/util/LocaleDataMetaInfo.java from $(words $(LOCALE_RESOURCES)) found resources.
ohairb71409c2012-10-26 14:23:29 -0700100 $(PRINTF) "PREV_LOCALE_RESOURCES:=$(LOCALE_RESOURCES)" > $(JDK_OUTPUTDIR)/gensrc/_the.locale_resources
naotoc378ffc2012-08-21 11:00:30 -0700101 $(SED) $(SED_ARGS) $< > $@
ohair92de5662012-04-10 08:22:03 -0700102
ohairb71409c2012-10-26 14:23:29 -0700103GENSRC_LOCALEDATAMETAINFO:=$(JDK_OUTPUTDIR)/gensrc/sun/util/locale/provider/LocaleDataMetaInfo.java
erikje78df742012-06-07 20:40:50 -0700104
105###
106
ohairb71409c2012-10-26 14:23:29 -0700107GENSRC_CRBC_DST := $(JDK_OUTPUTDIR)/gensrc/sun/util/CoreResourceBundleControl.java
erikje78df742012-06-07 20:40:50 -0700108GENSRC_CRBC_CMD := $(JDK_TOPDIR)/makefiles/scripts/localelist.sh
109
110JRE_NONEXIST_LOCALES := en en_US de_DE es_ES fr_FR it_IT ja_JP ko_KR sv_SE zh
111
112$(GENSRC_CRBC_DST) : $(JDK_TOPDIR)/src/share/classes/sun/util/CoreResourceBundleControl-XLocales.java.template \
113 $(GENSRC_CRBC_CMD)
114 $(MKDIR) -p $(@D)
115 NAWK="$(NAWK)" SED="$(SED)" $(SH) $(GENSRC_CRBC_CMD) "$(JRE_NONEXIST_LOCALES)" $< $@
116
117GENSRC_LOCALEDATAMETAINFO += $(GENSRC_CRBC_DST)
118
119###