#!/bin/sh
###
###	Configure Teltool
###
### %W%	(NCSA)	%G%
###
PATH=/bin:/usr/ucb:/usr/bin:/usr3/bin:/etc/:/usr/etc
trap 'echo "Configure Aborted"; exit 1' 1 2 3 15

###
### find out the answers to several questions
###
###  default values added 3/10/88 - timk
###

echo "The following values are used for the installation of teltool"
echo "Answer 'ok' to proceed with make."
echo "Otherwise, edit Bin/Configure with the correct values."
echo "\
Documentation on these fields can be found in Doc/install.doc"
echo "\
"

##
## Fonts,Help,Dumps are created by script only in libdir
##  they can be separate if you create them so.
##
## Edit the following fields to your liking.  Directory names must be
##  absolute names, given from the root.
##
teluser="root"
bindir="/usr/local/bin"
libdir="/usr/local/bin/Lib"
mandir="/usr/local/bin/Man"
defdir="/usr/local/bin/Defaults"
dumpdir="/usr/local/bin/Lib/Dumps"
helpdir="/usr/local/bin/Lib/Help"
boldfont="/usr/local/bin/Lib/Fonts/screen.b.14"
iconfont="/usr/local/bin/Lib/Fonts/screen.r.7"
grphfont="/usr/local/bin/Lib/Fonts/vt100g.r.14"

defcapname="capture.log"
defpsout="|lpr -Plw -JTeltool"
defhpout="|lpr -Pplot -JTeltool"
deftekout="tek.out"
defbmout="|lpr -Plw -v -Jteltool"
defscrollback="200"

echo -n "Telnet Tool Super User: "
echo $teluser

echo -n "Bin directory: "
echo $bindir

echo -n "Lib Directory: "
echo $libdir

echo -n "Man Directory: "
echo $mandir

echo -n "Defaults Directory: "
echo $defdir

echo -n "Dump Directory: "
echo $dumpdir

echo -n "Help Directory: "
echo $helpdir

echo -n "Bold Font: "
echo $boldfont

echo -n "Icon Font: "
echo $iconfont

echo -n "Graphics Font: "
echo $grphfont

echo -n "Default Capture Name: "
echo $defcapname

echo -n "Default PostScript Output: "
echo $defpsout

echo -n "Default HP-GL Output: "
echo $defhpout

echo -n "Default Tektronix Output: "
echo $deftekout

echo -n "Default Bitmap Output: "
echo $defbmout

echo -n "Scrollback Default: "
echo $defscrollback

echo -n "\
OK to proceed?  Answer 'ok': "
read answer

if [ $answer != "ok" ]; then
	exit 1
fi

echo Proceeding with configs
###
### Now build all dependent files from answers we got
###

echo "Configuring machdep.h"

cd Src/Main;

cat machdep.src | sed "s;XXBOLDFONTXX;$boldfont;
					   s;XXGRPHFONTXX;$grphfont;
					   s;XXICONFONTXX;$iconfont;
					   s;XXTELUSERXX;$teluser;
					   s;XXDUMPDIRXX;$dumpdir;
					   s;XXDEFHELPDIRXX;$helpdir;
					   s;XXDEFSCROLLBACKXX;$defscrollback;
					   s;XXDEFCAPNAMEXX;$defcapname;
					   s;XXDEFPSOUTXX;$defpsout;
					   s;XXDEFHPOUTXX;$defhpout;
					   s;XXDEFTEKOUTXX;$deftekout;
					   s;XXDEFBMOUTXX;$defbmout;" > machdep.h

###
### configure makefile
###

echo "Configuring Makefile."

cat Makefile.src | sed "s;XXBINDIRXX;$bindir;
						s;XXLIBDIRXX;$libdir;
						s;XXDEFDIRXX;$defdir;
						s;XXMANDIRXX;$mandir;" > Makefile

cd ../..

###
### make Teltool.d from Teltool.src
###

echo "Configuring Defaults File."
cd Defaults ; make

echo "Configuration Completed."
echo "Your make files have been updated to compile teltool with the"
echo "chosen defaults.  When you do the installation, teltool will"
echo "be compiled and then placed into the directories you have chosen."
echo "Use 'make install' to compile and install the teltool executable"
exit 0
