]> sourceware.org Git - glibc.git/blob - nss/Makefile
Move 'ethers' routines from 'inet' into 'nss'
[glibc.git] / nss / Makefile
1 # Copyright (C) 1996-2023 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 # pwd routines:
129 routines += \
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
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
147 endif
148
149 # shadow routines
150 routines += \
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
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
171 endif
172
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.
176 databases = \
177 alias \
178 ethers \
179 grp \
180 hosts \
181 netgrp \
182 network \
183 proto \
184 pwd \
185 service \
186 sgrp \
187 spwd \
188 # databases
189
190 ifneq (,$(filter sunrpc,$(subdirs)))
191 databases += key rpc
192 have-sunrpc := 1
193 else
194 have-sunrpc := 0
195 endif
196 CPPFLAGS-getent.c = -DHAVE_SUNRPC=$(have-sunrpc)
197
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)
203
204 tests-static = tst-field
205 tests-internal = tst-field
206
207 tests := \
208 bug17079 \
209 test-digits-dots \
210 test-netdb \
211 testgrp \
212 tst-fgetsgent_r \
213 tst-getpw \
214 tst-gshadow \
215 tst-nss-getpwent \
216 tst-nss-hash \
217 tst-nss-test1 \
218 tst-nss-test2 \
219 tst-nss-test4 \
220 tst-nss-test5 \
221 tst-nss-test_errno \
222 tst-putgrent \
223 tst-putpwent \
224 tst-putsgent \
225 tst-putspent \
226 tst-sgetsgent \
227 tst-shadow \
228 # tests
229
230 xtests = bug-erange
231
232 tests-container := \
233 tst-initgroups1 \
234 tst-initgroups2 \
235 tst-nss-compat1 \
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 \
242 tst-nss-test3 \
243 tst-reload1 \
244 tst-reload2 \
245 # tests-container
246
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)'; \
260 $(evaluate-test)
261 endif
262 endif
263
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
268 endif
269
270 # Specify rules for the nss_* modules. We have some services.
271 services := files db compat
272
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)
277
278 # The sources are found in the appropriate subdir.
279 subdir-dirs = $(services:%=nss_%)
280 vpath %.c $(subdir-dirs) ../locale/programs ../intl
281
282
283 routines += \
284 $(addprefix files-, $(filter-out key, $(databases))) \
285 files-init \
286 files-initgroups \
287 # routines
288
289 # Build only an empty shared libnss_files.
290 libnss_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.
294 install-lib-ldscripts = libnss_files.so
295 $(inst_libdir)/libnss_files.so:
296
297 libnss_db-dbs := $(addprefix db-,\
298 $(filter-out hosts network key alias,\
299 $(databases))) \
300 db-initgroups
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)))
304
305 libnss_compat-routines := $(addprefix compat-,grp pwd spwd initgroups) \
306 nisdomain
307
308 install-others += $(inst_vardbdir)/Makefile
309
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
315 endif
316 extra-test-objs += nss_test1.os nss_test2.os nss_test_errno.os \
317 nss_test_gai_hv2_canonname.os
318
319 ifeq ($(run-built-tests),yes)
320 ifneq (no,$(PERL))
321 tests-special += $(objpfx)mtrace-tst-nss-gai-hv2-canonname.out
322 endif
323 endif
324
325 generated += mtrace-tst-nss-gai-hv2-canonname.out \
326 tst-nss-gai-hv2-canonname.mtrace
327
328 include ../Rules
329
330 ifeq (yes,$(have-selinux))
331 LDLIBS-makedb := -lselinux
332 endif
333
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
337 # for new links:
338 $(services:%=$(objpfx)libnss_%.so): libc-for-link = $(libnss-libc)
339
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
347
348 $(objpfx)makedb: $(makedb-modules:%=$(objpfx)%.o)
349
350 $(inst_vardbdir)/Makefile: db-Makefile $(+force)
351 $(do-install)
352
353 libnss_test1.so-no-z-defs = 1
354 libnss_test2.so-no-z-defs = 1
355
356 rtld-tests-LDFLAGS += -Wl,--dynamic-list=nss_test.ver
357
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)
363 $(build-module)
364 $(objpfx)/libnss_test2.so: $(objpfx)nss_test2.os $(link-libc-deps)
365 $(build-module)
366 $(objpfx)/libnss_test_errno.so: $(objpfx)nss_test_errno.os $(link-libc-deps)
367 $(build-module)
368 $(objpfx)/libnss_test_gai_hv2_canonname.so: \
369 $(objpfx)nss_test_gai_hv2_canonname.os $(link-libc-deps)
370 $(build-module)
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
374 $(make-link)
375 $(objpfx)/libnss_test2.so$(libnss_files.so-version): $(objpfx)/libnss_test2.so
376 $(make-link)
377 $(objpfx)/libnss_test_errno.so$(libnss_files.so-version): \
378 $(objpfx)/libnss_test_errno.so
379 $(make-link)
380 $(objpfx)/libnss_test_gai_hv2_canonname.so$(libnss_files.so-version): \
381 $(objpfx)/libnss_test_gai_hv2_canonname.so
382 $(make-link)
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)
388
389 ifeq (yes,$(have-thread-library))
390 $(objpfx)tst-cancel-getpwuid_r: $(shared-thread-library)
391 endif
392
393 $(objpfx)tst-nss-files-alias-leak.out: $(objpfx)/libnss_files.so
394 $(objpfx)tst-nss-files-alias-truncated.out: $(objpfx)/libnss_files.so
395
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; } > $@; \
405 $(evaluate-test)
406
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
This page took 0.057203 seconds and 5 git commands to generate.