# Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
# This file is part of the GNU C Library.

# The GNU C Library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.

# The GNU C Library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Library General Public License for more details.

# You should have received a copy of the GNU Library General Public
# License along with the GNU C Library; see the file COPYING.LIB.  If not,
# write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.

#
#	Makefile for name service switch.
#
subdir	:= nss-v1

include ../Makeconfig

# The sources are found in the appropriate subdir.
subdir-dirs = nss1_compat nss1_db nss1_dns nss1_files nss1_nis
vpath %.c $(subdir-dirs)

extra-libs        := libnss1_compat libnss1_db libnss1_dns libnss1_files\
		     libnss1_nis
extra-libs-others := $(extra-libs)

# These are the databases that go through nss dispatch.
# Caution: if you add a database here, you must add its real name
# in databases.def, too.
databases               := proto service hosts network grp pwd rpc ethers\
			spwd netgrp alias

libnss1_files-routines	:= $(addprefix files-,$(databases))
libnss1_files-inhibit-o = $(filter-out .os,$(object-suffixes))

libnss1_db-routines	:= $(addprefix db-,$(filter-out hosts network,$(databases)))
libnss1_db-inhibit-o    = $(filter-out .os,$(object-suffixes))

libnss1_compat-routines  := $(addprefix compat-,grp pwd spwd)
libnss1_compat-inhibit-o = $(filter-out .os,$(object-suffixes))

libnss1_nis-routines     := $(addprefix nis-,$(databases))
libnss1_nis-inhibit-o    = $(filter-out .os,$(object-suffixes))

$(libnss1_db-routines:%=$(objpfx)%.c): $(objpfx)db-%.c: nss1_files/files-%.c
	@rm -f $@.new
	(echo '#define EXTERN_PARSER';\
	 echo '#define GENERIC "../nss1_db/db-XXX.c"';\
	 echo '#include <$<>') > $@.new
	mv -f $@.new $@

libnss1_dns-routines     := dns-host dns-network
libnss1_dns-inhibit-o    = $(filter-out .os,$(object-suffixes))

include ../Rules

# Force the soname to be libnss_*.so for compatibility.
LDFLAGS-nss1_compat.so = -Wl,-soname=lib$(libprefix)nss_compat.so$($(@F)-version)
LDFLAGS-nss1_db.so = -Wl,-soname=lib$(libprefix)nss_db.so$($(@F)-version)
LDFLAGS-nss1_dns.so = -Wl,-soname=lib$(libprefix)nss_dns.so$($(@F)-version)
LDFLAGS-nss1_files.so = -Wl,-soname=lib$(libprefix)nss_files.so$($(@F)-version)
LDFLAGS-nss1_nis.so = -Wl,-soname=lib$(libprefix)nss_nis.so$($(@F)-version)

# Depend on libc.so so a DT_NEEDED is generated in the shared objects.
# This ensures they will load libc.so for needed symbols if loaded by
# a statically-linked program that hasn't already loaded it.
$(objpfx)libnss1_compat.so: $(common-objpfx)nis/libnsl.so$(libnsl.so-version) \
                            $(objpfx)libnss1_files.so $(common-objpfx)libc.so
$(objpfx)libnss1_db.so: $(common-objpfx)db2/libdb.so $(objpfx)libnss1_files.so\
			$(common-objpfx)libc.so
$(objpfx)libnss1_dns.so: $(common-objpfx)resolv/libresolv.so \
			 $(common-objpfx)libc.so
$(objpfs)libnss1_files.so: $(common-objpfx)libc.so
$(objpfx)libnss1_nis.so: $(common-objpfx)nis/libnsl.so$(libnsl.so-version) \
                         $(objpfx)libnss1_files.so $(common-objpfx)libc.so
