hurd: Fix getting ssize_t for <sys/socket.h>
[glibc.git] / nss / Makefile
blobc9a5200f96648c91799516f84147bf4e7577e190
1 # Copyright (C) 1996-2017 Free Software Foundation, Inc.
2 # This file is part of the GNU C Library.
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.
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.
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/>.
19 # Makefile for name service switch.
21 subdir := nss
23 include ../Makeconfig
25 headers := nss.h
27 # This is the trivial part which goes into libc itself.
28 routines = nsswitch getnssent getnssent_r digits_dots \
29 valid_field valid_list_field rewrite_field \
30 $(addsuffix -lookup,$(databases)) \
31 compat-lookup
33 # These are the databases that go through nss dispatch.
34 # Caution: if you add a database here, you must add its real name
35 # in databases.def, too.
36 databases = proto service hosts network grp pwd ethers \
37 spwd netgrp alias sgrp
39 ifneq (,$(filter sunrpc,$(subdirs)))
40 databases += key rpc
41 have-sunrpc := 1
42 else
43 have-sunrpc := 0
44 endif
45 CPPFLAGS-getent.c = -DHAVE_SUNRPC=$(have-sunrpc)
47 others := getent makedb
48 install-bin := getent makedb
49 makedb-modules = xmalloc hash-string
50 others-extras = $(makedb-modules)
51 extra-objs += $(makedb-modules:=.o)
53 tests-static = tst-field
54 tests-internal = tst-field
55 tests = test-netdb test-digits-dots tst-nss-getpwent bug17079 \
56 tst-nss-test1 \
57 tst-nss-test2 \
58 tst-nss-test3 \
59 tst-nss-test4 \
60 tst-nss-test5
61 xtests = bug-erange
63 # Tests which need libdl
64 ifeq (yes,$(build-shared))
65 tests += tst-nss-files-hosts-erange
66 endif
68 # If we have a thread library then we can test cancellation against
69 # some routines like getpwuid_r.
70 ifeq (yes,$(have-thread-library))
71 tests += tst-cancel-getpwuid_r
72 endif
74 # Specify rules for the nss_* modules. We have some services.
75 services := files db
77 extra-libs = $(services:%=libnss_%)
78 # These libraries will be built in the `others' pass rather than
79 # the `lib' pass, because they depend on libc.so being built already.
80 extra-libs-others = $(extra-libs)
82 # The sources are found in the appropriate subdir.
83 subdir-dirs = $(services:%=nss_%)
84 vpath %.c $(subdir-dirs) ../locale/programs ../intl
87 libnss_files-routines := $(addprefix files-,$(databases)) \
88 files-initgroups files-init
90 libnss_db-dbs := $(addprefix db-,\
91 $(filter-out hosts network key alias,\
92 $(databases))) \
93 db-initgroups
94 libnss_db-routines := $(libnss_db-dbs) db-open db-init hash-string
95 generated += $(filter-out db-alias.c db-netgrp.c, \
96 $(addsuffix .c,$(libnss_db-dbs)))
98 install-others += $(inst_vardbdir)/Makefile
100 # Build static module into libc if requested
101 libnss_files-inhibit-o = $(filter-out .os,$(object-suffixes))
102 libnss_db-inhibit-o = $(filter-out .os,$(object-suffixes))
103 ifeq ($(build-static-nss),yes)
104 routines += $(libnss_files-routines)
105 static-only-routines += $(libnss_files-routines)
106 tests-static += tst-nss-static
107 endif
108 extra-test-objs += nss_test1.os nss_test2.os
110 include ../Rules
112 ifeq (yes,$(have-selinux))
113 LDLIBS-makedb := -lselinux
114 endif
116 libnss-libc = $(common-objpfx)linkobj/libc.so
117 # Target-specific variable setting to link objects using deprecated
118 # RPC interfaces with the version of libc.so that makes them available
119 # for new links:
120 $(services:%=$(objpfx)libnss_%.so): libc-for-link = $(libnss-libc)
122 $(objpfx)libnss_db.so: $(objpfx)libnss_files.so
124 $(libnss_db-dbs:%=$(objpfx)%.c): $(objpfx)db-%.c: nss_files/files-%.c
125 @rm -f $@.new
126 (echo '#define EXTERN_PARSER';\
127 echo '#define GENERIC "../nss_db/db-XXX.c"';\
128 echo '#include "$<"') > $@.new
129 mv -f $@.new $@
132 $(objpfx)makedb: $(makedb-modules:%=$(objpfx)%.o)
134 $(inst_vardbdir)/Makefile: db-Makefile $(+force)
135 $(do-install)
137 libnss_test1.so-no-z-defs = 1
138 libnss_test2.so-no-z-defs = 1
140 rtld-tests-LDFLAGS += -Wl,--dynamic-list=nss_test.ver
142 libof-nss_test1 = extramodules
143 libof-nss_test2 = extramodules
144 $(objpfx)/libnss_test1.so: $(objpfx)nss_test1.os $(link-libc-deps)
145 $(build-module)
146 $(objpfx)/libnss_test2.so: $(objpfx)nss_test2.os $(link-libc-deps)
147 $(build-module)
148 $(objpfx)nss_test2.os : nss_test1.c
149 ifdef libnss_test1.so-version
150 $(objpfx)/libnss_test1.so$(libnss_test1.so-version): $(objpfx)/libnss_test1.so
151 $(make-link)
152 endif
153 ifdef libnss_test2.so-version
154 $(objpfx)/libnss_test2.so$(libnss_test2.so-version): $(objpfx)/libnss_test2.so
155 $(make-link)
156 endif
157 $(patsubst %,$(objpfx)%.out,$(tests)) : \
158 $(objpfx)/libnss_test1.so$(libnss_test1.so-version) \
159 $(objpfx)/libnss_test2.so$(libnss_test2.so-version)
161 ifeq (yes,$(have-thread-library))
162 $(objpfx)tst-cancel-getpwuid_r: $(shared-thread-library)
163 endif
165 $(objpfx)tst-nss-files-hosts-erange: $(libdl)