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