1#!/bin/sh 2# 3# This file is in the public domain. 4# 5# This script creates the src.conf.5 man page using template text contained 6# herein and the contents of the WITH_* and WITHOUT_* files in the same 7# directory. Each WITH_* and WITHOUT_* file documents the effect of the 8# /etc/src.conf knob with the same name. 9# 10# For each supported architecture, "make showconfig" is invoked to determine 11# the default setting of every option: always WITH_, always WITHOUT_, or 12# architecture-dependent WITH_/WITHOUT_. It also determines and describes 13# dependencies between options. 14# 15# Usage: 16# 17# cd tools/build/options 18# sh makeman > ../../../share/man/man5/src.conf.5 19 20set -o errexit 21export LC_ALL=C 22 23t=$(mktemp -d -t makeman) 24trap 'test -d $t && rm -rf $t' exit 25 26srcdir=$(realpath ../../..) 27make="make -C $srcdir -m $srcdir/share/mk" 28 29# 30# usage: no_targets all_targets yes_targets 31# 32no_targets() 33{ 34 for t1 in $1 ; do 35 for t2 in $2 ; do 36 if [ "${t1}" = "${t2}" ] ; then 37 continue 2 38 fi 39 done 40 echo ${t1} 41 done 42} 43 44show_options() 45{ 46 ALL_TARGETS=$(echo $(${make} targets MK_AUTO_OBJ=no | tail -n +2)) 47 rm -f $t/settings 48 for target in ${ALL_TARGETS} ; do 49 prev_opt= 50 env -i ${make} showconfig \ 51 SRC_ENV_CONF=/dev/null SRCCONF=/dev/null \ 52 __MAKE_CONF=/dev/null \ 53 TARGET_ARCH=${target#*/} TARGET=${target%/*} | 54 while read var _ val ; do 55 case $var in 56 MK_*) 57 opt=${var#MK_} 58 if [ $opt = "$prev_opt" ]; then 59 echo "$target: ignoring duplicate option $opt" >&2 60 continue 61 fi 62 prev_opt=$opt 63 case ${val} in 64 yes) 65 echo ${opt} ${target} 66 ;; 67 no) 68 echo ${opt} 69 ;; 70 *) 71 echo "make showconfig broken: ${var} ${_} ${val} (not yes or no)" >&2 72 exit 1 73 ;; 74 esac 75 ;; 76 OPT_*) 77 # ignore 78 ;; 79 *) 80 echo "make showconfig broken: ${var} ${_} ${val} not MK_ or OPT_" >&2 81 exit 1 82 ;; 83 esac 84 done > $t/settings.target 85 if [ -r $t/settings ] ; then 86 join -t\ $t/settings $t/settings.target > $t/settings.new 87 mv $t/settings.new $t/settings 88 else 89 mv $t/settings.target $t/settings 90 fi 91 done 92 93 while read opt targets ; do 94 if [ "${targets}" = "${ALL_TARGETS}" ] ; then 95 echo "WITHOUT_${opt}" 96 elif [ -z "${targets}" ] ; then 97 echo "WITH_${opt}" 98 else 99 echo "WITHOUT_${opt}" $(no_targets "${ALL_TARGETS}" "${targets}") 100 echo "WITH_${opt} ${targets}" 101 fi 102 done < $t/settings 103} 104 105# 106# usage: show { settings | with | without } ... 107# 108show() 109{ 110 111 mode=$1 ; shift 112 case ${mode} in 113 settings) 114 yes_prefix=WITH 115 no_prefix=WITHOUT 116 ;; 117 with) 118 yes_prefix=WITH 119 no_prefix=WITH 120 ;; 121 without) 122 yes_prefix=WITHOUT 123 no_prefix=WITHOUT 124 ;; 125 *) 126 echo 'internal error' >&2 127 exit 1 128 ;; 129 esac 130 requireds=`env -i make -f ${srcdir}/share/mk/src.opts.mk \ 131 -V '${__REQUIRED_OPTIONS:ts,}'` 132 env -i ${make} .MAKE.MODE=normal "$@" showconfig __MAKE_CONF=/dev/null \ 133 SRCCONF=/dev/null | 134 while read var _ val ; do 135 case ${var} in 136 MK_*) 137 opt=${var#MK_} 138 case ,${requireds}, in 139 *,${opt},*) 140 continue 141 ;; 142 esac 143 case ${val} in 144 yes) 145 echo ${yes_prefix}_${opt} 146 ;; 147 no) 148 echo ${no_prefix}_${opt} 149 ;; 150 *) 151 echo "make showconfig broken: ${var} ${_} ${val} (not yes or no)" >&2 152 exit 1 153 ;; 154 esac 155 ;; 156 OPT_*) 157 # ignore 158 ;; 159 *) 160 echo "make showconfig broken: ${var} ${_} ${val} not MK_ or OPT_" >&2 161 exit 1 162 ;; 163 esac 164 done 165} 166 167show_group_options() 168{ 169 env -i ${make} .MAKE.MODE=normal "$@" showconfig __MAKE_CONF=/dev/null \ 170 SRCCONF=/dev/null | 171 while read var _ val ; do 172 case ${var} in 173 MK_*) 174 # ignore 175 ;; 176 OPT_*) 177 opt=${var#OPT_} 178 echo ${opt} 179 ;; 180 *) 181 echo "make showconfig broken: ${var} ${_} ${val} not MK_ or OPT_" >&2 182 exit 1 183 ;; 184 esac 185 done 186} 187 188main() 189{ 190 echo "building src.conf.5 man page from files in ${PWD}" >&2 191 192 generated='@'generated 193 cat <<EOF 194.\" DO NOT EDIT-- this file is $generated by tools/build/options/makeman. 195.Dd $(echo $(LC_TIME=C date +'%B %e, %Y')) 196.Dt SRC.CONF 5 197.Os 198.Sh NAME 199.Nm src.conf 200.Nd "source build options" 201.Sh DESCRIPTION 202The 203.Nm 204file contains variables that control what components will be generated during 205the build process of the 206.Fx 207source tree; see 208.Xr build 7 . 209.Pp 210The 211.Nm 212file uses the standard makefile syntax. 213However, 214.Nm 215should not specify any dependencies to 216.Xr make 1 . 217Instead, 218.Nm 219is to set 220.Xr make 1 221variables that control the aspects of how the system builds. 222.Pp 223The default location of 224.Nm 225is 226.Pa /etc/src.conf , 227though an alternative location can be specified in the 228.Xr make 1 229variable 230.Va SRCCONF . 231Overriding the location of 232.Nm 233may be necessary if the system-wide settings are not suitable 234for a particular build. 235For instance, setting 236.Va SRCCONF 237to 238.Pa /dev/null 239effectively resets all build controls to their defaults. 240.Pp 241The only purpose of 242.Nm 243is to control the compilation of the 244.Fx 245source code, which is usually located in 246.Pa /usr/src . 247As a rule, the system administrator creates 248.Nm 249when the values of certain control variables need to be changed 250from their defaults. 251.Pp 252In addition, control variables can be specified 253for a particular build via the 254.Fl D 255option of 256.Xr make 1 257or in its environment; see 258.Xr environ 7 . 259.Pp 260The environment of 261.Xr make 1 262for the build can be controlled via the 263.Va SRC_ENV_CONF 264variable, which defaults to 265.Pa /etc/src-env.conf . 266Some examples that may only be set in this file are 267.Va WITH_DIRDEPS_BUILD , 268and 269.Va WITH_META_MODE , 270and 271.Va MAKEOBJDIRPREFIX 272as they are environment-only variables. 273.Pp 274The values of 275.Va WITH_ 276and 277.Va WITHOUT_ 278variables are ignored regardless of their setting; 279even if they would be set to 280.Dq Li FALSE 281or 282.Dq Li NO . 283The presence of an option causes 284it to be honored by 285.Xr make 1 . 286.Pp 287This list provides a name and short description for variables 288that can be used for source builds. 289.Bl -tag -width indent 290EOF 291 show settings SRC_ENV_CONF=/dev/null | sort > $t/config_default 292 # Work around WITH_LDNS_UTILS forcing BIND_UTILS off by parsing the 293 # actual config that results from enabling every WITH_ option. This 294 # can be reverted if/when we no longer have options that disable 295 # others. 296 show with SRC_ENV_CONF=/dev/null | sort | sed 's/$/=/' > $t/src.conf 297 show settings SRC_ENV_CONF=$t/src.conf | sort > $t/config_WITH_ALL 298 show without SRC_ENV_CONF=/dev/null | sort > $t/config_WITHOUT_ALL 299 env_only_options="$(${make} MK_AUTO_OBJ=no -V __ENV_ONLY_OPTIONS)" 300 301 show_options | 302 while read opt targets ; do 303 if [ ! -f ${opt} ] ; then 304 echo "no description found for ${opt}, skipping" >&2 305 continue 306 fi 307 308 echo ".It Va ${opt}" 309 sed -e'/\$FreeBSD.*\$/d' ${opt} 310 if [ -n "${targets}" ] ; then 311 echo '.Pp' 312 echo 'This is a default setting on' 313 echo $(echo ${targets} | sed -e's/ /, /g' -e's/\(.*\), /\1 and /'). 314 fi 315 316 if [ "${opt%%_*}" = 'WITHOUT' ] ; then 317 sed -n "/^WITH_${opt#WITHOUT_}$/!s/$/=/p" $t/config_WITH_ALL > $t/src.conf 318 show settings SRC_ENV_CONF=$t/src.conf -D${opt} | sort > $t/config_WITH_ALL_${opt} 319 comm -13 $t/config_WITH_ALL $t/config_WITH_ALL_${opt} | sed -n "/^${opt}$/!p" > $t/deps 320 elif [ "${opt%%_*}" = 'WITH' ] ; then 321 sed -n "/^WITHOUT${opt#WITH}$/!s/$/=/p" $t/config_WITHOUT_ALL > $t/src.conf 322 show settings SRC_ENV_CONF=$t/src.conf -D${opt} | sort > $t/config_WITHOUT_ALL_${opt} 323 comm -13 $t/config_WITHOUT_ALL $t/config_WITHOUT_ALL_${opt} | sed -n "/^${opt}$/!p" > $t/deps 324 else 325 echo 'internal error' >&2 326 exit 1 327 fi 328 329 show settings SRC_ENV_CONF=/dev/null -D${opt} | sort > $t/config_${opt} 330 comm -13 $t/config_default $t/config_${opt} | sed -n "/^${opt}$/!p" | 331 comm -13 $t/deps - > $t/deps2 332 333 havedeps=0 334 if [ -s $t/deps ] ; then 335 havedeps=1 336 echo 'When set, it enforces these options:' 337 echo '.Pp' 338 echo '.Bl -item -compact' 339 while read opt2 ; do 340 echo '.It' 341 echo ".Va ${opt2}" 342 done < $t/deps 343 echo '.El' 344 fi 345 346 if [ -s $t/deps2 ] ; then 347 if [ ${havedeps} -eq 1 ] ; then 348 echo '.Pp' 349 fi 350 echo 'When set, these options are also in effect:' 351 echo '.Pp' 352 echo '.Bl -inset -compact' 353 while read opt2 ; do 354 echo ".It Va ${opt2}" 355 noopt=$(echo ${opt2} | sed -e's/WITH_/WITHOUT_/;t' -e's/WITHOUT_/WITH_/') 356 echo '(unless' 357 echo ".Va ${noopt}" 358 echo 'is set explicitly)' 359 done < $t/deps2 360 echo '.El' 361 fi 362 363 case " ${env_only_options} " in 364 *\ ${opt#*_}\ *) 365 echo ".Pp" 366 echo "This must be set in the environment, make command line, or" 367 echo ".Pa /etc/src-env.conf ," 368 echo "not" 369 echo ".Pa /etc/src.conf ." 370 ;; 371 esac 372 373 printf "." >&2 374 done 375 printf "\n" >&2 376 cat <<EOF 377.El 378.Pp 379The following options accept a single value from a list of valid values. 380.Bl -tag -width indent 381EOF 382 show_group_options | 383 while read opt ; do 384 if [ ! -f ${opt} ] ; then 385 echo "no description found for ${opt}, skipping" >&2 386 continue 387 fi 388 389 echo ".It Va ${opt}" 390 cat ${opt} 391 done 392 cat <<EOF 393.El 394.Sh FILES 395.Bl -tag -compact -width Pa 396.It Pa /etc/src.conf 397.It Pa /etc/src-env.conf 398.It Pa /usr/share/mk/bsd.own.mk 399.El 400.Sh SEE ALSO 401.Xr make 1 , 402.Xr make.conf 5 , 403.Xr build 7 , 404.Xr ports 7 405.Sh HISTORY 406The 407.Nm 408file appeared in 409.Fx 7.0 . 410.Sh AUTHORS 411This manual page was autogenerated by 412.An tools/build/options/makeman . 413EOF 414} 415 416main 417