Makerules 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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-so-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-a-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. ifneq ($(findstring s,$(MAKEFLAGS)),)
  30. DISP := sil
  31. Q := @
  32. else
  33. ifneq ($(V)$(VERBOSE),)
  34. DISP := ver
  35. Q :=
  36. else
  37. DISP := pur
  38. Q := @
  39. endif
  40. endif
  41. show_objs = $(subst ../,,$@)
  42. pur_disp_compile.c = echo " "CC $(show_objs)
  43. pur_disp_compile.S = echo " "AS $(show_objs)
  44. pur_disp_compile.m = $(pur_disp_compile.c)
  45. pur_disp_compile-m = echo " "CC-m $(show_objs)
  46. pur_disp_strip = echo " "STRIP $(STRIP_FLAGS) $@
  47. pur_disp_ar = echo " "AR $(ARFLAGS) $@
  48. pur_disp_ld = echo " "LD $(1)
  49. sil_disp_compile.c = true
  50. sil_disp_compile.S = true
  51. sil_disp_compile.m = true
  52. sil_disp_compile-m = true
  53. sil_disp_strip = true
  54. sil_disp_ar = true
  55. sil_disp_ld = true
  56. ver_disp_compile.c = echo $(cmd_compile.c)
  57. ver_disp_compile.S = echo $(cmd_compile.S)
  58. ver_disp_compile.m = echo $(cmd_compile.m)
  59. ver_disp_compile-m = echo $(cmd_compile-m)
  60. ver_disp_strip = echo $(cmd_strip)
  61. ver_disp_ar = echo $(cmd_ar)
  62. ver_disp_ld =
  63. disp_compile.c = $($(DISP)_disp_compile.c)
  64. disp_compile.S = $($(DISP)_disp_compile.S)
  65. disp_compile.m = $($(DISP)_disp_compile.m)
  66. disp_compile-m = $($(DISP)_disp_compile-m)
  67. disp_strip = $($(DISP)_disp_strip)
  68. disp_ar = $($(DISP)_disp_ar)
  69. disp_ld = $($(DISP)_disp_ld)
  70. cmd_compile.c = $(CC) -c $< -o $@ $(CFLAGS) $(ARCH_CFLAGS) $(CFLAGS-$(suffix $@)) $(CFLAGS-$(notdir $(^D))) $(CFLAGS-$(subst $(top_srcdir),,$(dir $<))) $(CFLAGS-$(notdir $<)) $(CFLAGS-$(notdir $@))
  71. cmd_compile.S = $(cmd_compile.c) $(ASFLAGS) $(ARCH_ASFLAGS) $(ASFLAGS-$(suffix $@)) $(ASFLAGS-$(notdir $<)) $(ASFLAGS-$(notdir $@))
  72. cmd_compile.m = $(cmd_compile.c) -DL_$(patsubst %$(suffix $(notdir $@)),%,$(notdir $@))
  73. cmd_compile-m = $(CC) $^ -c -o $@ $(CFLAGS) $(ARCH_CFLAGS) $(CFLAGS-$(suffix $@)) $(CFLAGS-$(notdir $@)) $(CFLAGS-multi-y)
  74. cmd_strip = $(STRIPTOOL) $(STRIP_FLAGS) $^
  75. cmd_ar = $(AR) $(ARFLAGS) $@ $^
  76. compile.c = @$(disp_compile.c) ; $(cmd_compile.c)
  77. compile.E = $(cmd_compile.c:-c=-E)
  78. compile.s = $(cmd_compile.c:-c=-S)
  79. compile.S = @$(disp_compile.S) ; $(cmd_compile.S)
  80. compile.m = @$(disp_compile.m) ; $(cmd_compile.m)
  81. compile-m = @$(disp_compile-m) ; $(cmd_compile-m)
  82. do_strip = @$(disp_strip) ; $(cmd_strip)
  83. do_ar = @$(disp_ar) ; $(cmd_ar)
  84. define compile.u
  85. @$(disp_compile.c)
  86. $(Q)$(CC) $^ $(DEPS-$(notdir $@)) -o $@ $(CFLAGS) $(CFLAGS-$(notdir $(^D))) $(CFLAGS-$(notdir $@))
  87. @$(disp_strip)
  88. $(Q)$(STRIPTOOL) $(STRIP_FLAGS) $@
  89. endef
  90. hcompile.u = $(HOSTCC) $^ $(DEPS-$(notdir $@)) -o $@ $(BUILD_LDFLAGS) $(BUILD_LDFLAGS-$(notdir $(^D))) $(BUILD_LDFLAGS-$(notdir $@)) $(BUILD_CFLAGS) $(BUILD_CFLAGS-$(notdir $(^D))) $(BUILD_CFLAGS-$(notdir $@))
  91. hcompile.o = $(HOSTCC) $^ $(DEPS-$(notdir $@)) -c -o $@ $(BUILD_CFLAGS) $(BUILD_CFLAGS-$(notdir $(^D))) $(BUILD_CFLAGS-$(notdir $@))
  92. define link.so
  93. $(Q)$(INSTALL) -d $(dir $@)
  94. $(Q)$(RM) $@ $@.$(2) $(dir $@)$(1)
  95. @$(disp_ld)
  96. $(Q)$(LD) $(LDFLAGS-$(notdir $@)) -soname=$(notdir $@).$(2) \
  97. -o $(dir $@)$(1) $(START_FILE-$(notdir $@)) \
  98. --whole-archive $(firstword $^) --no-whole-archive \
  99. $(LIBS-$(notdir $@)) $(LIBGCC) $(END_FILE-$(notdir $@))
  100. $(Q)$(LN) -sf $(1) $@.$(2)
  101. $(Q)$(LN) -sf $(1) $@
  102. endef
  103. CFLAGS-.os+=$(PICFLAG)
  104. CFLAGS-.oS+=$(PICFLAG) -DSHARED
  105. %.o: %.c ; $(compile.c)
  106. %.os: %.c ; $(compile.c)
  107. %.oS: %.c ; $(compile.c)
  108. %.o: %.S ; $(compile.S)
  109. %.os: %.S ; $(compile.S)
  110. %.oS: %.S ; $(compile.S)
  111. %.o: %.s ; $(compile.S)
  112. %.os: %.s ; $(compile.S)
  113. %.oS: %.s ; $(compile.S)
  114. %.E: %.c ; $(compile.E)
  115. %.E: %.S ; $(compile.E)
  116. %.s: %.c ; $(compile.s)
  117. %.s: %.S ; $(compile.s)
  118. $(top_builddir)lib/interp.c:
  119. $(Q)$(INSTALL) -d $(dir $@)
  120. $(Q)echo "/* Force shared libraries to know about the correct library loader */" > $@
  121. $(Q)echo "#include <features.h>" >> $@
  122. $(Q)echo "#ifdef __HAVE_ELF__" >> $@
  123. $(Q)echo "const char __dl_ldso__[] __attribute__ ((section " \
  124. "(\".interp\"))) =\""$(SHARED_LIB_LOADER_PREFIX)/$(UCLIBC_LDSO)"\";" >> $@
  125. $(Q)echo "#endif" >> $@
  126. $(interp): $(top_builddir)lib/interp.c
  127. $(compile.c)
  128. $(Q)$(STRIPTOOL) -x -R .note -R .comment $@
  129. $(ldso):
  130. @cd $(top_builddir); $(MAKE) lib/$(patsubst %.$(MAJOR_VERSION),%,$(notdir $@))
  131. $(libc):
  132. @cd $(top_builddir); $(MAKE) lib/$(patsubst %.$(MAJOR_VERSION),%,$(notdir $@))
  133. $(headers_dep):
  134. @cd $(top_builddir); $(MAKE) headers
  135. #ifeq ($(HAVE_ELF),y)
  136. CRT=crt1
  137. #else
  138. #CRT=crt0
  139. #endif
  140. ifeq ($(HAVE_SHARED),y)
  141. CRTS=$(top_builddir)lib/$(CRT).o $(top_builddir)lib/S$(CRT).o
  142. else
  143. CRTS=$(top_builddir)lib/$(CRT).o
  144. endif
  145. $(top_builddir)lib/$(CRT).o: $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/$(CRT).S
  146. $(Q)$(INSTALL) -d $(dir $@)
  147. $(compile.S) -DL_$(patsubst %$(suffix $(notdir $@)),%,$(notdir $@))
  148. $(Q)$(STRIPTOOL) -x -R .note -R .comment $@
  149. $(top_builddir)lib/S$(CRT).o: $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/$(CRT).S
  150. $(Q)$(INSTALL) -d $(dir $@)
  151. $(compile.S) $(PIEFLAG) -DL_$(patsubst %$(suffix $(notdir $@)),%,$(notdir $@))
  152. $(Q)$(STRIPTOOL) -x -R .note -R .comment $@
  153. CTOR_TARGETS=$(top_builddir)lib/crti.o $(top_builddir)lib/crtn.o
  154. ifeq ($(UCLIBC_CTOR_DTOR),y)
  155. $(CTOR_TARGETS): $(top_builddir)lib/%.o : $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/%.S
  156. $(Q)$(INSTALL) -d $(dir $@)
  157. $(compile.S) $(PICFLAG) $(SSP_DISABLE_FLAGS)
  158. else
  159. $(CTOR_TARGETS):
  160. $(Q)$(INSTALL) -d $(dir $@)
  161. $(do_ar)
  162. endif
  163. #ifeq ($(TARGET_ARCH),nios)
  164. #CRTS_COMPAT := $(top_builddir)lib/crt0.o
  165. #$(CRTS_COMPAT):
  166. # ln -fs crt1.o $(top_builddir)lib/crt0.o
  167. #else
  168. CRTS_COMPAT :=
  169. #endif
  170. $(crt-y): $(CRTS) $(CTOR_TARGETS) $(CRTS_COMPAT)
  171. $(top_builddir)lib/$(NONSHARED_LIBNAME): $(libc-nonshared-y)
  172. $(Q)$(INSTALL) -d $(dir $@)
  173. $(do_ar)
  174. .PHONY: dummy create
  175. clean: objclean-y headers_clean-y
  176. objclean-y: $(objclean-y)
  177. headers_clean-y: $(headers_clean-y)
  178. .PHONY: \
  179. all check clean distclean test \
  180. config dist menuconfig oldconfig release \
  181. subdirs utils