lang/Makefile

93 lines
1.9 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)
2021-05-20 16:45:10 -04:00
CABAL_FLAGS ?= -O -v0
2021-04-30 07:48:23 -04:00
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)
2021-05-20 16:45:10 -04:00
@echo "[pandoc] $<"
2020-08-18 03:35:36 -04:00
mkdir -p $(dir $@)
mkdir -p $(basename $@)
LAANTAS_SCRIPT="$(LAANTAS_SCRIPT)" LANG_COLOR="hsl(340deg, 50%, 35%)" \
DIRNAME="$(basename $@)" \
FILENAME="$@" \
pandoc -s --toc --template $(TEMPLATE) -o $@ $< \
--filter $(LANGFILTER)
2020-10-30 02:54:28 -04:00
$(BUILDDIR)/%: $(PAGESDIR)/%
2021-05-20 16:45:10 -04:00
$(copy)
2020-08-18 03:35:36 -04:00
2020-08-18 04:33:25 -04:00
$(BUILDDIR)/%: %
2021-05-20 16:45:10 -04:00
$(copy)
define copy
@echo "[copy] $<"
mkdir -p $(dir $@)
cp $< $@
endef
2020-08-18 04:33:25 -04:00
2020-08-18 12:33:25 -04:00
$(LANGFILTER): langfilter/*.hs langfilter/langfilter.cabal
2021-05-20 16:45:10 -04:00
$(cabal-exe)
2020-08-18 12:33:25 -04:00
2021-05-20 16:45:10 -04:00
$(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
2021-04-29 13:01:25 -04:00
upload: build
2021-05-20 16:45:10 -04:00
@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)/
2021-04-29 13:01:25 -04:00
2020-08-18 12:33:25 -04:00
2020-08-18 03:35:36 -04:00
.PHONY: clean distclean
clean:
2021-05-20 16:45:10 -04:00
@echo "[clean]"
2020-08-18 03:35:36 -04:00
rm -rf $(BUILDDIR)
rm -rf $(TMPDIR)
2021-05-20 16:45:10 -04:00
distclean: clean
@echo "[distclean]"
cabal clean
2021-05-20 16:45:10 -04:00
.SILENT: