Reenable nss_db with a completely new implementation
[platform/upstream/glibc.git] / nss / Makefile
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.
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, write to the Free
17 # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 # 02111-1307 USA.
19
20 #
21 #       Makefile for name service switch.
22 #
23 subdir  := nss
24
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
29
30 # This is the trivial part which goes into libc itself.
31 routines                = nsswitch getnssent getnssent_r digits_dots \
32                           $(addsuffix -lookup,$(databases))
33
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
39
40 others                  := getent makedb
41 install-bin             := getent makedb
42 makedb-modules = xmalloc hash-string
43 extra-objs              += $(makedb-modules:=.o)
44
45 tests                   = test-netdb tst-nss-test1
46 xtests                  = bug-erange
47
48 include ../Makeconfig
49
50 ifeq (yes,$(build-static-nss))
51 otherlibs += $(nssobjdir)/libnss_files.a $(resolvobjdir)/libnss_dns.a \
52              $(resolvobjdir)/libresolv.a
53 endif
54
55 # Specify rules for the nss_* modules.  We have some services.
56 services                := files db
57
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)
62
63 # The sources are found in the appropriate subdir.
64 subdir-dirs = $(services:%=nss_%)
65 vpath %.c $(subdir-dirs) ../locale/programs ../intl
66
67
68 libnss_files-routines   := $(addprefix files-,$(databases)) \
69                            files-initgroups files-have_o_cloexec
70 distribute              += files-XXX.c files-parse.c
71
72 libnss_db-dbs           := $(addprefix db-,\
73                                        $(filter-out hosts network key alias,\
74                                                     $(databases)))
75 libnss_db-routines      := $(libnss_db-dbs) db-open 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)
79
80 # Build static module if requested
81 ifneq ($(build-static-nss),yes)
82 libnss_files-inhibit-o  = $(filter-out .os,$(object-suffixes))
83 libnss_db-inhibit-o     = $(filter-out .os,$(object-suffixes))
84 endif
85
86 include ../Rules
87
88
89 ifeq (yes,$(build-static-nss))
90 $(objpfx)getent: $(objpfx)libnss_files.a
91 endif
92
93 ifeq (yes,$(have-selinux))
94 LDLIBS-makedb           := -lselinux
95 endif
96
97 # Depend on libc.so so a DT_NEEDED is generated in the shared objects.
98 # This ensures they will load libc.so for needed symbols if loaded by
99 # a statically-linked program that hasn't already loaded it.
100 libnss-libc = $(common-objpfx)linkobj/libc.so
101 $(services:%=$(objpfx)libnss_%.so): $(libnss-libc) \
102                                     $(common-objpfx)libc_nonshared.a
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 distribute              += nss_test1.c
117
118 CFLAGS-nss_test1.c = -DNOT_IN_libc=1
119 $(objpfx)/libnss_test1.so: $(objpfx)nss_test1.os $(common-objpfx)libc.so \
120                            $(common-objpfx)libc_nonshared.a
121         $(build-module)
122 $(objpfx)/libnss_test1.so$(libnss_test1.so-version): $(objpfx)/libnss_test1.so
123         $(make-link)
124 $(objpfx)tst-nss-test1.out: $(objpfx)/libnss_test1.so$(libnss_test1.so-version)