1 # Copyright (C) 1996-1998,2000-2002,2007,2009,2010,2011
2 # Free Software Foundation, Inc.
3 # This file is part of the GNU C Library.
5 # The GNU C Library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License, or (at your option) any later version.
10 # The GNU C Library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with the GNU C Library; if not, see
17 # <http://www.gnu.org/licenses/>.
20 # Makefile for name service switch.
25 distribute := nsswitch.h XXX-lookup.c getXXbyYY.c getXXbyYY_r.c \
26 getXXent.c getXXent_r.c databases.def \
27 nsswitch.conf digits_dots.c function.def
29 # This is the trivial part which goes into libc itself.
30 routines = nsswitch getnssent getnssent_r digits_dots \
31 $(addsuffix -lookup,$(databases))
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 rpc ethers \
37 spwd netgrp key alias sgrp
39 others := getent makedb
40 install-bin := getent makedb
41 makedb-modules = xmalloc hash-string
42 extra-objs += $(makedb-modules:=.o)
44 tests = test-netdb tst-nss-test1
49 ifeq (yes,$(build-static-nss))
50 otherlibs += $(nssobjdir)/libnss_files.a $(resolvobjdir)/libnss_dns.a \
51 $(resolvobjdir)/libresolv.a
54 # Specify rules for the nss_* modules. We have some services.
57 extra-libs = $(services:%=libnss_%)
58 # These libraries will be built in the `others' pass rather than
59 # the `lib' pass, because they depend on libc.so being built already.
60 extra-libs-others = $(extra-libs)
62 # The sources are found in the appropriate subdir.
63 subdir-dirs = $(services:%=nss_%)
64 vpath %.c $(subdir-dirs) ../locale/programs ../intl
67 libnss_files-routines := $(addprefix files-,$(databases)) \
68 files-initgroups files-have_o_cloexec files-init
69 distribute += files-XXX.c files-parse.c
71 libnss_db-dbs := $(addprefix db-,\
72 $(filter-out hosts network key alias,\
75 libnss_db-routines := $(libnss_db-dbs) db-open db-init hash-string
76 generated += $(filter-out db-alias.c db-netgrp.c, \
77 $(addsuffix .c,$(libnss_db-dbs)))
78 distribute += $(addprefix nss_db/, db-XXX.c nss_db.h)
80 install-others += $(inst_vardbdir)/Makefile
82 # Build static module if requested
83 ifneq ($(build-static-nss),yes)
84 libnss_files-inhibit-o = $(filter-out .os,$(object-suffixes))
85 libnss_db-inhibit-o = $(filter-out .os,$(object-suffixes))
91 ifeq (yes,$(build-static-nss))
92 $(objpfx)getent: $(objpfx)libnss_files.a
95 ifeq (yes,$(have-selinux))
96 LDLIBS-makedb := -lselinux
99 # Depend on libc.so so a DT_NEEDED is generated in the shared objects.
100 # This ensures they will load libc.so for needed symbols if loaded by
101 # a statically-linked program that hasn't already loaded it.
102 libnss-libc = $(common-objpfx)linkobj/libc.so
103 $(services:%=$(objpfx)libnss_%.so): $(libnss-libc) \
104 $(common-objpfx)libc_nonshared.a
106 $(objpfx)libnss_db.so: $(objpfx)libnss_files.so
108 $(libnss_db-dbs:%=$(objpfx)%.c): $(objpfx)db-%.c: nss_files/files-%.c
110 (echo '#define EXTERN_PARSER';\
111 echo '#define GENERIC "../nss_db/db-XXX.c"';\
112 echo '#include "$<"') > $@.new
116 $(objpfx)makedb: $(makedb-modules:%=$(objpfx)%.o)
118 $(inst_vardbdir)/Makefile: db-Makefile $(+force)
121 distribute += nss_test1.c
123 CFLAGS-nss_test1.c = -DNOT_IN_libc=1
124 $(objpfx)/libnss_test1.so: $(objpfx)nss_test1.os $(common-objpfx)libc.so \
125 $(common-objpfx)libc_nonshared.a
127 $(objpfx)/libnss_test1.so$(libnss_test1.so-version): $(objpfx)/libnss_test1.so
129 $(objpfx)tst-nss-test1.out: $(objpfx)/libnss_test1.so$(libnss_test1.so-version)