diff --git a/tools/build/options/makeman b/tools/build/options/makeman index 5a8b207b228a..db0b75363a85 100755 --- a/tools/build/options/makeman +++ b/tools/build/options/makeman @@ -1,347 +1,349 @@ #!/bin/sh # # This file is in the public domain. # $FreeBSD$ # # This script creates the src.conf.5 man page using template text contained # herein and the contents of the WITH_* and WITHOUT_* files in the same # directory. Each WITH_* and WITHOUT_* file documents the effect of the # /etc/src.conf knob with the same name. # # For each supported architecture, "make showconfig" is invoked to determine # the default setting of every option: always WITH_, always WITHOUT_, or # architecture-dependent WITH_/WITHOUT_. It also determines and describes # dependencies between options. # # Usage: # # cd tools/build/options # sh makeman > ../../../share/man/man5/src.conf.5 set -o errexit export LC_ALL=C +# just be clear that we are not making anything +export UPDATE_DEPENDFILE=no t=$(mktemp -d -t makeman) trap 'test -d $t && rm -rf $t' exit srcdir=$(realpath ../../..) make="make -C $srcdir -m $srcdir/share/mk" # # usage: no_targets all_targets yes_targets # no_targets() { for t1 in $1 ; do for t2 in $2 ; do if [ "${t1}" = "${t2}" ] ; then continue 2 fi done echo ${t1} done } show_options() { ALL_TARGETS=$(echo $(${make} targets MK_AUTO_OBJ=no | tail -n +2)) rm -f $t/settings for target in ${ALL_TARGETS} ; do prev_opt= env -i ${make} showconfig \ SRC_ENV_CONF=/dev/null SRCCONF=/dev/null \ __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} ;; no) echo ${opt} ;; *) echo "make showconfig broken: ${var} ${_} ${val} (not yes or no)" >&2 exit 1 ;; esac done > $t/settings.target if [ -r $t/settings ] ; then join -t\ $t/settings $t/settings.target > $t/settings.new mv $t/settings.new $t/settings else mv $t/settings.target $t/settings fi done while read opt targets ; do if [ "${targets}" = "${ALL_TARGETS}" ] ; then echo "WITHOUT_${opt}" elif [ -z "${targets}" ] ; then echo "WITH_${opt}" else echo "WITHOUT_${opt}" $(no_targets "${ALL_TARGETS}" "${targets}") echo "WITH_${opt} ${targets}" fi done < $t/settings } # # usage: show { settings | with | without } ... # show() { mode=$1 ; shift case ${mode} in settings) yes_prefix=WITH no_prefix=WITHOUT ;; with) yes_prefix=WITH no_prefix=WITH ;; without) yes_prefix=WITHOUT no_prefix=WITHOUT ;; *) echo 'internal error' >&2 exit 1 ;; esac env -i ${make} .MAKE.MODE=normal "$@" showconfig __MAKE_CONF=/dev/null \ SRCCONF=/dev/null | while read var _ val ; do opt=${var#MK_} 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 done } main() { echo "building src.conf.5 man page from files in ${PWD}" >&2 generated='@'generated cat < $t/config_default # Work around WITH_LDNS_UTILS forcing BIND_UTILS off by parsing the # actual config that results from enabling every WITH_ option. This # can be reverted if/when we no longer have options that disable # others. show with SRC_ENV_CONF=/dev/null | sort | sed 's/$/=/' > $t/src.conf show settings SRC_ENV_CONF=$t/src.conf | sort > $t/config_WITH_ALL show without SRC_ENV_CONF=/dev/null | sort > $t/config_WITHOUT_ALL env_only_options="$(${make} MK_AUTO_OBJ=no -V __ENV_ONLY_OPTIONS)" show_options | while read opt targets ; do if [ ! -f ${opt} ] ; then echo "no description found for ${opt}, skipping" >&2 continue fi echo ".It Va ${opt}" sed -e'/\$FreeBSD.*\$/d' ${opt} if [ -n "${targets}" ] ; then echo '.Pp' echo 'This is a default setting on' echo $(echo ${targets} | sed -e's/ /, /g' -e's/\(.*\), /\1 and /'). fi if [ "${opt%%_*}" = 'WITHOUT' ] ; then sed -n "/^WITH_${opt#WITHOUT_}$/!s/$/=/p" $t/config_WITH_ALL > $t/src.conf show settings SRC_ENV_CONF=$t/src.conf -D${opt} | sort > $t/config_WITH_ALL_${opt} comm -13 $t/config_WITH_ALL $t/config_WITH_ALL_${opt} | sed -n "/^${opt}$/!p" > $t/deps elif [ "${opt%%_*}" = 'WITH' ] ; then sed -n "/^WITHOUT${opt#WITH}$/!s/$/=/p" $t/config_WITHOUT_ALL > $t/src.conf show settings SRC_ENV_CONF=$t/src.conf -D${opt} | sort > $t/config_WITHOUT_ALL_${opt} comm -13 $t/config_WITHOUT_ALL $t/config_WITHOUT_ALL_${opt} | sed -n "/^${opt}$/!p" > $t/deps else echo 'internal error' >&2 exit 1 fi show settings SRC_ENV_CONF=/dev/null -D${opt} | sort > $t/config_${opt} comm -13 $t/config_default $t/config_${opt} | sed -n "/^${opt}$/!p" | comm -13 $t/deps - > $t/deps2 havedeps=0 if [ -s $t/deps ] ; then havedeps=1 echo 'When set, it enforces these options:' echo '.Pp' echo '.Bl -item -compact' while read opt2 ; do echo '.It' echo ".Va ${opt2}" done < $t/deps echo '.El' fi if [ -s $t/deps2 ] ; then if [ ${havedeps} -eq 1 ] ; then echo '.Pp' fi echo 'When set, these options are also in effect:' echo '.Pp' echo '.Bl -inset -compact' while read opt2 ; do echo ".It Va ${opt2}" noopt=$(echo ${opt2} | sed -e's/WITH_/WITHOUT_/;t' -e's/WITHOUT_/WITH_/') echo '(unless' echo ".Va ${noopt}" echo 'is set explicitly)' done < $t/deps2 echo '.El' fi case " ${env_only_options} " in *\ ${opt#*_}\ *) echo ".Pp" echo "This must be set in the environment, make command line, or" echo ".Pa /etc/src-env.conf ," echo "not" echo ".Pa /etc/src.conf ." ;; esac printf "." >&2 done printf "\n" >&2 cat <