3 # Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
5 # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
8 # command used to download source code
9 WGET := wget --passive-ftp
11 LOCALE_DATA_FILENAME := uClibc-locale-030818.tgz
13 BUILD_CFLAGS-locale-common := \
14 -D__UCLIBC_GEN_LOCALE \
15 -DUCLIBC_CTYPE_HEADER='"$(top_builddir)include/bits/uClibc_ctype.h"'
17 BUILD_CFLAGS-gen_wc8bit := $(BUILD_CFLAGS-locale-common) -DCTYPE_PACKED=1
19 BUILD_CFLAGS-gen_wctype := $(BUILD_CFLAGS-locale-common)
21 BUILD_CFLAGS-gen_ldc :=
22 ifeq ($(UCLIBC_HAS_WCHAR),y)
23 BUILD_CFLAGS-gen_wc8bit += -DDO_WIDE_CHAR=1
24 BUILD_CFLAGS-gen_ldc += -D__WCHAR_ENABLED=1
27 BUILD_CFLAGS-gen_locale := -D_GNU_SOURCE
29 DEPH-locale := $(top_builddir)include/bits/sysnum.h
30 DEPH-gen_locale := c8tables.h
31 DEPH-gen_ldc := c8tables.h wctables.h locale_tables.h locale_collate.h
33 locale_DIR := $(top_srcdir)extra/locale
34 locale_OUT := $(top_builddir)extra/locale
36 #locale_HOBJ := gen_collate gen_ldc gen_locale gen_wc8bit gen_wctype
37 locale_HOBJ := gen_collate gen_wc8bit gen_wctype
38 locale_HOBJ := $(patsubst %,$(locale_OUT)/%,$(locale_HOBJ))
40 locale_SRC := $(locale_OUT)/locale_data.c
41 locale_OBJ := $(locale_OUT)/locale_data.o
43 CFLAGS-locale_data.c := -D__WCHAR_ENABLED -I$(locale_OUT) -I$(locale_DIR)
46 #headers-$(UCLIBC_HAS_LOCALE) += locale_headers
48 libc-$(UCLIBC_HAS_LOCALE) += $(locale_OBJ)
50 libc-nomulti-$(UCLIBC_HAS_LOCALE) += $(locale_OBJ)
52 locale_headers: $(top_builddir)include/bits/uClibc_locale_data.h
54 # make sure that the host system has locales (this check is ok for uClibc/glibc)
55 # we do not know though which locales were really enabled for libc at build time
56 ifeq ($(wildcard /usr/include/iconv.h),)
58 $(locale_OUT)/codesets.txt:
59 @if [ ! -f $@ ] ; then \
62 echo "You do not have a codesets.txt file. Please create this "; \
63 echo "file in the $(locale_OUT) directory by running something like: "; \
64 echo -e " find $(locale_DIR)/charmaps -name \"*.pairs\" > \\"; \
66 echo "and then edit that file to disable/enable the codesets you wish to support. "; \
71 $(locale_OUT)/locales.txt:
72 @if [ ! -f $@ ] ; then \
75 echo "You do not have a locales.txt file in the $(locale_OUT) "; \
76 echo "directory, Please copy the LOCALES file to locales.txt by "; \
77 echo "running something like: "; \
78 echo " cp $(locale_DIR)/LOCALES \\ "; \
80 echo "then edit locales.txt to disable/enable the locales you wish "; \
81 echo "to support. "; \
88 $(locale_OUT)/codesets.txt:
89 ifeq ($(UCLIBC_BUILD_MINIMAL_LOCALE),y)
90 echo "$(locale_DIR)/charmaps/ASCII.pairs" > $@ ; \
91 echo "$(locale_DIR)/charmaps/ISO-8859-1.pairs" >> $@
93 find $(locale_DIR)/charmaps -name '*.pairs' | sort > $@
96 # the lines beginning w/ '#-' are mandatory
97 # at least one conversion is needed (euro/cyrillic)
98 $(locale_OUT)/locales.txt: $(locale_DIR)/LOCALES
99 ifeq ($(UCLIBC_BUILD_MINIMAL_LOCALE),y)
100 echo "@euro e" > $@ ; \
102 echo "UTF-8 yes" >> $@ ; \
103 echo "8-BIT yes" >> $@ ; \
105 echo "en_US.UTF-8 UTF-8" >> $@ ; \
106 echo "en_US ISO-8859-1" >> $@
113 $(locale_HOBJ): $(locale_OUT)/% : $(locale_DIR)/%.c | $(DEPH-locale)
116 $(locale_OUT)/gen_locale : $(locale_DIR)/gen_locale.c | $(DEPH-locale) $(patsubst %,$(locale_OUT)/%,$(DEPH-gen_locale))
119 $(locale_OUT)/gen_ldc : $(locale_DIR)/gen_ldc.c | $(DEPH-locale) $(patsubst %,$(locale_OUT)/%,$(DEPH-gen_ldc))
122 # code needs to be modified to support top_builddir in almost all apps that write directly to a file
124 $(locale_OUT)/c8tables.h: $(locale_OUT)/gen_wc8bit $(locale_OUT)/codesets.txt
125 $< `cat $(word 2,$^)`
127 # Warning! Beware tr_TR toupper/tolower exceptions!
128 $(locale_OUT)/wctables.h: $(locale_OUT)/gen_wctype
131 $(locale_OUT)/locale_tables.h: $(locale_OUT)/gen_locale $(locale_OUT)/locales.txt
134 $(locale_OUT)/lt_defines.h: $(locale_OUT)/locale_tables.h $(locale_OUT)/locale_collate.h
135 grep "^#define" $< > $@
136 grep "^#define __lc" $(word 2,$^) >> $@
138 $(locale_OUT)/locale_collate.h: $(locale_OUT)/gen_collate $(locale_OUT)/locale_tables.h
139 grep COL_IDX_ $(word 2,$^) | sed -e "s/^.*COL_IDX_\([^, ]*\).*$$/\1/" | \
140 sort | uniq | xargs $<
142 $(locale_OUT)/$(LOCALE_DATA_FILENAME):
143 ifeq ($(UCLIBC_DOWNLOAD_PREGENERATED_LOCALE_DATA),y)
144 ( cd $(dir $@); $(WGET) http://www.uclibc.org/downloads/$(notdir $@) )
147 ifeq ($(UCLIBC_PREGENERATED_LOCALE_DATA),y)
149 $(locale_SRC): $(locale_OUT)/$(LOCALE_DATA_FILENAME)
150 zcat $< | tar -xv -C $(dir $@) -f -
152 # we use the one in locale_DIR
153 #$(RM) $(locale_OUT)/locale_mmap.h
155 # for arch specific versions we have to at least overwrite lt_defines.h/locale_data.c/uClibc_locale_data.h
157 $(locale_OUT)/uClibc_locale_data.h: $(locale_SRC)
161 $(locale_SRC): $(locale_OUT)/gen_ldc
164 $(locale_OUT)/uClibc_locale_data.h: $(locale_OUT)/lt_defines.h $(locale_OUT)/c8tables.h $(locale_OUT)/wctables.h $(locale_DIR)/locale_mmap.h | $(locale_SRC)
165 grep -v "define __LC" $< > $@
166 cat $(wordlist 2,4,$^) >> $@
170 $(top_builddir)include/bits/uClibc_locale_data.h: $(locale_OUT)/uClibc_locale_data.h | $(top_builddir)include/bits/uClibc_config.h
171 cat $< | awk 'BEGIN{i=1}{ if ( /WANT_/ ) i = /endif/ ; else if (i) print $0 }' > $@
173 objclean-y += locale_clean
175 # lmmtolso.c/gen_mmap.c/tst-*.c not used
177 $(RM) $(locale_HOBJ) $(locale_SRC) $(locale_OUT)/{*.{o,os,txt},gen_locale,gen_ldc}
178 $(RM) $(locale_OUT)/{uClibc_locale_data,lt_defines,c8tables,wctables,locale_tables,locale_collate}.h
179 $(RM) $(locale_OUT)/{lmmtolso,gen_mmap,locale.mmap}