1c5922fbfSRuslan Ermilov#!/bin/sh 2c5922fbfSRuslan Ermilov# 3c5922fbfSRuslan Ermilov# This file is in the public domain. 4983e4096SEd Maste# $FreeBSD$ 59dc5d76eSEd Maste# 60af1da97SEd Maste# This script creates the src.conf.5 man page using template text contained 70af1da97SEd Maste# herein and the contents of the WITH_* and WITHOUT_* files in the same 80af1da97SEd Maste# directory. Each WITH_* and WITHOUT_* file documents the effect of the 99dc5d76eSEd Maste# /etc/src.conf knob with the same name. 109dc5d76eSEd Maste# 110af1da97SEd Maste# For each supported architecture, "make showconfig" is invoked to determine 120af1da97SEd Maste# the default setting of every option: always WITH_, always WITHOUT_, or 130af1da97SEd Maste# architecture-dependent WITH_/WITHOUT_. It also determines and describes 140af1da97SEd 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{ 47177d707cSBryan Drewery ALL_TARGETS=$(echo $(${make} targets MK_AUTO_OBJ=no | 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'$' 1440db9a543SEitan Adler generated='@'generated 145c5922fbfSRuslan Ermilov cat <<EOF 146b1a0e564SEitan Adler.\" DO NOT EDIT-- this file is $generated by tools/build/options/makeman. 147c5922fbfSRuslan Ermilov.\" ${fbsdid} 1482701a1b7SRuslan Ermilov.Dd $(echo $(LC_TIME=C date +'%B %e, %Y')) 149c5922fbfSRuslan Ermilov.Dt SRC.CONF 5 150c5922fbfSRuslan Ermilov.Os 151c5922fbfSRuslan Ermilov.Sh NAME 152c5922fbfSRuslan Ermilov.Nm src.conf 15357caf3d6STom Rhodes.Nd "source build options" 154c5922fbfSRuslan Ermilov.Sh DESCRIPTION 155c5922fbfSRuslan ErmilovThe 156c5922fbfSRuslan Ermilov.Nm 157*e6ca6901SGordon Berglingfile contains variables that control what components will be generated during 158*e6ca6901SGordon Berglingthe build process of the 159c5922fbfSRuslan Ermilov.Fx 160c5922fbfSRuslan Ermilovsource tree; see 161c5922fbfSRuslan Ermilov.Xr build 7 . 162c5922fbfSRuslan Ermilov.Pp 163c5922fbfSRuslan ErmilovThe 164c5922fbfSRuslan Ermilov.Nm 165c5922fbfSRuslan Ermilovfile uses the standard makefile syntax. 166c5922fbfSRuslan ErmilovHowever, 167c5922fbfSRuslan Ermilov.Nm 168c5922fbfSRuslan Ermilovshould not specify any dependencies to 169c5922fbfSRuslan Ermilov.Xr make 1 . 170c5922fbfSRuslan ErmilovInstead, 171c5922fbfSRuslan Ermilov.Nm 172c5922fbfSRuslan Ermilovis to set 173c5922fbfSRuslan Ermilov.Xr make 1 174c5922fbfSRuslan Ermilovvariables that control the aspects of how the system builds. 175c5922fbfSRuslan Ermilov.Pp 176c5922fbfSRuslan ErmilovThe default location of 177c5922fbfSRuslan Ermilov.Nm 178c5922fbfSRuslan Ermilovis 179c5922fbfSRuslan Ermilov.Pa /etc/src.conf , 180c5922fbfSRuslan Ermilovthough an alternative location can be specified in the 181c5922fbfSRuslan Ermilov.Xr make 1 182c5922fbfSRuslan Ermilovvariable 183c5922fbfSRuslan Ermilov.Va SRCCONF . 184c5922fbfSRuslan ErmilovOverriding the location of 185c5922fbfSRuslan Ermilov.Nm 186c5922fbfSRuslan Ermilovmay be necessary if the system-wide settings are not suitable 187c5922fbfSRuslan Ermilovfor a particular build. 188c5922fbfSRuslan ErmilovFor instance, setting 189c5922fbfSRuslan Ermilov.Va SRCCONF 190c5922fbfSRuslan Ermilovto 191c5922fbfSRuslan Ermilov.Pa /dev/null 192c5922fbfSRuslan Ermiloveffectively resets all build controls to their defaults. 193c5922fbfSRuslan Ermilov.Pp 194c5922fbfSRuslan ErmilovThe only purpose of 195c5922fbfSRuslan Ermilov.Nm 196c5922fbfSRuslan Ermilovis to control the compilation of the 197c5922fbfSRuslan Ermilov.Fx 19857caf3d6STom Rhodessource code, which is usually located in 199c5922fbfSRuslan Ermilov.Pa /usr/src . 200c5922fbfSRuslan ErmilovAs a rule, the system administrator creates 201c5922fbfSRuslan Ermilov.Nm 202c5922fbfSRuslan Ermilovwhen the values of certain control variables need to be changed 203c5922fbfSRuslan Ermilovfrom their defaults. 204c5922fbfSRuslan Ermilov.Pp 205c5922fbfSRuslan ErmilovIn addition, control variables can be specified 206c5922fbfSRuslan Ermilovfor a particular build via the 207c5922fbfSRuslan Ermilov.Fl D 208c5922fbfSRuslan Ermilovoption of 209c5922fbfSRuslan Ermilov.Xr make 1 2103d919b75SMike Makonnenor in its environment; see 211c5922fbfSRuslan Ermilov.Xr environ 7 . 212c5922fbfSRuslan Ermilov.Pp 213ca045714SBryan DreweryThe environment of 214ca045714SBryan Drewery.Xr make 1 215ca045714SBryan Dreweryfor the build can be controlled via the 216ca045714SBryan Drewery.Va SRC_ENV_CONF 217ca045714SBryan Dreweryvariable, which defaults to 218ca045714SBryan Drewery.Pa /etc/src-env.conf . 219ca045714SBryan DrewerySome examples that may only be set in this file are 22032b5dc9aSSimon J. Gerraty.Va WITH_DIRDEPS_BUILD , 221ca045714SBryan Dreweryand 222dfa09989SBryan Drewery.Va WITH_META_MODE , 223dfa09989SBryan Dreweryand 2245d111a97SBryan Drewery.Va MAKEOBJDIRPREFIX 225dfa09989SBryan Dreweryas they are environment-only variables. 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 248177d707cSBryan Drewery env_only_options="$(${make} MK_AUTO_OBJ=no -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 2824078537cSBryan Drewery havedeps=0 2832701a1b7SRuslan Ermilov if [ -s $t/deps ] ; then 2844078537cSBryan Drewery havedeps=1 2857a206c31SWarren Block echo 'When set, it enforces these options:' 2862701a1b7SRuslan Ermilov echo '.Pp' 2872701a1b7SRuslan Ermilov echo '.Bl -item -compact' 2884078537cSBryan Drewery while read opt2 ; do 2892701a1b7SRuslan Ermilov echo '.It' 2902701a1b7SRuslan Ermilov echo ".Va ${opt2}" 2914078537cSBryan Drewery done < $t/deps 2922701a1b7SRuslan Ermilov echo '.El' 2932701a1b7SRuslan Ermilov fi 2942701a1b7SRuslan Ermilov 2952701a1b7SRuslan Ermilov if [ -s $t/deps2 ] ; then 2964078537cSBryan Drewery if [ ${havedeps} -eq 1 ] ; then 2972701a1b7SRuslan Ermilov echo '.Pp' 2982701a1b7SRuslan Ermilov fi 2997a206c31SWarren Block echo 'When set, these options are also in effect:' 3002701a1b7SRuslan Ermilov echo '.Pp' 3012701a1b7SRuslan Ermilov echo '.Bl -inset -compact' 3024078537cSBryan Drewery while read opt2 ; do 3032701a1b7SRuslan Ermilov echo ".It Va ${opt2}" 3042701a1b7SRuslan Ermilov noopt=$(echo ${opt2} | sed -e's/WITH_/WITHOUT_/;t' -e's/WITHOUT_/WITH_/') 3052701a1b7SRuslan Ermilov echo '(unless' 3062701a1b7SRuslan Ermilov echo ".Va ${noopt}" 3072701a1b7SRuslan Ermilov echo 'is set explicitly)' 3084078537cSBryan Drewery done < $t/deps2 3092701a1b7SRuslan Ermilov echo '.El' 310c5922fbfSRuslan Ermilov fi 311da6e996dSBryan Drewery 312da6e996dSBryan Drewery case " ${env_only_options} " in 313da6e996dSBryan Drewery *\ ${opt#*_}\ *) 314da6e996dSBryan Drewery echo ".Pp" 315317c99b7SBryan Drewery echo "This must be set in the environment, make command line, or" 316da6e996dSBryan Drewery echo ".Pa /etc/src-env.conf ," 317da6e996dSBryan Drewery echo "not" 318da6e996dSBryan Drewery echo ".Pa /etc/src.conf ." 319da6e996dSBryan Drewery ;; 320da6e996dSBryan Drewery esac 321da6e996dSBryan Drewery 322e6a714e7SRuslan Ermilov twiddle >&2 323c5922fbfSRuslan Ermilov done 324c5922fbfSRuslan Ermilov cat <<EOF 325c5922fbfSRuslan Ermilov.El 326c5922fbfSRuslan Ermilov.Sh FILES 327691b39b5SGlen Barber.Bl -tag -compact -width Pa 328c5922fbfSRuslan Ermilov.It Pa /etc/src.conf 329ca045714SBryan Drewery.It Pa /etc/src-env.conf 330c5922fbfSRuslan Ermilov.It Pa /usr/share/mk/bsd.own.mk 331c5922fbfSRuslan Ermilov.El 332c5922fbfSRuslan Ermilov.Sh SEE ALSO 333c5922fbfSRuslan Ermilov.Xr make 1 , 334c5922fbfSRuslan Ermilov.Xr make.conf 5 , 335c5922fbfSRuslan Ermilov.Xr build 7 , 336c5922fbfSRuslan Ermilov.Xr ports 7 337c5922fbfSRuslan Ermilov.Sh HISTORY 338c5922fbfSRuslan ErmilovThe 339c5922fbfSRuslan Ermilov.Nm 340c5922fbfSRuslan Ermilovfile appeared in 341c5922fbfSRuslan Ermilov.Fx 7.0 . 342c5922fbfSRuslan Ermilov.Sh AUTHORS 343fd4f2cd5SEnji CooperThis manual page was autogenerated by 344cbc5a508SEnji Cooper.An tools/build/options/makeman . 345c5922fbfSRuslan ErmilovEOF 346c5922fbfSRuslan Ermilov} 347c5922fbfSRuslan Ermilov 348e6a714e7SRuslan Ermilovtwiddle_pos=0 349e6a714e7SRuslan Ermilovtwiddle() 350e6a714e7SRuslan Ermilov{ 351e6a714e7SRuslan Ermilov local c0='|' c1='/' c2='-' c3='\' 352e6a714e7SRuslan Ermilov 353e6a714e7SRuslan Ermilov eval printf '%c\\b' '$c'${twiddle_pos} 354e6a714e7SRuslan Ermilov twiddle_pos=$(((twiddle_pos+1)%4)) 355e6a714e7SRuslan Ermilov} 356e6a714e7SRuslan Ermilov 357c5922fbfSRuslan Ermilovmain 358