From aebf199ff034460c817782c1b14ec4e8c75a8959 Mon Sep 17 00:00:00 2001 From: Thomas Petazzoni Date: Tue, 8 May 2012 04:39:22 +0000 Subject: Add support to generate locale data In order to use locale support on a Linux system, you need locale data to be present: * on a (e)glibc based system, this data is typically in the /usr/lib/locale/locale-archive file, which can be created and extended using the localedef program * on an uClibc based system, the set of supported locales is defined at build time by an uClibc configuration option. This patch implements generating locale data for the following cases: * Internal toolchain * External toolchain based on (e)glibc. uClibc external toolchains are not supported, because with uClibc, the set of supported locales is defined at build time. CodeSourcery and Linaro toolchains have been tested, Crosstool-NG toolchains are believed to work properly as well. * Toolchains built using the Crosstool-NG backend, but only (e)glibc toolchains. This feature was runtime tested with internal uClibc toolchain, CodeSourcery ARM toolchain and Linaro ARM toolchain, thanks to a simple C program that shows the data and a gettext translated message. Note that this option differs from the "purge locales" option, which is responsible for removing translation files and other locale stuff installed by packages. At some point in the future, we may want to clarify the respective roles of those options. Signed-off-by: Thomas Petazzoni Signed-off-by: Peter Korsgaard --- Makefile | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'Makefile') diff --git a/Makefile b/Makefile index a7625ba0e..1d7973e96 100644 --- a/Makefile +++ b/Makefile @@ -239,6 +239,9 @@ TAR_OPTIONS=$(call qstrip,$(BR2_TAR_OPTIONS)) -xf # packages compiled for the host go here HOST_DIR:=$(call qstrip,$(BR2_HOST_DIR)) +# locales to generate +GENERATE_LOCALE=$(call qstrip,$(BR2_GENERATE_LOCALE)) + # stamp (dependency) files go here STAMP_DIR:=$(BASE_DIR)/stamps @@ -296,6 +299,12 @@ ifeq ($(BR2_ENABLE_LOCALE_PURGE),y) TARGETS+=target-purgelocales endif +ifneq ($(BR2_TOOLCHAIN_EXTERNAL_GLIBC)$(BR2_TOOLCHAIN_CTNG_eglibc)$(BR2_TOOLCHAIN_CTNG_glibc),) +ifneq ($(GENERATE_LOCALE),) +TARGETS+=target-generatelocales +endif +endif + include fs/common.mk TARGETS_CLEAN:=$(patsubst %,%-clean,$(TARGETS)) @@ -446,6 +455,30 @@ target-purgelocales: done endif +ifneq ($(GENERATE_LOCALE),) +# Generate locale data. Basically, we call the localedef program +# (built by the host-localedef package) for each locale. The input +# data comes preferably from the toolchain, or if the toolchain does +# not have them (Linaro toolchains), we use the ones available on the +# host machine. +target-generatelocales: host-localedef + $(Q)mkdir -p $(TARGET_DIR)/usr/lib/locale/ + $(Q)for locale in $(GENERATE_LOCALE) ; do \ + inputfile=`echo $${locale} | cut -f1 -d'.'` ; \ + charmap=`echo $${locale} | cut -f2 -d'.'` ; \ + if test -z "$${charmap}" ; then \ + charmap="UTF-8" ; \ + fi ; \ + echo "Generating locale $${inputfile}.$${charmap}" ; \ + I18NPATH=$(STAGING_DIR)/usr/share/i18n:/usr/share/i18n \ + $(HOST_DIR)/usr/bin/localedef \ + --prefix=$(TARGET_DIR) \ + --`echo $(BR2_ENDIAN) | tr [A-Z] [a-z]`-endian \ + -i $${inputfile} -f $${charmap} \ + $${locale} ; \ + done +endif + source: dirs $(TARGETS_SOURCE) $(HOST_SOURCE) external-deps: -- cgit v1.2.3