PANDOC=pandoc
PANDOCFLAGS=--standalone --smart --toc --number-sections --latex-engine=xelatex --variable geometry=margin=3cm --variable lang=french --variable mainfont=Cantarell --variable fontsize=12pt -c pandoc.css
SRCS=$(wildcard *.md)
IMAGES=$(wildcard images/*.png)
PDFS=$(SRCS:%.md=%.pdf)
HTMLS=$(SRCS:%.md=%.html)
TEXS=$(SRCS:%.md=%.tex)
ALL=$(PDFS) $(HTMLS) index.html

all: $(ALL)

index.html: $(SRCS) index.html.build
	echo $(IMAGES)
	sh ./index.html.build > index.html

%.pdf: %.md $(IMAGES) Makefile
	$(PANDOC) $(PANDOCFLAGS) $< -o $@

%.tex: %.md
	$(PANDOC) $(PANDOCFLAGS) $< -o $@

%.html: %.md
	$(PANDOC) $(PANDOCFLAGS) $< -o $@

%.txt: %.md
	$(PANDOC) $(PANDOCFLAGS) $< -o $@

.PHONY:

tex: $(TEXS)

clean:
	rm -f index.html $(PDFS) $(HTMLS) $(TEXS) $(SRCS:%.md=%.aux) $(SRCS:%.md=%.log) $(SRCS:%.md=%.out) $(SRCS:%.md=%.toc)

publish: $(ALL)
	rsync -av * doc.entrouvert.org:/var/vhosts/doc.entrouvert.org/web/supann/
