3 # Configures and builds nmh.
4 # * This script must be invoked from an nmh source directory.
5 # * This script retrieves configuration from the first existing nmh
6 # installation on your $PATH, if any.
7 # * Unless the -y option is provided, this script then interactively
8 # walks you through confirmation of common configuration settings.
11 # The first time you invoke this script, use the -i option to install
12 # nmh in the specified location. The script will walk you through the
13 # common nmh configuration settings. The -v option will cause display
14 # of brief progress indicators. Be sure to add the bin directory of
15 # the install location to your $PATH, if not already there.
16 # Subsequently, invoke this script with the -y option, to use the
17 # relevant configuration settings from the installed nmh without
23 # -v to display progress
24 # Subsequent uses, assuming installed nmh bin directory is on $PATH:
25 # -y to accept all configuration options without confirmation
27 # -l <logfile name>, default 'build_nmh.log'
28 # Advanced/developer use:
29 # -c to run 'make distcheck' instead of 'make check'
30 # -d to build nmh with debug enabled
31 # -s to use 'make superclean': requires recent autoconf and automake,
32 # see docs/README.developers
35 # On Fedora, at least these rpms must be installed:
38 # cyrus-sasl-devel, if using sasl
39 # openssl-devel, if using TLS
40 # autoconf and automake, with -s (see docs/README.developers for versions)
45 #### Interpret command arguments.
56 [-c to run 'make distcheck' instead of 'make check']
57 [-d to build nmh with debug enabled]
59 [-l <logfile name>, default '$logfile']
61 [-s to use 'make superclean': requires recent autoconf and automake]
62 [-v to display progress]
63 [-y to accept all configuration options without confirmation]"
65 while getopts 'cdil:rsvy?' arg
; do
67 c
) check
=distcheck
;;
70 l
) logfile
=$OPTARG ;;
75 '?') echo "$usage"; exit 0 ;;
78 shift `expr $OPTIND - 1`
80 #### No command line arguments are supported.
86 #### Check to see that we're in a nmh source directory.
87 if grep 'the authors of nmh' COPYRIGHT
>/dev
/null
; then
90 echo "$0: not in nmh source directory"
95 #### Set up configure options. Handle options that can have embedded
96 #### spaces (currently just smtpservers) specially.
99 #### Here are the config options that we will try to detect, then
100 #### confirm, and finally set.
101 config_prefix
=/usr
/local
/nmh
104 config_smtpservers
=localhost
110 #### Find location of a program. Bourne shell just puts the name in
111 #### $0 if it's found from the PATH, so search that if necessary.
117 [ -f "${d:=.}/$1" -a -x "$d/$1" ] && printf %s
"$d" && break
123 if install-mh -check >/dev
/null
2>&1; then
124 # Determine config options from installed nmh.
125 mhbin
=`finddir install-mh`
127 config_prefix
=`cd $mhbin/.. && pwd`
129 mtsconf
=`dirname "$mhbin"`/etc
/mts.conf
130 if [ -f "$mtsconf" ]; then
131 mts_entry
=`grep '^mts:' "$mtsconf"`
132 if [ "$mts_entry" ]; then
133 mts
=`echo "$mts_entry" | sed -e 's/^mts: *//'`
134 if [ "$mts" -a "$mts" != smtp
]; then
139 mtsconfservers
=`grep '^servers:' "$mtsconf"`
140 if [ "$mtsconfservers" ]; then
141 servers
=`echo "$mtsconfservers" | \
142 sed -e 's/^servers: *//' -e 's/ /\\\ /g'`
143 [ "$servers" ] && config_smtpservers
="$servers"
147 if test -x "$mhbin/mhparam"; then
148 if mhparam sasl
>/dev
/null
; then
149 case `$mhbin/mhparam sasl` in
150 *sasl
*) config_sasl
=y
;;
153 case `$mhbin/mhparam tls` in
154 *tls
*) config_tls
=y
;;
157 echo "$0: -y not supported with currently installed nmh"
163 [ $debug -ge 1 ] && config_debug
=y
165 if [ $yes -eq 0 ]; then
166 #### Confirm each config setting with user.
167 printf 'Install prefix [%s]: ' $config_prefix
169 [ "$prefix" ] && config_prefix
="$prefix"
171 printf 'Locking type (dot|fcntl|flock|lockf) [determined by configure]: '
173 [ "$locking" ] && config_locking
="$locking"
175 printf 'MTS (smtp|sendmail/smtp|sendmail/pipe) [%s]: ' $config_mts
177 [ "$mts" ] && config_mts
="$mts"
179 if [ "$config_mts" = smtp
]; then
180 printf 'SMTP server(s), space separated [%s]: ' $config_smtpservers
182 servers
=`echo $response | sed -e 's/ /\\\ /g'`
183 [ "$servers" ] && config_smtpservers
="$servers"
186 printf 'Cyrus SASL support [%s]: ' $config_sasl
188 if [ "$response" = y
-o "$response" = Y
]; then
190 elif [ "$response" = n
-o "$response" = N
]; then
194 printf 'TLS support [%s]: ' $config_tls
196 if [ "$response" = y
-o "$response" = Y
]; then
198 elif [ "$response" = n
-o "$response" = N
]; then
202 #### Don't confirm debug here: obey the -d option to this script.
206 config_opts
="--prefix=$config_prefix"
208 [ "$config_locking" ] && \
209 config_opts
="$config_opts --with-locking=$config_locking"
210 [ "$config_mts" -a "$config_mts" != smtp
] && \
211 config_opts
="$config_opts --with-mts=$config_mts"
212 [ "$config_smtpservers" -a "$config_smtpservers" != localhost
] && \
213 smtpservers
="--with-smtpservers=$config_smtpservers"
214 [ "$config_sasl" = y
] && \
215 config_opts
="$config_opts --with-cyrus-sasl"
216 [ "$config_tls" = y
] && \
217 config_opts
="$config_opts --with-tls"
218 [ $config_debug = y
] && \
219 config_opts
="$config_opts --enable-debug"
222 #### dotlocking, the usual default, requires chgrp and chmod of inc.
224 if [ $install -ge 1 -a `id -u` -ne 0 ]; then
225 if [ "$config_locking" = dot
]; then
226 echo "$0: "'install requires chgrp and chmod 2755'
227 echo 'so will sudo to install. Terminate with Ctrl-C if unacceptable.'
234 #### Clean up, and set up with autoconfig if necessary.
236 if [ -f Makefile
]; then
237 [ $verbose -ge 1 ] && echo cleaning . . .
238 if [ $superclean -ge 1 ]; then
239 make superclean
>/dev
/null
241 make distclean
>/dev
/null
245 /bin
/rm -f "$logfile"
246 if [ -f configure
-a -f Makefile.
in ]; then
249 [ $verbose -ge 1 ] && echo autoconfiguring . . .
250 .
/autogen.sh
>>"$logfile" 2>&1
257 [ $verbose -ge 1 ] && echo configuring . . .
258 echo .
/configure
$config_opts ${smtpservers:+"$smtpservers"} >>"$logfile" 2>&1
259 .
/configure
$config_opts ${smtpservers:+"$smtpservers"} >>"$logfile" 2>&1
262 if [ $status -eq 0 ]; then
263 [ $verbose -ge 1 ] && echo building . . .
264 make >>"$logfile" 2>&1
267 if [ $status -eq 0 ]; then
268 if [ "$TESTS_SHELL"x
= x
]; then
269 #### Bonus: use heirloom shell to test, if available, and if
270 #### TESTS_SHELL hadn't already been set.
271 heirloom_shell
=/usr
/lib
/heirloom
/5bin
/sh
272 if [ -x "$heirloom_shell" ]; then
273 TESTS_SHELL
="$heirloom_shell"; export TESTS_SHELL
277 [ $verbose -ge 1 ] && echo testing . . .
278 checkoutput
=`make $check AM_COLOR_TESTS=always 2>>"$logfile"`
281 tests_summary
=`echo "$checkoutput" | grep tests`
282 #### If multiple tests not run, that line will be caught by the
283 #### "grep tests" above.
284 test_not_run
=`echo "$checkoutput" | grep 'test was not run'`
285 fails
=`echo "$checkoutput" | grep FAIL`
286 if [ "$tests_summary" ]; then
287 echo '===================' >>"$logfile"
288 [ "$test_not_run" ] && echo "$test_not_run" >>"$logfile"
289 [ "$fails" ] && echo "$fails" >>"$logfile"
290 echo "$tests_summary" >>"$logfile"
291 echo '===================' >>"$logfile"
292 [ "$check" = distcheck
] && \
293 echo "$checkoutput" | tail -n 4 >>"$logfile"
296 if [ $status -eq 0 ]; then
297 if [ $install -ge 1 ]; then
298 [ $verbose -ge 1 ] && echo installing . . .
299 ($installpriv make install) >/dev
/null
2>>"$logfile"
303 if [ $status -eq 0 -a $build_rpm -ge 1 ]; then
304 [ $verbose -ge 1 ] && echo building rpm . . .
305 make rpm
>/dev
/null
2>>"$logfile"
312 grep Error
"$logfile"
315 if [ $status -eq 0 ]; then
316 [ $verbose -ge 1 ] && echo build completed successfully
319 echo build log is
in "$logfile"