Makefile.in 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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. #DEPH-locale := $(top_builddir)include/bits/sysnum.h
  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. #headers-$(UCLIBC_HAS_LOCALE) += $(locale_headers-y)
  39. headers: $(locale_headers-y)
  40. libc-$(UCLIBC_HAS_LOCALE) += $(locale_OBJ)
  41. libc-nomulti-$(UCLIBC_HAS_LOCALE) += $(locale_OBJ)
  42. $(locale_OUT)%.o: $(locale_OUT)%.c FORCE ; $(compile.c)
  43. $(locale_OUT)%.os: $(locale_OUT)%.c FORCE ; $(compile.c)
  44. $(locale_OUT)%.oS: $(locale_OUT)%.c FORCE ; $(compile.c)
  45. $(locale_OUT)%.o: $(locale_OUT)%.S FORCE ; $(compile.S)
  46. $(locale_OUT)%.os: $(locale_OUT)%.S FORCE ; $(compile.S)
  47. $(locale_OUT)%.oS: $(locale_OUT)%.S FORCE ; $(compile.S)
  48. $(locale_OUT)%.o: $(locale_OUT)%.s FORCE ; $(compile.S)
  49. $(locale_OUT)%.os: $(locale_OUT)%.s FORCE ; $(compile.S)
  50. $(locale_OUT)%.oS: $(locale_OUT)%.s FORCE ; $(compile.S)
  51. $(locale_OUT)%.i: $(locale_OUT)%.c FORCE ; $(compile.i)
  52. $(locale_OUT)%.i: $(locale_OUT)%.S FORCE ; $(compile.i)
  53. $(locale_OUT)%.s: $(locale_OUT)%.c FORCE ; $(compile.s)
  54. $(locale_OUT)%.s: $(locale_OUT)%.S FORCE ; $(compile.s)
  55. $(locale_OUT)%.dep:
  56. locale_headers: headers $(top_builddir)include/bits/uClibc_locale_data.h
  57. # make sure that the host system has locales (this check is ok for uClibc/glibc)
  58. # we do not know though which locales were really enabled for libc at build time
  59. ifeq ($(wildcard /usr/include/iconv.h),)
  60. $(locale_OUT)/codesets.txt:
  61. @if [ ! -f $@ ] ; then \
  62. set -e; \
  63. echo " "; \
  64. echo "You do not have a codesets.txt file. Please create this "; \
  65. echo "file in the $(locale_OUT) directory by running something like: "; \
  66. echo " find $(CURDIR)/$(locale_DIR)/charmaps -name \"*.pairs\" > \\"; \
  67. echo " $@"; \
  68. echo "and then edit that file to disable/enable the codesets you wish to support. "; \
  69. echo " "; \
  70. false; \
  71. fi
  72. $(locale_OUT)/locales.txt:
  73. @if [ ! -f $@ ] ; then \
  74. set -e; \
  75. echo " "; \
  76. echo "You do not have a locales.txt file in the $(locale_OUT) "; \
  77. echo "directory, Please copy the LOCALES file to locales.txt by "; \
  78. echo "running something like: "; \
  79. echo " cp $(locale_DIR)/LOCALES \\ "; \
  80. echo " $@ "; \
  81. echo "then edit locales.txt to disable/enable the locales you wish "; \
  82. echo "to support. "; \
  83. echo " "; \
  84. false; \
  85. fi
  86. else
  87. $(locale_OUT)/codesets.txt:
  88. @$(disp_gen)
  89. ifeq ($(UCLIBC_BUILD_MINIMAL_LOCALE),y)
  90. $(Q)echo "$(CURDIR)/$(locale_DIR)/charmaps/ASCII.pairs" > $@
  91. $(Q)echo "$(CURDIR)/$(locale_DIR)/charmaps/ISO-8859-1.pairs" >> $@
  92. else
  93. $(Q)set -e; \
  94. tmp=`mktemp $@.XXXXXX 2>/dev/null || true`; \
  95. [ -z "$$tmp" ] && tmp='$@.new'; \
  96. find $(CURDIR)/$(locale_DIR)/charmaps/ -name '*.pairs' | \
  97. sort > $$tmp; \
  98. [ -s $$tmp ]; \
  99. if cmp $@ $$tmp >/dev/null 2>&1; then \
  100. $(RM) $$tmp; \
  101. else \
  102. mv -f $$tmp $@; \
  103. fi
  104. endif
  105. # the lines beginning w/ '#-' are mandatory
  106. # at least one conversion is needed (euro/cyrillic)
  107. $(locale_OUT)/locales.txt: $(locale_DIR)/LOCALES
  108. @$(disp_gen)
  109. ifeq ($(UCLIBC_BUILD_MINIMAL_LOCALE),y)
  110. $(Q)echo "@euro e" > $@
  111. $(Q)echo "#-" >> $@
  112. $(Q)echo "UTF-8 yes" >> $@
  113. $(Q)echo "8-BIT yes" >> $@
  114. $(Q)echo "#-" >> $@
  115. $(Q)for locale in $(call qstrip,$(UCLIBC_BUILD_MINIMAL_LOCALES)); do \
  116. echo "$$locale.UTF-8 UTF-8"; \
  117. echo "$$locale ISO-8859-1"; \
  118. done >> $@
  119. else
  120. $(Q)cat $< > $@
  121. endif
  122. endif
  123. $(locale_DIR)/gen_collate.c: $(DEPH-gen_collate)
  124. $(locale_OUT)/gen_collate : $(locale_DIR)/gen_collate.c
  125. $(hcompile.u)
  126. $(locale_DIR)/gen_ldc.c: $(DEPH-gen_ldc)
  127. $(locale_OUT)/gen_ldc : $(locale_DIR)/gen_ldc.c
  128. $(hcompile.u)
  129. $(locale_DIR)/gen_locale.c: $(DEPH-gen_locale)
  130. $(locale_OUT)/gen_locale : $(locale_DIR)/gen_locale.c
  131. $(hcompile.u)
  132. $(locale_DIR)/gen_wc8bit.c: $(DEPH-gen_wc8bit)
  133. $(locale_OUT)/gen_wc8bit : $(locale_DIR)/gen_wc8bit.c
  134. $(hcompile.u)
  135. $(locale_DIR)/gen_wctype.c: $(DEPH-gen_wctype)
  136. $(locale_OUT)/gen_wctype : $(locale_DIR)/gen_wctype.c
  137. $(hcompile.u)
  138. ifneq ($(V),)
  139. ifeq ($(V),1)
  140. FLAG-locale-verbose := -v
  141. endif
  142. ifeq ($(V),2)
  143. FLAG-locale-verbose := -v -v
  144. endif
  145. endif
  146. # code needs to be modified to support top_builddir in almost all apps that write directly to a file
  147. # grep fopen *.c
  148. $(locale_OUT)/c8tables.h: $(locale_OUT)/gen_wc8bit $(locale_OUT)/codesets.txt
  149. @$(disp_gen)
  150. $(Q)$< `cat $(word 2,$^)` > $@
  151. # Warning! Beware tr_TR toupper/tolower exceptions!
  152. $(locale_OUT)/wctables.h: $(locale_OUT)/gen_wctype
  153. @$(disp_gen)
  154. $(Q)for locale in $(call qstrip,$(UCLIBC_BUILD_MINIMAL_LOCALES)) en_US en_GB; do \
  155. $< $(FLAG-locale-verbose) $$locale > $@ || \
  156. $< $(FLAG-locale-verbose) $$locale.UTF-8 > $@ || \
  157. $< $(FLAG-locale-verbose) $$locale.iso8859-1 > $@ && break; \
  158. done
  159. $(locale_OUT)/locale_tables.h: $(locale_OUT)/gen_locale $(locale_OUT)/locales.txt
  160. @$(disp_gen)
  161. $(Q)$< $(FLAG-locale-verbose) -o $@ $(word 2,$^)
  162. $(locale_OUT)/lt_defines.h: $(locale_OUT)/locale_tables.h $(locale_OUT)/locale_collate.h
  163. @$(disp_gen)
  164. $(Q)grep "^#define" $< > $@
  165. $(Q)grep "^#define __lc" $(word 2,$^) >> $@
  166. $(locale_OUT)/locale_collate.h: $(locale_OUT)/gen_collate $(locale_OUT)/locale_tables.h
  167. @$(disp_gen)
  168. $(Q)grep COL_IDX_ $(word 2,$^) | \
  169. $(SED) -e "s/^.*COL_IDX_\([^, ]*\).*$$/\1/" | sort | uniq | \
  170. xargs $< $(locale_DIR)/collation $(FLAG-locale-verbose) -o $@
  171. $(locale_OUT)/$(LOCALE_DATA_FILENAME):
  172. ifeq ($(UCLIBC_DOWNLOAD_PREGENERATED_LOCALE_DATA),y)
  173. ( cd $(@D); $(WGET) http://www.uclibc.org/downloads/$(@F) )
  174. endif
  175. ifeq ($(UCLIBC_PREGENERATED_LOCALE_DATA),y)
  176. $(locale_SRC): $(locale_OUT)/$(LOCALE_DATA_FILENAME)
  177. zcat $< | $(TAR) -xv -C $(@D) -f -
  178. touch $@
  179. # we use the one in locale_DIR
  180. #$(RM) $(locale_OUT)/locale_mmap.h
  181. # for arch specific versions we have to at least overwrite
  182. # lt_defines.h/locale_data.c/uClibc_locale_data.h
  183. $(locale_OUT)/uClibc_locale_data.h: $(locale_SRC)
  184. else
  185. $(locale_SRC): $(locale_OUT)/gen_ldc $(locale_OUT)/lt_defines.h
  186. @$(disp_gen)
  187. $(Q)$< $@
  188. $(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)
  189. @$(disp_gen)
  190. $(Q)grep -v "define __LC" $< > $@
  191. $(Q)cat $(wordlist 2,4,$^) >> $@
  192. endif
  193. $(top_builddir)include/bits/uClibc_locale_data.h: $(locale_OUT)/uClibc_locale_data.h | $(top_builddir)include/bits/uClibc_config.h
  194. @$(disp_gen)
  195. $(Q)$(AWK) 'BEGIN{i=1}{if (/WANT_/) i=/endif/;else if (i) print $0}' \
  196. $< > $@
  197. objclean-y += CLEAN_extra/locale
  198. # lmmtolso.c/gen_mmap.c/tst-*.c not used
  199. CLEAN_extra/locale:
  200. $(do_rm) $(locale_HOBJ) $(locale_SRC) $(addprefix $(locale_OUT)/*., o os txt) \
  201. $(addprefix $(locale_OUT)/,$(addsuffix .h,uClibc_locale_data lt_defines c8tables wctables locale_tables locale_collate) lmmtolso gen_mmap locale.mmap)