#! /bin/sh

# 4/5/1991 Dan Dill dan@chem.bu.edu
# This is part of TeX/Mathematica

# This script is executed as
#
#	$cmd document-file package-type package-file
#
# to assemble package-file of package-type from document-file.
# This script edits the template Emacs Lisp file
# $bindir/tex-mma-assemble-package.tmplt.
# The edited file is written to directory $tmpdir.
# It is then loaded into Emacs and executed.
# See comments in $bindir/tex-mma-assemble-package.tmplt for further details.
# The log of the emacs session is written to document-file.log

# Edit bindir, tmpdir (and tmpdirsed, tmpdir santized for sed)
# for your system
bindir=/usr8/dan/bin
tmpdir=/usr8/dan/emacs/lisp
tmpdirsed=\\/usr8\\/dan\\/emacs\\/lisp

cmd=tex-mma-assemble-package

if [ $# -lt 3 ]
then
echo $cmd package-type package-file document-file 
exit 1
fi

sed s/LDIR/$tmpdirsed/ $bindir/tex-mma-assemble-package.tmplt \
	| sed s/TYPE/$1/ \
	| sed s/FILE/$2/ \
		> $tmpdir/$$.el
emacs -batch $3 -l $tmpdir/$$.el -f tex-mma-assemble -kill > $2.log
rm $tmpdir/$$.el
