1 # Copyright (C) 1996-2022 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.
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 nss_files_fopen \
32 nss_readline nss_parse_line_result \
33 nss_fgetent_r nss_module nss_action \
34 nss_action_parse nss_database nss_files_data \
37 # These are the databases that go through nss dispatch.
38 # Caution: if you add a database here, you must add its real name
39 # in databases.def, too.
40 databases
= proto service hosts network grp pwd ethers \
41 spwd netgrp alias sgrp
43 ifneq (,$(filter sunrpc
,$(subdirs
)))
49 CPPFLAGS-getent.c
= -DHAVE_SUNRPC
=$(have-sunrpc
)
51 others
:= getent makedb
52 install-bin
:= getent makedb
53 makedb-modules
= xmalloc hash-string
54 others-extras
= $(makedb-modules
)
55 extra-objs
+= $(makedb-modules
:=.o
)
57 tests-static
= tst-field
58 tests-internal
= tst-field
59 tests
= test-netdb test-digits-dots tst-nss-getpwent bug17079 \
70 tst-nss-files-hosts-long \
73 tst-reload1 tst-reload2
75 # Tests which need libdl
76 ifeq (yes
,$(build-shared
))
77 tests
+= tst-nss-files-hosts-erange
78 tests
+= tst-nss-files-hosts-multi
79 tests
+= tst-nss-files-hosts-getent
80 tests
+= tst-nss-files-alias-leak
81 tests
+= tst-nss-files-alias-truncated
84 # If we have a thread library then we can test cancellation against
85 # some routines like getpwuid_r.
86 ifeq (yes
,$(have-thread-library
))
87 tests
+= tst-cancel-getpwuid_r
90 # Specify rules for the nss_* modules. We have some services.
91 services
:= files db compat
93 extra-libs
= $(services
:%=libnss_
%)
94 # These libraries will be built in the `others' pass rather than
95 # the `lib' pass, because they depend on libc.so being built already.
96 extra-libs-others
= $(extra-libs
)
98 # The sources are found in the appropriate subdir.
99 subdir-dirs
= $(services
:%=nss_
%)
100 vpath
%.c
$(subdir-dirs
) ..
/locale
/programs ..
/intl
104 $(addprefix files-
, $(filter-out key
, $(databases
))) \
109 # Build only an empty shared libnss_files.
110 libnss_files-inhibit-o
= $(filter-out .os
,$(object-suffixes
))
112 # Pretend that libnss_files.so is a linker script, so that the symbolic link
114 install-lib-ldscripts
= libnss_files.so
115 $(inst_libdir
)/libnss_files.so
:
117 libnss_db-dbs
:= $(addprefix db-
,\
118 $(filter-out hosts network key alias
,\
121 libnss_db-routines
:= $(libnss_db-dbs
) db-open db-init hash-string
122 generated
+= $(filter-out db-alias.c db-netgrp.c
, \
123 $(addsuffix .c
,$(libnss_db-dbs
)))
125 libnss_compat-routines
:= $(addprefix compat-
,grp pwd spwd initgroups
) \
128 install-others
+= $(inst_vardbdir
)/Makefile
130 # Build static module into libc if requested
131 libnss_db-inhibit-o
= $(filter-out .os
,$(object-suffixes
))
132 libnss_compat-inhibit-o
= $(filter-out .os
,$(object-suffixes
))
133 ifeq ($(build-static-nss
),yes
)
134 tests-static
+= tst-nss-static
136 extra-test-objs
+= nss_test1.os nss_test2.os nss_test_errno.os
140 ifeq (yes
,$(have-selinux
))
141 LDLIBS-makedb
:= -lselinux
144 libnss-libc
= $(common-objpfx
)linkobj
/libc.so
145 # Target-specific variable setting to link objects using deprecated
146 # RPC interfaces with the version of libc.so that makes them available
148 $(services
:%=$(objpfx
)libnss_
%.so
): libc-for-link
= $(libnss-libc
)
150 $(libnss_db-dbs
:%=$(objpfx
)%.c
): $(objpfx
)db-
%.c
: nss_files
/files-
%.c
152 (echo
'#define EXTERN_PARSER';\
153 echo
'#define GENERIC "../nss_db/db-XXX.c"';\
154 echo
'#include "$<"') > $@.new
158 $(objpfx
)makedb
: $(makedb-modules
:%=$(objpfx
)%.o
)
160 $(inst_vardbdir
)/Makefile
: db-Makefile
$(+force)
163 libnss_test1.so-no-z-defs
= 1
164 libnss_test2.so-no-z-defs
= 1
166 rtld-tests-LDFLAGS
+= -Wl
,--dynamic-list
=nss_test.ver
168 libof-nss_test1
= extramodules
169 libof-nss_test2
= extramodules
170 libof-nss_test_errno
= extramodules
171 $(objpfx
)/libnss_test1.so
: $(objpfx
)nss_test1.os
$(link-libc-deps
)
173 $(objpfx
)/libnss_test2.so
: $(objpfx
)nss_test2.os
$(link-libc-deps
)
175 $(objpfx
)/libnss_test_errno.so
: $(objpfx
)nss_test_errno.os
$(link-libc-deps
)
177 $(objpfx
)nss_test2.os
: nss_test1.c
178 # Use the nss_files suffix for these objects as well.
179 $(objpfx
)/libnss_test1.so
$(libnss_files.so-version
): $(objpfx
)/libnss_test1.so
181 $(objpfx
)/libnss_test2.so
$(libnss_files.so-version
): $(objpfx
)/libnss_test2.so
183 $(objpfx
)/libnss_test_errno.so
$(libnss_files.so-version
): \
184 $(objpfx
)/libnss_test_errno.so
186 $(patsubst %,$(objpfx
)%.out
,$(tests
) $(tests-container
)) : \
187 $(objpfx
)/libnss_test1.so
$(libnss_files.so-version
) \
188 $(objpfx
)/libnss_test2.so
$(libnss_files.so-version
) \
189 $(objpfx
)/libnss_test_errno.so
$(libnss_files.so-version
)
191 ifeq (yes
,$(have-thread-library
))
192 $(objpfx
)tst-cancel-getpwuid_r
: $(shared-thread-library
)
195 $(objpfx
)tst-nss-files-alias-leak.out
: $(objpfx
)/libnss_files.so
196 $(objpfx
)tst-nss-files-alias-truncated.out
: $(objpfx
)/libnss_files.so
198 # Disable DT_RUNPATH on NSS tests so that the glibc internal NSS
199 # functions can load testing NSS modules via DT_RPATH.
200 LDFLAGS-tst-nss-test1
= -Wl
,--disable-new-dtags
201 LDFLAGS-tst-nss-test2
= -Wl
,--disable-new-dtags
202 LDFLAGS-tst-nss-test3
= -Wl
,--disable-new-dtags
203 LDFLAGS-tst-nss-test4
= -Wl
,--disable-new-dtags
204 LDFLAGS-tst-nss-test5
= -Wl
,--disable-new-dtags
205 LDFLAGS-tst-nss-test_errno
= -Wl
,--disable-new-dtags