]> git.ipfire.org Git - thirdparty/glibc.git/blob - nss/Makefile
nss: Fix tst-nss-files-alias-truncated for default --as-needed linking
[thirdparty/glibc.git] / nss / Makefile
1 # Copyright (C) 1996-2019 Free Software Foundation, Inc.
2 # This file is part of the GNU C Library.
3
4 # The GNU C Library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
8
9 # The GNU C Library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
13
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with the GNU C Library; if not, see
16 # <http://www.gnu.org/licenses/>.
17
18 #
19 # Makefile for name service switch.
20 #
21 subdir := nss
22
23 include ../Makeconfig
24
25 headers := nss.h
26
27 # This is the trivial part which goes into libc itself.
28 routines = nsswitch getnssent getnssent_r digits_dots \
29 valid_field valid_list_field rewrite_field \
30 $(addsuffix -lookup,$(databases)) \
31 compat-lookup nss_hash
32
33 # These are the databases that go through nss dispatch.
34 # Caution: if you add a database here, you must add its real name
35 # in databases.def, too.
36 databases = proto service hosts network grp pwd ethers \
37 spwd netgrp alias sgrp
38
39 ifneq (,$(filter sunrpc,$(subdirs)))
40 databases += key rpc
41 have-sunrpc := 1
42 else
43 have-sunrpc := 0
44 endif
45 CPPFLAGS-getent.c = -DHAVE_SUNRPC=$(have-sunrpc)
46
47 others := getent makedb
48 install-bin := getent makedb
49 makedb-modules = xmalloc hash-string
50 others-extras = $(makedb-modules)
51 extra-objs += $(makedb-modules:=.o)
52
53 tests-static = tst-field
54 tests-internal = tst-field
55 tests = test-netdb test-digits-dots tst-nss-getpwent bug17079 \
56 tst-nss-test1 \
57 tst-nss-test2 \
58 tst-nss-test4 \
59 tst-nss-test5
60 xtests = bug-erange
61
62 tests-container = \
63 tst-nss-test3 \
64 tst-nss-files-hosts-long
65
66 # Tests which need libdl
67 ifeq (yes,$(build-shared))
68 tests += tst-nss-files-hosts-erange
69 tests += tst-nss-files-hosts-multi
70 tests += tst-nss-files-hosts-getent
71 tests += tst-nss-files-alias-leak
72 tests += tst-nss-files-alias-truncated
73 endif
74
75 # If we have a thread library then we can test cancellation against
76 # some routines like getpwuid_r.
77 ifeq (yes,$(have-thread-library))
78 tests += tst-cancel-getpwuid_r
79 endif
80
81 # Specify rules for the nss_* modules. We have some services.
82 services := files db compat
83
84 extra-libs = $(services:%=libnss_%)
85 # These libraries will be built in the `others' pass rather than
86 # the `lib' pass, because they depend on libc.so being built already.
87 extra-libs-others = $(extra-libs)
88
89 # The sources are found in the appropriate subdir.
90 subdir-dirs = $(services:%=nss_%)
91 vpath %.c $(subdir-dirs) ../locale/programs ../intl
92
93
94 libnss_files-routines := $(addprefix files-,$(databases)) \
95 files-initgroups files-init
96
97 libnss_db-dbs := $(addprefix db-,\
98 $(filter-out hosts network key alias,\
99 $(databases))) \
100 db-initgroups
101 libnss_db-routines := $(libnss_db-dbs) db-open db-init hash-string
102 generated += $(filter-out db-alias.c db-netgrp.c, \
103 $(addsuffix .c,$(libnss_db-dbs)))
104
105 libnss_compat-routines := $(addprefix compat-,grp pwd spwd initgroups) \
106 nisdomain
107
108 install-others += $(inst_vardbdir)/Makefile
109
110 # Build static module into libc if requested
111 libnss_files-inhibit-o = $(filter-out .os,$(object-suffixes))
112 libnss_db-inhibit-o = $(filter-out .os,$(object-suffixes))
113 libnss_compat-inhibit-o = $(filter-out .os,$(object-suffixes))
114 ifeq ($(build-static-nss),yes)
115 routines += $(libnss_files-routines)
116 static-only-routines += $(libnss_files-routines)
117 tests-static += tst-nss-static
118 endif
119 extra-test-objs += nss_test1.os nss_test2.os
120
121 include ../Rules
122
123 ifeq (yes,$(have-selinux))
124 LDLIBS-makedb := -lselinux
125 endif
126
127 libnss-libc = $(common-objpfx)linkobj/libc.so
128 # Target-specific variable setting to link objects using deprecated
129 # RPC interfaces with the version of libc.so that makes them available
130 # for new links:
131 $(services:%=$(objpfx)libnss_%.so): libc-for-link = $(libnss-libc)
132
133 $(objpfx)libnss_db.so: $(objpfx)libnss_files.so
134
135 $(libnss_db-dbs:%=$(objpfx)%.c): $(objpfx)db-%.c: nss_files/files-%.c
136 @rm -f $@.new
137 (echo '#define EXTERN_PARSER';\
138 echo '#define GENERIC "../nss_db/db-XXX.c"';\
139 echo '#include "$<"') > $@.new
140 mv -f $@.new $@
141
142
143 $(objpfx)makedb: $(makedb-modules:%=$(objpfx)%.o)
144
145 $(inst_vardbdir)/Makefile: db-Makefile $(+force)
146 $(do-install)
147
148 libnss_test1.so-no-z-defs = 1
149 libnss_test2.so-no-z-defs = 1
150
151 rtld-tests-LDFLAGS += -Wl,--dynamic-list=nss_test.ver
152
153 libof-nss_test1 = extramodules
154 libof-nss_test2 = extramodules
155 $(objpfx)/libnss_test1.so: $(objpfx)nss_test1.os $(link-libc-deps)
156 $(build-module)
157 $(objpfx)/libnss_test2.so: $(objpfx)nss_test2.os $(link-libc-deps)
158 $(build-module)
159 $(objpfx)nss_test2.os : nss_test1.c
160 ifdef libnss_test1.so-version
161 $(objpfx)/libnss_test1.so$(libnss_test1.so-version): $(objpfx)/libnss_test1.so
162 $(make-link)
163 endif
164 ifdef libnss_test2.so-version
165 $(objpfx)/libnss_test2.so$(libnss_test2.so-version): $(objpfx)/libnss_test2.so
166 $(make-link)
167 endif
168 $(patsubst %,$(objpfx)%.out,$(tests) $(tests-container)) : \
169 $(objpfx)/libnss_test1.so$(libnss_test1.so-version) \
170 $(objpfx)/libnss_test2.so$(libnss_test2.so-version)
171
172 ifeq (yes,$(have-thread-library))
173 $(objpfx)tst-cancel-getpwuid_r: $(shared-thread-library)
174 endif
175
176 $(objpfx)tst-nss-files-hosts-erange: $(libdl)
177 $(objpfx)tst-nss-files-hosts-multi: $(libdl)
178 $(objpfx)tst-nss-files-hosts-getent: $(libdl)
179 $(objpfx)tst-nss-files-alias-leak: $(libdl)
180 $(objpfx)tst-nss-files-alias-leak.out: $(objpfx)/libnss_files.so
181 $(objpfx)tst-nss-files-alias-truncated: $(libdl)
182 $(objpfx)tst-nss-files-alias-truncated.out: $(objpfx)/libnss_files.so