xref: /freebsd/tools/build/options/makeman (revision cae68bef117ef7af964af88470e62b2fcb34ed43)
1c5922fbfSRuslan Ermilov#!/bin/sh
2c5922fbfSRuslan Ermilov#
3c5922fbfSRuslan Ermilov# This file is in the public domain.
4c5922fbfSRuslan Ermilov
52701a1b7SRuslan Ermilovset -o errexit
62701a1b7SRuslan Ermilov
7c5922fbfSRuslan Ermilovident='$FreeBSD$'
8c5922fbfSRuslan Ermilov
92701a1b7SRuslan Ermilovt=$(mktemp -d -t makeman)
102701a1b7SRuslan Ermilovtrap 'test -d $t && rm -rf $t' exit
112701a1b7SRuslan Ermilov
12c5922fbfSRuslan Ermilov#
132701a1b7SRuslan Ermilov# usage: no_targets all_targets yes_targets
142701a1b7SRuslan Ermilov#
152701a1b7SRuslan Ermilovno_targets()
162701a1b7SRuslan Ermilov{
172701a1b7SRuslan Ermilov	for t1 in $1 ; do
182701a1b7SRuslan Ermilov		for t2 in $2 ; do
192701a1b7SRuslan Ermilov			if [ "${t1}" = "${t2}" ] ; then
202701a1b7SRuslan Ermilov				continue 2
212701a1b7SRuslan Ermilov			fi
222701a1b7SRuslan Ermilov		done
232701a1b7SRuslan Ermilov		echo ${t1}
242701a1b7SRuslan Ermilov	done
252701a1b7SRuslan Ermilov}
262701a1b7SRuslan Ermilov
272701a1b7SRuslan Ermilovshow_options()
282701a1b7SRuslan Ermilov{
292701a1b7SRuslan Ermilov	ALL_TARGETS=$(echo $(make -C ../../.. targets | tail -n +2))
302701a1b7SRuslan Ermilov	rm -f $t/settings
312701a1b7SRuslan Ermilov	for target in ${ALL_TARGETS} ; do
322701a1b7SRuslan Ermilov		make -C ../../.. showconfig \
332701a1b7SRuslan Ermilov		    SRCCONF=/dev/null __MAKE_CONF=/dev/null \
342701a1b7SRuslan Ermilov		    TARGET_ARCH=${target#*/} TARGET=${target%/*} |
352701a1b7SRuslan Ermilov		while read var _ val ; do
362701a1b7SRuslan Ermilov			opt=${var#MK_}
372701a1b7SRuslan Ermilov			case ${val} in
382701a1b7SRuslan Ermilov			yes)
392701a1b7SRuslan Ermilov				echo ${opt} ${target}
402701a1b7SRuslan Ermilov				;;
412701a1b7SRuslan Ermilov			no)
422701a1b7SRuslan Ermilov				echo ${opt}
432701a1b7SRuslan Ermilov				;;
442701a1b7SRuslan Ermilov			*)
452701a1b7SRuslan Ermilov				echo 'make showconfig broken' >&2
462701a1b7SRuslan Ermilov				exit 1
472701a1b7SRuslan Ermilov				;;
482701a1b7SRuslan Ermilov			esac
492701a1b7SRuslan Ermilov		done > $t/settings.target
502701a1b7SRuslan Ermilov		if [ -r $t/settings ] ; then
512701a1b7SRuslan Ermilov			join -t\  $t/settings $t/settings.target > $t/settings.new
522701a1b7SRuslan Ermilov			mv $t/settings.new $t/settings
532701a1b7SRuslan Ermilov		else
542701a1b7SRuslan Ermilov			mv $t/settings.target $t/settings
552701a1b7SRuslan Ermilov		fi
562701a1b7SRuslan Ermilov	done
572701a1b7SRuslan Ermilov
582701a1b7SRuslan Ermilov	cat $t/settings | while read opt targets ; do
592701a1b7SRuslan Ermilov		if [ "${targets}" = "${ALL_TARGETS}" ] ; then
602701a1b7SRuslan Ermilov			echo "WITHOUT_${opt}"
612701a1b7SRuslan Ermilov		elif [ -z "${targets}" ] ; then
622701a1b7SRuslan Ermilov			echo "WITH_${opt}"
632701a1b7SRuslan Ermilov		else
642701a1b7SRuslan Ermilov			echo "WITHOUT_${opt}" $(no_targets "${ALL_TARGETS}" "${targets}")
652701a1b7SRuslan Ermilov			echo "WITH_${opt} ${targets}"
662701a1b7SRuslan Ermilov		fi
672701a1b7SRuslan Ermilov	done
682701a1b7SRuslan Ermilov}
692701a1b7SRuslan Ermilov
702701a1b7SRuslan Ermilov#
712701a1b7SRuslan Ermilov# usage: show { settings | with | without } ...
72c5922fbfSRuslan Ermilov#
73c5922fbfSRuslan Ermilovshow()
74c5922fbfSRuslan Ermilov{
75c5922fbfSRuslan Ermilov
76c5922fbfSRuslan Ermilov	mode=$1 ; shift
77c5922fbfSRuslan Ermilov	case ${mode} in
78c5922fbfSRuslan Ermilov	settings)
79c5922fbfSRuslan Ermilov		yes_prefix=WITH
80c5922fbfSRuslan Ermilov		no_prefix=WITHOUT
81c5922fbfSRuslan Ermilov		;;
822701a1b7SRuslan Ermilov	with)
832701a1b7SRuslan Ermilov		yes_prefix=WITH
84c5922fbfSRuslan Ermilov		no_prefix=WITH
85c5922fbfSRuslan Ermilov		;;
862701a1b7SRuslan Ermilov	without)
872701a1b7SRuslan Ermilov		yes_prefix=WITHOUT
882701a1b7SRuslan Ermilov		no_prefix=WITHOUT
892701a1b7SRuslan Ermilov		;;
90c5922fbfSRuslan Ermilov	*)
912701a1b7SRuslan Ermilov		echo 'internal error' >&2
92c5922fbfSRuslan Ermilov		exit 1
93c5922fbfSRuslan Ermilov		;;
94c5922fbfSRuslan Ermilov	esac
952701a1b7SRuslan Ermilov	make -C ../../.. "$@" showconfig __MAKE_CONF=/dev/null |
96c5922fbfSRuslan Ermilov	while read var _ val ; do
97c5922fbfSRuslan Ermilov		opt=${var#MK_}
98c5922fbfSRuslan Ermilov		case ${val} in
99c5922fbfSRuslan Ermilov		yes)
100c5922fbfSRuslan Ermilov			echo ${yes_prefix}_${opt}
101c5922fbfSRuslan Ermilov			;;
102c5922fbfSRuslan Ermilov		no)
103c5922fbfSRuslan Ermilov			echo ${no_prefix}_${opt}
104c5922fbfSRuslan Ermilov			;;
105c5922fbfSRuslan Ermilov		*)
1062701a1b7SRuslan Ermilov			echo 'make showconfig broken' >&2
107c5922fbfSRuslan Ermilov			exit 1
108c5922fbfSRuslan Ermilov			;;
109c5922fbfSRuslan Ermilov		esac
110c5922fbfSRuslan Ermilov	done
111c5922fbfSRuslan Ermilov}
112c5922fbfSRuslan Ermilov
113c5922fbfSRuslan Ermilovmain()
114c5922fbfSRuslan Ermilov{
115c5922fbfSRuslan Ermilov
116c5922fbfSRuslan Ermilov	ident=${ident#$}
117c5922fbfSRuslan Ermilov	ident=${ident% $}
11841c8ddc3SRuslan Ermilov	fbsdid='$'FreeBSD'$'
119c5922fbfSRuslan Ermilov	cat <<EOF
120c5922fbfSRuslan Ermilov.\" DO NOT EDIT-- this file is automatically generated.
121c5922fbfSRuslan Ermilov.\" from ${ident}
122c5922fbfSRuslan Ermilov.\" ${fbsdid}
1232701a1b7SRuslan Ermilov.Dd $(echo $(LC_TIME=C date +'%B %e, %Y'))
124c5922fbfSRuslan Ermilov.Dt SRC.CONF 5
125c5922fbfSRuslan Ermilov.Os
126c5922fbfSRuslan Ermilov.Sh NAME
127c5922fbfSRuslan Ermilov.Nm src.conf
12857caf3d6STom Rhodes.Nd "source build options"
129c5922fbfSRuslan Ermilov.Sh DESCRIPTION
130c5922fbfSRuslan ErmilovThe
131c5922fbfSRuslan Ermilov.Nm
132c5922fbfSRuslan Ermilovfile contains settings that will apply to every build involving the
133c5922fbfSRuslan Ermilov.Fx
134c5922fbfSRuslan Ermilovsource tree; see
135c5922fbfSRuslan Ermilov.Xr build 7 .
136c5922fbfSRuslan Ermilov.Pp
137c5922fbfSRuslan ErmilovThe
138c5922fbfSRuslan Ermilov.Nm
139c5922fbfSRuslan Ermilovfile uses the standard makefile syntax.
140c5922fbfSRuslan ErmilovHowever,
141c5922fbfSRuslan Ermilov.Nm
142c5922fbfSRuslan Ermilovshould not specify any dependencies to
143c5922fbfSRuslan Ermilov.Xr make 1 .
144c5922fbfSRuslan ErmilovInstead,
145c5922fbfSRuslan Ermilov.Nm
146c5922fbfSRuslan Ermilovis to set
147c5922fbfSRuslan Ermilov.Xr make 1
148c5922fbfSRuslan Ermilovvariables that control the aspects of how the system builds.
149c5922fbfSRuslan Ermilov.Pp
150c5922fbfSRuslan ErmilovThe default location of
151c5922fbfSRuslan Ermilov.Nm
152c5922fbfSRuslan Ermilovis
153c5922fbfSRuslan Ermilov.Pa /etc/src.conf ,
154c5922fbfSRuslan Ermilovthough an alternative location can be specified in the
155c5922fbfSRuslan Ermilov.Xr make 1
156c5922fbfSRuslan Ermilovvariable
157c5922fbfSRuslan Ermilov.Va SRCCONF .
158c5922fbfSRuslan ErmilovOverriding the location of
159c5922fbfSRuslan Ermilov.Nm
160c5922fbfSRuslan Ermilovmay be necessary if the system-wide settings are not suitable
161c5922fbfSRuslan Ermilovfor a particular build.
162c5922fbfSRuslan ErmilovFor instance, setting
163c5922fbfSRuslan Ermilov.Va SRCCONF
164c5922fbfSRuslan Ermilovto
165c5922fbfSRuslan Ermilov.Pa /dev/null
166c5922fbfSRuslan Ermiloveffectively resets all build controls to their defaults.
167c5922fbfSRuslan Ermilov.Pp
168c5922fbfSRuslan ErmilovThe only purpose of
169c5922fbfSRuslan Ermilov.Nm
170c5922fbfSRuslan Ermilovis to control the compilation of the
171c5922fbfSRuslan Ermilov.Fx
17257caf3d6STom Rhodessource code, which is usually located in
173c5922fbfSRuslan Ermilov.Pa /usr/src .
174c5922fbfSRuslan ErmilovAs a rule, the system administrator creates
175c5922fbfSRuslan Ermilov.Nm
176c5922fbfSRuslan Ermilovwhen the values of certain control variables need to be changed
177c5922fbfSRuslan Ermilovfrom their defaults.
178c5922fbfSRuslan Ermilov.Pp
179c5922fbfSRuslan ErmilovIn addition, control variables can be specified
180c5922fbfSRuslan Ermilovfor a particular build via the
181c5922fbfSRuslan Ermilov.Fl D
182c5922fbfSRuslan Ermilovoption of
183c5922fbfSRuslan Ermilov.Xr make 1
1843d919b75SMike Makonnenor in its environment; see
185c5922fbfSRuslan Ermilov.Xr environ 7 .
186c5922fbfSRuslan Ermilov.Pp
18707b7d7fbSTom RhodesThe values of variables are ignored regardless of their setting;
18857caf3d6STom Rhodeseven if they would be set to
189c5922fbfSRuslan Ermilov.Dq Li FALSE
190c5922fbfSRuslan Ermilovor
19157caf3d6STom Rhodes.Dq Li NO .
19257caf3d6STom RhodesJust the existence of an option will cause
19357caf3d6STom Rhodesit to be honoured by
19457caf3d6STom Rhodes.Xr make 1 .
195c5922fbfSRuslan Ermilov.Pp
196c5922fbfSRuslan ErmilovThe following list provides a name and short description for variables
197c5922fbfSRuslan Ermilovthat can be used for source builds.
198c5922fbfSRuslan Ermilov.Bl -tag -width indent
199c5922fbfSRuslan ErmilovEOF
2002701a1b7SRuslan Ermilov	show settings SRCCONF=/dev/null | sort > $t/config_default
2012701a1b7SRuslan Ermilov	show with SRCCONF=/dev/null | sort > $t/config_WITH_ALL
2022701a1b7SRuslan Ermilov	show without SRCCONF=/dev/null | sort > $t/config_WITHOUT_ALL
2032701a1b7SRuslan Ermilov
2042701a1b7SRuslan Ermilov	show_options |
2052701a1b7SRuslan Ermilov	while read opt targets ; do
2062701a1b7SRuslan Ermilov		if [ ! -f ${opt} ] ; then
2072701a1b7SRuslan Ermilov			echo "no description found for ${opt}, skipping" >&2
208c3b08cc6SYaroslav Tykhiy			continue
209*cae68befSRuslan Ermilov		fi
210*cae68befSRuslan Ermilov
2112701a1b7SRuslan Ermilov		echo ".It Va ${opt}"
2122701a1b7SRuslan Ermilov		sed -e's/\$\(FreeBSD: .*\) \$/from \1/' ${opt}
2132701a1b7SRuslan Ermilov		if [ -n "${targets}" ] ; then
2142701a1b7SRuslan Ermilov			echo '.Pp'
2152701a1b7SRuslan Ermilov			echo 'It is a default setting on'
2162701a1b7SRuslan Ermilov			echo $(echo ${targets} | sed -e's/ /, /g' -e's/\(.*\), /\1 and /').
217c5922fbfSRuslan Ermilov		fi
2182701a1b7SRuslan Ermilov
219*cae68befSRuslan Ermilov		if [ "${opt%%_*}" = 'WITHOUT' ] ; then
2202701a1b7SRuslan Ermilov			sed -n "/^WITH_${opt#WITHOUT_}$/!s/$/=/p" $t/config_WITH_ALL > $t/src.conf
2212701a1b7SRuslan Ermilov			show settings SRCCONF=$t/src.conf -D${opt} | sort > $t/config_WITH_ALL_${opt}
2222701a1b7SRuslan Ermilov			comm -13 $t/config_WITH_ALL $t/config_WITH_ALL_${opt} | sed -n "/^${opt}$/!p" > $t/deps
223*cae68befSRuslan Ermilov		elif [ "${opt%%_*}" = 'WITH' ] ; then
2242701a1b7SRuslan Ermilov			sed -n "/^WITHOUT${opt#WITH}$/!s/$/=/p" $t/config_WITHOUT_ALL > $t/src.conf
2252701a1b7SRuslan Ermilov			show settings SRCCONF=$t/src.conf -D${opt} | sort > $t/config_WITHOUT_ALL_${opt}
2262701a1b7SRuslan Ermilov			comm -13 $t/config_WITHOUT_ALL $t/config_WITHOUT_ALL_${opt} | sed -n "/^${opt}$/!p" > $t/deps
2272701a1b7SRuslan Ermilov		else
2282701a1b7SRuslan Ermilov			echo 'internal error' >&2
2292701a1b7SRuslan Ermilov			exit 1
2302701a1b7SRuslan Ermilov		fi
2312701a1b7SRuslan Ermilov
2322701a1b7SRuslan Ermilov		if [ -s $t/deps ] ; then
2332701a1b7SRuslan Ermilov			echo 'When set, it also enforces the following options:'
2342701a1b7SRuslan Ermilov			echo '.Pp'
2352701a1b7SRuslan Ermilov			echo '.Bl -item -compact'
2362701a1b7SRuslan Ermilov			cat $t/deps | while read opt2 ; do
2372701a1b7SRuslan Ermilov				echo '.It'
2382701a1b7SRuslan Ermilov				echo ".Va ${opt2}"
239c5922fbfSRuslan Ermilov			done
2402701a1b7SRuslan Ermilov			echo '.El'
2412701a1b7SRuslan Ermilov		fi
2422701a1b7SRuslan Ermilov
2432701a1b7SRuslan Ermilov		show settings SRCCONF=/dev/null -D${opt} | sort > $t/config_${opt}
2442701a1b7SRuslan Ermilov		comm -13 $t/config_default $t/config_${opt} | sed -n "/^${opt}$/!p" |
2452701a1b7SRuslan Ermilov		comm -13 $t/deps - > $t/deps2
2462701a1b7SRuslan Ermilov
2472701a1b7SRuslan Ermilov		if [ -s $t/deps2 ] ; then
2482701a1b7SRuslan Ermilov			if [ -s $t/deps ] ; then
2492701a1b7SRuslan Ermilov				echo '.Pp'
2502701a1b7SRuslan Ermilov			fi
2512701a1b7SRuslan Ermilov			echo 'When set, the following options are also in effect:'
2522701a1b7SRuslan Ermilov			echo '.Pp'
2532701a1b7SRuslan Ermilov			echo '.Bl -inset -compact'
2542701a1b7SRuslan Ermilov			cat $t/deps2 | while read opt2 ; do
2552701a1b7SRuslan Ermilov				echo ".It Va ${opt2}"
2562701a1b7SRuslan Ermilov				noopt=$(echo ${opt2} | sed -e's/WITH_/WITHOUT_/;t' -e's/WITHOUT_/WITH_/')
2572701a1b7SRuslan Ermilov				echo '(unless'
2582701a1b7SRuslan Ermilov				echo ".Va ${noopt}"
2592701a1b7SRuslan Ermilov				echo 'is set explicitly)'
2602701a1b7SRuslan Ermilov			done
2612701a1b7SRuslan Ermilov			echo '.El'
262c5922fbfSRuslan Ermilov		fi
263c5922fbfSRuslan Ermilov	done
264c5922fbfSRuslan Ermilov	cat <<EOF
265c5922fbfSRuslan Ermilov.El
266c5922fbfSRuslan Ermilov.Sh FILES
267c5922fbfSRuslan Ermilov.Bl -tag -compact
268c5922fbfSRuslan Ermilov.It Pa /etc/src.conf
269c5922fbfSRuslan Ermilov.It Pa /usr/share/mk/bsd.own.mk
270c5922fbfSRuslan Ermilov.El
271c5922fbfSRuslan Ermilov.Sh SEE ALSO
272c5922fbfSRuslan Ermilov.Xr make 1 ,
273c5922fbfSRuslan Ermilov.Xr make.conf 5 ,
274c5922fbfSRuslan Ermilov.Xr build 7 ,
275c5922fbfSRuslan Ermilov.Xr ports 7
276c5922fbfSRuslan Ermilov.Sh HISTORY
277c5922fbfSRuslan ErmilovThe
278c5922fbfSRuslan Ermilov.Nm
279c5922fbfSRuslan Ermilovfile appeared in
280c5922fbfSRuslan Ermilov.Fx 7.0 .
281c5922fbfSRuslan Ermilov.Sh AUTHORS
282c5922fbfSRuslan ErmilovThis manual page was autogenerated.
283c5922fbfSRuslan ErmilovEOF
284c5922fbfSRuslan Ermilov}
285c5922fbfSRuslan Ermilov
286c5922fbfSRuslan Ermilovmain
287