Merge branch 'master' into bug13658-branch
[platform/upstream/glibc.git] / nss / Makefile
1 # Copyright (C) 1996-1998,2000-2002,2007,2009,2010,2011,2012
2 # Free Software Foundation, Inc.
3 # This file is part of the GNU C Library.
4
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.
9
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.
14
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/>.
18
19 #
20 #       Makefile for name service switch.
21 #
22 subdir  := nss
23
24 headers                 := nss.h
25
26 # This is the trivial part which goes into libc itself.
27 routines                = nsswitch getnssent getnssent_r digits_dots \
28                           $(addsuffix -lookup,$(databases))
29
30 # These are the databases that go through nss dispatch.
31 # Caution: if you add a database here, you must add its real name
32 # in databases.def, too.
33 databases               = proto service hosts network grp pwd rpc ethers \
34                           spwd netgrp key alias sgrp
35
36 others                  := getent makedb
37 install-bin             := getent makedb
38 makedb-modules = xmalloc hash-string
39 extra-objs              += $(makedb-modules:=.o)
40
41 tests                   = test-netdb tst-nss-test1
42 xtests                  = bug-erange
43
44 include ../Makeconfig
45
46 ifeq (yes,$(build-static-nss))
47 otherlibs += $(nssobjdir)/libnss_files.a $(resolvobjdir)/libnss_dns.a \
48              $(resolvobjdir)/libresolv.a
49 endif
50
51 # Specify rules for the nss_* modules.  We have some services.
52 services                := files db
53
54 extra-libs              = $(services:%=libnss_%)
55 # These libraries will be built in the `others' pass rather than
56 # the `lib' pass, because they depend on libc.so being built already.
57 extra-libs-others       = $(extra-libs)
58
59 # The sources are found in the appropriate subdir.
60 subdir-dirs = $(services:%=nss_%)
61 vpath %.c $(subdir-dirs) ../locale/programs ../intl
62
63
64 libnss_files-routines   := $(addprefix files-,$(databases)) \
65                            files-initgroups files-have_o_cloexec files-init
66
67 libnss_db-dbs           := $(addprefix db-,\
68                                        $(filter-out hosts network key alias,\
69                                                     $(databases))) \
70                            db-initgroups
71 libnss_db-routines      := $(libnss_db-dbs) db-open db-init hash-string
72 generated               += $(filter-out db-alias.c db-netgrp.c, \
73                                         $(addsuffix .c,$(libnss_db-dbs)))
74
75 install-others          += $(inst_vardbdir)/Makefile
76
77 # Build static module if requested
78 ifneq ($(build-static-nss),yes)
79 libnss_files-inhibit-o  = $(filter-out .os,$(object-suffixes))
80 libnss_db-inhibit-o     = $(filter-out .os,$(object-suffixes))
81 endif
82
83 include ../Rules
84
85
86 ifeq (yes,$(build-static-nss))
87 $(objpfx)getent: $(objpfx)libnss_files.a
88 endif
89
90 ifeq (yes,$(have-selinux))
91 LDLIBS-makedb           := -lselinux
92 endif
93
94 # Depend on libc.so so a DT_NEEDED is generated in the shared objects.
95 # This ensures they will load libc.so for needed symbols if loaded by
96 # a statically-linked program that hasn't already loaded it.
97 libnss-libc = $(common-objpfx)linkobj/libc.so
98 $(services:%=$(objpfx)libnss_%.so): $(libnss-libc) \
99                                     $(common-objpfx)libc_nonshared.a
100
101 $(objpfx)libnss_db.so: $(objpfx)libnss_files.so
102
103 $(libnss_db-dbs:%=$(objpfx)%.c): $(objpfx)db-%.c: nss_files/files-%.c
104         @rm -f $@.new
105         (echo '#define EXTERN_PARSER';\
106          echo '#define GENERIC "../nss_db/db-XXX.c"';\
107          echo '#include "$<"') > $@.new
108         mv -f $@.new $@
109
110
111 $(objpfx)makedb: $(makedb-modules:%=$(objpfx)%.o)
112
113 $(inst_vardbdir)/Makefile: db-Makefile $(+force)
114         $(do-install)
115
116 CFLAGS-nss_test1.c = -DNOT_IN_libc=1
117 $(objpfx)/libnss_test1.so: $(objpfx)nss_test1.os $(common-objpfx)libc.so \
118                            $(common-objpfx)libc_nonshared.a
119         $(build-module)
120 $(objpfx)/libnss_test1.so$(libnss_test1.so-version): $(objpfx)/libnss_test1.so
121         $(make-link)
122 $(objpfx)tst-nss-test1.out: $(objpfx)/libnss_test1.so$(libnss_test1.so-version)