ifeq (,$(shell command -v pandoc))
all:
clean:
else

# Source documentation in markdown lives in the src/ folder (html and manpages).
# This is what you should edit if you want to make changes to the documentation.
# From these sources, this script generates actual manpages and general
# documentation in html using pandoc.

HTML_MD = $(wildcard src/html/*.md)
MAN_MD = $(wildcard src/man/*.md)

HTML_HTML = $(patsubst src/html/%.md,html/%.html,$(HTML_MD))
MAN_MAN = $(patsubst src/man/%.md,manpages/%,$(MAN_MD))

all: $(HTML_HTML) $(MAN_MAN)

html/%.html: src/html/%.md
	pandoc -f markdown -t html $< > $@
	echo $@ successfully built in docs/html directory

manpages/%: src/man/%.md
	pandoc -s -t man $< -o $@
	echo $@ successfully built in docs/manpages directory

clean:
	rm -f html/*.html manpages/*.[58]
endif
