#!/bin/sh
#------------------------------------------------------------------------------
# create skeleton for given module name
# afb 8/90
#------------------------------------------------------------------------------

	name=`basename $0`
	usage="Usage: $name modulename"
	fillpattern="{...}"
	chapter=3
	infiledir=../../misc

if [ $# -ne 1 ]
then	echo >&2 "$usage"; exit 1
fi

if [ ! -d "$infiledir" ]
then	for dir in \
		/home/titania/src/oberon/ulm/sun3/doc/misc \
		/usr/borchert/oberon/doc/misc
	do	if [ -d "$dir" ]
		then	infiledir="$dir"; break
		fi
	done
	echo >&2 "$name: don't find directory with auxiliary files"
	exit 1
fi

modulename="$1"
case $modulename
in [a-z]*)	chapter=1
esac
manpage=`echo $modulename | sed 's/\(..........\).*/\1/'`.$chapter
if [ -f $manpage -o -f RCS/$manpage,v ]
then	echo 2>&1 "$manpage exists already"
	exit 1
fi
{	cat $infiledir/header
	cat $infiledir/macros
	echo ".TH $modulename $chapter "'"Oberon System"'
	echo ".SH NAME"
	echo "$modulename \- $fillpattern"
	echo ".SH SYNOPSIS"
	echo ".Pg"
	echo "$fillpattern"
	echo ".Pe"
	echo ".SH DESCRIPTION"
	echo "$fillpattern"
	echo ".SH DIAGNOSTICS"
	echo ".SH FILES"
	echo '.SH "SEE ALSO"'
	echo ".SH BUGS"
	cat $infiledir/trailer
} > $manpage
