Makefile.in 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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. locale_DIR := $(top_srcdir)extra/locale
  8. locale_OUT := $(top_builddir)extra/locale
  9. # command used to download source code
  10. WGET := wget --passive-ftp
  11. LOCALE_DATA_FILENAME := uClibc-locale-20081111-$(ARCH_NATIVE_BIT)-$(if $(ARCH_LITTLE_ENDIAN),el,eb).tgz
  12. BUILD_CFLAGS-locale-common := \
  13. -D__UCLIBC_GEN_LOCALE \
  14. -I$(top_builddir)
  15. BUILD_CFLAGS-gen_wc8bit := $(BUILD_CFLAGS-locale-common) -DCTYPE_PACKED=1
  16. BUILD_CFLAGS-gen_wctype := $(BUILD_CFLAGS-locale-common)
  17. BUILD_CFLAGS-gen_ldc := -I$(locale_OUT)
  18. ifeq ($(UCLIBC_HAS_WCHAR),y)
  19. BUILD_CFLAGS-gen_wc8bit += -DDO_WIDE_CHAR=1
  20. BUILD_CFLAGS-gen_ldc += -D__WCHAR_ENABLED=1
  21. endif
  22. BUILD_CFLAGS-gen_locale := -D_GNU_SOURCE -I$(locale_OUT)
  23. BUILD_CFLAGS-gen_collate := -D_GNU_SOURCE
  24. locale_headers-$(UCLIBC_HAS_LOCALE) := $(top_builddir)include/bits/uClibc_locale_data.h
  25. headers_dep += $(locale_headers-y)
  26. DEPH-locale := $(top_builddir)include/bits/uClibc_config.h
  27. DEPH-gen_collate := $(DEPH-locale)
  28. DEPH-gen_ldc := $(addprefix $(locale_OUT)/,c8tables.h wctables.h locale_tables.h locale_collate.h) $(DEPH-locale)
  29. DEPH-gen_locale := $(addprefix $(locale_OUT)/,c8tables.h) $(DEPH-locale)
  30. DEPH-gen_wc8bit := $(top_builddir)include/bits/uClibc_ctype.h $(DEPH-locale)
  31. DEPH-gen_wctype := $(top_builddir)include/bits/uClibc_ctype.h $(DEPH-locale)
  32. locale_HOBJ := gen_collate gen_ldc gen_locale gen_wc8bit gen_wctype
  33. locale_HOBJ := $(addprefix $(locale_OUT)/,$(locale_HOBJ))
  34. $(locale_HOBJ): | $(locale_OUT)
  35. locale_SRC := $(locale_OUT)/locale_data.c
  36. locale_OBJ := $(locale_OUT)/locale_data.o
  37. CFLAGS-locale_data.c := -D__WCHAR_ENABLED -I$(locale_OUT) -I$(locale_DIR)
  38. libc-$(UCLIBC_HAS_LOCALE) += $(locale_OBJ)
  39. libc-nomulti-$(UCLIBC_HAS_LOCALE) += $(locale_OBJ)
  40. $(locale_OUT)%.o: $(locale_OUT)%.c FORCE ; $(compile.c)
  41. $(locale_OUT)%.os: $(locale_OUT)%.c FORCE ; $(compile.c)
  42. $(locale_OUT)%.oS: $(locale_OUT)%.c FORCE ; $(compile.c)
  43. $(locale_OUT)%.o: $(locale_OUT)%.S FORCE ; $(compile.S)
  44. $(locale_OUT)%.os: $(locale_OUT)%.S FORCE ; $(compile.S)
  45. $(locale_OUT)%.oS: $(locale_OUT)%.S FORCE ; $(compile.S)
  46. $(locale_OUT)%.o: $(locale_OUT)%.s FORCE ; $(compile.S)
  47. $(locale_OUT)%.os: $(locale_OUT)%.s FORCE ; $(compile.S)
  48. $(locale_OUT)%.oS: $(locale_OUT)%.s FORCE ; $(compile.S)
  49. $(locale_OUT)%.i: $(locale_OUT)%.c FORCE ; $(compile.i)
  50. $(locale_OUT)%.i: $(locale_OUT)%.S FORCE ; $(compile.i)
  51. $(locale_OUT)%.s: $(locale_OUT)%.c FORCE ; $(compile.s)
  52. $(locale_OUT)%.s: $(locale_OUT)%.S FORCE ; $(compile.s)
  53. $(locale_OUT)%.dep:
  54. locale_headers: $(locale_headers-y)
  55. # make sure that the host system has locales (this check is ok for uClibc/glibc)
  56. # we do not know though which locales were really enabled for libc at build time
  57. ifeq ($(wildcard /usr/include/iconv.h),)
  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 " find $(CURDIR)/$(locale_DIR)/charmaps -name \"*.pairs\" > \\"; \
  65. echo " $@"; \
  66. echo "and then edit that file to disable/enable the codesets you wish to support. "; \
  67. echo " "; \
  68. false; \
  69. fi
  70. $(locale_OUT)/locales.txt:
  71. @if [ ! -f $@ ] ; then \
  72. set -e; \
  73. echo " "; \
  74. echo "You do not have a locales.txt file in the $(locale_OUT) "; \
  75. echo "directory, Please copy the LOCALES file to locales.txt by "; \
  76. echo "running something like: "; \
  77. echo " cp $(locale_DIR)/LOCALES \\ "; \
  78. echo " $@ "; \
  79. echo "then edit locales.txt to disable/enable the locales you wish "; \
  80. echo "to support. "; \
  81. echo " "; \
  82. false; \
  83. fi
  84. else
  85. $(locale_OUT)/codesets.txt:
  86. @$(disp_gen)
  87. ifeq ($(UCLIBC_BUILD_MINIMAL_LOCALE),y)
  88. $(Q)echo "$(CURDIR)/$(locale_DIR)/charmaps/ASCII.pairs" > $@
  89. $(Q)echo "$(CURDIR)/$(locale_DIR)/charmaps/ISO-8859-1.pairs" >> $@
  90. else
  91. $(Q)set -e; \
  92. find $(CURDIR)/$(locale_DIR)/charmaps/ -name '*.pairs' | \
  93. sort > $@.new; \
  94. [ -s $@.new ]; \
  95. cmp -s $@ $@.new && $(RM) $@.new || mv -f $@.new $@
  96. endif
  97. # the lines beginning w/ '#-' are mandatory
  98. # at least one conversion is needed (euro/cyrillic)
  99. $(locale_OUT)/locales.txt: $(locale_DIR)/LOCALES
  100. @$(disp_gen)
  101. ifeq ($(UCLIBC_BUILD_MINIMAL_LOCALE),y)
  102. $(Q)echo "@euro e" > $@
  103. $(Q)echo "#-" >> $@
  104. $(Q)echo "UTF-8 yes" >> $@
  105. $(Q)echo "8-BIT yes" >> $@
  106. $(Q)echo "#-" >> $@
  107. $(Q)for locale in $(call qstrip,$(UCLIBC_BUILD_MINIMAL_LOCALES)); do \
  108. echo "$$locale.UTF-8 UTF-8"; \
  109. echo "$$locale ISO-8859-1"; \
  110. done >> $@
  111. else
  112. $(Q)cat $< > $@
  113. endif
  114. endif
  115. $(locale_DIR)/gen_collate.c: $(DEPH-gen_collate)
  116. $(locale_OUT)/gen_collate : $(locale_DIR)/gen_collate.c
  117. $(hcompile.u)
  118. $(locale_DIR)/gen_ldc.c: $(DEPH-gen_ldc)
  119. $(locale_OUT)/gen_ldc : $(locale_DIR)/gen_ldc.c
  120. $(hcompile.u)
  121. $(locale_DIR)/gen_locale.c: $(DEPH-gen_locale)
  122. $(locale_OUT)/gen_locale : $(locale_DIR)/gen_locale.c
  123. $(hcompile.u)
  124. $(locale_DIR)/gen_wc8bit.c: $(DEPH-gen_wc8bit)
  125. $(locale_OUT)/gen_wc8bit : $(locale_DIR)/gen_wc8bit.c
  126. $(hcompile.u)
  127. $(locale_DIR)/gen_wctype.c: $(DEPH-gen_wctype)
  128. $(locale_OUT)/gen_wctype : $(locale_DIR)/gen_wctype.c
  129. $(hcompile.u)
  130. ifneq ($(V),)
  131. ifeq ($(V),1)
  132. FLAG-locale-verbose := -v -v
  133. endif
  134. ifeq ($(V),2)
  135. FLAG-locale-verbose := -v
  136. endif
  137. endif
  138. # code needs to be modified to support top_builddir in almost all apps that write directly to a file
  139. # grep fopen *.c
  140. $(locale_OUT)/c8tables.h: $(locale_OUT)/gen_wc8bit $(locale_OUT)/codesets.txt
  141. @$(disp_gen)
  142. $(Q)$< `cat $(word 2,$^)` > $@
  143. # Warning! Beware tr_TR toupper/tolower exceptions!
  144. $(locale_OUT)/wctables.h: $(locale_OUT)/gen_wctype
  145. @$(disp_gen)
  146. $(Q)for locale in $(call qstrip,$(UCLIBC_BUILD_MINIMAL_LOCALES)) en_US en_GB; do \
  147. $< $(FLAG-locale-verbose) $$locale > $@ || \
  148. $< $(FLAG-locale-verbose) $$locale.UTF-8 > $@ || \
  149. $< $(FLAG-locale-verbose) $$locale.iso8859-1 > $@ && break; \
  150. done
  151. $(locale_OUT)/locale_tables.h: $(locale_OUT)/gen_locale $(locale_OUT)/locales.txt
  152. @$(disp_gen)
  153. $(Q)$< $(FLAG-locale-verbose) -o $@ $(word 2,$^)
  154. $(locale_OUT)/lt_defines.h: $(locale_OUT)/locale_tables.h $(locale_OUT)/locale_collate.h
  155. @$(disp_gen)
  156. $(Q)grep "^#define" $< > $@
  157. $(Q)grep "^#define __lc" $(word 2,$^) >> $@
  158. $(locale_OUT)/locale_collate.h: $(locale_OUT)/gen_collate $(locale_OUT)/locale_tables.h
  159. @$(disp_gen)
  160. $(Q)grep COL_IDX_ $(word 2,$^) | \
  161. $(SED) -e "s/^.*COL_IDX_\([^, ]*\).*$$/\1/" | sort | uniq | \
  162. xargs $< $(locale_DIR)/collation $(FLAG-locale-verbose) -o $@
  163. $(locale_SRC): $(locale_OUT)/gen_ldc $(locale_OUT)/lt_defines.h
  164. @$(disp_gen)
  165. $(Q)$< $@
  166. $(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)
  167. @$(disp_gen)
  168. $(Q)grep -v "define __LC" $< > $@
  169. $(Q)cat $(wordlist 2,4,$^) >> $@
  170. $(top_builddir)include/bits/uClibc_locale_data.h: $(locale_OUT)/uClibc_locale_data.h | $(top_builddir)include/bits/uClibc_config.h
  171. @$(disp_gen)
  172. $(Q)$(AWK) 'BEGIN{i=1}{if (/WANT_/) i=/endif/;else if (i) print $0}' \
  173. $< > $@
  174. objclean-y += CLEAN_extra/locale
  175. # lmmtolso.c/gen_mmap.c/tst-*.c not used
  176. CLEAN_extra/locale:
  177. $(do_rm) $(locale_HOBJ) $(locale_SRC) $(addprefix $(locale_OUT)/*., o os txt) \
  178. $(addprefix $(locale_OUT)/,$(addsuffix .h,uClibc_locale_data lt_defines c8tables wctables locale_tables locale_collate) lmmtolso gen_mmap locale.mmap)