]> CyberLeo.Net >> Repos - FreeBSD/releng/10.3.git/blob - tools/build/options/makeman
- Copy stable/10@296371 to releng/10.3 in preparation for 10.3-RC1
[FreeBSD/releng/10.3.git] / tools / build / options / makeman
1 #!/bin/sh
2 #
3 # This file is in the public domain.
4
5 set -o errexit
6 LC_ALL=C
7
8 ident='$FreeBSD$'
9
10 t=$(mktemp -d -t makeman)
11 trap 'test -d $t && rm -rf $t' exit
12
13 srcdir=$(realpath ../../..)
14 make="make -C $srcdir -m $srcdir/share/mk"
15
16 #
17 # usage: no_targets all_targets yes_targets
18 #
19 no_targets()
20 {
21         for t1 in $1 ; do
22                 for t2 in $2 ; do
23                         if [ "${t1}" = "${t2}" ] ; then
24                                 continue 2
25                         fi
26                 done
27                 echo ${t1}
28         done
29 }
30
31 show_options()
32 {
33         ALL_TARGETS=$(echo $(${make} targets | tail -n +2))
34         rm -f $t/settings
35         for target in ${ALL_TARGETS} ; do
36                 env -i ${make} showconfig \
37                     SRCCONF=/dev/null __MAKE_CONF=/dev/null \
38                     TARGET_ARCH=${target#*/} TARGET=${target%/*} |
39                 while read var _ val ; do
40                         opt=${var#MK_}
41                         case ${val} in
42                         yes)
43                                 echo ${opt} ${target}
44                                 ;;
45                         no)
46                                 echo ${opt}
47                                 ;;
48                         *)
49                                 echo 'make showconfig broken' >&2
50                                 exit 1
51                                 ;;
52                         esac
53                 done > $t/settings.target
54                 if [ -r $t/settings ] ; then
55                         join -t\  $t/settings $t/settings.target > $t/settings.new
56                         mv $t/settings.new $t/settings
57                 else
58                         mv $t/settings.target $t/settings
59                 fi
60         done
61
62         while read opt targets ; do
63                 if [ "${targets}" = "${ALL_TARGETS}" ] ; then
64                         echo "WITHOUT_${opt}"
65                 elif [ -z "${targets}" ] ; then
66                         echo "WITH_${opt}"
67                 else
68                         echo "WITHOUT_${opt}" $(no_targets "${ALL_TARGETS}" "${targets}")
69                         echo "WITH_${opt} ${targets}"
70                 fi
71         done < $t/settings
72 }
73
74 #
75 # usage: show { settings | with | without } ...
76 #
77 show()
78 {
79
80         mode=$1 ; shift
81         case ${mode} in
82         settings)
83                 yes_prefix=WITH
84                 no_prefix=WITHOUT
85                 ;;
86         with)
87                 yes_prefix=WITH
88                 no_prefix=WITH
89                 ;;
90         without)
91                 yes_prefix=WITHOUT
92                 no_prefix=WITHOUT
93                 ;;
94         *)
95                 echo 'internal error' >&2
96                 exit 1
97                 ;;
98         esac
99         env -i ${make} "$@" showconfig __MAKE_CONF=/dev/null |
100         while read var _ val ; do
101                 opt=${var#MK_}
102                 case ${val} in
103                 yes)
104                         echo ${yes_prefix}_${opt}
105                         ;;
106                 no)
107                         echo ${no_prefix}_${opt}
108                         ;;
109                 *)
110                         echo 'make showconfig broken' >&2
111                         exit 1
112                         ;;
113                 esac
114         done
115 }
116
117 main()
118 {
119
120         ident=${ident#$}
121         ident=${ident% $}
122         fbsdid='$'FreeBSD'$'
123         cat <<EOF
124 .\" DO NOT EDIT-- this file is automatically generated.
125 .\" from ${ident}
126 .\" ${fbsdid}
127 .Dd $(echo $(LC_TIME=C date +'%B %e, %Y'))
128 .Dt SRC.CONF 5
129 .Os
130 .Sh NAME
131 .Nm src.conf
132 .Nd "source build options"
133 .Sh DESCRIPTION
134 The
135 .Nm
136 file contains settings that will apply to every build involving the
137 .Fx
138 source tree; see
139 .Xr build 7 .
140 .Pp
141 The
142 .Nm
143 file uses the standard makefile syntax.
144 However,
145 .Nm
146 should not specify any dependencies to
147 .Xr make 1 .
148 Instead,
149 .Nm
150 is to set
151 .Xr make 1
152 variables that control the aspects of how the system builds.
153 .Pp
154 The default location of
155 .Nm
156 is
157 .Pa /etc/src.conf ,
158 though an alternative location can be specified in the
159 .Xr make 1
160 variable
161 .Va SRCCONF .
162 Overriding the location of
163 .Nm
164 may be necessary if the system-wide settings are not suitable
165 for a particular build.
166 For instance, setting
167 .Va SRCCONF
168 to
169 .Pa /dev/null
170 effectively resets all build controls to their defaults.
171 .Pp
172 The only purpose of
173 .Nm
174 is to control the compilation of the
175 .Fx
176 source code, which is usually located in
177 .Pa /usr/src .
178 As a rule, the system administrator creates
179 .Nm
180 when the values of certain control variables need to be changed
181 from their defaults.
182 .Pp
183 In addition, control variables can be specified
184 for a particular build via the
185 .Fl D
186 option of
187 .Xr make 1
188 or in its environment; see
189 .Xr environ 7 .
190 .Pp
191 The values of variables are ignored regardless of their setting;
192 even if they would be set to
193 .Dq Li FALSE
194 or
195 .Dq Li NO .
196 Just the existence of an option will cause
197 it to be honoured by
198 .Xr make 1 .
199 .Pp
200 The following list provides a name and short description for variables
201 that can be used for source builds.
202 .Bl -tag -width indent
203 EOF
204         show settings SRCCONF=/dev/null | sort > $t/config_default
205         # Work around WITH_LDNS_UTILS forcing BIND_UTILS off by parsing the
206         # actual config that results from enabling every WITH_ option.  This
207         # can be reverted if/when we no longer have options that disable
208         # others.
209         show with SRCCONF=/dev/null | sort | sed 's/$/=/' > $t/src.conf
210         show settings SRCCONF=$t/src.conf | sort > $t/config_WITH_ALL
211         show without SRCCONF=/dev/null | sort > $t/config_WITHOUT_ALL
212
213         show_options |
214         while read opt targets ; do
215                 if [ ! -f ${opt} ] ; then
216                         echo "no description found for ${opt}, skipping" >&2
217                         continue
218                 fi
219
220                 echo ".It Va ${opt}"
221                 sed -e's/\$\(FreeBSD: .*\) \$/from \1/' ${opt}
222                 if [ -n "${targets}" ] ; then
223                         echo '.Pp'
224                         echo 'It is a default setting on'
225                         echo $(echo ${targets} | sed -e's/ /, /g' -e's/\(.*\), /\1 and /').
226                 fi
227
228                 if [ "${opt%%_*}" = 'WITHOUT' ] ; then
229                         sed -n "/^WITH_${opt#WITHOUT_}$/!s/$/=/p" $t/config_WITH_ALL > $t/src.conf
230                         show settings SRCCONF=$t/src.conf -D${opt} | sort > $t/config_WITH_ALL_${opt}
231                         comm -13 $t/config_WITH_ALL $t/config_WITH_ALL_${opt} | sed -n "/^${opt}$/!p" > $t/deps
232                 elif [ "${opt%%_*}" = 'WITH' ] ; then
233                         sed -n "/^WITHOUT${opt#WITH}$/!s/$/=/p" $t/config_WITHOUT_ALL > $t/src.conf
234                         show settings SRCCONF=$t/src.conf -D${opt} | sort > $t/config_WITHOUT_ALL_${opt}
235                         comm -13 $t/config_WITHOUT_ALL $t/config_WITHOUT_ALL_${opt} | sed -n "/^${opt}$/!p" > $t/deps
236                 else
237                         echo 'internal error' >&2
238                         exit 1
239                 fi
240
241                 show settings SRCCONF=/dev/null -D${opt} | sort > $t/config_${opt}
242                 comm -13 $t/config_default $t/config_${opt} | sed -n "/^${opt}$/!p" |
243                 comm -13 $t/deps - > $t/deps2
244
245                 # Work around BIND_UTILS=no being the default when every WITH_
246                 # option is enabled.
247                 if [ "$(cat $t/deps2)" = WITHOUT_BIND_UTILS ]; then
248                         sort $t/deps $t/deps2 > $t/_deps
249                         mv $t/_deps $t/deps
250                         :> $t/deps2
251                 fi
252
253                 havedeps=0
254                 if [ -s $t/deps ] ; then
255                         havedeps=1
256                         echo 'When set, it also enforces the following options:'
257                         echo '.Pp'
258                         echo '.Bl -item -compact'
259                         while read opt2 ; do
260                                 echo '.It'
261                                 echo ".Va ${opt2}"
262                         done < $t/deps
263                         echo '.El'
264                 fi
265
266                 if [ -s $t/deps2 ] ; then
267                         if [ ${havedeps} -eq 1 ] ; then
268                                 echo '.Pp'
269                         fi
270                         echo 'When set, the following options are also in effect:'
271                         echo '.Pp'
272                         echo '.Bl -inset -compact'
273                         while read opt2 ; do
274                                 echo ".It Va ${opt2}"
275                                 noopt=$(echo ${opt2} | sed -e's/WITH_/WITHOUT_/;t' -e's/WITHOUT_/WITH_/')
276                                 echo '(unless'
277                                 echo ".Va ${noopt}"
278                                 echo 'is set explicitly)'
279                         done < $t/deps2
280                         echo '.El'
281                 fi
282                 twiddle >&2
283         done
284         cat <<EOF
285 .El
286 .Sh FILES
287 .Bl -tag -compact -width Pa
288 .It Pa /etc/src.conf
289 .It Pa /usr/share/mk/bsd.own.mk
290 .El
291 .Sh SEE ALSO
292 .Xr make 1 ,
293 .Xr make.conf 5 ,
294 .Xr build 7 ,
295 .Xr ports 7
296 .Sh HISTORY
297 The
298 .Nm
299 file appeared in
300 .Fx 7.0 .
301 .Sh AUTHORS
302 This manual page was autogenerated.
303 EOF
304 }
305
306 twiddle_pos=0
307 twiddle()
308 {
309         local c0='|' c1='/' c2='-' c3='\'
310
311         eval printf '%c\\b' '$c'${twiddle_pos}
312         twiddle_pos=$(((twiddle_pos+1)%4))
313 }
314
315 main