# Makefile for converting doc formats, e.g. from AsciiDoctor to HTML and PDF.

ADOC_SRC = $(wildcard *.adoc)

MMD_SRC = $(wildcard *.mmd)

HTML = $(ADOC_SRC:.adoc=.html)

PDF = $(ADOC_SRC:.adoc=.pdf)

SVG = $(MMD_SRC:.mmd=.svg)

default: $(HTML) $(SVG)

all: $(HTML) $(PDF)

# General Rule for converting Markdown files to HTML.
# Note that you can use: pip3 install markdown and then have a script:
#   python3 -m markdown x.md > x.html
%.html: %.md
	rm -f $@
	markdown $^ > $@

# General Rule for converting AsciiDoc files to HTML.
%.html: %.adoc
	rm -f $@
	asciidoctor $^

# General Rule for converting AsciiDoc files to PDF.
%.pdf: %.adoc
	rm -f $@
	asciidoctor-pdf -a pdf-themesdir=themes -a pdf-theme=basic $^

# General Rule for converting MindMap files to SVG.
%.svg: %.mmd
	rm -f $@
	hms_mindmap.py $^ > $@

.PHONY: clean rec

clean:
	rm -f $(PDF) $(HTML)

rec:
	p4 rec
