1# Copyright (C) 1994-2022 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# <https://www.gnu.org/licenses/>.
17
18#
19#	Sub-makefile for sunrpc portion of the library.
20#
21subdir	:= sunrpc
22
23include ../Makeconfig
24
25ifdef have-GLIBC_2.31
26
27# The code in this subdirectory is taken from Sun's RPCSRC-4.0
28# distribution with some additional changes from the TI-RPC package
29# which is also available from Sun.  The files are heavily changed to
30# compile cleanly and to fit in the GNU environment.  All the code
31# from Sun's rpc and etc subdirectories is in this directory;
32# the rpc subdirectory contains only the header files.  Other than
33# that, several files were renamed so as not to exceed 14-character
34# file name limits:
35#
36#	authunix_prot.c -> authuxprot.c
37#	clnt_generic.c -> clnt_gen.c
38#	clnt_perror.c -> clnt_perr.c
39#	clnt_simple.c -> clnt_simp.c
40#	get_myaddress.c -> get_myaddr.c
41#	pmap_getmaps.c -> pm_getmaps.c
42#	pmap_getport.c -> pm_getport.c
43#	rpc_callmsg.c -> rpc_cmsg.c
44#	rpc_commondata.c -> rpc_common.c
45#	rpc_dtablesize.c -> rpc_dtable.c
46#	svc_auth_unix.c -> svc_authux.c
47#	xdr_reference.c -> xdr_ref.c
48
49ifeq ($(build-shared),yes)
50need-export-routines := auth_des auth_unix clnt_gen clnt_perr clnt_tcp \
51			clnt_udp get_myaddr key_call netname pm_getport \
52			rpc_thread svc svc_tcp svc_udp xcrypt xdr_array xdr \
53			xdr_intXX_t xdr_mem xdr_ref xdr_sizeof xdr_stdio \
54			svc_run
55
56routines := auth_none authuxprot clnt_raw clnt_simp \
57	    rpc_dtable getrpcport pmap_clnt pm_getmaps pmap_prot pmap_prot2 \
58	    pmap_rmt rpc_prot rpc_common rpc_cmsg svc_auth svc_authux svc_raw \
59	    svc_simple xdr_float xdr_rec publickey authdes_prot \
60	    des_crypt des_impl des_soft key_prot openchild rtime svcauth_des \
61	    clnt_unix svc_unix create_xid $(need-export-routines) \
62	    rpc_gethostbyname
63# We only add the RPC for compatibility to libc.so.
64shared-only-routines = $(routines)
65endif
66
67tests = tst-xdrmem tst-xdrmem2 test-rpcent tst-udp-error tst-udp-timeout \
68  tst-udp-nonblocking tst-bug22542 tst-bug28768
69
70xtests := tst-getmyaddr
71
72ifeq ($(have-thread-library),yes)
73xtests += thrsvc
74tests += tst-udp-garbage tst-svc_register
75endif
76
77ifeq (yes,$(build-shared))
78rpc-compat-routines = $(addprefix compat-,$(need-export-routines))
79rpc-compat-routines.os = $(addprefix $(objpfx), \
80				     $(addsuffix .os,$(rpc-compat-routines)))
81extra-objs += $(addsuffix .os,$(rpc-compat-routines))
82endif
83
84include ../Rules
85
86ifeq (yes,$(build-shared))
87subdir_lib: $(objpfx)librpc_compat_pic.a
88$(objpfx)librpc_compat_pic.a: $(rpc-compat-routines.os)
89	$(AR) cr$(verbose) $@ $^
90$(rpc-compat-routines.os): $(objpfx)compat-%.os: %.c $(before-compile)
91	$(compile-command.c) -DEXPORT_RPC_SYMBOLS
92endif
93
94CFLAGS-auth_unix.c += -fexceptions
95CFLAGS-key_call.c += -fexceptions
96CFLAGS-pmap_rmt.c += -fexceptions
97CFLAGS-clnt_perr.c += -fexceptions
98CFLAGS-openchild.c += -fexceptions
99
100$(objpfx)tst-getmyaddr: $(common-objpfx)linkobj/libc.so
101$(objpfx)tst-xdrmem: $(common-objpfx)linkobj/libc.so
102$(objpfx)tst-xdrmem2: $(common-objpfx)linkobj/libc.so
103$(objpfx)tst-udp-error: $(common-objpfx)linkobj/libc.so
104$(objpfx)tst-svc_register: \
105  $(common-objpfx)linkobj/libc.so $(shared-thread-library)
106
107$(objpfx)thrsvc: $(common-objpfx)linkobj/libc.so $(shared-thread-library)
108
109$(objpfx)tst-udp-timeout: $(common-objpfx)linkobj/libc.so
110$(objpfx)tst-udp-nonblocking: $(common-objpfx)linkobj/libc.so
111$(objpfx)tst-udp-garbage: \
112  $(common-objpfx)linkobj/libc.so $(shared-thread-library)
113
114$(objpfx)tst-bug22542: $(common-objpfx)linkobj/libc.so
115
116else # !have-GLIBC_2.31
117
118routines = $(routines-for-nss)
119
120include ../Rules
121
122ifeq (yes,$(build-shared))
123# Create an empty archive, so that Makerules can reference it.
124subdir_lib: $(objpfx)librpc_compat_pic.a
125$(objpfx)librpc_compat_pic.a: Makefile
126	$(make-target-directory)
127	$(AR) cr $@
128endif
129
130
131endif # !have-GLIBC_2.31
132