Merge branch 'master' of code.apps.glenux.net:glenux/makefiles-forever

This commit is contained in:
Glenn Y. Rolland 2024-01-06 11:41:32 +01:00
commit bb6839e9ce
6 changed files with 376 additions and 53 deletions

View file

@ -1,4 +1,35 @@
# Usage example
##
## Local configuration
##
##
## Configuration of input variables for libraries
##
PLANTUML_SRC_DIR = $(SOURCE_DIR)/plantuml
PLANTUML_DEST_DIR = $(IMAGES_DIR)/plantuml
MOCODO_SRC_DIR = $(SOURCE_DIR)/mocodo
MOCODO_DEST_DIR = $(IMAGES_DIR)/mocodo
GRAPHVIZ_SRC_DIR = $(SOURCE_DIR)/graphviz
GRAPHVIZ_DEST_DIR = $(IMAGES_DIR)/graphviz
##
## Include libraries
##
include mocodo.mk
include dot.mk
include plantuml.mk
##
## Rules
##
.PHONY: build
build: plantuml-build mocodo-build graphviz-build
.PHONY: clean
clean: plantuml-clean mocodo-clean graphviz-clean
-include mocodo.mk
-include dot.mk
-include plantuml.mk

View file

@ -1,60 +1,113 @@
<!--
# SPDX-License-Identifier: LGPL-3.0-or-later
#
# SPDX-FileCopyrightText: 2023 Glenn Y. Rolland <glenux@glenux.net>
# Copyright © 2023 Glenn Y. Rolland <glenux@glenux.net>
-->
[![Build Status](https://cicd.apps.glenux.net/api/badges/glenux/makefiles-forever/status.svg)](https://cicd.apps.glenux.net/glenux/makefiles-forever)
![License LGPL3.0-or-later](https://img.shields.io/badge/license-LGPL3.0--or--later-blue.svg)
[![Donate on patreon](https://img.shields.io/badge/patreon-donate-orange.svg)](https://patreon.com/glenux)
> :information_source: This project is available on our self-hosted server and
> on CodeBerg and GitHub as mirrors. For the latest updates and comprehensive
> version of our project, please visit our primary repository at:
> <https://code.apps.glenux.net/glenux/makefiles-forever>.
# Makefiles Forever # Makefiles Forever
A drop-in collection of makefiles libraries for your projects A drop-in collection of makefiles libraries for your projects
## Description ## Description
* plantuml.makefile — Build [plantuml](https://plantuml.com/) diagrams * plantuml.mk — Automate the building [plantuml](https://plantuml.com/) diagrams.
* dot.mk — Build [graphviz](https://graphviz.org/) graph diagrams * graphviz.mk — Streamline the creation of [graphviz](https://graphviz.org/) graph diagrams.
* mocodo.mk — Build [mocodo](http://mocodo.wingi.net/) entity-relation and logical diagrams * mocodo.mk — Facilitate the development of [mocodo](http://mocodo.wingi.net/) entity-relation and logical diagrams.
* mypaint.mk - Automate the conversion of [mypaint](https://mypaint.app/) openraster images to usual image formats.
## Usage ## Usage
Add this repository as a GIT submodule of your project ### Adding to your project
To include 'Makefiles Forever' in your project, add this repository as a GIT
submodule:
```shell-session ```shell-session
$ git submodule add https://github.com/glenux/makefiles-forever .makefiles $ git submodule add https://github.com/glenux/makefiles-forever .makefiles
``` ```
Include needed features in the end of your makefile ### Configuring your makefiles
In your project's makefile, include the necessary modules. __The `include` instructions must be located
after your existing targets__.
```makefile ```makefile
# [...] # [...variable definitions...]
-include .makefiles/featureA.mk # Include as many Makefiles Forever features as your want
-include .makefiles/featureB.mk include .makefiles/plantuml.mk
include .makefiles/mocodo.mk
# [...include as many modules as you want...]
# [...targets definitions...]
``` ```
Declare API variables (ex: `*_SRC_DIR`, `*_DEST_DIR`) for each module Declare API variables (ex: `*_SRC_DIR`, `*_DEST_DIR`) for each module
```makefile ```makefile
# Configuration for featureA from Makefiles Forever # PlantUML Configuration
FEATUREA_SRC_DIR=/path/to/somewhere PLANTUML_SRC_DIR=/path/to/plantuml/files
FEATUREA_DEST_DIR=/some/other/path PLANTUML_DEST_DIR=/path/to/output/directory
# Configuration for featureB from Makefiles Forever # Mocodo Configuration
FEATUREA_SRC_DIR=/another/path MOCODO_SRC_DIR=/path/to/mocodo/files
FEATUREB_DEST_DIR=/a/different/one MOCODO_DEST_DIR=/path/to/output/directory
# [...you the external variables of the modules you included...]
# [ ... etc ...]
``` ```
Use pre-defined targets as dependencies of your targets: Use pre-defined targets in your build process, as dependencies of your existing
targets:
```makefile ```makefile
build: featureA-build
build: featureB-build
clean: featureA-clean build: plantuml-build mocodo-build graphviz-build
clean: featureB-clean
clean: plantuml-clean mocodo-clean graphviz-clean
``` ```
Feature files usually define more targets than just build and clean, and you Feature files usually define more targets than just build and clean, and you
can use those too! can use those too!
## Good practices for coding .mk files ## Best practices used in our .mk modules
* Keep task parallelism in mind * Parallel Execution: We ensure targets are available from the root makefile and avoid descending into subdirectories for parallel execution.
* Make all targets available from root makefile * Modular Design: We keep our makefiles modular for easy maintenance and scalability.
* Do not descend in subdirectories * Documentation: We comment our makefiles for clarity and ease of use by others.
## Contributing
Contributions are what make the open-source community such an amazing place to
learn, inspire, and create. Any contributions you make are **greatly
appreciated**.
## Troubleshooting and Support
If you encounter any issues or need support, please open an issue in
[the project's issue tracker](https://code.apps.glenux.net/glenux/makefiles-forever/issues).
We strive to be responsive and helpful.
## License
Distributed under the LGPL-3.0-or-later License. See `LICENSE` file for more
information.
## Acknowledgments
* A special thanks to all contributors and users of this project for their
valuable feedback and support.

View file

@ -1,3 +1,8 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
#
# SPDX-FileCopyrightText: 2023 Glenn Y. Rolland <glenux@glenux.net>
# Copyright © 2023 Glenn Y. Rolland <glenux@glenux.net>
## ##
## GRAPHVIZ MODULE ## GRAPHVIZ MODULE
## ##
@ -15,11 +20,18 @@ GRAPHVIZ_DEST_DIR ?=
## Find .dot graphs ## Find .dot graphs
GRAPHVIZ_DOT := $(shell find $(GRAPHVIZ_SRC_DIR) \( -name '*.dot' ! -name '_*' \)) GRAPHVIZ_DOT := $(shell find $(GRAPHVIZ_SRC_DIR) \( -name '*.dot' ! -name '_*' \))
GRAPHVIZ_DOT_SVG := $(patsubst $(GRAPHVIZ_SRC_DIR)/%.dot,$(GRAPHVIZ_DEST_DIR)/%.dot.svg,$(GRAPHVIZ_DOT)) GRAPHVIZ_DOT_SVG := $(patsubst $(GRAPHVIZ_SRC_DIR)/%.dot,$(GRAPHVIZ_DEST_DIR)/%.dot.svg,$(GRAPHVIZ_DOT))
GRAPHVIZ_DOT_PNG := $(patsubst $(GRAPHVIZ_SRC_DIR)/%.dot,$(GRAPHVIZ_DEST_DIR)/%.dot.png,$(GRAPHVIZ_DOT))
GRAPHVIZ_DOT_PDF := $(patsubst $(GRAPHVIZ_SRC_DIR)/%.dot,$(GRAPHVIZ_DEST_DIR)/%.dot.pdf,$(GRAPHVIZ_DOT))
## Find .circo graphs ## Find .circo graphs
GRAPHVIZ_CIRCO := $(shell find $(GRAPHVIZ_SRC_DIR) \( -name '*.circo' ! -name '_*' \)) GRAPHVIZ_CIRCO := $(shell find $(GRAPHVIZ_SRC_DIR) \( -name '*.circo' ! -name '_*' \))
GRAPHVIZ_CIRCO_SVG := $(patsubst $(GRAPHVIZ_SRC_DIR)/%.circo,$(GRAPHVIZ_DEST_DIR)/%.circo.svg,$(GRAPHVIZ_CIRCO)) GRAPHVIZ_CIRCO_SVG := $(patsubst $(GRAPHVIZ_SRC_DIR)/%.circo,$(GRAPHVIZ_DEST_DIR)/%.circo.svg,$(GRAPHVIZ_CIRCO))
GRAPHVIZ_CIRCO_PNG := $(patsubst $(GRAPHVIZ_SRC_DIR)/%.circo,$(GRAPHVIZ_DEST_DIR)/%.circo.png,$(GRAPHVIZ_CIRCO))
GRAPHVIZ_CIRCO_PDF := $(patsubst $(GRAPHVIZ_SRC_DIR)/%.circo,$(GRAPHVIZ_DEST_DIR)/%.circo.pdf,$(GRAPHVIZ_CIRCO))
GRAPHVIZ_SVG := $(GRAPHVIZ_DOT_SVG) $(GRAPHVIZ_CIRCO_SVG) GRAPHVIZ_SVG := $(GRAPHVIZ_DOT_SVG) $(GRAPHVIZ_CIRCO_SVG)
GRAPHVIZ_PNG := $(GRAPHVIZ_DOT_PNG) $(GRAPHVIZ_CIRCO_PNG)
GRAPHVIZ_PDF := $(GRAPHVIZ_DOT_PDF) $(GRAPHVIZ_CIRCO_PDF)
## ##
## Prerequisistes (system packages) ## Prerequisistes (system packages)
@ -30,27 +42,48 @@ GRAPHVIZ_APT_PACKAGES := graphviz
## Rules ## Rules
## ##
$(GRAPHVIZ_DEST_DIR)/%.dot.svg: $(GRAPHVIZ_SRC_DIR)/%.dot $(GRAPHVIZ_DEST_DIR):
mkdir -p $(GRAPHVIZ_DEST_DIR)
$(GRAPHVIZ_DEST_DIR)/%.dot.svg: $(GRAPHVIZ_SRC_DIR)/%.dot | $(GRAPHVIZ_DEST_DIR)
dot -Tsvg $< > $@ dot -Tsvg $< > $@
$(GRAPHVIZ_DEST_DIR)/%.circo.svg: $(GRAPHVIZ_SRC_DIR)/%.circo $(GRAPHVIZ_DEST_DIR)/%.circo.svg: $(GRAPHVIZ_SRC_DIR)/%.circo | $(GRAPHVIZ_DEST_DIR)
circo -Tsvg $< > $@ circo -Tsvg $< > $@
$(GRAPHVIZ_SVG): | $(GRAPHVIZ_DEST_DIR) $(GRAPHVIZ_SVG): | $(GRAPHVIZ_DEST_DIR)
$(GRAPHVIZ_PDF): | $(GRAPHVIZ_DEST_DIR)
$(GRAPHVIZ_PNG): | $(GRAPHVIZ_DEST_DIR)
.PHONY: graphviz-build-dot-svg
graphviz-build-dot-svg: $(GRAPHVIZ_DOT_SVG) graphviz-build-dot-svg: $(GRAPHVIZ_DOT_SVG)
.PHONY: graphviz-build-circo-svg
graphviz-build-circo-svg: $(GRAPHVIZ_CIRCO_SVG) graphviz-build-circo-svg: $(GRAPHVIZ_CIRCO_SVG)
.PHONY: graphviz-build-svg
graphviz-build-svg: graphviz-build-dot-svg graphviz-build-circo-svg graphviz-build-svg: graphviz-build-dot-svg graphviz-build-circo-svg
.PHONY: graphviz-buil
graphviz-build: graphviz-build-svg graphviz-build: graphviz-build-svg
# Clean # Clean
# #
.PHONY: graphviz-clean-svg
graphviz-clean-svg: graphviz-clean-svg:
rm -f $(GRAPHVIZ_SVG) rm -f $(GRAPHVIZ_SVG)
graphviz-clean: graphviz-clean-svg .PHONY: graphviz-clean-pdf
graphviz-clean-pdf:
rm -f $(GRAPHVIZ_PDF)
.PHONY: graphviz-clean-png
graphviz-clean-png:
rm -f $(GRAPHVIZ_PNG)
.PHONY: graphviz-clean
graphviz-clean: graphviz-clean-svg graphviz-clean-png graphviz-clean-pdf

View file

@ -1,3 +1,8 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
#
# SPDX-FileCopyrightText: 2023 Glenn Y. Rolland <glenux@glenux.net>
# Copyright © 2023 Glenn Y. Rolland <glenux@glenux.net>
## ##
## MOCODO MODULE ## MOCODO MODULE
## ##
@ -5,26 +10,31 @@
## ##
## External variables (API) ## External variables (API)
## ##
MOCODO_OPT=--colors brewer-6 --shapes verdana MOCODO_OPT ?= --colors brewer-6 --shapes verdana
MOCODO_SRC_DIR= MOCODO_SRC_DIR ?=
MOCODO_DEST_DIR= MOCODO_DEST_DIR ?=
## ##
## Internal variables ## Internal variables (lazy recursive evaluation)
## ##
MOCODO_MCD_FILES=$(shell find $(MOCODO_SRC_DIR) \( -name '*.mcd' ! -name '_*' \))
MOCODO_MCD_MLD=$(patsubst $(MOCODO_SRC_DIR)/%.mcd,$(MOCODO_DEST_DIR)/%.mcd.mld,$(MOCODO_MCD_FILES))
MOCODO_MCD_SVG=$(patsubst $(MOCODO_SRC_DIR)/%.mcd,$(MOCODO_DEST_DIR)/%.mcd.svg,$(MOCODO_MCD_FILES))
MOCODO_MCD_PDF=$(patsubst $(MOCODO_SRC_DIR)/%.mcd,$(MOCODO_DEST_DIR)/%.mcd.pdf,$(MOCODO_MCD_FILES))
MOCODO_MLD_FILES=$(shell find $(MOCODO_SRC_DIR) \( -name '*.mld' ! -name '_*' \)) $(MOCODO_MCD_MLD) ## Find .mcd and .mld files
MOCODO_MLD_SVG=$(patsubst $(MOCODO_SRC_DIR)/%.mld,$(MOCODO_DEST_DIR)/%.mld.svg,$(MOCODO_MLD_FILES)) ## Convert .mcd to .mcd.mld, .mcd.svg and .mcd.pdf files
MOCODO_MLD_PDF=$(patsubst $(MOCODO_SRC_DIR)/%.mld,$(MOCODO_DEST_DIR)/%.mld.pdf,$(MOCODO_MLD_FILES)) ## Convert .mld to .mld.svg, and .mld.pdf files
MOCODO_MCD_FILES = $(shell find $(MOCODO_SRC_DIR) \( -name '*.mcd' ! -name '_*' \))
MOCODO_MCD_MLD = $(patsubst $(MOCODO_SRC_DIR)/%.mcd,$(MOCODO_DEST_DIR)/%.mcd.mld,$(MOCODO_MCD_FILES))
MOCODO_MCD_SVG = $(patsubst $(MOCODO_SRC_DIR)/%.mcd,$(MOCODO_DEST_DIR)/%.mcd.svg,$(MOCODO_MCD_FILES))
MOCODO_MCD_PDF = $(patsubst $(MOCODO_SRC_DIR)/%.mcd,$(MOCODO_DEST_DIR)/%.mcd.pdf,$(MOCODO_MCD_FILES))
MOCODO_MLD_FILES = $(shell find $(MOCODO_SRC_DIR) \( -name '*.mld' ! -name '_*' \)) $(MOCODO_MCD_MLD)
MOCODO_MLD_SVG = $(patsubst $(MOCODO_SRC_DIR)/%.mld,$(MOCODO_DEST_DIR)/%.mld.svg,$(MOCODO_MLD_FILES))
MOCODO_MLD_PDF = $(patsubst $(MOCODO_SRC_DIR)/%.mld,$(MOCODO_DEST_DIR)/%.mld.pdf,$(MOCODO_MLD_FILES))
## ##
## Prerequisistes (system packages) ## Prerequisistes (system packages)
## ##
MOCODO_APT_PACKAGES=ghostscript librsvg2-bin MOCODO_APT_PACKAGES = ghostscript librsvg2-bin
## ##
## Rules ## Rules
@ -71,26 +81,56 @@ $(MOCODO_DEST_DIR)/%.mcd.pdf: $(MOCODO_SRC_DIR)/%.mcd.svg
# rsvg-convert -f pdf $< > $@ # rsvg-convert -f pdf $< > $@
rsvg-convert -f ps $< | gs -sDEVICE=pdfwrite -sOutputFile=$@ -f - rsvg-convert -f ps $< | gs -sDEVICE=pdfwrite -sOutputFile=$@ -f -
.PHONY: mocodo-mcd-mld
mocodo-mcd-mld: $(MOCODO_MCD_MLD) mocodo-mcd-mld: $(MOCODO_MCD_MLD)
.PHONY: mocodo-mcd-svg
mocodo-mcd-svg: $(MOCODO_MCD_SVG) mocodo-mcd-svg: $(MOCODO_MCD_SVG)
.PHONY: mocodo-mld-pdf
mocodo-mcd-pdf: $(MOCODO_MCD_PDF)
.PHONY: mocodo-mld-svg
mocodo-mld-svg: $(MOCODO_MLD_SVG) mocodo-mld-svg: $(MOCODO_MLD_SVG)
mocodo-mcd-pdf: $(MOCODO_MCD_PDF) .PHONY: mocodo-mld-pdf
mocodo-mld-pdf: $(MOCODO_MLD_PDF) mocodo-mld-pdf: $(MOCODO_MLD_PDF)
.PHONY: mocodo-svg
mocodo-svg: mocodo-mcd-svg mocodo-mld-svg mocodo-svg: mocodo-mcd-svg mocodo-mld-svg
.PHONY: mocodo-pdf
mocodo-pdf: mocodo-mcd-pdf mocodo-mld-pdf mocodo-pdf: mocodo-mcd-pdf mocodo-mld-pdf
.PHONY: mocodo-clean-mld
mocodo-clean-mld: mocodo-clean-mld:
rm -f $(MOCODO_MCD_MLD) rm -f $(MOCODO_MCD_MLD)
.PHONY: mocodo-clean-svg
mocodo-clean-svg: mocodo-clean-svg:
rm -f $(MOCODO_MCD_SVG) $(MOCODO_MLD_SVG) rm -f $(MOCODO_MCD_SVG) $(MOCODO_MLD_SVG)
.PHONY: mocodo-clean-pdf
mocodo-clean-pdf: mocodo-clean-pdf:
rm -f $(MOCODO_MCD_PDF) $(MOCODO_MLD_PDF) rm -f $(MOCODO_MCD_PDF) $(MOCODO_MLD_PDF)
.PHONY: mocodo-clean
mocodo-clean: mocodo-clean-mld mocodo-clean-svg mocodo-clean-pdf mocodo-clean: mocodo-clean-mld mocodo-clean-svg mocodo-clean-pdf
.PHONY: mocodo-info
mocodo-info:
@echo "MOCODO:"
@echo " External variables:"
@echo " MOCODO_OPT: $(MOCODO_OPT)"
@echo " MOCODO_SRC_DIR: $(MOCODO_SRC_DIR)"
@echo " MOCODO_DEST_DIR: $(MOCODO_DEST_DIR)"
@echo " Internal variables"
@echo " MOCODO_MCD_FILES: $(MOCODO_MCD_FILES)"
@echo " MOCODO_MLD_FILES: $(MOCODO_MLD_FILES)"
@echo " MOCODO_MCD_MLD: $(MOCODO_MCD_MLD)"
@echo " MOCODO_MCD_SVG: $(MOCODO_MCD_SVG)"
@echo " MOCODO_MCD_PDF: $(MOCODO_MCD_PDF)"
@echo " MOCODO_MLD_FILES: $(MOCODO_MLD_FILES)"
@echo " MOCODO_MLD_SVG: $(MOCODO_MLD_SVG)"
@echo " MOCODO_MLD_PDF: $(MOCODO_MLD_PDF)"

View file

@ -0,0 +1,100 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
#
# SPDX-FileCopyrightText: 2023 Glenn Y. Rolland <glenux@glenux.net>
# Copyright © 2023 Glenn Y. Rolland <glenux@glenux.net>
##
## 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)"

View file

@ -1,3 +1,8 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
#
# SPDX-FileCopyrightText: 2023 Glenn Y. Rolland <glenux@glenux.net>
# Copyright © 2023 Glenn Y. Rolland <glenux@glenux.net>
## ##
## PLANTUML MODULE ## PLANTUML MODULE
## ##
@ -5,30 +10,91 @@
## ##
## External variables (API) ## External variables (API)
## ##
PLANTUML_SRC_DIR= PLANTUML_SUFFIX ?= uml
PLANTUML_DEST_DIR= PLANTUML_SRC_DIR ?=
PLANTUML_DEST_DIR ?=
PLANTUML_PLANTUML_COMMAND ?= podman run -i plantuml/plantuml plantuml
PLANTUML_RSVGCONVERT_COMMAND ?= rsvg-convert
PLANTUML_GHOSTSCRIPT_COMMAND ?= gs
## ##
## Internal variables ## Internal variables (lazy recursive evaluation)
## ##
## Find .uml graphs ## Find .uml files
PLANTUML_UML=$(shell find $(PLANTUML_SRC_DIR) \( -name '*.uml' ! -name '_*' \)) PLANTUML_UML = $(shell find $(PLANTUML_SRC_DIR) \( -name '*.uml' ! -name '_*' \))
PLANTUML_UML_SVG=$(patsubst $(PLANTUML_SRC_DIR)/%.uml,$(PLANTUML_DEST_DIR)/%.uml.svg,$(PLANTUML_UML)) PLANTUML_UML_PNG = $(patsubst $(PLANTUML_SRC_DIR)/%.uml,$(PLANTUML_DEST_DIR)/%.uml.png,$(PLANTUML_UML))
PLANTUML_UML_SVG = $(patsubst $(PLANTUML_SRC_DIR)/%.uml,$(PLANTUML_DEST_DIR)/%.uml.svg,$(PLANTUML_UML))
PLANTUML_UML_PDF = $(patsubst $(PLANTUML_SRC_DIR)/%.uml,$(PLANTUML_DEST_DIR)/%.uml.pdf,$(PLANTUML_UML))
##
## Prerequisistes (system packages)
##
GRAPHVIZ_APT_PACKAGES := plantuml librsvg2-bin ghostscript
## ##
## Rules ## Rules
## ##
$(PLANTUML_DEST_DIR)/%.uml.svg: $(PLANTUML_SRC_DIR)/%.uml
plantuml -pipe -tsvg < $< > $@ $(PLANTUML_DEST_DIR):
mkdir -p $(PLANTUML_DEST_DIR)
$(PLANTUML_DEST_DIR)/%.uml.png: $(PLANTUML_SRC_DIR)/%.uml | $(PLANTUML_DEST_DIR)
$(PLANTUML_PLANTUML_COMMAND) -pipe -tpng < $< > $@
$(PLANTUML_DEST_DIR)/%.uml.svg: $(PLANTUML_SRC_DIR)/%.uml | $(PLANTUML_DEST_DIR)
$(PLANTUML_PLANTUML_COMMAND) -pipe -tsvg < $< > $@
$(PLANTUML_DEST_DIR)/%.uml.pdf: $(PLANTUML_DEST_DIR)/%.uml.svg | $(PLANTUML_DEST_DIR)
$(PLANTUML_RSVGCONVERT_COMMAND) -f ps $< | $(PLANTUML_GHOSTSCRIPT_COMMAND) -sDEVICE=pdfwrite -sOutputFile=$@ -f -
plantuml-uml-svg: .PHONY: plantuml-uml-svg
plantuml-uml-svg: $(PLANTUML_UML_SVG)
plantuml-svg: .PHONY: plantuml-uml-png
plantuml-uml-png: $(PLANTUML_UML_PNG)
.PHONY: plantuml-uml-pdf
plantuml-uml-pdf: $(PLANTUML_UML_PDF)
.PHONY: plantuml-svg
plantuml-svg: plantuml-uml-svg
.PHONY: plantuml-png
plantuml-png: plantuml-uml-png
.PHONY: plantuml-pdf
plantuml-pdf: plantuml-uml-pdf
.PHONY: plantuml-clean-svg
plantuml-clean-svg: plantuml-clean-svg:
rm -f $(PLANTUML_UML_SVG)
plantuml-clean: .PHONY: plantuml-clean-png
plantuml-clean-png:
rm -f $(PLANTUML_UML_PNG)
.PHONY: plantuml-clean-pdf
plantuml-clean-pdf:
rm -f $(PLANTUML_UML_PDF)
.PHONY: plantuml-clean
plantuml-clean: plantuml-clean-pdf plantuml-clean-svg
.PHONY: plantuml-info
plantuml-info:
@echo "PLANTUML:"
@echo " External variables:"
@echo " PLANTUML_SUFFIX: $(PLANTUML_SUFFIX)"
@echo " PLANTUML_DEST_DIR: $(PLANTUML_DEST_DIR)"
@echo " PLANTUML_SRC_DIR: $(PLANTUML_SRC_DIR)"
@echo " PLANTUML_PLANTUML_COMMAND: $(PLANTUML_PLANTUML_COMMAND)"
@echo " PLANTUML_RSVGCONVERT_COMMAND: $(PLANTUML_RSVGCONVERT_COMMAND)"
@echo " PLANTUML_GHOSTSCRIPT_COMMAND: $(PLANTUML_GHOSTSCRIPT_COMMAND)"
@echo " Internal variables"
@echo " PLANTUML_UML: $(PLANTUML_UML)"
@echo " PLANTUML_UML_PDF: $(PLANTUML_UML_PDF)"
@echo " PLANTUML_UML_PNG: $(PLANTUML_UML_PNG)"
@echo " PLANTUML_UML_SVG: $(PLANTUML_UML_SVG)"