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