gallery/Makefile

92 lines
2 KiB
Makefile

DATADIR := data
TMPDIR := _tmp
BUILDDIR := _build
INFONAME := info.yaml
ROOT := https://gallery.niss.website
# SMALL = thumbnails, MED = single pages (link to full size)
SMALL := 200
MEDW := 1000
MEDH := 1200
MAKEPAGES := $(TMPDIR)/make-pages
YAMLS != find $(DATADIR) -name $(INFONAME)
SCRIPTS := $(wildcard script/*.js)
STYLES != find style -name '*.css'
STYLESVGS != find style -name '*.svg'
STYLEPNGS != find style -name '*.png'
FONTS := $(shell find fonts \
-iname '*.eot' -or -iname '*.svg' -or \
-iname '*.ttf' -or -iname '*.woff' -or \
-iname '*.woff2' -or -iname '*.css')
STATIC := $(SCRIPTS) $(STYLES) $(STYLEPNGS) $(STYLESVGS) $(FONTS)
BSTATIC := $(patsubst %,$(BUILDDIR)/%,$(STATIC))
.PHONY: all build
all: build
build: $(BUILDDIR)/index.html $(BSTATIC)
$(BUILDDIR)/index.html: $(DATADIR)/index.yaml $(MAKEPAGES)
echo "[index] "$@
mkdir -p $(dir $@)
$(MAKEPAGES) $(MPFLAGS) index $< -o $@
$(BUILDDIR)/%: %
echo "[copy] "$@
mkdir -p $(dir $@)
cp $< $@
$(BUILDDIR)/%: $(TMPDIR)/%
echo "[copy] "$@
mkdir -p $(dir $@)
cp $< $@
$(MAKEPAGES): make-pages/*.hs make-pages/make-pages.cabal
echo "[make-pages]"
mkdir -p $(dir $@)
cabal v2-build all -O0 -v0 -j
find dist-newstyle -name make-pages -executable -type f \
-exec cp {} $@ \;
$(TMPDIR)/index.mk: $(DATADIR)/index.yaml $(YAMLS) $(MAKEPAGES)
echo "[deps] "$@
mkdir -p $(dir $@)
$(MAKEPAGES) $(MPFLAGS) depend-gallery $< -o $@ \
-B $(BUILDDIR) -D $(DATADIR) -T $(TMPDIR) -I $(INFONAME)
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),distclean)
-include $(TMPDIR)/index.mk
endif
endif
.PHONY: clean distclean
clean:
echo "[clean]"
rm -rf $(BUILDDIR) $(TMPDIR)
distclean: clean
echo "[distclean]"
rm -rf dist-newstyle
HOST ?= gallery.niss.website
REMOTE_USER ?= www-data
IDFILE ?= ~/.ssh/xyz
REMOTE_DIR ?= gallery
.PHONY: upload
upload: build
@rsync -rPLzh --delete -e 'ssh -l $(REMOTE_USER) -i $(IDFILE)' \
$(BUILDDIR)/ $(HOST):$(REMOTE_DIR)/
.SILENT: