]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/uclibc/lib/contrib/uclibc/extra/locale/Makefile.in
8bda8d8aae078dc3dbb07bbbe04a367084c2b507
[l4.git] / l4 / pkg / uclibc / lib / contrib / uclibc / 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)for locale in $(call qstrip,$(UCLIBC_BUILD_MINIMAL_LOCALES)); do \
137                 echo "$$locale.UTF-8 UTF-8"; \
138                 echo "$$locale ISO-8859-1"; \
139         done >> $@
140 else
141         $(Q)cat $< > $@
142 endif
143
144 endif
145
146 $(locale_DIR)/gen_collate.c: $(DEPH-gen_collate)
147 $(locale_OUT)/gen_collate : $(locale_DIR)/gen_collate.c
148         $(hcompile.u)
149 $(locale_DIR)/gen_ldc.c: $(DEPH-gen_ldc)
150 $(locale_OUT)/gen_ldc : $(locale_DIR)/gen_ldc.c
151         $(hcompile.u)
152 $(locale_DIR)/gen_locale.c: $(DEPH-gen_locale)
153 $(locale_OUT)/gen_locale : $(locale_DIR)/gen_locale.c
154         $(hcompile.u)
155 $(locale_DIR)/gen_wc8bit.c: $(DEPH-gen_wc8bit)
156 $(locale_OUT)/gen_wc8bit : $(locale_DIR)/gen_wc8bit.c
157         $(hcompile.u)
158 $(locale_DIR)/gen_wctype.c: $(DEPH-gen_wctype)
159 $(locale_OUT)/gen_wctype : $(locale_DIR)/gen_wctype.c
160         $(hcompile.u)
161
162 ifneq ($(V),)
163 ifeq ($(V),1)
164 FLAG-locale-verbose := -v
165 endif
166 ifeq ($(V),2)
167 FLAG-locale-verbose := -v -v
168 endif
169 endif
170
171 # code needs to be modified to support top_builddir in almost all apps that write directly to a file
172 # grep fopen *.c
173 $(locale_OUT)/c8tables.h: $(locale_OUT)/gen_wc8bit $(locale_OUT)/codesets.txt
174         @$(disp_gen)
175         $(Q)$< `cat $(word 2,$^)` > $@
176
177 # Warning! Beware tr_TR toupper/tolower exceptions!
178 $(locale_OUT)/wctables.h: $(locale_OUT)/gen_wctype
179         @$(disp_gen)
180         $(Q)for locale in $(call qstrip,$(UCLIBC_BUILD_MINIMAL_LOCALES)) en_US en_GB; do \
181                 $< $(FLAG-locale-verbose) $$locale > $@ || \
182                 $< $(FLAG-locale-verbose) $$locale.UTF-8 > $@ || \
183                 $< $(FLAG-locale-verbose) $$locale.iso8859-1 > $@ && break; \
184         done
185
186 $(locale_OUT)/locale_tables.h: $(locale_OUT)/gen_locale $(locale_OUT)/locales.txt
187         @$(disp_gen)
188         $(Q)$< $(FLAG-locale-verbose) -o $@ $(word 2,$^)
189
190 $(locale_OUT)/lt_defines.h: $(locale_OUT)/locale_tables.h $(locale_OUT)/locale_collate.h
191         @$(disp_gen)
192         $(Q)grep "^#define" $< > $@
193         $(Q)grep "^#define __lc" $(word 2,$^) >> $@
194
195 $(locale_OUT)/locale_collate.h: $(locale_OUT)/gen_collate $(locale_OUT)/locale_tables.h
196         @$(disp_gen)
197         $(Q)grep COL_IDX_ $(word 2,$^) | \
198                 $(SED) -e "s/^.*COL_IDX_\([^, ]*\).*$$/\1/" | sort | uniq | \
199                 xargs $< $(locale_DIR)/collation $(FLAG-locale-verbose) -o $@
200
201 $(locale_OUT)/$(LOCALE_DATA_FILENAME):
202 ifeq ($(UCLIBC_DOWNLOAD_PREGENERATED_LOCALE_DATA),y)
203         ( cd $(@D); $(WGET) http://www.uclibc.org/downloads/$(@F) )
204 endif
205
206 ifeq ($(UCLIBC_PREGENERATED_LOCALE_DATA),y)
207
208 $(locale_SRC): $(locale_OUT)/$(LOCALE_DATA_FILENAME)
209         zcat $< | $(TAR) -xv -C $(@D) -f -
210         touch $@
211         # we use the one in locale_DIR
212         #$(RM) $(locale_OUT)/locale_mmap.h
213
214 # for arch specific versions we have to at least overwrite
215 # lt_defines.h/locale_data.c/uClibc_locale_data.h
216
217 $(locale_OUT)/uClibc_locale_data.h: $(locale_SRC)
218
219 else
220
221 $(locale_SRC): $(locale_OUT)/gen_ldc $(locale_OUT)/lt_defines.h
222         @$(disp_gen)
223         $(Q)$< $@
224
225 $(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)
226         @$(disp_gen)
227         $(Q)grep -v "define __LC" $< > $@
228         $(Q)cat $(wordlist 2,4,$^) >> $@
229
230 endif
231
232 $(top_builddir)include/bits/uClibc_locale_data.h: $(locale_OUT)/uClibc_locale_data.h | $(top_builddir)include/bits/uClibc_config.h
233         @$(disp_gen)
234         $(Q)$(AWK) 'BEGIN{i=1}{if (/WANT_/) i=/endif/;else if (i) print $0}' \
235                 $< > $@
236
237 objclean-y += locale_clean
238
239 # lmmtolso.c/gen_mmap.c/tst-*.c not used
240 locale_clean:
241         $(do_rm) $(locale_HOBJ) $(locale_SRC) $(addprefix $(locale_OUT)/*., o os txt) \
242                 $(addprefix $(locale_OUT)/,$(addsuffix .h,uClibc_locale_data lt_defines c8tables wctables locale_tables locale_collate) lmmtolso gen_mmap locale.mmap)