Fix parsing of numeric hosts in gethostbyname_r
[glibc.git] / nss / Makefile
blob553eafaa6b9270554fda6d2bb4f925f7cf6486a2
1 # Copyright (C) 1996-2013 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 headers := nss.h
25 # This is the trivial part which goes into libc itself.
26 routines = nsswitch getnssent getnssent_r digits_dots \
27 $(addsuffix -lookup,$(databases))
29 # These are the databases that go through nss dispatch.
30 # Caution: if you add a database here, you must add its real name
31 # in databases.def, too.
32 databases = proto service hosts network grp pwd rpc ethers \
33 spwd netgrp key alias sgrp
35 others := getent makedb
36 install-bin := getent makedb
37 makedb-modules = xmalloc hash-string
38 extra-objs += $(makedb-modules:=.o)
40 tests = test-netdb tst-nss-test1 test-digits-dots
41 xtests = bug-erange
43 include ../Makeconfig
45 # Specify rules for the nss_* modules. We have some services.
46 services := files db
48 extra-libs = $(services:%=libnss_%)
49 # These libraries will be built in the `others' pass rather than
50 # the `lib' pass, because they depend on libc.so being built already.
51 extra-libs-others = $(extra-libs)
53 # The sources are found in the appropriate subdir.
54 subdir-dirs = $(services:%=nss_%)
55 vpath %.c $(subdir-dirs) ../locale/programs ../intl
58 libnss_files-routines := $(addprefix files-,$(databases)) \
59 files-initgroups files-have_o_cloexec files-init
61 libnss_db-dbs := $(addprefix db-,\
62 $(filter-out hosts network key alias,\
63 $(databases))) \
64 db-initgroups
65 libnss_db-routines := $(libnss_db-dbs) db-open db-init hash-string
66 generated += $(filter-out db-alias.c db-netgrp.c, \
67 $(addsuffix .c,$(libnss_db-dbs)))
69 install-others += $(inst_vardbdir)/Makefile
71 # Build static module into libc if requested
72 libnss_files-inhibit-o = $(filter-out .os,$(object-suffixes))
73 libnss_db-inhibit-o = $(filter-out .os,$(object-suffixes))
74 ifeq ($(build-static-nss),yes)
75 routines += $(libnss_files-routines)
76 static-only-routines += $(libnss_files-routines)
77 tests-static = tst-nss-static
78 tests += $(tests-static)
79 endif
81 include ../Rules
83 ifeq (yes,$(have-selinux))
84 LDLIBS-makedb := -lselinux
85 endif
87 # Depend on libc.so so a DT_NEEDED is generated in the shared objects.
88 # This ensures they will load libc.so for needed symbols if loaded by
89 # a statically-linked program that hasn't already loaded it.
90 libnss-libc = $(common-objpfx)linkobj/libc.so
91 $(services:%=$(objpfx)libnss_%.so): $(libnss-libc) \
92 $(common-objpfx)libc_nonshared.a
94 $(objpfx)libnss_db.so: $(objpfx)libnss_files.so
96 $(libnss_db-dbs:%=$(objpfx)%.c): $(objpfx)db-%.c: nss_files/files-%.c
97 @rm -f $@.new
98 (echo '#define EXTERN_PARSER';\
99 echo '#define GENERIC "../nss_db/db-XXX.c"';\
100 echo '#include "$<"') > $@.new
101 mv -f $@.new $@
104 $(objpfx)makedb: $(makedb-modules:%=$(objpfx)%.o)
106 $(inst_vardbdir)/Makefile: db-Makefile $(+force)
107 $(do-install)
109 CFLAGS-nss_test1.c = -DNOT_IN_libc=1
110 $(objpfx)/libnss_test1.so: $(objpfx)nss_test1.os $(common-objpfx)libc.so \
111 $(common-objpfx)libc_nonshared.a
112 $(build-module)
113 ifdef libnss_test1.so-version
114 $(objpfx)/libnss_test1.so$(libnss_test1.so-version): $(objpfx)/libnss_test1.so
115 $(make-link)
116 endif
117 $(objpfx)tst-nss-test1.out: $(objpfx)/libnss_test1.so$(libnss_test1.so-version)