Makerules 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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
  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. objs: shared_objs ar_objs
  10. else
  11. .LIBPATTERNS: "lib%.a"
  12. libs: lib-a-y
  13. objs: ar_objs
  14. endif
  15. shared_objs-y = $(lduClibc-so-y) $(libc-so-y) $(libc-nonshared-y) $(libdl-so-y)
  16. shared_objs-y += $(libcrypt-so-y) $(libintl-so-y) $(libm-so-y) $(libnsl-so-y) $(libpthread-so-y)
  17. shared_objs-y += $(libresolv-so-y) $(librt-so-y) $(libutil-so-y)
  18. ar_objs-y = $(libc-a-y) $(libcrypt-a-y) $(libintl-a-y) $(libm-a-y) $(libnsl-a-y)
  19. ar_objs-y += $(libpthread-a-y) $(libresolv-a-y) $(librt-a-y) $(libutil-a-y)
  20. shared_objs: $(shared_objs-y)
  21. ifeq ($(DOPIC),y)
  22. ar_objs: $(ar_objs-y:.o=.os)
  23. else
  24. ar_objs: $(ar_objs-y)
  25. endif
  26. headers-y: $(headers-y)
  27. ld-uClibc-y: $(ld-uClibc-y)
  28. interp-y: $(interp)
  29. pre-y: interp-y ld-uClibc-y
  30. libc-y: pre-y $(libc) crt-y
  31. lib-a-y: headers_root crt-y $(lib-a-y)
  32. lib-so-y: libc-y $(lib-so-y)
  33. headers_root:
  34. @cd $(top_builddir); $(MAKE) headers
  35. ifneq ($(findstring s,$(MAKEFLAGS)),)
  36. DISP := sil
  37. Q := @
  38. else
  39. ifneq ($(V)$(VERBOSE),)
  40. DISP := ver
  41. Q :=
  42. else
  43. DISP := pur
  44. Q := @
  45. endif
  46. endif
  47. show_objs = $(subst ../,,$@)
  48. pur_disp_compile.c = echo " "CC $(show_objs)
  49. pur_disp_compile.S = echo " "AS $(show_objs)
  50. pur_disp_compile.m = $(pur_disp_compile.c)
  51. pur_disp_compile-m = echo " "CC-m $(show_objs)
  52. pur_disp_strip = echo " "STRIP $(STRIP_FLAGS) $@:*
  53. pur_disp_ar = echo " "AR $(ARFLAGS) $@
  54. pur_disp_ld = echo " "LD $(1)
  55. sil_disp_compile.c = true
  56. sil_disp_compile.S = true
  57. sil_disp_compile.m = true
  58. sil_disp_compile-m = true
  59. sil_disp_strip = true
  60. sil_disp_ar = true
  61. sil_disp_ld = true
  62. ver_disp_compile.c = echo $(cmd_compile.c)
  63. ver_disp_compile.S = echo $(cmd_compile.S)
  64. ver_disp_compile.m = echo $(cmd_compile.m)
  65. ver_disp_compile-m = echo $(cmd_compile-m)
  66. ver_disp_strip = echo $(cmd_strip)
  67. ver_disp_ar = echo $(cmd_ar)
  68. ver_disp_ld =
  69. disp_compile.c = $($(DISP)_disp_compile.c)
  70. disp_compile.S = $($(DISP)_disp_compile.S)
  71. disp_compile.m = $($(DISP)_disp_compile.m)
  72. disp_compile-m = $($(DISP)_disp_compile-m)
  73. disp_strip = $($(DISP)_disp_strip)
  74. disp_ar = $($(DISP)_disp_ar)
  75. disp_ld = $($(DISP)_disp_ld)
  76. cmd_compile.c = $(CC) -c $< -o $@ $(CFLAGS) $(ARCH_CFLAGS) $(CFLAGS-$(suffix $@)) $(CFLAGS-$(notdir $(^D))) $(CFLAGS-$(subst $(top_srcdir),,$(dir $<))) $(CFLAGS-$(notdir $<)) $(CFLAGS-$(notdir $@))
  77. cmd_compile.S = $(cmd_compile.c) $(ASFLAGS) $(ARCH_ASFLAGS) $(ASFLAGS-$(suffix $@)) $(ASFLAGS-$(notdir $<)) $(ASFLAGS-$(notdir $@))
  78. cmd_compile.m = $(cmd_compile.c) -DL_$(patsubst %$(suffix $(notdir $@)),%,$(notdir $@))
  79. cmd_compile-m = $(CC) $^ -c -o $@ $(CFLAGS) $(ARCH_CFLAGS) $(CFLAGS-$(suffix $@)) $(CFLAGS-$(notdir $@)) $(CFLAGS-multi-y)
  80. cmd_strip = $(STRIPTOOL) $(STRIP_FLAGS) $^
  81. cmd_ar = $(AR) $(ARFLAGS) $@ $^
  82. compile.c = @$(disp_compile.c) ; $(cmd_compile.c)
  83. compile.E = $(cmd_compile.c:-c=-E)
  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. %.o: %.s ; $(compile.S)
  108. %.os: %.s ; $(compile.S)
  109. %.E: %.c ; $(compile.E)
  110. %.E: %.S ; $(compile.E)
  111. #ifeq ($(HAVE_ELF),y)
  112. CRT=crt1
  113. #else
  114. #CRT=crt0
  115. #endif
  116. ifeq ($(HAVE_SHARED),y)
  117. CRTS=$(top_builddir)lib/$(CRT).o $(top_builddir)lib/S$(CRT).o
  118. else
  119. CRTS=$(top_builddir)lib/$(CRT).o
  120. endif
  121. $(top_builddir)lib/$(CRT).o: $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/$(CRT).S
  122. $(Q)$(INSTALL) -d $(dir $@)
  123. $(compile.S) -DL_$(patsubst %$(suffix $(notdir $@)),%,$(notdir $@))
  124. @$(disp_strip) $(show_objs)
  125. $(Q)$(STRIPTOOL) -x -R .note -R .comment $@
  126. $(top_builddir)lib/S$(CRT).o: $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/$(CRT).S
  127. $(Q)$(INSTALL) -d $(dir $@)
  128. $(compile.S) $(PIEFLAG) -DL_$(patsubst %$(suffix $(notdir $@)),%,$(notdir $@))
  129. @$(disp_strip) $(show_objs)
  130. $(Q)$(STRIPTOOL) -x -R .note -R .comment $@
  131. CTOR_TARGETS=$(top_builddir)lib/crti.o $(top_builddir)lib/crtn.o
  132. ifeq ($(UCLIBC_CTOR_DTOR),y)
  133. $(top_builddir)lib/crti.o: $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/crti.S
  134. $(Q)$(INSTALL) -d $(dir $@)
  135. $(compile.S) $(PICFLAG) $(SSP_DISABLE_FLAGS)
  136. $(top_builddir)lib/crtn.o: $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/crtn.S
  137. $(Q)$(INSTALL) -d $(dir $@)
  138. $(compile.S) $(PICFLAG) $(SSP_DISABLE_FLAGS)
  139. else
  140. $(CTOR_TARGETS):
  141. $(Q)$(INSTALL) -d $(top_builddir)lib
  142. $(do_ar)
  143. endif
  144. crt-y: $(crt-y)
  145. $(crt-y): $(CRTS) $(CTOR_TARGETS)
  146. $(top_builddir)lib/$(NONSHARED_LIBNAME): $(libc-nonshared-y)
  147. $(Q)$(INSTALL) -d $(dir $@)
  148. $(do_ar)
  149. .PHONY: dummy create
  150. clean: objclean-y headers_clean-y
  151. objclean-y: $(objclean-y)
  152. headers_clean-y: $(headers_clean-y)