Makefile.in 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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. find $(CURDIR)/$(locale_DIR)/charmaps/ -name '*.pairs' | \
  95. sort > $@.new; \
  96. [ -s $@.new ]; \
  97. cmp -s $@ $@.new && $(RM) $@.new || mv -f $@.new $@
  98. endif
  99. # the lines beginning w/ '#-' are mandatory
  100. # at least one conversion is needed (euro/cyrillic)
  101. $(locale_OUT)/locales.txt: $(locale_DIR)/LOCALES
  102. @$(disp_gen)
  103. ifeq ($(UCLIBC_BUILD_MINIMAL_LOCALE),y)
  104. $(Q)echo "@euro e" > $@
  105. $(Q)echo "#-" >> $@
  106. $(Q)echo "UTF-8 yes" >> $@
  107. $(Q)echo "8-BIT yes" >> $@
  108. $(Q)echo "#-" >> $@
  109. $(Q)for locale in $(call qstrip,$(UCLIBC_BUILD_MINIMAL_LOCALES)); do \
  110. echo "$$locale.UTF-8 UTF-8"; \
  111. echo "$$locale ISO-8859-1"; \
  112. done >> $@
  113. else
  114. $(Q)cat $< > $@
  115. endif
  116. endif
  117. $(locale_DIR)/gen_collate.c: $(DEPH-gen_collate)
  118. $(locale_OUT)/gen_collate : $(locale_DIR)/gen_collate.c
  119. $(hcompile.u)
  120. $(locale_DIR)/gen_ldc.c: $(DEPH-gen_ldc)
  121. $(locale_OUT)/gen_ldc : $(locale_DIR)/gen_ldc.c
  122. $(hcompile.u)
  123. $(locale_DIR)/gen_locale.c: $(DEPH-gen_locale)
  124. $(locale_OUT)/gen_locale : $(locale_DIR)/gen_locale.c
  125. $(hcompile.u)
  126. $(locale_DIR)/gen_wc8bit.c: $(DEPH-gen_wc8bit)
  127. $(locale_OUT)/gen_wc8bit : $(locale_DIR)/gen_wc8bit.c
  128. $(hcompile.u)
  129. $(locale_DIR)/gen_wctype.c: $(DEPH-gen_wctype)
  130. $(locale_OUT)/gen_wctype : $(locale_DIR)/gen_wctype.c
  131. $(hcompile.u)
  132. ifneq ($(V),)
  133. ifeq ($(V),1)
  134. FLAG-locale-verbose := -v
  135. endif
  136. ifeq ($(V),2)
  137. FLAG-locale-verbose := -v -v
  138. endif
  139. endif
  140. # code needs to be modified to support top_builddir in almost all apps that write directly to a file
  141. # grep fopen *.c
  142. $(locale_OUT)/c8tables.h: $(locale_OUT)/gen_wc8bit $(locale_OUT)/codesets.txt
  143. @$(disp_gen)
  144. $(Q)$< `cat $(word 2,$^)` > $@
  145. # Warning! Beware tr_TR toupper/tolower exceptions!
  146. $(locale_OUT)/wctables.h: $(locale_OUT)/gen_wctype
  147. @$(disp_gen)
  148. $(Q)for locale in $(call qstrip,$(UCLIBC_BUILD_MINIMAL_LOCALES)) en_US en_GB; do \
  149. $< $(FLAG-locale-verbose) $$locale > $@ || \
  150. $< $(FLAG-locale-verbose) $$locale.UTF-8 > $@ || \
  151. $< $(FLAG-locale-verbose) $$locale.iso8859-1 > $@ && break; \
  152. done
  153. $(locale_OUT)/locale_tables.h: $(locale_OUT)/gen_locale $(locale_OUT)/locales.txt
  154. @$(disp_gen)
  155. $(Q)$< $(FLAG-locale-verbose) -o $@ $(word 2,$^)
  156. $(locale_OUT)/lt_defines.h: $(locale_OUT)/locale_tables.h $(locale_OUT)/locale_collate.h
  157. @$(disp_gen)
  158. $(Q)grep "^#define" $< > $@
  159. $(Q)grep "^#define __lc" $(word 2,$^) >> $@
  160. $(locale_OUT)/locale_collate.h: $(locale_OUT)/gen_collate $(locale_OUT)/locale_tables.h
  161. @$(disp_gen)
  162. $(Q)grep COL_IDX_ $(word 2,$^) | \
  163. $(SED) -e "s/^.*COL_IDX_\([^, ]*\).*$$/\1/" | sort | uniq | \
  164. xargs $< $(locale_DIR)/collation $(FLAG-locale-verbose) -o $@
  165. $(locale_OUT)/$(LOCALE_DATA_FILENAME):
  166. ifeq ($(UCLIBC_DOWNLOAD_PREGENERATED_LOCALE_DATA),y)
  167. ( cd $(@D); $(WGET) http://www.uclibc.org/downloads/$(@F) )
  168. endif
  169. ifeq ($(UCLIBC_PREGENERATED_LOCALE_DATA),y)
  170. $(locale_SRC): $(locale_OUT)/$(LOCALE_DATA_FILENAME)
  171. zcat $< | $(TAR) -xv -C $(@D) -f -
  172. touch $@
  173. # we use the one in locale_DIR
  174. #$(RM) $(locale_OUT)/locale_mmap.h
  175. # for arch specific versions we have to at least overwrite
  176. # lt_defines.h/locale_data.c/uClibc_locale_data.h
  177. $(locale_OUT)/uClibc_locale_data.h: $(locale_SRC)
  178. else
  179. $(locale_SRC): $(locale_OUT)/gen_ldc $(locale_OUT)/lt_defines.h
  180. @$(disp_gen)
  181. $(Q)$< $@
  182. $(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)
  183. @$(disp_gen)
  184. $(Q)grep -v "define __LC" $< > $@
  185. $(Q)cat $(wordlist 2,4,$^) >> $@
  186. endif
  187. $(top_builddir)include/bits/uClibc_locale_data.h: $(locale_OUT)/uClibc_locale_data.h | $(top_builddir)include/bits/uClibc_config.h
  188. @$(disp_gen)
  189. $(Q)$(AWK) 'BEGIN{i=1}{if (/WANT_/) i=/endif/;else if (i) print $0}' \
  190. $< > $@
  191. objclean-y += CLEAN_extra/locale
  192. # lmmtolso.c/gen_mmap.c/tst-*.c not used
  193. CLEAN_extra/locale:
  194. $(do_rm) $(locale_HOBJ) $(locale_SRC) $(addprefix $(locale_OUT)/*., o os txt) \
  195. $(addprefix $(locale_OUT)/,$(addsuffix .h,uClibc_locale_data lt_defines c8tables wctables locale_tables locale_collate) lmmtolso gen_mmap locale.mmap)