1c5922fbfSRuslan Ermilov#!/bin/sh 2c5922fbfSRuslan Ermilov# 3c5922fbfSRuslan Ermilov# This file is in the public domain. 4983e4096SEd Maste# $FreeBSD$ 59dc5d76eSEd Maste# 6*0af1da97SEd Maste# This script creates the src.conf.5 man page using template text contained 7*0af1da97SEd Maste# herein and the contents of the WITH_* and WITHOUT_* files in the same 8*0af1da97SEd Maste# directory. Each WITH_* and WITHOUT_* file documents the effect of the 99dc5d76eSEd Maste# /etc/src.conf knob with the same name. 109dc5d76eSEd Maste# 11*0af1da97SEd Maste# For each supported architecture, "make showconfig" is invoked to determine 12*0af1da97SEd Maste# the default setting of every option: always WITH_, always WITHOUT_, or 13*0af1da97SEd Maste# architecture-dependent WITH_/WITHOUT_. It also determines and describes 14*0af1da97SEd Maste# dependencies between options. 159dc5d76eSEd Maste# 169dc5d76eSEd Maste# Usage: 179dc5d76eSEd Maste# 189dc5d76eSEd Maste# cd tools/build/options 199dc5d76eSEd Maste# sh makeman > ../../../share/man/man5/src.conf.5 20c5922fbfSRuslan Ermilov 212701a1b7SRuslan Ermilovset -o errexit 22f1f871e1SHajimu UMEMOTOexport LC_ALL=C 232701a1b7SRuslan Ermilov 242701a1b7SRuslan Ermilovt=$(mktemp -d -t makeman) 254af17bf5SWarren Blocktrap 'test -d $t && rm -rf $t' exit 262701a1b7SRuslan Ermilov 2769c469c9SDag-Erling Smørgravsrcdir=$(realpath ../../..) 2869c469c9SDag-Erling Smørgravmake="make -C $srcdir -m $srcdir/share/mk" 2969c469c9SDag-Erling Smørgrav 30c5922fbfSRuslan Ermilov# 312701a1b7SRuslan Ermilov# usage: no_targets all_targets yes_targets 322701a1b7SRuslan Ermilov# 332701a1b7SRuslan Ermilovno_targets() 342701a1b7SRuslan Ermilov{ 352701a1b7SRuslan Ermilov for t1 in $1 ; do 362701a1b7SRuslan Ermilov for t2 in $2 ; do 372701a1b7SRuslan Ermilov if [ "${t1}" = "${t2}" ] ; then 382701a1b7SRuslan Ermilov continue 2 392701a1b7SRuslan Ermilov fi 402701a1b7SRuslan Ermilov done 412701a1b7SRuslan Ermilov echo ${t1} 422701a1b7SRuslan Ermilov done 432701a1b7SRuslan Ermilov} 442701a1b7SRuslan Ermilov 452701a1b7SRuslan Ermilovshow_options() 462701a1b7SRuslan Ermilov{ 4769c469c9SDag-Erling Smørgrav ALL_TARGETS=$(echo $(${make} targets | tail -n +2)) 482701a1b7SRuslan Ermilov rm -f $t/settings 492701a1b7SRuslan Ermilov for target in ${ALL_TARGETS} ; do 50b7f38e69SEd Maste prev_opt= 513dfad7c7SBryan Drewery env -i ${make} showconfig \ 52317c99b7SBryan Drewery SRC_ENV_CONF=/dev/null SRCCONF=/dev/null \ 53317c99b7SBryan Drewery __MAKE_CONF=/dev/null \ 542701a1b7SRuslan Ermilov TARGET_ARCH=${target#*/} TARGET=${target%/*} | 552701a1b7SRuslan Ermilov while read var _ val ; do 562701a1b7SRuslan Ermilov opt=${var#MK_} 57b7f38e69SEd Maste if [ $opt = "$prev_opt" ]; then 58b7f38e69SEd Maste echo "$target: ignoring duplicate option $opt" >&2 59b7f38e69SEd Maste continue 60b7f38e69SEd Maste fi 61b7f38e69SEd Maste prev_opt=$opt 622701a1b7SRuslan Ermilov case ${val} in 632701a1b7SRuslan Ermilov yes) 642701a1b7SRuslan Ermilov echo ${opt} ${target} 652701a1b7SRuslan Ermilov ;; 662701a1b7SRuslan Ermilov no) 672701a1b7SRuslan Ermilov echo ${opt} 682701a1b7SRuslan Ermilov ;; 692701a1b7SRuslan Ermilov *) 70cc2520d2SSimon J. Gerraty echo "make showconfig broken: ${var} ${_} ${val} (not yes or no)" >&2 712701a1b7SRuslan Ermilov exit 1 722701a1b7SRuslan Ermilov ;; 732701a1b7SRuslan Ermilov esac 742701a1b7SRuslan Ermilov done > $t/settings.target 752701a1b7SRuslan Ermilov if [ -r $t/settings ] ; then 762701a1b7SRuslan Ermilov join -t\ $t/settings $t/settings.target > $t/settings.new 772701a1b7SRuslan Ermilov mv $t/settings.new $t/settings 782701a1b7SRuslan Ermilov else 792701a1b7SRuslan Ermilov mv $t/settings.target $t/settings 802701a1b7SRuslan Ermilov fi 812701a1b7SRuslan Ermilov done 822701a1b7SRuslan Ermilov 834078537cSBryan Drewery while read opt targets ; do 842701a1b7SRuslan Ermilov if [ "${targets}" = "${ALL_TARGETS}" ] ; then 852701a1b7SRuslan Ermilov echo "WITHOUT_${opt}" 862701a1b7SRuslan Ermilov elif [ -z "${targets}" ] ; then 872701a1b7SRuslan Ermilov echo "WITH_${opt}" 882701a1b7SRuslan Ermilov else 892701a1b7SRuslan Ermilov echo "WITHOUT_${opt}" $(no_targets "${ALL_TARGETS}" "${targets}") 902701a1b7SRuslan Ermilov echo "WITH_${opt} ${targets}" 912701a1b7SRuslan Ermilov fi 924078537cSBryan Drewery done < $t/settings 932701a1b7SRuslan Ermilov} 942701a1b7SRuslan Ermilov 952701a1b7SRuslan Ermilov# 962701a1b7SRuslan Ermilov# usage: show { settings | with | without } ... 97c5922fbfSRuslan Ermilov# 98c5922fbfSRuslan Ermilovshow() 99c5922fbfSRuslan Ermilov{ 100c5922fbfSRuslan Ermilov 101c5922fbfSRuslan Ermilov mode=$1 ; shift 102c5922fbfSRuslan Ermilov case ${mode} in 103c5922fbfSRuslan Ermilov settings) 104c5922fbfSRuslan Ermilov yes_prefix=WITH 105c5922fbfSRuslan Ermilov no_prefix=WITHOUT 106c5922fbfSRuslan Ermilov ;; 1072701a1b7SRuslan Ermilov with) 1082701a1b7SRuslan Ermilov yes_prefix=WITH 109c5922fbfSRuslan Ermilov no_prefix=WITH 110c5922fbfSRuslan Ermilov ;; 1112701a1b7SRuslan Ermilov without) 1122701a1b7SRuslan Ermilov yes_prefix=WITHOUT 1132701a1b7SRuslan Ermilov no_prefix=WITHOUT 1142701a1b7SRuslan Ermilov ;; 115c5922fbfSRuslan Ermilov *) 1162701a1b7SRuslan Ermilov echo 'internal error' >&2 117c5922fbfSRuslan Ermilov exit 1 118c5922fbfSRuslan Ermilov ;; 119c5922fbfSRuslan Ermilov esac 1203dfad7c7SBryan Drewery env -i ${make} .MAKE.MODE=normal "$@" showconfig __MAKE_CONF=/dev/null \ 121317c99b7SBryan Drewery SRCCONF=/dev/null | 122c5922fbfSRuslan Ermilov while read var _ val ; do 123c5922fbfSRuslan Ermilov opt=${var#MK_} 124c5922fbfSRuslan Ermilov case ${val} in 125c5922fbfSRuslan Ermilov yes) 126c5922fbfSRuslan Ermilov echo ${yes_prefix}_${opt} 127c5922fbfSRuslan Ermilov ;; 128c5922fbfSRuslan Ermilov no) 129c5922fbfSRuslan Ermilov echo ${no_prefix}_${opt} 130c5922fbfSRuslan Ermilov ;; 131c5922fbfSRuslan Ermilov *) 132cc2520d2SSimon J. Gerraty echo "make showconfig broken: ${var} ${_} ${val} (not yes or no)" >&2 133c5922fbfSRuslan Ermilov exit 1 134c5922fbfSRuslan Ermilov ;; 135c5922fbfSRuslan Ermilov esac 136c5922fbfSRuslan Ermilov done 137c5922fbfSRuslan Ermilov} 138c5922fbfSRuslan Ermilov 139c5922fbfSRuslan Ermilovmain() 140c5922fbfSRuslan Ermilov{ 1417a206c31SWarren Block echo "building src.conf.5 man page from files in ${PWD}" >&2 142c5922fbfSRuslan Ermilov 14341c8ddc3SRuslan Ermilov fbsdid='$'FreeBSD'$' 144c5922fbfSRuslan Ermilov cat <<EOF 1459dc5d76eSEd Maste.\" DO NOT EDIT-- this file is generated by tools/build/options/makeman. 146c5922fbfSRuslan Ermilov.\" ${fbsdid} 1472701a1b7SRuslan Ermilov.Dd $(echo $(LC_TIME=C date +'%B %e, %Y')) 148c5922fbfSRuslan Ermilov.Dt SRC.CONF 5 149c5922fbfSRuslan Ermilov.Os 150c5922fbfSRuslan Ermilov.Sh NAME 151c5922fbfSRuslan Ermilov.Nm src.conf 15257caf3d6STom Rhodes.Nd "source build options" 153c5922fbfSRuslan Ermilov.Sh DESCRIPTION 154c5922fbfSRuslan ErmilovThe 155c5922fbfSRuslan Ermilov.Nm 156c5922fbfSRuslan Ermilovfile contains settings that will apply to every build involving the 157c5922fbfSRuslan Ermilov.Fx 158c5922fbfSRuslan Ermilovsource tree; see 159c5922fbfSRuslan Ermilov.Xr build 7 . 160c5922fbfSRuslan Ermilov.Pp 161c5922fbfSRuslan ErmilovThe 162c5922fbfSRuslan Ermilov.Nm 163c5922fbfSRuslan Ermilovfile uses the standard makefile syntax. 164c5922fbfSRuslan ErmilovHowever, 165c5922fbfSRuslan Ermilov.Nm 166c5922fbfSRuslan Ermilovshould not specify any dependencies to 167c5922fbfSRuslan Ermilov.Xr make 1 . 168c5922fbfSRuslan ErmilovInstead, 169c5922fbfSRuslan Ermilov.Nm 170c5922fbfSRuslan Ermilovis to set 171c5922fbfSRuslan Ermilov.Xr make 1 172c5922fbfSRuslan Ermilovvariables that control the aspects of how the system builds. 173c5922fbfSRuslan Ermilov.Pp 174c5922fbfSRuslan ErmilovThe default location of 175c5922fbfSRuslan Ermilov.Nm 176c5922fbfSRuslan Ermilovis 177c5922fbfSRuslan Ermilov.Pa /etc/src.conf , 178c5922fbfSRuslan Ermilovthough an alternative location can be specified in the 179c5922fbfSRuslan Ermilov.Xr make 1 180c5922fbfSRuslan Ermilovvariable 181c5922fbfSRuslan Ermilov.Va SRCCONF . 182c5922fbfSRuslan ErmilovOverriding the location of 183c5922fbfSRuslan Ermilov.Nm 184c5922fbfSRuslan Ermilovmay be necessary if the system-wide settings are not suitable 185c5922fbfSRuslan Ermilovfor a particular build. 186c5922fbfSRuslan ErmilovFor instance, setting 187c5922fbfSRuslan Ermilov.Va SRCCONF 188c5922fbfSRuslan Ermilovto 189c5922fbfSRuslan Ermilov.Pa /dev/null 190c5922fbfSRuslan Ermiloveffectively resets all build controls to their defaults. 191c5922fbfSRuslan Ermilov.Pp 192c5922fbfSRuslan ErmilovThe only purpose of 193c5922fbfSRuslan Ermilov.Nm 194c5922fbfSRuslan Ermilovis to control the compilation of the 195c5922fbfSRuslan Ermilov.Fx 19657caf3d6STom Rhodessource code, which is usually located in 197c5922fbfSRuslan Ermilov.Pa /usr/src . 198c5922fbfSRuslan ErmilovAs a rule, the system administrator creates 199c5922fbfSRuslan Ermilov.Nm 200c5922fbfSRuslan Ermilovwhen the values of certain control variables need to be changed 201c5922fbfSRuslan Ermilovfrom their defaults. 202c5922fbfSRuslan Ermilov.Pp 203c5922fbfSRuslan ErmilovIn addition, control variables can be specified 204c5922fbfSRuslan Ermilovfor a particular build via the 205c5922fbfSRuslan Ermilov.Fl D 206c5922fbfSRuslan Ermilovoption of 207c5922fbfSRuslan Ermilov.Xr make 1 2083d919b75SMike Makonnenor in its environment; see 209c5922fbfSRuslan Ermilov.Xr environ 7 . 210c5922fbfSRuslan Ermilov.Pp 211ca045714SBryan DreweryThe environment of 212ca045714SBryan Drewery.Xr make 1 213ca045714SBryan Dreweryfor the build can be controlled via the 214ca045714SBryan Drewery.Va SRC_ENV_CONF 215ca045714SBryan Dreweryvariable, which defaults to 216ca045714SBryan Drewery.Pa /etc/src-env.conf . 217ca045714SBryan DrewerySome examples that may only be set in this file are 21832b5dc9aSSimon J. Gerraty.Va WITH_DIRDEPS_BUILD , 219ca045714SBryan Dreweryand 220ca045714SBryan Drewery.Va WITH_META_MODE 221ca045714SBryan Dreweryas they are environment-only variables. 2225d111a97SBryan DreweryNote that 2235d111a97SBryan Drewery.Va MAKEOBJDIRPREFIX 2245d111a97SBryan Drewerymay be set here only when using 2255d111a97SBryan Drewery.Va WITH_DIRDEPS_BUILD . 226ca045714SBryan Drewery.Pp 22707b7d7fbSTom RhodesThe values of variables are ignored regardless of their setting; 22857caf3d6STom Rhodeseven if they would be set to 229c5922fbfSRuslan Ermilov.Dq Li FALSE 230c5922fbfSRuslan Ermilovor 23157caf3d6STom Rhodes.Dq Li NO . 2327a206c31SWarren BlockThe presence of an option causes 2337a206c31SWarren Blockit to be honored by 23457caf3d6STom Rhodes.Xr make 1 . 235c5922fbfSRuslan Ermilov.Pp 2367a206c31SWarren BlockThis list provides a name and short description for variables 237c5922fbfSRuslan Ermilovthat can be used for source builds. 238c5922fbfSRuslan Ermilov.Bl -tag -width indent 239c5922fbfSRuslan ErmilovEOF 240317c99b7SBryan Drewery show settings SRC_ENV_CONF=/dev/null | sort > $t/config_default 241f506e293SEd Maste # Work around WITH_LDNS_UTILS forcing BIND_UTILS off by parsing the 242f506e293SEd Maste # actual config that results from enabling every WITH_ option. This 243f506e293SEd Maste # can be reverted if/when we no longer have options that disable 244f506e293SEd Maste # others. 245317c99b7SBryan Drewery show with SRC_ENV_CONF=/dev/null | sort | sed 's/$/=/' > $t/src.conf 246317c99b7SBryan Drewery show settings SRC_ENV_CONF=$t/src.conf | sort > $t/config_WITH_ALL 247317c99b7SBryan Drewery show without SRC_ENV_CONF=/dev/null | sort > $t/config_WITHOUT_ALL 248da6e996dSBryan Drewery env_only_options="$(${make} -V __ENV_ONLY_OPTIONS)" 2492701a1b7SRuslan Ermilov 2502701a1b7SRuslan Ermilov show_options | 2512701a1b7SRuslan Ermilov while read opt targets ; do 2522701a1b7SRuslan Ermilov if [ ! -f ${opt} ] ; then 2532701a1b7SRuslan Ermilov echo "no description found for ${opt}, skipping" >&2 254c3b08cc6SYaroslav Tykhiy continue 255cae68befSRuslan Ermilov fi 256cae68befSRuslan Ermilov 2572701a1b7SRuslan Ermilov echo ".It Va ${opt}" 258983e4096SEd Maste sed -e'/\$FreeBSD.*\$/d' ${opt} 2592701a1b7SRuslan Ermilov if [ -n "${targets}" ] ; then 2602701a1b7SRuslan Ermilov echo '.Pp' 2617a206c31SWarren Block echo 'This is a default setting on' 2622701a1b7SRuslan Ermilov echo $(echo ${targets} | sed -e's/ /, /g' -e's/\(.*\), /\1 and /'). 263c5922fbfSRuslan Ermilov fi 2642701a1b7SRuslan Ermilov 265cae68befSRuslan Ermilov if [ "${opt%%_*}" = 'WITHOUT' ] ; then 2662701a1b7SRuslan Ermilov sed -n "/^WITH_${opt#WITHOUT_}$/!s/$/=/p" $t/config_WITH_ALL > $t/src.conf 267317c99b7SBryan Drewery show settings SRC_ENV_CONF=$t/src.conf -D${opt} | sort > $t/config_WITH_ALL_${opt} 2682701a1b7SRuslan Ermilov comm -13 $t/config_WITH_ALL $t/config_WITH_ALL_${opt} | sed -n "/^${opt}$/!p" > $t/deps 269cae68befSRuslan Ermilov elif [ "${opt%%_*}" = 'WITH' ] ; then 2702701a1b7SRuslan Ermilov sed -n "/^WITHOUT${opt#WITH}$/!s/$/=/p" $t/config_WITHOUT_ALL > $t/src.conf 271317c99b7SBryan Drewery show settings SRC_ENV_CONF=$t/src.conf -D${opt} | sort > $t/config_WITHOUT_ALL_${opt} 2722701a1b7SRuslan Ermilov comm -13 $t/config_WITHOUT_ALL $t/config_WITHOUT_ALL_${opt} | sed -n "/^${opt}$/!p" > $t/deps 2732701a1b7SRuslan Ermilov else 2742701a1b7SRuslan Ermilov echo 'internal error' >&2 2752701a1b7SRuslan Ermilov exit 1 2762701a1b7SRuslan Ermilov fi 2772701a1b7SRuslan Ermilov 278317c99b7SBryan Drewery show settings SRC_ENV_CONF=/dev/null -D${opt} | sort > $t/config_${opt} 279f506e293SEd Maste comm -13 $t/config_default $t/config_${opt} | sed -n "/^${opt}$/!p" | 280f506e293SEd Maste comm -13 $t/deps - > $t/deps2 281f506e293SEd Maste 282f506e293SEd Maste # Work around BIND_UTILS=no being the default when every WITH_ 283f506e293SEd Maste # option is enabled. 284e60c420fSEd Maste if [ "$(cat $t/deps2)" = WITHOUT_BIND_UTILS ]; then 285f506e293SEd Maste sort $t/deps $t/deps2 > $t/_deps 286f506e293SEd Maste mv $t/_deps $t/deps 287f506e293SEd Maste :> $t/deps2 288f506e293SEd Maste fi 289f506e293SEd Maste 2904078537cSBryan Drewery havedeps=0 2912701a1b7SRuslan Ermilov if [ -s $t/deps ] ; then 2924078537cSBryan Drewery havedeps=1 2937a206c31SWarren Block echo 'When set, it enforces these options:' 2942701a1b7SRuslan Ermilov echo '.Pp' 2952701a1b7SRuslan Ermilov echo '.Bl -item -compact' 2964078537cSBryan Drewery while read opt2 ; do 2972701a1b7SRuslan Ermilov echo '.It' 2982701a1b7SRuslan Ermilov echo ".Va ${opt2}" 2994078537cSBryan Drewery done < $t/deps 3002701a1b7SRuslan Ermilov echo '.El' 3012701a1b7SRuslan Ermilov fi 3022701a1b7SRuslan Ermilov 3032701a1b7SRuslan Ermilov if [ -s $t/deps2 ] ; then 3044078537cSBryan Drewery if [ ${havedeps} -eq 1 ] ; then 3052701a1b7SRuslan Ermilov echo '.Pp' 3062701a1b7SRuslan Ermilov fi 3077a206c31SWarren Block echo 'When set, these options are also in effect:' 3082701a1b7SRuslan Ermilov echo '.Pp' 3092701a1b7SRuslan Ermilov echo '.Bl -inset -compact' 3104078537cSBryan Drewery while read opt2 ; do 3112701a1b7SRuslan Ermilov echo ".It Va ${opt2}" 3122701a1b7SRuslan Ermilov noopt=$(echo ${opt2} | sed -e's/WITH_/WITHOUT_/;t' -e's/WITHOUT_/WITH_/') 3132701a1b7SRuslan Ermilov echo '(unless' 3142701a1b7SRuslan Ermilov echo ".Va ${noopt}" 3152701a1b7SRuslan Ermilov echo 'is set explicitly)' 3164078537cSBryan Drewery done < $t/deps2 3172701a1b7SRuslan Ermilov echo '.El' 318c5922fbfSRuslan Ermilov fi 319da6e996dSBryan Drewery 320da6e996dSBryan Drewery case " ${env_only_options} " in 321da6e996dSBryan Drewery *\ ${opt#*_}\ *) 322da6e996dSBryan Drewery echo ".Pp" 323317c99b7SBryan Drewery echo "This must be set in the environment, make command line, or" 324da6e996dSBryan Drewery echo ".Pa /etc/src-env.conf ," 325da6e996dSBryan Drewery echo "not" 326da6e996dSBryan Drewery echo ".Pa /etc/src.conf ." 327da6e996dSBryan Drewery ;; 328da6e996dSBryan Drewery esac 329da6e996dSBryan Drewery 330e6a714e7SRuslan Ermilov twiddle >&2 331c5922fbfSRuslan Ermilov done 332c5922fbfSRuslan Ermilov cat <<EOF 333c5922fbfSRuslan Ermilov.El 334c5922fbfSRuslan Ermilov.Sh FILES 335691b39b5SGlen Barber.Bl -tag -compact -width Pa 336c5922fbfSRuslan Ermilov.It Pa /etc/src.conf 337ca045714SBryan Drewery.It Pa /etc/src-env.conf 338c5922fbfSRuslan Ermilov.It Pa /usr/share/mk/bsd.own.mk 339c5922fbfSRuslan Ermilov.El 340c5922fbfSRuslan Ermilov.Sh SEE ALSO 341c5922fbfSRuslan Ermilov.Xr make 1 , 342c5922fbfSRuslan Ermilov.Xr make.conf 5 , 343c5922fbfSRuslan Ermilov.Xr build 7 , 344c5922fbfSRuslan Ermilov.Xr ports 7 345c5922fbfSRuslan Ermilov.Sh HISTORY 346c5922fbfSRuslan ErmilovThe 347c5922fbfSRuslan Ermilov.Nm 348c5922fbfSRuslan Ermilovfile appeared in 349c5922fbfSRuslan Ermilov.Fx 7.0 . 350c5922fbfSRuslan Ermilov.Sh AUTHORS 351fd4f2cd5SEnji CooperThis manual page was autogenerated by 352cbc5a508SEnji Cooper.An tools/build/options/makeman . 353c5922fbfSRuslan ErmilovEOF 354c5922fbfSRuslan Ermilov} 355c5922fbfSRuslan Ermilov 356e6a714e7SRuslan Ermilovtwiddle_pos=0 357e6a714e7SRuslan Ermilovtwiddle() 358e6a714e7SRuslan Ermilov{ 359e6a714e7SRuslan Ermilov local c0='|' c1='/' c2='-' c3='\' 360e6a714e7SRuslan Ermilov 361e6a714e7SRuslan Ermilov eval printf '%c\\b' '$c'${twiddle_pos} 362e6a714e7SRuslan Ermilov twiddle_pos=$(((twiddle_pos+1)%4)) 363e6a714e7SRuslan Ermilov} 364e6a714e7SRuslan Ermilov 365c5922fbfSRuslan Ermilovmain 366