md=$(wildcard *.markdown)
html=$(patsubst %.markdown,%.html,$(md))
dot=$(wildcard *.dot)
png=$(patsubst %.dot,%.png,$(dot))
docdir=/usr/share/doc/botch

.PHONY: all
all: $(html) $(png)

%.html: %.markdown
	sed -e 's/\[\([^]]\+\)\](\([^\/)]\+\))/<a href="\2.html">\1<\/a>/' -e 's#https://gitlab.mister-muffin.de/uploads/debian-bootstrap/botch/.\{10\}/\([^)]\+\)#\1#' $< | markdown > $@

%.png: %.dot
	dot -T png $< > $@

.PHONY: install
install: all
	mkdir -p $(DESTDIR)$(docdir)/wiki
	cp $(html) $(png) $(DESTDIR)$(docdir)/wiki

.PHONY: clean
clean:
	rm -f $(html) $(png)
