# $Id: Makefile 60 2022-10-05 22:42:54Z karl $
# Makefile for Eplain manuals.  This file is public domain.

MAKEINFO        = makeinfo
MAKEINFO_FLAGS  = 
MAKEINFO_HTML   = $(MAKEINFO_FLAGS) --html \
                 -c TOP_NODE_UP_URL=https://tug.org/texinfohtml/

# for quieter TeX
TEXFOT          = texfot

TEXI2FLAGS      = -b -I ..

TEXI2PDF        = $(TEXFOT) texi2dvi
TEXI2PDF_FLAGS  = --pdf $(TEXI2FLAGS)

TEXI2DVI        = $(TEXFOT) texi2dvi
TEXI2DVI_FLAGS  = $(TEXI2FLAGS)

DVIPS           = dvips
DVIPS_FLAGS     = -t letter

LATEX           = latex
LATEX_FLAGS     = 

BIBTEX          = bibtex
BIBTEX_FLAGS    = 

LATEX2HTML      = latex2html
LATEX2HTML_FLAGS= 

PDFTOPS         = pdftops
PDFTOPS_FLAGS   = 

PDFCROP         = pdfcrop
PDFCROP_FLAGS   = 

CONVERT         = convert
CONVERT_FLAGS   = -quality 75

GROFF           = groff
GROFF_PDF_FLAGS = -man -t -rS11

PS2PDF          = ps2pdf
PS2PDF_FLAGS    = -sPAPERSIZE=a4

DEMO_DIR   = ../demo
PDF_DEMOS  = xhyper.pdf lscommnt.pdf
EPS_DEMOS  = $(PDF_DEMOS:%.pdf=%.eps)
JPG_DEMOS  = $(PDF_DEMOS:%.pdf=%.jpg)

.PHONY: all doc dvi ps pdf html info
.PHONY: clean mostlyclean distclean maintainer-clean
.DELETE_ON_ERROR:


all: doc ../INSTALL

doc alldoc: dvi pdf html info

dvi: eplain.dvi
eplain.dvi: *.texi $(EPS_DEMOS)
	$(TEXI2DVI) $(TEXI2DVI_FLAGS) eplain.texi

ps: eplain.ps
eplain.ps: eplain.dvi
	$(DVIPS) $(DVIPS_FLAGS) $< -o

pdf: eplain.pdf eplain.man1.pdf
eplain.pdf: *.texi $(PDF_DEMOS)
	$(TEXI2PDF) $(TEXI2PDF_FLAGS) eplain.texi
eplain.man1.pdf: eplain.1
	$(GROFF) $(GROFF_PDF_FLAGS) $< | $(PS2PDF) $(PS2PDF_FLAGS) - $@

html: eplain.html eplain/index.html
eplain.html eplain/index.html: *.texi $(JPG_DEMOS)
	$(MAKEINFO) $(MAKEINFO_HTML) eplain.texi
	$(MAKEINFO) $(MAKEINFO_HTML) --no-split eplain.texi
	cp $(JPG_DEMOS) eplain

info: eplain.info
eplain.info: *.texi $(DEMO_DIR)/*.tex
	$(MAKEINFO) $(MAKEINFO_FLAGS) --no-split eplain.texi

../INSTALL: install.texi
	$(MAKEINFO) $(MAKEINFO_FLAGS) --no-number-section \
	  --no-warn --no-headers eplain.texi -o - \
	  | sed -n '/^Installation/,/^Invoking/'p \
	  | sed '$$d' > ../INSTALL

# Images for the "Demo files" section of the manual.
$(PDF_DEMOS): $(DEMO_DIR)/xhyper.tex $(DEMO_DIR)/lscommnt.tex
	$(MAKE) -C $(DEMO_DIR) $@
	$(PDFCROP) $(PDFCROP_FLAGS) $(DEMO_DIR)/$@ $@

$(EPS_DEMOS): %.eps: %.pdf
	$(PDFTOPS) $(PDFTOPS_FLAGS) -eps $<

$(JPG_DEMOS): %.jpg: %.pdf
	$(CONVERT) $(CONVERT_FLAGS) $< $@

#
# Clean-up.
#
clean mostlyclean:
	rm -f eplain.?? eplain.{aux,cps,fns,log,toc}
	rm -f $(PDF_DEMOS)
	rm -f $(EPS_DEMOS)

distclean: clean
	rm -rf eplain.dvi eplain

maintainer-clean: distclean
	rm -f $(JPG_DEMOS)
	rm -f ../INSTALL eplain.info eplain.pdf eplain.html eplain.man1.pdf

svr:
	svn revert eplain.info eplain.pdf
