Makerules 6.4 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 = $(cmd_compile.c:-c=-S)
  84. compile.S = @$(disp_compile.S) ; $(cmd_compile.S)
  85. compile.m = @$(disp_compile.m) ; $(cmd_compile.m)
  86. compile-m = @$(disp_compile-m) ; $(cmd_compile-m)
  87. do_strip = @$(disp_strip) ; $(cmd_strip)
  88. do_ar = @$(disp_ar) ; $(cmd_ar)
  89. define link.so
  90. $(Q)$(INSTALL) -d $(dir $@)
  91. $(Q)$(RM) $@ $@.$(2) $(dir $@)$(1)
  92. @$(disp_ld)
  93. $(Q)$(LD) $(LDFLAGS-$(notdir $@)) -soname=$(notdir $@).$(2) \
  94. -o $(dir $@)$(1) $(START_FILE-$(notdir $@)) \
  95. --whole-archive $(firstword $^) --no-whole-archive \
  96. $(LIBS-$(notdir $@)) $(LIBGCC) $(END_FILE-$(notdir $@))
  97. $(Q)$(LN) -sf $(1) $@.$(2)
  98. $(Q)$(LN) -sf $(1) $@
  99. endef
  100. CFLAGS-.os+=$(PICFLAG)
  101. CFLAGS-.oS+=$(PICFLAG) -DSHARED
  102. %.o: %.c ; $(compile.c)
  103. %.os: %.c ; $(compile.c)
  104. %.oS: %.c ; $(compile.c)
  105. %.o: %.S ; $(compile.S)
  106. %.os: %.S ; $(compile.S)
  107. %.oS: %.S ; $(compile.S)
  108. %.o: %.s ; $(compile.S)
  109. %.os: %.s ; $(compile.S)
  110. %.oS: %.s ; $(compile.S)
  111. %.E: %.c ; $(compile.E)
  112. %.E: %.S ; $(compile.E)
  113. %.s: %.c ; $(compile.s)
  114. %.s: %.S ; $(compile.s)
  115. $(top_builddir)lib/interp.c:
  116. $(Q)$(INSTALL) -d $(dir $@)
  117. $(Q)echo "/* Force shared libraries to know about the correct library loader */" > $@
  118. $(Q)echo "#include <features.h>" >> $@
  119. $(Q)echo "#ifdef __HAVE_ELF__" >> $@
  120. $(Q)echo "const char __dl_ldso__[] __attribute__ ((section " \
  121. "(\".interp\"))) =\""$(SHARED_LIB_LOADER_PREFIX)/$(UCLIBC_LDSO)"\";" >> $@
  122. $(Q)echo "#endif" >> $@
  123. $(interp): $(top_builddir)lib/interp.c
  124. $(compile.c)
  125. $(Q)$(STRIPTOOL) -x -R .note -R .comment $@
  126. $(ldso):
  127. @cd $(top_builddir); $(MAKE) lib/$(patsubst %.$(MAJOR_VERSION),%,$(notdir $@))
  128. $(libc):
  129. @cd $(top_builddir); $(MAKE) lib/$(patsubst %.$(MAJOR_VERSION),%,$(notdir $@))
  130. $(headers_dep):
  131. @cd $(top_builddir); $(MAKE) headers
  132. #ifeq ($(HAVE_ELF),y)
  133. CRT=crt1
  134. #else
  135. #CRT=crt0
  136. #endif
  137. ifeq ($(HAVE_SHARED),y)
  138. CRTS=$(top_builddir)lib/$(CRT).o $(top_builddir)lib/S$(CRT).o
  139. else
  140. CRTS=$(top_builddir)lib/$(CRT).o
  141. endif
  142. $(top_builddir)lib/$(CRT).o: $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/$(CRT).S
  143. $(Q)$(INSTALL) -d $(dir $@)
  144. $(compile.S) -DL_$(patsubst %$(suffix $(notdir $@)),%,$(notdir $@))
  145. $(Q)$(STRIPTOOL) -x -R .note -R .comment $@
  146. $(top_builddir)lib/S$(CRT).o: $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/$(CRT).S
  147. $(Q)$(INSTALL) -d $(dir $@)
  148. $(compile.S) $(PIEFLAG) -DL_$(patsubst %$(suffix $(notdir $@)),%,$(notdir $@))
  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