gallery/Makefile

81 lines
1.8 KiB
Makefile

DATADIR = data
TMPDIR = _tmp
BUILDDIR = _build
INFONAME = info.yaml
# SMALL = thumbnails, MED = single pages (link to full size)
SMALL := 200
MED := 1000
MAKEPAGES = $(TMPDIR)/make-pages
YAMLS != find $(DATADIR) -name $(INFONAME)
SCRIPTS := $(wildcard script/*.js)
STYLES := $(wildcard style/*.css)
STYLESVGS = $(wildcard style/*.svg)
STYLEPNGS = $(wildcard style/*.png) \
$(STYLESVGS:.svg=.png) $(STYLESVGS:.svg=_small.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))
all: make-pages $(BUILDDIR)/index.html $(BSTATIC)
$(BUILDDIR)/%: %
echo "[copy] "$@
mkdir -p $(dir $@)
cp $< $@
$(BUILDDIR)/%: $(TMPDIR)/%
echo "[copy] "$@
mkdir -p $(dir $@)
cp $< $@
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)
$(BUILDDIR)/index.html: $(DATADIR)/galleries.yaml $(MAKEPAGES)
echo "[index]"
mkdir -p $(dir $@)
$(MAKEPAGES) $(MPFLAGS) index $< -o $@
$(MAKEPAGES): make-pages/*.hs make-pages/make-pages.cabal
echo "[make-pages]"
mkdir -p $(dir $@)
cabal v2-build all -O0 -j
find dist-newstyle -name make-pages -executable -type f \
-exec cp {} $@ \;
$(TMPDIR)/galleries.mk: $(DATADIR)/galleries.yaml $(DATADIR) $(MAKEPAGES)
echo "[deps] "$@
mkdir -p $(dir $@)
$(MAKEPAGES) $(MPFLAGS) depend-gallery $< -o $@ \
-B $(BUILDDIR) -D $(DATADIR) -T $(TMPDIR) -I $(INFONAME)
-include $(TMPDIR)/galleries.mk
.PHONY: clean distclean
clean:
echo "[clean]"
rm -rf $(BUILDDIR) $(TMPDIR)
distclean: clean
echo "[distclean]"
rm -rf dist-newstyle
.SILENT: