git: 897ae85f7d02 - main - makeman: add minimal support for group options

From: Brooks Davis <brooks_at_FreeBSD.org>
Date: Fri, 01 Sep 2023 16:54:54 UTC
The branch main has been updated by brooks:

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

commit 897ae85f7d02e1244907587e7b7c3b628ca66365
Author:     Brooks Davis <brooks@FreeBSD.org>
AuthorDate: 2023-09-01 16:41:59 +0000
Commit:     Brooks Davis <brooks@FreeBSD.org>
CommitDate: 2023-09-01 16:54:23 +0000

    makeman: add minimal support for group options
    
    Ignore OPT_* values in showconfig out in exising code paths and add
    a new path to include descriptions for each. For now, hardcode the
    description contents rather than attempting to generate it.  This runs
    the risk of docs getting out of date, limits the amount of new shell
    code added today while a lua rewrite is nearly ready to land.
    
    This change requires a followup commit to enable OPT_* values in
    "make showconfig" in order to actually find group options.
    
    Reviewed by:    emaste
    Differential Revision:  https://reviews.freebsd.org/D41681
---
 tools/build/options/makeman | 103 ++++++++++++++++++++++++++++++++++----------
 1 file changed, 81 insertions(+), 22 deletions(-)

diff --git a/tools/build/options/makeman b/tools/build/options/makeman
index c4a51ec7c56e..f4089d453801 100755
--- a/tools/build/options/makeman
+++ b/tools/build/options/makeman
@@ -52,21 +52,32 @@ show_options()
 		    __MAKE_CONF=/dev/null \
 		    TARGET_ARCH=${target#*/} TARGET=${target%/*} |
 		while read var _ val ; do
-			opt=${var#MK_}
-			if [ $opt = "$prev_opt" ]; then
-				echo "$target: ignoring duplicate option $opt" >&2
-				continue
-			fi
-			prev_opt=$opt
-			case ${val} in
-			yes)
-				echo ${opt} ${target}
+			case $var in
+			MK_*)
+				opt=${var#MK_}
+				if [ $opt = "$prev_opt" ]; then
+					echo "$target: ignoring duplicate option $opt" >&2
+					continue
+				fi
+				prev_opt=$opt
+				case ${val} in
+				yes)
+					echo ${opt} ${target}
+					;;
+				no)
+					echo ${opt}
+					;;
+				*)
+					echo "make showconfig broken: ${var} ${_} ${val} (not yes or no)" >&2
+					exit 1
+					;;
+				esac
 				;;
-			no)
-				echo ${opt}
+			OPT_*)
+				# ignore
 				;;
 			*)
-				echo "make showconfig broken: ${var} ${_} ${val} (not yes or no)" >&2
+				echo "make showconfig broken: ${var} ${_} ${val} not MK_ or OPT_" >&2
 				exit 1
 				;;
 			esac
@@ -121,21 +132,53 @@ show()
 	env -i ${make} .MAKE.MODE=normal "$@" showconfig __MAKE_CONF=/dev/null \
 	    SRCCONF=/dev/null |
 	while read var _ val ; do
-		opt=${var#MK_}
-		case ,${requireds}, in
-		*,${opt},*)
-			continue
+		case ${var} in
+		MK_*)
+			opt=${var#MK_}
+			case ,${requireds}, in
+			*,${opt},*)
+				continue
+				;;
+			esac
+			case ${val} in
+			yes)
+				echo ${yes_prefix}_${opt}
+				;;
+			no)
+				echo ${no_prefix}_${opt}
+				;;
+			*)
+				echo "make showconfig broken: ${var} ${_} ${val} (not yes or no)" >&2
+				exit 1
+				;;
+			esac
+			;;
+		OPT_*)
+			# ignore
+			;;
+		*)
+			echo "make showconfig broken: ${var} ${_} ${val} not MK_ or OPT_" >&2
+			exit 1
 			;;
 		esac
-		case ${val} in
-		yes)
-			echo ${yes_prefix}_${opt}
+	done
+}
+
+show_group_options()
+{
+	env -i ${make} .MAKE.MODE=normal "$@" showconfig __MAKE_CONF=/dev/null \
+	    SRCCONF=/dev/null |
+	while read var _ val ; do
+		case ${var} in
+		MK_*)
+			# ignore
 			;;
-		no)
-			echo ${no_prefix}_${opt}
+		OPT_*)
+			opt=${var#OPT_}
+			echo ${opt}
 			;;
 		*)
-			echo "make showconfig broken: ${var} ${_} ${val} (not yes or no)" >&2
+			echo "make showconfig broken: ${var} ${_} ${val} not MK_ or OPT_" >&2
 			exit 1
 			;;
 		esac
@@ -332,6 +375,22 @@ EOF
 	printf "\n" >&2
 	cat <<EOF
 .El
+.Pp
+The following options accept a single value from a list of valid values.
+.Bl -tag -width indent
+EOF
+	show_group_options |
+	while read opt ; do
+		if [ ! -f ${opt} ] ; then
+			echo "no description found for ${opt}, skipping" >&2
+			continue
+		fi
+
+		echo ".It Va ${opt}"
+		cat ${opt}
+	done
+	cat <<EOF
+.El
 .Sh FILES
 .Bl -tag -compact -width Pa
 .It Pa /etc/src.conf