lang/Makefile

75 lines
1.7 KiB
Makefile
Raw Normal View History

2021-04-29 13:01:25 -04:00
HOST ?= rhiannon.website
REMOTE_USER ?= www-data
IDFILE ?= ~/.ssh/xyz
REMOTE_DIR ?= lang
2020-08-18 03:35:36 -04:00
TMPDIR ?= _tmp
BUILDDIR ?= _build
PAGESDIR ?= pages
DATADIR ?= data
TEMPLATE ?= $(DATADIR)/template.html
2020-10-30 02:54:28 -04:00
STATICEXTS := yaml
2020-08-18 03:35:36 -04:00
PAGES != find $(PAGESDIR) -name '*.md'
2020-10-30 02:54:28 -04:00
STATICS != parallel find $(PAGESDIR) -name '\*.{}' ::: $(STATICEXTS)
OUTPUTPAGES = \
$(patsubst $(PAGESDIR)/%.md,$(BUILDDIR)/%.html,$(PAGES)) \
$(patsubst $(PAGESDIR)/%,$(BUILDDIR)/%,$(STATICS))
2020-08-18 03:35:36 -04:00
2020-08-18 04:33:25 -04:00
STYLE != find style -type f
OUTPUTSTYLE = $(patsubst %,$(BUILDDIR)/%,$(STYLE))
OUTPUT = $(OUTPUTPAGES) $(OUTPUTSTYLE)
2020-08-18 03:35:36 -04:00
2020-08-18 12:33:25 -04:00
LANGFILTER = $(TMPDIR)/langfilter
LAANTAS_SCRIPT = $(TMPDIR)/laantas-script
2020-08-18 12:33:25 -04:00
EXECS = $(LANGFILTER)
2020-08-18 03:35:36 -04:00
.PHONY: all
all: build
.PHONY: build
2020-08-18 04:33:25 -04:00
build: $(OUTPUT)
2020-08-18 03:35:36 -04:00
$(BUILDDIR)/%.html: $(PAGESDIR)/%.md $(TEMPLATE) $(LANGFILTER) $(LAANTAS_SCRIPT)
2020-08-18 03:35:36 -04:00
mkdir -p $(dir $@)
LAANTAS_SCRIPT="$(LAANTAS_SCRIPT)" \
DIRNAME="$(subst $(PAGESDIR),$(BUILDDIR),$(dir $<))" \
pandoc -s --toc --template $(TEMPLATE) -o $@ $< \
--filter $(LANGFILTER)
2020-10-30 02:54:28 -04:00
$(BUILDDIR)/%: $(PAGESDIR)/%
mkdir -p $(dir $@)
cp $< $@
2020-08-18 03:35:36 -04:00
2020-08-18 04:33:25 -04:00
$(BUILDDIR)/%: %
mkdir -p $(dir $@)
cp $< $@
2020-08-18 12:33:25 -04:00
$(LANGFILTER): langfilter/*.hs langfilter/langfilter.cabal
cabal build langfilter
2020-10-30 02:54:42 -04:00
mkdir -p $(dir $@)
2020-08-18 12:33:25 -04:00
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) \;
2021-04-29 13:01:25 -04:00
upload: build
@rsync -rPLzh --delete -e 'ssh -l $(REMOTE_USER) -i $(IDFILE)' \
$(BUILDDIR)/ $(HOST):$(REMOTE_DIR)/
2020-08-18 12:33:25 -04:00
2020-08-18 03:35:36 -04:00
.PHONY: clean distclean
clean:
rm -rf $(BUILDDIR)
distclean: clean
rm -rf $(TMPDIR)
cabal clean