[mod.sources] v07i020: ELM Update Kit, Part03/03

sources-request@mirror.UUCP (09/03/86)

Submitted by: Dave Taylor <taylor@hplabs.HP.COM>
Mod.sources: Volume 7, Issue 20
Archive-name: elm_update/Part03

[  The shell scripts in this posting should be run on a clean copy of
   the ELM sources.  Then run the "Configure.sh" script now provided,
   to build the Makefiles, etc.  I suppose this is a good time to say
   that Dave said to ignore errors in unpacking Part 12 of the Volume
   6 ELM distribution.  -- r$  ]

#!/bin/sh
# This is a shell archive.  Remove anything before this line,
# then unpack it by saving it in a file and typing "sh file".

# Exit status; set to 1 on "wc" errors or if would overwrite.
STATUS=0
# Contents:  Edit3
 
echo x - Edit3
if test -f Edit3 ; then
    echo Edit3 exists, putting output in $$Edit3
    OUT=$$Edit3
    STATUS=1
else
    OUT=Edit3
fi
sed 's/^XX//' > $OUT <<'@//E*O*F Edit3//'
XX: Use /bin/sh

XX# This is the automatically generated output of the AUTODIFF program after
XX# being run on the two directories;
XX#	Old Directory: Elm-Posted
XX#	New Directory: Elm

XX# Any problems with execution of this script should be reported to the 
XX#     author of the program, Dave Taylor, at "hplabs!taylor".  Thanks

XX# first off, let's make sure we're running in SH

XXexport PATH || (sh $0; exit $$)

XX# next, let's ensure the user has "ed"...

XXif [ ! -f /bin/ed ]
XXthen
XX  echo I can\'t find /bin/ed\!
XX  exit 1
XXfi

XX# finally, let's get this show on the road!!

XX#---------------------------------
XX# File Elm/Configure.sh is new!

XXecho File Elm/Configure.sh is new - extracting...
XXif [ -f Configure.sh ]
XXthen
XX  echo File \'Configure.sh\' is new, but you already have something called that\!
XX  echo I\'m going to move your file to \'Configure.sh.old\'...
XX  /bin/mv -f Configure.sh Configure.sh.old
XXelse
XX  echo Extracting new file \'Configure.sh\'
XXfi

XXcat > Configure.sh << 'END_OF_FILE'
XX#!/bin/sh
XX#
XX# Configure.sh, a shell script for configuring the Elm mail system for
XX# 	your site and desires.  This script uses some ideas ripped out
XX#	of the 'rn' install script.  Thanks Larry!
XX#

XXexport PATH || (sh $0 ; kill $$)

XXSHELL=/bin/sh

XXSED1=/tmp/Elm.sed1
XXSED2=/tmp/Elm.sed2

XXif [ -f /bin/rm ]
XXthen
XX  rm=/bin/rm
XXelse
XX  rm=rm
XXfi

XX$rm -f $SED1 $SED2
XXtouch $SED1 $SED2
XXchmod 777 $SED1 $SED2

XX# first test - is stdin still free for answering questions??
XXif [ ! -t 0 ]
XXthen
XX  echo "Please use 'sh Configure.sh' rather than 'sh < Configure.sh'"
XX  exit 1
XXfi

XX# next let's see what sorta echo flag we have here...

XXif [ "`echo -n`" = "-n" ]
XXthen
XX  nflag=""
XX  cflag="\\c" 
XXelse
XX  nflag="-n"
XX  cflag=""
XXfi

XX# now the intro blurb

XXcat << END_OF_INTRO

XX       		    Elm Configuration Script, v2
XX       
XX      
XX    This is the configuration script for the Elm mail system.  By using
XX    it rather than editing the "hdrs/sysdefs.h" file, it is hoped that
XX    the installation process will be considerably easier.

XX    On all questions, the value in [square brackets] is the default that 
XX    will be used if you just press RETURN...


XXEND_OF_INTRO

XXecho "Trying to figure out what sort of OS you're on..."

XX# next interesting part - figure out what OS we're on

XXos_name=""

XX$rm -f .osname
XXtouch .osname

XXcat << 'EOF' > .get_osname

XXuname

XXif [ $? != 0 ] 
XXthen
XX  if [ -f /vmunix ]
XX  then
XX    echo "bsd" > .osname
XX  else
XX    exit 0
XX  fi
XXfi

XXif [ "`uname -s`" != "" ]
XXthen
XX   uname -s | tr '[A-Z]' '[a-z]' > .osname
XXfi

XXexit 0
XX 
XXEOF

XXsh .get_osname > /dev/null 2>&1

XXif [ -f .osname ] 
XXthen
XX  os_name="`cat .osname`"
XX  $rm -f .osname
XXfi

XX$rm -f .get_osname

XXif [ "$os_name" = "" ] 
XXthen
XX  cat << THE_END

XXI cannot figure out what sort of operating system you're running here.  Please
XXtype in the NAME of the OS you're running or the name of the machine you're
XXTHE_END

XX  echo $nflag "running on.  I'll check the name in a minute : " $cflag

XX  read junk morejunk
XX  
XX  os_name=`echo $junk | tr '[A-Z]' '[a-z]'`
XXfi

XXOS_FLAG="HUH??"

XXwhile [ "$OS_FLAG" = "HUH??" ]
XXdo

XX  case $os_name in
XX    hp)		NAME="HP-UX"; OS_FLAG=""		;;
XX    hp-ux) 	NAME="HP-UX"; OS_FLAG="";   		;;
XX    vax)	NAME="BSD"; OS_FLAG="BSD";  	;;
XX    vaxen)	NAME="BSD"; OS_FLAG="BSD";  	;;
XX    bsd)	NAME="BSD"; OS_FLAG="BSD";  	;;
XX    uts)	NAME="UTS"; OS_FLAG="UTS";  	;;
XX    sun)	NAME="Sun BSD"; OS_FLAG="SUN";		;;
XX    pyramid)	NAME="Pyramid BSD"; OS_FLAG="PYRAMID";	;;
XX    amdahl)	NAME="UTS"; OS_FLAG="UTS";  	;;
XX    v5)		NAME="System V"; OS_FLAG="";		;;
XX    v7)		NAME="System VII"; OS_FLAG="";		;;
XX    eunice)	NAME="Eunice"; OS_FLAG="";		;;
XX    convergent)	NAME="Convergent BSD"; OS_FLAG="BSD";		;;
XX    berkeley)	NAME="BSD"; OS_FLAG="BSD";		;;
XX    ultrix)	cat << THE_END

XXI know that this is a breed of Unix, but I don't know what TYPE of OS it
XXis like.  Please enter the NAME of the OS that this is most like (e.g. "BSD")
XXand we'll go from there.

XXTHE_END
XX					;;
XX    xenix)	cat << THE_END

XXYou're outta luck.  Xenix (dumb OS that it is only allows 6 character 
XXidentifier names.  You'll need to go in and LABORIOUSLY translate all the
XXVERY LONG identifier names to the right length.   The correct response to 
XXseeing this message is to call your vendor and get ANGRY!!!!

XXMeanwhile, we might as well just quit here.  Sorry.
XXTHE_END
XXexit 1
XX					;;
XX    *)		cat << THE_END

XXI don't know what OS you're specifying!  The only one's I know of are;

XX  HP-UX, BSD, UTS, Eunice, Xenix, Ultrix, V5, and V7

XXI also know the machines

XX  HP, Amdahl, Sun, Vaxen, Convergent and Pyramid

XXIf you're not among this list, you'll need to pick the closest OS name.  
XXTHE_END

XX    echo " "
XX    echo $nflag "Please choose again: " $cflag
XX    read os_name
XX    ;;
XX  esac

XXdone

XXecho " "
XXecho " "
XXecho you\'re on the following version of Unix: $NAME

XXcase $OS_FLAG in 
XX  BSD) echo "s/>os-define</-DBSD/" >> $SED2
XX       echo "s/>lib2</-lcurses/" >> $SED2
XX       ;;

XX  SUN) echo "s/>os-define</"-DBSD -DSUN"/" >> $SED2
XX       echo "s/>lib2</-lcurses/" >> $SED2
XX       ;;

XX  PYRAMID) echo "s/>os-define</"-DBSD -DNO_VAR_ARGS"/" >> $SED2
XX       echo "s/>lib2</-lcurses/" >> $SED2
XX       ;;

XX  *)   echo "s/>os-define<//"    >> $SED2
XX       echo "s/>lib2<//"         >> $SED2
XX       ;;

XXesac

XXecho " "
XXecho "Now we can get down to those questions..."
XXecho " "

XXcat << THE_END


XXDoes your site receive mail with valid "Reply-To:" and "From:" fields in
XXthe messages?  (usually the answer is "no" since not all sites on the network
XXrewrite the addresses, and this'll usually cause the return mail to fail).
XXTHE_END

XXanswer="no"
XXecho $nflag "Are the addresses valid (y/n) [no] ?" $cflag
XXread answer

XXif [ "$answer" != "y" -a "$answer" != "yes" ]
XXthen
XX  echo \
XX"s/#define USE_EMBEDDED_ADDRESSES/\/** #define USE_EMBEDDED_ADDRESSES **\//" \
XX  >> $SED1
XXfi

XXcat << THE_END

XX-------------------------------------------------------------------------------

XXHow about memory?  If you have a lot, you can enter a fairly large number
XXfor the next few questions...if not, you'll probably want to enter the
XXsuggested small-system values.  (This applies to the speed of the swapping
XXon your system too - if you're on a FAST system, use the big values!)

XXFirst, how many messages should be allowed in a single folder?  (the suggested
XXvalues are 1000 for blindly fast systems, 500 for average systems and 100 for
XXTHE_END

XXecho $nflag "slow systems).  Number of messages [500] ? " $cflag

XXmax_headers=NONE

XXwhile [ "$max_headers" = "NONE" ]
XXdo 
XX  read junk

XX  if [ "$junk" = "" ]
XX  then
XX    junk=500
XX  fi

XX  if [ $junk -gt 1000 -o $junk -lt 50 ] 
XX  then
XX    echo "I think a value of $junk is pretty strange.  You better answer this"
XX    echo "question again..."
XX    echo " "
XX    echo $nflag "How many messages per folder [500] ? " $cflag
XX    read junk
XX  else
XX    max_headers=$junk
XX    echo "s/>500</$max_headers/" >> $SED1
XX  fi
XX 
XX  if [ $junk -lt 200 ]
XX  then
XX    system_size="small"
XX  elif [ $junk -lt 750 ]
XX  then
XX    system_size="normal"
XX  else
XX    system_size="big"
XX  fi
XXdone

XXcase $system_size in
XX  small)  default=223;		;;
XX  normal) default=503;		;;
XX  big)    default=739;		;;
XXesac

XXecho " "

XXmax_saliases="NONE"

XXwhile [ "$max_saliases" = "NONE" ] 
XXdo 

XX  echo $nflag "Max number of system aliases available [$default] ? " $cflag

XX  read junk

XX  if [ "$junk" = "" ] 
XX  then
XX    junk=$default
XX  fi

XX  if [ $junk -lt 50 -o $junk -gt 1000 ] 
XX  then
XX    echo "Pretty far out value for this question!  I think you should reconsider"
XX    echo "your answer and try this question again..."
XX    echo " "
XX  else
XX    max_saliases=$junk
XX    echo "s/>503</$max_saliases/" >> $SED1
XX  fi
XXdone

XXcase $system_size in 
XX  small) 	default=127;		;;
XX  normal)	default=251;		;;
XX  big)		default=503;		;;
XXesac

XXmax_ualiases="NONE"

XXwhile [ "$max_ualiases" = "NONE" ] 
XXdo 

XX  echo $nflag "Max number of user aliases available   [$default] ? " $cflag

XX  read junk

XX  if [ "$junk" = "" ] 
XX  then
XX   junk=$default
XX  fi

XX  if [ $junk -lt 50 -o $junk -gt 1000 ] 
XX  then
XX    echo "Pretty far out value for this question!  I think you should reconsider"
XX    echo "your answer and try this question again..."
XX    echo " "
XX  else
XX    max_ualiases=$junk
XX    echo "s/>251</$max_ualiases/" >> $SED1
XX  fi
XXdone

XXcase $system_size in 
XX  small) 	default=50;		;;
XX  normal)	default=150;		;;
XX  big)		default=150;		;;
XXesac

XXmax_in_weedlist="NONE"

XXwhile [ "$max_in_weedlist" = "NONE" ] 
XXdo 

XX  echo $nflag "Max number of headers in weedout list  [$default] ? " $cflag

XX  read junk

XX  if [ "$junk" = "" ] 
XX  then
XX    junk=$default
XX  fi

XX  if [ $junk -lt 10 -o $junk -gt 200 ] 
XX  then
XX    echo "Pretty strange answer to this question!  I think you should reconsider"
XX    echo "and try this question again..."
XX    echo " "
XX  else
XX    max_in_weedlist=$junk
XX    echo "s/>150</$max_in_weedlist/" >> $SED1
XX  fi
XXdone

XXcat << THE_END

XXThe next pair of questions have to do with what to do when another program has 
XXlocked a mailbox...

XXFirst, how many times should the program check for the removal of the lock
XXTHE_END

XXdefault=6

XXmax_attempts="NONE"

XXwhile [ "$max_attempts" = "NONE" ] 
XXdo 

XX  echo $nflag "file before giving up? [6] " $cflag

XX  read junk

XX  if [ "$junk" = "" ] 
XX  then
XX   junk=$default
XX  fi

XX  if [ $junk -lt 3 -o $junk -gt 10 ] 
XX  then
XX    echo \
XX"The recommended range is 3-10   ...Number of times to check lock"
XX  else
XX    max_attempts=$junk
XX    echo "s/>6</$max_attempts/" >> $SED1
XX  fi
XXdone

XXecho " "
XXanswer="no"
XXecho $nflag "Should it REMOVE the lockfile after $max_attempts checks [no] ?" \
XX     $cflag
XXread answer

XXif [ "$answer" != "y" -a "$answer" != "yes" ]
XXthen
XX  echo \
XX"s/#define REMOVE_AT_LAST/\/** #define REMOVE_AT_LAST **\//" \
XX  >> $SED1
XXfi

XXif [ "$NAME" = "BSD" ]
XXthen 
XX  ps="ps -cax"
XXelse
XX  ps="ps -ef"
XXfi

XXecho " "
XXecho " "
XXecho "poking about a bit.."

XXif [ "`$ps | grep sendmail | grep -v grep`" != "" ]
XXthen
XX  echo "You're running sendmail.  Well done, I guess..."
XX  echo "s/\/\*\* #define DONT_ADD_FROM \*\*\//#define DONT_ADD_FROM/" \
XX    >> $SED1
XX    echo \
XX "s/#define USE_DOMAIN/\/** #define USE_DOMAIN **\//" \
XX    >> $SED1
XXelse

XX  cat << THE_END

XXSince you're not running sendmail, should I check local user entered addresses
XXTHE_END

XXanswer="yes"
XXecho $nflag "against the valid mailboxes on this system [yes] ? " $cflag
XXread answer

XXif [ "$answer" != "y" -a "$answer" != "yes" -a "$answer" != "" ]
XXthen
XX  echo \
XX"s/#define NOCHECK_VALIDNAME/\/** #define NOCHECK_VALIDNAME **\//" \
XX  >> $SED1
XXfi

XXcat << THE_END

XXAre you running a machine where you want to have a domain name appended to the
XXTHE_END

XXanswer="yes"
XXecho $nflag "hostname on outbound mail [no] ? " $cflag
XXread answer

XXif [ "$answer" != "y" -a "$answer" != "yes" ]
XXthen
XX    echo \
XX "s/#define USE_DOMAIN/\/** #define USE_DOMAIN **\//" \
XX    >> $SED1
XXelse
XX  echo " "
XX  echo $nflag "Enter the domain name (include leading '.') : " $cflag
XX  read answer
XX  echo "s/<enter your domain here>/$answer/" >> $SED1
XXfi

XXfi

XX# next let's see if we can find the vfork command on this system..

XXcat << EOF > .test.c
XXmain()
XX{
XX	(void) vfork();
XX}
XXEOF

XXcat << EOF > .vfork
XXcc .test.c
XXEOF

XXsh .vfork > .log 2>& 1

XXif [ "`wc -l .log`" -eq "0" ]
XXthen
XX  echo "You have virtual memory system calls available.  Cool..."
XXelse
XX  cat << THE_END

XXYour machine doesn't seem to have the vfork command available.  Should I assume
XXTHE_END

XX  answer="no"
XX  echo $nflag "you have it, anyway [no] ? " $cflag
XX  read answer

XXif [ "$answer" != "y" -a "$answer" != "yes" ]
XX  then
XX    echo "s/\/\*\* #define NO_VM \*\*\//#define NO_VM/" >> $SED1
XX  fi
XXfi

XX$rm -f a.out .test.c .vfork .log

XX# next let's see if we have the gethostname() system call...

XXcat << EOF > .test.c
XXmain()
XX{
XX	(void) gethostname();
XX}
XXEOF

XXcat << EOF > .hostname
XXcc .test.c
XXEOF

XXsh .hostname > .log 2>& 1

XXif [ "`wc -l .log`" -eq "0" ]
XXthen
XX  echo "You have the 'gethostname()' system call..."
XXelse
XX  echo "s/\/\*\* #define NEED_GETHOSTNAME \*\*\//#define NEED_GETHOSTNAME/" \
XX  >> $SED1
XXfi

XX$rm -f a.out .test.c .hostname .log

XX# next let's see if we have long variable names...

XXcat << EOF > .test.c
XXmain()
XX{
XX	int this_is_a_long_variable;

XX	(void) this_is_a_long_variable_routine_name();
XX	
XX}
XXthis_is_a_long_variable_routine_name() { }
XXEOF

XXcat << EOF > .varnames
XXcc .test.c
XXEOF

XXsh .varnames > .log 2>& 1

XXif [ "`wc -l .log`" -eq "0" ]
XXthen
XX  echo "You have long variable names.  Well done!!!!!"
XXelse
XX  echo "How embarassing.  Your C compiler doesn't support long variables..."
XX  echo "s/\/\*\* #define SHORTNAMES \*\*\//#define SHORTNAMES/" \
XX  >> $SED1
XXfi

XX$rm -f a.out .test.c .varname .log

XXcat << THE_END

XXWhen given a machine that you talk to directly, should the 'pathalias' route to
XXTHE_END

XXanswer="no"
XXecho $nflag "the machine be used instead [no] ? " $cflag
XXread answer

XXif [ "$answer" != "y" -a "$answer" != "yes" ]
XXthen
XX    echo \
XX "s/#define LOOK_CLOSE_AFTER_SEARCH/\/** #define LOOK_CLOSE_AFTER_SEARCH **\//" \
XX    >> $SED1
XXfi

XXanswer="yes"
XXecho " "
XXecho $nflag "Is the preferred address notation 'user@host' [yes] ?" $cflag
XXread answer

XXif [ "$answer" != "y" -a "$answer" != "yes" -a  "$answer" != "" ]
XXthen
XX    echo \
XX "s/#define INTERNET_ADDRESS_FORMAT/\/** #define INTERNET_ADDRESS_FORMAT **\//" \
XX    >> $SED1
XXfi

XXecho " "
XXanswer="yes"
XXecho $nflag "Am I going to be running as a setgid program [yes] ? "$cflag
XXread answer

XXif [ "$answer" != "y" -a "$answer" != "yes" -a "$answer" != "" ]
XXthen
XX  echo answer is currently equal to \"$answer\"
XX  echo \
XX "s/#define SAVE_GROUP_MAILBOX_ID/\/** #define SAVE_GROUP_MAILBOX_ID **\//" \
XX    >> $SED1
XXfi
XX    
XXcat << THE_END


XXFor any of the questions after this point, you can press RETURN if the 
XXquestions doesn't apply, or there's no reasonable answer...

XXTHE_END

XXif [ ! -f /usr/lib/nmail.paths ] 
XXthen
XX  echo $nflag "Where does the output of pathalias live ? " $cflag
XX  read answer

XX  if [ "$answer" != "" ]
XX  then
XX    echo "s^/usr/lib/nmail.paths^$answer^" >> $SED1
XX  fi
XXfi
XX 
XXif [ ! -f /usr/lib/domains ] 
XXthen
XX  echo $nflag "Where does the 'domains' file live ? " $cflag
XX  read answer

XX  if [ "$answer" != "" ]
XX  then
XX    echo "s^/usr/lib/domains^$answer^" >> $SED1
XX  fi
XXfi

XXif [ ! -f /usr/lib/uucp/L.sys ]
XXthen
XX  echo $nflag "Where does the 'L.sys' file live ? " $cflag
XX  read answer

XX  if [ "$answer" != "" ]
XX  then
XX    echo "s^/usr/lib/uucp/L.sys^$answer^" >> $SED1
XX  fi
XXfi
XX 
XXif [ ! -d /tmp ]
XXthen 
XX  echo $nflag "/tmp isn't a directory!  What should I use?? " $cflag
XX  read answer

XX  if [ "$answer" != "" ]
XX  then
XX    echo "s^/tmp^$answer^" >> $SED1
XX  fi
XXfi

XXif [ ! -f /usr/ucb/vi -a "$os_name" = "BSD" ]
XXthen
XX  echo $nflag "I can't find the 'vi' editor!  Where is it? " $cflag
XX  read answer

XX  if [ "$answer" != "" ]
XX  then
XX    echo "s^/usr/ucb/vi^$answer^" >> $SED1
XX  fi
XXelif [ ! -f /usr/bin/vi -a "$os_name" = "" ]
XXthen
XX  echo $nflag \
XX    "I can't find the 'vi' editor!  Where is it? " $cflag
XX  read answer

XX  if [ "$answer" != "" ]
XX  then
XX    echo "s^/usr/bin/vi^$answer^" >> $SED1
XX  fi
XXfi

XXif [ ! -d /usr/spool/mail -a "$os_name" = "BSD" ]
XXthen
XX  echo $nflag "I can't find your inbound mail directory!  Where is it? " $cflag
XX  read answer

XX  if [ "$answer" != "" ]
XX  then
XX    echo "s^/usr/spool/mail^$answer^" >> $SED1
XX  fi
XXelif [ ! -d /usr/mail -a "$os_name" = "" ]
XXthen
XX  echo $nflag "I can't find your inbound mail directory!  Where is it? " $cflag
XX  read answer

XX  if [ "$answer" != "" ]
XX  then
XX    echo "s^/usr/mail^$answer^" >> $SED1
XX  fi
XXfi

XXif [ ! -f /bin/rm ]
XXthen
XX  echo $nflag "Where's the 'rm' program? " $cflag
XX  read answer

XX  if [ "$answer" != "" ]
XX  then
XX    echo "s^/bin/rm^$answer^" >> $SED1
XX  fi
XXfi

XXif [ ! -f /bin/cat ]
XXthen
XX  echo $nflag "Where's the 'cat' program? " $cflag
XX  read answer

XX  if [ "$answer" != "" ]
XX  then
XX    echo "s^/bin/rm^$answer^" >> $SED1
XX  fi
XXfi
XX 
XXif [ ! -f /dev/rct ]
XXthen
XX  if [ ! -f /dev/rmt ]
XX  then
XX    echo $nflag "What's the name of your remote-tape unit? " $cflag
XX    read answer

XX    if [ "$answer" = "" ]
XX    then
XX      echo "s^>tapeunit<^unknown-remote-tape-unit^" >> $SED2
XX    else
XX      if [ ! -f $answer ] 
XX      then
XX	if [ -f /dev/$answer ]
XX	then
XX          echo "s^>tapeunit<^/dev/$answer^" >> $SED2
XX        else
XX          echo \
XX           "I can't find either $answer or /dev/$answer.  I'll set it to junk" 
XX          echo "s^>tapeunit<^unknown-remote-tape-unit^" >> $SED2
XX        fi
XX      else
XX        echo "s^>tapeunit<^$answer^" >> $SED2
XX      fi
XX    fi
XX  else
XX    echo "s^>tapeunit<^/dev/rmt^" >> $SED2
XX  fi
XXelse
XX  echo "s^>tapeunit<^/dev/rct^" >> $SED2
XXfi

XXif [ ! -d /usr/local/bin ]
XXthen
XX  echo $nflag "Where do you want the system software installed? " $cflag
XX  read answer

XX  if [ "$answer" = "" ]
XX  then
XX    echo "s^>dest-dir<^unknown-destination-directory^" >> $SED2
XX  else
XX    if [ -d $answer ]
XX    then
XX      echo "s^>dest-dir<^$answer^" >> $SED2
XX    else
XX      echo "I don't know what you're talking about.  I'll set it to junk" 
XX      echo "s^>dest-dir<^unknown-destination-directory^" >> $SED2
XX    fi
XX  fi
XXelse
XX  echo "s^>dest-dir<^/usr/local/bin^" >> $SED2
XXfi

XXif [ ! -f /usr/bin/troff ]
XXthen
XX  if [ ! -f /usr/local/bin/troff ]
XX  then
XX    if [ ! -f /usr/contrib/bin/troff ]
XX    then
XX      if [ ! -f /usr/ucb/troff ]
XX      then
XX        if [ ! -f /bin/troff ]
XX        then
XX          echo $nflag "Where does the 'troff' program live? " $cflag
XX 	  read answer

XX	  if [ "$answer" = "" ]
XX	  then
XX            echo "s/>troff</nroff/" >> $SED2
XX	  else
XX            if [ -f $answer ]
XX	    then
XX              echo "s^>troff<^$answer^" >> $SED2
XX              troff=$answer
XX	    else
XX	      echo "Still can't find it.  I'll set it to \"nroff\" instead."
XX              echo "s/>troff</nroff/" >> $SED2
XX	    fi
XX	  fi
XX	else
XX          echo "s^>troff<^/bin/troff^" >> $SED2
XX          troff=/bin/troff
XX        fi
XX      else
XX        echo "s^>troff<^/usr/ucb/troff^" >> $SED2
XX        troff=/usr/ucb/troff
XX      fi
XX    else
XX      echo "s^>troff<^/usr/contrib/bin/troff^" >> $SED2
XX      troff=/usr/contribbin/troff
XX    fi
XX  else
XX    echo "s^>troff<^/usr/local/bin/troff^" >> $SED2
XX    troff=/usr/local/bin/troff
XX  fi
XXelse
XX  echo "s^>troff<^/usr/bin/troff^" >> $SED2
XX  troff=/usr/bin/troff
XXfi

XX# phew!

XXtroffdir=`dirname $troff`

XXif [ -f $troffdir/tbl ]
XXthen
XX  echo "s^>tbl<^$troffdir/tbl^" >> $SED2
XXelse
XX  echo $nflag "Where does the 'tbl' program live? " $cflag
XX  read answer

XX  if [ "$answer" = "" ]
XX  then
XX    echo "s^>tbl<^cat^" >> $SED2
XX  elif [ -f $answer ]
XX  then
XX    echo "s^>tbl<^$answer^" >> $SED2
XX  else
XX    echo "I can't find that either.  I'll just set it to junk..."
XX    echo "s^>tbl<^cat^" >> $SED2
XX  fi
XXfi

XXif [ -f /bin/cc ]
XXthen
XX  echo "s^>cc<^/bin/cc^" >> $SED2
XXelse
XX  echo $nflag "Where does the 'C' compiler live? " $cflag
XX  read answer

XX  if [ "$answer" = "" ]
XX  then
XX    cat << THE_END

XXI hope you realize that without a "C" compiler there's no point in doing any
XXof this.  If we can't compile anything then this is just so much disk filler.

XXIn fact, thinking about it, let's just quit right now.

XXTHE_END

XX    exit 1
XX  fi

XX  if [ -f $answer ]
XX  then
XX    echo "s^>cc<^$answer^" >> $SED2
XX  else
XX    cat << THE_END

XXI couldn't find what you specified, pal.  I hope you realize that without a 
XX"C" compiler there's no point in doing any of this.  If we can't compile 
XXanything then this system is just so much disk filler.

XXIn fact, thinking about it, let's just quit right now.

XXTHE_END
XX    exit 1
XX  fi
XXfi

XXecho "s^>rm<^$rm -f^" >> $SED2

XXif [ -f /bin/mv ]
XXthen
XX  echo "s^>mv<^/bin/mv -f^" >> $SED2
XXelse
XX  echo "s^>mv<^mv -f^" >> $SED2  
XXfi

XXif [ -f /bin/cp ]
XXthen
XX  echo "s^>cp<^/bin/cp^" >> $SED2
XXelse
XX  echo "s^>cp<^cp^" >> $SED2  
XXfi

XXcat << END

XXThat's it.  Just  have to do some patching up and such...hang loose for a 
XXminute or two, please...

XXEND

XX# process the three Makefiles accordingly...

XXecho "1 - processing the file \"Makefile\"..."
XXcat Makefile.mstr | sed -f $SED2 > Makefile

XXecho "2 - processing the file \"src/Makefile\"..."
XXcat src/Makefile.mstr | sed -f $SED2 > src/Makefile

XXecho "3 - processing the file \"utils/Makefile\"..."
XXcat utils/Makefile.mstr | sed -f $SED2 > utils/Makefile

XX# then filter the sysdefs file through the sed script we've created!

XXecho "Finally, processing the file \"hdrs/sysdefs.h\"..."

XXif [ -f hdrs/sysdefs.h ]
XXthen
XX  mv hdrs/sysdefs.h hdrs/sysdefs.old
XXfi

XXcat hdrs/sysdefs.master | sed -f $SED1 > hdrs/sysdefs.h

XXecho Done\!

XX$rm -f $SED1 $SED2
XXexit 0
XXEND_OF_FILE

XXchars=`cat Configure.sh | wc -c`

XXif [ $chars -ne 19263 ]
XXthen
XX  echo File damaged in transit...should be 19263 bytes, is $chars instead
XX  echo  I suggest you check it closely...
XXfi

XX#---------------------------------
XX# File Elm/Makefile.mstr is new!

XXecho File Elm/Makefile.mstr is new - extracting...
XXif [ -f Makefile.mstr ]
XXthen
XX  echo File \'Makefile.mstr\' is new, but you already have something called that\!
XX  echo I\'m going to move your file to \'Makefile.mstr.old\'...
XX  /bin/mv -f Makefile.mstr Makefile.mstr.old
XXelse
XX  echo Extracting new file \'Makefile.mstr\'
XXfi

XXcat > Makefile.mstr << 'END_OF_FILE'
XX#
XX#  Makefile for the entire ELM mail system
XX#
XX#         (C) Copyright 1986, Dave Taylor
XX#
XX#  Last modification: July 14th, 1986

XXSHELL=/bin/sh
XX 
XX#########################
XX#
XX# The following entries need to be customized for the local site:  
XX#    The first is the address of the data-cassette drive to allow
XX# easy tape copies to be made, and the second is the final location 
XX# that all the software should be installed in when 'make install'
XX# is run.
XX#
XX#########################

XXTAPE=   >tapeunit< 
XXDEST=   >dest-dir<

XXLIB=    /usr/local/lib
XXMAN=	/usr/man/man1
XXCATMAN= /usr/man/cat1
XXSHAR=   /usr/local/bin/shar -s 60000

XX# See the Configuration Guide for further information on this stuff;
XX#
XX# if on a Berkeley system:
XX#   DEFINE = -DBSD
XX#   LIB2   = -lcurses
XX# else if on a UTS system:
XX#   DEFINE = -DUTS
XX#   LIB2   = -la
XX# else if on a Sun system:
XX#   DEFINE = "-DBSD -DSUN"
XX#   LIB2   = -lcurses
XX# else if on a Pyramid system:
XX#   DEFINE = "-DBSD -DNO_VAR_ARGS"
XX#   LIB2   = -lcurses
XX# otherwise;

XX    DEFINE = >os-define<
XX    LIB2   = >lib2<

XX# If you're on ACSnet (Australia) you'll want to define
XX# the following;

XX#   DEFINE="${DEFINE} -DACSNET"

XX#########################

XXLIBS=   -ltermcap
XXCFLAGS= -O
XXCC=	>cc<
XXRM=	>rm<
XXMV=     >mv<
XXCP=	>cp<

XX# if you want to use "nroff", change this...

XXFORMATTER = >troff<
XXTBL       = >tbl<

XXDOCS=   Config.guide Users.guide Ref.guide Alias.guide elm.1 from.1 \
XX	printmail.1 newalias.1 newmail.1 answer.1 messages.1 \
XX	grabalias.1 fastmail.1 readmsg.1 autoreply.1 wnewmail.1 \
XX	trim-headers.1

XXUTILSRC= utils/answer.c utils/arepdaemon.c utils/autoreply.c           \
XX	utils/fastmail.c utils/from.c utils/newalias.c \
XX	utils/newmail.c utils/printmail.c utils/readmsg.c utils/wnewmail.c \
XX	utils/trim-headers

XXELMSRC=	src/addr_utils.c src/alias.c src/aliasdb.c src/aliaslib.c     \
XX	src/args.c src/bounceback.c src/connect_to.c src/curses.c     \
XX	src/date.c src/delete.c src/domains.c src/edit.c src/encode.c \
XX	src/errno.c src/file.c src/file_utils.c src/fileio.c src/hdrconfg.c \
XX	src/help.c src/initialize.c src/input_utils.c src/leavembox.c \
XX	src/mailmsg1.c src/mailmsg2.c src/mailtime.c src/mkhdrs.c     \
XX	src/elm.c src/newmbox.c src/notesfile.c src/opt_utils.c       \
XX	src/output_utils.c src/pattern.c src/quit.c src/read_rc.c     \
XX	src/remail.c src/reply.c src/return_addr.c src/savecopy.c     \
XX	src/screen.c src/showmsg.c src/signals.c src/softkeys.c       \
XX	src/strings.c src/syscall.c src/utils.c src/validname.c       \
XX	src/calendar.c src/sort.c src/getopt.c src/string2.c	      \
XX	src/builtin.c

XX################

XXall:	bin/elm utils 
XX	@echo Everything is up to date!

XXdocumentation:  doc/Users.fmtd doc/Ref.fmtd doc/Config.fmtd  doc/Alias.fmtd
XX	
XXdoc/Users.fmtd: doc/Users.guide
XX	${TBL} doc/Users.guide | ${FORMATTER} -mm > doc/Users.fmtd

XXdoc/Ref.fmtd: doc/Ref.guide
XX	${FORMATTER} -mm doc/Ref.guide > doc/Ref.fmtd

XXdoc/Config.fmtd:  doc/Config.guide
XX	${TBL} doc/Config.guide | ${FORMATTER} -mm > doc/Config.fmtd

XXdoc/Alias.fmtd:  doc/Alias.guide
XX	${FORMATTER} -mm doc/Alias.guide > doc/Alias.fmtd

XXbin/elm: ${ELMSRC}
XX	cd src;make DEFINE=${DEFINE} LIB2=${LIB2} ../bin/elm; cd ..
XX	
XXbin/utils: ${UTILSRC}
XX	cd utils; make DEFINE=${DEFINE} LIBS=${LIB2} all; cd ..
XX	@touch bin/utils

XXinstall: all
XX	${CP} bin/elm          ${DEST}/elm
XX	${CP} bin/from         ${DEST}/from
XX	${CP} bin/newalias     ${DEST}/newalias
XX	${CP} bin/printmail    ${DEST}/printmail
XX	${CP} bin/fastmail     ${DEST}/fastmail
XX	${CP} bin/readmsg      ${DEST}/readmsg
XX	${CP} bin/newmail      ${DEST}/newmail
XX	${CP} bin/wnewmail     ${DEST}/wnewmail
XX	${CP} bin/checkalias   ${DEST}/checkalias
XX	${CP} bin/messages     ${DEST}/messages
XX	${CP} bin/trim-headers ${DEST}/trim-headers
XX	${CP} bin/arepdaemon   ${DEST}/arepdaemon
XX	${CP} bin/autoreply    ${DEST}/autoreply
XX	${RM} ${CATMAN}/elm.1 ${CATMAN}/from.1 \
XX	      ${CATMAN}/newalias.1 ${CATMAN}/printmail.1 \
XX	      ${CATMAN}/fastmail.1 ${CATMAN}/elm.1 \
XX	      ${CATMAN}/readmsg.1 ${CATMAN}/answer.1 \
XX	      ${CATMAN}/newmail.1 ${CATMAN}/checkalias.1 \
XX	      ${CATMAN}/autoreply.1 ${CATMAN}/wnewmail.1 \
XX	      ${CATMAN}/messages.1 ${CATMAN}/trim-headers.1
XX	${CP} doc/elm.1        ${MAN}/elm.1
XX	${CP} doc/from.1       ${MAN}/from.1
XX	${CP} doc/newalias.1   ${MAN}/newalias.1
XX	${CP} doc/printmail.1  ${MAN}/printmail.1
XX	${CP} doc/fastmail.1   ${MAN}/fastmail.1
XX	${CP} doc/checkalias.1 ${MAN}/checkalias.1
XX	${CP} doc/messages.1   ${MAN}/messages.1
XX	${CP} doc/trim-headers.1 ${MAN}/trim-headers.1
XX	${CP} doc/autoreply.1  ${MAN}/autoreply.1
XX	${CP} doc/answer.1     ${MAN}/answer.1
XX	${CP} doc/readmsg.1    ${MAN}/readmsg.1
XX	${CP} doc/newmail.1    ${MAN}/newmail.1
XX	${CP} doc/wnewmail.1   ${MAN}/wnewmail.1
XX	${CP} doc/helpfile     ${LIB}/elm-help.main
XX	chmod a+rx ${DEST}/from ${DEST}/newalias \
XX		   ${DEST}/printmail ${DEST}/fastmail \
XX		   ${DEST}/readmsg ${DEST}/trim-headers \
XX		   ${DEST}/checkalias ${DEST}/autoreply \
XX		   ${DEST}/newmail ${DEST}/wnewmail ${DEST}/messages
XX	chgrp mail ${DEST}/elm
XX	chmod 2755 ${DEST}/elm
XX	@echo Done with installation.

XXrmt-install: remote-defined
XX	@echo " "
XX	@echo Warning: This assumes "install" has been done on the
XX	@echo "         remote machine.  If this is not the case you"
XX	@echo "         better hit BREAK quickly!"
XX	@echo " "
XX	${CP} ${REMOTE}${DEST}/elm          ${DEST}/elm
XX	${CP} ${REMOTE}${DEST}/from         ${DEST}/from
XX	${CP} ${REMOTE}${DEST}/newalias     ${DEST}/newalias
XX	${CP} ${REMOTE}${DEST}/printmail    ${DEST}/printmail
XX	${CP} ${REMOTE}${DEST}/fastmail     ${DEST}/fastmail
XX	${CP} ${REMOTE}${DEST}/readmsg      ${DEST}/readmsg
XX	${CP} ${REMOTE}${DEST}/wnewmail     ${DEST}/wnewmail
XX	${CP} ${REMOTE}${DEST}/newmail      ${DEST}/newmail
XX	${CP} ${REMOTE}${DEST}/checkalias   ${DEST}/checkalias
XX	${CP} ${REMOTE}${DEST}/messages     ${DEST}/messages
XX	${CP} ${REMOTE}${DEST}/arepdaemon   ${DEST}/arepdaemon
XX	${CP} ${REMOTE}${DEST}/autoreply    ${DEST}/autoreply
XX	${RM} ${CATMAN}/elm.1 \
XX	      ${CATMAN}/from.1 \
XX              ${CATMAN}/newalias.1 \
XX	      ${CATMAN}/printmail.1 \
XX	      ${CATMAN}/fastmail.1 \
XX              ${CATMAN}/checkalias.1 \
XX              ${CATMAN}/autoreply.1 \
XX	      ${CATMAN}/readmsg.1 \
XX	      ${CATMAN}/answer.1 \
XX	      ${CATMAN}/newmail.1 \
XX	      ${CATMAN}/wnewmail.1 \
XX              ${CATMAN}/elm.1
XX	${CP} ${REMOTE}${MAN}/elm.1        ${MAN}/elm.1
XX	${CP} ${REMOTE}${MAN}/from.1       ${MAN}/from.1
XX	${CP} ${REMOTE}${MAN}/newalias.1   ${MAN}/newalias.1
XX	${CP} ${REMOTE}${MAN}/printmail.1  ${MAN}/printmail.1
XX	${CP} ${REMOTE}${MAN}/fastmail.1   ${MAN}/fastmail.1
XX	${CP} ${REMOTE}${MAN}/checkalias.1 ${MAN}/checkalias.1
XX	${CP} ${REMOTE}${MAN}/autoreply.1  ${MAN}/autoreply.1
XX	${CP} ${REMOTE}${MAN}/readmsg.1    ${MAN}/readmsg.1
XX	${CP} ${REMOTE}${MAN}/answer.1     ${MAN}/answer.1
XX	${CP} ${REMOTE}${MAN}/wnewmail.1   ${MAN}/wnewmail.1
XX	${CP} ${REMOTE}${MAN}/newmail.1    ${MAN}/newmail.1
XX	${CP} ${REMOTE}${LIB}/elm-help.main ${LIB}/elm-help.main
XX	chmod a+rx ${DEST}/from ${DEST}/newalias ${DEST}/printmail \
XX	           ${DEST}/fastmail ${DEST}/readmsg \
XX		   ${DEST}/checkalias ${DEST}/autoreply ${DEST}/wnewmail \
XX		   ${DEST}/newmail ${DEST}/messages
XX	chgrp mail ${DEST}/elm
XX	chmod 2755 ${DEST}/elm
XX	@echo everything is installed based on files from ${REMOTE}

XXsource: 
XX	tar cvf ${TAPE} bin/makelisting utils/*.c src/*.c doc/* hdrs/* \
XX	Instructions Makefile UNIQ_SYMS README utils/Makefile src/Makefile \
XX	test/* utils/*.awk CHANGES Overview

XX# Note that the production for SHAR assumes a pretty snazzy shar program
XX# that can break down the output into a number of files as needed...
XX#   The current threshold is 60,000 bytes per file, for email/netnews

XXshar:   
XX	${SHAR} *

XXlint:
XX	lint ${UTILSRC} > lint.out

XXlisting:
XX	@echo listing all source files 
XX	@/bin/echo \\f > LISTING
XX	@echo adding file 'README'...
XX	@cat README >> LISTING
XX	@/bin/echo \\f >> LISTING
XX	@echo adding file 'Instructions...
XX	@cat Instructions >> LISTING
XX	@/bin/echo \\f >> LISTING
XX	@echo adding file 'Makefile'...
XX	@cat Makefile >> LISTING
XX	@bin/makelisting Makefile ${UTILSRC} src/Makefile src/*.c hdrs/*.h
XX	@echo LISTING generated.

XXelm-listing: 
XX	@echo listing just the ELM system source files
XX	@echo ' ' > src/LISTING
XX	@cd src ; make listing ; cd ..
XX	@echo LISTING generated \(in directory /src\).

XXclean:
XX	@cd src ; make clean ; cd ..
XX	@cd utils; make clean ; cd ..
XX	@echo All spurious files removed

XXelm: bin/elm
XXutils: bin/utils
XXutils/checkalias:
XXutils/messages:
XXdoc/Users.guide:
XXdoc/Ref.guide:
XXdoc/Alias.guide:
XXdoc/Config.guide:

XXremote-defined:
XX	@if ( "${REMOTE}" == "" ) then; \
XX	   echo " " ; \
XX	   echo "You need to define 'REMOTE' as the remote file system" ; \
XX	   echo "for this particular command.   The easiest way to do " ; \
XX	   echo "this is to type:" ;\
XX	   echo "    make -f <makefile> REMOTE=<remote file system> rmt-install" ; \
XX	   echo " " ; \
XX	 endif
XX	@if ( "${REMOTE}" == "" ) exit 1
XXEND_OF_FILE

XXchars=`cat Makefile.mstr | wc -c`

XXif [ $chars -ne 8850 ]
XXthen
XX  echo File damaged in transit...should be 8850 bytes, is $chars instead
XX  echo  I suggest you check it closely...
XXfi


XXecho done with autodiff, part 2
XXexit 0

XX\SHAR_EOF
@//E*O*F Edit3//
chmod u=rw,g=rw,o=rw $OUT
 
echo Inspecting for damage in transit...
temp=/tmp/sharin$$; dtemp=/tmp/sharout$$
trap "rm -f $temp $dtemp; exit" 0 1 2 3 15
cat > $temp <<\!!!
    1276    4208   29970 Edit3
!!!
wc  Edit3 | sed 's=[^ ]*/==' | diff -b $temp - >$dtemp
if test -s $dtemp ; then
    echo "Ouch [diff of wc output]:"
    cat $dtemp
    STATUS=1
elif test $STATUS = 0 ; then
    echo "No problems found."
else
    echo "WARNING -- PROBLEMS WERE FOUND..."
fi
exit $STATUS