1MANFILES = asy.1 xasy.1x
2ASYFILES = $(filter-out $(wildcard latexusage-*.asy),$(wildcard *.asy))
3SOURCE = asymptote.texi version.texi options
4ASY = ../asy -dir ../base -config "" -render=0
5DOCFILES = asymptote.pdf asy-latex.pdf CAD.pdf TeXShopAndAsymptote.pdf \
6           asyRefCard.pdf
7
8docdir = $(DESTDIR)@docdir@
9infodir = $(DESTDIR)@infodir@
10datarootdir = @datarootdir@
11INSTALL = @INSTALL@
12TEXI2DVI = @TEXI2DVI@
13PERL5LIB = ./
14
15export docdir infodir INSTALL PERL5LIB
16
17all:    doc
18
19asy-latex.pdf:
20	pdflatex asy-latex.dtx
21
22asymptote.sty:
23	pdflatex asy-latex.dtx
24
25dvi:	doc asymptote.dvi
26
27doc:	$(DOCFILES) asy.1 faq
28	cd png && $(MAKE) all
29
30manpage: $(MANFILES)
31
32man:	$(DOCFILES) manpage
33	cd png && $(MAKE) asymptote.info
34
35faq:
36	cd FAQ && $(MAKE) faq
37
38%.eps:	%.asy
39	$(ASY) -f eps $<
40
41%.pdf:	%.asy
42	$(ASY) -f pdf -noprc $<
43
44latexusage.pdf: latexusage.tex asymptote.sty
45	rm -f latexusage-*
46	rm -f latexusage.pre
47	rm -f latexusage.aux
48	pdflatex latexusage
49	$(ASY) -noprc latexusage-*.asy
50	pdflatex latexusage
51
52options: ../settings.cc
53	$(ASY) -h 2>&1 | grep -iv Asymptote > options
54
55asy.1: options asy.1.begin asy.1.end
56	cat options | grep \^- | \
57	sed -e "s/-\(.*\)  \([a-zA-Z0-9].*\)/.TP\n.B -\1\n\2\./" | \
58	sed -e "/^.B/ s/-/\\\\-/g" | cat asy.1.begin - asy.1.end > asy.1
59
60asymptote.dvi: $(SOURCE) $(ASYFILES:.asy=.eps) latexusage.pdf
61	ln -sf asymptote.texi asymptote_.texi
62	-$(TEXI2DVI) asymptote_.texi
63	mv asymptote_.dvi asymptote.dvi
64
65asymptote.pdf: $(SOURCE) $(ASYFILES:.asy=.pdf) latexusage.pdf
66	-$(TEXI2DVI) --pdf asymptote.texi
67
68CAD.pdf: CAD.tex CAD1.eps
69	pdflatex CAD
70	pdflatex CAD
71	pdflatex CAD
72
73TeXShopAndAsymptote.pdf: TeXShopAndAsymptote.tex
74	pdflatex TeXShopAndAsymptote
75	pdflatex TeXShopAndAsymptote
76
77asyRefCard.pdf: asyRefCard.tex
78	pdftex asyRefCard
79
80clean: FORCE
81	-rm -f asy-latex.{aux,idx,ins,log,toc}
82	-rm -f $(ASYFILES:.asy=.pdf)
83	-rm -f *.eps latexusage.{dvi,eps,pdf,log,aux,*.eps} latexusage-* \
84            latexusage.pre
85	-rm -f \
86            {asymptote,asymptote_}.{aux,cp,cps,dvi,fn,info,ky,log,pg,toc,tp,vr}
87	-rm -f asymptote_.texi
88	-rm -f {CAD,TeXShopAndAsymptote,asyRefCard}.{aux,dvi,log,toc}
89	-rm -f options asy.1
90	cd png && $(MAKE) clean
91
92install-man:
93	${INSTALL} -d -m 755 $(docdir) $(mandir)/man1
94	${INSTALL} -p -m 644 $(DOCFILES) $(docdir)
95	${INSTALL} -p -m 644 $(MANFILES) $(mandir)/man1
96
97install: man faq install-man
98	cd png && $(MAKE) install
99	cd FAQ && $(MAKE) install
100
101install-prebuilt: install-man options
102	touch png/asymptote.info
103	cd png && $(MAKE) install
104	cd FAQ && $(MAKE) install-prebuilt
105
106install-all: $(DOCFILES) $(MANFILES) faq install-man
107	cd png && $(MAKE) install-all
108	cd FAQ && $(MAKE) install-info
109
110uninstall: uninstall-all
111
112uninstall-all:
113	cd png && $(MAKE) uninstall
114	cd FAQ && $(MAKE) uninstall
115	-cd $(mandir)/man1 && rm -f $(MANFILES)
116	-rm -f $(addprefix $(docdir)/,$(DOCFILES))
117
118distclean: FORCE clean
119	-rm -f version.texi Makefile
120	-rm -f $(DOCFILES)
121	cd png && $(MAKE) distclean
122	cd FAQ && $(MAKE) distclean
123FORCE:
124
125Makefile: Makefile.in
126	cd ..; config.status
127