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