Makerules 6.0 KB

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