Debian Codegraph @

nss/Makefile

raw symbols ◀ ▶ SCIP
2 Debian patches touch this file
1 # Copyright (C) 1996-2026 Free Software Foundation, Inc.
2 # This file is part of the GNU C Library.
3
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.
8
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.
13
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/>.
17
18 #
19 # Makefile for name service switch.
20 #
21 subdir := nss
22
23 include ../Makeconfig
24
25 headers := \
26 aliases.h \
27 grp.h \
28 gshadow.h \
29 nss.h \
30 pwd.h \
31 shadow.h \
32 # headers
33
34 # This is the trivial part which goes into libc itself.
35 routines = \
36 $(addsuffix -lookup,$(databases)) \
37 compat-lookup \
38 digits_dots \
39 getnssent \
40 getnssent_r \
41 nss_action \
42 nss_action_parse \
43 nss_database \
44 nss_fgetent_r \
45 nss_files_data \
46 nss_files_fopen \
47 nss_files_functions \
48 nss_hash \
49 nss_module \
50 nss_parse_line_result \
51 nss_readline \
52 nsswitch \
53 rewrite_field \
54 valid_field \
55 valid_list_field \
56 # routines
57
58 # alias routines:
59 routines += \
60 getaliasent \
61 getaliasent_r \
62 getaliasname \
63 getaliasname_r \
•64 # routines
65
66 ifeq ($(have-thread-library),yes)
67 CFLAGS-getaliasent_r.c += -fexceptions
68 CFLAGS-getaliasent.c += -fexceptions
69 endif
70
71 # ethers routines:
72 routines += \
73 ether_hton \
74 ether_ntoh \
75 # routines
76
77 # grp routines:
78 routines += \
79 fgetgrent \
80 fgetgrent_r \
81 getgrent \
82 getgrent_r \
83 getgrgid \
84 getgrgid_r \
85 getgrnam \
86 getgrnam_r \
87 grp-merge \
88 initgroups \
89 putgrent \
90 # routines
91
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)
103 endif
104
105 # gshadow routines:
106 routines += \
107 fgetsgent \
108 fgetsgent_r \
109 getsgent \
110 getsgent_r \
111 getsgnam \
112 getsgnam_r \
113 putsgent \
114 sgetsgent \
115 sgetsgent_r \
116 # routines
117
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
126 endif
127
128 # hosts routines:
129 routines += \
130 getaddrinfo \
131 gethstbyad \
132 gethstbyad_r \
133 gethstbynm \
134 gethstbynm2 \
135 gethstbynm2_r \
136 gethstbynm_r \
137 gethstent \
138 gethstent_r \
139 getnameinfo \
140 # routines
141
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
152 endif
153
154 # netgroup routines:
155 routines += \
156 getnetgrent \
157 getnetgrent_r \
158 # routines
159
160 ifeq ($(have-thread-library),yes)
161 CFLAGS-getnetgrent.c += -fexceptions
162 CFLAGS-getnetgrent_r.c += -fexceptions
163 endif
164
165 # networks routines:
166 routines += \
167 getnetbyad \
168 getnetbyad_r \
169 getnetbynm \
170 getnetbynm_r \
171 getnetent \
172 getnetent_r \
173 # routines
174
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
182 endif
183
184 # protocols routines:
185 routines += \
186 getproto \
187 getproto_r \
188 getprtent \
189 getprtent_r \
190 getprtname \
191 getprtname_r \
192 # routines
193
194 ifeq ($(have-thread-library),yes)
195 CFLAGS-getprtent_r.c += -fexceptions
196 CFLAGS-getprtent.c += -fexceptions
197 endif
198
199 # pwd routines:
200 routines += \
201 fgetpwent \
202 fgetpwent_r \
203 getpw \
204 getpwent \
205 getpwent_r \
206 getpwnam \
207 getpwnam_r \
208 getpwuid \
209 getpwuid_r \
210 putpwent \
211 # routines
212
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
218 endif
219
220 # rpc routines:
221 routines += \
222 getrpcbyname \
223 getrpcbyname_r \
224 getrpcbynumber \
225 getrpcbynumber_r \
226 getrpcent \
227 getrpcent_r \
228 # routines
229
230 ifeq ($(have-thread-library),yes)
231 CFLAGS-getrpcent_r.c += -fexceptions
232 CFLAGS-getrpcent.c += -fexceptions
233 endif
234
235 # services routines:
236 routines += \
237 getservent \
238 getservent_r \
239 getsrvbynm \
240 getsrvbynm_r \
241 getsrvbypt \
242 getsrvbypt_r \
243 # routines
244
245 ifeq ($(have-thread-library),yes)
246 CFLAGS-getservent_r.c += -fexceptions
247 CFLAGS-getservent.c += -fexceptions
248 endif
249
250 # shadow routines
251 routines += \
252 fgetspent \
253 fgetspent_r \
254 getspent \
255 getspent_r \
256 getspnam \
257 getspnam_r \
258 lckpwdf \
259 putspent \
260 sgetspent \
261 sgetspent_r \
262 # routines
263
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
272 endif
273
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.
277 databases = \
278 alias \
279 ethers \
280 grp \
281 hosts \
282 netgrp \
283 network \
284 proto \
285 pwd \
286 service \
287 sgrp \
288 spwd \
289 # databases
290
291 ifneq (,$(filter sunrpc,$(subdirs)))
292 databases += key rpc
293 have-sunrpc := 1
294 else
295 have-sunrpc := 0
296 endif
297 CPPFLAGS-getent.c = -DHAVE_SUNRPC=$(have-sunrpc)
298
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)
304
305 tests-static = tst-field
306
307 tests-internal := \
308 tst-field \
309 tst-rfc3484 \
310 tst-rfc3484-2 \
311 tst-rfc3484-3 \
312 # tests-internal
313
314 tests := \
315 bug17079 \
316 test-digits-dots \
317 test-netdb \
318 test-rpcent \
319 testgrp \
320 tst-fgetsgent_r \
321 tst-getaddrinfo \
322 tst-getaddrinfo2 \
323 tst-getaddrinfo3 \
324 tst-gethnm \
325 tst-getpw \
326 tst-gshadow \
327 tst-nss-getpwent \
328 tst-nss-hash \
•329 tst-nss-malloc-failure-getlogin_r \
330 tst-nss-test1 \
331 tst-nss-test2 \
332 tst-nss-test4 \
333 tst-nss-test5 \
334 tst-nss-test_errno \
335 tst-putgrent \
336 tst-putpwent \
337 tst-putsgent \
338 tst-putspent \
339 tst-sgetsgent \
340 tst-shadow \
341 # tests
342
343 xtests := \
344 bug-erange \
345 tst-getaddrinfo4 \
346 tst-getaddrinfo5 \
347 # xtests
348
349 tests-container := \
350 tst-initgroups1 \
351 tst-initgroups2 \
352 tst-nss-action-parse \
353 tst-nss-compat1 \
354 tst-nss-db-endgrent \
355 tst-nss-db-endpwent \
356 tst-nss-files-hosts-long \
357 tst-nss-files-hosts-v4mapped \
358 tst-nss-gai-actions \
359 tst-nss-gai-hv2-canonname \
360 tst-nss-test3 \
361 tst-reload1 \
362 tst-reload2 \
363 # tests-container
364
365 ifeq (yes,$(build-shared))
366 # Tests which need libdl
367 tests += tst-nss-files-hosts-erange
368 tests += tst-nss-files-hosts-multi
369 tests += tst-nss-files-hosts-getent
370 tests += tst-nss-files-alias-leak
371 tests += tst-nss-files-alias-truncated
372 tests += tst-nss-files-network
373 # tst_fgetgrent currently only works with shared libraries
374 test-srcs := tst_fgetgrent
375 ifeq ($(run-built-tests),yes)
376 tests-special += $(objpfx)tst_fgetgrent.out
377 $(objpfx)tst_fgetgrent.out: tst_fgetgrent.sh $(objpfx)tst_fgetgrent
378 $(SHELL) $< $(common-objpfx) '$(test-program-prefix)'; \
379 $(evaluate-test)
380 endif
381 endif
382
383 # If we have a thread library then we can test cancellation against
384 # some routines like getpwuid_r.
385 ifeq (yes,$(have-thread-library))
386 tests += tst-cancel-getpwuid_r
387 endif
388
389 # Specify rules for the nss_* modules. We have some services.
390 services := files compat
391
392 extra-libs = $(services:%=libnss_%)
393 # These libraries will be built in the `others' pass rather than
394 # the `lib' pass, because they depend on libc.so being built already.
395 extra-libs-others = $(extra-libs)
396
397 # The sources are found in the appropriate subdir.
398 subdir-dirs = $(services:%=nss_%)
399 vpath %.c $(subdir-dirs) ../locale/programs ../intl
400
401
402 routines += \
403 $(addprefix files-, $(filter-out key, $(databases))) \
404 files-init \
405 files-initgroups \
406 # routines
407
408 # Build only an empty shared libnss_files.
409 libnss_files-inhibit-o = $(filter-out .os,$(object-suffixes))
410
411 # Pretend that libnss_files.so is a linker script, so that the symbolic link
412 # is not installed.
413 install-lib-ldscripts = libnss_files.so
414 $(inst_libdir)/libnss_files.so:
415
416 libnss_db-dbs := $(addprefix db-,\
417 $(filter-out hosts network key alias,\
418 $(databases))) \
419 db-initgroups
420 libnss_db-routines := $(libnss_db-dbs) db-open db-init hash-string
421 generated += $(filter-out db-alias.c db-netgrp.c, \
422 $(addsuffix .c,$(libnss_db-dbs)))
423
424 libnss_compat-routines := $(addprefix compat-,grp pwd spwd initgroups) \
425 nisdomain
426
427 install-others += $(inst_vardbdir)/Makefile
428
429 # Build static module into libc if requested
430 libnss_db-inhibit-o = $(filter-out .os,$(object-suffixes))
431 libnss_compat-inhibit-o = $(filter-out .os,$(object-suffixes))
432 ifeq ($(build-static-nss),yes)
433 tests-static += tst-nss-static
434 endif
435 extra-test-objs += nss_test1.os nss_test2.os nss_test_errno.os \
436 nss_test_gai_hv2_canonname.os
437
438 ifeq ($(run-built-tests),yes)
439 ifneq (no,$(PERL))
440 tests-special += $(objpfx)mtrace-tst-nss-gai-hv2-canonname.out
441 endif
442 endif
443
444 generated += mtrace-tst-nss-gai-hv2-canonname.out \
445 tst-nss-gai-hv2-canonname.mtrace
446
447 include ../Rules
448
449 LOCALES := tr_TR.UTF-8
450 include ../gen-locales.mk
451
452 ifeq (yes,$(have-selinux))
453 LDLIBS-makedb := -lselinux
454 endif
455
456 libnss-libc = $(common-objpfx)linkobj/libc.so
457 # Target-specific variable setting to link objects using deprecated
458 # RPC interfaces with the version of libc.so that makes them available
459 # for new links:
460 $(services:%=$(objpfx)libnss_%.so): libc-for-link = $(libnss-libc)
461
462 $(libnss_db-dbs:%=$(objpfx)%.c): $(objpfx)db-%.c: nss_files/files-%.c
463 @rm -f [email protected]
464 (echo '#define EXTERN_PARSER';\
465 echo '#define GENERIC "../nss_db/db-XXX.c"';\
466 echo '#include "$<"') > [email protected]
467 mv -f [email protected] $@
468
469
470 $(objpfx)makedb: $(makedb-modules:%=$(objpfx)%.o)
471
472 $(inst_vardbdir)/Makefile: db-Makefile $(+force)
473 $(do-install)
474
475 libnss_test1.so-no-z-defs = 1
476 libnss_test2.so-no-z-defs = 1
477
478 rtld-tests-LDFLAGS += -Wl,--dynamic-list=nss_test.ver
479
480 libof-nss_test1 = extramodules
481 libof-nss_test2 = extramodules
482 libof-nss_test_errno = extramodules
483 libof-nss_test_gai_hv2_canonname = extramodules
484 $(objpfx)libnss_test1.so: $(objpfx)nss_test1.os $(link-libc-deps)
485 $(build-module)
486 $(objpfx)libnss_test2.so: $(objpfx)nss_test2.os $(link-libc-deps)
487 $(build-module)
488 $(objpfx)libnss_test_errno.so: $(objpfx)nss_test_errno.os $(link-libc-deps)
489 $(build-module)
490 $(objpfx)libnss_test_gai_hv2_canonname.so: \
491 $(objpfx)nss_test_gai_hv2_canonname.os $(link-libc-deps)
492 $(build-module)
493 $(objpfx)nss_test2.os : nss_test1.c
494 # Use the nss_files suffix for these objects as well.
495 $(objpfx)libnss_test1.so$(libnss_files.so-version): $(objpfx)libnss_test1.so
496 $(make-link)
497 $(objpfx)libnss_test2.so$(libnss_files.so-version): $(objpfx)libnss_test2.so
498 $(make-link)
499 $(objpfx)libnss_test_errno.so$(libnss_files.so-version): \
500 $(objpfx)libnss_test_errno.so
501 $(make-link)
502 $(objpfx)libnss_test_gai_hv2_canonname.so$(libnss_files.so-version): \
503 $(objpfx)libnss_test_gai_hv2_canonname.so
504 $(make-link)
505 $(patsubst %,$(objpfx)%.out,$(tests) $(tests-container)) : \
506 $(objpfx)libnss_test1.so$(libnss_files.so-version) \
507 $(objpfx)libnss_test2.so$(libnss_files.so-version) \
508 $(objpfx)libnss_test_errno.so$(libnss_files.so-version) \
509 $(objpfx)libnss_test_gai_hv2_canonname.so$(libnss_files.so-version)
510
511 ifeq (yes,$(have-thread-library))
512 $(objpfx)tst-cancel-getpwuid_r: $(shared-thread-library)
513 endif
514
515 $(objpfx)tst-nss-files-alias-leak.out: $(objpfx)libnss_files.so
516 $(objpfx)tst-nss-files-alias-truncated.out: $(objpfx)libnss_files.so
517
518 tst-nss-gai-hv2-canonname-ENV = \
519 MALLOC_TRACE=$(objpfx)tst-nss-gai-hv2-canonname.mtrace \
520 LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so
521 $(objpfx)mtrace-tst-nss-gai-hv2-canonname.out: \
522 $(objpfx)tst-nss-gai-hv2-canonname.out
523 { test -r $(objpfx)tst-nss-gai-hv2-canonname.mtrace \
524 || ( echo "tst-nss-gai-hv2-canonname.mtrace does not exist"; exit 77; ) \
525 && $(common-objpfx)malloc/mtrace \
526 $(objpfx)tst-nss-gai-hv2-canonname.mtrace; } > $@; \
527 $(evaluate-test)
528
529 $(objpfx)tst-nss-action-parse.out: $(gen-locales)
530
531 # Disable DT_RUNPATH on NSS tests so that the glibc internal NSS
532 # functions can load testing NSS modules via DT_RPATH.
533 LDFLAGS-tst-nss-test1 = -Wl,--disable-new-dtags
534 LDFLAGS-tst-nss-test2 = -Wl,--disable-new-dtags
535 LDFLAGS-tst-nss-test3 = -Wl,--disable-new-dtags
536 LDFLAGS-tst-nss-test4 = -Wl,--disable-new-dtags
537 LDFLAGS-tst-nss-test5 = -Wl,--disable-new-dtags
538 LDFLAGS-tst-nss-test_errno = -Wl,--disable-new-dtags
539 LDFLAGS-tst-nss-test_gai_hv2_canonname = -Wl,--disable-new-dtags