#!/bin/csh
set LIBFILES = (Warranty.message tklibr.copying.message TkLibrarian.help \
		CardDisp.help ListItems.help)
set BINSRCFILE = TkLibrarian.src
set BINFILE = TkLibrarian

if ("`whoami`" != "root") then
	echo "You need to run this script as root.  Either login as root"
	echo "or use sudo"
	exit 1
endif

echo "*************** TkLibrarian Installation beginning *******************"
echo ""
echo "Default values are in '[]'.  Hitting ENTER or RETURN accepts the default"
echo "value."
echo ""
echo -n "Binaries dir [/usr/local/bin]: "
set ans = $<
if ("$ans" == "") then
	set BINDIR = /usr/local/bin
else
	set BINDIR = $ans
endif
echo -n "Library dir [/usr/local/lib/TkLibrarian]: "
set ans = $<
if ("$ans" == "") then
	set LIBDIR = /usr/local/lib/TkLibrarian
else
	set LIBDIR = $ans
endif

if (!(-d $BINDIR)) then
	mkdir -p $BINDIR
endif
if (!(-d $LIBDIR)) then
	mkdir -p $LIBDIR
endif

/lib/cpp -P -DTKLIBRPATH=$LIBDIR -DWISHCMD=$BINDIR/LibrWish \
		 $BINSRCFILE | sed 's/%%%/#/g' >$BINDIR/$BINFILE
chmod +x $BINDIR/$BINFILE

cp $LIBFILES $LIBDIR/

ls -lgFCL $LIBDIR/ $BINDIR/$BINFILE

echo "*************** TkLibrarian Installation complete *******************"
