lang/Makefile
2021-04-29 19:01:25 +02:00

74 lines
1.7 KiB
Makefile

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)
.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
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
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