TOOLS=	../tools

CHAPTERS= ch01.t ch02.t ch03.t ch04.t ch05.t ch06.t ch07.t ch08.t \
	  ch09.t ch10.t ch11.t ch12.t ch13.t ch14.t ch15.t ch16.t ch17.t ch18.t

APPENDIXES= appa.t appc.t appd.t appe.t appf.t appg.t

AUX=	Makefile page.awk massageps.el utp.t utp.mac README

POSTSCRIPT= ${CHAPTERS:%.t=ps/%.ps} ${APPENDIXES:%.t=ps/%.ps}

.SUFFIXES: .t .ps .txt .html .ascii .pdf

all: ps book ps/utp.ps

${POSTSCRIPT}: ${@:ps/%.ps=%.t} utp.mac
	groff -pt -ms ${@:ps/%.ps=%.t} > $@

ps/utp.ps:	utp.t utp.mac
	groff -pt -ms utp.t > $@

book:	ps/book.ps

ps/book.ps:  ${POSTSCRIPT} massageps.el
	cat ${POSTSCRIPT} > $@
	emacs -batch $@ -l $F/massageps.el -f massageps -f exit
	rm ps/book.ps~

info:
	@echo ${POSTSCRIPT}
	
ps:
	mkdir $@

# This is a target because we may want to modify the source.
massageps.el:
	cp ${TOOLS}/massageps.el .

clean:
	rm -rf ps *~ Make.log UTP.tar.gz

dist UTP.tar.gz:
	tar czvf UTP.tar.gz ${CHAPTERS} ${APPENDIXES} ${AUX}