MAKEFLAGS+="-j -l $(shell grep -c ^processor /proc/cpuinfo)"
MD=multimarkdown
HDIR=html
SRC = $(wildcard *.txt)
STYLE = $(wildcard *.css)
OUT = $(patsubst %.txt,$(HDIR)/%.html,$(SRC)) $(patsubst %,$(HDIR)/%,$(STYLE)) $(HDIR)/feats.html

all: $(OUT) 
	# Done. 

.PHONY: clean all

$(HDIR):
	mkdir -p $(HDIR)

feats.txt: feats.csv format_feats.py
	./format_feats.py >feats.txt

$(HDIR)/%.html: %.txt header.html footer.html |$(HDIR)
	sed "s/MY_TITLE/$(shell head -n 1 $<)/" header.html > $@
	$(MD) $< >> $@
	cat footer.html >> $@

$(HDIR)/%: % |$(HDIR)
	cp $< $@

clean:
	rm -f $(OUT)
	rmdir $(HDIR)

