]> diplodocus.org Git - nmh/blobdiff - build_nmh
Update XOAUTH2 documentation.
[nmh] / build_nmh
index dfb1c0bd83161a43e312d249176f70f375a0f427..ef6037c10b8156c17f88e6bcbd57b15db7e244a6 100755 (executable)
--- a/build_nmh
+++ b/build_nmh
@@ -33,7 +33,7 @@
 #     -l <logfile name>, default 'build_nmh.log', - for stdout/stderr
 #   Advanced/developer use:
 #     -c to run 'make distcheck' instead of 'make check'
-#     -d to build nmh with asserts enabled and optimization disabled
+#     -d to build nmh with optimization disabled
 #     -s to use 'make superclean': requires recent autoconf and automake,
 #        see docs/README.developers
 #     -r to build rpm
@@ -48,7 +48,7 @@ logfile=build_nmh.log
 usage="usage:
   [-b <branch>, only if downloading]
   [-c to run 'make distcheck' instead of 'make check']
-  [-d to build nmh with asserts enabled and optimization disabled]
+  [-d to build nmh with optimization disabled]
   [-i to install nmh]
   [-l <logfile name>, default '$logfile']
   [-r to build rpm]
@@ -122,7 +122,7 @@ download_sources() {
     [ "$verbose" -eq 0 ]  &&  git_opts=--quiet
     [ "$branch" = master ]  ||
       git_opts="${git_opts:+$git_opts }--branch $branch"
-    if "$gitdir"/git clone --depth 1 $git_opts "git://$gitrepo/nmh.git" >&3
+    if "$gitdir"/git clone $git_opts "git://$gitrepo/nmh.git" >&3
     then
       directory=nmh
       cd "$directory"  ||  die "failed to clone $directory"
@@ -214,8 +214,7 @@ else
 fi
 
 ####
-#### Set up configure options.  Handle options that can have embedded
-#### spaces (currently just smtpservers) specially.
+#### Set up configure options.
 ####
 
 #### Here are the config options that we will try to detect, then
@@ -223,7 +222,7 @@ fi
 config_prefix=/usr/local/nmh
 config_locking=
 config_mts=smtp
-config_smtpservers=localhost
+config_smtpserver=localhost
 config_sasl='determined by configure'
 config_tls='determined by configure'
 config_debug=n
@@ -253,13 +252,12 @@ if install-mh -check >/dev/null 2>&1; then
 
     mtsconfservers=`grep '^servers:' "$mtsconf"`
     if [ "$mtsconfservers" ]; then
-      servers=`echo "$mtsconfservers" | \
-               sed -e 's/^servers: *//' -e 's/ /\\\ /g'`
-      [ "$servers" ]  &&  config_smtpservers="$servers"
+      servers=`echo "$mtsconfservers" | sed -e 's/^servers: *//'`
+      [ "$servers" ]  &&  config_smtpserver="$servers"
     fi
   fi
 
-  if test -x "$mhbin/mhparam"; then
+  if test $yes -eq 1  -a  -x "$mhbin/mhparam"; then
     if mhparam sasl >/dev/null; then
       case `$mhbin/mhparam sasl` in
         *sasl*) config_sasl=y ;;
@@ -295,10 +293,9 @@ if [ $yes -eq 0 ]; then
   [ "$mts" ]  &&  config_mts="$mts"
 
   if [ "$config_mts" = smtp ]; then
-    printf 'SMTP server(s), space separated [%s]: ' $config_smtpservers >&3
-    read response
-    servers=`echo $response | sed -e 's/ /\\\ /g'`
-    [ "$servers" ]  &&  config_smtpservers="$servers"
+    printf 'SMTP server [%s]: ' $config_smtpserver >&3
+    read server
+    [ "$server" ]  &&  config_smtpserver="$servers"
   fi
 
   printf 'Cyrus SASL support (y|n) [%s]: ' "$config_sasl" >&3
@@ -310,18 +307,24 @@ if [ $yes -eq 0 ]; then
   [ "$response" = y  -o  "$response" = Y ]  &&  config_tls=y
 fi
 
-smtpservers=
 config_opts="--prefix=$config_prefix"
 
 [ "$config_locking" ]  &&
   config_opts="$config_opts --with-locking=$config_locking"
 [ "$config_mts"  -a  "$config_mts" != smtp ]  &&
   config_opts="$config_opts --with-mts=$config_mts"
-[ "$config_smtpservers"  -a  "$config_smtpservers" != localhost ]  &&
-  smtpservers="--with-smtpservers=$config_smtpservers"
-[ "$config_sasl" = y ]  &&  config_opts="$config_opts --with-cyrus-sasl"
-[ "$config_tls" = y ]  &&  config_opts="$config_opts --with-tls"
-[ $config_debug = y ]  &&  config_opts="$config_opts --enable-assert"
+[ "$config_smtpserver"  -a  "$config_smtpserver" != localhost ]  &&
+  config_opts="$config_opts --with-smtpserver=$config_smtpserver"
+if [ "$config_sasl" = y ]; then
+    config_opts="$config_opts --with-cyrus-sasl"
+elif [ "$config_sasl" != 'determined by configure' ]; then
+    config_opts="$config_opts --with-cyrus-sasl=no"
+fi
+if [ "$config_tls" = y ]; then
+    config_opts="$config_opts --with-tls"
+elif [ "$config_tls" != 'determined by configure' ]; then
+    config_opts="$config_opts --with-tls=no"
+fi
 
 #### dotlocking, the usual default, requires chgrp and chmod of inc.
 installpriv=
@@ -367,18 +370,26 @@ if [ -z "$CFLAGS" ]; then
   #### Only use these flags with gcc.
   if cc -dM -E - </dev/null 2>&1 | grep __GNUC__ >/dev/null; then
     #### configure will supply -g -O2 with gcc, but only if CFLAGS
-    #### isn't defined.
-    CFLAGS='-g -ansi -pedantic'
+    #### isn't defined.  Always add -g here.
+    #### Try all this, borrowed from Fedora 32 build.
+    CFLAGS="-g -std=c99 -pedantic -Wall -Werror=format-security \
+-Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong \
+-grecord-gcc-switches -fasynchronous-unwind-tables \
+-fstack-clash-protection -fcf-protection"
+    if ! cc -x c -c $CFLAGS /dev/null -o /dev/null 2>/dev/null; then
+        #### All that wasn't supported.  The following should be.
+        CFLAGS='-g -std=c99 -pedantic'
+    fi
     if [ "$config_debug" = n ]; then
-      CFLAGS="$CFLAGS -O2"
+      CFLAGS="$CFLAGS -O2 -Wp,-D_FORTIFY_SOURCE=2"
     else
       CFLAGS="$CFLAGS -O0"
     fi
   fi
 fi
 
-printf '\n./configure %s\n' "$config_opts${smtpservers:+ $smtpservers}"
-./configure CFLAGS="${CFLAGS}" $config_opts${smtpservers:+" $smtpservers"}
+printf "\n./configure $config_opts${CFLAGS:+ CFLAGS=\"${CFLAGS}\"}\n"
+./configure $config_opts ${CFLAGS:+CFLAGS="${CFLAGS}"}
 status=$?
 
 if [ $status -eq 0 ]; then