Add strlcat/wcslcat testcase.
[glibc.git] / nss / Makefile
blob32764b74c0188e55d4f8d46644aa265fbd3f530e
1 # Copyright (C) 1996-2023 Free Software Foundation, Inc.
2 # This file is part of the GNU C Library.
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.
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.
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 # <https://www.gnu.org/licenses/>.
19 # Makefile for name service switch.
21 subdir := nss
23 include ../Makeconfig
25 headers := \
26 nss.h \
27 # headers
29 # This is the trivial part which goes into libc itself.
30 routines = \
31 $(addsuffix -lookup,$(databases)) \
32 compat-lookup \
33 digits_dots \
34 getnssent \
35 getnssent_r \
36 nss_action \
37 nss_action_parse \
38 nss_database \
39 nss_fgetent_r \
40 nss_files_data \
41 nss_files_fopen \
42 nss_files_functions \
43 nss_hash \
44 nss_module \
45 nss_parse_line_result \
46 nss_readline \
47 nsswitch \
48 rewrite_field \
49 valid_field \
50 valid_list_field \
51 # routines
53 # These are the databases that go through nss dispatch.
54 # Caution: if you add a database here, you must add its real name
55 # in databases.def, too.
56 databases = \
57 alias \
58 ethers \
59 grp \
60 hosts \
61 netgrp \
62 network \
63 proto \
64 pwd \
65 service \
66 sgrp \
67 spwd \
68 # databases
70 ifneq (,$(filter sunrpc,$(subdirs)))
71 databases += key rpc
72 have-sunrpc := 1
73 else
74 have-sunrpc := 0
75 endif
76 CPPFLAGS-getent.c = -DHAVE_SUNRPC=$(have-sunrpc)
78 others := getent makedb
79 install-bin := getent makedb
80 makedb-modules = xmalloc hash-string
81 others-extras = $(makedb-modules)
82 extra-objs += $(makedb-modules:=.o)
84 tests-static = tst-field
85 tests-internal = tst-field
87 tests := \
88 bug17079 \
89 test-digits-dots \
90 test-netdb \
91 tst-nss-getpwent \
92 tst-nss-hash \
93 tst-nss-test1 \
94 tst-nss-test2 \
95 tst-nss-test4 \
96 tst-nss-test5 \
97 tst-nss-test_errno \
98 # tests
100 xtests = bug-erange
102 tests-container := \
103 tst-nss-compat1 \
104 tst-nss-db-endgrent \
105 tst-nss-db-endpwent \
106 tst-nss-files-hosts-long \
107 tst-nss-files-hosts-v4mapped \
108 tst-nss-gai-actions \
109 tst-nss-gai-hv2-canonname \
110 tst-nss-test3 \
111 tst-reload1 \
112 tst-reload2 \
113 # tests-container
115 # Tests which need libdl
116 ifeq (yes,$(build-shared))
117 tests += tst-nss-files-hosts-erange
118 tests += tst-nss-files-hosts-multi
119 tests += tst-nss-files-hosts-getent
120 tests += tst-nss-files-alias-leak
121 tests += tst-nss-files-alias-truncated
122 endif
124 # If we have a thread library then we can test cancellation against
125 # some routines like getpwuid_r.
126 ifeq (yes,$(have-thread-library))
127 tests += tst-cancel-getpwuid_r
128 endif
130 # Specify rules for the nss_* modules. We have some services.
131 services := files db compat
133 extra-libs = $(services:%=libnss_%)
134 # These libraries will be built in the `others' pass rather than
135 # the `lib' pass, because they depend on libc.so being built already.
136 extra-libs-others = $(extra-libs)
138 # The sources are found in the appropriate subdir.
139 subdir-dirs = $(services:%=nss_%)
140 vpath %.c $(subdir-dirs) ../locale/programs ../intl
143 routines += \
144 $(addprefix files-, $(filter-out key, $(databases))) \
145 files-init \
146 files-initgroups \
147 # routines
149 # Build only an empty shared libnss_files.
150 libnss_files-inhibit-o = $(filter-out .os,$(object-suffixes))
152 # Pretend that libnss_files.so is a linker script, so that the symbolic link
153 # is not installed.
154 install-lib-ldscripts = libnss_files.so
155 $(inst_libdir)/libnss_files.so:
157 libnss_db-dbs := $(addprefix db-,\
158 $(filter-out hosts network key alias,\
159 $(databases))) \
160 db-initgroups
161 libnss_db-routines := $(libnss_db-dbs) db-open db-init hash-string
162 generated += $(filter-out db-alias.c db-netgrp.c, \
163 $(addsuffix .c,$(libnss_db-dbs)))
165 libnss_compat-routines := $(addprefix compat-,grp pwd spwd initgroups) \
166 nisdomain
168 install-others += $(inst_vardbdir)/Makefile
170 # Build static module into libc if requested
171 libnss_db-inhibit-o = $(filter-out .os,$(object-suffixes))
172 libnss_compat-inhibit-o = $(filter-out .os,$(object-suffixes))
173 ifeq ($(build-static-nss),yes)
174 tests-static += tst-nss-static
175 endif
176 extra-test-objs += nss_test1.os nss_test2.os nss_test_errno.os \
177 nss_test_gai_hv2_canonname.os
179 ifeq ($(run-built-tests),yes)
180 ifneq (no,$(PERL))
181 tests-special += $(objpfx)mtrace-tst-nss-gai-hv2-canonname.out
182 endif
183 endif
185 generated += mtrace-tst-nss-gai-hv2-canonname.out \
186 tst-nss-gai-hv2-canonname.mtrace
188 include ../Rules
190 ifeq (yes,$(have-selinux))
191 LDLIBS-makedb := -lselinux
192 endif
194 libnss-libc = $(common-objpfx)linkobj/libc.so
195 # Target-specific variable setting to link objects using deprecated
196 # RPC interfaces with the version of libc.so that makes them available
197 # for new links:
198 $(services:%=$(objpfx)libnss_%.so): libc-for-link = $(libnss-libc)
200 $(libnss_db-dbs:%=$(objpfx)%.c): $(objpfx)db-%.c: nss_files/files-%.c
201 @rm -f $@.new
202 (echo '#define EXTERN_PARSER';\
203 echo '#define GENERIC "../nss_db/db-XXX.c"';\
204 echo '#include "$<"') > $@.new
205 mv -f $@.new $@
208 $(objpfx)makedb: $(makedb-modules:%=$(objpfx)%.o)
210 $(inst_vardbdir)/Makefile: db-Makefile $(+force)
211 $(do-install)
213 libnss_test1.so-no-z-defs = 1
214 libnss_test2.so-no-z-defs = 1
216 rtld-tests-LDFLAGS += -Wl,--dynamic-list=nss_test.ver
218 libof-nss_test1 = extramodules
219 libof-nss_test2 = extramodules
220 libof-nss_test_errno = extramodules
221 libof-nss_test_gai_hv2_canonname = extramodules
222 $(objpfx)/libnss_test1.so: $(objpfx)nss_test1.os $(link-libc-deps)
223 $(build-module)
224 $(objpfx)/libnss_test2.so: $(objpfx)nss_test2.os $(link-libc-deps)
225 $(build-module)
226 $(objpfx)/libnss_test_errno.so: $(objpfx)nss_test_errno.os $(link-libc-deps)
227 $(build-module)
228 $(objpfx)/libnss_test_gai_hv2_canonname.so: \
229 $(objpfx)nss_test_gai_hv2_canonname.os $(link-libc-deps)
230 $(build-module)
231 $(objpfx)nss_test2.os : nss_test1.c
232 # Use the nss_files suffix for these objects as well.
233 $(objpfx)/libnss_test1.so$(libnss_files.so-version): $(objpfx)/libnss_test1.so
234 $(make-link)
235 $(objpfx)/libnss_test2.so$(libnss_files.so-version): $(objpfx)/libnss_test2.so
236 $(make-link)
237 $(objpfx)/libnss_test_errno.so$(libnss_files.so-version): \
238 $(objpfx)/libnss_test_errno.so
239 $(make-link)
240 $(objpfx)/libnss_test_gai_hv2_canonname.so$(libnss_files.so-version): \
241 $(objpfx)/libnss_test_gai_hv2_canonname.so
242 $(make-link)
243 $(patsubst %,$(objpfx)%.out,$(tests) $(tests-container)) : \
244 $(objpfx)/libnss_test1.so$(libnss_files.so-version) \
245 $(objpfx)/libnss_test2.so$(libnss_files.so-version) \
246 $(objpfx)/libnss_test_errno.so$(libnss_files.so-version) \
247 $(objpfx)/libnss_test_gai_hv2_canonname.so$(libnss_files.so-version)
249 ifeq (yes,$(have-thread-library))
250 $(objpfx)tst-cancel-getpwuid_r: $(shared-thread-library)
251 endif
253 $(objpfx)tst-nss-files-alias-leak.out: $(objpfx)/libnss_files.so
254 $(objpfx)tst-nss-files-alias-truncated.out: $(objpfx)/libnss_files.so
256 tst-nss-gai-hv2-canonname-ENV = \
257 MALLOC_TRACE=$(objpfx)tst-nss-gai-hv2-canonname.mtrace \
258 LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so
259 $(objpfx)mtrace-tst-nss-gai-hv2-canonname.out: \
260 $(objpfx)tst-nss-gai-hv2-canonname.out
261 { test -r $(objpfx)tst-nss-gai-hv2-canonname.mtrace \
262 || ( echo "tst-nss-gai-hv2-canonname.mtrace does not exist"; exit 77; ) \
263 && $(common-objpfx)malloc/mtrace \
264 $(objpfx)tst-nss-gai-hv2-canonname.mtrace; } > $@; \
265 $(evaluate-test)
267 # Disable DT_RUNPATH on NSS tests so that the glibc internal NSS
268 # functions can load testing NSS modules via DT_RPATH.
269 LDFLAGS-tst-nss-test1 = -Wl,--disable-new-dtags
270 LDFLAGS-tst-nss-test2 = -Wl,--disable-new-dtags
271 LDFLAGS-tst-nss-test3 = -Wl,--disable-new-dtags
272 LDFLAGS-tst-nss-test4 = -Wl,--disable-new-dtags
273 LDFLAGS-tst-nss-test5 = -Wl,--disable-new-dtags
274 LDFLAGS-tst-nss-test_errno = -Wl,--disable-new-dtags
275 LDFLAGS-tst-nss-test_gai_hv2_canonname = -Wl,--disable-new-dtags