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 opt=${var#MK_} 56 if [ $opt = "$prev_opt" ]; then 57 echo "$target: ignoring duplicate option $opt" >&2 58 continue 59 fi 60 prev_opt=$opt 61 case ${val} in 62 yes) 63 echo ${opt} ${target} 64 ;; 65 no) 66 echo ${opt} 67 ;; 68 *) 69 echo "make showconfig broken: ${var} ${_} ${val} (not yes or no)" >&2 70 exit 1 71 ;; 72 esac 73 done > $t/settings.target 74 if [ -r $t/settings ] ; then 75 join -t\ $t/settings $t/settings.target > $t/settings.new 76 mv $t/settings.new $t/settings 77 else 78 mv $t/settings.target $t/settings 79 fi 80 done 81 82 while read opt targets ; do 83 if [ "${targets}" = "${ALL_TARGETS}" ] ; then 84 echo "WITHOUT_${opt}" 85 elif [ -z "${targets}" ] ; then 86 echo "WITH_${opt}" 87 else 88 echo "WITHOUT_${opt}" $(no_targets "${ALL_TARGETS}" "${targets}") 89 echo "WITH_${opt} ${targets}" 90 fi 91 done < $t/settings 92} 93 94# 95# usage: show { settings | with | without } ... 96# 97show() 98{ 99 100 mode=$1 ; shift 101 case ${mode} in 102 settings) 103 yes_prefix=WITH 104 no_prefix=WITHOUT 105 ;; 106 with) 107 yes_prefix=WITH 108 no_prefix=WITH 109 ;; 110 without) 111 yes_prefix=WITHOUT 112 no_prefix=WITHOUT 113 ;; 114 *) 115 echo 'internal error' >&2 116 exit 1 117 ;; 118 esac 119 env -i ${make} .MAKE.MODE=normal "$@" showconfig __MAKE_CONF=/dev/null \ 120 SRCCONF=/dev/null | 121 while read var _ val ; do 122 opt=${var#MK_} 123 case ${val} in 124 yes) 125 echo ${yes_prefix}_${opt} 126 ;; 127 no) 128 echo ${no_prefix}_${opt} 129 ;; 130 *) 131 echo "make showconfig broken: ${var} ${_} ${val} (not yes or no)" >&2 132 exit 1 133 ;; 134 esac 135 done 136} 137 138main() 139{ 140 echo "building src.conf.5 man page from files in ${PWD}" >&2 141 142 fbsdid='$'FreeBSD'$' 143 generated='@'generated 144 cat <<EOF 145.\" DO NOT EDIT-- this file is $generated by tools/build/options/makeman. 146.\" ${fbsdid} 147.Dd $(echo $(LC_TIME=C date +'%B %e, %Y')) 148.Dt SRC.CONF 5 149.Os 150.Sh NAME 151.Nm src.conf 152.Nd "source build options" 153.Sh DESCRIPTION 154The 155.Nm 156file contains variables that control what components will be generated during 157the build process of the 158.Fx 159source tree; see 160.Xr build 7 . 161.Pp 162The 163.Nm 164file uses the standard makefile syntax. 165However, 166.Nm 167should not specify any dependencies to 168.Xr make 1 . 169Instead, 170.Nm 171is to set 172.Xr make 1 173variables that control the aspects of how the system builds. 174.Pp 175The default location of 176.Nm 177is 178.Pa /etc/src.conf , 179though an alternative location can be specified in the 180.Xr make 1 181variable 182.Va SRCCONF . 183Overriding the location of 184.Nm 185may be necessary if the system-wide settings are not suitable 186for a particular build. 187For instance, setting 188.Va SRCCONF 189to 190.Pa /dev/null 191effectively resets all build controls to their defaults. 192.Pp 193The only purpose of 194.Nm 195is to control the compilation of the 196.Fx 197source code, which is usually located in 198.Pa /usr/src . 199As a rule, the system administrator creates 200.Nm 201when the values of certain control variables need to be changed 202from their defaults. 203.Pp 204In addition, control variables can be specified 205for a particular build via the 206.Fl D 207option of 208.Xr make 1 209or in its environment; see 210.Xr environ 7 . 211.Pp 212The environment of 213.Xr make 1 214for the build can be controlled via the 215.Va SRC_ENV_CONF 216variable, which defaults to 217.Pa /etc/src-env.conf . 218Some examples that may only be set in this file are 219.Va WITH_DIRDEPS_BUILD , 220and 221.Va WITH_META_MODE , 222and 223.Va MAKEOBJDIRPREFIX 224as they are environment-only variables. 225.Pp 226The values of variables are ignored regardless of their setting; 227even if they would be set to 228.Dq Li FALSE 229or 230.Dq Li NO . 231The presence of an option causes 232it to be honored by 233.Xr make 1 . 234.Pp 235This list provides a name and short description for variables 236that can be used for source builds. 237.Bl -tag -width indent 238EOF 239 show settings SRC_ENV_CONF=/dev/null | sort > $t/config_default 240 # Work around WITH_LDNS_UTILS forcing BIND_UTILS off by parsing the 241 # actual config that results from enabling every WITH_ option. This 242 # can be reverted if/when we no longer have options that disable 243 # others. 244 show with SRC_ENV_CONF=/dev/null | sort | sed 's/$/=/' > $t/src.conf 245 show settings SRC_ENV_CONF=$t/src.conf | sort > $t/config_WITH_ALL 246 show without SRC_ENV_CONF=/dev/null | sort > $t/config_WITHOUT_ALL 247 env_only_options="$(${make} MK_AUTO_OBJ=no -V __ENV_ONLY_OPTIONS)" 248 249 show_options | 250 while read opt targets ; do 251 if [ ! -f ${opt} ] ; then 252 echo "no description found for ${opt}, skipping" >&2 253 continue 254 fi 255 256 echo ".It Va ${opt}" 257 sed -e'/\$FreeBSD.*\$/d' ${opt} 258 if [ -n "${targets}" ] ; then 259 echo '.Pp' 260 echo 'This is a default setting on' 261 echo $(echo ${targets} | sed -e's/ /, /g' -e's/\(.*\), /\1 and /'). 262 fi 263 264 if [ "${opt%%_*}" = 'WITHOUT' ] ; then 265 sed -n "/^WITH_${opt#WITHOUT_}$/!s/$/=/p" $t/config_WITH_ALL > $t/src.conf 266 show settings SRC_ENV_CONF=$t/src.conf -D${opt} | sort > $t/config_WITH_ALL_${opt} 267 comm -13 $t/config_WITH_ALL $t/config_WITH_ALL_${opt} | sed -n "/^${opt}$/!p" > $t/deps 268 elif [ "${opt%%_*}" = 'WITH' ] ; then 269 sed -n "/^WITHOUT${opt#WITH}$/!s/$/=/p" $t/config_WITHOUT_ALL > $t/src.conf 270 show settings SRC_ENV_CONF=$t/src.conf -D${opt} | sort > $t/config_WITHOUT_ALL_${opt} 271 comm -13 $t/config_WITHOUT_ALL $t/config_WITHOUT_ALL_${opt} | sed -n "/^${opt}$/!p" > $t/deps 272 else 273 echo 'internal error' >&2 274 exit 1 275 fi 276 277 show settings SRC_ENV_CONF=/dev/null -D${opt} | sort > $t/config_${opt} 278 comm -13 $t/config_default $t/config_${opt} | sed -n "/^${opt}$/!p" | 279 comm -13 $t/deps - > $t/deps2 280 281 havedeps=0 282 if [ -s $t/deps ] ; then 283 havedeps=1 284 echo 'When set, it enforces these options:' 285 echo '.Pp' 286 echo '.Bl -item -compact' 287 while read opt2 ; do 288 echo '.It' 289 echo ".Va ${opt2}" 290 done < $t/deps 291 echo '.El' 292 fi 293 294 if [ -s $t/deps2 ] ; then 295 if [ ${havedeps} -eq 1 ] ; then 296 echo '.Pp' 297 fi 298 echo 'When set, these options are also in effect:' 299 echo '.Pp' 300 echo '.Bl -inset -compact' 301 while read opt2 ; do 302 echo ".It Va ${opt2}" 303 noopt=$(echo ${opt2} | sed -e's/WITH_/WITHOUT_/;t' -e's/WITHOUT_/WITH_/') 304 echo '(unless' 305 echo ".Va ${noopt}" 306 echo 'is set explicitly)' 307 done < $t/deps2 308 echo '.El' 309 fi 310 311 case " ${env_only_options} " in 312 *\ ${opt#*_}\ *) 313 echo ".Pp" 314 echo "This must be set in the environment, make command line, or" 315 echo ".Pa /etc/src-env.conf ," 316 echo "not" 317 echo ".Pa /etc/src.conf ." 318 ;; 319 esac 320 321 twiddle >&2 322 done 323 cat <<EOF 324.El 325.Sh FILES 326.Bl -tag -compact -width Pa 327.It Pa /etc/src.conf 328.It Pa /etc/src-env.conf 329.It Pa /usr/share/mk/bsd.own.mk 330.El 331.Sh SEE ALSO 332.Xr make 1 , 333.Xr make.conf 5 , 334.Xr build 7 , 335.Xr ports 7 336.Sh HISTORY 337The 338.Nm 339file appeared in 340.Fx 7.0 . 341.Sh AUTHORS 342This manual page was autogenerated by 343.An tools/build/options/makeman . 344EOF 345} 346 347twiddle_pos=0 348twiddle() 349{ 350 local c0='|' c1='/' c2='-' c3='\' 351 352 eval printf '%c\\b' '$c'${twiddle_pos} 353 twiddle_pos=$(((twiddle_pos+1)%4)) 354} 355 356main 357