2024-01-05 21:36:38 +00:00
|
|
|
# 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>
|
|
|
|
|
2021-07-23 13:39:44 +00:00
|
|
|
##
|
|
|
|
## PLANTUML MODULE
|
|
|
|
##
|
|
|
|
|
|
|
|
##
|
|
|
|
## External variables (API)
|
|
|
|
##
|
2024-01-05 18:24:35 +00:00
|
|
|
PLANTUML_SUFFIX ?= uml
|
2023-12-18 16:25:07 +00:00
|
|
|
PLANTUML_SRC_DIR ?=
|
|
|
|
PLANTUML_DEST_DIR ?=
|
2024-01-05 21:49:47 +00:00
|
|
|
PLANTUML_PLANTUML_COMMAND ?= podman run -i plantuml/plantuml plantuml
|
|
|
|
PLANTUML_RSVGCONVERT_COMMAND ?= rsvg-convert
|
|
|
|
PLANTUML_GHOSTSCRIPT_COMMAND ?= gs
|
2021-07-23 13:39:44 +00:00
|
|
|
|
|
|
|
##
|
2024-01-05 18:24:35 +00:00
|
|
|
## Internal variables (lazy recursive evaluation)
|
2021-07-23 13:39:44 +00:00
|
|
|
##
|
|
|
|
|
2024-01-05 21:36:38 +00:00
|
|
|
## Find .uml files
|
2024-01-05 18:24:35 +00:00
|
|
|
PLANTUML_UML = $(shell find $(PLANTUML_SRC_DIR) \( -name '*.uml' ! -name '_*' \))
|
|
|
|
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))
|
2021-07-23 13:39:44 +00:00
|
|
|
|
2024-01-05 21:49:47 +00:00
|
|
|
##
|
|
|
|
## Prerequisistes (system packages)
|
|
|
|
##
|
|
|
|
GRAPHVIZ_APT_PACKAGES := plantuml librsvg2-bin ghostscript
|
|
|
|
|
2021-07-23 13:39:44 +00:00
|
|
|
##
|
|
|
|
## Rules
|
|
|
|
##
|
|
|
|
|
2023-12-18 16:25:07 +00:00
|
|
|
$(PLANTUML_DEST_DIR):
|
|
|
|
mkdir -p $(PLANTUML_DEST_DIR)
|
2021-07-23 13:39:44 +00:00
|
|
|
|
2024-01-05 18:24:35 +00:00
|
|
|
$(PLANTUML_DEST_DIR)/%.uml.png: $(PLANTUML_SRC_DIR)/%.uml | $(PLANTUML_DEST_DIR)
|
2024-01-05 22:37:10 +00:00
|
|
|
$(PLANTUML_PLANTUML_COMMAND) -pipe -tpng < $< > $@
|
2024-01-05 18:24:35 +00:00
|
|
|
|
2023-12-18 16:25:07 +00:00
|
|
|
$(PLANTUML_DEST_DIR)/%.uml.svg: $(PLANTUML_SRC_DIR)/%.uml | $(PLANTUML_DEST_DIR)
|
2024-01-05 22:37:10 +00:00
|
|
|
$(PLANTUML_PLANTUML_COMMAND) -pipe -tsvg < $< > $@
|
2021-07-23 13:39:44 +00:00
|
|
|
|
2024-01-05 20:41:37 +00:00
|
|
|
$(PLANTUML_DEST_DIR)/%.uml.pdf: $(PLANTUML_DEST_DIR)/%.uml.svg | $(PLANTUML_DEST_DIR)
|
2024-01-05 21:49:47 +00:00
|
|
|
$(PLANTUML_RSVGCONVERT_COMMAND) -f ps $< | $(PLANTUML_GHOSTSCRIPT_COMMAND) -sDEVICE=pdfwrite -sOutputFile=$@ -f -
|
2024-01-05 21:36:38 +00:00
|
|
|
|
2021-07-23 13:39:44 +00:00
|
|
|
|
2023-12-18 16:25:07 +00:00
|
|
|
.PHONY: plantuml-uml-svg
|
|
|
|
plantuml-uml-svg: $(PLANTUML_UML_SVG)
|
|
|
|
|
2024-01-05 18:24:35 +00:00
|
|
|
.PHONY: plantuml-uml-png
|
|
|
|
plantuml-uml-png: $(PLANTUML_UML_PNG)
|
|
|
|
|
2023-12-18 16:25:07 +00:00
|
|
|
.PHONY: plantuml-uml-pdf
|
|
|
|
plantuml-uml-pdf: $(PLANTUML_UML_PDF)
|
|
|
|
|
|
|
|
.PHONY: plantuml-svg
|
|
|
|
plantuml-svg: plantuml-uml-svg
|
|
|
|
|
2024-01-05 18:24:35 +00:00
|
|
|
.PHONY: plantuml-png
|
|
|
|
plantuml-png: plantuml-uml-png
|
|
|
|
|
2023-12-18 16:25:07 +00:00
|
|
|
.PHONY: plantuml-pdf
|
|
|
|
plantuml-pdf: plantuml-uml-pdf
|
|
|
|
|
|
|
|
.PHONY: plantuml-clean-svg
|
2021-07-23 13:39:44 +00:00
|
|
|
plantuml-clean-svg:
|
2023-12-18 16:25:07 +00:00
|
|
|
rm -f $(PLANTUML_UML_SVG)
|
|
|
|
|
2024-01-05 18:24:35 +00:00
|
|
|
.PHONY: plantuml-clean-png
|
|
|
|
plantuml-clean-png:
|
|
|
|
rm -f $(PLANTUML_UML_PNG)
|
|
|
|
|
2023-12-18 16:25:07 +00:00
|
|
|
.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:
|
2024-01-05 22:01:22 +00:00
|
|
|
@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)"
|
2021-07-23 13:39:44 +00:00
|
|
|
|