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 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 (,$($(lib
)-static-only-routines
))
15 ifneq (,$(filter yes
%,$(build-shared
)$($(lib
).so-version
)))
16 object-suffixes-
$(lib
) += $(filter-out $($(lib
)-inhibit-o
),.oS
)
20 ifneq (,$(object-suffixes-
$(lib
)))
22 # Make sure these are simply-expanded variables before we append to them,
23 # since we want the expressions we append to be expanded right now.
24 install-lib
:= $(install-lib
)
25 extra-objs
:= $(extra-objs
)
27 # The modules that go in $(lib).
28 all-
$(lib
)-routines
:= $($(lib
)-routines
) $($(lib
)-sysdep_routines
)
30 # Add each flavor of library to the lists of things to build and install.
31 install-lib
+= $(foreach o
,$(object-suffixes-
$(lib
)),$(lib
:lib
%=$(libtype
$o)))
32 extra-objs
+= $(foreach o
,$(filter-out .os .oS
,$(object-suffixes-
$(lib
))),\
33 $(patsubst %,%$o,$(filter-out \
34 $($(lib
)-shared-only-routines
),\
35 $(all-
$(lib
)-routines
))))
36 ifneq (,$(filter .os
,$(object-suffixes-
$(lib
))))
37 extra-objs
+= $(patsubst %,%.os
,$(filter-out $($(lib
)-static-only-routines
),\
38 $(all-
$(lib
)-routines
)))
40 ifneq (,$(filter .oS
,$(object-suffixes-
$(lib
))))
41 extra-objs
+= $(patsubst %,%.oS
,$(filter $($(lib
)-static-only-routines
),\
42 $(all-
$(lib
)-routines
)))
44 alltypes-
$(lib
) := $(foreach o
,$(object-suffixes-
$(lib
)),\
45 $(objpfx
)$(patsubst %,$(libtype
$o),\
48 ifeq (,$(filter $(lib
),$(extra-libs-others
)))
49 lib-noranlib
: $(alltypes-
$(lib
))
50 ifeq (yes
,$(build-shared
))
51 lib-noranlib
: $(objpfx
)$(lib
).so
$($(lib
).so-version
)
54 others
: $(alltypes-
$(lib
))
57 # The linked shared library is never a dependent of lib-noranlib,
58 # because linking it will depend on libc.so already being built.
59 ifneq (,$(filter .os
,$(object-suffixes-
$(lib
))))
60 others
: $(objpfx
)$(lib
).so
$($(lib
).so-version
)
64 # Use o-iterator.mk to generate a rule for each flavor of library.
65 ifneq (,$(filter-out .os .oS
,$(object-suffixes-
$(lib
))))
66 define o-iterator-doit
67 $(objpfx
)$(patsubst %,$(libtype
$o),$(lib
:lib
%=%)): \
68 $(patsubst %,$(objpfx
)%$o,\
69 $(filter-out $($(lib
)-shared-only-routines
),\
70 $(all-
$(lib
)-routines
))); \
73 object-suffixes-left
= $(filter-out .os .oS
,$(object-suffixes-
$(lib
)))
74 include $(patsubst %,$(..
)o-iterator.mk
,$(object-suffixes-left
))
77 ifneq (,$(filter .os
,$(object-suffixes-
$(lib
))))
78 $(objpfx
)$(patsubst %,$(libtype.os
),$(lib
:lib
%=%)): \
79 $(patsubst %,$(objpfx
)%.os
,\
80 $(filter-out $($(lib
)-static-only-routines
),\
81 $(all-
$(lib
)-routines
)))
85 ifneq (,$(filter .oS
,$(object-suffixes-
$(lib
))))
86 $(objpfx
)$(patsubst %,$(libtype.oS
),$(lib
:lib
%=%)): \
87 $(patsubst %,$(objpfx
)%.oS
,\
88 $(filter $($(lib
)-static-only-routines
),\
89 $(all-
$(lib
)-routines
)))
93 ifeq ($(build-shared
),yes
)
94 # Add the version script to the dependencies of the shared library.
95 $(objpfx
)$(lib
).so
: $(firstword $($(lib
)-map
) \
96 $(addprefix $(common-objpfx
), \
97 $(filter $(lib
).map
, \
103 # This will define `libof-ROUTINE := LIB' for each of the routines.
104 cpp-srcs-left
:= $($(lib
)-routines
) $($(lib
)-sysdep_routines
)
105 ifneq (,$(cpp-srcs-left
))
106 include $(patsubst %,$(..
)cppflags-iterator.mk
,$(cpp-srcs-left
))
109 CPPFLAGS-
$(lib
) := -DNOT_IN_libc
=1 -DIS_IN_
$(lib
)=1