OSDN Git Service

52de0f26e276a33a804f51473a181f695f3e97df
[uclinux-h8/uClibc.git] / extra / locale / Makefile.in
1 # Makefile for uClibc
2 #
3 # Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
4 #
5 # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
6 #
7
8 # command used to download source code
9 WGET := wget --passive-ftp
10
11 LOCALE_DATA_FILENAME := uClibc-locale-030818.tgz
12
13 BUILD_CFLAGS-locale-common := \
14         -D__UCLIBC_GEN_LOCALE \
15         -DUCLIBC_CTYPE_HEADER='"$(top_builddir)include/bits/uClibc_ctype.h"'
16
17 BUILD_CFLAGS-gen_wc8bit := $(BUILD_CFLAGS-locale-common) -DCTYPE_PACKED=1
18
19 BUILD_CFLAGS-gen_wctype := $(BUILD_CFLAGS-locale-common)
20
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
25 endif
26
27 BUILD_CFLAGS-gen_locale := -D_GNU_SOURCE
28
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
32
33 locale_DIR := $(top_srcdir)extra/locale
34 locale_OUT := $(top_builddir)extra/locale
35
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))
39
40 locale_SRC := $(locale_OUT)/locale_data.c
41 locale_OBJ := $(locale_OUT)/locale_data.o
42
43 CFLAGS-locale_data.c := -D__WCHAR_ENABLED -I$(locale_OUT) -I$(locale_DIR)
44
45 # produces a loop
46 #headers-$(UCLIBC_HAS_LOCALE) += locale_headers
47
48 libc-$(UCLIBC_HAS_LOCALE) += $(locale_OBJ)
49
50 libc-nomulti-$(UCLIBC_HAS_LOCALE) += $(locale_OBJ)
51
52 locale_headers: $(top_builddir)include/bits/uClibc_locale_data.h
53
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),)
57
58 $(locale_OUT)/codesets.txt:
59         @if [ ! -f $@ ] ; then \
60             set -e; \
61             echo " "; \
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\" > \\"; \
65             echo -e "        $@"; \
66             echo "and then edit that file to disable/enable the codesets you wish to support. "; \
67             echo " "; \
68             false; \
69         fi;
70
71 $(locale_OUT)/locales.txt:
72         @if [ ! -f $@ ] ; then \
73             set -e; \
74             echo " "; \
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 \\ "; \
79             echo "      $@ "; \
80             echo "then edit locales.txt to disable/enable the locales you wish "; \
81             echo "to support. "; \
82             echo " "; \
83             false; \
84         fi;
85
86 else
87
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" >> $@
92 else
93         find $(locale_DIR)/charmaps -name '*.pairs' | sort > $@
94 endif
95
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" > $@ ; \
101         echo "#-" >> $@ ; \
102         echo "UTF-8 yes" >> $@ ; \
103         echo "8-BIT yes" >> $@ ; \
104         echo "#-" >> $@ ; \
105         echo "en_US.UTF-8 UTF-8" >> $@ ; \
106         echo "en_US ISO-8859-1" >> $@
107 else
108         cp $< $@
109 endif
110
111 endif
112
113 $(locale_HOBJ): $(locale_OUT)/% : $(locale_DIR)/%.c | $(DEPH-locale)
114         $(hcompile.u)
115
116 $(locale_OUT)/gen_locale : $(locale_DIR)/gen_locale.c | $(DEPH-locale) $(patsubst %,$(locale_OUT)/%,$(DEPH-gen_locale))
117         $(hcompile.u)
118
119 $(locale_OUT)/gen_ldc : $(locale_DIR)/gen_ldc.c | $(DEPH-locale) $(patsubst %,$(locale_OUT)/%,$(DEPH-gen_ldc))
120         $(hcompile.u)
121
122 # code needs to be modified to support top_builddir in almost all apps that write directly to a file
123 # grep fopen *.c
124 $(locale_OUT)/c8tables.h: $(locale_OUT)/gen_wc8bit $(locale_OUT)/codesets.txt
125         $< `cat $(word 2,$^)`
126
127 # Warning! Beware tr_TR toupper/tolower exceptions!
128 $(locale_OUT)/wctables.h: $(locale_OUT)/gen_wctype
129         $< en_US
130
131 $(locale_OUT)/locale_tables.h: $(locale_OUT)/gen_locale $(locale_OUT)/locales.txt
132         $< $(word 2,$^)
133
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,$^) >> $@
137
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 $<
141
142 $(locale_OUT)/$(LOCALE_DATA_FILENAME):
143 ifeq ($(UCLIBC_DOWNLOAD_PREGENERATED_LOCALE_DATA),y)
144         ( cd $(dir $@); $(WGET) http://www.uclibc.org/downloads/$(notdir $@) )
145 endif
146
147 ifeq ($(UCLIBC_PREGENERATED_LOCALE_DATA),y)
148
149 $(locale_SRC): $(locale_OUT)/$(LOCALE_DATA_FILENAME)
150         zcat $< | tar -xv -C $(dir $@) -f -
151         touch $@
152         # we use the one in locale_DIR
153         #$(RM) $(locale_OUT)/locale_mmap.h
154
155 # for arch specific versions we have to at least overwrite lt_defines.h/locale_data.c/uClibc_locale_data.h
156
157 $(locale_OUT)/uClibc_locale_data.h: $(locale_SRC)
158
159 else
160
161 $(locale_SRC): $(locale_OUT)/gen_ldc
162         $<
163
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,$^) >> $@
167
168 endif
169
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 }' > $@
172
173 objclean-y += locale_clean
174
175 # lmmtolso.c/gen_mmap.c/tst-*.c not used
176 locale_clean:
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}