xref: /OK3568_Linux_fs/buildroot/support/misc/gen-glibc-locales.mk (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun# Generates glibc locale data for target.
2*4882a593Smuzhiyun
3*4882a593Smuzhiyuninputfile = $(firstword $(subst ., ,$(1)))
4*4882a593Smuzhiyuncharmap = $(or $(word 2,$(subst ., ,$(1))),UTF-8)
5*4882a593Smuzhiyun
6*4882a593Smuzhiyun# Packages all the generated locale data into the final archive.
7*4882a593Smuzhiyun#
8*4882a593Smuzhiyun# We sort the file names to produce consistent output regardless of
9*4882a593Smuzhiyun# the `find` outputs order.
10*4882a593Smuzhiyun$(TARGET_DIR)/usr/lib/locale/locale-archive: $(LOCALES)
11*4882a593Smuzhiyun	$(Q)rm -f $(@)
12*4882a593Smuzhiyun	$(Q)find $(TARGET_DIR)/usr/lib/locale/ -maxdepth 1 -mindepth 1 -type d -print0 \
13*4882a593Smuzhiyun	| sort -z \
14*4882a593Smuzhiyun	| xargs -0 \
15*4882a593Smuzhiyun		$(HOST_DIR)/bin/localedef \
16*4882a593Smuzhiyun			--prefix=$(TARGET_DIR) \
17*4882a593Smuzhiyun			--$(ENDIAN)-endian \
18*4882a593Smuzhiyun			--add-to-archive
19*4882a593Smuzhiyun
20*4882a593Smuzhiyun# Generates locale data for each locale.
21*4882a593Smuzhiyun#
22*4882a593Smuzhiyun# The input data comes preferably from the toolchain, or if the toolchain
23*4882a593Smuzhiyun# does not have them (Linaro toolchains), we use the ones available on the
24*4882a593Smuzhiyun# host machine.
25*4882a593Smuzhiyun#
26*4882a593Smuzhiyun# Uses `localedef`, which is built by the `host-localedef` package.
27*4882a593Smuzhiyun$(LOCALES): | $(TARGET_DIR)/usr/lib/locale/
28*4882a593Smuzhiyun	$(Q)echo "Generating locale $(@)"
29*4882a593Smuzhiyun	$(Q)I18NPATH=$(STAGING_DIR)/usr/share/i18n:/usr/share/i18n \
30*4882a593Smuzhiyun	$(HOST_DIR)/bin/localedef \
31*4882a593Smuzhiyun		--prefix=$(TARGET_DIR) \
32*4882a593Smuzhiyun		--$(ENDIAN)-endian \
33*4882a593Smuzhiyun		--no-archive \
34*4882a593Smuzhiyun		-i $(call inputfile,$(@)) \
35*4882a593Smuzhiyun		-f $(call charmap,$(@)) \
36*4882a593Smuzhiyun		$(@)
37*4882a593Smuzhiyun
38*4882a593Smuzhiyun.PHONY: $(LOCALES)
39*4882a593Smuzhiyun
40*4882a593Smuzhiyun$(TARGET_DIR)/usr/lib/locale/:
41*4882a593Smuzhiyun	$(Q)mkdir -p $(TARGET_DIR)/usr/lib/locale/
42