1c5922fbfSRuslan Ermilov#!/bin/sh 2c5922fbfSRuslan Ermilov# 3c5922fbfSRuslan Ermilov# This file is in the public domain. 4c5922fbfSRuslan Ermilov 52701a1b7SRuslan Ermilovset -o errexit 6e9f950b5SBaptiste DaroussinLC_ALL=C 72701a1b7SRuslan Ermilov 8c5922fbfSRuslan Ermilovident='$FreeBSD$' 9c5922fbfSRuslan Ermilov 102701a1b7SRuslan Ermilovt=$(mktemp -d -t makeman) 112701a1b7SRuslan Ermilovtrap 'test -d $t && rm -rf $t' exit 122701a1b7SRuslan Ermilov 1369c469c9SDag-Erling Smørgravsrcdir=$(realpath ../../..) 1469c469c9SDag-Erling Smørgravmake="make -C $srcdir -m $srcdir/share/mk" 1569c469c9SDag-Erling Smørgrav 16c5922fbfSRuslan Ermilov# 172701a1b7SRuslan Ermilov# usage: no_targets all_targets yes_targets 182701a1b7SRuslan Ermilov# 192701a1b7SRuslan Ermilovno_targets() 202701a1b7SRuslan Ermilov{ 212701a1b7SRuslan Ermilov for t1 in $1 ; do 222701a1b7SRuslan Ermilov for t2 in $2 ; do 232701a1b7SRuslan Ermilov if [ "${t1}" = "${t2}" ] ; then 242701a1b7SRuslan Ermilov continue 2 252701a1b7SRuslan Ermilov fi 262701a1b7SRuslan Ermilov done 272701a1b7SRuslan Ermilov echo ${t1} 282701a1b7SRuslan Ermilov done 292701a1b7SRuslan Ermilov} 302701a1b7SRuslan Ermilov 312701a1b7SRuslan Ermilovshow_options() 322701a1b7SRuslan Ermilov{ 3369c469c9SDag-Erling Smørgrav ALL_TARGETS=$(echo $(${make} targets | tail -n +2)) 342701a1b7SRuslan Ermilov rm -f $t/settings 352701a1b7SRuslan Ermilov for target in ${ALL_TARGETS} ; do 3669c469c9SDag-Erling Smørgrav ${make} showconfig \ 372701a1b7SRuslan Ermilov SRCCONF=/dev/null __MAKE_CONF=/dev/null \ 382701a1b7SRuslan Ermilov TARGET_ARCH=${target#*/} TARGET=${target%/*} | 392701a1b7SRuslan Ermilov while read var _ val ; do 402701a1b7SRuslan Ermilov opt=${var#MK_} 412701a1b7SRuslan Ermilov case ${val} in 422701a1b7SRuslan Ermilov yes) 432701a1b7SRuslan Ermilov echo ${opt} ${target} 442701a1b7SRuslan Ermilov ;; 452701a1b7SRuslan Ermilov no) 462701a1b7SRuslan Ermilov echo ${opt} 472701a1b7SRuslan Ermilov ;; 482701a1b7SRuslan Ermilov *) 49cc2520d2SSimon J. Gerraty echo "make showconfig broken: ${var} ${_} ${val} (not yes or no)" >&2 502701a1b7SRuslan Ermilov exit 1 512701a1b7SRuslan Ermilov ;; 522701a1b7SRuslan Ermilov esac 532701a1b7SRuslan Ermilov done > $t/settings.target 542701a1b7SRuslan Ermilov if [ -r $t/settings ] ; then 552701a1b7SRuslan Ermilov join -t\ $t/settings $t/settings.target > $t/settings.new 562701a1b7SRuslan Ermilov mv $t/settings.new $t/settings 572701a1b7SRuslan Ermilov else 582701a1b7SRuslan Ermilov mv $t/settings.target $t/settings 592701a1b7SRuslan Ermilov fi 602701a1b7SRuslan Ermilov done 612701a1b7SRuslan Ermilov 62*4078537cSBryan Drewery while read opt targets ; do 632701a1b7SRuslan Ermilov if [ "${targets}" = "${ALL_TARGETS}" ] ; then 642701a1b7SRuslan Ermilov echo "WITHOUT_${opt}" 652701a1b7SRuslan Ermilov elif [ -z "${targets}" ] ; then 662701a1b7SRuslan Ermilov echo "WITH_${opt}" 672701a1b7SRuslan Ermilov else 682701a1b7SRuslan Ermilov echo "WITHOUT_${opt}" $(no_targets "${ALL_TARGETS}" "${targets}") 692701a1b7SRuslan Ermilov echo "WITH_${opt} ${targets}" 702701a1b7SRuslan Ermilov fi 71*4078537cSBryan Drewery done < $t/settings 722701a1b7SRuslan Ermilov} 732701a1b7SRuslan Ermilov 742701a1b7SRuslan Ermilov# 752701a1b7SRuslan Ermilov# usage: show { settings | with | without } ... 76c5922fbfSRuslan Ermilov# 77c5922fbfSRuslan Ermilovshow() 78c5922fbfSRuslan Ermilov{ 79c5922fbfSRuslan Ermilov 80c5922fbfSRuslan Ermilov mode=$1 ; shift 81c5922fbfSRuslan Ermilov case ${mode} in 82c5922fbfSRuslan Ermilov settings) 83c5922fbfSRuslan Ermilov yes_prefix=WITH 84c5922fbfSRuslan Ermilov no_prefix=WITHOUT 85c5922fbfSRuslan Ermilov ;; 862701a1b7SRuslan Ermilov with) 872701a1b7SRuslan Ermilov yes_prefix=WITH 88c5922fbfSRuslan Ermilov no_prefix=WITH 89c5922fbfSRuslan Ermilov ;; 902701a1b7SRuslan Ermilov without) 912701a1b7SRuslan Ermilov yes_prefix=WITHOUT 922701a1b7SRuslan Ermilov no_prefix=WITHOUT 932701a1b7SRuslan Ermilov ;; 94c5922fbfSRuslan Ermilov *) 952701a1b7SRuslan Ermilov echo 'internal error' >&2 96c5922fbfSRuslan Ermilov exit 1 97c5922fbfSRuslan Ermilov ;; 98c5922fbfSRuslan Ermilov esac 99cc2520d2SSimon J. Gerraty ${make} .MAKE.MODE=normal "$@" showconfig __MAKE_CONF=/dev/null | 100c5922fbfSRuslan Ermilov while read var _ val ; do 101c5922fbfSRuslan Ermilov opt=${var#MK_} 102c5922fbfSRuslan Ermilov case ${val} in 103c5922fbfSRuslan Ermilov yes) 104c5922fbfSRuslan Ermilov echo ${yes_prefix}_${opt} 105c5922fbfSRuslan Ermilov ;; 106c5922fbfSRuslan Ermilov no) 107c5922fbfSRuslan Ermilov echo ${no_prefix}_${opt} 108c5922fbfSRuslan Ermilov ;; 109c5922fbfSRuslan Ermilov *) 110cc2520d2SSimon J. Gerraty echo "make showconfig broken: ${var} ${_} ${val} (not yes or no)" >&2 111c5922fbfSRuslan Ermilov exit 1 112c5922fbfSRuslan Ermilov ;; 113c5922fbfSRuslan Ermilov esac 114c5922fbfSRuslan Ermilov done 115c5922fbfSRuslan Ermilov} 116c5922fbfSRuslan Ermilov 117c5922fbfSRuslan Ermilovmain() 118c5922fbfSRuslan Ermilov{ 119c5922fbfSRuslan Ermilov 120c5922fbfSRuslan Ermilov ident=${ident#$} 121c5922fbfSRuslan Ermilov ident=${ident% $} 12241c8ddc3SRuslan Ermilov fbsdid='$'FreeBSD'$' 123c5922fbfSRuslan Ermilov cat <<EOF 124c5922fbfSRuslan Ermilov.\" DO NOT EDIT-- this file is automatically generated. 125c5922fbfSRuslan Ermilov.\" from ${ident} 126c5922fbfSRuslan Ermilov.\" ${fbsdid} 1272701a1b7SRuslan Ermilov.Dd $(echo $(LC_TIME=C date +'%B %e, %Y')) 128c5922fbfSRuslan Ermilov.Dt SRC.CONF 5 129c5922fbfSRuslan Ermilov.Os 130c5922fbfSRuslan Ermilov.Sh NAME 131c5922fbfSRuslan Ermilov.Nm src.conf 13257caf3d6STom Rhodes.Nd "source build options" 133c5922fbfSRuslan Ermilov.Sh DESCRIPTION 134c5922fbfSRuslan ErmilovThe 135c5922fbfSRuslan Ermilov.Nm 136c5922fbfSRuslan Ermilovfile contains settings that will apply to every build involving the 137c5922fbfSRuslan Ermilov.Fx 138c5922fbfSRuslan Ermilovsource tree; see 139c5922fbfSRuslan Ermilov.Xr build 7 . 140c5922fbfSRuslan Ermilov.Pp 141c5922fbfSRuslan ErmilovThe 142c5922fbfSRuslan Ermilov.Nm 143c5922fbfSRuslan Ermilovfile uses the standard makefile syntax. 144c5922fbfSRuslan ErmilovHowever, 145c5922fbfSRuslan Ermilov.Nm 146c5922fbfSRuslan Ermilovshould not specify any dependencies to 147c5922fbfSRuslan Ermilov.Xr make 1 . 148c5922fbfSRuslan ErmilovInstead, 149c5922fbfSRuslan Ermilov.Nm 150c5922fbfSRuslan Ermilovis to set 151c5922fbfSRuslan Ermilov.Xr make 1 152c5922fbfSRuslan Ermilovvariables that control the aspects of how the system builds. 153c5922fbfSRuslan Ermilov.Pp 154c5922fbfSRuslan ErmilovThe default location of 155c5922fbfSRuslan Ermilov.Nm 156c5922fbfSRuslan Ermilovis 157c5922fbfSRuslan Ermilov.Pa /etc/src.conf , 158c5922fbfSRuslan Ermilovthough an alternative location can be specified in the 159c5922fbfSRuslan Ermilov.Xr make 1 160c5922fbfSRuslan Ermilovvariable 161c5922fbfSRuslan Ermilov.Va SRCCONF . 162c5922fbfSRuslan ErmilovOverriding the location of 163c5922fbfSRuslan Ermilov.Nm 164c5922fbfSRuslan Ermilovmay be necessary if the system-wide settings are not suitable 165c5922fbfSRuslan Ermilovfor a particular build. 166c5922fbfSRuslan ErmilovFor instance, setting 167c5922fbfSRuslan Ermilov.Va SRCCONF 168c5922fbfSRuslan Ermilovto 169c5922fbfSRuslan Ermilov.Pa /dev/null 170c5922fbfSRuslan Ermiloveffectively resets all build controls to their defaults. 171c5922fbfSRuslan Ermilov.Pp 172c5922fbfSRuslan ErmilovThe only purpose of 173c5922fbfSRuslan Ermilov.Nm 174c5922fbfSRuslan Ermilovis to control the compilation of the 175c5922fbfSRuslan Ermilov.Fx 17657caf3d6STom Rhodessource code, which is usually located in 177c5922fbfSRuslan Ermilov.Pa /usr/src . 178c5922fbfSRuslan ErmilovAs a rule, the system administrator creates 179c5922fbfSRuslan Ermilov.Nm 180c5922fbfSRuslan Ermilovwhen the values of certain control variables need to be changed 181c5922fbfSRuslan Ermilovfrom their defaults. 182c5922fbfSRuslan Ermilov.Pp 183c5922fbfSRuslan ErmilovIn addition, control variables can be specified 184c5922fbfSRuslan Ermilovfor a particular build via the 185c5922fbfSRuslan Ermilov.Fl D 186c5922fbfSRuslan Ermilovoption of 187c5922fbfSRuslan Ermilov.Xr make 1 1883d919b75SMike Makonnenor in its environment; see 189c5922fbfSRuslan Ermilov.Xr environ 7 . 190c5922fbfSRuslan Ermilov.Pp 191ca045714SBryan DreweryThe environment of 192ca045714SBryan Drewery.Xr make 1 193ca045714SBryan Dreweryfor the build can be controlled via the 194ca045714SBryan Drewery.Va SRC_ENV_CONF 195ca045714SBryan Dreweryvariable, which defaults to 196ca045714SBryan Drewery.Pa /etc/src-env.conf . 197ca045714SBryan DrewerySome examples that may only be set in this file are 198ca045714SBryan Drewery.Va MAKEOBJDIRPREFIX , 199ca045714SBryan Dreweryand 200ca045714SBryan Drewery.Va WITH_META_MODE 201ca045714SBryan Dreweryas they are environment-only variables. 202ca045714SBryan Drewery.Pp 20307b7d7fbSTom RhodesThe values of variables are ignored regardless of their setting; 20457caf3d6STom Rhodeseven if they would be set to 205c5922fbfSRuslan Ermilov.Dq Li FALSE 206c5922fbfSRuslan Ermilovor 20757caf3d6STom Rhodes.Dq Li NO . 20857caf3d6STom RhodesJust the existence of an option will cause 20957caf3d6STom Rhodesit to be honoured by 21057caf3d6STom Rhodes.Xr make 1 . 211c5922fbfSRuslan Ermilov.Pp 212c5922fbfSRuslan ErmilovThe following list provides a name and short description for variables 213c5922fbfSRuslan Ermilovthat can be used for source builds. 214c5922fbfSRuslan Ermilov.Bl -tag -width indent 215c5922fbfSRuslan ErmilovEOF 2162701a1b7SRuslan Ermilov show settings SRCCONF=/dev/null | sort > $t/config_default 217f506e293SEd Maste # Work around WITH_LDNS_UTILS forcing BIND_UTILS off by parsing the 218f506e293SEd Maste # actual config that results from enabling every WITH_ option. This 219f506e293SEd Maste # can be reverted if/when we no longer have options that disable 220f506e293SEd Maste # others. 221f506e293SEd Maste show with SRCCONF=/dev/null | sort | sed 's/$/=/' > $t/src.conf 222f506e293SEd Maste show settings SRCCONF=$t/src.conf | sort > $t/config_WITH_ALL 2232701a1b7SRuslan Ermilov show without SRCCONF=/dev/null | sort > $t/config_WITHOUT_ALL 224da6e996dSBryan Drewery env_only_options="$(${make} -V __ENV_ONLY_OPTIONS)" 2252701a1b7SRuslan Ermilov 2262701a1b7SRuslan Ermilov show_options | 2272701a1b7SRuslan Ermilov while read opt targets ; do 2282701a1b7SRuslan Ermilov if [ ! -f ${opt} ] ; then 2292701a1b7SRuslan Ermilov echo "no description found for ${opt}, skipping" >&2 230c3b08cc6SYaroslav Tykhiy continue 231cae68befSRuslan Ermilov fi 232cae68befSRuslan Ermilov 2332701a1b7SRuslan Ermilov echo ".It Va ${opt}" 2342701a1b7SRuslan Ermilov sed -e's/\$\(FreeBSD: .*\) \$/from \1/' ${opt} 2352701a1b7SRuslan Ermilov if [ -n "${targets}" ] ; then 2362701a1b7SRuslan Ermilov echo '.Pp' 2372701a1b7SRuslan Ermilov echo 'It is a default setting on' 2382701a1b7SRuslan Ermilov echo $(echo ${targets} | sed -e's/ /, /g' -e's/\(.*\), /\1 and /'). 239c5922fbfSRuslan Ermilov fi 2402701a1b7SRuslan Ermilov 241cae68befSRuslan Ermilov if [ "${opt%%_*}" = 'WITHOUT' ] ; then 2422701a1b7SRuslan Ermilov sed -n "/^WITH_${opt#WITHOUT_}$/!s/$/=/p" $t/config_WITH_ALL > $t/src.conf 2432701a1b7SRuslan Ermilov show settings SRCCONF=$t/src.conf -D${opt} | sort > $t/config_WITH_ALL_${opt} 2442701a1b7SRuslan Ermilov comm -13 $t/config_WITH_ALL $t/config_WITH_ALL_${opt} | sed -n "/^${opt}$/!p" > $t/deps 245cae68befSRuslan Ermilov elif [ "${opt%%_*}" = 'WITH' ] ; then 2462701a1b7SRuslan Ermilov sed -n "/^WITHOUT${opt#WITH}$/!s/$/=/p" $t/config_WITHOUT_ALL > $t/src.conf 2472701a1b7SRuslan Ermilov show settings SRCCONF=$t/src.conf -D${opt} | sort > $t/config_WITHOUT_ALL_${opt} 2482701a1b7SRuslan Ermilov comm -13 $t/config_WITHOUT_ALL $t/config_WITHOUT_ALL_${opt} | sed -n "/^${opt}$/!p" > $t/deps 2492701a1b7SRuslan Ermilov else 2502701a1b7SRuslan Ermilov echo 'internal error' >&2 2512701a1b7SRuslan Ermilov exit 1 2522701a1b7SRuslan Ermilov fi 2532701a1b7SRuslan Ermilov 254f506e293SEd Maste show settings SRCCONF=/dev/null -D${opt} | sort > $t/config_${opt} 255f506e293SEd Maste comm -13 $t/config_default $t/config_${opt} | sed -n "/^${opt}$/!p" | 256f506e293SEd Maste comm -13 $t/deps - > $t/deps2 257f506e293SEd Maste 258f506e293SEd Maste # Work around BIND_UTILS=no being the default when every WITH_ 259f506e293SEd Maste # option is enabled. 260e60c420fSEd Maste if [ "$(cat $t/deps2)" = WITHOUT_BIND_UTILS ]; then 261f506e293SEd Maste sort $t/deps $t/deps2 > $t/_deps 262f506e293SEd Maste mv $t/_deps $t/deps 263f506e293SEd Maste :> $t/deps2 264f506e293SEd Maste fi 265f506e293SEd Maste 266*4078537cSBryan Drewery havedeps=0 2672701a1b7SRuslan Ermilov if [ -s $t/deps ] ; then 268*4078537cSBryan Drewery havedeps=1 2692701a1b7SRuslan Ermilov echo 'When set, it also enforces the following options:' 2702701a1b7SRuslan Ermilov echo '.Pp' 2712701a1b7SRuslan Ermilov echo '.Bl -item -compact' 272*4078537cSBryan Drewery while read opt2 ; do 2732701a1b7SRuslan Ermilov echo '.It' 2742701a1b7SRuslan Ermilov echo ".Va ${opt2}" 275*4078537cSBryan Drewery done < $t/deps 2762701a1b7SRuslan Ermilov echo '.El' 2772701a1b7SRuslan Ermilov fi 2782701a1b7SRuslan Ermilov 2792701a1b7SRuslan Ermilov if [ -s $t/deps2 ] ; then 280*4078537cSBryan Drewery if [ ${havedeps} -eq 1 ] ; then 2812701a1b7SRuslan Ermilov echo '.Pp' 2822701a1b7SRuslan Ermilov fi 2832701a1b7SRuslan Ermilov echo 'When set, the following options are also in effect:' 2842701a1b7SRuslan Ermilov echo '.Pp' 2852701a1b7SRuslan Ermilov echo '.Bl -inset -compact' 286*4078537cSBryan Drewery while read opt2 ; do 2872701a1b7SRuslan Ermilov echo ".It Va ${opt2}" 2882701a1b7SRuslan Ermilov noopt=$(echo ${opt2} | sed -e's/WITH_/WITHOUT_/;t' -e's/WITHOUT_/WITH_/') 2892701a1b7SRuslan Ermilov echo '(unless' 2902701a1b7SRuslan Ermilov echo ".Va ${noopt}" 2912701a1b7SRuslan Ermilov echo 'is set explicitly)' 292*4078537cSBryan Drewery done < $t/deps2 2932701a1b7SRuslan Ermilov echo '.El' 294c5922fbfSRuslan Ermilov fi 295da6e996dSBryan Drewery 296da6e996dSBryan Drewery case " ${env_only_options} " in 297da6e996dSBryan Drewery *\ ${opt#*_}\ *) 298da6e996dSBryan Drewery echo ".Pp" 299da6e996dSBryan Drewery echo "This must be set in the environment or" 300da6e996dSBryan Drewery echo ".Pa /etc/src-env.conf ," 301da6e996dSBryan Drewery echo "not" 302da6e996dSBryan Drewery echo ".Pa /etc/src.conf ." 303da6e996dSBryan Drewery ;; 304da6e996dSBryan Drewery esac 305da6e996dSBryan Drewery 306e6a714e7SRuslan Ermilov twiddle >&2 307c5922fbfSRuslan Ermilov done 308c5922fbfSRuslan Ermilov cat <<EOF 309c5922fbfSRuslan Ermilov.El 310c5922fbfSRuslan Ermilov.Sh FILES 311691b39b5SGlen Barber.Bl -tag -compact -width Pa 312c5922fbfSRuslan Ermilov.It Pa /etc/src.conf 313ca045714SBryan Drewery.It Pa /etc/src-env.conf 314c5922fbfSRuslan Ermilov.It Pa /usr/share/mk/bsd.own.mk 315c5922fbfSRuslan Ermilov.El 316c5922fbfSRuslan Ermilov.Sh SEE ALSO 317c5922fbfSRuslan Ermilov.Xr make 1 , 318c5922fbfSRuslan Ermilov.Xr make.conf 5 , 319c5922fbfSRuslan Ermilov.Xr build 7 , 320c5922fbfSRuslan Ermilov.Xr ports 7 321c5922fbfSRuslan Ermilov.Sh HISTORY 322c5922fbfSRuslan ErmilovThe 323c5922fbfSRuslan Ermilov.Nm 324c5922fbfSRuslan Ermilovfile appeared in 325c5922fbfSRuslan Ermilov.Fx 7.0 . 326c5922fbfSRuslan Ermilov.Sh AUTHORS 327c5922fbfSRuslan ErmilovThis manual page was autogenerated. 328c5922fbfSRuslan ErmilovEOF 329c5922fbfSRuslan Ermilov} 330c5922fbfSRuslan Ermilov 331e6a714e7SRuslan Ermilovtwiddle_pos=0 332e6a714e7SRuslan Ermilovtwiddle() 333e6a714e7SRuslan Ermilov{ 334e6a714e7SRuslan Ermilov local c0='|' c1='/' c2='-' c3='\' 335e6a714e7SRuslan Ermilov 336e6a714e7SRuslan Ermilov eval printf '%c\\b' '$c'${twiddle_pos} 337e6a714e7SRuslan Ermilov twiddle_pos=$(((twiddle_pos+1)%4)) 338e6a714e7SRuslan Ermilov} 339e6a714e7SRuslan Ermilov 340c5922fbfSRuslan Ermilovmain 341