HOST ?= rhiannon.website REMOTE_USER ?= www-data IDFILE ?= ~/.ssh/xyz REMOTE_DIR ?= lang TMPDIR ?= _tmp BUILDDIR ?= _build PAGESDIR ?= pages DATADIR ?= data TEMPLATE ?= $(DATADIR)/template.html STATICEXTS := yaml PAGES != find $(PAGESDIR) -name '*.md' STATICS != parallel find $(PAGESDIR) -name '\*.{}' ::: $(STATICEXTS) OUTPUTPAGES = \ $(patsubst $(PAGESDIR)/%.md,$(BUILDDIR)/%.html,$(PAGES)) \ $(patsubst $(PAGESDIR)/%,$(BUILDDIR)/%,$(STATICS)) STYLE != find style -type f OUTPUTSTYLE = $(patsubst %,$(BUILDDIR)/%,$(STYLE)) OUTPUT = $(OUTPUTPAGES) $(OUTPUTSTYLE) LANGFILTER = $(TMPDIR)/langfilter LAANTAS_SCRIPT = $(TMPDIR)/laantas-script EXECS = $(LANGFILTER) CABAL_FLAGS ?= -O .PHONY: all all: build .PHONY: build build: $(OUTPUT) $(BUILDDIR)/%.html: $(PAGESDIR)/%.md $(TEMPLATE) $(LANGFILTER) $(LAANTAS_SCRIPT) mkdir -p $(dir $@) LAANTAS_SCRIPT="$(LAANTAS_SCRIPT)" \ DIRNAME="$(subst $(PAGESDIR),$(BUILDDIR),$(dir $<))" \ pandoc -s --toc --template $(TEMPLATE) -o $@ $< \ --filter $(LANGFILTER) $(BUILDDIR)/%: $(PAGESDIR)/% mkdir -p $(dir $@) cp $< $@ $(BUILDDIR)/%: % mkdir -p $(dir $@) cp $< $@ $(LANGFILTER): langfilter/*.hs langfilter/langfilter.cabal cabal build langfilter $(CABAL_FLAGS) mkdir -p $(dir $@) find dist-newstyle -name $(notdir $@) \ -print -type f -exec cp {} $(TMPDIR) \; $(LAANTAS_SCRIPT): laantas-script/*.hs laantas-script/laantas-script.cabal cabal build laantas-script $(CABAL_FLAGS) mkdir -p $(dir $@) find dist-newstyle -name $(notdir $@) \ -type f -exec cp {} $(TMPDIR) \; upload: build @rsync -rPLzh --delete -e 'ssh -l $(REMOTE_USER) -i $(IDFILE)' \ $(BUILDDIR)/ $(HOST):$(REMOTE_DIR)/ .PHONY: clean distclean clean: rm -rf $(BUILDDIR) distclean: clean rm -rf $(TMPDIR) cabal clean