MKDIR=mkdir
COPY=cp
CHDIR=cd
ZIP=zip -9
INSTALLDIRVAR=TEXMFMAIN
all: hyperref test

hyperref: unpack documentation

unpack:
	latex hyperref.ins

hyperref.drv: unpack

documentation: hyperref.drv
	latex hyperref.dtx
	makeindex -s gind hyperref
	latex hyperref.dtx
	makeindex -s gind hyperref
	latex hyperref.dtx

test: test.nodir
test.nodir:
	$(CHDIR) test; latex test0
	$(CHDIR) test; makeindex test0
	$(CHDIR) test; latex test0

install: unpack
	( \
	TEXMF=`kpsewhich -expand-var '$$$(INSTALLDIRVAR)'`; \
	echo installing to $${TEXMF}/tex/latex/hyperref; \
	$(MKDIR) $${TEXMF}/tex/latex/hyperref; \
	$(COPY) *.sty *.def htex4ht.cfg $${TEXMF}/tex/latex/hyperref \
	)

clean:
	-rm *.aux *.toc *.idx *.drv *.dvi *.log *.rep *.lof *.brf *.tmp *.ist *.ilg *.ind *.out *.css *.html
	-$(CHDIR) test; rm *.aux *.log *.dvi *.toc *.lot *.lof *.idx *.ilg *.ind *.out *.brf
	-rm nameref.sty 
	-rm backref.sty 
	-rm hyperref.sty 
	-rm *.def htex4ht.cfg *.otc *.idv *.lg *.xref


distrib:
	(cd ..; $(ZIP) hyperref \
	hyperref/*.txt\
	hyperref/ANNOUNCE \
	hyperref/ChangeLog \
	hyperref/hyperref.dtx \
	hyperref/nameref.dtx \
	hyperref/backref.dtx \
	hyperref/hyperref.ins \
	hyperref/Makefile \
	hyperref/xr-hyper.sty \
	hyperref/minitoc-hyper.sty \
	hyperref/ntheorem-hyper.sty \
	hyperref/hyl* \
	hyperref/test/Makefile \
	hyperref/test/test*.tex \
	hyperref/test/bit.tex \
	hyperref/test/testbib.bib \
	hyperref/test/testbib.bbl \
	hyperref/test/testurl.bib \
	hyperref/test/testurl.bbl \
	hyperref/test/test0.dvi \
	hyperref/test/b*.png \
	hyperref/test/phys*.jpg \
	hyperref/test/test7.pdf \
	hyperref/test/picture.* \
	hyperref/test/hog.* \
	hyperref/test/seminar.con \
	)
	(cd ..; $(ZIP) hyperdoc \
	hyperref/doc/options.tex \
	hyperref/doc/manual.pdf \
	hyperref/doc/slides.pdf \
	hyperref/doc/paper.pdf \
	)

checks:
	for what in test*tex ;\
	do \
	 pdflatex $$what; pdflatex $$what; latex $$what; latex $$what ;\
	done
