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, as well as any $EDITOR/$VISUAL
7 # and $PAGER environment variable settings.
8 # * Unless the -y option is provided, this script then interactively
9 # walks you through confirmation of common configuration settings.
12 # The first time you invoke this script, use the -i option to install
13 # nmh in the specified location. The script will walk you through the
14 # common nmh configuration settings. The -v option will cause display
15 # of brief progress indicators. Be sure to add the bin directory of
16 # the install location to your $PATH, if not already there.
17 # Subsequently, invoke this script with the -y option, to use the
18 # relevant configuration settings from the installed nmh without
24 # -v to display progress
25 # Subsequent uses, assuming installed nmh bin directory is on $PATH:
26 # -y to accept all configuration options without confirmation
28 # -l <logfile name>, default 'build_nmh.log'
29 # Advanced/developer use:
30 # -c to run 'make distcheck' instead of 'make check'
31 # -d to build nmh with debug enabled
32 # -s to use 'make superclean': requires recent autoconf and automake,
33 # see docs/README.developers
36 # On Fedora, at least these rpms must be installed:
39 # cyrus-sasl-devel, if using sasl
40 # openssl-devel, if using TLS
41 # autoconf and automake, with -s (see docs/README.developers for versions)
46 #### OS-specific setup.
52 #### Interpret command arguments.
63 [-c to run 'make distcheck' instead of 'make check']
64 [-d to build nmh with debug enabled]
66 [-l <logfile name>, default '$logfile']
68 [-s to use 'make superclean': requires recent autoconf and automake]
69 [-v to display progress]
70 [-y to accept all configuration options without confirmation]"
72 while getopts 'cdil:rsvy?' arg; do
74 c ) check=distcheck ;;
77 l ) logfile=$OPTARG ;;
82 '?') echo "$usage"; exit 0 ;;
85 shift `expr $OPTIND - 1`
87 #### No command line arguments are supported.
93 #### Check to see that we're in a nmh source directory.
94 if grep 'the authors of nmh' COPYRIGHT >/dev/null; then
97 echo "$0: not in nmh source directory"
102 #### Set up configure options. Handle options that can have embedded
103 #### spaces (currently just smtpservers) specially.
106 #### Here are the config options that we will try to detect, then
107 #### confirm, and finally set.
108 config_prefix=/usr/local/nmh
111 config_smtpservers=localhost
115 for i in more less most cat; do
116 if which $i >/dev/null 2>&1; then
123 if install-mh -check >/dev/null 2>&1; then
124 # Determine config options from installed nmh.
125 mhparam=`which mhparam`
126 mhbin=`dirname "$mhparam"`
128 config_prefix=`cd $mhbin/.. && pwd`
130 mtsconf=`dirname "$mhbin"`/etc/mts.conf
131 if [ -f "$mtsconf" ]; then
132 mts_entry=`grep '^mts:' $mtsconf`
133 if [ "$mts_entry" ]; then
134 mts=`echo $mts_entry | sed -e 's/^mts: *//'`
135 if [ "$mts" -a "$mts" != smtp ]; then
140 mtsconfservers=`grep '^servers:' $mtsconf`
141 if [ "$mtsconfservers" ]; then
142 servers=`echo $mtsconfservers | sed -e 's/^servers: *//' -e 's/ /\\\ /g'`
143 [ "$servers" ] && config_smtpservers="$servers"
147 if $ldd $mhbin/inc | grep sasl >/dev/null; then
151 if $ldd $mhbin/inc | grep ssl >/dev/null; then
156 if [ "$EDITOR" ]; then
157 config_editor="$EDITOR"
158 elif [ "$VISUAL" ]; then
159 config_editor="$VISUAL"
162 [ "$PAGER" ] && config_pager="$PAGER"
164 [ $debug -ge 1 ] && config_debug=y
166 if [ $yes -eq 0 ]; then
167 #### Confirm each config setting with user.
168 printf 'Install prefix [%s]: ' $config_prefix
170 [ "$prefix" ] && config_prefix="$prefix"
172 printf 'Locking type (dot|fcntl|flock|lockf) [determined by configure]: '
174 [ "$locking" ] && config_locking="$locking"
176 printf 'MTS (smtp|sendmail) [%s]: ' $config_mts
178 [ "$mts" ] && config_mts="$mts"
180 if [ "$config_mts" = smtp ]; then
181 printf 'SMTP server(s), space separated [%s]: ' $config_smtpservers
183 servers=`echo $response | sed -e 's/ /\\\ /g'`
184 [ "$servers" ] && config_smtpservers="$servers"
187 printf 'Cyrus SASL support [%s]: ' $config_sasl
189 if [ "$response" = y -o "$response" = Y ]; then
191 elif [ "$response" = n -o "$response" = N ]; then
195 printf 'TLS support [%s]: ' $config_tls
197 if [ "$response" = y -o "$response" = Y ]; then
199 elif [ "$response" = n -o "$response" = N ]; then
203 printf 'Default editor [%s]: ' $config_editor
205 [ "$editor" ] && config_editor=$editor
207 printf 'Pager [%s]: ' $config_pager
209 [ "$pager" ] && config_pager=$pager
211 #### Don't confirm debug here: obey the -d option to this script.
215 config_opts="--prefix=$config_prefix"
217 [ "$config_locking" ] && \
218 config_opts="$config_opts --with-locking=$config_locking"
219 [ "$config_mts" -a "$config_mts" != smtp ] && \
220 config_opts="$config_opts --with-mts=$config_mts"
221 [ "$config_smtpservers" -a "$config_smtpservers" != localhost ] && \
222 smtpservers="--with-smtpservers=$config_smtpservers"
223 [ "$config_sasl" = y ] && \
224 config_opts="$config_opts --with-cyrus-sasl"
225 [ "$config_tls" = y ] && \
226 config_opts="$config_opts --with-tls"
227 [ "$config_editor" ] && \
228 config_opts="$config_opts --with-editor=$config_editor"
229 [ "$config_pager" ] && \
230 config_opts="$config_opts --with-pager=$config_pager"
231 [ $config_debug = y ] && \
232 config_opts="$config_opts --enable-debug"
235 #### dotlocking, the usual default, requires chgrp and chmod of inc.
237 if [ $install -ge 1 -a `id -u` -ne 0 ]; then
238 if [ "$config_locking" = dot ]; then
239 echo "$0: "'install requires chgrp and chmod 2755'
240 echo 'so will sudo to install. Terminate with Ctrl-C if unacceptable.'
247 #### Clean up, and set up with autoconfig if necessary.
249 if [ -f Makefile ]; then
250 [ $verbose -ge 1 ] && echo cleaning . . .
251 if [ $superclean -ge 1 ]; then
252 make superclean >/dev/null
254 make distclean >/dev/null
259 if [ -f configure -a -f Makefile.in ]; then
262 [ $verbose -ge 1 ] && echo autoconfiguring . . .
263 ./autogen.sh >>$logfile 2>&1
270 [ $verbose -ge 1 ] && echo configuring . . .
271 echo ./configure $config_opts ${smtpservers:+"$smtpservers"} >>$logfile 2>&1
272 ./configure $config_opts ${smtpservers:+"$smtpservers"} >>$logfile 2>&1
275 if [ $status -eq 0 ]; then
276 [ $verbose -ge 1 ] && echo building . . .
280 if [ $status -eq 0 ]; then
281 [ $verbose -ge 1 ] && echo testing . . .
282 checkoutput=`make $check 2>>$logfile`
285 tests_summary=`echo "$checkoutput" | grep tests`
286 if [ "$tests_summary" ]; then
287 echo '===================' >>$logfile
288 echo $tests_summary >>$logfile
289 echo '===================' >>$logfile
290 [ "$check" = distcheck ] && \
291 echo "$checkoutput" | tail -n 4 >>$logfile
294 if [ $status -eq 0 ]; then
295 if [ $install -ge 1 ]; then
296 [ $verbose -ge 1 ] && echo installing . . .
297 ($installpriv make install) >/dev/null 2>>$logfile
301 if [ $status -eq 0 -a $build_rpm -ge 1 ]; then
302 [ $verbose -ge 1 ] && echo building rpm . . .
303 make rpm >/dev/null 2>>$logfile
310 grep 'Error' $logfile
312 if [ $status -ne 0 ]; then
314 echo build log is in $logfile
316 [ $status -eq 0 -a $verbose -ge 1 ] && echo build completed successfully