Makerules 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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. define compile.u
  76. $(CC) $^ $(DEPS-$(notdir $@)) -o $@ $(CFLAGS) $(CFLAGS-$(notdir $(^D))) $(CFLAGS-$(notdir $@))
  77. $(STRIPTOOL) $(STRIP_FLAGS) $@
  78. endef
  79. hcompile.u = $(HOSTCC) $^ $(DEPS-$(notdir $@)) -o $@ $(BUILD_LDFLAGS) $(BUILD_LDFLAGS-$(notdir $(^D))) $(BUILD_LDFLAGS-$(notdir $@)) $(BUILD_CFLAGS) $(BUILD_CFLAGS-$(notdir $(^D))) $(BUILD_CFLAGS-$(notdir $@))
  80. hcompile.o = $(HOSTCC) $^ $(DEPS-$(notdir $@)) -c -o $@ $(BUILD_CFLAGS) $(BUILD_CFLAGS-$(notdir $(^D))) $(BUILD_CFLAGS-$(notdir $@))
  81. compile.c = @$(disp_compile.c) ; $(cmd_compile.c)
  82. compile.E = $(cmd_compile.c:-c=-E)
  83. compile.S = @$(disp_compile.S) ; $(cmd_compile.S)
  84. compile.m = @$(disp_compile.m) ; $(cmd_compile.m)
  85. compile-m = @$(disp_compile-m) ; $(cmd_compile-m)
  86. do_strip = @$(disp_strip) ; $(cmd_strip)
  87. do_ar = @$(disp_ar) ; $(cmd_ar)
  88. define link.so
  89. $(Q)$(INSTALL) -d $(dir $@)
  90. $(Q)$(RM) $@ $@.$(2) $(dir $@)$(1)
  91. @$(disp_ld)
  92. $(Q)$(LD) $(LDFLAGS-$(notdir $@)) -soname=$(notdir $@).$(2) \
  93. -o $(dir $@)$(1) $(START_FILE-$(notdir $@)) \
  94. --whole-archive $(firstword $^) --no-whole-archive \
  95. $(LIBS-$(notdir $@)) $(LIBGCC) $(END_FILE-$(notdir $@))
  96. $(Q)$(LN) -sf $(1) $@.$(2)
  97. $(Q)$(LN) -sf $(1) $@
  98. endef
  99. CFLAGS-.os+=$(PICFLAG)
  100. CFLAGS-.oS+=$(PICFLAG) -DSHARED
  101. %.o: %.c ; $(compile.c)
  102. %.os: %.c ; $(compile.c)
  103. %.oS: %.c ; $(compile.c)
  104. %.o: %.S ; $(compile.S)
  105. %.os: %.S ; $(compile.S)
  106. %.oS: %.S ; $(compile.S)
  107. %.o: %.s ; $(compile.S)
  108. %.os: %.s ; $(compile.S)
  109. %.oS: %.s ; $(compile.S)
  110. %.E: %.c ; $(compile.E)
  111. %.E: %.S ; $(compile.E)
  112. $(top_builddir)lib/interp.c:
  113. $(Q)$(INSTALL) -d $(dir $@)
  114. $(Q)echo "/* Force shared libraries to know about the correct library loader */" > $@
  115. $(Q)echo "#include <features.h>" >> $@
  116. $(Q)echo "#ifdef __HAVE_ELF__" >> $@
  117. $(Q)echo "const char __dl_ldso__[] __attribute__ ((section " \
  118. "(\".interp\"))) =\""$(SHARED_LIB_LOADER_PREFIX)/$(UCLIBC_LDSO)"\";" >> $@
  119. $(Q)echo "#endif" >> $@
  120. $(interp): $(top_builddir)lib/interp.c
  121. $(compile.c)
  122. @$(disp_strip)
  123. $(Q)$(STRIPTOOL) -x -R .note -R .comment $@
  124. $(ldso):
  125. @cd $(top_builddir); $(MAKE) lib/$(patsubst %.$(MAJOR_VERSION),%,$(notdir $@))
  126. $(libc):
  127. @cd $(top_builddir); $(MAKE) lib/$(patsubst %.$(MAJOR_VERSION),%,$(notdir $@))
  128. $(headers_dep):
  129. @cd $(top_builddir); $(MAKE) headers
  130. #ifeq ($(HAVE_ELF),y)
  131. CRT=crt1
  132. #else
  133. #CRT=crt0
  134. #endif
  135. ifeq ($(HAVE_SHARED),y)
  136. CRTS=$(top_builddir)lib/$(CRT).o $(top_builddir)lib/S$(CRT).o
  137. else
  138. CRTS=$(top_builddir)lib/$(CRT).o
  139. endif
  140. $(top_builddir)lib/$(CRT).o: $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/$(CRT).S
  141. $(Q)$(INSTALL) -d $(dir $@)
  142. $(compile.S) -DL_$(patsubst %$(suffix $(notdir $@)),%,$(notdir $@))
  143. @$(disp_strip)
  144. $(Q)$(STRIPTOOL) -x -R .note -R .comment $@
  145. $(top_builddir)lib/S$(CRT).o: $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/$(CRT).S
  146. $(Q)$(INSTALL) -d $(dir $@)
  147. $(compile.S) $(PIEFLAG) -DL_$(patsubst %$(suffix $(notdir $@)),%,$(notdir $@))
  148. @$(disp_strip)
  149. $(Q)$(STRIPTOOL) -x -R .note -R .comment $@
  150. CTOR_TARGETS=$(top_builddir)lib/crti.o $(top_builddir)lib/crtn.o
  151. ifeq ($(UCLIBC_CTOR_DTOR),y)
  152. $(CTOR_TARGETS): $(top_builddir)lib/%.o : $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/%.S
  153. $(Q)$(INSTALL) -d $(dir $@)
  154. $(compile.S) $(PICFLAG) $(SSP_DISABLE_FLAGS)
  155. else
  156. $(CTOR_TARGETS):
  157. $(Q)$(INSTALL) -d $(dir $@)
  158. $(do_ar)
  159. endif
  160. $(crt-y): $(CRTS) $(CTOR_TARGETS)
  161. $(top_builddir)lib/$(NONSHARED_LIBNAME): $(libc-nonshared-y)
  162. $(Q)$(INSTALL) -d $(dir $@)
  163. $(do_ar)
  164. .PHONY: dummy create
  165. clean: objclean-y headers_clean-y
  166. objclean-y: $(objclean-y)
  167. headers_clean-y: $(headers_clean-y)
  168. .PHONY: \
  169. all check clean distclean test \
  170. config dist menuconfig oldconfig release \
  171. subdirs utils