]> sourceware.org Git - glibc.git/blame - nss/Makefile
Move 'ethers' routines from 'inet' into 'nss'
[glibc.git] / nss / Makefile
CommitLineData
6d7e8eda 1# Copyright (C) 1996-2023 Free Software Foundation, Inc.
5f0e6fc7
RM
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
41bdb6e2
AJ
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.
5f0e6fc7
RM
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
41bdb6e2 12# Lesser General Public License for more details.
5f0e6fc7 13
41bdb6e2 14# You should have received a copy of the GNU Lesser General Public
59ba27a6 15# License along with the GNU C Library; if not, see
5a82c748 16# <https://www.gnu.org/licenses/>.
5f0e6fc7
RM
17
18#
19# Makefile for name service switch.
20#
21subdir := nss
22
a5f891ac
JM
23include ../Makeconfig
24
751850cf 25headers := \
42985866 26 aliases.h \
b121fdc5 27 grp.h \
98b107e3 28 gshadow.h \
751850cf 29 nss.h \
0ac35d18 30 pwd.h \
c6b577ca 31 shadow.h \
751850cf 32 # headers
5f0e6fc7
RM
33
34# This is the trivial part which goes into libc itself.
751850cf
AS
35routines = \
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
5f0e6fc7 57
42985866
AS
58# alias routines:
59routines += \
60 getaliasent \
61 getaliasent_r \
62 getaliasname \
63 getaliasname_r \
64 # routines
65
66ifeq ($(have-thread-library),yes)
67CFLAGS-getaliasent_r.c += -fexceptions
68CFLAGS-getaliasent.c += -fexceptions
69endif
70
1c402663
AS
71# ethers routines:
72routines += \
73 ether_hton \
74 ether_ntoh \
75 # routines
76
b121fdc5
AS
77# grp routines:
78routines += \
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
92ifeq ($(have-thread-library),yes)
93CFLAGS-fgetgrent.c += -fexceptions
94CFLAGS-fgetgrent_r.c += -fexceptions $(libio-mtsafe)
95CFLAGS-getgrent.c += -fexceptions
96CFLAGS-getgrent_r.c += -fexceptions
97CFLAGS-getgrgid.c += -fexceptions
98CFLAGS-getgrgid_r.c += -fexceptions
99CFLAGS-getgrnam.c += -fexceptions
100CFLAGS-getgrnam_r.c += -fexceptions
101CFLAGS-initgroups.c += -fexceptions
102CFLAGS-putgrent.c += -fexceptions $(libio-mtsafe)
103endif
104
98b107e3
AS
105# gshadow routines:
106routines += \
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
118ifeq ($(have-thread-library),yes)
119CFLAGS-getsgent_r.c += -fexceptions
120CFLAGS-getsgent.c += -fexceptions
121CFLAGS-fgetsgent.c += -fexceptions
122CFLAGS-fgetsgent_r.c += -fexceptions $(libio-mtsafe)
123CFLAGS-putsgent.c += -fexceptions $(libio-mtsafe)
124CFLAGS-getsgnam.c += -fexceptions
125CFLAGS-getsgnam_r.c += -fexceptions
126endif
127
0ac35d18
AS
128# pwd routines:
129routines += \
130 fgetpwent \
131 fgetpwent_r \
132 getpw \
133 getpwent \
134 getpwent_r \
135 getpwnam \
136 getpwnam_r \
137 getpwuid \
138 getpwuid_r \
139 putpwent \
140 # routines
141
142ifeq ($(have-thread-library),yes)
143CFLAGS-fgetpwent_r.c += $(libio-mtsafe)
144CFLAGS-getpw.c += -fexceptions
145CFLAGS-getpwent.c += -fexceptions
146CFLAGS-getpwent_r.c += -fexceptions
147endif
148
c6b577ca
AS
149# shadow routines
150routines += \
151 fgetspent \
152 fgetspent_r \
153 getspent \
154 getspent_r \
155 getspnam \
156 getspnam_r \
157 lckpwdf \
158 putspent \
159 sgetspent \
160 sgetspent_r \
161 # routines
162
163ifeq ($(have-thread-library),yes)
164CFLAGS-getspent_r.c += -fexceptions
165CFLAGS-getspent.c += -fexceptions
166CFLAGS-fgetspent.c += -fexceptions
167CFLAGS-fgetspent_r.c += -fexceptions $(libio-mtsafe)
168CFLAGS-putspent.c += -fexceptions $(libio-mtsafe)
169CFLAGS-getspnam.c += -fexceptions
170CFLAGS-getspnam_r.c += -fexceptions
171endif
172
6dbe2837 173# These are the databases that go through nss dispatch.
a8874ead
UD
174# Caution: if you add a database here, you must add its real name
175# in databases.def, too.
751850cf
AS
176databases = \
177 alias \
178 ethers \
179 grp \
180 hosts \
181 netgrp \
182 network \
183 proto \
184 pwd \
185 service \
186 sgrp \
187 spwd \
188 # databases
a1309c2b
RM
189
190ifneq (,$(filter sunrpc,$(subdirs)))
191databases += key rpc
192have-sunrpc := 1
193else
194have-sunrpc := 0
195endif
196CPPFLAGS-getent.c = -DHAVE_SUNRPC=$(have-sunrpc)
5f0e6fc7 197
9ee76b5a
UD
198others := getent makedb
199install-bin := getent makedb
200makedb-modules = xmalloc hash-string
7b3ce395 201others-extras = $(makedb-modules)
9ee76b5a 202extra-objs += $(makedb-modules:=.o)
7d6a8338 203
676599b3 204tests-static = tst-field
7c3018f9 205tests-internal = tst-field
e2f68b54
SP
206
207tests := \
208 bug17079 \
209 test-digits-dots \
210 test-netdb \
b121fdc5 211 testgrp \
98b107e3 212 tst-fgetsgent_r \
0ac35d18 213 tst-getpw \
98b107e3 214 tst-gshadow \
e2f68b54 215 tst-nss-getpwent \
5f2f0f69 216 tst-nss-hash \
e2f68b54
SP
217 tst-nss-test1 \
218 tst-nss-test2 \
219 tst-nss-test4 \
220 tst-nss-test5 \
221 tst-nss-test_errno \
b121fdc5 222 tst-putgrent \
0ac35d18 223 tst-putpwent \
98b107e3 224 tst-putsgent \
c6b577ca 225 tst-putspent \
98b107e3 226 tst-sgetsgent \
c6b577ca 227 tst-shadow \
751850cf 228 # tests
e2f68b54
SP
229
230xtests = bug-erange
231
232tests-container := \
b121fdc5
AS
233 tst-initgroups1 \
234 tst-initgroups2 \
e2f68b54
SP
235 tst-nss-compat1 \
236 tst-nss-db-endgrent \
237 tst-nss-db-endpwent \
238 tst-nss-files-hosts-long \
c4376314 239 tst-nss-files-hosts-v4mapped \
1c37b802 240 tst-nss-gai-actions \
751850cf 241 tst-nss-gai-hv2-canonname \
e2f68b54
SP
242 tst-nss-test3 \
243 tst-reload1 \
244 tst-reload2 \
751850cf 245 # tests-container
561b0bec 246
f4a6be25 247ifeq (yes,$(build-shared))
b121fdc5 248# Tests which need libdl
f4a6be25 249tests += tst-nss-files-hosts-erange
d8425e11 250tests += tst-nss-files-hosts-multi
916124ed 251tests += tst-nss-files-hosts-getent
e95c6f61 252tests += tst-nss-files-alias-leak
2bac7daa 253tests += tst-nss-files-alias-truncated
b121fdc5
AS
254# tst_fgetgrent currently only works with shared libraries
255test-srcs := tst_fgetgrent
256ifeq ($(run-built-tests),yes)
257tests-special += $(objpfx)tst_fgetgrent.out
258$(objpfx)tst_fgetgrent.out: tst_fgetgrent.sh $(objpfx)tst_fgetgrent
259 $(SHELL) $< $(common-objpfx) '$(test-program-prefix)'; \
260 $(evaluate-test)
261endif
f4a6be25
FW
262endif
263
b0a679f4
CD
264# If we have a thread library then we can test cancellation against
265# some routines like getpwuid_r.
266ifeq (yes,$(have-thread-library))
267tests += tst-cancel-getpwuid_r
268endif
269
5f0e6fc7 270# Specify rules for the nss_* modules. We have some services.
64d1e08e 271services := files db compat
5f0e6fc7
RM
272
273extra-libs = $(services:%=libnss_%)
dbe31b9a
RM
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.
276extra-libs-others = $(extra-libs)
5f0e6fc7
RM
277
278# The sources are found in the appropriate subdir.
6dbe2837 279subdir-dirs = $(services:%=nss_%)
9ee76b5a 280vpath %.c $(subdir-dirs) ../locale/programs ../intl
5f0e6fc7
RM
281
282
6212bb67
FW
283routines += \
284 $(addprefix files-, $(filter-out key, $(databases))) \
285 files-init \
286 files-initgroups \
287 # routines
5f0e6fc7 288
9ed48fee
FW
289# Build only an empty shared libnss_files.
290libnss_files-inhibit-o = $(filter-out .os,$(object-suffixes))
291
292# Pretend that libnss_files.so is a linker script, so that the symbolic link
293# is not installed.
294install-lib-ldscripts = libnss_files.so
295$(inst_libdir)/libnss_files.so:
296
2666d441
UD
297libnss_db-dbs := $(addprefix db-,\
298 $(filter-out hosts network key alias,\
9f2da732
UD
299 $(databases))) \
300 db-initgroups
319b9ad4 301libnss_db-routines := $(libnss_db-dbs) db-open db-init hash-string
2666d441
UD
302generated += $(filter-out db-alias.c db-netgrp.c, \
303 $(addsuffix .c,$(libnss_db-dbs)))
1aadea59 304
64d1e08e
AS
305libnss_compat-routines := $(addprefix compat-,grp pwd spwd initgroups) \
306 nisdomain
307
77fb9117
UD
308install-others += $(inst_vardbdir)/Makefile
309
3ff42526 310# Build static module into libc if requested
2666d441 311libnss_db-inhibit-o = $(filter-out .os,$(object-suffixes))
64d1e08e 312libnss_compat-inhibit-o = $(filter-out .os,$(object-suffixes))
3ff42526 313ifeq ($(build-static-nss),yes)
676599b3 314tests-static += tst-nss-static
6ca96fe2 315endif
973fe93a
SP
316extra-test-objs += nss_test1.os nss_test2.os nss_test_errno.os \
317 nss_test_gai_hv2_canonname.os
5f0e6fc7 318
ec6b95c3
RG
319ifeq ($(run-built-tests),yes)
320ifneq (no,$(PERL))
321tests-special += $(objpfx)mtrace-tst-nss-gai-hv2-canonname.out
322endif
323endif
324
325generated += mtrace-tst-nss-gai-hv2-canonname.out \
326 tst-nss-gai-hv2-canonname.mtrace
327
5f0e6fc7
RM
328include ../Rules
329
9ee76b5a
UD
330ifeq (yes,$(have-selinux))
331LDLIBS-makedb := -lselinux
332endif
333
7b57bfe5 334libnss-libc = $(common-objpfx)linkobj/libc.so
fab7ce3f
JM
335# Target-specific variable setting to link objects using deprecated
336# RPC interfaces with the version of libc.so that makes them available
337# for new links:
338$(services:%=$(objpfx)libnss_%.so): libc-for-link = $(libnss-libc)
c3e2f19b 339
2666d441
UD
340$(libnss_db-dbs:%=$(objpfx)%.c): $(objpfx)db-%.c: nss_files/files-%.c
341 @rm -f $@.new
342 (echo '#define EXTERN_PARSER';\
343 echo '#define GENERIC "../nss_db/db-XXX.c"';\
344 echo '#include "$<"') > $@.new
345 mv -f $@.new $@
346
c3e2f19b 347
9ee76b5a
UD
348$(objpfx)makedb: $(makedb-modules:%=$(objpfx)%.o)
349
77fb9117
UD
350$(inst_vardbdir)/Makefile: db-Makefile $(+force)
351 $(do-install)
352
ae5c498d
DD
353libnss_test1.so-no-z-defs = 1
354libnss_test2.so-no-z-defs = 1
355
356rtld-tests-LDFLAGS += -Wl,--dynamic-list=nss_test.ver
357
9cd47470 358libof-nss_test1 = extramodules
ae5c498d 359libof-nss_test2 = extramodules
9bdf92c7 360libof-nss_test_errno = extramodules
973fe93a 361libof-nss_test_gai_hv2_canonname = extramodules
fab7ce3f 362$(objpfx)/libnss_test1.so: $(objpfx)nss_test1.os $(link-libc-deps)
c3e2f19b 363 $(build-module)
ae5c498d
DD
364$(objpfx)/libnss_test2.so: $(objpfx)nss_test2.os $(link-libc-deps)
365 $(build-module)
9bdf92c7
FW
366$(objpfx)/libnss_test_errno.so: $(objpfx)nss_test_errno.os $(link-libc-deps)
367 $(build-module)
973fe93a
SP
368$(objpfx)/libnss_test_gai_hv2_canonname.so: \
369 $(objpfx)nss_test_gai_hv2_canonname.os $(link-libc-deps)
370 $(build-module)
ae5c498d 371$(objpfx)nss_test2.os : nss_test1.c
aefc79ab
FW
372# Use the nss_files suffix for these objects as well.
373$(objpfx)/libnss_test1.so$(libnss_files.so-version): $(objpfx)/libnss_test1.so
c3e2f19b 374 $(make-link)
aefc79ab 375$(objpfx)/libnss_test2.so$(libnss_files.so-version): $(objpfx)/libnss_test2.so
ae5c498d 376 $(make-link)
9bdf92c7
FW
377$(objpfx)/libnss_test_errno.so$(libnss_files.so-version): \
378 $(objpfx)/libnss_test_errno.so
379 $(make-link)
973fe93a
SP
380$(objpfx)/libnss_test_gai_hv2_canonname.so$(libnss_files.so-version): \
381 $(objpfx)/libnss_test_gai_hv2_canonname.so
382 $(make-link)
268bb71e 383$(patsubst %,$(objpfx)%.out,$(tests) $(tests-container)) : \
aefc79ab 384 $(objpfx)/libnss_test1.so$(libnss_files.so-version) \
9bdf92c7 385 $(objpfx)/libnss_test2.so$(libnss_files.so-version) \
973fe93a
SP
386 $(objpfx)/libnss_test_errno.so$(libnss_files.so-version) \
387 $(objpfx)/libnss_test_gai_hv2_canonname.so$(libnss_files.so-version)
b0a679f4
CD
388
389ifeq (yes,$(have-thread-library))
390$(objpfx)tst-cancel-getpwuid_r: $(shared-thread-library)
391endif
f4a6be25 392
e95c6f61 393$(objpfx)tst-nss-files-alias-leak.out: $(objpfx)/libnss_files.so
081bdf94 394$(objpfx)tst-nss-files-alias-truncated.out: $(objpfx)/libnss_files.so
57e349b1 395
ec6b95c3
RG
396tst-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; } > $@; \
405 $(evaluate-test)
406
57e349b1
L
407# Disable DT_RUNPATH on NSS tests so that the glibc internal NSS
408# functions can load testing NSS modules via DT_RPATH.
409LDFLAGS-tst-nss-test1 = -Wl,--disable-new-dtags
410LDFLAGS-tst-nss-test2 = -Wl,--disable-new-dtags
411LDFLAGS-tst-nss-test3 = -Wl,--disable-new-dtags
412LDFLAGS-tst-nss-test4 = -Wl,--disable-new-dtags
413LDFLAGS-tst-nss-test5 = -Wl,--disable-new-dtags
9bdf92c7 414LDFLAGS-tst-nss-test_errno = -Wl,--disable-new-dtags
973fe93a 415LDFLAGS-tst-nss-test_gai_hv2_canonname = -Wl,--disable-new-dtags
This page took 0.6513 seconds and 5 git commands to generate.