# Author- and Meta-data
# THESE FIELDS MAY NOT CONTAIN ANY SEMICOLONS

.PHONY : all
all: pdf epub

build/%.pdf : src/%.tex
	@echo "Building $@... $^"
	@if [ ! -d "./build" ]; then mkdir ./build; fi
	@pdflatex --output-dir ./build $<
	@pdflatex --output-dir ./build $<

build/%.epub : src/%.tex
	@echo "Building $@... $^"
	@if [ ! -d "./build" ]; then mkdir ./build; fi
	@pandoc -f latex $< -o $@

pdf : build/promise.pdf

epub : build/promise.epub

.PHONY : release
release : pdf epub
	@echo "Building release.... $<"
	@if [ ! -d "./release" ]; then mkdir ./release; fi
	@cp ./build/*.pdf ./release/
	@cp ./build/*.epub ./release/

clean :
	@rm -rf *.aux *.dvi *.log *.out *.pdf *.bak ./build/ ./release/