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