blob: b1693a875cf4485765a18f1fe8a41bbb87111607 [file] [log] [blame]
xf.libdd93d52023-05-12 07:10:14 -07001# Copyright (C) 1996-2016 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# <http://www.gnu.org/licenses/>.
17
18#
19# Makefile for name service switch.
20#
21subdir := nss
22
23include ../Makeconfig
24
25headers := nss.h
26
27# This is the trivial part which goes into libc itself.
28routines = nsswitch getnssent getnssent_r digits_dots \
29 valid_field valid_list_field rewrite_field \
30 $(addsuffix -lookup,$(databases))
31
32# These are the databases that go through nss dispatch.
33# Caution: if you add a database here, you must add its real name
34# in databases.def, too.
35databases = proto service hosts network grp pwd ethers \
36 spwd netgrp alias sgrp
37
38ifneq (,$(filter sunrpc,$(subdirs)))
39databases += key rpc
40have-sunrpc := 1
41else
42have-sunrpc := 0
43endif
44CPPFLAGS-getent.c = -DHAVE_SUNRPC=$(have-sunrpc)
45
46others := getent makedb
47install-bin := getent makedb
48makedb-modules = xmalloc hash-string
49extra-objs += $(makedb-modules:=.o)
50
51tests-static = tst-field
52tests = test-netdb tst-nss-test1 test-digits-dots \
53 tst-nss-getpwent bug17079 \
54 $(tests-static)
55xtests = bug-erange
56
57# Specify rules for the nss_* modules. We have some services.
58services := files db
59
60extra-libs = $(services:%=libnss_%)
61# These libraries will be built in the `others' pass rather than
62# the `lib' pass, because they depend on libc.so being built already.
63extra-libs-others = $(extra-libs)
64
65# The sources are found in the appropriate subdir.
66subdir-dirs = $(services:%=nss_%)
67vpath %.c $(subdir-dirs) ../locale/programs ../intl
68
69
70libnss_files-routines := $(addprefix files-,$(databases)) \
71 files-initgroups files-have_o_cloexec files-init
72
73libnss_db-dbs := $(addprefix db-,\
74 $(filter-out hosts network key alias,\
75 $(databases))) \
76 db-initgroups
77libnss_db-routines := $(libnss_db-dbs) db-open db-init hash-string
78generated += $(filter-out db-alias.c db-netgrp.c, \
79 $(addsuffix .c,$(libnss_db-dbs)))
80
81install-others += $(inst_vardbdir)/Makefile
82
83# Build static module into libc if requested
84libnss_files-inhibit-o = $(filter-out .os,$(object-suffixes))
85libnss_db-inhibit-o = $(filter-out .os,$(object-suffixes))
86ifeq ($(build-static-nss),yes)
87routines += $(libnss_files-routines)
88static-only-routines += $(libnss_files-routines)
89tests-static += tst-nss-static
90endif
91
92include ../Rules
93
94ifeq (yes,$(have-selinux))
95LDLIBS-makedb := -lselinux
96endif
97
98libnss-libc = $(common-objpfx)linkobj/libc.so
99# Target-specific variable setting to link objects using deprecated
100# RPC interfaces with the version of libc.so that makes them available
101# for new links:
102$(services:%=$(objpfx)libnss_%.so): libc-for-link = $(libnss-libc)
103
104$(objpfx)libnss_db.so: $(objpfx)libnss_files.so
105
106$(libnss_db-dbs:%=$(objpfx)%.c): $(objpfx)db-%.c: nss_files/files-%.c
107 @rm -f $@.new
108 (echo '#define EXTERN_PARSER';\
109 echo '#define GENERIC "../nss_db/db-XXX.c"';\
110 echo '#include "$<"') > $@.new
111 mv -f $@.new $@
112
113
114$(objpfx)makedb: $(makedb-modules:%=$(objpfx)%.o)
115
116$(inst_vardbdir)/Makefile: db-Makefile $(+force)
117 $(do-install)
118
119libof-nss_test1 = extramodules
120$(objpfx)/libnss_test1.so: $(objpfx)nss_test1.os $(link-libc-deps)
121 $(build-module)
122ifdef libnss_test1.so-version
123$(objpfx)/libnss_test1.so$(libnss_test1.so-version): $(objpfx)/libnss_test1.so
124 $(make-link)
125endif
126$(objpfx)tst-nss-test1.out: $(objpfx)/libnss_test1.so$(libnss_test1.so-version)