extra-lib.mk 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. # This file is included several times in a row, once
  2. # for each element of $(extra-libs). $(extra-libs-left)
  3. # is initialized first to $(extra-libs) so that with each
  4. # inclusion, we advance $(lib) to the next library name (e.g. libfoo).
  5. # The variable $($(lib)-routines) defines the list of modules
  6. # to be included in that library. A sysdep Makefile can add to
  7. # $(lib)-sysdep_routines to include additional modules.
  8. #
  9. # Libraries listed in $(extra-libs-noinstall) are built, but not
  10. # installed.
  11. lib := $(firstword $(extra-libs-left))
  12. extra-libs-left := $(filter-out $(lib),$(extra-libs-left))
  13. object-suffixes-$(lib) := $(filter-out $($(lib)-inhibit-o),$(object-suffixes))
  14. ifneq (,$($(lib)-static-only-routines))
  15. ifneq (,$(filter yes%,$(build-shared)$($(lib).so-version)))
  16. object-suffixes-$(lib) += $(filter-out $($(lib)-inhibit-o),.oS)
  17. endif
  18. endif
  19. ifneq (,$(object-suffixes-$(lib)))
  20. # Make sure these are simply-expanded variables before we append to them,
  21. # since we want the expressions we append to be expanded right now.
  22. install-lib := $(install-lib)
  23. extra-objs := $(extra-objs)
  24. # The modules that go in $(lib).
  25. all-$(lib)-routines := $($(lib)-routines) $($(lib)-sysdep_routines)
  26. # Add each flavor of library to the lists of things to build and install.
  27. ifeq (,$(filter $(lib), $(extra-libs-noinstall)))
  28. install-lib += $(foreach o,$(object-suffixes-$(lib)),$(lib:lib%=$(libtype$o)))
  29. endif
  30. extra-objs += $(foreach o,$(filter-out .os .oS,$(object-suffixes-$(lib))),\
  31. $(patsubst %,%$o,$(filter-out \
  32. $($(lib)-shared-only-routines),\
  33. $(all-$(lib)-routines))))
  34. ifneq (,$(filter .os,$(object-suffixes-$(lib))))
  35. extra-objs += $(patsubst %,%.os,$(filter-out $($(lib)-static-only-routines),\
  36. $(all-$(lib)-routines)))
  37. endif
  38. ifneq (,$(filter .oS,$(object-suffixes-$(lib))))
  39. extra-objs += $(patsubst %,%.oS,$(filter $($(lib)-static-only-routines),\
  40. $(all-$(lib)-routines)))
  41. endif
  42. alltypes-$(lib) := $(foreach o,$(object-suffixes-$(lib)),\
  43. $(objpfx)$(patsubst %,$(libtype$o),\
  44. $(lib:lib%=%)))
  45. ifeq (,$(filter $(lib),$(extra-libs-others)))
  46. lib-noranlib: $(alltypes-$(lib))
  47. ifeq (yes,$(build-shared))
  48. lib-noranlib: $(objpfx)$(lib).so$($(lib).so-version)
  49. endif
  50. else
  51. others: $(alltypes-$(lib))
  52. endif
  53. # The linked shared library is never a dependent of lib-noranlib,
  54. # because linking it will depend on libc.so already being built.
  55. ifneq (,$(filter .os,$(object-suffixes-$(lib))))
  56. others: $(objpfx)$(lib).so$($(lib).so-version)
  57. endif
  58. # Use o-iterator.mk to generate a rule for each flavor of library.
  59. ifneq (,$(filter-out .os .oS,$(object-suffixes-$(lib))))
  60. define o-iterator-doit
  61. $(objpfx)$(patsubst %,$(libtype$o),$(lib:lib%=%)): \
  62. $(patsubst %,$(objpfx)%$o,\
  63. $(filter-out $($(lib)-shared-only-routines),\
  64. $(all-$(lib)-routines))); \
  65. $$(build-extra-lib)
  66. endef
  67. object-suffixes-left = $(filter-out .os .oS,$(object-suffixes-$(lib)))
  68. include $(patsubst %,$(..)o-iterator.mk,$(object-suffixes-left))
  69. endif
  70. ifneq (,$(filter .os,$(object-suffixes-$(lib))))
  71. $(objpfx)$(patsubst %,$(libtype.os),$(lib:lib%=%)): \
  72. $(patsubst %,$(objpfx)%.os,\
  73. $(filter-out $($(lib)-static-only-routines),\
  74. $(all-$(lib)-routines)))
  75. $(build-extra-lib)
  76. endif
  77. ifneq (,$(filter .oS,$(object-suffixes-$(lib))))
  78. $(objpfx)$(patsubst %,$(libtype.oS),$(lib:lib%=%)): \
  79. $(patsubst %,$(objpfx)%.oS,\
  80. $(filter $($(lib)-static-only-routines),\
  81. $(all-$(lib)-routines)))
  82. $(build-extra-lib)
  83. endif
  84. ifeq ($(build-shared),yes)
  85. # Add the version script to the dependencies of the shared library.
  86. $(objpfx)$(lib).so: $(firstword $($(lib)-map) \
  87. $(addprefix $(common-objpfx), \
  88. $(filter $(lib).map, \
  89. $(version-maps))))
  90. endif
  91. endif
  92. # This will define `libof-ROUTINE := LIB' for each of the routines.
  93. cpp-srcs-left := $($(lib)-routines) $($(lib)-sysdep_routines)
  94. ifneq (,$(cpp-srcs-left))
  95. include $(patsubst %,$(..)libof-iterator.mk,$(cpp-srcs-left))
  96. endif