1PSFILES=ip-cref.ps ip-tunnels.ps api-ip6-flowlabels.ps ss.ps nstat.ps arpd.ps rtstat.ps
2# tc-cref.ps
3# api-rtnl.tex api-pmtudisc.tex api-news.tex
4# iki-netdev.ps iki-neighdst.ps
5
6
7LATEX=latex
8DVIPS=dvips
9SGML2DVI=sgml2latex --output=dvi
10SGML2HTML=sgml2html -s 0
11LPR=lpr -Zsduplex
12SHELL=bash
13PAGESIZE=a4
14PAGESPERPAGE=2
15
16HTMLFILES=$(subst .sgml,.html,$(shell echo *.sgml))
17DVIFILES=$(subst .ps,.dvi,$(PSFILES))
18PDFFILES=$(subst .ps,.pdf,$(PSFILES))
19
20
21all: pstwocol
22
23pstwocol: $(PSFILES)
24
25html: $(HTMLFILES)
26
27dvi: $(DVIFILES)
28
29pdf: $(PDFFILES)
30
31print: $(PSFILES)
32	$(LPR) $(PSFILES)
33
34%.dvi: %.sgml
35	$(SGML2DVI) $<
36
37%.dvi: %.tex
38	@set -e; pass=2; echo "Running LaTeX $<"; \
39	while [ `$(LATEX) $< </dev/null 2>&1 | \
40		 grep -c '^\(LaTeX Warning: Label(s) may\|No file \|! Emergency stop\)'` -ge 1 ]; do \
41		if [ $$pass -gt 3 ]; then \
42			echo "Seems, something is wrong. Try by hands." ; exit 1 ; \
43		fi; \
44		echo "Re-running LaTeX $<, $${pass}d pass"; pass=$$[$$pass + 1]; \
45	done
46
47#%.pdf: %.tex
48#	pdflatex $<
49%.pdf: %.ps
50	ps2pdf $<
51
52%.ps: %.dvi
53	$(DVIPS) $< -o $@
54
55%.html: %.sgml
56	$(SGML2HTML) $<
57
58install:
59	install -m 0644 $(shell echo *.tex) $(DESTDIR)$(DOCDIR)
60	install -m 0644 $(shell echo *.sgml) $(DESTDIR)$(DOCDIR)
61
62clean:
63	rm -f *.aux *.log *.toc $(PSFILES) $(DVIFILES) *.html
64