Project:Toolchain/Glibc 2.26 porting notes/RPC implementation

This page provides a guideline and example code snippets to port packages away from SunRPC - necessary for everything listed in tracker. The snippets are taken from the first package on the tracker that I encountered, net-analyzer/dsniff, from which I prepared a reference implementation in my overlay.

Use flag(s)
If there's a use-flag, please use it to enable / disable entirely an optional RPC support. For switching between implementations, please use : if unset, use glibc's SunRPC, if set, pull in net-lib/libtirpc.

IUSE="+libtirpc"

It makes sense to default this flag to "on", for two reasons:
 * libtirpc is the more modern and likely faster implementation
 * libtirpc works independent of the installed glibc, while SunRPC will go away with glibc-2.26.

Dependencies
!libtirpc? ( sys-libs/glibc[rpc(-)] ) libtirpc? ( net-libs/rpcsvc-proto net-libs/libtirpc )

(Depending on the package you may need rpcsvc-proto or not. It provides the rpcgen binary.)

Patching the build system
Here's an example  snippet for providing switchable RPC implementation:

AC_ARG_WITH([libtirpc],           AS_HELP_STRING([--with-libtirpc], [Use libtirpc as RPC implementation (instead of sunrpc)]),            [], [ with_libtirpc=no ]) AS_IF([test "x$with_libtirpc" != xno],       [PKG_CHECK_MODULES([TIRPC], [libtirpc], [RPC_CFLAGS=$TIRPC_CFLAGS; RPC_LIBS=$TIRPC_LIBS;], [AC_MSG_ERROR([libtirpc requested, but library not found.])] )],       [AC_CHECK_HEADER(rpc/rpc.h,                        [RPC_CFLAGS=""; RPC_LIBS="";], [AC_MSG_ERROR([sunrpc requested, but headers are not present.])] )] ) AC_SUBST(RPC_CFLAGS) AC_SUBST(RPC_LIBS)

And here is a corresponding  snippet:

INCS  = -I. $(X11INC) -I$(srcdir)/missing @RPC_CFLAGS@ LIBS  = @LIBS@ -L$(srcdir) -lmissing @RPC_LIBS@

src_configure
econf $(use_with libtirpc)

Nuff said.