git: 9e914c7af1f3 - main - Add new DISK_IMAGE_TOOLS_BOOTSTRAP option

From: Jessica Clarke <jrtc27_at_FreeBSD.org>
Date: Wed, 15 Mar 2023 00:07:15 UTC
The branch main has been updated by jrtc27:

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

commit 9e914c7af1f3d176acf2712e5a86a9a6a7b779c6
Author:     Jessica Clarke <jrtc27@FreeBSD.org>
AuthorDate: 2023-03-15 00:06:53 +0000
Commit:     Jessica Clarke <jrtc27@FreeBSD.org>
CommitDate: 2023-03-15 00:06:53 +0000

    Add new DISK_IMAGE_TOOLS_BOOTSTRAP option
    
    This will build etdump, makefs and mkimg as bootstrap tools to allow
    easily creating disk images. Note that etdump is bootstrapped due to its
    use in the release scripts for building ISO images.
    
    Reviewed by:    emaste, arichardson
    Differential Revision:  https://reviews.freebsd.org/D39072
---
 Makefile.inc1                                      | 22 ++++++++++++++++++++--
 share/man/man5/src.conf.5                          |  7 +++++++
 share/mk/src.opts.mk                               |  1 +
 .../build/options/WITH_DISK_IMAGE_TOOLS_BOOTSTRAP  |  6 ++++++
 4 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/Makefile.inc1 b/Makefile.inc1
index 2767a6038354..63c3ce80f54d 100644
--- a/Makefile.inc1
+++ b/Makefile.inc1
@@ -2301,8 +2301,8 @@ _flua= lib/liblua lib/libucl libexec/flua
 # r245440 mtree -N support added
 # r313404 requires sha384.h for libnetbsd, added to libmd in r292782
 .if ${BOOTSTRAPPING} < 1100093
+_libnetbsd=	lib/libnetbsd
 _nmtree=	lib/libmd \
-		lib/libnetbsd \
 		usr.sbin/nmtree
 
 ${_bt}-lib/libnetbsd: ${_bt}-lib/libmd
@@ -2335,9 +2335,23 @@ _crunchgen=	usr.sbin/crunch/crunchgen
 _bootstrap_tools_links+=crunchgen
 .endif
 
+.if ${MK_DISK_IMAGE_TOOLS_BOOTSTRAP} != "no"
+_etdump=	usr.bin/etdump
+_makefs=	usr.sbin/makefs
+
+_libnetbsd=	lib/libnetbsd
+${_bt}-usr.sbin/makefs: ${_bt}-lib/libnetbsd
+
+.if defined(BOOTSTRAP_ALL_TOOLS)
+_libsbuf=	lib/libsbuf
+${_bt}-usr.sbin/makefs: ${_bt}-lib/libsbuf
+.endif
+.endif
+
 # 1300102: VHDX support
 .if ${BOOTSTRAPPING} < 1201520 || \
-	(${BOOTSTRAPPING} > 1300000 && ${BOOTSTRAPPING} < 1300102)
+	(${BOOTSTRAPPING} > 1300000 && ${BOOTSTRAPPING} < 1300102) || \
+	${MK_DISK_IMAGE_TOOLS_BOOTSTRAP} != "no"
 _mkimg=	usr.bin/mkimg
 .else
 _bootstrap_tools_links+=mkimg
@@ -2538,6 +2552,10 @@ bootstrap-tools: ${_bt}-links .PHONY
     ${_flua} \
     ${_crunchide} \
     ${_crunchgen} \
+    ${_etdump} \
+    ${_libnetbsd} \
+    ${_libsbuf} \
+    ${_makefs} \
     ${_mkimg} \
     ${_nmtree} \
     ${_vtfontcvt} \
diff --git a/share/man/man5/src.conf.5 b/share/man/man5/src.conf.5
index 04af879dbd02..7ef13efbb4d0 100644
--- a/share/man/man5/src.conf.5
+++ b/share/man/man5/src.conf.5
@@ -569,6 +569,13 @@ This must be set in the environment, make command line, or
 .Pa /etc/src-env.conf ,
 not
 .Pa /etc/src.conf .
+.It Va WITH_DISK_IMAGE_TOOLS_BOOTSTRAP
+Build
+.Xr etdump 1 ,
+.Xr makefs 8
+and
+.Xr mkimg 1
+as bootstrap tools.
 .It Va WITHOUT_DMAGENT
 Do not build dma Mail Transport Agent.
 .It Va WITHOUT_DOCCOMPRESS
diff --git a/share/mk/src.opts.mk b/share/mk/src.opts.mk
index 7e865b31db25..880f1139843c 100644
--- a/share/mk/src.opts.mk
+++ b/share/mk/src.opts.mk
@@ -197,6 +197,7 @@ __DEFAULT_NO_OPTIONS = \
     CLANG_EXTRAS \
     CLANG_FORMAT \
     DETECT_TZ_CHANGES \
+    DISK_IMAGE_TOOLS_BOOTSTRAP \
     DTRACE_TESTS \
     EXPERIMENTAL \
     HESIOD \
diff --git a/tools/build/options/WITH_DISK_IMAGE_TOOLS_BOOTSTRAP b/tools/build/options/WITH_DISK_IMAGE_TOOLS_BOOTSTRAP
new file mode 100644
index 000000000000..5f5fba2ea0a2
--- /dev/null
+++ b/tools/build/options/WITH_DISK_IMAGE_TOOLS_BOOTSTRAP
@@ -0,0 +1,6 @@
+Build
+.Xr etdump 1 ,
+.Xr makefs 8
+and
+.Xr mkimg 1
+as bootstrap tools.