:
# script to make font files for program 'plotter' based
#	upon D.a archive and *.d files in this directory.
# execute as:
#	Makefonts dest_font_directory
# where dest_font_directory is full path name of font directory.
#
if [ $# != 1 ] ; then
	echo "Makefonts dest_font_directory"
	exit 1
fi
if [ ! -d $1 ] ; then	# make directory if it doesn't exist
	echo "making directory $1\c"
	mkdir $1
	if [ $? != 0 ] ; then
		echo "can't make directory"
		exit 1
	fi
	echo " ... done"
fi
if [ ! -x symgen ] ; then	# compile symgen
	echo "compiling symgen\c"
	cc -o symgen symgen.c
	if [ $? != 0 ] ; then
		echo "failure to compile symgen"
		exit 2
	fi
	echo " ... done"
fi
# extract compressed tables
zlist=""
for x in `echo *.tab.Z`
do
	echo "decompressing $x"
	t=`expr $x : '\(.*\)\.Z'`
	zcat $t >$t
	zlist=${zlist}" "${t}
done
for a in basic-fonts/* *.d ; do	# loop through definitions to make fonts
	if [ -f $a ] ; then
		b=`basename $a`
		b=`expr $b : '\(.*\)\.[dD]'`
		echo "making font $b \c"
		if [ -f ${1}/${b} ] ; then
			echo "< WARNING! Overwriting existing copy >\c"
		fi
		./symgen $a ${1}/${b} *.tab
		echo " ... done"
	fi
done
echo "cleaning up"
#
# cleanup
for x in $zlist
do
	rm -f $x
done
rm -f symgen
echo "Fonts installed in library: $1"
