/*
You are in a Master directory for an electronic report.

To make a new report,
	Change file sep??.bib to contain fixed page numbers in old report.
	cp sep??.bib  /homes/sep/database/bib
	cd  /homes/sep/database/bib
		cake SEP.bib
	cd back to ThisOldDocument/Adm
	cp ../{Adm,Dvi,Photos}  New Document
	cd NewDocument/Adm
	Hand edit the following files:
		document.name   Put in your document name.
		tpage.tex 	Make your titlepage,
		copyr.tex 	Make your copyright page
		phone.tex	Make your phone number page
		bios.tex	Make your biographies
		Cakefile	Needs no changes, we hope!

Tell people to test their papers:
	cd this directory (Adm)
        Testmypaper  papername  

For the first several builds of your new report
		cake wipe
		cake FirstBuild

	which is synonymous to the steps 
		cake filemaker
			(makes  all.tex  toc.tex  sep??.bib)
		cake testall
		cake install-to-read

Later, hand edit (keep in sync) the files below, eg. order your chapters,
	toc.tex
	all.tex

For later builds of your new report
		cake testall
		cake install-to-read


To put the report on CDROM, make sure you generate all bib databases,
	cake bibfiles


The following scripts (in this directory) are run by this cakefile
        Testallpaper
		test all papers individually and report results
		in files  paperlist.bad  paperlist.good 
        CreateAll
		CreateAll reportnumber >allpapers.tex
        CreateToc
		CreateToc reportnumber >tableofcontents.tex
		   creates automatically a table of contents,
        CreateTest	(don't run me)

*/

/* get the document name from the file */
#include "document.name"
#define TEXPROPTS -v -bib
#include <SEP.defs>

/* Consider the report final and do not remove crucial files */

/* #define FINAL */

/* get the report number */
#define REPORTNO `grep "#define BOOK " document.name|sed "s/\#define BOOK //"`

/* define the location of the document */
#define REPLOC `echo $cwd`

default&:  install-to-read

FirstBuild&:  testall install-to-read

filemaker&: toc.tex all.tex 
	cake sep/**/REPORTNO/**/.bib

testall&:
	Testallpaper

#ifdef FINAL
wipe&:
	@echo Cannot remove toc.tex all.tex sep/**/REPORTNO/**/.bib
	@echo and paperlist.bad paperlist.good
	@echo since FINAL
#else
wipe&:
	echo "not FINAL"
	-rm -f toc.tex all.tex sep/**/REPORTNO/**/.bib \*.aux \*.dvi \*.log
	-rm -f paperlist.bad paperlist.good
#endif


$		/* make the report and install it and the reading shell */
install-to-read&: BOOK.dvi OFFBINDIR/BOOK
	makewritable ../Dvi/BOOK.dvi
	cp BOOK.dvi ../Dvi/BOOK.dvi

$				/* page automatically through the report */
pager&:
        BOOK &
        xtexkeys char=f reset=1g cnt=310 time=3

$					/* install the reading shell */
OFFBINDIR/BOOK&: 
	makewritable OFFBINDIR/BOOK
	cp BOOK.csh OFFBINDIR/BOOK
	chmod 755 OFFBINDIR/BOOK

$					/* create the report dvi file */
BOOK.dvi:
	makewritable all.tex
	makewritable BOOK.dvi
	-rm *.aux
	-rm ../\*/\*.aux
	texpr -l -v -bib -d all
	mv all.dvi BOOK.dvi
	chmod a+rw BOOK.dvi

$					/* create the table of contents file */
toc.tex:  if not exist toc.tex
	CreateToc REPORTNO >toc.tex

toc.tex:  if exist toc.tex
	cp toc.tex toc.tex.bak

$					/* create the all.tex file */
all.tex: if not exist all.tex
	CreateAll REPORTNO >all.tex

all.tex: if exist all.tex
	cp all.tex all.tex.bak

$			/* extract all bibtex entries used in the report,
$			necessary to put on CD */
bibfiles&: SEP.bib MISC.bib GEOTLE.bib SEGCON.bib EAEG.bib SEGBKS.bib ASEGC.bib BOOK.bib
	echo "please check each bib file again"
	echo "take out possible error messages"

$			/* create the bibliography file,
$			for later inclusion into the SEP.bib databse */
localbib&: BOOK.bib


sep%.bib:
	echo " creating a preliminary bibtex file from all paper directories"
	-cp BOOK.bib BOOK.bib.bak
	CreateBib % > sep%.bib
	mv sep%.bib REPORTNO.bib

$			/* extract bibliography entries used in this report */
%.bib: 
	bibextract % >%.bib


$				/* in order to force page reversal */

print&: print100 print200 print300 print400 

print100 &:
	texpr -l printer=lw from=1 to=100 REPLOC/../Dvi/BOOK.dvi

print200 &:
	texpr -l printer=lw from=101 to=200 REPLOC/../Dvi/BOOK.dvi

print300 &:
	texpr -l printer=lw from=201 to=300 REPLOC/../Dvi/BOOK.dvi

print400 &:
	texpr -l printer=lw from=301 to=400 REPLOC/../Dvi/BOOK.dvi 

print500 &:
	texpr -l printer=lw from=401 to=500 REPLOC/../Dvi/BOOK.dvi 

/*
print&: REPLOC/../Dvi/BOOK.dvi 
	/usr/local/bin/dvips -r REPLOC/../Dvi/BOOK.dvi -o /scr/USER/BOOK.ps
	/usr/ucb/lpr -h -s -Psparc /scr/USER/BOOK.ps
*/

print100s&:  
	texpr printer=sparc from=1 to=100 REPLOC/../Dvi/BOOK.dvi 

print200s&:  
	texpr printer=sparc from=101 to=200 REPLOC/../Dvi/BOOK.dvi 

print300s&:  
	texpr printer=sparc from=201 to=300 REPLOC/../Dvi/BOOK.dvi 

print400s&:  
	texpr printer=sparc from=301 to=400 REPLOC/../Dvi/BOOK.dvi 

print500s&:  
	texpr printer=sparc from=401 to=500 REPLOC/../Dvi/BOOK.dvi 

print_%:
	texpr -s -2 -bib %.tex printer=sparc

agenda&:
	texpr -l TEXPROPTS agenda.tex

all&: 
	texpr TEXPROPTS -l  all.tex

bios&:	
	texpr TEXPROPTS -s bios.tex

phone&:	
	texpr TEXPROPTS -s ph.tex

pub&:	
	texpr TEXPROPTS -s pub.tex

toc&:	
	texpr TEXPROPTS -s toc.tex

print-toc&:	
	texpr -l -2 to=4 printer=sparc all.tex

tpage&:	
	texpr TEXPROPTS -s tpage.tex

/*  make something happen when the bio figures are pressed */

bio-steve-1.action&: Sound/steve-1.sound if exist /usr/demo/SOUND/play
	/usr/demo/SOUND/play -i -v 70 Sound/steve-1.sound 

bio-%.action&: Sound/%.sound if exist /usr/demo/SOUND/play
	/usr/demo/SOUND/play -i -v 100 Sound/%.sound 

bio-steve-1.action&: Sound/steve-1.sound if not exist /usr/demo/SOUND/play and exist /dev/audio
	cat Sound/steve-1.sound >/dev/audio

bio-%.action&: Sound/%.sound if not exist /usr/demo/SOUND/play and exist /dev/audio
	cat Sound/%.sound >/dev/audio

clean&: texclean

#include <SEP.prog.rules>
#include <SEP.obj.rules>
#include <SEP.idoc.rules>
