Blame nss/Makefile

Packit 6c4009
# Copyright (C) 1996-2018 Free Software Foundation, Inc.
Packit 6c4009
# This file is part of the GNU C Library.
Packit 6c4009
Packit 6c4009
# The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
# modify it under the terms of the GNU Lesser General Public
Packit 6c4009
# License as published by the Free Software Foundation; either
Packit 6c4009
# version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
# The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
# but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
# Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
# You should have received a copy of the GNU Lesser General Public
Packit 6c4009
# License along with the GNU C Library; if not, see
Packit 6c4009
# <http://www.gnu.org/licenses/>.
Packit 6c4009
Packit 6c4009
#
Packit 6c4009
#	Makefile for name service switch.
Packit 6c4009
#
Packit 6c4009
subdir	:= nss
Packit 6c4009
Packit 6c4009
include ../Makeconfig
Packit 6c4009
Packit 6c4009
headers			:= nss.h
Packit 6c4009
Packit 6c4009
# This is the trivial part which goes into libc itself.
Packit 6c4009
routines		= nsswitch getnssent getnssent_r digits_dots \
Packit 6c4009
			  valid_field valid_list_field rewrite_field \
Packit 6c4009
			  $(addsuffix -lookup,$(databases)) \
Packit Service 867ec4
			  compat-lookup nss_hash nss_files_fopen \
Packit Service 867ec4
			  nss_readline nss_parse_line_result \
Packit Service 867ec4
			  nss_fgetent_r
Packit 6c4009
Packit 6c4009
# These are the databases that go through nss dispatch.
Packit 6c4009
# Caution: if you add a database here, you must add its real name
Packit 6c4009
# in databases.def, too.
Packit 6c4009
databases		= proto service hosts network grp pwd ethers \
Packit 6c4009
			  spwd netgrp alias sgrp
Packit 6c4009
Packit 6c4009
ifneq (,$(filter sunrpc,$(subdirs)))
Packit 6c4009
databases		+= key rpc
Packit 6c4009
have-sunrpc		:= 1
Packit 6c4009
else
Packit 6c4009
have-sunrpc		:= 0
Packit 6c4009
endif
Packit 6c4009
CPPFLAGS-getent.c	= -DHAVE_SUNRPC=$(have-sunrpc)
Packit 6c4009
Packit 6c4009
others                  := getent makedb
Packit 6c4009
install-bin             := getent makedb
Packit 6c4009
makedb-modules = xmalloc hash-string
Packit 6c4009
others-extras		= $(makedb-modules)
Packit 6c4009
extra-objs		+= $(makedb-modules:=.o)
Packit 6c4009
Packit 6c4009
tests-static            = tst-field
Packit 6c4009
tests-internal		= tst-field
Packit 6c4009
tests			= test-netdb test-digits-dots tst-nss-getpwent bug17079 \
Packit 6c4009
			  tst-nss-test1 \
Packit 6c4009
			  tst-nss-test2 \
Packit 6c4009
			  tst-nss-test3 \
Packit 6c4009
			  tst-nss-test4 \
Packit 6c4009
			  tst-nss-test5
Packit 6c4009
xtests			= bug-erange
Packit 6c4009
Packit Service 0b5c9d
tests-container = \
Packit Service 0b5c9d
			  tst-nss-db-endpwent \
Packit Service 0b5c9d
			  tst-nss-db-endgrent
Packit Service 0b5c9d
Packit 6c4009
# Tests which need libdl
Packit 6c4009
ifeq (yes,$(build-shared))
Packit 6c4009
tests += tst-nss-files-hosts-erange
Packit 6c4009
tests += tst-nss-files-hosts-multi
Packit 6c4009
tests += tst-nss-files-hosts-getent
Packit Service b0f34f
tests += tst-nss-files-alias-leak
Packit 6c4009
endif
Packit 6c4009
Packit 6c4009
# If we have a thread library then we can test cancellation against
Packit 6c4009
# some routines like getpwuid_r.
Packit 6c4009
ifeq (yes,$(have-thread-library))
Packit 6c4009
tests += tst-cancel-getpwuid_r
Packit 6c4009
endif
Packit 6c4009
Packit 6c4009
# Specify rules for the nss_* modules.  We have some services.
Packit 6c4009
services		:= files db compat
Packit 6c4009
Packit 6c4009
extra-libs		= $(services:%=libnss_%)
Packit 6c4009
# These libraries will be built in the `others' pass rather than
Packit 6c4009
# the `lib' pass, because they depend on libc.so being built already.
Packit 6c4009
extra-libs-others	= $(extra-libs)
Packit 6c4009
Packit 6c4009
# The sources are found in the appropriate subdir.
Packit 6c4009
subdir-dirs = $(services:%=nss_%)
Packit 6c4009
vpath %.c $(subdir-dirs) ../locale/programs ../intl
Packit 6c4009
Packit Service 1d5bfa
# In RHEL we add nss_readline, nss_parse_line_result, and
Packit Service 1d5bfa
# nss_files_fopen to the libnss_files-routines in order to avoid the
Packit Service 1d5bfa
# case where a long running process (having never used NSS) attemps to
Packit Service 1d5bfa
# load an NSS module for the first time and that NSS module needs a
Packit Service 1d5bfa
# newer GLIBC_PRIVATE interface.  In effect we must make the NSS modules
Packit Service 1d5bfa
# self-sufficient and not rely on a GLIBC_PRIVATE interface.
Packit Service 1d5bfa
# See: https://bugzilla.redhat.com/show_bug.cgi?id=1927040
Packit Service 1d5bfa
# Note: We must recompile the objects to get the correct global symbol
Packit Service 1d5bfa
#       references, which is why we have the *_int.c wrappers.
Packit 6c4009
libnss_files-routines	:= $(addprefix files-,$(databases)) \
Packit Service 1d5bfa
			   files-initgroups files-init \
Packit Service 1d5bfa
			   nss_readline_int nss_parse_line_result_int \
Packit Service 1d5bfa
			   nss_files_fopen_int
Packit 6c4009
Packit 6c4009
libnss_db-dbs		:= $(addprefix db-,\
Packit 6c4009
				       $(filter-out hosts network key alias,\
Packit 6c4009
						    $(databases))) \
Packit 6c4009
			   db-initgroups
Packit 6c4009
libnss_db-routines	:= $(libnss_db-dbs) db-open db-init hash-string
Packit 6c4009
generated		+= $(filter-out db-alias.c db-netgrp.c, \
Packit 6c4009
					$(addsuffix .c,$(libnss_db-dbs)))
Packit 6c4009
Packit Service 1d5bfa
# See note above regarding nss_files_fopen.
Packit 6c4009
libnss_compat-routines	:= $(addprefix compat-,grp pwd spwd initgroups) \
Packit Service 1d5bfa
			   nisdomain \
Packit Service 1d5bfa
			   nss_files_fopen_int
Packit 6c4009
Packit 6c4009
install-others		+= $(inst_vardbdir)/Makefile
Packit 6c4009
Packit 6c4009
# Build static module into libc if requested
Packit 6c4009
libnss_files-inhibit-o	= $(filter-out .os,$(object-suffixes))
Packit 6c4009
libnss_db-inhibit-o	= $(filter-out .os,$(object-suffixes))
Packit 6c4009
libnss_compat-inhibit-o	= $(filter-out .os,$(object-suffixes))
Packit 6c4009
ifeq ($(build-static-nss),yes)
Packit 6c4009
routines                += $(libnss_files-routines)
Packit 6c4009
static-only-routines    += $(libnss_files-routines)
Packit 6c4009
tests-static		+= tst-nss-static
Packit 6c4009
endif
Packit 6c4009
extra-test-objs		+= nss_test1.os nss_test2.os
Packit 6c4009
Packit 6c4009
include ../Rules
Packit 6c4009
Packit 6c4009
ifeq (yes,$(have-selinux))
Packit 6c4009
LDLIBS-makedb		:= -lselinux
Packit 6c4009
endif
Packit 6c4009
Packit 6c4009
libnss-libc = $(common-objpfx)linkobj/libc.so
Packit 6c4009
# Target-specific variable setting to link objects using deprecated
Packit 6c4009
# RPC interfaces with the version of libc.so that makes them available
Packit 6c4009
# for new links:
Packit 6c4009
$(services:%=$(objpfx)libnss_%.so): libc-for-link = $(libnss-libc)
Packit 6c4009
Packit 6c4009
$(objpfx)libnss_db.so: $(objpfx)libnss_files.so
Packit 6c4009
Packit 6c4009
$(libnss_db-dbs:%=$(objpfx)%.c): $(objpfx)db-%.c: nss_files/files-%.c
Packit 6c4009
	@rm -f $@.new
Packit 6c4009
	(echo '#define EXTERN_PARSER';\
Packit 6c4009
	 echo '#define GENERIC "../nss_db/db-XXX.c"';\
Packit 6c4009
	 echo '#include "$<"') > $@.new
Packit 6c4009
	mv -f $@.new $@
Packit 6c4009
Packit 6c4009
Packit 6c4009
$(objpfx)makedb: $(makedb-modules:%=$(objpfx)%.o)
Packit 6c4009
Packit 6c4009
$(inst_vardbdir)/Makefile: db-Makefile $(+force)
Packit 6c4009
	$(do-install)
Packit 6c4009
Packit 6c4009
libnss_test1.so-no-z-defs = 1
Packit 6c4009
libnss_test2.so-no-z-defs = 1
Packit 6c4009
Packit 6c4009
rtld-tests-LDFLAGS += -Wl,--dynamic-list=nss_test.ver
Packit 6c4009
Packit 6c4009
libof-nss_test1 = extramodules
Packit 6c4009
libof-nss_test2 = extramodules
Packit 6c4009
$(objpfx)/libnss_test1.so: $(objpfx)nss_test1.os $(link-libc-deps)
Packit 6c4009
	$(build-module)
Packit 6c4009
$(objpfx)/libnss_test2.so: $(objpfx)nss_test2.os $(link-libc-deps)
Packit 6c4009
	$(build-module)
Packit 6c4009
$(objpfx)nss_test2.os : nss_test1.c
Packit 6c4009
ifdef libnss_test1.so-version
Packit 6c4009
$(objpfx)/libnss_test1.so$(libnss_test1.so-version): $(objpfx)/libnss_test1.so
Packit 6c4009
	$(make-link)
Packit 6c4009
endif
Packit 6c4009
ifdef libnss_test2.so-version
Packit 6c4009
$(objpfx)/libnss_test2.so$(libnss_test2.so-version): $(objpfx)/libnss_test2.so
Packit 6c4009
	$(make-link)
Packit 6c4009
endif
Packit 6c4009
$(patsubst %,$(objpfx)%.out,$(tests)) : \
Packit 6c4009
	$(objpfx)/libnss_test1.so$(libnss_test1.so-version) \
Packit 6c4009
	$(objpfx)/libnss_test2.so$(libnss_test2.so-version)
Packit 6c4009
Packit 6c4009
ifeq (yes,$(have-thread-library))
Packit 6c4009
$(objpfx)tst-cancel-getpwuid_r: $(shared-thread-library)
Packit 6c4009
endif
Packit 6c4009
Packit 6c4009
$(objpfx)tst-nss-files-hosts-erange: $(libdl)
Packit 6c4009
$(objpfx)tst-nss-files-hosts-multi: $(libdl)
Packit 6c4009
$(objpfx)tst-nss-files-hosts-getent: $(libdl)
Packit Service b0f34f
$(objpfx)tst-nss-files-alias-leak: $(libdl)
Packit Service b0f34f
$(objpfx)tst-nss-files-alias-leak.out: $(objpfx)/libnss_files.so