#! /bin/csh -f
#
# makeman [-d description] functions...
#
# Makes a section 3 man page (called "function.3") for the given functions.
# The first function name is taken to be the name of the man page.
# Remember to change appropriate contents below (organization, author, etc).
# Makeman calls 'cman', which presumes that an up to date tags file exists.
#
# Crude, crude indeed.
# Michael Hawley (dagobah!mike)
# Lucasfilm Ltd.  May 1984
#
set cw = "\fL"	# or \f(CW -- constant width font
set CW = "L"	# or CW

if ($#argv >= 1 && "$1" == "-d") then
	set Desc = " \- $2"; shift; shift
else
	set Desc = ""
endif

if ($#argv == 0) then
	set Output = $0.3
else
	set Output = $1.3
endif

set last = $argv[${#argv}]
				# print header of man page
cat > $Output << EOF
.TH $1 3  "The Droid Works"
.UC 4
.SH NAME
EOF

foreach i ($*)
	echo -n "$cw$i\fR" >> $Output
	if ($i != $last) echo -n ", " >> $Output
end
	# you'll want to change some of the following text:
cat >> $Output << EOF
$Desc
.SH SYNOPSIS
.ft L
cc ... -lmidi
.br
#include <midi.h>
.ft R
EOF
if (-e synopsis) cat synopsis >>  $Output
cat >> $Output << EOF
.sp
.ft $CW
EOF
cman $* >> $Output	# insert function descriptions
	# print trailer for man page
cat >> $Output << EOF
.SH AUTHOR
Michael Hawley, Lucasfilm Ltd.
(dagobah!mike)
EOF
