if USE_PDFLATEX
  PDFLATEX = pdflatex
else
  PDFLATEX = @echo "skipping pdf-doc: missing pdflatex - pdf cannot be build by pdflatex"
endif

if USE_HTLATEX
  HTLATEX = htlatex
else
  HTLATEX = @echo "skipping html-doc: missing htlatex - html cannot be build by htlatex"
endif

RM      = rm -f

all-local: doc-local

MASTER        = TOPCOM-manual
SRC_MASTER    = $(srcdir)/$(MASTER).tex
SRC_FIGURES   = $(srcdir)/TOPCOM_points.pdf $(srcdir)/TOPCOM_statistics.pdf $(srcdir)/TOPCOM_tree_graph.pdf

PDF_MASTER    = $(builddir)/$(MASTER).pdf
HTML_MASTER   = $(builddir)/$(MASTER).html
CSS_MASTER    = $(builddir)/$(MASTER).css

EXTRA_DIST = $(PDF_MASTER) $(HTML_MASTER) $(CSS_MASTER)

doc-local: html-doc pdf-doc 

html-doc: $(HTML_MASTER)

pdf-doc: $(PDF_MASTER)

$(HTML_MASTER): $(SRC_MASTER) $(SRC_FIGURES)
	$(HTLATEX) $(SRC_MASTER)

$(PDF_MASTER): $(SRC_MASTER) $(SRC_FIGURES)
	$(PDFLATEX) $(SRC_MASTER)
	$(PDFLATEX) $(SRC_MASTER)

clean-local:
	$(RM) $(HTML_MASTER)
	$(RM) $(PDF_MASTER)
	$(RM) *.css *.4ct *.4tc *.idv *.lg *.tmp *.xref *-.png

.PHONY: pdf-doc html-doc doc-local clean-local
