1 # Copyright (C) 1996-1998,2000-2002,2007,2009 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, write to the Free
16 # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 # Makefile for name service switch.
22 include ../option-groups.mak
27 distribute := nsswitch.h XXX-lookup.c getXXbyYY.c getXXbyYY_r.c \
28 getXXent.c getXXent_r.c databases.def \
29 nsswitch.conf digits_dots.c function.def \
32 # These are the databases that go through nss dispatch.
33 # Caution: if you add a database here, you must add its real name
34 # in databases.def, too.
35 databases-y = grp pwd spwd sgrp
36 databases-$(OPTION_EGLIBC_INET) \
37 += proto service hosts network rpc ethers \
39 databases-$(OPTION_EGLIBC_DB_ALIASES) += alias
41 # This is the trivial part which goes into libc itself.
42 routines-y += nsswitch getnssent getnssent_r \
43 $(addsuffix -lookup,$(databases-y))
44 routines-$(OPTION_EGLIBC_INET) += digits_dots
49 tests-$(OPTION_EGLIBC_INET) += test-netdb test-digits-dots
50 xtests-$(OPTION_EGLIBC_INET) += bug-erange
54 ifeq (yes,$(build-static-nss))
55 otherlibs += $(nssobjdir)/libnss_files.a $(resolvobjdir)/libnss_dns.a \
56 $(resolvobjdir)/libresolv.a
59 # Specify rules for the nss_* modules. We have some services.
62 extra-libs = $(services:%=libnss_%)
63 # These libraries will be built in the `others' pass rather than
64 # the `lib' pass, because they depend on libc.so being built already.
65 extra-libs-others = $(extra-libs)
67 # The sources are found in the appropriate subdir.
68 subdir-dirs = $(services:%=nss_%)
69 vpath %.c $(subdir-dirs)
72 libnss_files-routines := $(addprefix files-,$(databases-y)) \
74 distribute += files-XXX.c files-parse.c
77 # Build static module if requested
78 ifneq ($(build-static-nss),yes)
79 libnss_files-inhibit-o = $(filter-out .os,$(object-suffixes))
82 ifneq ($(OPTION_EGLIBC_NSSWITCH),y)
84 ifndef OPTION_EGLIBC_NSSWITCH_FIXED_CONFIG
85 $(error OPTION_EGLIBC_NSSWITCH_FIXED_CONFIG variable left unset)
88 ifndef OPTION_EGLIBC_NSSWITCH_FIXED_FUNCTIONS
89 $(error OPTION_EGLIBC_NSSWITCH_FIXED_FUNCTIONS variable left unset)
92 ifeq (,$(wildcard $(OPTION_EGLIBC_NSSWITCH_FIXED_CONFIG)))
93 $(warning OPTION_EGLIBC_NSSWITCH is disabled, but fixed config file)
94 $(error does not exist: $(OPTION_EGLIBC_NSSWITCH_FIXED_CONFIG))
97 ifeq (,$(wildcard $(OPTION_EGLIBC_NSSWITCH_FIXED_FUNCTIONS)))
98 $(warning OPTION_EGLIBC_NSSWITCH is disabled, but fixed functions file)
99 $(error does not exist: $(OPTION_EGLIBC_NSSWITCH_FIXED_FUNCTIONS))
102 before-compile := $(objpfx)fixed-nsswitch.h
103 generated := fixed-nsswitch.h
104 $(objpfx)fixed-nsswitch.h $(objfpx)fixed-nsswitch-libs: \
105 $(objpfx)gen-fixed-nsswitch \
106 $(OPTION_EGLIBC_NSSWITCH_FIXED_CONFIG)
107 $< $(objpfx)fixed-nsswitch.h \
108 $(objpfx)fixed-nsswitch-libs \
109 $(OPTION_EGLIBC_NSSWITCH_FIXED_CONFIG)
111 $(objpfx)gen-fixed-nsswitch: gen-fixed-nsswitch.c \
112 $(common-objpfx)option-groups.config \
113 $(OPTION_EGLIBC_NSSWITCH_FIXED_FUNCTIONS)
115 gen-fixed-nsswitch-CFLAGS = \
118 -DFIXED_FUNCTIONS='"$(OPTION_EGLIBC_NSSWITCH_FIXED_FUNCTIONS)"'
124 ifeq (yes,$(build-static-nss))
125 $(objpfx)getent: $(objpfx)libnss_files.a
128 # Depend on libc.so so a DT_NEEDED is generated in the shared objects.
129 # This ensures they will load libc.so for needed symbols if loaded by
130 # a statically-linked program that hasn't already loaded it.
131 $(services:%=$(objpfx)libnss_%.so): $(common-objpfx)libc.so \
132 $(common-objpfx)libc_nonshared.a