From dbe9e97f62aaaaae72f3f313811593e09df8a64b Mon Sep 17 00:00:00 2001 From: Glenn Date: Fri, 5 Jan 2024 23:02:16 +0100 Subject: [PATCH] feat: add new module for mypaint --- mypaint.mk | 100 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) diff --git a/mypaint.mk b/mypaint.mk index e69de29..75b2417 100644 --- a/mypaint.mk +++ b/mypaint.mk @@ -0,0 +1,100 @@ +# SPDX-License-Identifier: LGPL-3.0-or-later +# +# SPDX-FileCopyrightText: 2023 Glenn Y. Rolland +# Copyright © 2023 Glenn Y. Rolland + +## +## MYPAINT MODULE +## + +## +## External variables (API) +## +MYPAINT_SUFFIX ?= ora +MYPAINT_SRC_DIR ?= +MYPAINT_DEST_DIR ?= +MYPAINT_PDF_DENSITY ?= 75 +MYPAINT_JPG_QUALITY ?= 100 + +## +## Internal variables (lazy recursive evaluation) +## + +## Find .ora files +MYPAINT_ORA = $(shell find $(MYPAINT_SRC_DIR) \( -name '*.ora' ! -name '_*' \)) +MYPAINT_ORA_PNG = $(patsubst $(MYPAINT_SRC_DIR)/%.ora,$(MYPAINT_DEST_DIR)/%.ora.png,$(MYPAINT_ORA)) +MYPAINT_ORA_JPG = $(patsubst $(MYPAINT_SRC_DIR)/%.ora,$(MYPAINT_DEST_DIR)/%.ora.jpg,$(MYPAINT_ORA)) +MYPAINT_ORA_PDF = $(patsubst $(MYPAINT_SRC_DIR)/%.ora,$(MYPAINT_DEST_DIR)/%.ora.pdf,$(MYPAINT_ORA)) + +## +## Prerequisistes (system packages) +## +MYPAINT_APT_PACKAGES := unzip mypaint imagemagick + +## +## Rules +## + +$(MYPAINT_DEST_DIR): + mkdir -p $(MYPAINT_DEST_DIR) + +$(MYPAINT_DEST_DIR)/%.ora.png: $(MYPAINT_SRC_DIR)/%.ora | $(MYPAINT_DEST_DIR) + TMPDIR="$$(mktemp -d)" \ + && unzip -q $< -d "$$TMPDIR" mergedimage.png \ + && touch "$$TMPDIR/mergedimage.png" \ + && mv "$$TMPDIR/mergedimage.png" $@ + +$(MYPAINT_DEST_DIR)/%.ora.jpg: $(MYPAINT_DEST_DIR)/%.ora.png | $(MYPAINT_DEST_DIR) + convert -quality $(MYPAINT_JPG_QUALITY) $< $@ + +$(MYPAINT_DEST_DIR)/%.ora.pdf: $(MYPAINT_DEST_DIR)/%.ora.png | $(MYPAINT_DEST_DIR) + convert -density $(MYPAINT_PDF_DENSITY) $< $@ + +.PHONY: mypaint-ora-jpg +mypaint-ora-jpg: $(MYPAINT_ORA_JPG) + +.PHONY: mypaint-ora-png +mypaint-ora-png: $(MYPAINT_ORA_PNG) + +.PHONY: mypaint-ora-pdf +mypaint-ora-pdf: $(MYPAINT_ORA_PDF) + +.PHONY: mypaint-jpg +mypaint-jpg: mypaint-ora-jpg + +.PHONY: mypaint-png +mypaint-png: mypaint-ora-png + +.PHONY: mypaint-pdf +mypaint-pdf: mypaint-ora-pdf + +.PHONY: mypaint-clean-jpg +mypaint-clean-jpg: + rm -f $(MYPAINT_ORA_JPG) + +.PHONY: mypaint-clean-png +mypaint-clean-png: + rm -f $(MYPAINT_ORA_PNG) + +.PHONY: mypaint-clean-pdf +mypaint-clean-pdf: + rm -f $(MYPAINT_ORA_PDF) + +.PHONY: mypaint-clean +mypaint-clean: mypaint-clean-pdf mypaint-clean-jpg + +.PHONY: mypaint-info +mypaint-info: + @echo "MYPAINT:" + @echo " External variables:" + @echo " MYPAINT_SUFFIX: $(MYPAINT_SUFFIX)" + @echo " MYPAINT_SRC_DIR: $(MYPAINT_SRC_DIR)" + @echo " MYPAINT_DEST_DIR: $(MYPAINT_DEST_DIR)" + @echo " MYPAINT_PDF_DENSITY: $(MYPAINT_PDF_DENSITY)" + @echo " MYPAINT_JPG_QUALITY: $(MYPAINT_JPG_QUALITY)" + @echo " Internal variables" + @echo " MYPAINT_ORA: $(MYPAINT_ORA)" + @echo " MYPAINT_ORA_PNG: $(MYPAINT_ORA_PDF)" + @echo " MYPAINT_ORA_PDF: $(MYPAINT_ORA_PDF)" + @echo " MYPAINT_ORA_JPG: $(MYPAINT_ORA_JPG)" +