# Makefile for the various bits of Eplain's documentation.

# For `install'.
prefix = /usr/local
infodir = $(prefix)/info

INSTALL_DATA = install -m 0664
MAKEINFO = makeinfo
TEX = tex '\nonstopmode \input'
TEXINDEX = texindex

all: eplain.info eplain.dvi

eplain.dvi: eplain.cps
	$(TEX) eplain.texi
eplain.cps: eplain.cp
	$(TEXINDEX) eplain.??
eplain.cp: *.texi
	$(TEX) eplain.texi

eplain.info: *.texi
	$(MAKEINFO) eplain.texi

install: eplain.info
	for i in eplain.info*; do $(INSTALL_DATA) $$i $(infodir); done

update:
	emacs -batch -l update.el

# Separate the installation instructions into a separate file, for the
# benefit of people who don't want to look at the info file.
INSTALL: eplain.info
	sed -n '/Node: Installation,/,/change the pathnames./p' eplain.info*\
	  | tr -d '\037' > $@

# `make dist' should only be called from the top-level Makefile, as it
# depends on $(version), at least.
distdir = ../eplain-$(version)/doc
dist:
	cp -p $(texdist)/bibtex/btxdoc.tex $(distdir)
	cp -p $(plain)/texinfo.tex $(distdir)
	ln Makefile *.texi *info* eplain.??s $(distdir)
	(cd $(distdir); \
         add-version $(version) eplain.texi; \
         add-date eplain.texi; \
         $(MAKE) INSTALL eplain.cps distclean)
	mv $(distdir)/INSTALL $(distdir)/..

distclean clean mostlyclean:
	rm -f eplain.?? *.dvi *.log

realclean: distclean
	rm -f *.info* eplain.??? INSTALL
