Makerules 6.4 KB

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