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 13*69c469c9SDag-Erling Smørgravsrcdir=$(realpath ../../..) 14*69c469c9SDag-Erling Smørgravmake="make -C $srcdir -m $srcdir/share/mk" 15*69c469c9SDag-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{ 33*69c469c9SDag-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 36*69c469c9SDag-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 *) 492701a1b7SRuslan Ermilov echo 'make showconfig broken' >&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 622701a1b7SRuslan Ermilov cat $t/settings | 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 712701a1b7SRuslan Ermilov done 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 99*69c469c9SDag-Erling Smørgrav ${make} "$@" 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 *) 1102701a1b7SRuslan Ermilov echo 'make showconfig broken' >&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 19107b7d7fbSTom RhodesThe values of variables are ignored regardless of their setting; 19257caf3d6STom Rhodeseven if they would be set to 193c5922fbfSRuslan Ermilov.Dq Li FALSE 194c5922fbfSRuslan Ermilovor 19557caf3d6STom Rhodes.Dq Li NO . 19657caf3d6STom RhodesJust the existence of an option will cause 19757caf3d6STom Rhodesit to be honoured by 19857caf3d6STom Rhodes.Xr make 1 . 199c5922fbfSRuslan Ermilov.Pp 200c5922fbfSRuslan ErmilovThe following list provides a name and short description for variables 201c5922fbfSRuslan Ermilovthat can be used for source builds. 202c5922fbfSRuslan Ermilov.Bl -tag -width indent 203c5922fbfSRuslan ErmilovEOF 2042701a1b7SRuslan Ermilov show settings SRCCONF=/dev/null | sort > $t/config_default 205f506e293SEd Maste # Work around WITH_LDNS_UTILS forcing BIND_UTILS off by parsing the 206f506e293SEd Maste # actual config that results from enabling every WITH_ option. This 207f506e293SEd Maste # can be reverted if/when we no longer have options that disable 208f506e293SEd Maste # others. 209f506e293SEd Maste show with SRCCONF=/dev/null | sort | sed 's/$/=/' > $t/src.conf 210f506e293SEd Maste show settings SRCCONF=$t/src.conf | sort > $t/config_WITH_ALL 2112701a1b7SRuslan Ermilov show without SRCCONF=/dev/null | sort > $t/config_WITHOUT_ALL 2122701a1b7SRuslan Ermilov 2132701a1b7SRuslan Ermilov show_options | 2142701a1b7SRuslan Ermilov while read opt targets ; do 2152701a1b7SRuslan Ermilov if [ ! -f ${opt} ] ; then 2162701a1b7SRuslan Ermilov echo "no description found for ${opt}, skipping" >&2 217c3b08cc6SYaroslav Tykhiy continue 218cae68befSRuslan Ermilov fi 219cae68befSRuslan Ermilov 2202701a1b7SRuslan Ermilov echo ".It Va ${opt}" 2212701a1b7SRuslan Ermilov sed -e's/\$\(FreeBSD: .*\) \$/from \1/' ${opt} 2222701a1b7SRuslan Ermilov if [ -n "${targets}" ] ; then 2232701a1b7SRuslan Ermilov echo '.Pp' 2242701a1b7SRuslan Ermilov echo 'It is a default setting on' 2252701a1b7SRuslan Ermilov echo $(echo ${targets} | sed -e's/ /, /g' -e's/\(.*\), /\1 and /'). 226c5922fbfSRuslan Ermilov fi 2272701a1b7SRuslan Ermilov 228cae68befSRuslan Ermilov if [ "${opt%%_*}" = 'WITHOUT' ] ; then 2292701a1b7SRuslan Ermilov sed -n "/^WITH_${opt#WITHOUT_}$/!s/$/=/p" $t/config_WITH_ALL > $t/src.conf 2302701a1b7SRuslan Ermilov show settings SRCCONF=$t/src.conf -D${opt} | sort > $t/config_WITH_ALL_${opt} 2312701a1b7SRuslan Ermilov comm -13 $t/config_WITH_ALL $t/config_WITH_ALL_${opt} | sed -n "/^${opt}$/!p" > $t/deps 232cae68befSRuslan Ermilov elif [ "${opt%%_*}" = 'WITH' ] ; then 2332701a1b7SRuslan Ermilov sed -n "/^WITHOUT${opt#WITH}$/!s/$/=/p" $t/config_WITHOUT_ALL > $t/src.conf 2342701a1b7SRuslan Ermilov show settings SRCCONF=$t/src.conf -D${opt} | sort > $t/config_WITHOUT_ALL_${opt} 2352701a1b7SRuslan Ermilov comm -13 $t/config_WITHOUT_ALL $t/config_WITHOUT_ALL_${opt} | sed -n "/^${opt}$/!p" > $t/deps 2362701a1b7SRuslan Ermilov else 2372701a1b7SRuslan Ermilov echo 'internal error' >&2 2382701a1b7SRuslan Ermilov exit 1 2392701a1b7SRuslan Ermilov fi 2402701a1b7SRuslan Ermilov 241f506e293SEd Maste show settings SRCCONF=/dev/null -D${opt} | sort > $t/config_${opt} 242f506e293SEd Maste comm -13 $t/config_default $t/config_${opt} | sed -n "/^${opt}$/!p" | 243f506e293SEd Maste comm -13 $t/deps - > $t/deps2 244f506e293SEd Maste 245f506e293SEd Maste # Work around BIND_UTILS=no being the default when every WITH_ 246f506e293SEd Maste # option is enabled. 247e60c420fSEd Maste if [ "$(cat $t/deps2)" = WITHOUT_BIND_UTILS ]; then 248f506e293SEd Maste sort $t/deps $t/deps2 > $t/_deps 249f506e293SEd Maste mv $t/_deps $t/deps 250f506e293SEd Maste :> $t/deps2 251f506e293SEd Maste fi 252f506e293SEd Maste 2532701a1b7SRuslan Ermilov if [ -s $t/deps ] ; then 2542701a1b7SRuslan Ermilov echo 'When set, it also enforces the following options:' 2552701a1b7SRuslan Ermilov echo '.Pp' 2562701a1b7SRuslan Ermilov echo '.Bl -item -compact' 2572701a1b7SRuslan Ermilov cat $t/deps | while read opt2 ; do 2582701a1b7SRuslan Ermilov echo '.It' 2592701a1b7SRuslan Ermilov echo ".Va ${opt2}" 260c5922fbfSRuslan Ermilov done 2612701a1b7SRuslan Ermilov echo '.El' 2622701a1b7SRuslan Ermilov fi 2632701a1b7SRuslan Ermilov 2642701a1b7SRuslan Ermilov if [ -s $t/deps2 ] ; then 2652701a1b7SRuslan Ermilov if [ -s $t/deps ] ; then 2662701a1b7SRuslan Ermilov echo '.Pp' 2672701a1b7SRuslan Ermilov fi 2682701a1b7SRuslan Ermilov echo 'When set, the following options are also in effect:' 2692701a1b7SRuslan Ermilov echo '.Pp' 2702701a1b7SRuslan Ermilov echo '.Bl -inset -compact' 2712701a1b7SRuslan Ermilov cat $t/deps2 | while read opt2 ; do 2722701a1b7SRuslan Ermilov echo ".It Va ${opt2}" 2732701a1b7SRuslan Ermilov noopt=$(echo ${opt2} | sed -e's/WITH_/WITHOUT_/;t' -e's/WITHOUT_/WITH_/') 2742701a1b7SRuslan Ermilov echo '(unless' 2752701a1b7SRuslan Ermilov echo ".Va ${noopt}" 2762701a1b7SRuslan Ermilov echo 'is set explicitly)' 2772701a1b7SRuslan Ermilov done 2782701a1b7SRuslan Ermilov echo '.El' 279c5922fbfSRuslan Ermilov fi 280e6a714e7SRuslan Ermilov twiddle >&2 281c5922fbfSRuslan Ermilov done 282c5922fbfSRuslan Ermilov cat <<EOF 283c5922fbfSRuslan Ermilov.El 284c5922fbfSRuslan Ermilov.Sh FILES 285691b39b5SGlen Barber.Bl -tag -compact -width Pa 286c5922fbfSRuslan Ermilov.It Pa /etc/src.conf 287c5922fbfSRuslan Ermilov.It Pa /usr/share/mk/bsd.own.mk 288c5922fbfSRuslan Ermilov.El 289c5922fbfSRuslan Ermilov.Sh SEE ALSO 290c5922fbfSRuslan Ermilov.Xr make 1 , 291c5922fbfSRuslan Ermilov.Xr make.conf 5 , 292c5922fbfSRuslan Ermilov.Xr build 7 , 293c5922fbfSRuslan Ermilov.Xr ports 7 294c5922fbfSRuslan Ermilov.Sh HISTORY 295c5922fbfSRuslan ErmilovThe 296c5922fbfSRuslan Ermilov.Nm 297c5922fbfSRuslan Ermilovfile appeared in 298c5922fbfSRuslan Ermilov.Fx 7.0 . 299c5922fbfSRuslan Ermilov.Sh AUTHORS 300c5922fbfSRuslan ErmilovThis manual page was autogenerated. 301c5922fbfSRuslan ErmilovEOF 302c5922fbfSRuslan Ermilov} 303c5922fbfSRuslan Ermilov 304e6a714e7SRuslan Ermilovtwiddle_pos=0 305e6a714e7SRuslan Ermilovtwiddle() 306e6a714e7SRuslan Ermilov{ 307e6a714e7SRuslan Ermilov local c0='|' c1='/' c2='-' c3='\' 308e6a714e7SRuslan Ermilov 309e6a714e7SRuslan Ermilov eval printf '%c\\b' '$c'${twiddle_pos} 310e6a714e7SRuslan Ermilov twiddle_pos=$(((twiddle_pos+1)%4)) 311e6a714e7SRuslan Ermilov} 312e6a714e7SRuslan Ermilov 313c5922fbfSRuslan Ermilovmain 314