gallery/Makefile

102 lines
2.1 KiB
Makefile
Raw Normal View History

2020-07-14 01:10:33 -04:00
DATADIR = data
TMPDIR = _tmp
BUILDDIR = _build
2020-07-16 10:07:28 -04:00
INFONAME = info.yaml
2020-07-14 01:10:33 -04:00
# SMALL = thumbnails, MED = single pages (link to full size)
SMALL := 200
2020-07-18 18:11:42 -04:00
MEDW := 1000
MEDH := 1200
2020-07-14 01:10:33 -04:00
2020-07-16 10:07:28 -04:00
MAKEPAGES = $(TMPDIR)/make-pages
2020-07-14 01:10:33 -04:00
2020-07-17 06:29:13 -04:00
YAMLS != find $(DATADIR) -name $(INFONAME)
2020-07-15 05:58:44 -04:00
2020-07-17 06:29:13 -04:00
SCRIPTS := $(wildcard script/*.js)
2020-07-18 05:44:30 -04:00
STYLES := $(wildcard style/*.css)
STYLESVGS = $(wildcard style/*.svg)
STYLEPNGS = $(wildcard style/*.png) \
$(STYLESVGS:.svg=.png) $(STYLESVGS:.svg=_small.png)
2020-07-17 06:29:13 -04:00
FONTS := $(shell find fonts \
-iname '*.eot' -or -iname '*.svg' -or \
-iname '*.ttf' -or -iname '*.woff' -or \
-iname '*.woff2' -or -iname '*.css')
2020-07-18 05:44:30 -04:00
STATIC := $(SCRIPTS) $(STYLES) $(STYLEPNGS) $(STYLESVGS) $(FONTS)
2020-07-17 06:29:13 -04:00
BSTATIC := $(patsubst %,$(BUILDDIR)/%,$(STATIC))
2020-07-18 05:58:41 -04:00
.PHONY: all build
all: build
build: $(BUILDDIR)/index.html $(BSTATIC)
2020-07-17 06:29:13 -04:00
2020-07-19 06:08:44 -04:00
$(BUILDDIR)/index.html: $(DATADIR)/index.yaml $(MAKEPAGES)
2020-07-18 05:58:41 -04:00
echo "[index] "$@
2020-07-17 06:29:13 -04:00
mkdir -p $(dir $@)
2020-07-18 05:58:41 -04:00
$(MAKEPAGES) $(MPFLAGS) index $< -o $@
2020-07-15 05:58:44 -04:00
2020-07-18 05:44:30 -04:00
define inkscape =
echo "[svg] "$@
mkdir -p $(dir $@)
inkscape $< -e $@ -w $(1) >/dev/null
endef
$(TMPDIR)/%.png: %.svg
$(call inkscape,32)
$(TMPDIR)/%_small.png: %.svg
$(call inkscape,16)
2020-07-18 05:58:41 -04:00
$(BUILDDIR)/%: %
echo "[copy] "$@
2020-07-16 10:07:28 -04:00
mkdir -p $(dir $@)
2020-07-18 05:58:41 -04:00
cp $< $@
$(BUILDDIR)/%: $(TMPDIR)/%
echo "[copy] "$@
mkdir -p $(dir $@)
cp $< $@
2020-07-15 14:09:40 -04:00
2020-07-17 06:29:13 -04:00
$(MAKEPAGES): make-pages/*.hs make-pages/make-pages.cabal
2020-07-16 10:07:28 -04:00
echo "[make-pages]"
mkdir -p $(dir $@)
2020-07-18 05:44:51 -04:00
cabal v2-build all -O0 -v0 -j
2020-07-16 10:07:28 -04:00
find dist-newstyle -name make-pages -executable -type f \
-exec cp {} $@ \;
2020-07-14 01:10:33 -04:00
2020-07-18 05:58:41 -04:00
2020-07-19 06:08:44 -04:00
$(TMPDIR)/index.mk: $(DATADIR)/index.yaml $(DATADIR) $(MAKEPAGES)
2020-07-17 06:29:13 -04:00
echo "[deps] "$@
2020-07-16 10:07:28 -04:00
mkdir -p $(dir $@)
2020-07-17 06:29:13 -04:00
$(MAKEPAGES) $(MPFLAGS) depend-gallery $< -o $@ \
2020-07-16 10:07:28 -04:00
-B $(BUILDDIR) -D $(DATADIR) -T $(TMPDIR) -I $(INFONAME)
2020-07-15 14:09:40 -04:00
2020-07-19 06:08:44 -04:00
-include $(TMPDIR)/index.mk
2020-07-15 05:58:58 -04:00
2020-07-18 05:58:41 -04:00
2020-07-15 05:58:44 -04:00
.PHONY: clean distclean
2020-07-14 01:10:33 -04:00
clean:
2020-07-16 10:07:28 -04:00
echo "[clean]"
2020-07-15 05:58:44 -04:00
rm -rf $(BUILDDIR) $(TMPDIR)
distclean: clean
2020-07-16 10:07:28 -04:00
echo "[distclean]"
2020-07-15 05:58:44 -04:00
rm -rf dist-newstyle
2020-07-16 10:07:28 -04:00
2020-07-18 05:55:53 -04:00
HOST ?= gallery.niss.website
REMOTE_USER ?= www-data
IDFILE ?= ~/.ssh/xyz
REMOTE_DIR ?= gallery
2020-07-18 05:58:41 -04:00
.PHONY: upload
upload: build
2020-07-18 05:55:53 -04:00
@rsync -rPLzh --delete -e 'ssh -l $(REMOTE_USER) -i $(IDFILE)' \
$(BUILDDIR)/ $(HOST):$(REMOTE_DIR)/
2020-07-16 10:07:28 -04:00
.SILENT: