FORMAT		= latex
prefix		= /t/src/i
TEXMFMAIN       = $(prefix)/share/texmf
FMTDIR          = $(shell echo $${TEXMFMAIN-`kpsexpand '$$TEXMFMAIN'`}/web2c)
TEXDIR		= $(TEXMFMAIN)/tex/$(FORMAT)/$(PACKAGE)
TEXMISC		= $(TEXMFMAIN)/tex/$(FORMAT)/misc
DOCDIR		= $(TEXMFMAIN)/doc/$(FORMAT)/$(PACKAGE)
BSTDIR		= $(TEXMFMAIN)/bibtex/bst/$(PACKAGE)
BSTMISC		= $(TEXMFMAIN)/bibtex/bst/misc
ISTDIR		= $(TEXMFMAIN)/makeindex
ISTMISC		= $(TEXMFMAIN)/makeindex
DOCMISC		= $(TEXMFMAIN)/doc/$(FORMAT)/styles
DIRS		= $(TEXDIR) $(DOCDIR) $(FMTDIR)
BIN		= $(prefix)/bin
MAN		= $(prefix)/man/man1

DIRPERMS	= 755
INPUTS		= $(TMPINPUTS) $(EXTRAINPUTS)
DOC		= $(TMPDOC) $(EXTRADOC)
TMPFILES	= $(TMPINPUTS) $(TMPDOC) $(JUNK)
default: unpack

%.dvi:	%.tex
	latex $<
	mkindex $*
	latex $<
	latex $<

%.dvi:	%.drv
	latex $<
	mkindex $*
	latex $<
	latex $<

%.dvi:	%.dtx
	latex $<
	mkindex $*
	latex $<
	latex $<


$(INPUTS):
	latex tetex.ins

clean:
	rm -f $(TMPFILES)
	rm -f *.log *.aux *.dvi *.idx *.lof *.lot
	rm -f *.toc *.ilg *.ind *.glo *.gls

install: unpack doc formats
	@../install-files $(TEXDIR) $(TEXMISC) $(INPUTS)
	@../install-files $(DOCDIR) $(DOCMISC) $(DOC)
	@../install-files $(FMTDIR) $(FMTDIR)  $(FORMATS)
	@../install-files $(BSTDIR) $(BSTMISC) $(BSTFILES)
	@../install-files $(ISTDIR) $(ISTMISC) $(ISTFILES)

rehash:
	texhash

update:
	cp -auvf $(SRCDIR)/* .

unpack: $(INPUTS)
doc:	unpack $(DOC)
formats:	$(FORMATS)

.PHONY: unpack install doc rehash formats
