Makefile.in 8.1 KB

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