1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
|
# Makefile for uClibc
#
# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
locale_DIR := $(top_srcdir)extra/locale
locale_OUT := $(top_builddir)extra/locale
# command used to download source code
WGET := wget --passive-ftp
LOCALE_DATA_FILENAME := uClibc-locale-030818.tgz
BUILD_CFLAGS-locale-common := \
-D__UCLIBC_GEN_LOCALE \
-I$(top_builddir) \
-DUCLIBC_CTYPE_HEADER='"include/bits/uClibc_ctype.h"'
BUILD_CFLAGS-gen_wc8bit := $(BUILD_CFLAGS-locale-common) -DCTYPE_PACKED=1
BUILD_CFLAGS-gen_wctype := $(BUILD_CFLAGS-locale-common)
BUILD_CFLAGS-gen_ldc :=
ifeq ($(UCLIBC_HAS_WCHAR),y)
BUILD_CFLAGS-gen_wc8bit += -DDO_WIDE_CHAR=1
BUILD_CFLAGS-gen_ldc += -D__WCHAR_ENABLED=1
endif
BUILD_CFLAGS-gen_locale := -D_GNU_SOURCE -I$(locale_OUT)
BUILD_CFLAGS-gen_collate := -D_GNU_SOURCE
DEPH-locale := $(top_builddir)include/bits/sysnum.h
DEPH-gen_locale := $(addprefix $(locale_OUT)/,c8tables.h) $(DEPH-locale)
DEPH-gen_ldc := $(addprefix $(locale_OUT)/,c8tables.h wctables.h locale_tables.h locale_collate.h) $(DEPH-locale)
DEPH-gen_wc8bit := $(top_builddir)/include/bits/uClibc_ctype.h $(DEPH-locale)
DEPH-gen_wctype := $(top_builddir)/include/bits/uClibc_ctype.h $(DEPH-locale)
DEPH-gen_collate := $(DEPH-locale)
locale_HOBJ := gen_collate gen_ldc gen_locale gen_wc8bit gen_wctype
locale_HOBJ := $(addprefix $(locale_OUT)/,$(locale_HOBJ))
locale_SRC := $(locale_OUT)/locale_data.c
locale_OBJ := $(locale_OUT)/locale_data.o
CFLAGS-locale_data.c := -D__WCHAR_ENABLED -I$(locale_OUT) -I$(locale_DIR)
headers-$(UCLIBC_HAS_LOCALE) += $(top_builddir)include/bits/uClibc_locale_data.h
libc-$(UCLIBC_HAS_LOCALE) += $(locale_OBJ)
libc-nomulti-$(UCLIBC_HAS_LOCALE) += $(locale_OBJ)
locale_headers: $(top_builddir)include/bits/uClibc_locale_data.h
# make sure that the host system has locales (this check is ok for uClibc/glibc)
# we do not know though which locales were really enabled for libc at build time
ifeq ($(wildcard /usr/include/iconv.h),)
$(locale_OUT)/codesets.txt:
@if [ ! -f $@ ] ; then \
set -e; \
echo " "; \
echo "You do not have a codesets.txt file. Please create this "; \
echo "file in the $(locale_OUT) directory by running something like: "; \
echo " cd $(locale_DIR) && find charmaps -name \"*.pairs\" > \\"; \
echo " $@"; \
echo "and then edit that file to disable/enable the codesets you wish to support. "; \
echo " "; \
false; \
fi;
$(locale_OUT)/locales.txt:
@if [ ! -f $@ ] ; then \
set -e; \
echo " "; \
echo "You do not have a locales.txt file in the $(locale_OUT) "; \
echo "directory, Please copy the LOCALES file to locales.txt by "; \
echo "running something like: "; \
echo " cp $(locale_DIR)/LOCALES \\ "; \
echo " $@ "; \
echo "then edit locales.txt to disable/enable the locales you wish "; \
echo "to support. "; \
echo " "; \
false; \
fi;
else
$(locale_OUT)/codesets.txt:
ifeq ($(UCLIBC_BUILD_MINIMAL_LOCALE),y)
echo "charmaps/ASCII.pairs" > $@ ; \
echo "charmaps/ISO-8859-1.pairs" >> $@
else
(cd $(locale_DIR)/ && find charmaps/ -name '*.pairs' | sort ) > $@
endif
# the lines beginning w/ '#-' are mandatory
# at least one conversion is needed (euro/cyrillic)
$(locale_OUT)/locales.txt: $(locale_DIR)/LOCALES
ifeq ($(UCLIBC_BUILD_MINIMAL_LOCALE),y)
echo "@euro e" > $@ ; \
echo "#-" >> $@ ; \
echo "UTF-8 yes" >> $@ ; \
echo "8-BIT yes" >> $@ ; \
echo "#-" >> $@ ; \
echo "en_US.UTF-8 UTF-8" >> $@ ; \
echo "en_US ISO-8859-1" >> $@
else
cp $< $@
endif
endif
$(locale_OUT)/gen_collate : $(locale_DIR)/gen_collate.c | $(DEPH-gen_collate)
$(hcompile.u)
$(locale_OUT)/gen_ldc : $(locale_DIR)/gen_ldc.c | $(DEPH-gen_ldc)
$(hcompile.u)
$(locale_OUT)/gen_locale : $(locale_DIR)/gen_locale.c | $(DEPH-gen_locale)
$(hcompile.u)
$(locale_OUT)/gen_wc8bit : $(locale_DIR)/gen_wc8bit.c | $(DEPH-gen_wc8bit)
$(hcompile.u)
$(locale_OUT)/gen_wctype : $(locale_DIR)/gen_wctype.c | $(DEPH-gen_wctype)
$(hcompile.u)
# code needs to be modified to support top_builddir in almost all apps that write directly to a file
# grep fopen *.c
$(locale_OUT)/c8tables.h: $(locale_OUT)/gen_wc8bit $(locale_OUT)/codesets.txt
(cd $(<D) && ./$(<F) `cat $(word 2,$(^F))`)
# Warning! Beware tr_TR toupper/tolower exceptions!
$(locale_OUT)/wctables.h: $(locale_OUT)/gen_wctype
(cd $(<D) ; ./$(<F) en_US || ./$(<F) en_US.UTF-8 \
|| ./$(<F) en_US.iso8859-1 \
|| ./$(<F) en_GB || ./$(<F) en_GB.UTF-8)
$(locale_OUT)/locale_tables.h: $(locale_OUT)/gen_locale $(locale_OUT)/locales.txt
$< $(word 2,$^) $@
$(locale_OUT)/lt_defines.h: $(locale_OUT)/locale_tables.h $(locale_OUT)/locale_collate.h
grep "^#define" $< > $@
grep "^#define __lc" $(word 2,$^) >> $@
$(locale_OUT)/locale_collate.h: $(locale_OUT)/gen_collate $(locale_OUT)/locale_tables.h
grep COL_IDX_ $(word 2,$^) | $(SED) -e "s/^.*COL_IDX_\([^, ]*\).*$$/\1/" | \
sort | uniq | (cd $(<D) && xargs ./$(<F))
$(locale_OUT)/$(LOCALE_DATA_FILENAME):
ifeq ($(UCLIBC_DOWNLOAD_PREGENERATED_LOCALE_DATA),y)
( cd $(dir $@); $(WGET) http://www.uclibc.org/downloads/$(notdir $@) )
endif
ifeq ($(UCLIBC_PREGENERATED_LOCALE_DATA),y)
$(locale_SRC): $(locale_OUT)/$(LOCALE_DATA_FILENAME)
zcat $< | $(TAR) -xv -C $(dir $@) -f -
touch $@
# we use the one in locale_DIR
#$(RM) $(locale_OUT)/locale_mmap.h
# for arch specific versions we have to at least overwrite lt_defines.h/locale_data.c/uClibc_locale_data.h
$(locale_OUT)/uClibc_locale_data.h: $(locale_SRC)
else
$(locale_SRC): $(locale_OUT)/gen_ldc $(locale_OUT)/lt_defines.h
$< $@
$(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)
grep -v "define __LC" $< > $@
cat $(wordlist 2,4,$^) >> $@
endif
$(top_builddir)include/bits/uClibc_locale_data.h: $(locale_OUT)/uClibc_locale_data.h | $(top_builddir)include/bits/uClibc_config.h
cat $< | $(AWK) 'BEGIN{i=1}{ if ( /WANT_/ ) i = /endif/ ; else if (i) print $0 }' > $@
objclean-y += locale_clean
# lmmtolso.c/gen_mmap.c/tst-*.c not used
locale_clean:
$(RM) $(locale_HOBJ) $(locale_SRC) $(locale_OUT)/*.{o,os,txt}
$(RM) $(locale_OUT)/{uClibc_locale_data,lt_defines,c8tables,wctables,locale_tables,locale_collate}.h
$(RM) $(locale_OUT)/{lmmtolso,gen_mmap,locale.mmap}
|