#!/bin/tcsh

set path= ($path /Library/TeX/texbin /usr/texbin /usr/local/bin)
set mpfile = "$1"
set mpoutput = "${mpfile:r}"
set texfile = "${mpfile:r}".tex

if ( -e "$texfile" ) then
else
printf '%s\n' '\input supp-pdf.mkii' '\def\insimg#1{\convertMPtoPDF{#1}{1}{1}}' '' '\font\textt=cmtex10 \textt' '\def\okbreak{\vfil\penalty2000\vfilneg}' '' '\def\today{\ifcase\month\or' '  January\or February\or March\or April\or May\or June\or' '  July\or August\or September\or October\or November\or December\fi' '  \space\number\day, \number\year}' '\newcount\m \newcount\n' '\n=\time \divide\n 60 \m=-\n \multiply\m 60 \advance\m \time' '\def\hours{\twodigits\n\twodigits\m}' '\def\twodigits#1{\ifnum #1<10 0\fi \number#1}' '' '\footline={\sevenrm\today\ at \hours\hss\tenrm\folio\hss}' '' '\def\endit{\\}' '\def\munch#1 {\def\next{#1}\ifx\next\endit\endit' '  \else#1$$\insimg{#1}$$\par\okbreak\fi\munch}' '' '\def\\{\let\munch=\relax\def\\{}}' '' '\everypar{\everypar{}\munchline}' '' '\obeylines\def\munchline#1' '{\catcode`\^^M=5 \munch#1\relax\\ \vfill\end}%' >"$texfile"
endif

mpost "$mpfile"
pdftex "$texfile" "$mpoutput".*[0-9]
