OSDN Git Service

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