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.
34 # This is the trivial part which goes into libc itself.
36 $(addsuffix -lookup
,$(databases
)) \
50 nss_parse_line_result \
66 ifeq ($(have-thread-library
),yes
)
67 CFLAGS-getaliasent_r.c
+= -fexceptions
68 CFLAGS-getaliasent.c
+= -fexceptions
92 ifeq ($(have-thread-library
),yes
)
93 CFLAGS-fgetgrent.c
+= -fexceptions
94 CFLAGS-fgetgrent_r.c
+= -fexceptions
$(libio-mtsafe
)
95 CFLAGS-getgrent.c
+= -fexceptions
96 CFLAGS-getgrent_r.c
+= -fexceptions
97 CFLAGS-getgrgid.c
+= -fexceptions
98 CFLAGS-getgrgid_r.c
+= -fexceptions
99 CFLAGS-getgrnam.c
+= -fexceptions
100 CFLAGS-getgrnam_r.c
+= -fexceptions
101 CFLAGS-initgroups.c
+= -fexceptions
102 CFLAGS-putgrent.c
+= -fexceptions
$(libio-mtsafe
)
118 ifeq ($(have-thread-library
),yes
)
119 CFLAGS-getsgent_r.c
+= -fexceptions
120 CFLAGS-getsgent.c
+= -fexceptions
121 CFLAGS-fgetsgent.c
+= -fexceptions
122 CFLAGS-fgetsgent_r.c
+= -fexceptions
$(libio-mtsafe
)
123 CFLAGS-putsgent.c
+= -fexceptions
$(libio-mtsafe
)
124 CFLAGS-getsgnam.c
+= -fexceptions
125 CFLAGS-getsgnam_r.c
+= -fexceptions
142 ifeq ($(have-thread-library
),yes
)
143 CFLAGS-fgetpwent_r.c
+= $(libio-mtsafe
)
144 CFLAGS-getpw.c
+= -fexceptions
145 CFLAGS-getpwent.c
+= -fexceptions
146 CFLAGS-getpwent_r.c
+= -fexceptions
163 ifeq ($(have-thread-library
),yes
)
164 CFLAGS-getspent_r.c
+= -fexceptions
165 CFLAGS-getspent.c
+= -fexceptions
166 CFLAGS-fgetspent.c
+= -fexceptions
167 CFLAGS-fgetspent_r.c
+= -fexceptions
$(libio-mtsafe
)
168 CFLAGS-putspent.c
+= -fexceptions
$(libio-mtsafe
)
169 CFLAGS-getspnam.c
+= -fexceptions
170 CFLAGS-getspnam_r.c
+= -fexceptions
173 # These are the databases that go through nss dispatch.
174 # Caution: if you add a database here, you must add its real name
175 # in databases.def, too.
190 ifneq (,$(filter sunrpc
,$(subdirs
)))
196 CPPFLAGS-getent.c
= -DHAVE_SUNRPC
=$(have-sunrpc
)
198 others
:= getent makedb
199 install-bin
:= getent makedb
200 makedb-modules
= xmalloc hash-string
201 others-extras
= $(makedb-modules
)
202 extra-objs
+= $(makedb-modules
:=.o
)
204 tests-static
= tst-field
205 tests-internal
= tst-field
236 tst-nss-db-endgrent \
237 tst-nss-db-endpwent \
238 tst-nss-files-hosts-long \
239 tst-nss-files-hosts-v4mapped \
240 tst-nss-gai-actions \
241 tst-nss-gai-hv2-canonname \
247 ifeq (yes
,$(build-shared
))
248 # Tests which need libdl
249 tests
+= tst-nss-files-hosts-erange
250 tests
+= tst-nss-files-hosts-multi
251 tests
+= tst-nss-files-hosts-getent
252 tests
+= tst-nss-files-alias-leak
253 tests
+= tst-nss-files-alias-truncated
254 # tst_fgetgrent currently only works with shared libraries
255 test-srcs
:= tst_fgetgrent
256 ifeq ($(run-built-tests
),yes
)
257 tests-special
+= $(objpfx
)tst_fgetgrent.out
258 $(objpfx
)tst_fgetgrent.out
: tst_fgetgrent.sh
$(objpfx
)tst_fgetgrent
259 $(SHELL
) $< $(common-objpfx
) '$(test-program-prefix)'; \
264 # If we have a thread library then we can test cancellation against
265 # some routines like getpwuid_r.
266 ifeq (yes
,$(have-thread-library
))
267 tests
+= tst-cancel-getpwuid_r
270 # Specify rules for the nss_* modules. We have some services.
271 services
:= files db compat
273 extra-libs
= $(services
:%=libnss_
%)
274 # These libraries will be built in the `others' pass rather than
275 # the `lib' pass, because they depend on libc.so being built already.
276 extra-libs-others
= $(extra-libs
)
278 # The sources are found in the appropriate subdir.
279 subdir-dirs
= $(services
:%=nss_
%)
280 vpath
%.c
$(subdir-dirs
) ..
/locale
/programs ..
/intl
284 $(addprefix files-
, $(filter-out key
, $(databases
))) \
289 # Build only an empty shared libnss_files.
290 libnss_files-inhibit-o
= $(filter-out .os
,$(object-suffixes
))
292 # Pretend that libnss_files.so is a linker script, so that the symbolic link
294 install-lib-ldscripts
= libnss_files.so
295 $(inst_libdir
)/libnss_files.so
:
297 libnss_db-dbs
:= $(addprefix db-
,\
298 $(filter-out hosts network key alias
,\
301 libnss_db-routines
:= $(libnss_db-dbs
) db-open db-init hash-string
302 generated
+= $(filter-out db-alias.c db-netgrp.c
, \
303 $(addsuffix .c
,$(libnss_db-dbs
)))
305 libnss_compat-routines
:= $(addprefix compat-
,grp pwd spwd initgroups
) \
308 install-others
+= $(inst_vardbdir
)/Makefile
310 # Build static module into libc if requested
311 libnss_db-inhibit-o
= $(filter-out .os
,$(object-suffixes
))
312 libnss_compat-inhibit-o
= $(filter-out .os
,$(object-suffixes
))
313 ifeq ($(build-static-nss
),yes
)
314 tests-static
+= tst-nss-static
316 extra-test-objs
+= nss_test1.os nss_test2.os nss_test_errno.os \
317 nss_test_gai_hv2_canonname.os
319 ifeq ($(run-built-tests
),yes
)
321 tests-special
+= $(objpfx
)mtrace-tst-nss-gai-hv2-canonname.out
325 generated
+= mtrace-tst-nss-gai-hv2-canonname.out \
326 tst-nss-gai-hv2-canonname.mtrace
330 ifeq (yes
,$(have-selinux
))
331 LDLIBS-makedb
:= -lselinux
334 libnss-libc
= $(common-objpfx
)linkobj
/libc.so
335 # Target-specific variable setting to link objects using deprecated
336 # RPC interfaces with the version of libc.so that makes them available
338 $(services
:%=$(objpfx
)libnss_
%.so
): libc-for-link
= $(libnss-libc
)
340 $(libnss_db-dbs
:%=$(objpfx
)%.c
): $(objpfx
)db-
%.c
: nss_files
/files-
%.c
342 (echo
'#define EXTERN_PARSER';\
343 echo
'#define GENERIC "../nss_db/db-XXX.c"';\
344 echo
'#include "$<"') > $@.new
348 $(objpfx
)makedb
: $(makedb-modules
:%=$(objpfx
)%.o
)
350 $(inst_vardbdir
)/Makefile
: db-Makefile
$(+force)
353 libnss_test1.so-no-z-defs
= 1
354 libnss_test2.so-no-z-defs
= 1
356 rtld-tests-LDFLAGS
+= -Wl
,--dynamic-list
=nss_test.ver
358 libof-nss_test1
= extramodules
359 libof-nss_test2
= extramodules
360 libof-nss_test_errno
= extramodules
361 libof-nss_test_gai_hv2_canonname
= extramodules
362 $(objpfx
)/libnss_test1.so
: $(objpfx
)nss_test1.os
$(link-libc-deps
)
364 $(objpfx
)/libnss_test2.so
: $(objpfx
)nss_test2.os
$(link-libc-deps
)
366 $(objpfx
)/libnss_test_errno.so
: $(objpfx
)nss_test_errno.os
$(link-libc-deps
)
368 $(objpfx
)/libnss_test_gai_hv2_canonname.so
: \
369 $(objpfx
)nss_test_gai_hv2_canonname.os
$(link-libc-deps
)
371 $(objpfx
)nss_test2.os
: nss_test1.c
372 # Use the nss_files suffix for these objects as well.
373 $(objpfx
)/libnss_test1.so
$(libnss_files.so-version
): $(objpfx
)/libnss_test1.so
375 $(objpfx
)/libnss_test2.so
$(libnss_files.so-version
): $(objpfx
)/libnss_test2.so
377 $(objpfx
)/libnss_test_errno.so
$(libnss_files.so-version
): \
378 $(objpfx
)/libnss_test_errno.so
380 $(objpfx
)/libnss_test_gai_hv2_canonname.so
$(libnss_files.so-version
): \
381 $(objpfx
)/libnss_test_gai_hv2_canonname.so
383 $(patsubst %,$(objpfx
)%.out
,$(tests
) $(tests-container
)) : \
384 $(objpfx
)/libnss_test1.so
$(libnss_files.so-version
) \
385 $(objpfx
)/libnss_test2.so
$(libnss_files.so-version
) \
386 $(objpfx
)/libnss_test_errno.so
$(libnss_files.so-version
) \
387 $(objpfx
)/libnss_test_gai_hv2_canonname.so
$(libnss_files.so-version
)
389 ifeq (yes
,$(have-thread-library
))
390 $(objpfx
)tst-cancel-getpwuid_r
: $(shared-thread-library
)
393 $(objpfx
)tst-nss-files-alias-leak.out
: $(objpfx
)/libnss_files.so
394 $(objpfx
)tst-nss-files-alias-truncated.out
: $(objpfx
)/libnss_files.so
396 tst-nss-gai-hv2-canonname-ENV
= \
397 MALLOC_TRACE
=$(objpfx
)tst-nss-gai-hv2-canonname.mtrace \
398 LD_PRELOAD
=$(common-objpfx
)/malloc
/libc_malloc_debug.so
399 $(objpfx
)mtrace-tst-nss-gai-hv2-canonname.out
: \
400 $(objpfx
)tst-nss-gai-hv2-canonname.out
401 { test -r
$(objpfx
)tst-nss-gai-hv2-canonname.mtrace \
402 ||
( echo
"tst-nss-gai-hv2-canonname.mtrace does not exist"; exit
77; ) \
403 && $(common-objpfx
)malloc
/mtrace \
404 $(objpfx
)tst-nss-gai-hv2-canonname.mtrace
; } > $@
; \
407 # Disable DT_RUNPATH on NSS tests so that the glibc internal NSS
408 # functions can load testing NSS modules via DT_RPATH.
409 LDFLAGS-tst-nss-test1
= -Wl
,--disable-new-dtags
410 LDFLAGS-tst-nss-test2
= -Wl
,--disable-new-dtags
411 LDFLAGS-tst-nss-test3
= -Wl
,--disable-new-dtags
412 LDFLAGS-tst-nss-test4
= -Wl
,--disable-new-dtags
413 LDFLAGS-tst-nss-test5
= -Wl
,--disable-new-dtags
414 LDFLAGS-tst-nss-test_errno
= -Wl
,--disable-new-dtags
415 LDFLAGS-tst-nss-test_gai_hv2_canonname
= -Wl
,--disable-new-dtags