## Define the appropriate configuration variables.

PACKAGE = /fsys2/u/usystem/software/u++-4.7

## Include the architecture dependent definitions.

.INCLUDE : ${PACKAGE}/CONFIG

## Define the path names of important directories.

SRCDIR = ${PACKAGE}/doc/refman
EXPDIR = ${PACKAGE}/src/examples

## Define some of the commands.

TeXLIB = .:../TeXmacros:
Latex  = TEXINPUTS=${TeXLIB} && export TEXINPUTS && latex
Bibtex = TEXINPUTS=${TeXLIB} && export TEXINPUTS && bibtex

## Define the source for the documents.

SOURCE = ${SRCDIR}/{\
uC++ \
}.tex

FIGURES = ${SRCDIR}/{\
RWEx1 \
MonAcceptBB \
MonConditionBB \
TaskAcceptBB \
SemaphoreBB \
BinaryInsertionSort \
LOOK \
File \
CyclicFullCoroutine \
uC++MutexObject \
DirectComm \
SimpleIOCluster \
ComplexIOCluster \
ClientServerUnconnected \
ClientServerConnected \
RunTimeStructure \
ReadyQueue \
DSLNodes \
DSLStack \
DSLQueue \
DSLSequence \
}.tex

PROGRAMS = ${SRCDIR}/{\
BinaryInsertionSort \
RWEx1 \
MonAcceptBB \
MonConditionBB \
TaskAcceptBB \
SemaphoreBB \
LOOK \
ClientUNIX2 \
ServerUNIX2 \
ClientINET \
ServerINET \
}.tex

## Define the documents that need to be made.

DOCUMENTS = ${SRCDIR}/uC++.ps

# Directives #

all : ${DOCUMENTS};

clean :
	rm -f *.zzz *.bbl *.aux *.dvi *.idx *.ilg *.ind *.log *.toc *.blg ${SOURCE} ${FIGURES} ${PROGRAMS} ${DOCUMENTS}

install : ${INSTALLDOCDIR} ${DOCUMENTS}
[
	for file in ${DOCUMENTS:f} ; do
		if cmp -s $$file ${INSTALLDOCDIR}/$$file ; then . ; else ${INSTALL} $$file ${INSTALLDOCDIR}/$$file ; fi
	done
]

# File Dependencies #

${INSTALLDOCDIR} :
	mkdir $@

${DOCUMENTS} : ${DOCUMENTS:db}.dvi
	dvips $< -o $@

${DOCUMENTS:db}.dvi : Makefile ${FIGURES} ${PROGRAMS} ${SOURCE} ${DOCUMENTS:db}.idx ${DOCUMENTS:db}.bbl
	${Latex} $*.tex
	if fgrep -s "Label(s) may have changed. Rerun" $*.log ; then ${Latex} $*.tex ; else . ; fi
	makeindex $*.idx
	${Latex} $*.tex		% to get index title in toc

${DOCUMENTS:db}.idx : ${DOCUMENTS:db}.tex
	if [ ! -r $*.ind ] ; then cp /dev/null $*.ind ; fi

${DOCUMENTS:db}.bbl : Makefile
	if [ ! -r $*.aux ] ; then ${Latex} $*.tex ; fi
	-${Bibtex} $*
	${Latex} $*.tex
	-${Bibtex} $*

# This recipe is done only on plg (architecture master machine) because of the
# additional preprocessing pass over the document to handle lgrind macros.

HOSTNAME = $(shell hostname)
.IF ${HOSTNAME} == plg2.math
${DOCUMENTS:db}.tex : ${DOCUMENTS:db}.pretex
	/u/pabuhr/bin/lgrind -e -d /u/pabuhr/lib/vgrindefs -lu++ -tab 4 $< > $@
.END

## Define the default recipes.

%.tex	: ${EXPDIR}/$$(@:f:db).cc
	/u/pabuhr/bin/lgrind -i -d /u/pabuhr/lib/vgrindefs -lu++ -tab 4 $< > $@

%.tex	: ${EXPDIR}/IO/$$(@:f:db).cc
	/u/pabuhr/bin/lgrind -i -d /u/pabuhr/lib/vgrindefs -lu++ -tab 4 $< > $@

%.tex	: %.fig
	fig2dev -L eepic $< > $@

## Local Variables: ##
## compile-command: "dmake" ##
## End: ##
