Makerules 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. #
  2. # Licensed under LGPL v2.1, see the file COPYING.LIB in this tarball for details.
  3. #
  4. .SUFFIXES: .c .S .o .os .oS .so .a .s .i .E
  5. # order is important, the stripping uses STRIP_FLAGS for lib-so, but not for lib-a
  6. ifeq ($(HAVE_SHARED),y)
  7. .LIBPATTERNS: "lib%.so"
  8. libs: $(lib-so-y) $(lib-a-y)
  9. $(lib-so-y): $(interp)
  10. else
  11. .LIBPATTERNS: "lib%.a"
  12. libs: $(lib-a-y)
  13. endif
  14. objs: all_objs
  15. shared_objs = $(ldso-y) $(libc-y:.o=.os) $(libc-shared-y) $(libc-nonshared-y) $(libdl-so-y)
  16. shared_objs += $(libcrypt-so-y) $(libintl-so-y) $(libm-so-y) $(libnsl-so-y) $(libpthread-so-y)
  17. shared_objs += $(libthread_db-so-y) $(libresolv-so-y) $(librt-so-y) $(libutil-so-y)
  18. ar_objs = $(libc-y) $(libc-static-y) $(libdl-a-y) $(libcrypt-a-y) $(libintl-a-y) $(libm-a-y) $(libnsl-a-y)
  19. ar_objs += $(libpthread-a-y) $(libthread_db-a-y) $(libresolv-a-y) $(librt-a-y) $(libutil-a-y)
  20. ifeq ($(DOPIC),y)
  21. ar_objs := $(ar_objs:.o=.os)
  22. endif
  23. ifeq ($(HAVE_SHARED),y)
  24. all_objs: $(sort $(shared_objs) $(ar_objs))
  25. else
  26. all_objs: $(ar_objs)
  27. endif
  28. headers-y: $(headers-y)
  29. MAKEFLAGS += --no-print-directory
  30. ifneq ($(findstring s,$(MAKEFLAGS)),)
  31. DISP := sil
  32. Q := @
  33. else
  34. ifneq ($(V)$(VERBOSE),)
  35. DISP := ver
  36. Q :=
  37. else
  38. DISP := pur
  39. Q := @
  40. endif
  41. endif
  42. show_objs = $(subst ../,,$@)
  43. pur_disp_compile.c = echo " "CC $(show_objs)
  44. pur_disp_compile.S = echo " "AS $(show_objs)
  45. pur_disp_compile.m = $(pur_disp_compile.c)
  46. pur_disp_compile-m = echo " "CC-m $(show_objs)
  47. pur_disp_strip = echo " "STRIP $(STRIP_FLAGS) $@
  48. pur_disp_t_strip = echo " "STRIP $(STRIP_FLAGS) $@
  49. pur_disp_ar = echo " "AR $(ARFLAGS) $@
  50. pur_disp_ld = echo " "LD $(1)
  51. sil_disp_compile.c = true
  52. sil_disp_compile.S = true
  53. sil_disp_compile.m = true
  54. sil_disp_compile-m = true
  55. sil_disp_strip = true
  56. sil_disp_t_strip = true
  57. sil_disp_ar = true
  58. sil_disp_ld = true
  59. ver_disp_compile.c = echo $(cmd_compile.c)
  60. ver_disp_compile.S = echo $(cmd_compile.S)
  61. ver_disp_compile.m = echo $(cmd_compile.m)
  62. ver_disp_compile-m = echo $(cmd_compile-m)
  63. ver_disp_strip = echo $(cmd_strip)
  64. ver_disp_t_strip = echo $(cmd_t_strip)
  65. ver_disp_ar = echo $(cmd_ar)
  66. ver_disp_ld =
  67. disp_compile.c = $($(DISP)_disp_compile.c)
  68. disp_compile.S = $($(DISP)_disp_compile.S)
  69. disp_compile.m = $($(DISP)_disp_compile.m)
  70. disp_compile-m = $($(DISP)_disp_compile-m)
  71. disp_strip = $($(DISP)_disp_strip)
  72. disp_t_strip = $($(DISP)_disp_t_strip)
  73. disp_ar = $($(DISP)_disp_ar)
  74. disp_ld = $($(DISP)_disp_ld)
  75. cmd_compile.c = $(CC) -c $< -o $@ $(CFLAGS) $(ARCH_CFLAGS) $(CFLAGS-$(suffix $@)) $(CFLAGS-$(notdir $(^D))) $(CFLAGS-$(subst $(top_srcdir),,$(dir $<))) $(CFLAGS-$(notdir $<)) $(CFLAGS-$(notdir $@))
  76. cmd_compile.S = $(cmd_compile.c) $(ASFLAGS) $(ARCH_ASFLAGS) $(ASFLAGS-$(suffix $@)) $(ASFLAGS-$(notdir $<)) $(ASFLAGS-$(notdir $@))
  77. cmd_compile.m = $(cmd_compile.c) -DL_$(patsubst %$(suffix $(notdir $@)),%,$(notdir $@))
  78. cmd_compile-m = $(CC) $^ -c -o $@ $(CFLAGS) $(ARCH_CFLAGS) $(CFLAGS-$(suffix $@)) $(CFLAGS-$(notdir $(@D))) $(CFLAGS-$(notdir $@))
  79. #cmd_compile-m = $(CC) $^ -c -o $@ $(CFLAGS) $(ARCH_CFLAGS) $(CFLAGS-$(suffix $@)) $(CFLAGS-$(notdir $(@D))) $(CFLAGS-$(notdir $@)) $(CFLAGS-multi-y)
  80. cmd_strip = $(STRIPTOOL) $(STRIP_FLAGS) $^
  81. cmd_t_strip = $(STRIPTOOL) $(STRIP_FLAGS) $@
  82. cmd_ar = $(AR) $(ARFLAGS) $@ $^
  83. compile.c = @$(disp_compile.c) ; $(cmd_compile.c)
  84. compile.E = $(cmd_compile.c:-c=-E)
  85. compile.s = $(cmd_compile.c:-c=-S)
  86. compile.S = @$(disp_compile.S) ; $(cmd_compile.S)
  87. compile.m = @$(disp_compile.m) ; $(cmd_compile.m)
  88. compile-m = @$(disp_compile-m) ; $(cmd_compile-m)
  89. do_strip = @$(disp_strip) ; $(cmd_strip)
  90. do_t_strip= @$(disp_t_strip) ; $(cmd_t_strip)
  91. do_ar = @$(disp_ar) ; $(cmd_ar)
  92. define compile.u
  93. @$(disp_compile.c)
  94. $(Q)$(CC) $^ $(DEPS-$(notdir $@)) -o $@ $(CFLAGS) $(CFLAGS-$(notdir $(^D))) $(CFLAGS-$(notdir $@))
  95. @$(disp_strip)
  96. $(Q)$(STRIPTOOL) $(STRIP_FLAGS) $@
  97. endef
  98. hcompile.u = $(HOSTCC) $^ $(DEPS-$(notdir $@)) -o $@ $(BUILD_LDFLAGS) $(BUILD_LDFLAGS-$(notdir $(^D))) $(BUILD_LDFLAGS-$(notdir $@)) $(BUILD_CFLAGS) $(BUILD_CFLAGS-$(notdir $(^D))) $(BUILD_CFLAGS-$(notdir $@))
  99. hcompile.o = $(HOSTCC) $^ $(DEPS-$(notdir $@)) -c -o $@ $(BUILD_CFLAGS) $(BUILD_CFLAGS-$(notdir $(^D))) $(BUILD_CFLAGS-$(notdir $@))
  100. define link.so
  101. $(Q)$(INSTALL) -d $(dir $@)
  102. $(Q)$(RM) $@ $@.$(2) $(dir $@)$(1)
  103. @$(disp_ld)
  104. $(Q)$(LD) $(LDFLAGS-$(notdir $@)) -soname=$(notdir $@).$(2) \
  105. -o $(dir $@)$(1) $(START_FILE-$(notdir $@)) \
  106. --whole-archive $(firstword $^) --no-whole-archive \
  107. $(LIBS-$(notdir $@)) $(LIBGCC) $(END_FILE-$(notdir $@))
  108. $(Q)$(LN) -sf $(1) $@.$(2)
  109. $(Q)$(LN) -sf $(1) $@
  110. endef
  111. define linkm.so
  112. $(Q)$(INSTALL) -d $(dir $@)
  113. $(Q)$(RM) $@ $@.$(2) $(dir $@)$(1)
  114. @$(disp_ld)
  115. $(Q)$(LD) $(LDFLAGS-$(notdir $@)) -soname=$(notdir $@).$(2) \
  116. -o $(dir $@)$(1) $(START_FILE-$(notdir $@)) $(firstword $^) \
  117. $(LIBS-$(notdir $@)) $(LIBGCC) $(END_FILE-$(notdir $@))
  118. $(Q)$(LN) -sf $(1) $@.$(2)
  119. $(Q)$(LN) -sf $(1) $@
  120. endef
  121. CFLAGS-.os+=$(PICFLAG)
  122. CFLAGS-.oS+=$(PICFLAG) -DSHARED
  123. %.o: %.c ; $(compile.c)
  124. %.os: %.c ; $(compile.c)
  125. %.oS: %.c ; $(compile.c)
  126. %.o: %.S ; $(compile.S)
  127. %.os: %.S ; $(compile.S)
  128. %.oS: %.S ; $(compile.S)
  129. %.o: %.s ; $(compile.S)
  130. %.os: %.s ; $(compile.S)
  131. %.oS: %.s ; $(compile.S)
  132. %.E: %.c ; $(compile.E)
  133. %.E: %.S ; $(compile.E)
  134. %.s: %.c ; $(compile.s)
  135. %.s: %.S ; $(compile.s)
  136. $(top_builddir)lib/interp.c:
  137. $(Q)$(INSTALL) -d $(dir $@)
  138. $(Q)echo "/* Force shared libraries to know about the correct library loader */" > $@
  139. $(Q)echo "#include <features.h>" >> $@
  140. $(Q)echo "const char __dl_ldso__[] __attribute__ ((section " \
  141. "(\".interp\"))) =\""$(SHARED_LIB_LOADER_PREFIX)/$(UCLIBC_LDSO)"\";" >> $@
  142. $(interp): $(top_builddir)lib/interp.c
  143. $(compile.c)
  144. $(Q)$(STRIPTOOL) -x -R .note -R .comment $@
  145. $(ldso):
  146. @cd $(top_builddir); $(MAKE) lib/$(patsubst %.$(MAJOR_VERSION),%,$(notdir $@))
  147. $(libc):
  148. @cd $(top_builddir); $(MAKE) lib/$(patsubst %.$(MAJOR_VERSION),%,$(notdir $@))
  149. $(headers_dep):
  150. @cd $(top_builddir); $(MAKE) headers
  151. CRT=crt1
  152. ifeq ($(HAVE_SHARED),y)
  153. CRTS=$(top_builddir)lib/$(CRT).o $(top_builddir)lib/S$(CRT).o
  154. else
  155. CRTS=$(top_builddir)lib/$(CRT).o
  156. endif
  157. $(top_builddir)lib/$(CRT).o: $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/$(CRT).S
  158. $(Q)$(INSTALL) -d $(dir $@)
  159. $(compile.S) -DL_$(patsubst %$(suffix $(notdir $@)),%,$(notdir $@))
  160. $(Q)$(STRIPTOOL) -x -R .note -R .comment $@
  161. $(top_builddir)lib/S$(CRT).o: $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/$(CRT).S
  162. $(Q)$(INSTALL) -d $(dir $@)
  163. $(compile.S) $(PIEFLAG) -DL_$(patsubst %$(suffix $(notdir $@)),%,$(notdir $@))
  164. $(Q)$(STRIPTOOL) -x -R .note -R .comment $@
  165. CTOR_TARGETS=$(top_builddir)lib/crti.o $(top_builddir)lib/crtn.o
  166. ifeq ($(UCLIBC_CTOR_DTOR),y)
  167. $(CTOR_TARGETS): $(top_builddir)lib/%.o : $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/%.S
  168. $(Q)$(INSTALL) -d $(dir $@)
  169. $(compile.S) $(PICFLAG) $(SSP_DISABLE_FLAGS)
  170. else
  171. $(CTOR_TARGETS):
  172. $(Q)$(INSTALL) -d $(dir $@)
  173. $(do_ar)
  174. endif
  175. #ifeq ($(TARGET_ARCH),nios)
  176. #CRTS_COMPAT := $(top_builddir)lib/crt0.o
  177. #$(CRTS_COMPAT):
  178. # ln -fs crt1.o $(top_builddir)lib/crt0.o
  179. #else
  180. CRTS_COMPAT :=
  181. #endif
  182. $(crt-y): $(CRTS) $(CTOR_TARGETS) $(CRTS_COMPAT)
  183. $(top_builddir)lib/$(NONSHARED_LIBNAME): $(libc-nonshared-y)
  184. $(Q)$(INSTALL) -d $(dir $@)
  185. $(do_ar)
  186. .PHONY: dummy create
  187. clean: objclean-y headers_clean-y
  188. objclean-y: $(objclean-y)
  189. headers_clean-y: $(headers_clean-y)
  190. .PHONY: \
  191. all check clean distclean test \
  192. config dist menuconfig oldconfig release \
  193. subdirs utils