makefile stuff

This commit is contained in:
Rhiannon Morris 2020-07-15 20:09:40 +02:00
parent 966481dacd
commit 393e75ce19

View file

@ -12,38 +12,67 @@ YAMLS != find $(DATADIR) -iname "*.yaml"
all:
define copy =
echo "[copy] "$@
cp $< $@
endef
ifneq ($(BUILDDIR),$(DATADIR))
$(BUILDDIR)/%: $(DATADIR)/%
@echo "[copy] "$@
@cp $< $@
@$(call copy)
endif
$(BUILDDIR)/nsfw/%: $(DATADIR)/%
@$(call copy)
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
@echo "[resize] "$@
@mkdir -p $(dir $@)
@convert -resize "$(SMALL)x$(SMALL)^" -gravity center -crop 1:1+0 $< $@
@$(call resize,$(SMALL),^,$(crop))
$(BUILDDIR)/%_med.png: $(DATADIR)/%.png
@echo "[resize] "$@
@mkdir -p $(dir $@)
@convert -resize "$(MED)x$(MED)>" $< $@
@$(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
@echo "[single] "$@
@mkdir -p $(dir $@)
@$(MAKEPAGES) single $< -o $@
@$(call single)
$(BUILDDIR)/nsfw/%/index.html: $(DATADIR)/%/info.yaml
@echo "[single] "$@
@mkdir -p $(dir $@)
@$(MAKEPAGES) single $< -o $@ -n
@$(call single,-n)
define depend-single =
echo "[deps] "$@
mkdir -p $(dir $@)
$(MAKEPAGES) depend-single $< -o $@ $(1)
endef
$(TMPDIR)/%.d: %.yaml
@echo "[deps] "$@
@mkdir -p $(dir $@)
@$(MAKEPAGES) depend-single $< -o $@
@$(call depend-single)
$(TMPDIR)/nsfw/%.d: %.yaml
@$(call depend-single,-n -p nsfw)
include $(TMPDIR)/$(YAMLS:.yaml=.d)
include $(TMPDIR)/nsfw/$(YAMLS:.yaml=.d)
.PHONY: clean distclean
clean: