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 -v0 .PHONY: all all: build .PHONY: build build: $(OUTPUT) $(BUILDDIR)/%.html: $(PAGESDIR)/%.md $(TEMPLATE) $(LANGFILTER) $(LAANTAS_SCRIPT) @echo "[pandoc] $<" mkdir -p $(dir $@) LAANTAS_SCRIPT="$(LAANTAS_SCRIPT)" \ DIRNAME="$(subst $(PAGESDIR),$(BUILDDIR),$(dir $<))" \ pandoc -s --toc --template $(TEMPLATE) -o $@ $< \ --filter $(LANGFILTER) $(BUILDDIR)/%: $(PAGESDIR)/% $(copy) $(BUILDDIR)/%: % $(copy) define copy @echo "[copy] $<" mkdir -p $(dir $@) cp $< $@ endef $(LANGFILTER): langfilter/*.hs langfilter/langfilter.cabal $(cabal-exe) $(LAANTAS_SCRIPT): laantas-script/* $(cabal-exe) define cabal-exe @echo "[build] $(notdir $@)" cabal build $(notdir $@) $(CABAL_FLAGS) mkdir -p $(dir $@) find dist-newstyle -name $(notdir $@) -type f -exec cp {} $(TMPDIR) \; endef upload: build @echo "[upload]" @rsync --recursive --partial --progress --copy-links \ --compress --human-readable --hard-links --size-only \ --delete --delete-after \ --rsh='ssh -l $(REMOTE_USER) -i $(IDFILE)' \ $(BUILDDIR)/ $(HOST):$(REMOTE_DIR)/ .PHONY: clean distclean clean: @echo "[clean]" rm -rf $(BUILDDIR) rm -rf $(TMPDIR) distclean: clean @echo "[distclean]" cabal clean .SILENT: