From 928d69309592704892d124b1f8de9111164c3793 Mon Sep 17 00:00:00 2001
From: Mike Frysinger <vapier@gentoo.org>
Date: Mon, 18 Jun 2018 22:11:21 -0400
Subject: [PATCH] configure: add a --without-rpc flag

The build already supports NO_RPC to disable all RPC logic.  Turn it
into a proper configure flag so people don't have to hack it up.
---
 configure.ac | 25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/configure.ac b/configure.ac
index 8d0b562ddaac..75ae7fb472dc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -37,11 +37,6 @@ AC_CHECK_LIB([m], [log10], [
 	AC_MSG_ERROR([Unable to find working libm.so])
 ])
 AC_SUBST([LIBM_LIBS])
-PKG_CHECK_MODULES([TIRPC],[libtirpc], [
-	AC_DEFINE([HAVE_RPCENT_H], [1], [Have <rpc/rpcent.h>.])
-], [
-	AC_MSG_WARN([Libtirpc not found, will not use <rpc/rpcent.h>])
-])
 
 # ======================================
 # Check for various headers and settings
@@ -112,6 +107,26 @@ AS_IF([test x"$with_labeled_networking" != "xno"], [
     ])
 ])
 
+AC_ARG_WITH([rpc],
+    [AS_HELP_STRING([--without-rpc], [Do not include RPC support])],
+    [with_rpc="$withval"],
+    [with_rpc="auto"]
+)
+AS_IF([test x"$with_rpc" != "xno"], [
+    PKG_CHECK_MODULES([TIRPC],[libtirpc], [
+        AC_DEFINE([HAVE_RPCENT_H], [1], [Have <rpc/rpcent.h>.])
+    ], [
+        AS_IF([test x"$with_rpc" = "xyes"], [
+            AC_MSG_ERROR([RPC support requested but not found])
+        ])
+        with_rpc="no"
+        AC_MSG_WARN([Libtirpc not found, will not use <rpc/rpcent.h>])
+    ])
+])
+AS_IF([test x"$with_rpc" = "xno"], [
+    AC_DEFINE([NO_RPC], [1], [Omit RPC support.])
+])
+
 # =========
 # Hardening
 # =========
-- 
2.16.1

