]>
Commit | Line | Data |
---|---|---|
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 | # | |
21 | subdir := nss | |
22 | ||
a5f891ac JM |
23 | include ../Makeconfig |
24 | ||
a8874ead | 25 | headers := nss.h |
5f0e6fc7 RM |
26 | |
27 | # This is the trivial part which goes into libc itself. | |
a5fdf99b | 28 | routines = nsswitch getnssent getnssent_r digits_dots \ |
676599b3 | 29 | valid_field valid_list_field rewrite_field \ |
c88ffc23 | 30 | $(addsuffix -lookup,$(databases)) \ |
bdee910e FW |
31 | compat-lookup nss_hash nss_files_fopen \ |
32 | nss_readline nss_parse_line_result \ | |
fd5b9b44 | 33 | nss_fgetent_r nss_module nss_action \ |
f9c8b11e FW |
34 | nss_action_parse nss_database nss_files_data \ |
35 | nss_files_functions | |
5f0e6fc7 | 36 | |
6dbe2837 | 37 | # These are the databases that go through nss dispatch. |
a8874ead UD |
38 | # Caution: if you add a database here, you must add its real name |
39 | # in databases.def, too. | |
a1309c2b RM |
40 | databases = proto service hosts network grp pwd ethers \ |
41 | spwd netgrp alias sgrp | |
42 | ||
43 | ifneq (,$(filter sunrpc,$(subdirs))) | |
44 | databases += key rpc | |
45 | have-sunrpc := 1 | |
46 | else | |
47 | have-sunrpc := 0 | |
48 | endif | |
49 | CPPFLAGS-getent.c = -DHAVE_SUNRPC=$(have-sunrpc) | |
5f0e6fc7 | 50 | |
9ee76b5a UD |
51 | others := getent makedb |
52 | install-bin := getent makedb | |
53 | makedb-modules = xmalloc hash-string | |
7b3ce395 | 54 | others-extras = $(makedb-modules) |
9ee76b5a | 55 | extra-objs += $(makedb-modules:=.o) |
7d6a8338 | 56 | |
676599b3 | 57 | tests-static = tst-field |
7c3018f9 | 58 | tests-internal = tst-field |
e2f68b54 SP |
59 | |
60 | tests := \ | |
61 | bug17079 \ | |
62 | test-digits-dots \ | |
63 | test-netdb \ | |
64 | tst-nss-getpwent \ | |
5f2f0f69 | 65 | tst-nss-hash \ |
e2f68b54 SP |
66 | tst-nss-test1 \ |
67 | tst-nss-test2 \ | |
68 | tst-nss-test4 \ | |
69 | tst-nss-test5 \ | |
70 | tst-nss-test_errno \ | |
71 | # tests | |
72 | ||
73 | xtests = bug-erange | |
74 | ||
75 | tests-container := \ | |
76 | tst-nss-compat1 \ | |
77 | tst-nss-db-endgrent \ | |
78 | tst-nss-db-endpwent \ | |
79 | tst-nss-files-hosts-long \ | |
c4376314 | 80 | tst-nss-files-hosts-v4mapped \ |
1c37b802 | 81 | tst-nss-gai-actions \ |
e2f68b54 SP |
82 | tst-nss-test3 \ |
83 | tst-reload1 \ | |
84 | tst-reload2 \ | |
85 | # tests-container | |
561b0bec | 86 | |
f4a6be25 FW |
87 | # Tests which need libdl |
88 | ifeq (yes,$(build-shared)) | |
89 | tests += tst-nss-files-hosts-erange | |
d8425e11 | 90 | tests += tst-nss-files-hosts-multi |
916124ed | 91 | tests += tst-nss-files-hosts-getent |
e95c6f61 | 92 | tests += tst-nss-files-alias-leak |
2bac7daa | 93 | tests += tst-nss-files-alias-truncated |
f4a6be25 FW |
94 | endif |
95 | ||
b0a679f4 CD |
96 | # If we have a thread library then we can test cancellation against |
97 | # some routines like getpwuid_r. | |
98 | ifeq (yes,$(have-thread-library)) | |
99 | tests += tst-cancel-getpwuid_r | |
100 | endif | |
101 | ||
5f0e6fc7 | 102 | # Specify rules for the nss_* modules. We have some services. |
64d1e08e | 103 | services := files db compat |
5f0e6fc7 RM |
104 | |
105 | extra-libs = $(services:%=libnss_%) | |
dbe31b9a RM |
106 | # These libraries will be built in the `others' pass rather than |
107 | # the `lib' pass, because they depend on libc.so being built already. | |
108 | extra-libs-others = $(extra-libs) | |
5f0e6fc7 RM |
109 | |
110 | # The sources are found in the appropriate subdir. | |
6dbe2837 | 111 | subdir-dirs = $(services:%=nss_%) |
9ee76b5a | 112 | vpath %.c $(subdir-dirs) ../locale/programs ../intl |
5f0e6fc7 RM |
113 | |
114 | ||
6212bb67 FW |
115 | routines += \ |
116 | $(addprefix files-, $(filter-out key, $(databases))) \ | |
117 | files-init \ | |
118 | files-initgroups \ | |
119 | # routines | |
5f0e6fc7 | 120 | |
9ed48fee FW |
121 | # Build only an empty shared libnss_files. |
122 | libnss_files-inhibit-o = $(filter-out .os,$(object-suffixes)) | |
123 | ||
124 | # Pretend that libnss_files.so is a linker script, so that the symbolic link | |
125 | # is not installed. | |
126 | install-lib-ldscripts = libnss_files.so | |
127 | $(inst_libdir)/libnss_files.so: | |
128 | ||
2666d441 UD |
129 | libnss_db-dbs := $(addprefix db-,\ |
130 | $(filter-out hosts network key alias,\ | |
9f2da732 UD |
131 | $(databases))) \ |
132 | db-initgroups | |
319b9ad4 | 133 | libnss_db-routines := $(libnss_db-dbs) db-open db-init hash-string |
2666d441 UD |
134 | generated += $(filter-out db-alias.c db-netgrp.c, \ |
135 | $(addsuffix .c,$(libnss_db-dbs))) | |
1aadea59 | 136 | |
64d1e08e AS |
137 | libnss_compat-routines := $(addprefix compat-,grp pwd spwd initgroups) \ |
138 | nisdomain | |
139 | ||
77fb9117 UD |
140 | install-others += $(inst_vardbdir)/Makefile |
141 | ||
3ff42526 | 142 | # Build static module into libc if requested |
2666d441 | 143 | libnss_db-inhibit-o = $(filter-out .os,$(object-suffixes)) |
64d1e08e | 144 | libnss_compat-inhibit-o = $(filter-out .os,$(object-suffixes)) |
3ff42526 | 145 | ifeq ($(build-static-nss),yes) |
676599b3 | 146 | tests-static += tst-nss-static |
6ca96fe2 | 147 | endif |
9bdf92c7 | 148 | extra-test-objs += nss_test1.os nss_test2.os nss_test_errno.os |
5f0e6fc7 RM |
149 | |
150 | include ../Rules | |
151 | ||
9ee76b5a UD |
152 | ifeq (yes,$(have-selinux)) |
153 | LDLIBS-makedb := -lselinux | |
154 | endif | |
155 | ||
7b57bfe5 | 156 | libnss-libc = $(common-objpfx)linkobj/libc.so |
fab7ce3f JM |
157 | # Target-specific variable setting to link objects using deprecated |
158 | # RPC interfaces with the version of libc.so that makes them available | |
159 | # for new links: | |
160 | $(services:%=$(objpfx)libnss_%.so): libc-for-link = $(libnss-libc) | |
c3e2f19b | 161 | |
2666d441 UD |
162 | $(libnss_db-dbs:%=$(objpfx)%.c): $(objpfx)db-%.c: nss_files/files-%.c |
163 | @rm -f $@.new | |
164 | (echo '#define EXTERN_PARSER';\ | |
165 | echo '#define GENERIC "../nss_db/db-XXX.c"';\ | |
166 | echo '#include "$<"') > $@.new | |
167 | mv -f $@.new $@ | |
168 | ||
c3e2f19b | 169 | |
9ee76b5a UD |
170 | $(objpfx)makedb: $(makedb-modules:%=$(objpfx)%.o) |
171 | ||
77fb9117 UD |
172 | $(inst_vardbdir)/Makefile: db-Makefile $(+force) |
173 | $(do-install) | |
174 | ||
ae5c498d DD |
175 | libnss_test1.so-no-z-defs = 1 |
176 | libnss_test2.so-no-z-defs = 1 | |
177 | ||
178 | rtld-tests-LDFLAGS += -Wl,--dynamic-list=nss_test.ver | |
179 | ||
9cd47470 | 180 | libof-nss_test1 = extramodules |
ae5c498d | 181 | libof-nss_test2 = extramodules |
9bdf92c7 | 182 | libof-nss_test_errno = extramodules |
fab7ce3f | 183 | $(objpfx)/libnss_test1.so: $(objpfx)nss_test1.os $(link-libc-deps) |
c3e2f19b | 184 | $(build-module) |
ae5c498d DD |
185 | $(objpfx)/libnss_test2.so: $(objpfx)nss_test2.os $(link-libc-deps) |
186 | $(build-module) | |
9bdf92c7 FW |
187 | $(objpfx)/libnss_test_errno.so: $(objpfx)nss_test_errno.os $(link-libc-deps) |
188 | $(build-module) | |
ae5c498d | 189 | $(objpfx)nss_test2.os : nss_test1.c |
aefc79ab FW |
190 | # Use the nss_files suffix for these objects as well. |
191 | $(objpfx)/libnss_test1.so$(libnss_files.so-version): $(objpfx)/libnss_test1.so | |
c3e2f19b | 192 | $(make-link) |
aefc79ab | 193 | $(objpfx)/libnss_test2.so$(libnss_files.so-version): $(objpfx)/libnss_test2.so |
ae5c498d | 194 | $(make-link) |
9bdf92c7 FW |
195 | $(objpfx)/libnss_test_errno.so$(libnss_files.so-version): \ |
196 | $(objpfx)/libnss_test_errno.so | |
197 | $(make-link) | |
268bb71e | 198 | $(patsubst %,$(objpfx)%.out,$(tests) $(tests-container)) : \ |
aefc79ab | 199 | $(objpfx)/libnss_test1.so$(libnss_files.so-version) \ |
9bdf92c7 FW |
200 | $(objpfx)/libnss_test2.so$(libnss_files.so-version) \ |
201 | $(objpfx)/libnss_test_errno.so$(libnss_files.so-version) | |
b0a679f4 CD |
202 | |
203 | ifeq (yes,$(have-thread-library)) | |
204 | $(objpfx)tst-cancel-getpwuid_r: $(shared-thread-library) | |
205 | endif | |
f4a6be25 | 206 | |
e95c6f61 | 207 | $(objpfx)tst-nss-files-alias-leak.out: $(objpfx)/libnss_files.so |
081bdf94 | 208 | $(objpfx)tst-nss-files-alias-truncated.out: $(objpfx)/libnss_files.so |
57e349b1 L |
209 | |
210 | # Disable DT_RUNPATH on NSS tests so that the glibc internal NSS | |
211 | # functions can load testing NSS modules via DT_RPATH. | |
212 | LDFLAGS-tst-nss-test1 = -Wl,--disable-new-dtags | |
213 | LDFLAGS-tst-nss-test2 = -Wl,--disable-new-dtags | |
214 | LDFLAGS-tst-nss-test3 = -Wl,--disable-new-dtags | |
215 | LDFLAGS-tst-nss-test4 = -Wl,--disable-new-dtags | |
216 | LDFLAGS-tst-nss-test5 = -Wl,--disable-new-dtags | |
9bdf92c7 | 217 | LDFLAGS-tst-nss-test_errno = -Wl,--disable-new-dtags |