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'$' 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 220*dfa09989SBryan Drewery.Va WITH_META_MODE , 221*dfa09989SBryan Dreweryand 2225d111a97SBryan Drewery.Va MAKEOBJDIRPREFIX 223*dfa09989SBryan Dreweryas they are environment-only variables. 224ca045714SBryan Drewery.Pp 22507b7d7fbSTom RhodesThe values of variables are ignored regardless of their setting; 22657caf3d6STom Rhodeseven if they would be set to 227c5922fbfSRuslan Ermilov.Dq Li FALSE 228c5922fbfSRuslan Ermilovor 22957caf3d6STom Rhodes.Dq Li NO . 2307a206c31SWarren BlockThe presence of an option causes 2317a206c31SWarren Blockit to be honored by 23257caf3d6STom Rhodes.Xr make 1 . 233c5922fbfSRuslan Ermilov.Pp 2347a206c31SWarren BlockThis list provides a name and short description for variables 235c5922fbfSRuslan Ermilovthat can be used for source builds. 236c5922fbfSRuslan Ermilov.Bl -tag -width indent 237c5922fbfSRuslan ErmilovEOF 238317c99b7SBryan Drewery show settings SRC_ENV_CONF=/dev/null | sort > $t/config_default 239f506e293SEd Maste # Work around WITH_LDNS_UTILS forcing BIND_UTILS off by parsing the 240f506e293SEd Maste # actual config that results from enabling every WITH_ option. This 241f506e293SEd Maste # can be reverted if/when we no longer have options that disable 242f506e293SEd Maste # others. 243317c99b7SBryan Drewery show with SRC_ENV_CONF=/dev/null | sort | sed 's/$/=/' > $t/src.conf 244317c99b7SBryan Drewery show settings SRC_ENV_CONF=$t/src.conf | sort > $t/config_WITH_ALL 245317c99b7SBryan Drewery show without SRC_ENV_CONF=/dev/null | sort > $t/config_WITHOUT_ALL 246177d707cSBryan Drewery env_only_options="$(${make} MK_AUTO_OBJ=no -V __ENV_ONLY_OPTIONS)" 2472701a1b7SRuslan Ermilov 2482701a1b7SRuslan Ermilov show_options | 2492701a1b7SRuslan Ermilov while read opt targets ; do 2502701a1b7SRuslan Ermilov if [ ! -f ${opt} ] ; then 2512701a1b7SRuslan Ermilov echo "no description found for ${opt}, skipping" >&2 252c3b08cc6SYaroslav Tykhiy continue 253cae68befSRuslan Ermilov fi 254cae68befSRuslan Ermilov 2552701a1b7SRuslan Ermilov echo ".It Va ${opt}" 256983e4096SEd Maste sed -e'/\$FreeBSD.*\$/d' ${opt} 2572701a1b7SRuslan Ermilov if [ -n "${targets}" ] ; then 2582701a1b7SRuslan Ermilov echo '.Pp' 2597a206c31SWarren Block echo 'This is a default setting on' 2602701a1b7SRuslan Ermilov echo $(echo ${targets} | sed -e's/ /, /g' -e's/\(.*\), /\1 and /'). 261c5922fbfSRuslan Ermilov fi 2622701a1b7SRuslan Ermilov 263cae68befSRuslan Ermilov if [ "${opt%%_*}" = 'WITHOUT' ] ; then 2642701a1b7SRuslan Ermilov sed -n "/^WITH_${opt#WITHOUT_}$/!s/$/=/p" $t/config_WITH_ALL > $t/src.conf 265317c99b7SBryan Drewery show settings SRC_ENV_CONF=$t/src.conf -D${opt} | sort > $t/config_WITH_ALL_${opt} 2662701a1b7SRuslan Ermilov comm -13 $t/config_WITH_ALL $t/config_WITH_ALL_${opt} | sed -n "/^${opt}$/!p" > $t/deps 267cae68befSRuslan Ermilov elif [ "${opt%%_*}" = 'WITH' ] ; then 2682701a1b7SRuslan Ermilov sed -n "/^WITHOUT${opt#WITH}$/!s/$/=/p" $t/config_WITHOUT_ALL > $t/src.conf 269317c99b7SBryan Drewery show settings SRC_ENV_CONF=$t/src.conf -D${opt} | sort > $t/config_WITHOUT_ALL_${opt} 2702701a1b7SRuslan Ermilov comm -13 $t/config_WITHOUT_ALL $t/config_WITHOUT_ALL_${opt} | sed -n "/^${opt}$/!p" > $t/deps 2712701a1b7SRuslan Ermilov else 2722701a1b7SRuslan Ermilov echo 'internal error' >&2 2732701a1b7SRuslan Ermilov exit 1 2742701a1b7SRuslan Ermilov fi 2752701a1b7SRuslan Ermilov 276317c99b7SBryan Drewery show settings SRC_ENV_CONF=/dev/null -D${opt} | sort > $t/config_${opt} 277f506e293SEd Maste comm -13 $t/config_default $t/config_${opt} | sed -n "/^${opt}$/!p" | 278f506e293SEd Maste comm -13 $t/deps - > $t/deps2 279f506e293SEd Maste 2804078537cSBryan Drewery havedeps=0 2812701a1b7SRuslan Ermilov if [ -s $t/deps ] ; then 2824078537cSBryan Drewery havedeps=1 2837a206c31SWarren Block echo 'When set, it enforces these options:' 2842701a1b7SRuslan Ermilov echo '.Pp' 2852701a1b7SRuslan Ermilov echo '.Bl -item -compact' 2864078537cSBryan Drewery while read opt2 ; do 2872701a1b7SRuslan Ermilov echo '.It' 2882701a1b7SRuslan Ermilov echo ".Va ${opt2}" 2894078537cSBryan Drewery done < $t/deps 2902701a1b7SRuslan Ermilov echo '.El' 2912701a1b7SRuslan Ermilov fi 2922701a1b7SRuslan Ermilov 2932701a1b7SRuslan Ermilov if [ -s $t/deps2 ] ; then 2944078537cSBryan Drewery if [ ${havedeps} -eq 1 ] ; then 2952701a1b7SRuslan Ermilov echo '.Pp' 2962701a1b7SRuslan Ermilov fi 2977a206c31SWarren Block echo 'When set, these options are also in effect:' 2982701a1b7SRuslan Ermilov echo '.Pp' 2992701a1b7SRuslan Ermilov echo '.Bl -inset -compact' 3004078537cSBryan Drewery while read opt2 ; do 3012701a1b7SRuslan Ermilov echo ".It Va ${opt2}" 3022701a1b7SRuslan Ermilov noopt=$(echo ${opt2} | sed -e's/WITH_/WITHOUT_/;t' -e's/WITHOUT_/WITH_/') 3032701a1b7SRuslan Ermilov echo '(unless' 3042701a1b7SRuslan Ermilov echo ".Va ${noopt}" 3052701a1b7SRuslan Ermilov echo 'is set explicitly)' 3064078537cSBryan Drewery done < $t/deps2 3072701a1b7SRuslan Ermilov echo '.El' 308c5922fbfSRuslan Ermilov fi 309da6e996dSBryan Drewery 310da6e996dSBryan Drewery case " ${env_only_options} " in 311da6e996dSBryan Drewery *\ ${opt#*_}\ *) 312da6e996dSBryan Drewery echo ".Pp" 313317c99b7SBryan Drewery echo "This must be set in the environment, make command line, or" 314da6e996dSBryan Drewery echo ".Pa /etc/src-env.conf ," 315da6e996dSBryan Drewery echo "not" 316da6e996dSBryan Drewery echo ".Pa /etc/src.conf ." 317da6e996dSBryan Drewery ;; 318da6e996dSBryan Drewery esac 319da6e996dSBryan Drewery 320e6a714e7SRuslan Ermilov twiddle >&2 321c5922fbfSRuslan Ermilov done 322c5922fbfSRuslan Ermilov cat <<EOF 323c5922fbfSRuslan Ermilov.El 324c5922fbfSRuslan Ermilov.Sh FILES 325691b39b5SGlen Barber.Bl -tag -compact -width Pa 326c5922fbfSRuslan Ermilov.It Pa /etc/src.conf 327ca045714SBryan Drewery.It Pa /etc/src-env.conf 328c5922fbfSRuslan Ermilov.It Pa /usr/share/mk/bsd.own.mk 329c5922fbfSRuslan Ermilov.El 330c5922fbfSRuslan Ermilov.Sh SEE ALSO 331c5922fbfSRuslan Ermilov.Xr make 1 , 332c5922fbfSRuslan Ermilov.Xr make.conf 5 , 333c5922fbfSRuslan Ermilov.Xr build 7 , 334c5922fbfSRuslan Ermilov.Xr ports 7 335c5922fbfSRuslan Ermilov.Sh HISTORY 336c5922fbfSRuslan ErmilovThe 337c5922fbfSRuslan Ermilov.Nm 338c5922fbfSRuslan Ermilovfile appeared in 339c5922fbfSRuslan Ermilov.Fx 7.0 . 340c5922fbfSRuslan Ermilov.Sh AUTHORS 341fd4f2cd5SEnji CooperThis manual page was autogenerated by 342cbc5a508SEnji Cooper.An tools/build/options/makeman . 343c5922fbfSRuslan ErmilovEOF 344c5922fbfSRuslan Ermilov} 345c5922fbfSRuslan Ermilov 346e6a714e7SRuslan Ermilovtwiddle_pos=0 347e6a714e7SRuslan Ermilovtwiddle() 348e6a714e7SRuslan Ermilov{ 349e6a714e7SRuslan Ermilov local c0='|' c1='/' c2='-' c3='\' 350e6a714e7SRuslan Ermilov 351e6a714e7SRuslan Ermilov eval printf '%c\\b' '$c'${twiddle_pos} 352e6a714e7SRuslan Ermilov twiddle_pos=$(((twiddle_pos+1)%4)) 353e6a714e7SRuslan Ermilov} 354e6a714e7SRuslan Ermilov 355c5922fbfSRuslan Ermilovmain 356