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.
29 # This is the trivial part which goes into libc itself.
31 $(addsuffix -lookup
,$(databases
)) \
45 nss_parse_line_result \
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.
70 ifneq (,$(filter sunrpc
,$(subdirs
)))
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
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 \
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
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
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
144 $(addprefix files-
, $(filter-out key
, $(databases
))) \
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
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
,\
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
) \
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
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
)
181 tests-special
+= $(objpfx
)mtrace-tst-nss-gai-hv2-canonname.out
185 generated
+= mtrace-tst-nss-gai-hv2-canonname.out \
186 tst-nss-gai-hv2-canonname.mtrace
190 ifeq (yes
,$(have-selinux
))
191 LDLIBS-makedb
:= -lselinux
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
198 $(services
:%=$(objpfx
)libnss_
%.so
): libc-for-link
= $(libnss-libc
)
200 $(libnss_db-dbs
:%=$(objpfx
)%.c
): $(objpfx
)db-
%.c
: nss_files
/files-
%.c
202 (echo
'#define EXTERN_PARSER';\
203 echo
'#define GENERIC "../nss_db/db-XXX.c"';\
204 echo
'#include "$<"') > $@.new
208 $(objpfx
)makedb
: $(makedb-modules
:%=$(objpfx
)%.o
)
210 $(inst_vardbdir
)/Makefile
: db-Makefile
$(+force)
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
)
224 $(objpfx
)/libnss_test2.so
: $(objpfx
)nss_test2.os
$(link-libc-deps
)
226 $(objpfx
)/libnss_test_errno.so
: $(objpfx
)nss_test_errno.os
$(link-libc-deps
)
228 $(objpfx
)/libnss_test_gai_hv2_canonname.so
: \
229 $(objpfx
)nss_test_gai_hv2_canonname.os
$(link-libc-deps
)
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
235 $(objpfx
)/libnss_test2.so
$(libnss_files.so-version
): $(objpfx
)/libnss_test2.so
237 $(objpfx
)/libnss_test_errno.so
$(libnss_files.so-version
): \
238 $(objpfx
)/libnss_test_errno.so
240 $(objpfx
)/libnss_test_gai_hv2_canonname.so
$(libnss_files.so-version
): \
241 $(objpfx
)/libnss_test_gai_hv2_canonname.so
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
)
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
; } > $@
; \
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