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.
9 # Libraries listed in $(extra-libs-noinstall) are built, but not
12 lib
:= $(firstword $(extra-libs-left
))
13 extra-libs-left
:= $(filter-out $(lib
),$(extra-libs-left
))
15 object-suffixes-
$(lib
) := $(filter-out $($(lib
)-inhibit-o
),$(object-suffixes
))
17 ifneq (,$($(lib
)-static-only-routines
))
18 ifneq (,$(filter yes
%,$(build-shared
)$($(lib
).so-version
)))
19 object-suffixes-
$(lib
) += $(filter-out $($(lib
)-inhibit-o
),.oS
)
23 ifneq (,$(object-suffixes-
$(lib
)))
25 # Make sure these are simply-expanded variables before we append to them,
26 # since we want the expressions we append to be expanded right now.
27 install-lib
:= $(install-lib
)
28 extra-objs
:= $(extra-objs
)
30 # The modules that go in $(lib).
31 all-
$(lib
)-routines
:= $($(lib
)-routines
) $($(lib
)-sysdep_routines
)
33 # Add each flavor of library to the lists of things to build and install.
34 ifeq (,$(filter $(lib
), $(extra-libs-noinstall
)))
35 install-lib
+= $(foreach o
,$(object-suffixes-
$(lib
)),$(lib
:lib
%=$(libtype
$o)))
37 extra-objs
+= $(foreach o
,$(filter-out .os .oS
,$(object-suffixes-
$(lib
))),\
38 $(patsubst %,%$o,$(filter-out \
39 $($(lib
)-shared-only-routines
),\
40 $(all-
$(lib
)-routines
))))
41 ifneq (,$(filter .os
,$(object-suffixes-
$(lib
))))
42 extra-objs
+= $(patsubst %,%.os
,$(filter-out $($(lib
)-static-only-routines
),\
43 $(all-
$(lib
)-routines
)))
45 ifneq (,$(filter .oS
,$(object-suffixes-
$(lib
))))
46 extra-objs
+= $(patsubst %,%.oS
,$(filter $($(lib
)-static-only-routines
),\
47 $(all-
$(lib
)-routines
)))
49 alltypes-
$(lib
) := $(foreach o
,$(object-suffixes-
$(lib
)),\
50 $(objpfx
)$(patsubst %,$(libtype
$o),\
53 ifeq (,$(filter $(lib
),$(extra-libs-others
)))
54 lib-noranlib
: $(alltypes-
$(lib
))
55 ifeq (yes
,$(build-shared
))
56 lib-noranlib
: $(objpfx
)$(lib
).so
$($(lib
).so-version
)
59 others
: $(alltypes-
$(lib
))
62 # The linked shared library is never a dependent of lib-noranlib,
63 # because linking it will depend on libc.so already being built.
64 ifneq (,$(filter .os
,$(object-suffixes-
$(lib
))))
65 others
: $(objpfx
)$(lib
).so
$($(lib
).so-version
)
69 # Use o-iterator.mk to generate a rule for each flavor of library.
70 ifneq (,$(filter-out .os .oS
,$(object-suffixes-
$(lib
))))
71 define o-iterator-doit
72 $(objpfx
)$(patsubst %,$(libtype
$o),$(lib
:lib
%=%)): \
73 $(patsubst %,$(objpfx
)%$o,\
74 $(filter-out $($(lib
)-shared-only-routines
),\
75 $(all-
$(lib
)-routines
))); \
78 object-suffixes-left
= $(filter-out .os .oS
,$(object-suffixes-
$(lib
)))
79 include $(patsubst %,$(..
)o-iterator.mk
,$(object-suffixes-left
))
82 ifneq (,$(filter .os
,$(object-suffixes-
$(lib
))))
83 $(objpfx
)$(patsubst %,$(libtype.os
),$(lib
:lib
%=%)): \
84 $(patsubst %,$(objpfx
)%.os
,\
85 $(filter-out $($(lib
)-static-only-routines
),\
86 $(all-
$(lib
)-routines
)))
90 ifneq (,$(filter .oS
,$(object-suffixes-
$(lib
))))
91 $(objpfx
)$(patsubst %,$(libtype.oS
),$(lib
:lib
%=%)): \
92 $(patsubst %,$(objpfx
)%.oS
,\
93 $(filter $($(lib
)-static-only-routines
),\
94 $(all-
$(lib
)-routines
)))
98 ifeq ($(build-shared
),yes
)
99 # Add the version script to the dependencies of the shared library.
100 $(objpfx
)$(lib
).so
: $(firstword $($(lib
)-map
) \
101 $(addprefix $(common-objpfx
), \
102 $(filter $(lib
).map
, \
108 # This will define `libof-ROUTINE := LIB' for each of the routines.
109 cpp-srcs-left
:= $($(lib
)-routines
) $($(lib
)-sysdep_routines
)
110 ifneq (,$(cpp-srcs-left
))
111 include $(patsubst %,$(..
)libof-iterator.mk
,$(cpp-srcs-left
))