gallery/Makefile

89 lines
1.9 KiB
Makefile
Raw Normal View History

2020-07-19 12:05:01 -04:00
DATADIR := data
TMPDIR := _tmp
BUILDDIR := _build
INFONAME := info.yaml
ROOT := https://gallery.niss.website
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-19 12:05:01 -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
2020-07-19 16:36:15 -04:00
STYLES != find style -name '*.css'
STYLESVGS != find style -name '*.svg'
STYLEPNGS != find style -name '*.png'
2020-07-18 05:44:30 -04:00
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
2020-07-19 12:05:01 -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
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
2020-07-19 12:05:01 -04:00
HOST ?= gallery.niss.website
2020-07-18 05:55:53 -04:00
REMOTE_USER ?= www-data
2020-07-19 12:05:01 -04:00
IDFILE ?= ~/.ssh/xyz
REMOTE_DIR ?= gallery
2020-07-18 05:55:53 -04:00
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: