2021-07-23 21:35:02 -04:00
|
|
|
HOST ?= rhiannon.website
|
|
|
|
REMOTE_USER ?= www-data
|
|
|
|
IDFILE ?= ~/.ssh/xyz
|
|
|
|
REMOTE_DIR ?= blog
|
|
|
|
|
|
|
|
TMPDIR ?= _tmp
|
|
|
|
BUILDDIR ?= _build
|
|
|
|
POSTSDIR ?= posts
|
2023-12-27 19:00:25 -05:00
|
|
|
IMAGESDIR ?= images
|
2021-07-23 21:35:02 -04:00
|
|
|
TEMPLATEDIR ?= templates
|
|
|
|
|
2023-12-27 19:00:25 -05:00
|
|
|
STATICS != find $(IMAGESDIR) -type f
|
2022-03-15 23:54:57 -04:00
|
|
|
|
2021-07-23 21:35:02 -04:00
|
|
|
POSTS != find $(POSTSDIR) -name '*.md'
|
|
|
|
OUTPUTPOSTS = \
|
|
|
|
$(patsubst $(POSTSDIR)/%.md,$(BUILDDIR)/%.html,$(POSTS)) \
|
2023-12-27 19:00:25 -05:00
|
|
|
$(addprefix $(BUILDDIR)/,$(STATICS)) \
|
2024-09-15 11:49:23 -04:00
|
|
|
$(BUILDDIR)/index.html $(BUILDDIR)/rss.xml
|
2021-07-23 21:35:02 -04:00
|
|
|
|
|
|
|
STYLE != find style -type f
|
|
|
|
OUTPUTSTYLE = $(patsubst %,$(BUILDDIR)/%,$(STYLE))
|
|
|
|
|
|
|
|
OUTPUT = $(OUTPUTPOSTS) $(OUTPUTSTYLE)
|
|
|
|
|
|
|
|
ALL_TAGS = $(TMPDIR)/all-tags
|
|
|
|
POST_LISTS = $(TMPDIR)/post-lists
|
|
|
|
NICE_DATE = $(TMPDIR)/nice-date
|
2022-09-17 14:54:16 -04:00
|
|
|
SLUG_TAGS = $(TMPDIR)/slug-tags
|
2021-07-23 21:35:02 -04:00
|
|
|
EXECS = \
|
2023-12-27 19:00:25 -05:00
|
|
|
$(LAANTAS_SCRIPT) \
|
2022-09-17 14:54:16 -04:00
|
|
|
$(ALL_TAGS) $(POST_LISTS) $(NICE_DATE) $(SLUG_TAGS)
|
2021-07-23 21:35:02 -04:00
|
|
|
|
2023-12-27 19:00:25 -05:00
|
|
|
CABAL_FLAGS ?= -O
|
2021-07-23 21:35:02 -04:00
|
|
|
|
2022-03-14 23:40:25 -04:00
|
|
|
SYNTAXDIR := syntax
|
2022-03-16 13:39:53 -04:00
|
|
|
SYNTAXFILES != find $(SYNTAXDIR) -name *.xml
|
|
|
|
SYNTAXFLAGS = $(patsubst %,--syntax-definition=%,$(SYNTAXFILES))
|
2022-03-14 23:40:25 -04:00
|
|
|
|
2021-07-23 21:35:02 -04:00
|
|
|
.PHONY: all
|
|
|
|
all: build
|
|
|
|
|
|
|
|
.PHONY: build
|
|
|
|
build: $(EXECS) $(OUTPUT)
|
|
|
|
|
|
|
|
|
2023-12-27 19:00:25 -05:00
|
|
|
LANGFILTER != cabal list-bin langfilter
|
|
|
|
LAANTAS_SCRIPT != cabal list-bin laantas-script
|
|
|
|
|
|
|
|
POSTDEPS = \
|
|
|
|
$(TEMPLATEDIR)/* \
|
|
|
|
langfilter laantas-script \
|
|
|
|
$(SYNTAXFILES) acm.csl quox.bib
|
2021-07-23 21:35:02 -04:00
|
|
|
|
|
|
|
$(TMPDIR)/all-tags.md $(TMPDIR)/tags.mk &: $(POSTS) $(ALL_TAGS)
|
|
|
|
@echo "[all-tags]"
|
|
|
|
$(ALL_TAGS) $(POSTSDIR) $(TMPDIR)/all-tags.md $(TMPDIR)/tags.mk
|
|
|
|
build: $(BUILDDIR)/all-tags.html
|
|
|
|
include $(TMPDIR)/tags.mk
|
|
|
|
|
2024-09-15 11:49:23 -04:00
|
|
|
$(BUILDDIR)/%.html: $(POSTSDIR)/%.md $(POSTDEPS) ; $(call pandoc,post.html)
|
|
|
|
$(BUILDDIR)/%.html: $(TMPDIR)/%.md $(POSTDEPS) ; $(call pandoc,meta.html)
|
|
|
|
|
|
|
|
$(BUILDDIR)/rss.xml: $(TMPDIR)/index.md $(POSTDEPS)
|
|
|
|
$(call pandoc,rss.xml,--metadata-file rss.yaml --write html)
|
2021-07-23 21:35:02 -04:00
|
|
|
|
2023-12-27 19:00:25 -05:00
|
|
|
.PHONY: langfilter laantas-script
|
|
|
|
langfilter laantas-script: %: ; cabal build $@
|
|
|
|
|
2024-09-15 11:49:23 -04:00
|
|
|
# $(1): template file
|
|
|
|
# $(2): extra flags
|
2021-07-23 21:35:02 -04:00
|
|
|
define pandoc
|
2024-09-15 11:49:23 -04:00
|
|
|
@echo "[pandoc] $(subst $(TMPDIR)/,,$(subst $(BUILDDIR)/,,$@))"
|
2021-07-23 21:35:02 -04:00
|
|
|
mkdir -p $(dir $@)
|
|
|
|
mkdir -p $(basename $@)
|
2024-09-15 11:49:23 -04:00
|
|
|
LAANTAS_SCRIPT="$(LAANTAS_SCRIPT)" LANG_COLOR="#325" \
|
2021-07-23 21:35:02 -04:00
|
|
|
DIRNAME="$(basename $@)" \
|
|
|
|
FILENAME="$@" \
|
2024-09-15 11:49:23 -04:00
|
|
|
pandoc -s --toc --toc-depth=2 --template $(TEMPLATEDIR)/$(1) -o $@ $< \
|
|
|
|
-f markdown+emoji $(2) \
|
2022-03-14 23:40:25 -04:00
|
|
|
$(SYNTAXFLAGS) \
|
2022-09-17 14:54:16 -04:00
|
|
|
--filter $(LANGFILTER) --filter $(NICE_DATE) --filter $(SLUG_TAGS) \
|
2024-09-15 11:48:16 -04:00
|
|
|
--mathml --citeproc --csl=apa-eu.csl
|
2021-07-23 21:35:02 -04:00
|
|
|
endef
|
|
|
|
|
|
|
|
|
2023-12-27 19:00:25 -05:00
|
|
|
$(BUILDDIR)/%: $(POSTSDIR)/% ; $(call copy)
|
|
|
|
$(BUILDDIR)/%: $(TMPDIR)/% ; $(call copy)
|
|
|
|
$(BUILDDIR)/%: % ; $(call copy)
|
2021-07-23 21:35:02 -04:00
|
|
|
|
|
|
|
define copy
|
|
|
|
@echo "[copy] $<"
|
|
|
|
mkdir -p $(dir $@)
|
|
|
|
cp $< $@
|
|
|
|
endef
|
|
|
|
|
|
|
|
|
|
|
|
BLOG_META_DEPS != find blog-meta -type f
|
|
|
|
|
2023-12-27 19:00:25 -05:00
|
|
|
$(ALL_TAGS): $(BLOG_META_DEPS) ; $(call cabal-exe,blog-meta:)
|
|
|
|
$(POST_LISTS): $(BLOG_META_DEPS) ; $(call cabal-exe,blog-meta:)
|
|
|
|
$(NICE_DATE): $(BLOG_META_DEPS) ; $(call cabal-exe,blog-meta:)
|
|
|
|
$(SLUG_TAGS): $(BLOG_META_DEPS) ; $(call cabal-exe,blog-meta:)
|
2021-07-23 21:35:02 -04:00
|
|
|
|
|
|
|
define cabal-exe
|
|
|
|
@echo "[build] $(notdir $@)"
|
|
|
|
cabal build $(1)$(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:
|