Blame sunrpc/Makefile

Packit 6c4009
# Copyright (C) 1994-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
#	Sub-makefile for sunrpc portion of the library.
Packit 6c4009
#
Packit 6c4009
subdir	:= sunrpc
Packit 6c4009
Packit 6c4009
include ../Makeconfig
Packit 6c4009
Packit 6c4009
# The code in this subdirectory is taken from Sun's RPCSRC-4.0
Packit 6c4009
# distribution with some additional changes from the TI-RPC package
Packit 6c4009
# which is also available from Sun.  The files are heavily changed to
Packit 6c4009
# compile cleanly and to fit in the GNU environment.  All the code
Packit 6c4009
# from Sun's rpc, etc, and rpcgen subdirectories is in this directory;
Packit 6c4009
# the rpc subdirectory contains only the header files.  Other than
Packit 6c4009
# that, several files were renamed so as not to exceed 14-character
Packit 6c4009
# file name limits:
Packit 6c4009
#
Packit 6c4009
#	authunix_prot.c -> authuxprot.c
Packit 6c4009
#	bindresvport.c -> bindrsvprt.c
Packit 6c4009
#	clnt_generic.c -> clnt_gen.c
Packit 6c4009
#	clnt_perror.c -> clnt_perr.c
Packit 6c4009
#	clnt_simple.c -> clnt_simp.c
Packit 6c4009
#	get_myaddress.c -> get_myaddr.c
Packit 6c4009
#	pmap_getmaps.c -> pm_getmaps.c
Packit 6c4009
#	pmap_getport.c -> pm_getport.c
Packit 6c4009
#	rpc_callmsg.c -> rpc_cmsg.c
Packit 6c4009
#	rpc_commondata.c -> rpc_common.c
Packit 6c4009
#	rpc_dtablesize.c -> rpc_dtable.c
Packit 6c4009
#	svc_auth_unix.c -> svc_authux.c
Packit 6c4009
#	xdr_reference.c -> xdr_ref.c
Packit 6c4009
Packit 6c4009
rpcsvc = bootparam_prot.x nlm_prot.x rstat.x \
Packit 6c4009
	 yppasswd.x klm_prot.x rex.x sm_inter.x mount.x \
Packit 6c4009
	 rusers.x spray.x nfs_prot.x rquota.x key_prot.x
Packit 6c4009
headers-sunrpc = $(addprefix rpc/,auth.h auth_unix.h clnt.h pmap_clnt.h \
Packit 6c4009
				  pmap_prot.h pmap_rmt.h rpc.h rpc_msg.h \
Packit 6c4009
				  svc.h svc_auth.h types.h xdr.h auth_des.h \
Packit 6c4009
				  key_prot.h) \
Packit 6c4009
		       $(rpcsvc:%=rpcsvc/%) rpcsvc/bootparam.h
Packit 6c4009
headers = rpc/netdb.h
Packit 6c4009
install-others = $(inst_sysconfdir)/rpc
Packit 6c4009
generated += $(rpcsvc:%.x=rpcsvc/%.h) $(rpcsvc:%.x=x%.c) $(rpcsvc:%.x=x%.stmp) \
Packit 6c4009
	     $(rpcsvc:%.x=rpcsvc/%.stmp) rpcgen
Packit 6c4009
generated-dirs += rpcsvc
Packit 6c4009
Packit 6c4009
ifeq ($(link-obsolete-rpc),yes)
Packit 6c4009
headers += $(headers-sunrpc)
Packit 6c4009
endif
Packit 6c4009
Packit 6c4009
ifeq ($(build-shared),yes)
Packit 6c4009
need-export-routines := auth_des auth_unix clnt_gen clnt_perr clnt_tcp \
Packit 6c4009
			clnt_udp get_myaddr key_call netname pm_getport \
Packit 6c4009
			rpc_thread svc svc_tcp svc_udp xcrypt xdr_array xdr \
Packit 6c4009
			xdr_intXX_t xdr_mem xdr_ref xdr_sizeof xdr_stdio \
Packit 6c4009
			svc_run
Packit 6c4009
Packit 6c4009
routines := auth_none authuxprot bindrsvprt clnt_raw clnt_simp \
Packit 6c4009
	    rpc_dtable getrpcport pmap_clnt pm_getmaps pmap_prot pmap_prot2 \
Packit 6c4009
	    pmap_rmt rpc_prot rpc_common rpc_cmsg svc_auth svc_authux svc_raw \
Packit 6c4009
	    svc_simple xdr_float xdr_rec publickey authdes_prot \
Packit 6c4009
	    des_crypt des_impl des_soft key_prot openchild rtime svcauth_des \
Packit 6c4009
	    getrpcent getrpcbyname getrpcbynumber \
Packit 6c4009
	    getrpcent_r getrpcbyname_r getrpcbynumber_r \
Packit 6c4009
	    clnt_unix svc_unix create_xid $(need-export-routines) \
Packit 6c4009
	    rpc_gethostbyname
Packit 6c4009
ifneq ($(link-obsolete-rpc),yes)
Packit 6c4009
# We only add the RPC for compatibility to libc.so.
Packit 6c4009
shared-only-routines = $(routines)
Packit 6c4009
endif
Packit 6c4009
endif
Packit 6c4009
Packit 6c4009
ifeq ($(link-obsolete-rpc),yes)
Packit 6c4009
install-bin := rpcgen
Packit 6c4009
rpcgen-objs = rpc_main.o rpc_hout.o rpc_cout.o rpc_parse.o \
Packit 6c4009
	      rpc_scan.o rpc_util.o rpc_svcout.o rpc_clntout.o \
Packit 6c4009
	      rpc_tblout.o rpc_sample.o
Packit 6c4009
extra-objs = $(rpcgen-objs) $(addprefix cross-,$(rpcgen-objs))
Packit 6c4009
others += rpcgen
Packit 6c4009
endif
Packit 6c4009
Packit 6c4009
tests = tst-xdrmem tst-xdrmem2 test-rpcent tst-udp-error tst-udp-timeout \
Packit 6c4009
  tst-udp-nonblocking
Packit 6c4009
xtests := tst-getmyaddr
Packit 6c4009
Packit 6c4009
ifeq ($(have-thread-library),yes)
Packit 6c4009
xtests += thrsvc
Packit 6c4009
tests += tst-udp-garbage
Packit 6c4009
tests-internal += tst-svc_register
Packit 6c4009
endif
Packit 6c4009
Packit 6c4009
ifeq ($(run-built-tests),yes)
Packit 6c4009
ifeq ($(link-obsolete-rpc),yes)
Packit 6c4009
rpcgen-tests := $(objpfx)bug20790.out
Packit 6c4009
tests-special += $(rpcgen-tests)
Packit 6c4009
endif
Packit 6c4009
endif
Packit 6c4009
Packit 6c4009
ifeq ($(link-obsolete-rpc),yes)
Packit 6c4009
headers += $(rpcsvc:%.x=rpcsvc/%.h)
Packit 6c4009
extra-libs := librpcsvc
Packit 6c4009
extra-libs-others := librpcsvc # Make it in `others' pass, not `lib' pass.
Packit 6c4009
librpcsvc-routines = $(rpcsvc:%.x=x%)
Packit 6c4009
librpcsvc-inhibit-o = .os # Build no shared rpcsvc library.
Packit 6c4009
omit-deps = $(librpcsvc-routines)
Packit 6c4009
endif
Packit 6c4009
Packit 6c4009
ifeq (yes,$(build-shared))
Packit 6c4009
rpc-compat-routines = $(addprefix compat-,$(need-export-routines))
Packit 6c4009
rpc-compat-routines.os = $(addprefix $(objpfx), \
Packit 6c4009
				     $(addsuffix .os,$(rpc-compat-routines)))
Packit 6c4009
extra-objs += $(addsuffix .os,$(rpc-compat-routines))
Packit 6c4009
endif
Packit 6c4009
Packit 6c4009
include ../Rules
Packit 6c4009
Packit 6c4009
ifeq (yes,$(build-shared))
Packit 6c4009
subdir_lib: $(objpfx)librpc_compat_pic.a
Packit 6c4009
$(objpfx)librpc_compat_pic.a: $(rpc-compat-routines.os)
Packit 6c4009
	$(AR) cr$(verbose) $@ $^
Packit 6c4009
$(rpc-compat-routines.os): $(objpfx)compat-%.os: %.c $(before-compile)
Packit 6c4009
	$(compile-command.c) -DEXPORT_RPC_SYMBOLS
Packit 6c4009
endif
Packit 6c4009
Packit 6c4009
CFLAGS-xbootparam_prot.c += -Wno-unused $(PIC-ccflag)
Packit 6c4009
CFLAGS-xnlm_prot.c += -Wno-unused $(PIC-ccflag)
Packit 6c4009
CFLAGS-xrstat.c += -Wno-unused $(PIC-ccflag)
Packit 6c4009
CFLAGS-xyppasswd.c += -Wno-unused $(PIC-ccflag)
Packit 6c4009
CFLAGS-xklm_prot.c += -Wno-unused $(PIC-ccflag)
Packit 6c4009
CFLAGS-xrex.c += -Wno-unused $(PIC-ccflag)
Packit 6c4009
CFLAGS-xsm_inter.c += -Wno-unused $(PIC-ccflag)
Packit 6c4009
CFLAGS-xmount.c += -Wno-unused $(PIC-ccflag)
Packit 6c4009
CFLAGS-xrusers.c += -Wno-unused $(PIC-ccflag)
Packit 6c4009
CFLAGS-xspray.c += -Wno-unused $(PIC-ccflag)
Packit 6c4009
CFLAGS-xnfs_prot.c += -Wno-unused $(PIC-ccflag)
Packit 6c4009
CFLAGS-xrquota.c += -Wno-unused $(PIC-ccflag)
Packit 6c4009
CFLAGS-xkey_prot.c += -Wno-unused $(PIC-ccflag)
Packit 6c4009
CFLAGS-auth_unix.c += -fexceptions
Packit 6c4009
CFLAGS-key_call.c += -fexceptions
Packit 6c4009
CFLAGS-pmap_rmt.c += -fexceptions
Packit 6c4009
CFLAGS-clnt_perr.c += -fexceptions
Packit 6c4009
CFLAGS-openchild.c += -fexceptions
Packit 6c4009
Packit 6c4009
$(objpfx)tst-getmyaddr: $(common-objpfx)linkobj/libc.so
Packit 6c4009
$(objpfx)tst-xdrmem: $(common-objpfx)linkobj/libc.so
Packit 6c4009
$(objpfx)tst-xdrmem2: $(common-objpfx)linkobj/libc.so
Packit 6c4009
$(objpfx)tst-udp-error: $(common-objpfx)linkobj/libc.so
Packit 6c4009
$(objpfx)tst-svc_register: \
Packit 6c4009
  $(common-objpfx)linkobj/libc.so $(shared-thread-library)
Packit 6c4009
Packit 6c4009
$(objpfx)rpcgen: $(addprefix $(objpfx),$(rpcgen-objs))
Packit 6c4009
Packit 6c4009
cross-rpcgen-objs := $(addprefix $(objpfx)cross-,$(rpcgen-objs))
Packit 6c4009
Packit 6c4009
# When generic makefile support for build system programs is
Packit 6c4009
# available, it should replace this code.  See
Packit 6c4009
# <https://sourceware.org/bugzilla/show_bug.cgi?id=14087>.
Packit 6c4009
$(cross-rpcgen-objs): $(objpfx)cross-%.o: %.c $(before-compile)
Packit 6c4009
	$(BUILD_CC) $($(basename $(
Packit 6c4009
		$(OUTPUT_OPTION) $(native-compile-mkdep-flags) -c
Packit 6c4009
Packit 6c4009
$(objpfx)cross-rpcgen: $(cross-rpcgen-objs)
Packit 6c4009
	$(BUILD_CC) $^ $(BUILD_LDFLAGS) -o $@
Packit 6c4009
Packit 6c4009
# This makes sure -DIN_MODULE is passed for all these modules.
Packit 6c4009
cpp-srcs-left := $(rpcgen-objs:.o=.c)
Packit 6c4009
lib := nonlib
Packit 6c4009
include $(patsubst %,$(..)libof-iterator.mk,$(cpp-srcs-left))
Packit 6c4009
Packit 6c4009
# How we run rpcgen to generate sources and headers in the rules below.
Packit 6c4009
# Setting CPP tells it how to run the C preprocessor correctly.  Note
Packit 6c4009
# that $(built-program-file) requires that the just-built cross-rpcgen
Packit 6c4009
# binary be the second dependency listed in each rule using rpcgen-cmd.
Packit 6c4009
rpcgen-cmd = CPP='$(CC) -E -x c-header' $(built-program-file) -Y ../scripts
Packit 6c4009
Packit 6c4009
# Install the rpc data base file.
Packit 6c4009
$(inst_sysconfdir)/rpc: etc.rpc $(+force)
Packit 6c4009
	$(do-install)
Packit 6c4009

Packit 6c4009
# Generate the rpcsvc headers with rpcgen.
Packit 6c4009
# We use a stamp file to avoid unnessary recompilation each time rpcgen is
Packit 6c4009
# relinked.
Packit 6c4009
$(rpcsvc:%.x=$(objpfx)rpcsvc/%.h): $(objpfx)rpcsvc/%.h: $(objpfx)rpcsvc/%.stmp
Packit 6c4009
	@:
Packit 6c4009
$(objpfx)rpcsvc/%.stmp: rpcsvc/%.x $(objpfx)cross-rpcgen
Packit 6c4009
	$(make-target-directory)
Packit 6c4009
	-@rm -f ${@:stmp=T} $@
Packit 6c4009
	$(rpcgen-cmd) -h $< -o ${@:stmp=T}
Packit 6c4009
	$(move-if-change) $(@:stmp=T) $(@:stmp=h)
Packit 6c4009
	touch $@
Packit 6c4009
Packit 6c4009
# Generate the rpcsvc XDR functions with rpcgen.
Packit 6c4009
$(rpcsvc:%.x=$(objpfx)x%.c): $(objpfx)x%.c: $(objpfx)x%.stmp
Packit 6c4009
	@:
Packit 6c4009
$(objpfx)x%.stmp: rpcsvc/%.x $(objpfx)cross-rpcgen
Packit 6c4009
	-@rm -f ${@:stmp=T} $@
Packit 6c4009
	$(rpcgen-cmd) -c $< -o ${@:stmp=T}
Packit 6c4009
	$(move-if-change) $(@:stmp=T) $(@:stmp=c)
Packit 6c4009
	touch $@
Packit 6c4009
Packit 6c4009
# The generated source files depend on the corresponding generated headers.
Packit 6c4009
# Gratuitous dependency on generated .c file here just gets it mentioned to
Packit 6c4009
# avoid being an intermediate file and getting removed.
Packit 6c4009
define o-iterator-doit
Packit 6c4009
$(rpcsvc:%.x=$(objpfx)x%$o): $(objpfx)x%$o: $(objpfx)x%.c $(objpfx)rpcsvc/%.h
Packit 6c4009
endef
Packit 6c4009
object-suffixes-left = $(filter-out $(librpcsvc-inhibit-o),$(object-suffixes))
Packit 6c4009
include $(o-iterator)
Packit 6c4009
Packit 6c4009
rpcsvc-dt-files := $(foreach o,$(filter-out $(librpcsvc-inhibit-o),\
Packit 6c4009
					    $(object-suffixes)),\
Packit 6c4009
			     $(rpcsvc:%.x=$(objpfx)x%$o.dt))
Packit 6c4009
rpcsvc-depfiles := $(patsubst %.dt,%.d,$(wildcard $(rpcsvc-dt-files))) \
Packit 6c4009
		   $(wildcard $(rpcsvc-dt-files:.dt=.d))
Packit 6c4009
ifdef rpcsvc-depfiles
Packit 6c4009
ifneq ($(no_deps),t)
Packit 6c4009
-include $(rpcsvc-depfiles)
Packit 6c4009
endif
Packit 6c4009
endif
Packit 6c4009
Packit 6c4009
$(objpfx)thrsvc: $(common-objpfx)linkobj/libc.so $(shared-thread-library)
Packit 6c4009
Packit 6c4009
ifeq ($(run-built-tests),yes)
Packit 6c4009
$(rpcgen-tests): $(objpfx)%.out: %.x $(objpfx)rpcgen
Packit 6c4009
	-rm -f $@
Packit 6c4009
	$(built-program-cmd) -c $< -o $@; \
Packit 6c4009
	$(evaluate-test)
Packit 6c4009
endif
Packit 6c4009
Packit 6c4009
$(objpfx)tst-udp-timeout: $(common-objpfx)linkobj/libc.so
Packit 6c4009
$(objpfx)tst-udp-nonblocking: $(common-objpfx)linkobj/libc.so
Packit 6c4009
$(objpfx)tst-udp-garbage: \
Packit 6c4009
  $(common-objpfx)linkobj/libc.so $(shared-thread-library)