]> git.ipfire.org Git - thirdparty/glibc.git/blame - nss/Makefile
Update copyright dates with scripts/update-copyrights
[thirdparty/glibc.git] / nss / Makefile
CommitLineData
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#
21subdir := nss
22
a5f891ac
JM
23include ../Makeconfig
24
a8874ead 25headers := nss.h
5f0e6fc7
RM
26
27# This is the trivial part which goes into libc itself.
a5fdf99b 28routines = 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
39databases = proto service hosts network grp pwd ethers \
40 spwd netgrp alias sgrp
41
42ifneq (,$(filter sunrpc,$(subdirs)))
43databases += key rpc
44have-sunrpc := 1
45else
46have-sunrpc := 0
47endif
48CPPFLAGS-getent.c = -DHAVE_SUNRPC=$(have-sunrpc)
5f0e6fc7 49
9ee76b5a
UD
50others := getent makedb
51install-bin := getent makedb
52makedb-modules = xmalloc hash-string
7b3ce395 53others-extras = $(makedb-modules)
9ee76b5a 54extra-objs += $(makedb-modules:=.o)
7d6a8338 55
676599b3 56tests-static = tst-field
7c3018f9 57tests-internal = tst-field
ae5c498d
DD
58tests = 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 63xtests = bug-erange
6591c335 64
561b0bec 65tests-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
73ifeq (yes,$(build-shared))
74tests += tst-nss-files-hosts-erange
d8425e11 75tests += tst-nss-files-hosts-multi
916124ed 76tests += tst-nss-files-hosts-getent
e95c6f61 77tests += tst-nss-files-alias-leak
2bac7daa 78tests += tst-nss-files-alias-truncated
f4a6be25
FW
79endif
80
b0a679f4
CD
81# If we have a thread library then we can test cancellation against
82# some routines like getpwuid_r.
83ifeq (yes,$(have-thread-library))
84tests += tst-cancel-getpwuid_r
85endif
86
5f0e6fc7 87# Specify rules for the nss_* modules. We have some services.
64d1e08e 88services := files db compat
5f0e6fc7
RM
89
90extra-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.
93extra-libs-others = $(extra-libs)
5f0e6fc7
RM
94
95# The sources are found in the appropriate subdir.
6dbe2837 96subdir-dirs = $(services:%=nss_%)
9ee76b5a 97vpath %.c $(subdir-dirs) ../locale/programs ../intl
5f0e6fc7
RM
98
99
94d9c76e
FW
100libnss_files-routines := $(addprefix files-, \
101 $(filter-out key, $(databases))) \
cef9b653 102 files-initgroups files-init
5f0e6fc7 103
2666d441
UD
104libnss_db-dbs := $(addprefix db-,\
105 $(filter-out hosts network key alias,\
9f2da732
UD
106 $(databases))) \
107 db-initgroups
319b9ad4 108libnss_db-routines := $(libnss_db-dbs) db-open db-init hash-string
2666d441
UD
109generated += $(filter-out db-alias.c db-netgrp.c, \
110 $(addsuffix .c,$(libnss_db-dbs)))
1aadea59 111
64d1e08e
AS
112libnss_compat-routines := $(addprefix compat-,grp pwd spwd initgroups) \
113 nisdomain
114
77fb9117
UD
115install-others += $(inst_vardbdir)/Makefile
116
3ff42526 117# Build static module into libc if requested
40a55d20 118libnss_files-inhibit-o = $(filter-out .os,$(object-suffixes))
2666d441 119libnss_db-inhibit-o = $(filter-out .os,$(object-suffixes))
64d1e08e 120libnss_compat-inhibit-o = $(filter-out .os,$(object-suffixes))
3ff42526
PP
121ifeq ($(build-static-nss),yes)
122routines += $(libnss_files-routines)
123static-only-routines += $(libnss_files-routines)
676599b3 124tests-static += tst-nss-static
6ca96fe2 125endif
ae5c498d 126extra-test-objs += nss_test1.os nss_test2.os
5f0e6fc7
RM
127
128include ../Rules
129
9ee76b5a
UD
130ifeq (yes,$(have-selinux))
131LDLIBS-makedb := -lselinux
132endif
133
7b57bfe5 134libnss-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
155libnss_test1.so-no-z-defs = 1
156libnss_test2.so-no-z-defs = 1
157
158rtld-tests-LDFLAGS += -Wl,--dynamic-list=nss_test.ver
159
9cd47470 160libof-nss_test1 = extramodules
ae5c498d 161libof-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 167ifdef libnss_test1.so-version
c3e2f19b
UD
168$(objpfx)/libnss_test1.so$(libnss_test1.so-version): $(objpfx)/libnss_test1.so
169 $(make-link)
6bacf05b 170endif
ae5c498d
DD
171ifdef libnss_test2.so-version
172$(objpfx)/libnss_test2.so$(libnss_test2.so-version): $(objpfx)/libnss_test2.so
173 $(make-link)
174endif
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
179ifeq (yes,$(have-thread-library))
180$(objpfx)tst-cancel-getpwuid_r: $(shared-thread-library)
181endif
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