* sysdeps/i386/dl-machine.h: Include <sysdep.h>.
[glibc.git] / extra-lib.mk
blob5428523e06d13d8025fb827061129068ad35d3fd
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 (,$(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)
32 endif
33 alltypes-$(lib) := $(foreach o,$(object-suffixes-$(lib)),\
34 $(objpfx)$(patsubst %,$(libtype$o),\
35 $(lib:lib%=%)))
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)
41 endif
42 else
43 others: $(alltypes-$(lib))
44 endif
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)
50 endif
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))); \
60 $$(build-extra-lib)
61 endef
62 object-suffixes-left = $(object-suffixes-$(lib):.os=)
63 include $(patsubst %,$(..)o-iterator.mk,$(object-suffixes-$(lib):.os=))
64 endif
66 ifneq (,$(filter .os,$(object-suffixes-$(lib))))
67 $(objpfx)$(patsubst %,$(libtype.os),$(lib:lib%=%)): \
68 $(all-$(lib)-routines:%=$(objpfx)%.os)
69 $(build-extra-lib)
70 endif
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, \
77 $(version-maps))))
78 endif
80 endif
82 # This will define `libof-ROUTINE := LIB' for each of the routines.
83 cpp-srcs-left := $($(lib)-routines) $($(lib)-sysdep_routines)
84 ifneq (,$(cpp-srcs-left))
85 include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left))
86 endif
88 CPPFLAGS-$(lib) := -DNOT_IN_libc=1 -DIS_IN_$(lib)=1