git: 0f0d52fd6ae7 - stable/13 - sbin: build ping if at least one of INET & INET6 is enabled

From: Ed Maste <emaste_at_FreeBSD.org>
Date: Mon, 13 Dec 2021 01:29:29 UTC
The branch stable/13 has been updated by emaste:

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

commit 0f0d52fd6ae71657ea0797338e633696c1c3567d
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2021-11-28 17:50:13 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2021-12-13 01:28:58 +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
    
    (cherry picked from commit a4ef9e58bc0c07110a54ba0fa88eb118c5377e6f)
    
    OptionalObsoleteFiles: remove ping with INET & INET6 disabled
    
    Reported by:    kevans
    Fixes:          a4ef9e58bc0c ("sbin: build ping if at least one of...")
    Sponsored by:   The FreeBSD Foundation
    
    (cherry picked from commit 0179739a0096c62cb3c9665d68246046255ab849)
---
 sbin/Makefile                            | 5 ++++-
 sbin/ping/main.c                         | 2 ++
 tools/build/mk/OptionalObsoleteFiles.inc | 5 +++++
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/sbin/Makefile b/sbin/Makefile
index 64840bae82bb..c9b548a8a390 100644
--- a/sbin/Makefile
+++ b/sbin/Makefile
@@ -53,7 +53,6 @@ SUBDIR=adjkerntz \
 	nfsiod \
 	nos-tun \
 	pfilctl \
-	ping \
 	rcorder \
 	reboot \
 	recoverdisk \
@@ -69,6 +68,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
diff --git a/tools/build/mk/OptionalObsoleteFiles.inc b/tools/build/mk/OptionalObsoleteFiles.inc
index 90e71f342b0e..c88ad051d940 100644
--- a/tools/build/mk/OptionalObsoleteFiles.inc
+++ b/tools/build/mk/OptionalObsoleteFiles.inc
@@ -2571,6 +2571,11 @@ OLD_DIRS+=usr/share/i18n/csmapper/KS
 OLD_DIRS+=usr/share/i18n/csmapper/GB
 .endif
 
+.if ${MK_INET} == no && ${MK_INET6} == no
+OLD_FILES+=sbin/ping
+OLD_FILES+=usr/share/man/man8/ping.8.gz
+.endif
+
 .if ${MK_INET6} == no
 OLD_FILES+=sbin/ping6
 OLD_FILES+=sbin/rtsol