a lot of stuff sorry

This commit is contained in:
Rhiannon Morris 2020-07-16 16:07:28 +02:00
parent adfc8b9a82
commit 375c6e833a
9 changed files with 297 additions and 151 deletions

View file

@ -1,81 +1,44 @@
DATADIR = data
TMPDIR = _tmp
BUILDDIR = _build
INFONAME = info.yaml
# SMALL = thumbnails, MED = single pages (link to full size)
SMALL := 200
MED := 1200
MAKEPAGES = cabal -v0 run -- make-pages
MAKEPAGES = $(TMPDIR)/make-pages
YAMLS != find $(DATADIR) -iname "*.yaml"
all:
all: make-pages $(BUILDDIR)/index.html
define copy =
echo "[copy] "$@
cp $< $@
endef
$(BUILDDIR)/index.html:
echo "[index]"
mkdir -p $(dir $@)
touch $@ # FIXME
ifneq ($(BUILDDIR),$(DATADIR))
$(BUILDDIR)/%: $(DATADIR)/%
@$(call copy)
endif
$(MAKEPAGES): make-pages
echo "[make-pages]"
mkdir -p $(dir $@)
cabal v2-build all -O0
find dist-newstyle -name make-pages -executable -type f \
-exec cp {} $@ \;
$(BUILDDIR)/nsfw/%: $(DATADIR)/%
@$(call copy)
$(TMPDIR)/galleries.d: $(DATADIR)/galleries.yaml $(MAKEPAGES)
echo "[gallery-deps] "$@
mkdir -p $(dir $@)
$(MAKEPAGES) depend-gallery $< -o $@ \
-B $(BUILDDIR) -D $(DATADIR) -T $(TMPDIR) -I $(INFONAME)
define resize =
echo "[resize] "$@
mkdir -p $(dir $@)
convert -resize "$(1)x$(1)$(2)" $(3) $< $@
endef
crop = -gravity center -crop 1:1+0
$(BUILDDIR)/%_small.png: $(DATADIR)/%.png
@$(call resize,$(SMALL),^,$(crop))
$(BUILDDIR)/%_med.png: $(DATADIR)/%.png
@$(call resize,$(MED),>)
$(BUILDDIR)/nsfw/%_small.png: $(DATADIR)/%.png
@$(call resize,$(SMALL),^,$(crop))
$(BUILDDIR)/nsfw/%_med.png: $(DATADIR)/%.png
@$(call resize,$(MED),>)
define single =
echo "[single] "$@
mkdir -p $(dir $@)
$(MAKEPAGES) single $< -o $@ $(1)
endef
$(BUILDDIR)/%/index.html: $(DATADIR)/%/info.yaml
@$(call single)
$(BUILDDIR)/nsfw/%/index.html: $(DATADIR)/%/info.yaml
@$(call single,-n)
define depend-single =
echo "[deps] "$@
mkdir -p $(dir $@)
$(MAKEPAGES) depend-single $< -o $@ $(1)
endef
$(TMPDIR)/%.d: %.yaml
@$(call depend-single)
$(TMPDIR)/nsfw/%.d: %.yaml
@$(call depend-single,-n -p nsfw)
include $(TMPDIR)/$(YAMLS:.yaml=.d)
include $(TMPDIR)/nsfw/$(YAMLS:.yaml=.d)
-include $(TMPDIR)/galleries.d
.PHONY: clean distclean
clean:
echo "[clean]"
rm -rf $(BUILDDIR) $(TMPDIR)
distclean: clean
echo "[distclean]"
rm -rf dist-newstyle
.SILENT: