OSDN Git Service

8fe2528759819504e967339f3901f97902cbd8e7
[uclinux-h8/uClibc.git] / extra / locale / Makefile
1
2 TOPDIR = ../../
3 EXTRA_LOCALE_DIR:=${shell cd $(TOPDIR)/extra/locale && pwd}
4 include $(TOPDIR)Rules.mak
5
6 CFLAGS_wc8bit=-DCTYPE_PACKED=1
7 CFLAGS_mmap=
8 ifeq ($(strip $(UCLIBC_HAS_WCHAR)),y)
9     CFLAGS_wc8bit += -DDO_WIDE_CHAR=1
10     CFLAGS_mmap += -D__WCHAR_ENABLED=1
11 endif
12
13 all: links-target
14
15 codesets.txt:
16         @if [ ! -f codesets.txt ] ; then \
17             set -e; \
18             echo " "; \
19             echo "You do not have a codesets.txt file.  Please create this "; \
20             echo "file in the extra/locale directory by running something like: "; \
21             echo -e "  find $(EXTRA_LOCALE_DIR)/charmaps -name \"*.pairs\" > \\"; \
22             echo -e "        $(EXTRA_LOCALE_DIR)/codesets.txt"; \
23             echo "and then edit that file to disable/enable the codesets you wish to support. "; \
24             echo " "; \
25             false; \
26         fi;
27
28 gen_wc8bit: gen_wc8bit.c
29         $(HOSTCC) $(HOSTCFLAGS) $(NATIVE_LDFLAGS) $(CFLAGS_wc8bit) -D__UCLIBC_GEN_LOCALE $^ -o $@
30
31 c8tables.h: gen_wc8bit codesets.txt
32         ./gen_wc8bit `cat codesets.txt`
33
34 gen_wctype: gen_wctype.c
35         $(HOSTCC) $(HOSTCFLAGS) $(NATIVE_LDFLAGS) -D__UCLIBC_GEN_LOCALE $^ -o $@
36
37 # Warning! Beware tr_TR toupper/tolower exceptions!
38 wctables.h: gen_wctype
39         ./gen_wctype en_US
40
41 gen_locale: gen_locale.c c8tables.h
42         $(HOSTCC) $(HOSTCFLAGS) $(NATIVE_LDFLAGS) gen_locale.c -o $@
43
44 locale_tables.h: gen_locale locales.txt
45         ./gen_locale locales.txt
46
47 lt_defines.h: locale_tables.h locale_collate.h
48         grep "^#define" locale_tables.h > lt_defines.h
49         grep "^#define __lc" locale_collate.h >> lt_defines.h
50
51 gen_collate: gen_collate.c
52         $(HOSTCC) $(HOSTCFLAGS) $(NATIVE_LDFLAGS) gen_collate.c -o $@
53
54 locale_collate.h: gen_collate locale_tables.h
55         grep COL_IDX_ locale_tables.h | sed -e "s/^.*COL_IDX_\([^, ]*\).*$$/\1/" | sort | uniq | xargs ./gen_collate
56
57 locales.txt:
58         @if [ ! -f locales.txt ] ; then \
59             set -e; \
60             echo " "; \
61             echo "You do not have a locales.txt file in the extra/locale "; \
62             echo "directory, Please copy the LOCALES file to locales.txt by "; \
63             echo "running something like: "; \
64             echo "  cp $(EXTRA_LOCALE_DIR)/LOCALES \\ "; \
65             echo "      $(EXTRA_LOCALE_DIR)/locales.txt "; \
66             echo "then edit locales.txt to disable/enable the locales you wish "; \
67             echo "to support. "; \
68             echo " "; \
69             false; \
70         fi;
71
72 gen_ldc: gen_ldc.c c8tables.h wctables.h locale_tables.h locale_collate.h
73         $(HOSTCC) $(HOSTCFLAGS) $(NATIVE_LDFLAGS) $(CFLAGS_mmap) gen_ldc.c -o $@
74
75 locale_data.c: gen_ldc
76         ./gen_ldc
77
78 uClibc_locale_data.h: c8tables.h wctables.h lt_defines.h locale_mmap.h
79         grep -v "define __LC" lt_defines.h > uClibc_locale_data.h
80         cat c8tables.h wctables.h locale_mmap.h >> uClibc_locale_data.h
81
82 links-target: locale_data.c uClibc_locale_data.h
83         cat uClibc_locale_data.h | awk 'BEGIN{i=1}{ if ( /WANT_/ ) i = /endif/ ; else if (i) print $0 }' > ../../include/bits/uClibc_locale_data.h
84
85 pregen:
86         cat uClibc_locale_data.h | awk 'BEGIN{i=1}{ if ( /WANT_/ ) i = /endif/ ; else if (i) print $0 }' > ../../include/bits/uClibc_locale_data.h
87
88 clean:
89         $(RM) *.o *~ core
90         $(RM) gen_wc8bit gen_wctype gen_locale gen_ldc gen_collate
91         $(RM) c8tables.h wctables.h locale_tables.h lt_defines.h locale_collate.h
92         $(RM) gen_mmap locale.mmap lmmtolso
93         $(RM) locale_data.c uClibc_locale_data.h
94
95 .PHONY: pregen links-target