SRCDIR=isodate
INSTALLDIR=`kpsewhich --expand-path='$$TEXMFLOCAL'`/tex/latex/isodate
DOCDIR=`kpsewhich --expand-path='$$TEXMFLOCAL'`/doc/latex/isodate
VERSION=`grep '^\\\\def\\\\fileversion' isodate.dtx | sed 's/^\\\\def\\\\fileversion{\\(.*\\)\\.\\(.*\\)}/\\1_\\2/'`

.SUFFIXES: .sty .ins .dtx .dvi .ps .pdf

LANG= danish.idf english.idf french.idf german.idf norsk.idf swedish.idf

.ins.sty:
	latex $<

.dtx.dvi:
	latex $<
	latex $<
	makeindex -s gind.ist $(*D)/$(*F)
	makeindex -s gglo.ist -o $(*D)/$(*F).gls $(*D)/$(*F).glo
	latex $<

.dvi.ps:
	dvips -o $(*D)/$(*F).ps $(*D)/$(*F)

.dtx.pdf:
	pdflatex $<

all: isodate isodateo isodate.dvi isodateo.dvi testdate.dvi tst ausgabe

isodate.sty: isodate.ins isodate.dtx

testdate.dvi:
	latex testdate

tst:
	latex tstlang

isodate: isodate.sty $(LANG)

isodateo: isodateo.sty


danish.idf: isodate.ins
	latex isodate.ins
english.idf: isodate.ins
	latex isodate.ins
french.idf: isodate.ins
	latex isodate.ins
german.idf: isodate.ins
	latex isodate.ins
swedish.idf: isodate.ins
	latex isodate.ins

substr:
	@if [ -z `kpsewhich substr.sty` ]; then \
	echo; echo "Error installing isodate:"; \
	echo "This version of isodate needs the package substr.sty"; \
	echo "which cannot be found in your system."; \
	echo; \
	echo "Please download it from CTAN:/macros/latex/contrib/supported/substr/."; \
	echo "One of the possible CTAN nodes is ftp.dante.de."; \
	echo "Try to execute make after installing substr.sty again."; \
	echo; exit; fi


clean:
	@-rm -f isodate.{glo,gls,idx,ilg,ind,aux,log,toc}
	@-rm -f isodateo.{glo,gls,idx,ilg,ind,aux,log,toc}
	@-rm -f testdate.{log,aux}
	@-rm -f *~

distclean: clean
	@-rm -f $(LANG)
	@-rm -f isodate.{sty,dvi,ps,pdf}
	@-rm -f isodateo.{sty,dvi,ps}
	@-rm -f testdate.{dvi,ps}
	@-rm -f tstlang.log

tar:	all clean
	echo Lege isodate-$(VERSION).tar.gz an
	-rm -f isodate-$(VERSION).tar.gz
	tar czhCf .. isodate-$(VERSION).tar.gz isodate/install.{sh,bat} \
	  isodate/README isodate/Makefile \
	  isodate/isodate.{dtx,ins,dvi} \
	  isodate/isodateo.{dtx,ins,dvi} \
	  isodate/testdate.{dvi,tex} \
	  isodate/tstlang.tex isodate/testisodate_without_babel.tex \
	  isodate/isodate.xml


install: all
	if [ ! -d $(INSTALLDIR) ]; then mkdirhier $(INSTALLDIR); fi
	if [ ! -d $(DOCDIR) ]; then mkdirhier $(DOCDIR); fi
	install -m644 *.sty *.idf $(INSTALLDIR)
	install -m644 isodate.dvi $(DOCDIR)
	texhash

ausgabe:
	@echo "Please copy isodate.sty, *.idf, and isodateo.sty to a directory"
	@echo "in the LaTeX search path"



