Makerules 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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. interp-y: $(interp)
  28. pre-y: $(interp) $(ld-uClibc-y)
  29. libc-y: pre-y $(libc) $(crt-y) $(top_builddir)lib/$(NONSHARED_LIBNAME)
  30. ldso-dep =
  31. libc-so-dep = $(top_builddir)lib/libc.so $(interp)
  32. lib-so-y = $(libc-so-dep) $(lib-so-y)
  33. lib-a-y = $(crt-y) $(lib-a-y)
  34. ifneq ($(findstring s,$(MAKEFLAGS)),)
  35. DISP := sil
  36. Q := @
  37. else
  38. ifneq ($(V)$(VERBOSE),)
  39. DISP := ver
  40. Q :=
  41. else
  42. DISP := pur
  43. Q := @
  44. endif
  45. endif
  46. show_objs = $(subst ../,,$@)
  47. pur_disp_compile.c = echo " "CC $(show_objs)
  48. pur_disp_compile.S = echo " "AS $(show_objs)
  49. pur_disp_compile.m = $(pur_disp_compile.c)
  50. pur_disp_compile-m = echo " "CC-m $(show_objs)
  51. pur_disp_strip = echo " "STRIP $(STRIP_FLAGS) $@
  52. pur_disp_ar = echo " "AR $(ARFLAGS) $@
  53. pur_disp_ld = echo " "LD $(1)
  54. sil_disp_compile.c = true
  55. sil_disp_compile.S = true
  56. sil_disp_compile.m = true
  57. sil_disp_compile-m = true
  58. sil_disp_strip = true
  59. sil_disp_ar = true
  60. sil_disp_ld = true
  61. ver_disp_compile.c = echo $(cmd_compile.c)
  62. ver_disp_compile.S = echo $(cmd_compile.S)
  63. ver_disp_compile.m = echo $(cmd_compile.m)
  64. ver_disp_compile-m = echo $(cmd_compile-m)
  65. ver_disp_strip = echo $(cmd_strip)
  66. ver_disp_ar = echo $(cmd_ar)
  67. ver_disp_ld =
  68. disp_compile.c = $($(DISP)_disp_compile.c)
  69. disp_compile.S = $($(DISP)_disp_compile.S)
  70. disp_compile.m = $($(DISP)_disp_compile.m)
  71. disp_compile-m = $($(DISP)_disp_compile-m)
  72. disp_strip = $($(DISP)_disp_strip)
  73. disp_ar = $($(DISP)_disp_ar)
  74. disp_ld = $($(DISP)_disp_ld)
  75. cmd_compile.c = $(CC) -c $< -o $@ $(CFLAGS) $(ARCH_CFLAGS) $(CFLAGS-$(suffix $@)) $(CFLAGS-$(notdir $(^D))) $(CFLAGS-$(subst $(top_srcdir),,$(dir $<))) $(CFLAGS-$(notdir $<)) $(CFLAGS-$(notdir $@))
  76. cmd_compile.S = $(cmd_compile.c) $(ASFLAGS) $(ARCH_ASFLAGS) $(ASFLAGS-$(suffix $@)) $(ASFLAGS-$(notdir $<)) $(ASFLAGS-$(notdir $@))
  77. cmd_compile.m = $(cmd_compile.c) -DL_$(patsubst %$(suffix $(notdir $@)),%,$(notdir $@))
  78. cmd_compile-m = $(CC) $^ -c -o $@ $(CFLAGS) $(ARCH_CFLAGS) $(CFLAGS-$(suffix $@)) $(CFLAGS-$(notdir $@)) $(CFLAGS-multi-y)
  79. cmd_strip = $(STRIPTOOL) $(STRIP_FLAGS) $^
  80. cmd_ar = $(AR) $(ARFLAGS) $@ $^
  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. %.o: %.s ; $(compile.S)
  107. %.os: %.s ; $(compile.S)
  108. %.E: %.c ; $(compile.E)
  109. %.E: %.S ; $(compile.E)
  110. #ifeq ($(HAVE_ELF),y)
  111. CRT=crt1
  112. #else
  113. #CRT=crt0
  114. #endif
  115. ifeq ($(HAVE_SHARED),y)
  116. CRTS=$(top_builddir)lib/$(CRT).o $(top_builddir)lib/S$(CRT).o
  117. else
  118. CRTS=$(top_builddir)lib/$(CRT).o
  119. endif
  120. $(top_builddir)lib/$(CRT).o: $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/$(CRT).S
  121. $(Q)$(INSTALL) -d $(dir $@)
  122. $(compile.S) -DL_$(patsubst %$(suffix $(notdir $@)),%,$(notdir $@))
  123. @$(disp_strip)
  124. $(Q)$(STRIPTOOL) -x -R .note -R .comment $@
  125. $(top_builddir)lib/S$(CRT).o: $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/$(CRT).S
  126. $(Q)$(INSTALL) -d $(dir $@)
  127. $(compile.S) $(PIEFLAG) -DL_$(patsubst %$(suffix $(notdir $@)),%,$(notdir $@))
  128. @$(disp_strip)
  129. $(Q)$(STRIPTOOL) -x -R .note -R .comment $@
  130. CTOR_TARGETS=$(top_builddir)lib/crti.o $(top_builddir)lib/crtn.o
  131. ifeq ($(UCLIBC_CTOR_DTOR),y)
  132. $(top_builddir)lib/crti.o: $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/crti.S
  133. $(Q)$(INSTALL) -d $(dir $@)
  134. $(compile.S) $(PICFLAG) $(SSP_DISABLE_FLAGS)
  135. $(top_builddir)lib/crtn.o: $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/crtn.S
  136. $(Q)$(INSTALL) -d $(dir $@)
  137. $(compile.S) $(PICFLAG) $(SSP_DISABLE_FLAGS)
  138. else
  139. $(CTOR_TARGETS):
  140. $(Q)$(INSTALL) -d $(top_builddir)lib
  141. $(do_ar)
  142. endif
  143. $(crt-y): $(CRTS) $(CTOR_TARGETS)
  144. $(top_builddir)lib/$(NONSHARED_LIBNAME): $(libc-nonshared-y)
  145. $(Q)$(INSTALL) -d $(dir $@)
  146. $(do_ar)
  147. .PHONY: dummy create
  148. clean: objclean-y headers_clean-y
  149. objclean-y: $(objclean-y)
  150. headers_clean-y: $(headers_clean-y)
  151. .PHONY: \
  152. all check clean distclean test \
  153. config dist menuconfig oldconfig release \
  154. subdirs utils