git: a4ef9e58bc0c - main - sbin: build ping if at least one of INET & INET6 is enabled

From: Ed Maste <emaste_at_FreeBSD.org>
Date: Sun, 28 Nov 2021 18:08:08 UTC
The branch main has been updated by emaste:

URL: https://cgit.FreeBSD.org/src/commit/?id=a4ef9e58bc0c07110a54ba0fa88eb118c5377e6f

commit a4ef9e58bc0c07110a54ba0fa88eb118c5377e6f
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2021-11-28 17:50:13 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2021-11-28 18:05:39 +0000

    sbin: build ping if at least one of INET & INET6 is enabled
    
    It does not build (and serves no purpose) if neither is true (i.e.,
    building WITHOUT_INET and WITHOUT_INET6).  Also add an explicit error
    in ping to make this case clear.
    
    PR:             260082
    Sponsored by:   The FreeBSD Foundation
---
 sbin/Makefile    | 5 ++++-
 sbin/ping/main.c | 2 ++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/sbin/Makefile b/sbin/Makefile
index 7eb497e3e3dd..69cf51a83e26 100644
--- a/sbin/Makefile
+++ b/sbin/Makefile
@@ -53,7 +53,6 @@ SUBDIR=adjkerntz \
 	nfsiod \
 	nos-tun \
 	pfilctl \
-	ping \
 	rcorder \
 	reboot \
 	recoverdisk \
@@ -68,6 +67,10 @@ SUBDIR=adjkerntz \
 	tunefs \
 	umount
 
+.if ${MK_INET} != "no" || ${MK_INET6} != "no"
+SUBDIR+=	ping
+.endif
+
 SUBDIR.${MK_CCD}+=	ccdconfig
 SUBDIR.${MK_CXX}+=	devd
 SUBDIR.${MK_HAST}+=	hastctl
diff --git a/sbin/ping/main.c b/sbin/ping/main.c
index c021e2c26b14..1d0b714f1480 100644
--- a/sbin/ping/main.c
+++ b/sbin/ping/main.c
@@ -57,6 +57,8 @@ __FBSDID("$FreeBSD$");
 #define	OPTSTR PING4OPTS
 #elif defined(INET6)
 #define	OPTSTR PING6OPTS
+#else
+#error At least one of INET and INET6 is required
 #endif
 
 int