#!/bin/csh
set LIBFILES = (Warranty.message tkedit.copying.message TkEditLibr.help \
		EditCard.help ListItems.help PrintCards.help PrintLabels.help)
set BINSRCFILE = TkEditLibr.src
set BINFILE = TkEditLibr

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 "*************** TkEditLibr 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/TkEditLibr]: "
set ans = $<
if ("$ans" == "") then
	set LIBDIR = /usr/local/lib/TkEditLibr
else
	set LIBDIR = $ans
endif

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

/lib/cpp -P -DTKEDITPATH=$LIBDIR -DWISHCMD=$BINDIR/LibrWish \
	    -DPRINTLAB=$BINDIR/PrintLabels -DPRINTCARD=$BINDIR/PrintCards \
	    -DBINDIR=$BINDIR \
	    $BINSRCFILE | sed 's/%%%/#/g' >$BINDIR/$BINFILE
chmod +x $BINDIR/$BINFILE

cp $LIBFILES $LIBDIR/

ls -lgFCL $LIBDIR/ $BINDIR/$BINFILE

echo "*************** TkEditLibr Installation complete *******************"
