Update.
[jlayton/glibc.git] / extra-lib.mk
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.
7
8 lib := $(firstword $(extra-libs-left))
9 extra-libs-left := $(filter-out $(lib),$(extra-libs-left))
10
11 object-suffixes-$(lib) := $(filter-out $($(lib)-inhibit-o),$(object-suffixes))
12
13 ifneq (,$(object-suffixes-$(lib)))
14
15 # Make sure these are simply-expanded variables before we append to them,
16 # since we want the expressions we append to be expanded right now.
17 install-lib := $(install-lib)
18 extra-objs := $(extra-objs)
19
20 # Add each flavor of library to the lists of things to build and install.
21 install-lib += $(foreach o,$(object-suffixes-$(lib)),$(lib:lib%=$(libtype$o)))
22 extra-objs += $(foreach o,$(object-suffixes-$(lib):.os=),\
23                         $(patsubst %,%$o,$(filter-out \
24                                            $($(lib)-shared-only-routines),\
25                                            $($(lib)-routines))))
26 ifneq (,$(filter .os,$(object-suffixes-$(lib))))
27 extra-objs += $($(lib)-routines:=.os)
28 endif
29 alltypes-$(lib) := $(foreach o,$(object-suffixes-$(lib)),\
30                              $(objpfx)$(patsubst %,$(libtype$o),\
31                              $(lib:lib%=%)))
32
33 ifeq (,$(filter $(lib),$(extra-libs-others)))
34 lib-noranlib: $(alltypes-$(lib))
35 ifeq (yes,$(build-shared))
36 lib-noranlib: $(objpfx)$(lib).so$($(lib).so-version)
37 endif
38 else
39 others: $(alltypes-$(lib))
40 endif
41
42 # The linked shared library is never a dependent of lib-noranlib,
43 # because linking it will depend on libc.so already being built.
44 ifneq (,$(filter .os,$(object-suffixes-$(lib))))
45 others: $(objpfx)$(lib).so$($(lib).so-version)
46 endif
47
48
49 # Use o-iterator.mk to generate a rule for each flavor of library.
50 ifneq (,$(filter-out .os,$(object-suffices-$(lib))))
51 define o-iterator-doit
52 $(objpfx)$(patsubst %,$(libtype$o),$(lib:lib%=%)): \
53   $(patsubst %,$(objpfx)%$o,\
54              $(filter-out $($(lib)-shared-only-routines),\
55                           $($(lib)-routines))); \
56         $$(build-extra-lib)
57 endef
58 object-suffixes-left = $(object-suffixes-$(lib):.os=)
59 include $(patsubst %,$(..)o-iterator.mk,$(object-suffixes-$(lib):.os=))
60 endif
61
62 ifneq (,$(filter .os,$(object-suffixes-$(lib))))
63 $(objpfx)$(patsubst %,$(libtype.os),$(lib:lib%=%)): \
64   $($(lib)-routines:%=$(objpfx)%.os)
65         $(build-extra-lib)
66 endif
67
68 ifeq ($(versioning),yes)
69 # Add the version script to the dependencies of the shared library.
70 $(objpfx)$(lib).so: $(firstword $($(lib)-map) \
71                                 $(addprefix $(common-objpfx), \
72                                             $(filter $(lib).map, \
73                                                      $(version-maps))))
74 endif
75
76 endif