blob: 789ef423e517d042ea3192a967c49b057ecdd8e8 [file] [log] [blame]
xf.libdd93d52023-05-12 07:10:14 -07001# Copyright (C) 1994-2016 Free Software Foundation, Inc.
2# This file is part of the GNU C Library.
3
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.
8
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.
13
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/>.
17
18#
19# Sub-makefile for sunrpc portion of the library.
20#
21subdir := sunrpc
22
23include ../Makeconfig
24
25# The code in this subdirectory is taken from Sun's RPCSRC-4.0
26# distribution with some additional changes from the TI-RPC package
27# which is also available from Sun. The files are heavily changed to
28# compile cleanly and to fit in the GNU environment. All the code
29# from Sun's rpc, etc, and rpcgen subdirectories is in this directory;
30# the rpc subdirectory contains only the header files. Other than
31# that, several files were renamed so as not to exceed 14-character
32# file name limits:
33#
34# authunix_prot.c -> authuxprot.c
35# bindresvport.c -> bindrsvprt.c
36# clnt_generic.c -> clnt_gen.c
37# clnt_perror.c -> clnt_perr.c
38# clnt_simple.c -> clnt_simp.c
39# get_myaddress.c -> get_myaddr.c
40# pmap_getmaps.c -> pm_getmaps.c
41# pmap_getport.c -> pm_getport.c
42# rpc_callmsg.c -> rpc_cmsg.c
43# rpc_commondata.c -> rpc_common.c
44# rpc_dtablesize.c -> rpc_dtable.c
45# svc_auth_unix.c -> svc_authux.c
46# xdr_reference.c -> xdr_ref.c
47
48rpcsvc = bootparam_prot.x nlm_prot.x rstat.x \
49 yppasswd.x klm_prot.x rex.x sm_inter.x mount.x \
50 rusers.x spray.x nfs_prot.x rquota.x key_prot.x
51headers-in-tirpc = $(addprefix rpc/,auth.h auth_unix.h clnt.h pmap_clnt.h \
52 pmap_prot.h pmap_rmt.h rpc.h rpc_msg.h \
53 svc.h svc_auth.h types.h xdr.h auth_des.h \
54 des_crypt.h)
55headers-not-in-tirpc = $(addprefix rpc/,key_prot.h rpc_des.h) \
56 $(rpcsvc:%=rpcsvc/%) rpcsvc/bootparam.h
57headers = rpc/netdb.h
58install-others = $(inst_sysconfdir)/rpc
59generated += $(rpcsvc:%.x=rpcsvc/%.h) $(rpcsvc:%.x=x%.c) $(rpcsvc:%.x=x%.stmp) \
60 $(rpcsvc:%.x=rpcsvc/%.stmp) rpcgen
61generated-dirs += rpcsvc
62
63ifeq ($(link-obsolete-rpc),yes)
64headers += $(headers-in-tirpc) $(headers-not-in-tirpc)
65endif
66
67ifeq ($(build-shared),yes)
68need-export-routines := auth_des auth_unix clnt_gen clnt_perr clnt_tcp \
69 clnt_udp get_myaddr key_call netname pm_getport \
70 rpc_thread svc svc_tcp svc_udp xcrypt xdr_array xdr \
71 xdr_intXX_t xdr_mem xdr_ref xdr_sizeof xdr_stdio \
72 svc_run
73
74routines := auth_none authuxprot bindrsvprt clnt_raw clnt_simp \
75 rpc_dtable getrpcport pmap_clnt pm_getmaps pmap_prot pmap_prot2 \
76 pmap_rmt rpc_prot rpc_common rpc_cmsg svc_auth svc_authux svc_raw \
77 svc_simple xdr_float xdr_rec publickey authdes_prot \
78 des_crypt des_impl des_soft key_prot openchild rtime svcauth_des \
79 getrpcent getrpcbyname getrpcbynumber \
80 getrpcent_r getrpcbyname_r getrpcbynumber_r \
81 clnt_unix svc_unix create_xid $(need-export-routines)
82ifneq ($(link-obsolete-rpc),yes)
83# We only add the RPC for compatibility to libc.so.
84shared-only-routines = $(routines)
85endif
86endif
87
88# We do not build rpcinfo anymore. It is not needed for a bootstrap
89# and not wanted on complete systems.
90# others := rpcinfo
91# install-sbin := rpcinfo
92install-bin := rpcgen
93rpcgen-objs = rpc_main.o rpc_hout.o rpc_cout.o rpc_parse.o \
94 rpc_scan.o rpc_util.o rpc_svcout.o rpc_clntout.o \
95 rpc_tblout.o rpc_sample.o
96extra-objs = $(rpcgen-objs) $(addprefix cross-,$(rpcgen-objs))
97others += rpcgen
98
99tests = tst-xdrmem tst-xdrmem2 test-rpcent
100xtests := tst-getmyaddr
101
102ifeq ($(have-thread-library),yes)
103xtests += thrsvc
104endif
105
106headers += $(rpcsvc:%.x=rpcsvc/%.h)
107extra-libs := librpcsvc
108extra-libs-others := librpcsvc # Make it in `others' pass, not `lib' pass.
109librpcsvc-routines = $(rpcsvc:%.x=x%)
110librpcsvc-inhibit-o = .os # Build no shared rpcsvc library.
111omit-deps = $(librpcsvc-routines)
112
113ifeq (yes,$(build-shared))
114rpc-compat-routines = $(addprefix compat-,$(need-export-routines))
115rpc-compat-routines.os = $(addprefix $(objpfx), \
116 $(addsuffix .os,$(rpc-compat-routines)))
117extra-objs += $(addsuffix .os,$(rpc-compat-routines))
118endif
119
120include ../Rules
121
122ifeq (yes,$(build-shared))
123subdir_lib: $(objpfx)librpc_compat_pic.a
124$(objpfx)librpc_compat_pic.a: $(rpc-compat-routines.os)
125 $(AR) cr$(verbose) $@ $^
126$(rpc-compat-routines.os): $(objpfx)compat-%.os: %.c $(before-compile)
127 $(compile-command.c) -DEXPORT_RPC_SYMBOLS
128endif
129
130CFLAGS-xbootparam_prot.c = -Wno-unused $(PIC-ccflag)
131CFLAGS-xnlm_prot.c = -Wno-unused $(PIC-ccflag)
132CFLAGS-xrstat.c = -Wno-unused $(PIC-ccflag)
133CFLAGS-xyppasswd.c = -Wno-unused $(PIC-ccflag)
134CFLAGS-xklm_prot.c = -Wno-unused $(PIC-ccflag)
135CFLAGS-xrex.c = -Wno-unused $(PIC-ccflag)
136CFLAGS-xsm_inter.c = -Wno-unused $(PIC-ccflag)
137CFLAGS-xmount.c = -Wno-unused $(PIC-ccflag)
138CFLAGS-xrusers.c = -Wno-unused $(PIC-ccflag)
139CFLAGS-xspray.c = -Wno-unused $(PIC-ccflag)
140CFLAGS-xnfs_prot.c = -Wno-unused $(PIC-ccflag)
141CFLAGS-xrquota.c = -Wno-unused $(PIC-ccflag)
142CFLAGS-xkey_prot.c = -Wno-unused $(PIC-ccflag)
143CFLAGS-auth_unix.c = -fexceptions
144CFLAGS-key_call.c = -fexceptions
145CFLAGS-pmap_rmt.c = -fexceptions
146CFLAGS-clnt_perr.c = -fexceptions
147CFLAGS-openchild.c = -fexceptions
148
149sunrpc-CPPFLAGS = -D_RPC_THREAD_SAFE_
150CPPFLAGS += $(sunrpc-CPPFLAGS)
151BUILD_CPPFLAGS += $(sunrpc-CPPFLAGS)
152
153$(objpfx)tst-getmyaddr: $(common-objpfx)linkobj/libc.so
154$(objpfx)tst-xdrmem: $(common-objpfx)linkobj/libc.so
155$(objpfx)tst-xdrmem2: $(common-objpfx)linkobj/libc.so
156
157$(objpfx)rpcgen: $(addprefix $(objpfx),$(rpcgen-objs))
158
159cross-rpcgen-objs := $(addprefix $(objpfx)cross-,$(rpcgen-objs))
160
161# When generic makefile support for build system programs is
162# available, it should replace this code. See
163# <http://sourceware.org/bugzilla/show_bug.cgi?id=14087>.
164$(cross-rpcgen-objs): $(objpfx)cross-%.o: %.c $(before-compile)
165 $(BUILD_CC) $($(basename $(<F))-CFLAGS) $(ALL_BUILD_CFLAGS) $< \
166 $(OUTPUT_OPTION) $(native-compile-mkdep-flags) -c
167
168$(objpfx)cross-rpcgen: $(cross-rpcgen-objs)
169 $(BUILD_CC) $^ $(BUILD_LDFLAGS) -o $@
170
171# This makes sure -DIN_MODULE is passed for all these modules.
172cpp-srcs-left := $(rpcgen-objs:.o=.c)
173lib := nonlib
174include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left))
175
176# How we run rpcgen to generate sources and headers in the rules below.
177# Setting CPP tells it how to run the C preprocessor correctly. Note
178# that $(built-program-file) requires that the just-built cross-rpcgen
179# binary be the second dependency listed in each rule using rpcgen-cmd.
180rpcgen-cmd = CPP='$(CC) -E -x c-header' $(built-program-file) -Y ../scripts
181
182# Install the rpc data base file.
183$(inst_sysconfdir)/rpc: etc.rpc $(+force)
184 $(do-install)
185
186# Generate the rpcsvc headers with rpcgen.
187# We use a stamp file to avoid unnessary recompilation each time rpcgen is
188# relinked.
189$(rpcsvc:%.x=$(objpfx)rpcsvc/%.h): $(objpfx)rpcsvc/%.h: $(objpfx)rpcsvc/%.stmp
190 @:
191$(objpfx)rpcsvc/%.stmp: rpcsvc/%.x $(objpfx)cross-rpcgen
192 $(make-target-directory)
193 -@rm -f ${@:stmp=T} $@
194 $(rpcgen-cmd) -h $< -o ${@:stmp=T}
195 $(move-if-change) $(@:stmp=T) $(@:stmp=h)
196 touch $@
197
198# Generate the rpcsvc XDR functions with rpcgen.
199$(rpcsvc:%.x=$(objpfx)x%.c): $(objpfx)x%.c: $(objpfx)x%.stmp
200 @:
201$(objpfx)x%.stmp: rpcsvc/%.x $(objpfx)cross-rpcgen
202 -@rm -f ${@:stmp=T} $@
203 $(rpcgen-cmd) -c $< -o ${@:stmp=T}
204 $(move-if-change) $(@:stmp=T) $(@:stmp=c)
205 touch $@
206
207# The generated source files depend on the corresponding generated headers.
208# Gratuitous dependency on generated .c file here just gets it mentioned to
209# avoid being an intermediate file and getting removed.
210define o-iterator-doit
211$(rpcsvc:%.x=$(objpfx)x%$o): $(objpfx)x%$o: $(objpfx)x%.c $(objpfx)rpcsvc/%.h
212endef
213object-suffixes-left = $(filter-out $(librpcsvc-inhibit-o),$(object-suffixes))
214include $(o-iterator)
215
216rpcsvc-dt-files := $(foreach o,$(filter-out $(librpcsvc-inhibit-o),\
217 $(object-suffixes)),\
218 $(rpcsvc:%.x=$(objpfx)x%$o.dt))
219rpcsvc-depfiles := $(patsubst %.dt,%.d,$(wildcard $(rpcsvc-dt-files))) \
220 $(wildcard $(rpcsvc-dt-files:.dt=.d))
221ifdef rpcsvc-depfiles
222ifneq ($(no_deps),t)
223-include $(rpcsvc-depfiles)
224endif
225endif
226
227$(objpfx)thrsvc: $(common-objpfx)linkobj/libc.so $(shared-thread-library)