Open /etc/resolv.conf with FD_CLOEXEC
[glibc.git] / nss / Makefile
blobfb6428345bf18230c2176cc6fe7bb2b765bc928a
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, write to the Free
17 # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 # 02111-1307 USA.
21 # Makefile for name service switch.
23 subdir := nss
25 headers := nss.h
26 distribute := nsswitch.h XXX-lookup.c getXXbyYY.c getXXbyYY_r.c \
27 getXXent.c getXXent_r.c databases.def \
28 nsswitch.conf digits_dots.c function.def
30 # This is the trivial part which goes into libc itself.
31 routines = nsswitch getnssent getnssent_r digits_dots \
32 $(addsuffix -lookup,$(databases))
34 # These are the databases that go through nss dispatch.
35 # Caution: if you add a database here, you must add its real name
36 # in databases.def, too.
37 databases = proto service hosts network grp pwd rpc ethers \
38 spwd netgrp key alias sgrp
40 others := getent makedb
41 install-bin := getent makedb
42 makedb-modules = xmalloc hash-string
43 extra-objs += $(makedb-modules:=.o)
45 tests = test-netdb tst-nss-test1
46 xtests = bug-erange
48 include ../Makeconfig
50 ifeq (yes,$(build-static-nss))
51 otherlibs += $(nssobjdir)/libnss_files.a $(resolvobjdir)/libnss_dns.a \
52 $(resolvobjdir)/libresolv.a
53 endif
55 # Specify rules for the nss_* modules. We have some services.
56 services := files db
58 extra-libs = $(services:%=libnss_%)
59 # These libraries will be built in the `others' pass rather than
60 # the `lib' pass, because they depend on libc.so being built already.
61 extra-libs-others = $(extra-libs)
63 # The sources are found in the appropriate subdir.
64 subdir-dirs = $(services:%=nss_%)
65 vpath %.c $(subdir-dirs) ../locale/programs ../intl
68 libnss_files-routines := $(addprefix files-,$(databases)) \
69 files-initgroups files-have_o_cloexec files-init
70 distribute += files-XXX.c files-parse.c
72 libnss_db-dbs := $(addprefix db-,\
73 $(filter-out hosts network key alias,\
74 $(databases))) \
75 db-initgroups
76 libnss_db-routines := $(libnss_db-dbs) db-open db-init hash-string
77 generated += $(filter-out db-alias.c db-netgrp.c, \
78 $(addsuffix .c,$(libnss_db-dbs)))
79 distribute += $(addprefix nss_db/, db-XXX.c nss_db.h)
81 install-others += $(inst_vardbdir)/Makefile
83 # Build static module if requested
84 ifneq ($(build-static-nss),yes)
85 libnss_files-inhibit-o = $(filter-out .os,$(object-suffixes))
86 libnss_db-inhibit-o = $(filter-out .os,$(object-suffixes))
87 endif
89 include ../Rules
92 ifeq (yes,$(build-static-nss))
93 $(objpfx)getent: $(objpfx)libnss_files.a
94 endif
96 ifeq (yes,$(have-selinux))
97 LDLIBS-makedb := -lselinux
98 endif
100 # Depend on libc.so so a DT_NEEDED is generated in the shared objects.
101 # This ensures they will load libc.so for needed symbols if loaded by
102 # a statically-linked program that hasn't already loaded it.
103 libnss-libc = $(common-objpfx)linkobj/libc.so
104 $(services:%=$(objpfx)libnss_%.so): $(libnss-libc) \
105 $(common-objpfx)libc_nonshared.a
107 $(objpfx)libnss_db.so: $(objpfx)libnss_files.so
109 $(libnss_db-dbs:%=$(objpfx)%.c): $(objpfx)db-%.c: nss_files/files-%.c
110 @rm -f $@.new
111 (echo '#define EXTERN_PARSER';\
112 echo '#define GENERIC "../nss_db/db-XXX.c"';\
113 echo '#include "$<"') > $@.new
114 mv -f $@.new $@
117 $(objpfx)makedb: $(makedb-modules:%=$(objpfx)%.o)
119 $(inst_vardbdir)/Makefile: db-Makefile $(+force)
120 $(do-install)
122 distribute += nss_test1.c
124 CFLAGS-nss_test1.c = -DNOT_IN_libc=1
125 $(objpfx)/libnss_test1.so: $(objpfx)nss_test1.os $(common-objpfx)libc.so \
126 $(common-objpfx)libc_nonshared.a
127 $(build-module)
128 $(objpfx)/libnss_test1.so$(libnss_test1.so-version): $(objpfx)/libnss_test1.so
129 $(make-link)
130 $(objpfx)tst-nss-test1.out: $(objpfx)/libnss_test1.so$(libnss_test1.so-version)