# programs
JADE = jade

# directory for PNG versions of equations
FIGDIR = figures

# other files 
DOC = sampler
DSL = sample-both.dsl
MATHSS = TeXMath.dsl
HMATHSS = HTMLMath.dsl

all: pdf html

# to make PDF from tex source, run pdfjadetex 3 times
pdf: $(DOC).tex jadetex.cfg
	pdfjadetex $(DOC)
	pdfjadetex $(DOC)
	pdfjadetex $(DOC)

# to make the tex file, run jade and then "unescape" the math
$(DOC).tex: $(DOC).sgml $(DSL) $(MATHSS)
	$(JADE) -t tex -d $(DSL)\#print $(DOC).sgml
	./unescape_math.pl $(DOC).tex

# to make HTML, make PNG images out of the equations and
# process the SGML source with jade
html: $(DOC).sgml $(DSL) $(HMATHSS) 
	cd html_out && mkdir -p $(FIGDIR) && \
	$(JADE) -t sgml -ihtml -V nochunks -d ../$(DSL)\#html \
	../$(DOC).sgml > $(DOC).html && \
	../texmath2png.pl equation-list.sgml

clean:
	rm -f html_out/$(DOC).* $(DOC).tex $(DOC).pdf *.log *.out *.aux
	rm -f html_out/equation-list.sgml
	rm -rf html_out/$(FIGDIR)


