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 override lib
:= $(firstword $(extra-libs-left
))
10 extra-libs-left
:= $(filter-out $(lib
),$(extra-libs-left
))
12 object-suffixes-
$(lib
) := $(filter-out $($(lib
)-inhibit-o
),$(object-suffixes
))
14 ifneq (,$(object-suffixes-
$(lib
)))
16 # Make sure these are simply-expanded variables before we append to them,
17 # since we want the expressions we append to be expanded right now.
18 install-lib
:= $(install-lib
)
19 extra-objs
:= $(extra-objs
)
21 # The modules that go in $(lib).
22 all-
$(lib
)-routines
:= $($(lib
)-routines
) $($(lib
)-sysdep_routines
)
24 # Add each flavor of library to the lists of things to build and install.
25 install-lib
+= $(foreach o
,$(object-suffixes-
$(lib
)),$(lib
:lib
%=$(libtype
$o)))
26 extra-objs
+= $(foreach o
,$(object-suffixes-
$(lib
):.os
=),\
27 $(patsubst %,%$o,$(filter-out \
28 $($(lib
)-shared-only-routines
),\
29 $(all-
$(lib
)-routines
))))
30 ifneq (,$(filter .os
,$(object-suffixes-
$(lib
))))
31 extra-objs
+= $(all-
$(lib
)-routines
:%=%.os
)
33 alltypes-
$(lib
) := $(foreach o
,$(object-suffixes-
$(lib
)),\
34 $(objpfx
)$(patsubst %,$(libtype
$o),\
37 ifeq (,$(filter $(lib
),$(extra-libs-others
)))
38 lib-noranlib
: $(alltypes-
$(lib
))
39 ifeq (yes
,$(build-shared
))
40 lib-noranlib
: $(objpfx
)$(lib
).so
$($(lib
).so-version
)
43 others
: $(alltypes-
$(lib
))
46 # The linked shared library is never a dependent of lib-noranlib,
47 # because linking it will depend on libc.so already being built.
48 ifneq (,$(filter .os
,$(object-suffixes-
$(lib
))))
49 others
: $(objpfx
)$(lib
).so
$($(lib
).so-version
)
53 # Use o-iterator.mk to generate a rule for each flavor of library.
54 ifneq (,$(filter-out .os
,$(object-suffixes-
$(lib
))))
55 define o-iterator-doit
56 $(objpfx
)$(patsubst %,$(libtype
$o),$(lib
:lib
%=%)): \
57 $(patsubst %,$(objpfx
)%$o,\
58 $(filter-out $($(lib
)-shared-only-routines
),\
59 $(all-
$(lib
)-routines
))); \
62 object-suffixes-left
= $(object-suffixes-
$(lib
):.os
=)
63 include $(patsubst %,$(..
)o-iterator.mk
,$(object-suffixes-
$(lib
):.os
=))
66 ifneq (,$(filter .os
,$(object-suffixes-
$(lib
))))
67 $(objpfx
)$(patsubst %,$(libtype.os
),$(lib
:lib
%=%)): \
68 $(all-
$(lib
)-routines
:%=$(objpfx
)%.os
)
72 ifeq ($(versioning
),yes
)
73 # Add the version script to the dependencies of the shared library.
74 $(objpfx
)$(lib
).so
: $(firstword $($(lib
)-map
) \
75 $(addprefix $(common-objpfx
), \
76 $(filter $(lib
).map
, \
82 cpp-srcs-left
= $(lib
)-routines
83 ifneq (,$($(lib
)-routines
))
84 cpp-srcs-left
= $($(lib
)-routines
)
85 include $(patsubst %,$(..
)cppflags-iterator.mk
,$($(lib
)-routines
))
87 ifneq (,$($(lib
)-sysdep_routines
))
88 cpp-srcs-left
= $($(lib
)-sysdep_routines
)
89 include $(patsubst %,$(..
)cppflags-iterator.mk
,$($(lib
)-sysdep_routines
))