]>
Commit | Line | Data |
---|---|---|
2b778ceb | 1 | # Copyright (C) 1996-2021 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 \ |
fa78feca | 34 | nss_action_parse nss_database |
5f0e6fc7 | 35 | |
6dbe2837 | 36 | # These are the databases that go through nss dispatch. |
a8874ead UD |
37 | # Caution: if you add a database here, you must add its real name |
38 | # in databases.def, too. | |
a1309c2b RM |
39 | databases = proto service hosts network grp pwd ethers \ |
40 | spwd netgrp alias sgrp | |
41 | ||
42 | ifneq (,$(filter sunrpc,$(subdirs))) | |
43 | databases += key rpc | |
44 | have-sunrpc := 1 | |
45 | else | |
46 | have-sunrpc := 0 | |
47 | endif | |
48 | CPPFLAGS-getent.c = -DHAVE_SUNRPC=$(have-sunrpc) | |
5f0e6fc7 | 49 | |
9ee76b5a UD |
50 | others := getent makedb |
51 | install-bin := getent makedb | |
52 | makedb-modules = xmalloc hash-string | |
7b3ce395 | 53 | others-extras = $(makedb-modules) |
9ee76b5a | 54 | extra-objs += $(makedb-modules:=.o) |
7d6a8338 | 55 | |
676599b3 | 56 | tests-static = tst-field |
7c3018f9 | 57 | tests-internal = tst-field |
ae5c498d DD |
58 | tests = test-netdb test-digits-dots tst-nss-getpwent bug17079 \ |
59 | tst-nss-test1 \ | |
60 | tst-nss-test2 \ | |
ae5c498d DD |
61 | tst-nss-test4 \ |
62 | tst-nss-test5 | |
9a1c21c4 | 63 | xtests = bug-erange |
6591c335 | 64 | |
561b0bec | 65 | tests-container = \ |
11eb21c4 | 66 | tst-nss-test3 \ |
99135114 DD |
67 | tst-nss-files-hosts-long \ |
68 | tst-nss-db-endpwent \ | |
f8847d83 DD |
69 | tst-nss-db-endgrent \ |
70 | tst-reload1 | |
561b0bec | 71 | |
f4a6be25 FW |
72 | # Tests which need libdl |
73 | ifeq (yes,$(build-shared)) | |
74 | tests += tst-nss-files-hosts-erange | |
d8425e11 | 75 | tests += tst-nss-files-hosts-multi |
916124ed | 76 | tests += tst-nss-files-hosts-getent |
e95c6f61 | 77 | tests += tst-nss-files-alias-leak |
2bac7daa | 78 | tests += tst-nss-files-alias-truncated |
f4a6be25 FW |
79 | endif |
80 | ||
b0a679f4 CD |
81 | # If we have a thread library then we can test cancellation against |
82 | # some routines like getpwuid_r. | |
83 | ifeq (yes,$(have-thread-library)) | |
84 | tests += tst-cancel-getpwuid_r | |
85 | endif | |
86 | ||
5f0e6fc7 | 87 | # Specify rules for the nss_* modules. We have some services. |
64d1e08e | 88 | services := files db compat |
5f0e6fc7 RM |
89 | |
90 | extra-libs = $(services:%=libnss_%) | |
dbe31b9a RM |
91 | # These libraries will be built in the `others' pass rather than |
92 | # the `lib' pass, because they depend on libc.so being built already. | |
93 | extra-libs-others = $(extra-libs) | |
5f0e6fc7 RM |
94 | |
95 | # The sources are found in the appropriate subdir. | |
6dbe2837 | 96 | subdir-dirs = $(services:%=nss_%) |
9ee76b5a | 97 | vpath %.c $(subdir-dirs) ../locale/programs ../intl |
5f0e6fc7 RM |
98 | |
99 | ||
94d9c76e FW |
100 | libnss_files-routines := $(addprefix files-, \ |
101 | $(filter-out key, $(databases))) \ | |
cef9b653 | 102 | files-initgroups files-init |
5f0e6fc7 | 103 | |
2666d441 UD |
104 | libnss_db-dbs := $(addprefix db-,\ |
105 | $(filter-out hosts network key alias,\ | |
9f2da732 UD |
106 | $(databases))) \ |
107 | db-initgroups | |
319b9ad4 | 108 | libnss_db-routines := $(libnss_db-dbs) db-open db-init hash-string |
2666d441 UD |
109 | generated += $(filter-out db-alias.c db-netgrp.c, \ |
110 | $(addsuffix .c,$(libnss_db-dbs))) | |
1aadea59 | 111 | |
64d1e08e AS |
112 | libnss_compat-routines := $(addprefix compat-,grp pwd spwd initgroups) \ |
113 | nisdomain | |
114 | ||
77fb9117 UD |
115 | install-others += $(inst_vardbdir)/Makefile |
116 | ||
3ff42526 | 117 | # Build static module into libc if requested |
40a55d20 | 118 | libnss_files-inhibit-o = $(filter-out .os,$(object-suffixes)) |
2666d441 | 119 | libnss_db-inhibit-o = $(filter-out .os,$(object-suffixes)) |
64d1e08e | 120 | libnss_compat-inhibit-o = $(filter-out .os,$(object-suffixes)) |
3ff42526 PP |
121 | ifeq ($(build-static-nss),yes) |
122 | routines += $(libnss_files-routines) | |
123 | static-only-routines += $(libnss_files-routines) | |
676599b3 | 124 | tests-static += tst-nss-static |
6ca96fe2 | 125 | endif |
ae5c498d | 126 | extra-test-objs += nss_test1.os nss_test2.os |
5f0e6fc7 RM |
127 | |
128 | include ../Rules | |
129 | ||
9ee76b5a UD |
130 | ifeq (yes,$(have-selinux)) |
131 | LDLIBS-makedb := -lselinux | |
132 | endif | |
133 | ||
7b57bfe5 | 134 | libnss-libc = $(common-objpfx)linkobj/libc.so |
fab7ce3f JM |
135 | # Target-specific variable setting to link objects using deprecated |
136 | # RPC interfaces with the version of libc.so that makes them available | |
137 | # for new links: | |
138 | $(services:%=$(objpfx)libnss_%.so): libc-for-link = $(libnss-libc) | |
c3e2f19b | 139 | |
2666d441 UD |
140 | $(objpfx)libnss_db.so: $(objpfx)libnss_files.so |
141 | ||
142 | $(libnss_db-dbs:%=$(objpfx)%.c): $(objpfx)db-%.c: nss_files/files-%.c | |
143 | @rm -f $@.new | |
144 | (echo '#define EXTERN_PARSER';\ | |
145 | echo '#define GENERIC "../nss_db/db-XXX.c"';\ | |
146 | echo '#include "$<"') > $@.new | |
147 | mv -f $@.new $@ | |
148 | ||
c3e2f19b | 149 | |
9ee76b5a UD |
150 | $(objpfx)makedb: $(makedb-modules:%=$(objpfx)%.o) |
151 | ||
77fb9117 UD |
152 | $(inst_vardbdir)/Makefile: db-Makefile $(+force) |
153 | $(do-install) | |
154 | ||
ae5c498d DD |
155 | libnss_test1.so-no-z-defs = 1 |
156 | libnss_test2.so-no-z-defs = 1 | |
157 | ||
158 | rtld-tests-LDFLAGS += -Wl,--dynamic-list=nss_test.ver | |
159 | ||
9cd47470 | 160 | libof-nss_test1 = extramodules |
ae5c498d | 161 | libof-nss_test2 = extramodules |
fab7ce3f | 162 | $(objpfx)/libnss_test1.so: $(objpfx)nss_test1.os $(link-libc-deps) |
c3e2f19b | 163 | $(build-module) |
ae5c498d DD |
164 | $(objpfx)/libnss_test2.so: $(objpfx)nss_test2.os $(link-libc-deps) |
165 | $(build-module) | |
166 | $(objpfx)nss_test2.os : nss_test1.c | |
6bacf05b | 167 | ifdef libnss_test1.so-version |
c3e2f19b UD |
168 | $(objpfx)/libnss_test1.so$(libnss_test1.so-version): $(objpfx)/libnss_test1.so |
169 | $(make-link) | |
6bacf05b | 170 | endif |
ae5c498d DD |
171 | ifdef libnss_test2.so-version |
172 | $(objpfx)/libnss_test2.so$(libnss_test2.so-version): $(objpfx)/libnss_test2.so | |
173 | $(make-link) | |
174 | endif | |
268bb71e | 175 | $(patsubst %,$(objpfx)%.out,$(tests) $(tests-container)) : \ |
ae5c498d DD |
176 | $(objpfx)/libnss_test1.so$(libnss_test1.so-version) \ |
177 | $(objpfx)/libnss_test2.so$(libnss_test2.so-version) | |
b0a679f4 CD |
178 | |
179 | ifeq (yes,$(have-thread-library)) | |
180 | $(objpfx)tst-cancel-getpwuid_r: $(shared-thread-library) | |
181 | endif | |
f4a6be25 FW |
182 | |
183 | $(objpfx)tst-nss-files-hosts-erange: $(libdl) | |
d8425e11 | 184 | $(objpfx)tst-nss-files-hosts-multi: $(libdl) |
916124ed | 185 | $(objpfx)tst-nss-files-hosts-getent: $(libdl) |
e95c6f61 FW |
186 | $(objpfx)tst-nss-files-alias-leak: $(libdl) |
187 | $(objpfx)tst-nss-files-alias-leak.out: $(objpfx)/libnss_files.so | |
081bdf94 FW |
188 | $(objpfx)tst-nss-files-alias-truncated: $(libdl) |
189 | $(objpfx)tst-nss-files-alias-truncated.out: $(objpfx)/libnss_files.so |