1 # Copyright (C) 1996-2024 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-getaddrinfo.c
+= -fexceptions
144 CFLAGS-gethstbyad.c
+= -fexceptions
145 CFLAGS-gethstbyad_r.c
+= -fexceptions
146 CFLAGS-gethstbynm.c
+= -fexceptions
147 CFLAGS-gethstbynm_r.c
+= -fexceptions
148 CFLAGS-gethstbynm2.c
+= -fexceptions
149 CFLAGS-gethstbynm2_r.c
+= -fexceptions
150 CFLAGS-gethstent.c
+= -fexceptions
151 CFLAGS-gethstent_r.c
+= -fexceptions
160 ifeq ($(have-thread-library
),yes
)
161 CFLAGS-getnetgrent.c
+= -fexceptions
162 CFLAGS-getnetgrent_r.c
+= -fexceptions
175 ifeq ($(have-thread-library
),yes
)
176 CFLAGS-getnetbyad.c
+= -fexceptions
177 CFLAGS-getnetbyad_r.c
+= -fexceptions
178 CFLAGS-getnetbynm.c
+= -fexceptions
179 CFLAGS-getnetbynm_r.c
+= -fexceptions
180 CFLAGS-getnetent.c
+= -fexceptions
181 CFLAGS-getnetent_r.c
+= -fexceptions
184 # protocols routines:
194 ifeq ($(have-thread-library
),yes
)
195 CFLAGS-getprtent_r.c
+= -fexceptions
196 CFLAGS-getprtent.c
+= -fexceptions
213 ifeq ($(have-thread-library
),yes
)
214 CFLAGS-fgetpwent_r.c
+= $(libio-mtsafe
)
215 CFLAGS-getpw.c
+= -fexceptions
216 CFLAGS-getpwent.c
+= -fexceptions
217 CFLAGS-getpwent_r.c
+= -fexceptions
230 ifeq ($(have-thread-library
),yes
)
231 CFLAGS-getrpcent_r.c
+= -fexceptions
232 CFLAGS-getrpcent.c
+= -fexceptions
245 ifeq ($(have-thread-library
),yes
)
246 CFLAGS-getservent_r.c
+= -fexceptions
247 CFLAGS-getservent.c
+= -fexceptions
264 ifeq ($(have-thread-library
),yes
)
265 CFLAGS-getspent_r.c
+= -fexceptions
266 CFLAGS-getspent.c
+= -fexceptions
267 CFLAGS-fgetspent.c
+= -fexceptions
268 CFLAGS-fgetspent_r.c
+= -fexceptions
$(libio-mtsafe
)
269 CFLAGS-putspent.c
+= -fexceptions
$(libio-mtsafe
)
270 CFLAGS-getspnam.c
+= -fexceptions
271 CFLAGS-getspnam_r.c
+= -fexceptions
274 # These are the databases that go through nss dispatch.
275 # Caution: if you add a database here, you must add its real name
276 # in databases.def, too.
291 ifneq (,$(filter sunrpc
,$(subdirs
)))
297 CPPFLAGS-getent.c
= -DHAVE_SUNRPC
=$(have-sunrpc
)
299 others
:= getent makedb
300 install-bin
:= getent makedb
301 makedb-modules
= xmalloc hash-string
302 others-extras
= $(makedb-modules
)
303 extra-objs
+= $(makedb-modules
:=.o
)
305 tests-static
= tst-field
352 tst-nss-db-endgrent \
353 tst-nss-db-endpwent \
354 tst-nss-files-hosts-long \
355 tst-nss-files-hosts-v4mapped \
356 tst-nss-gai-actions \
357 tst-nss-gai-hv2-canonname \
363 ifeq (yes
,$(build-shared
))
364 # Tests which need libdl
365 tests
+= tst-nss-files-hosts-erange
366 tests
+= tst-nss-files-hosts-multi
367 tests
+= tst-nss-files-hosts-getent
368 tests
+= tst-nss-files-alias-leak
369 tests
+= tst-nss-files-alias-truncated
370 # tst_fgetgrent currently only works with shared libraries
371 test-srcs
:= tst_fgetgrent
372 ifeq ($(run-built-tests
),yes
)
373 tests-special
+= $(objpfx
)tst_fgetgrent.out
374 $(objpfx
)tst_fgetgrent.out
: tst_fgetgrent.sh
$(objpfx
)tst_fgetgrent
375 $(SHELL
) $< $(common-objpfx
) '$(test-program-prefix)'; \
380 # If we have a thread library then we can test cancellation against
381 # some routines like getpwuid_r.
382 ifeq (yes
,$(have-thread-library
))
383 tests
+= tst-cancel-getpwuid_r
386 # Specify rules for the nss_* modules. We have some services.
387 services
:= files db compat
389 extra-libs
= $(services
:%=libnss_
%)
390 # These libraries will be built in the `others' pass rather than
391 # the `lib' pass, because they depend on libc.so being built already.
392 extra-libs-others
= $(extra-libs
)
394 # The sources are found in the appropriate subdir.
395 subdir-dirs
= $(services
:%=nss_
%)
396 vpath
%.c
$(subdir-dirs
) ..
/locale
/programs ..
/intl
400 $(addprefix files-
, $(filter-out key
, $(databases
))) \
405 # Build only an empty shared libnss_files.
406 libnss_files-inhibit-o
= $(filter-out .os
,$(object-suffixes
))
408 # Pretend that libnss_files.so is a linker script, so that the symbolic link
410 install-lib-ldscripts
= libnss_files.so
411 $(inst_libdir
)/libnss_files.so
:
413 libnss_db-dbs
:= $(addprefix db-
,\
414 $(filter-out hosts network key alias
,\
417 libnss_db-routines
:= $(libnss_db-dbs
) db-open db-init hash-string
418 generated
+= $(filter-out db-alias.c db-netgrp.c
, \
419 $(addsuffix .c
,$(libnss_db-dbs
)))
421 libnss_compat-routines
:= $(addprefix compat-
,grp pwd spwd initgroups
) \
424 install-others
+= $(inst_vardbdir
)/Makefile
426 # Build static module into libc if requested
427 libnss_db-inhibit-o
= $(filter-out .os
,$(object-suffixes
))
428 libnss_compat-inhibit-o
= $(filter-out .os
,$(object-suffixes
))
429 ifeq ($(build-static-nss
),yes
)
430 tests-static
+= tst-nss-static
432 extra-test-objs
+= nss_test1.os nss_test2.os nss_test_errno.os \
433 nss_test_gai_hv2_canonname.os
435 ifeq ($(run-built-tests
),yes
)
437 tests-special
+= $(objpfx
)mtrace-tst-nss-gai-hv2-canonname.out
441 generated
+= mtrace-tst-nss-gai-hv2-canonname.out \
442 tst-nss-gai-hv2-canonname.mtrace
446 ifeq (yes
,$(have-selinux
))
447 LDLIBS-makedb
:= -lselinux
450 libnss-libc
= $(common-objpfx
)linkobj
/libc.so
451 # Target-specific variable setting to link objects using deprecated
452 # RPC interfaces with the version of libc.so that makes them available
454 $(services
:%=$(objpfx
)libnss_
%.so
): libc-for-link
= $(libnss-libc
)
456 $(libnss_db-dbs
:%=$(objpfx
)%.c
): $(objpfx
)db-
%.c
: nss_files
/files-
%.c
458 (echo
'#define EXTERN_PARSER';\
459 echo
'#define GENERIC "../nss_db/db-XXX.c"';\
460 echo
'#include "$<"') > $@.new
464 $(objpfx
)makedb
: $(makedb-modules
:%=$(objpfx
)%.o
)
466 $(inst_vardbdir
)/Makefile
: db-Makefile
$(+force)
469 libnss_test1.so-no-z-defs
= 1
470 libnss_test2.so-no-z-defs
= 1
472 rtld-tests-LDFLAGS
+= -Wl
,--dynamic-list
=nss_test.ver
474 libof-nss_test1
= extramodules
475 libof-nss_test2
= extramodules
476 libof-nss_test_errno
= extramodules
477 libof-nss_test_gai_hv2_canonname
= extramodules
478 $(objpfx
)/libnss_test1.so
: $(objpfx
)nss_test1.os
$(link-libc-deps
)
480 $(objpfx
)/libnss_test2.so
: $(objpfx
)nss_test2.os
$(link-libc-deps
)
482 $(objpfx
)/libnss_test_errno.so
: $(objpfx
)nss_test_errno.os
$(link-libc-deps
)
484 $(objpfx
)/libnss_test_gai_hv2_canonname.so
: \
485 $(objpfx
)nss_test_gai_hv2_canonname.os
$(link-libc-deps
)
487 $(objpfx
)nss_test2.os
: nss_test1.c
488 # Use the nss_files suffix for these objects as well.
489 $(objpfx
)/libnss_test1.so
$(libnss_files.so-version
): $(objpfx
)/libnss_test1.so
491 $(objpfx
)/libnss_test2.so
$(libnss_files.so-version
): $(objpfx
)/libnss_test2.so
493 $(objpfx
)/libnss_test_errno.so
$(libnss_files.so-version
): \
494 $(objpfx
)/libnss_test_errno.so
496 $(objpfx
)/libnss_test_gai_hv2_canonname.so
$(libnss_files.so-version
): \
497 $(objpfx
)/libnss_test_gai_hv2_canonname.so
499 $(patsubst %,$(objpfx
)%.out
,$(tests
) $(tests-container
)) : \
500 $(objpfx
)/libnss_test1.so
$(libnss_files.so-version
) \
501 $(objpfx
)/libnss_test2.so
$(libnss_files.so-version
) \
502 $(objpfx
)/libnss_test_errno.so
$(libnss_files.so-version
) \
503 $(objpfx
)/libnss_test_gai_hv2_canonname.so
$(libnss_files.so-version
)
505 ifeq (yes
,$(have-thread-library
))
506 $(objpfx
)tst-cancel-getpwuid_r
: $(shared-thread-library
)
509 $(objpfx
)tst-nss-files-alias-leak.out
: $(objpfx
)/libnss_files.so
510 $(objpfx
)tst-nss-files-alias-truncated.out
: $(objpfx
)/libnss_files.so
512 tst-nss-gai-hv2-canonname-ENV
= \
513 MALLOC_TRACE
=$(objpfx
)tst-nss-gai-hv2-canonname.mtrace \
514 LD_PRELOAD
=$(common-objpfx
)/malloc
/libc_malloc_debug.so
515 $(objpfx
)mtrace-tst-nss-gai-hv2-canonname.out
: \
516 $(objpfx
)tst-nss-gai-hv2-canonname.out
517 { test -r
$(objpfx
)tst-nss-gai-hv2-canonname.mtrace \
518 ||
( echo
"tst-nss-gai-hv2-canonname.mtrace does not exist"; exit
77; ) \
519 && $(common-objpfx
)malloc
/mtrace \
520 $(objpfx
)tst-nss-gai-hv2-canonname.mtrace
; } > $@
; \
523 # Disable DT_RUNPATH on NSS tests so that the glibc internal NSS
524 # functions can load testing NSS modules via DT_RPATH.
525 LDFLAGS-tst-nss-test1
= -Wl
,--disable-new-dtags
526 LDFLAGS-tst-nss-test2
= -Wl
,--disable-new-dtags
527 LDFLAGS-tst-nss-test3
= -Wl
,--disable-new-dtags
528 LDFLAGS-tst-nss-test4
= -Wl
,--disable-new-dtags
529 LDFLAGS-tst-nss-test5
= -Wl
,--disable-new-dtags
530 LDFLAGS-tst-nss-test_errno
= -Wl
,--disable-new-dtags
531 LDFLAGS-tst-nss-test_gai_hv2_canonname
= -Wl
,--disable-new-dtags