USE_JAG = yes
include ${SEPINC}/SEP.top

URL    = sepwww.stanford.edu/sep/matt/jest
WWWDIR =              /sepwww/pub/sep/matt/jest/adm/Web

SCRDIR =              /scrka1/matt/
SRCDIR =              /sepwww/pub/sep/matt/jest

GZIP = gzip -f 

.IGNORE: ; 

tex = $(wildcard *.tex)

default:  $(patsubst %.tex,%.html,$(tex))

.PHONY: paper.tex 
paper.tex : 
	${MAKE} texclean
	${TOUCH} paper.tex; ${RM} paper.tex
	cat $(subst paper.tex,,$(wildcard *.tex)) > paper.tex 

html : $(foreach file,$(tex),$(subst .tex,.html,$(file))) 
	echo "hello"

%.html : %.tex
	${MAKE} clean 
	vulcanize < $*.tex > $*.html

## for the web stuff ## 

www web :  
	${MAKE} doitall | tee | tee 2>&1 log.allwww

prepare : 
	echo "Let's make the software palatable ..."
	echo "Let's make some space ..."
	if [ -d ${SCRDIR} ]; then /bin/rm -rf ${SCRDIR}; fi; mkdir ${SCRDIR};
	if [ -d ${WWWDIR} ]; then /bin/rm -rf ${WWWDIR}; fi; mkdir ${WWWDIR};
	echo "Let's create our own work space and clean it ... "
	mkdir             ${SCRDIR}/jest
	cp -R ${SRCDIR}/* ${SCRDIR}/jest
	cd    ${SCRDIR}/jest/adm/redoc; ${MAKE} allclean
	cd    ${SCRDIR}/jest          ; find . -name '[A-Z]*' \( ! -name Fig \) \( ! -name Data \)  -type d -exec /bin/rm -rf {} ';'

tar : 
	echo "Let's tar all of jest"
	cd    ${SCRDIR}        ; tar -cvf    jest.tar  ./jest 
	cd    ${SCRDIR}        ; ${GZIP}     jest.tar 
	echo "Let's tar individual packages ..."
	cd    ${SCRDIR}/jest   ; tar -cvf  ../jam.tar      ./jam 
	cd    ${SCRDIR}        ; ${GZIP}     jam.tar; 
	cd    ${SCRDIR}/jest   ; tar -cvf  ../juice.tar    ./juice 
	cd    ${SCRDIR}        ; ${GZIP}     juice.tar; 
	cd    ${SCRDIR}/jest   ; tar -cvf  ../sep.tar      ./sep 
	cd    ${SCRDIR}        ; ${GZIP}     sep.tar; 
	cd    ${SCRDIR}/jest   ; tar -cvf  ../rsf.tar      ./rsf 
	cd    ${SCRDIR}        ; ${GZIP}     rsf.tar; 
	cd    ${SCRDIR}/jest   ; tar -cvf  ../isf.tar      ./isf 
	cd    ${SCRDIR}        ; ${GZIP}     isf.tar; 
	cd    ${SCRDIR}/jest   ; tar -cvf  ../gag.tar      ./gag 
	cd    ${SCRDIR}        ; ${GZIP}     gag.tar; 
	cd    ${SCRDIR}/jest   ; tar -chvf ../doc.tar     ./jdocs 
	cd    ${SCRDIR}        ; ${GZIP}     doc.tar; 
	cd    ${SCRDIR}/jest   ; tar -cvf  ../adm.tar      ./amd
	cd    ${SCRDIR}        ; ${GZIP}     adm.tar; 
	echo "Let's make the document"
	#cd    ${SCRDIR}/jest/intro/paper; ${MAKE} paper.ps; 
	#cd    ${SCRDIR}/jest/intro/paper; mv      paper.ps ${SCRDIR}
	#cd    ${SCRDIR}                 ; ${GZIP} paper.ps; 
	#echo "I wish I had an html version"

install:
	echo "Let's copy all gzipped files"
	cp    ${SCRDIR}/*.gz ${WWWDIR} 
	#echo "Let's copy the index and faq file ..."
	#cp index.html ${WWWDIR}
	#cp   faq.html ${WWWDIR}

clean : jclean

include ${SEPINC}/SEP.bottom

