#!/bin/sh
# If this don't work delete these two lines and say "sh config"
xgen='xgen'
contains=''
rmlist=''
shsharp=''
spitshell=''
sharpbang=''
n=''
c=''
tempdir='/tmp/.ZZZ'
ostype=''
pth=`echo $PATH | sed -e 's/:/ /g'`

mydir=`pwd`
cd ..; top=`pwd`; cd $mydir

mkdir $tempdir
cd $tempdir

trap 'echo " "; cd ..; /bin/rm -rf $tempdir; exit 1' 1 2 3


eunicefix=':'
if test -f /etc/unixtovms; then
    eunicefix=/etc/unixtovms
fi
if test -f /etc/unixtovms.exe; then
    eunicefix=/etc/unixtovms.exe
fi


: some greps do not return status, grrr.
echo "grimblepritz" >contains.txt
if grep blurfldyick contains.txt >/dev/null 2>&1 ; then
    contains=contains
elif grep grimblepritz contains.txt >/dev/null 2>&1 ; then
    contains=grep
else
    contains=contains
fi
: the following should work in any shell
case "$contains" in
contains*)
    echo " "
    echo "AGH!  Grep doesn't return a status.  Attempting remedial action."
    cat >contains <<'EOSS'
grep "$1" "$2" >.greptmp && cat .greptmp && test -s .greptmp
EOSS
chmod +x contains
esac

cat <<EOSC >loc
$startsh
case \$# in
0) exit 1;;
esac
thing=\$1
shift
dflt=\$1
shift
for dir in \$*; do
    case "\$thing" in
    .)
        if test -d \$dir/\$thing; then
            echo \$dir
            exit 0
        fi
        ;;
    *)
        if test -f \$dir/\$thing; then
            echo \$dir/\$thing
            exit 0
        elif test -f \$dir/\$thing.exe; then
            : on Eunice apparently
            echo \$dir/\$thing
            exit 0
        fi
        ;;
    esac
done
echo \$dflt
exit 1
EOSC
chmod +x loc

: set up shell script to do ~ expansion
cat >filexp <<EOSS
$startsh
: expand filename
case "\$1" in
 ~/*|~)
    echo \$1 | $sed "s|~|\${HOME-\$LOGDIR}|"
    ;;
 ~*)
    if $test -f /bin/csh; then
        /bin/csh -f -c "glob \$1"
        echo ""
    else
        name=\`$expr x\$1 : '..\([^/]*\)'\`
        dir=\`$sed -n -e "/^\${name}:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'\$'"/\1/" -e p -e q -e '}' </etc/passwd\`
        if $test ! -d "\$dir"; then
            me=\`basename \$0\`
            echo "\$me: can't locate home directory for: \$name" >&2
            exit 1
        fi
        case "\$1" in
        */*)
            echo \$dir/\`$expr x\$1 : '..[^/]*/\(.*\)'\`
            ;;
        *)
            echo \$dir
            ;;
        esac
    fi
    ;;
*)
    echo \$1
    ;;
esac
EOSS
chmod +x filexp
$eunicefix filexp

: see if sh knows # comments
echo " "
echo "Checking your sh to see if it knows about # comments..."
if sh -c '#' >/dev/null 2>&1 ; then
    echo "Your sh handles # comments correctly."
    shsharp=true
    spitshell=cat
    echo " "
    echo "Okay, let's see if #! works on this system..."
    if test -f /bsd43/bin/echo; then
	echo "#!/bsd43/bin/echo hi" > spit.sh
    else
	echo "#!/bin/echo hi" > spit.sh
    fi
    $eunicefix spit.sh
    chmod +x spit.sh
    ./spit.sh > today
    if $contains hi today >/dev/null 2>&1; then
	echo "It does."
	sharpbang='#!'
    else
	echo "#! /bin/echo hi" > spit.sh
	$eunicefix spit.sh
	chmod +x spit.sh
	./spit.sh > today
	if test -s today; then
	    echo "It does."
	    sharpbang='#! '
	else
	    echo "It doesn't."
	    sharpbang=': use '
	fi
    fi
else
    echo "Your sh doesn't grok # comments--I will strip them later on."
    shsharp=false
    echo "exec grep -v '^#'" >spitshell
    chmod +x spitshell
    $eunicefix spitshell
    spitshell=`pwd`/spitshell
    echo "I presume that if # doesn't work, #! won't work either!"
    sharpbang=': use '
fi

: figure out how to guarantee sh startup
echo " "
echo "Checking out how to guarantee sh startup..."
startsh=$sharpbang'/bin/sh'
echo "Let's see if '$startsh' works..."
cat >start.sh <<EOSS
$startsh
set abc
test "$?abc" != 1
EOSS

chmod +x start.sh
$eunicefix start.sh
if ./start.sh; then
    echo "Yup, it does."
else
    echo "Nope.  You may have to fix up the shell scripts to make sure sh runs them."
fi

: first determine how to suppress newline on echo command
echo "Checking echo to see how to suppress newlines..."
(echo "hi there\c" ; echo " ") >echotmp
if $contains c echotmp >/dev/null 2>&1 ; then
    echo "...using -n."
    n='-n'
    c=''
else
    cat <<'EOM'
...using \c
EOM
    n=''
    c='\c'
fi
echo $n "Type carriage return to continue.  Your cursor should be here-->$c"
read ans

: now set up to do reads with possible shell escape and default assignment
cat <<EOSC >myread
case "\$fastread" in
yes) ans=''; echo " " ;;
*) ans='!';;
esac
while expr "X\$ans" : "X!" >/dev/null; do
    read ans
    case "\$ans" in
    !)
	sh
	echo " "
	echo $n "\$rp $c"
	;;
    !*)
	set \`expr "X\$ans" : "X!\(.*\)\$"\`
	sh -c "\$*"
	echo " "
	echo $n "\$rp $c"
	;;
    esac
done
rp='Your answer:'
case "\$ans" in
'') ans="\$dflt";;
esac
EOSC

test=''
if sh -c "PATH= test true" >/dev/null 2>&1; then
    echo "Using the test built into your sh."
    test=test
else
    test=/bin/test
fi

: print intro
cat<<INTRO

This installation shell script will examine your system and ask you questions
to determine how $xgen should be installed.  If you get stuck
on a question, you may use a ! shell escape to start a subshell or execute
a command.  Many of the questions will have default answers in square
brackets--typing carriage return will give you the default.

On some of the questions which ask for file or directory names you are
allowed to use the ~name construct to specify the login directory belonging
to "name", even if you don't have a shell which knows about that.  Questions
where this is allowed will be marked "(~name ok)".

INTRO
rp="[Type carriage return to continue]"
echo $n "$rp $c"
. ./myread
cat <<EOH

Much effort has been expended to ensure that this shell script will run on any
Unix system.  If despite that it blows up on you, your best bet is to edit
Setup and run it again. Also, let me (kurt@zorro.cecer.army.mil)
know how I blew it.  If you can't run Setup for some reason, you'll have
to generate a config.sh file by hand.

This installation script will do direct variable substitutions on some 
of the files included in this kit. You may edit any of these files as 
the need arises after running this script.

If you make a mistake on a question, there is no easy way to back up to it
currently.  The easiest thing to do is to edit config.sh and rerun all the
SH files.  Setup will offer to let you do this before it runs the SH files.

EOH
rp="[Type carriage return to continue]"
echo $n "$rp $c"
. ./myread

: check for an old config.sh

if test -f $mydir/config.sh; then
cat<<EOOLDCONFIG

    I see an old config.sh file. I'll save it as $top/oldconfig.sh.
    If for some reason you  decided to abort this process, you can
    move it back...

EOOLDCONFIG
    mv $mydir/config.sh $mydir/oldconfig.sh
    echo "Removing old config.sh files in the source tree..."
    cd $mydir
    rm -f config.sh
    cd $tempdir
fi

echo " "
cat <<EOEXPL
    We will be creating an executable program that should 
    be available to all folks that want to use $xgen.
EOEXPL
dflt="/usr/local/bin"
cont=true
while $test "$cont" ; do
    echo " "
    echo "Where would you like to put these programs ? [$dflt] "
    rp=" : "
    echo $n "$rp $c"
    . ./myread
    case "$ans" in
    /*)
        if test -d "$ans"; then
            localbin=$ans
            cont=''
        else
            echo "Your answer appears to be wrong. Try again..."
        fi
        ;;
    *) echo "I need a fully qualified path"
       ;;
    esac
done

echo "Place to put $xgen binary $localbin"

: determine where manual pages go
case "$mansrc" in
'')
    dflt=`./loc . /usr/man/man1 /usr/man/mann /usr/man/manl /usr/man/local/man1 /usr/man/u_man/man1 /usr/man/man1`
    ;;
*)  dflt="$mansrc"
    ;;
esac
cont=true
while $test "$cont" ; do
    echo " "
    rp="Where do the manual pages (source) go? [$dflt]"
    echo $n "$rp $c"
    . ./myread
    mansrc=`./filexp "$ans"`
    if test -d $mansrc; then
        cont=''
    else
        dflt=n
        rp="Directory $mansrc doesn't exist.  Use that name anyway? [$dflt]"
        echo $n "$rp $c"
        . ./myread
        dflt=''
        case "$ans" in
        y*) cont='';;
        esac
    fi
done
case "$mansrc" in
*l)
    manext=l
    ;;
*n)
    manext=n
    ;;
*C)
    manext=C
    ;;
*)
    manext=1
    ;;
esac


ostype='bsd'

echo " "
if $test -f /bin/4d && /bin/4d; then
    echo "Looks like a IRIX"
    ostype='irix'
elif $test -f /bin/mips && /bin/mips; then
    echo "Looks like a MIPS system...fast box..."
    ostype='mips'
elif $test -d /etc/init.d; then
    echo "Oooh, a System V machine perhaps ?"
    ostype='sysv'
elif $test -d /usr/5bin; then
    echo "I surmise that this is a Sun"
    ostype='sun'
fi

echo " "
cat <<EOMACH
	We need to know what type of operating system $xgrass 
	will be running on. The OS types I know about are :

		mips 
		irix 
		sysv 
                aix    
                dynix/ptx  [specifically Dynix/Ptx 1.4]
		svr4
		sun
		bsd

EOMACH
dflt=$ostype
mipsos=''
rp="What type of OS is this ? [$dflt] "
cont=true
while $test "$cont" ; do
    echo " "
    echo $n "$rp $c"
    . ./myread
    case "$ans" in
    mips)
	ostype='mips'
        cc=cc
	rm='rm -f'
	optim='-O -Olimit 2000 -Wf,-XNd8400,-XNp12000'
	dflt='bsd'
	rp="Which universe would you like to use (bsd or sysv)? [$dflt] "
	echo $n "$rp $c"
	. ./myread
        case "$ans" in
	sysv)
	    cflags="$optim -signed -systype sysv -DMips -DSYSV"
	    ldflags="$optim -systype sysv"
	    mipsos="sysv"
	    ;;
	*)
	    cflags="$optim -signed -systype bsd43 -DMips -DBSD -DBSD43"
	    ldflags="$optim -systype bsd43"
	    mipsos="bsd"
	    ;;
	esac
        cont=''
        ;;
    bsd)
	ostype='bsd'
        cc=cc
	rm='rm -f'
	optim='-O'
	cflags="$optim -DBSD"
	ldflags="$optim"
        cont=''
        ;;
    dynix)
	ostype='dynix'
        cc=cc
	rm='rm -f'
	optim='-O'
	cflags="$optim -DSYSV"
	ldflags="$optim"
        cont=''
        ;;
    aix)
	ostype='aix'
        cc=cc
	rm='rm -f'
	optim='-O'
	cflags="$optim -DSYSV -DAIX"
	ldflags="$optim"
        cont=''
        ;;
    irix)
	ostype='irix'
        cc=cc
	rm='rm -f'
	optim='-O'
	cflags="$optim -DSYSV -DIRIX"
	ldflags="$optim"
        cont=''
        ;;
    sysv)
	ostype='sysv'
        cc=cc
	rm='rm -f'
	optim='-O'
	cflags="$optim -DSYSV"
	ldflags="$optim"
        cont=''
        ;;
    svr4)
	ostype='sysv'
        cc=cc
	rm='rm -f'
	optim='-O'
	cflags="$optim -DSVR4 -I/usr/ucbinclude"
	ldflags="$optim"
        cont=''
        ;;
    sun)
	ostype='sun'
        cc=cc
	rm='rm -f'
	optim='-O'
	cflags="$optim -DSUNOS"
	ldflags="$optim"
        cont=''
        ;;
    *) echo "I don't know that one.  Please try again."
       ;;
    esac
done

echo " "
dflt=$cc
rp="What C compiler do you want to use ? [$dflt] "
cont=true
while $test "$cont" ; do
    echo " "
    echo $n "$rp $c"
    . ./myread
    xxx=`./loc $ans $ans $pth`
    case "$xxx" in
    /*)
        echo $ans is in $xxx.
        cc=$ans
        cont=''
	;;
    *) echo "I don't know that one.  Please try again."
       ;;
    esac
done

: check for ANSI compliance in C compiler
echo " "
echo "Checking to see if your C compiler handles prototypes"
cat >ansicheck.c <<'EOCP'
int somefunction(char *,void *,long);

EOCP
if $cc -c ansicheck.c  >/dev/null 2>&1; then
    echo "Yup, it does."
else
    cflags="$cflags -D_NO_PROTO"
    echo "Nope, so much for ANSI"
fi

cat <<EOCFLAG

    So far I think your compiler flags should be: 

	$cflags
EOCFLAG

: any other cflags???
echo " "
dflt=''
echo " "
rp="Enter any other needed compiler flags (type . to change flags) : "
echo $n "$rp $c"
. ./myread
case "$ans" in
    .)
	cont=true
	while $test "$cont"; do
	    rp="Enter compiler flags : "
	    echo $n "$rp $c"
	    . ./myread
	    dflt='y'
	    echo $n "Is [$ans] correct? [y] "
	    saveans="$ans"
	    . ./myread
	    case "$ans" in
		y*|Y*)
		    cont=''
		    cflags="$saveans"
		    ;;
	    esac
	done
	;;
    *)
	cflags="$cflags $ans"
	;;
esac

: any ldflags ??

cat <<EOLDFLAG

    So far I think your linker flags should be: 

	$ldflags
EOLDFLAG
echo " "
dflt=''
rp="Enter any other needed linker flags (type . to change flags) : "
echo $n "$rp $c"
. ./myread
case "$ans" in
    .)
        cont=true
        while $test "$cont"; do
            rp="Enter linker flags : "
            echo $n "$rp $c"
            . ./myread
            dflt='y'
            echo $n "Is [$ans] correct? [y] "
            saveans="$ans"
            . ./myread
            case "$ans" in
                y*|Y*)
                    cont=''
                    ldflags="$saveans"
                    ;;
            esac
        done
        ;;
    *)
        ldflags="$ldflags $ans"
        ;;
esac

echo " "
cont=true
while $test "$cont"; do
    ans=''
    case $ostype in
    dynix)
	dflt='-linet -lnsl -lPW -lseq'
        ;;
    irix)
	dflt='-lPW'
        ;;
    *)
	dflt=''
        ;;
    esac
    rp="Enter any extra libraries needed here [$dflt]: "
    echo $n "$rp $c"
    . ./myread
    dflt='y'
    echo $n "Is [$ans] correct? [y] "
    saveans="$ans"
    . ./myread
    case "$ans" in
	y*|Y*)
	    cont=''
	    extraldflags="$saveans"
	    ;;
    esac
done


x11incpth='/usr/RISCwindows4.0/include /usr/include /usr/local/include'
motifincpth='/usr/RISCwindows4.0/include/X11 /usr/include/Motif1.1 /usr/include/X11 /usr/include /usr/local/include/X11 /usr/local/include'
xlibpth='/usr/RISCwindows4.0/lib /usr/lib/Motif1.1 /usr/lib/X11R4 /usr/lib'

x=`./loc X11/X.h nope $x11incpth`
xx=`./loc X11/Intrinsic.h nope $x11incpth`
if test -f "$x" -a -f "$xx"; then
   echo "Found X11 includes [$x]"
   echo "Found Xt includes [$xx]"
   x11inc=`echo $x| sed -e 's:/X11/X.h::'`
   xtinc=`echo $xx| sed -e 's:/X11/Intrinsic.h::'`
else
   if test -f "$x"; then
      echo "Cannot find your X11 include files..."
      cont=true
      rp="Where are they ? "
      while $test "$cont"; do
	  dflt=''
	  echo $n "$rp $c"
	  . ./myread
	  case "$ans" in
	  /*)
	      x=`./loc X11/X.h nope $ans`
	      if test -f "$x"; then
		  echo "Got it."
		  x11inc=`echo $x| sed -e 's:/X11/X.h::'`
		  cont=''
	      else
		  echo "That's not it either...Try again."
	      fi
	      ;;
	  *)
	      echo "Need a full path...Try again."
	      ;;
	  esac
      done
   else
      echo "Found X11 includes [$x]"
      x11inc=`echo $x| sed -e 's:/X11/X.h::'`
   fi
   if test -f "$xx"; then
      echo "Cannot find your Xt include files..."
      cont=true
      rp="Where are they ? "
      while $test "$cont"; do
	  dflt=''
          echo $n "$rp $c"
          . ./myread
          case "$ans" in
          /*)
              xx=`./loc X11/Intrinsic.h nope $ans`
              if test -f "$xx"; then
                  echo "Got it."
                  xtinc=`echo $xx| sed -e 's:/X11/Intrinsic.h::'`
                  cont=''
              else
                  echo "That's not it either...Try again."
              fi
              ;;
          *)
	      echo "Need a full path...Try again."
              ;;
          esac
      done
   else
      echo "Found Xt includes [$xx]"
      xtinc=`echo $xx| sed -e 's:/X11/Intrinsic.h::'`
   fi
fi

xxx=`./loc Xm/Xm.h nope $motifincpth`
if test -f "$xxx"; then
  echo "Found Motif includes [$xxx]"
  motifinc=`echo $xxx| sed -e 's:/Xm/Xm.h::'`
else
  echo "Cannot find your Motif include files..."
  cont=true
  rp="Where are they ? "
  while $test "$cont"; do
      dflt=''
      echo $n "$rp $c"
      . ./myread
      case "$ans" in
      /*)
	  xxx=`./loc Xm/Xm.h nope $ans`
	  if test -f "$xxx"; then
	      echo "Got it."
	      motifinc=`echo $xxx| sed -e 's:/Xm/Xm.h::'`
	      cont=''
	  else
	      echo "That's not it either...Try again."
	  fi
	  ;;
      *)
	  echo "Need a full path...Try again."
	  ;;
      esac
  done
fi

xincs=''
if test "$x11inc" = "$xtinc"; then
   if test "$x11inc" != "$motifinc"; then
       if test "$x11inc" != "/usr/include"; then
	   xincs="$xincs -I$x11inc"
       fi
       if test "$motifinc" != "/usr/include"; then
	   xincs="$xincs -I$motifinc"
       fi
   else
       if test "$x11inc" != "/usr/include"; then
	   xincs="-I$x11inc"
       fi
   fi
else
   if test "$xtinc" != "/usr/include"; then
       xincs="$xincs -I$xtinc"
   fi
   if test "$x11inc" != "$motifinc"; then
       if test "$x11inc" != "/usr/include"; then
	   xincs="$xincs -I$x11inc"
       fi
       if test "$motifinc" != "/usr/include"; then
	   xincs="$xincs -I$motifinc"
       fi
   else
       if test "$x11inc" != "/usr/include"; then
	   xincs="$xincs -I$x11inc"
       fi
   fi
fi

x=`./loc libX11.a libX11.a $xlibpth`
if test -f "$x"; then
  echo "Found X11 library [$x]"
  tempxlibdir=`echo $x | sed -e 's:/libX11.a::'`
else
  echo "Cannot find your X11 library..."
  cont=true
  rp="Where is it ? "
  while $test "$cont"; do
      dflt=''
      echo $n "$rp $c"
      . ./myread
      case "$ans" in
      /*)
          x=`./loc libX11.a nope $ans`
          if test -f "$x"; then
              echo "Got it."
	      tempxlibdir=`echo $x | sed -e 's:/libX11.a::'`
              cont=''
          else
              echo "That's not it either...Try again."
          fi
          ;;
      *)
          echo "Need a full path...Try again."
          ;;
      esac
  done
fi

xx=`./loc libXt.a libXt.a $xlibpth`
if test -f "$xx"; then
  echo "Found X Toolkit library [$xx]"
  tempxtlibdir=`echo $xx | sed -e 's:/libXt.a::'`
else
  echo "Cannot find your X Toolkit library..."
  cont=true
  rp="Where is it ? "
  while $test "$cont"; do
      dflt=''
      echo $n "$rp $c"
      . ./myread
      case "$ans" in
      /*)
          xx=`./loc libXt.a nope $ans`
          if test -f "$xx"; then
              echo "Got it."
	      tempxtlibdir=`echo $xx | sed -e 's:/libXt.a::'`
              cont=''
          else
              echo "That's not it either...Try again."
          fi
          ;;
      *)
          echo "Need a full path...Try again."
          ;;
      esac
  done
fi

xxx=`./loc libXm.a libXm.a $xlibpth`
if test -f "$xxx"; then
  echo "Found Motif library [$xxx]"
  tempxmlibdir=`echo $xxx | sed -e 's:/libXm.a::'`
else
  echo "Cannot find your Motif library..."
  cont=true
  rp="Where is it ? "
  while $test "$cont"; do
      dflt=''
      echo $n "$rp $c"
      . ./myread
      case "$ans" in
      /*)
          xxx=`./loc libXm.a nope $ans`
          if test -f "$xxx"; then
              echo "Got it."
	      tempxmlibdir=`echo $xxx | sed -e 's:/libXm.a::'`
              cont=''
          else
              echo "That's not it either...Try again."
          fi
          ;;
      *)
          echo "Need a full path...Try again."
          ;;
      esac
  done
fi

xlibdir=''
xtlibdir=''
xmlibdir=''
if test "$tempxmlibdir" = "$tempxtlibdir"; then
   if test "$tempxmlibdir" != "$tempxlibdir"; then
       if test "$tempxmlibdir" != "/usr/lib"; then
           xmlibdir="-L$tempxlibdir"
       fi
       if test "$tempxlibdir" != "/usr/lib"; then
           xlibdir="-L$tempxlibdir"
       fi
   else
       if test "$tempxmlibdir" != "/usr/lib"; then
           xmlibdir="-L$tempxmlibdir"
       fi
   fi
else
   if test "$tempxtlibdir" != "/usr/lib"; then
       xtlibdir="-L$tempxtlibdir"
   fi
   if test "$tempxmlibdir" != "$tempxlibdir"; then
       if test "$tempxmlibdir" != "/usr/lib"; then
           xmlibdir="-L$tempxmlibdir"
       fi
       if test "$tempxlibdir" != "/usr/lib"; then
           xlibdir="-L$tempxlibdir"
       fi
   else
       if test "$tempxmlibdir" != "/usr/lib"; then
           xmlibdir="-L$tempxmlibdir"
       fi
   fi
fi

: get the preferred printer command
cat <<EOPRINT

    We will be compiling a default printer command into the editor used
    to capture output of commands run by $xgen. The printer command string 
    can be any command that will print a UNIX file. The UNIX file name that
    we will be inserting into the print command is represented by the
    string "%s". For example, if we want to use lpr(1) to print to a
    network printer named "bozo", the print command would be:

        lpr -Pbozo %s

EOPRINT
echo " "
printcommand='cat %s | /bin/lp'
dflt='cat %s | /bin/lp'
cont=true
while $test "$cont"; do
    rp="Enter the desired print command : [$dflt] "
    echo $n "$rp $c"
    . ./myread
    xxx=`echo "$ans" | $contains "%s"`
    if test "$xxx"; then
        dflt='y'
        echo $n "Is [$ans] correct? [y] "
        saveans="$ans"
        . ./myread
        case "$ans" in
            y*|Y*)
                cont=''
                printcommand="$saveans"
                ;;
        esac
    else
        echo "The command you entered has no %s in it...try again"
    fi
done

: end of configuration questions
echo " "
echo "End of configuration questions."
echo " "

: now create config.sh
echo "Creating config.sh..."
test -f $mydir/config.sh && cp $mydir/config.sh $tempdir/oldconfig.sh
$spitshell <<EOT >$mydir/config.sh
$startsh
# config.sh
# This file was produced by running the XGRASS config script.
# DO NOT EDIT THIS FILE...or else
eunicefix='$eunicefix'
spitshell='$spitshell'
xgrassinc='$xgrassinc'
localbin='$localbin'
mansrc='$mansrc'
manext='$manext'
ldflags='$ldflags'
extraldflags='$extraldflags'
mipsos='$mipsos'
xincs='$xincs'
xlibdir='$xlibdir'
xtlibdir='$xtlibdir'
xmlibdir='$xmlibdir'
cflags='$cflags'
cc='$cc'
rm='$rm'
printcommand='$printcommand'
EOT

echo "CONFIG=true" >>$mydir/config.sh

: wrap things up
CONFIG=true

echo " "
dflt=''
fastread=''
echo "If you didn't make any mistakes, then just type a carriage return here."
echo "If you need to edit $mydir/config.sh,"
rp="do it as a shell escape here:"
echo $n "$rp $c"
. ./myread
case "$ans" in
'') ;;
*) : in case they cannot read
    eval $ans;;
esac

cd $mydir

sh Makefile.SH
sh editor.c.SH

if test -f ./[Mm]akefile; then
    echo " "
    echo "Now you must run a make."
else
    echo "Done."
fi


: Hey bozo, Leave this at the end...
/bin/rm -rf $tempdir
