summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile33
-rw-r--r--toolchain/toolchain-common.in18
-rw-r--r--toolchain/uClibc/uclibc.mk11
3 files changed, 61 insertions, 1 deletions
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:
diff --git a/toolchain/toolchain-common.in b/toolchain/toolchain-common.in
index fb87a888e..cc7b4de56 100644
--- a/toolchain/toolchain-common.in
+++ b/toolchain/toolchain-common.in
@@ -58,6 +58,24 @@ config BR2_ENABLE_LOCALE_WHITELIST
will be available on the target - That purely depends on the
support for that locale in the selected packages.
+config BR2_GENERATE_LOCALE
+ string "Generate locale data"
+ default ""
+ # Pre-built uClibc external toolchains and uClibc toolchains
+ # built by the Crosstool-NG backend cannot be supported,
+ # because the list of locales to support must be defined at
+ # build time.
+ depends on \
+ BR2_TOOLCHAIN_BUILDROOT || \
+ BR2_TOOLCHAIN_EXTERNAL_GLIBC || \
+ BR2_TOOLCHAIN_CTNG_eglibc || \
+ BR2_TOOLCHAIN_CTNG_glibc
+ help
+ Generate support for a list of locales. Locales can be
+ specified with or without encoding, when no encoding is
+ specified, UTF-8 is assumed. Examples of locales: en_US,
+ fr_FR.UTF-8.
+
# glibc and eglibc directly include gettext, so a separatly compiled
# gettext isn't needed and shouldn't be built to avoid conflicts. Some
# packages always need gettext, other packages only need gettext when
diff --git a/toolchain/uClibc/uclibc.mk b/toolchain/uClibc/uclibc.mk
index 32cbe4605..07281351b 100644
--- a/toolchain/uClibc/uclibc.mk
+++ b/toolchain/uClibc/uclibc.mk
@@ -66,6 +66,15 @@ endif
UCLIBC_ARM_TYPE:=CONFIG_$(call qstrip,$(BR2_ARM_TYPE))
UCLIBC_SPARC_TYPE:=CONFIG_SPARC_$(call qstrip,$(BR2_SPARC_TYPE))
+ifeq ($(GENERATE_LOCALE),)
+# We need at least one locale
+UCLIBC_LOCALES = en_US
+else
+# Strip out the encoding part of locale names, if any
+UCLIBC_LOCALES = $(foreach locale,$(GENERATE_LOCALE),\
+ $(firstword $(subst .,$(space),$(locale))))
+endif
+
$(DL_DIR)/$(UCLIBC_SOURCE):
$(call DOWNLOAD,$(UCLIBC_SITE)/$(UCLIBC_SOURCE))
@@ -309,7 +318,7 @@ else
echo "# PTHREADS_DEBUG_SUPPORT is not set" >> $(UCLIBC_DIR)/.oldconfig
endif
ifeq ($(BR2_ENABLE_LOCALE),y)
- $(SED) 's,^.*UCLIBC_HAS_LOCALE.*,UCLIBC_HAS_LOCALE=y\n# UCLIBC_BUILD_ALL_LOCALE is not set\nUCLIBC_BUILD_MINIMAL_LOCALE=y\nUCLIBC_BUILD_MINIMAL_LOCALES="en_US"\nUCLIBC_PREGENERATED_LOCALE_DATA=n\nUCLIBC_DOWNLOAD_PREGENERATED_LOCALE_DATA=n\nUCLIBC_HAS_XLOCALE=y\nUCLIBC_HAS_GLIBC_DIGIT_GROUPING=n\n,g' $(UCLIBC_DIR)/.oldconfig
+ $(SED) 's,^.*UCLIBC_HAS_LOCALE.*,UCLIBC_HAS_LOCALE=y\n# UCLIBC_BUILD_ALL_LOCALE is not set\nUCLIBC_BUILD_MINIMAL_LOCALE=y\nUCLIBC_BUILD_MINIMAL_LOCALES="$(UCLIBC_LOCALES)"\nUCLIBC_PREGENERATED_LOCALE_DATA=n\nUCLIBC_DOWNLOAD_PREGENERATED_LOCALE_DATA=n\nUCLIBC_HAS_XLOCALE=y\nUCLIBC_HAS_GLIBC_DIGIT_GROUPING=n\n,g' $(UCLIBC_DIR)/.oldconfig
else
$(SED) 's,^.*UCLIBC_HAS_LOCALE.*,UCLIBC_HAS_LOCALE=n,g' $(UCLIBC_DIR)/.oldconfig
endif