#!/bin/sh
FONTPATH=$1
FONTSIZES=$2
VFPATH=$3
shift 3

BUTTONS=y
A4=''
SUBDIR=''
TEXFONTS=''
GREY=y
MAKEPK=y
BDPI=''
PS=y
DPS=''
NEWS=''
GHOST=y

while test $# -gt 0
do
	case $1 in
	-DNOBUTTONS)		BUTTONS=;;
	-DA4)			A4=y;;
	-DSEARCH_SUBDIRECTORIES) SUBDIR=y;;
	-DXDVIFONTS_ONLY)	TEXFONTS=y;;
	-DNOGREY)			GREY=;;
	-DMAKEPK)		MAKEPK=-DMAKEPKCMD=\\\"MakeTeXPK\\\";;
	-DMAKEPKCMD*)		MAKEPK=$1;;
	-DBDPI=*)		BDPI=$1;;
	-DPS_DPS)		DPS=y; GHOST=; PS=y;;
	-DPS_NEWS)		NEWS=y; GHOST=; PS=y;;
	-DPS_GS)		GHOST=y; PS=y;;
	esac
	shift
done

if test -z "$BUTTONS";	then	echo	'/^#ifbuttons/,/^#/d';	fi
if test -z "$SUBDIR";	then	echo	'/^#ifsubdir/,/^#/d';	fi
if test -n "$TEXFONTS";	then	echo	'/^#iftexfonts/,/^#/d';	fi
if test -z "$GREY";	then	echo	'/^#ifgrey/,/^#/d';	fi
if test -z "$PS";	then	echo	'/^#ifps/,/^#/d';	fi
if test -z "$DPS";	then	echo	'/^#ifdps/,/^#/d';	fi
if test -z "$NEWS";	then	echo	'/^#ifnews/,/^#/d';	fi
if test -z "$GHOST";	then	echo	'/^#ifghost/,/^#/d';	fi
if test -z "$MAKEPK";	then	echo	'/^#ifmakepk/,/^#/d'
	else	echo	"s^%%mkpk%%^`echo $MAKEPK | sed s/-DMAKEPKCMD=//`^"
	fi
echo	'/^#/d'

if test -n "$A4"
then
	echo	's/%%defaultpagesize%%/21 x 29.7 cm (A4 size)/'
else
	echo	's/%%defaultpagesize%%/8.5 x 11 inches/'
fi

if test -n "$BDPI"
then
	echo	"s/%%bdpi%%/`echo $BDPI | sed s/-DBDPI=//`/"
else
	echo	's/%%bdpi%%/300/'
fi

echo	"s@%%DEFAULT_FONT_PATH%%   @.B $FONTPATH\\
@" | sed -e "s@:@\\\\\\
.TP\\\\\\
.B @g"

echo	"s/%%DEFAULT_FONT_SIZES%%/$FONTSIZES/" | sed -e "s/:/ :\\\\\\
/g"

if test -n "$VFPATH"
then
	echo	"s@%%DEFAULT_VF_PATH%%   @.TP\\
.B $VFPATH\\
@" | sed -e "s@:@\\\\\\
.TP\\\\\\
.B @g"
else
	echo	'/%%DEFAULT_VF_PATH%%/d'
fi
