makefiles-forever/graphviz.mk

61 lines
1.3 KiB
Makefile
Raw Normal View History

##
## GRAPHVIZ MODULE
##
##
2021-07-23 14:07:42 +00:00
## External variables influencing build process (API)
##
2021-07-23 14:07:42 +00:00
GRAPHVIZ_SRC_DIR ?=
GRAPHVIZ_DEST_DIR ?=
##
## Internal variables
##
## Find .dot graphs
2021-07-23 14:07:42 +00:00
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))
## Find .circo graphs
2021-07-23 14:07:42 +00:00
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_SVG := $(GRAPHVIZ_DOT_SVG) $(GRAPHVIZ_CIRCO_SVG)
##
## Prerequisistes (system packages)
##
2021-07-23 14:07:42 +00:00
GRAPHVIZ_APT_PACKAGES := graphviz
##
## Rules
##
$(GRAPHVIZ_DEST_DIR):
mkdir -p $(GRAPHVIZ_DEST_DIR)
$(GRAPHVIZ_DEST_DIR)/%.dot.svg: $(GRAPHVIZ_SRC_DIR)/%.dot | $(GRAPHVIZ_DEST_DIR)
dot -Tsvg $< > $@
$(GRAPHVIZ_DEST_DIR)/%.circo.svg: $(GRAPHVIZ_SRC_DIR)/%.circo | $(GRAPHVIZ_DEST_DIR)
circo -Tsvg $< > $@
2021-07-23 14:07:42 +00:00
$(GRAPHVIZ_SVG): | $(GRAPHVIZ_DEST_DIR)
mkdir -p $(GRAPHVIZ_DEST_DIR)
2021-07-23 14:07:42 +00:00
graphviz-build-dot-svg: $(GRAPHVIZ_DOT_SVG)
2021-07-23 14:07:42 +00:00
graphviz-build-circo-svg: $(GRAPHVIZ_CIRCO_SVG)
2021-07-23 14:07:42 +00:00
graphviz-build-svg: graphviz-build-dot-svg graphviz-build-circo-svg
graphviz-build: graphviz-build-svg
# Clean
#
graphviz-clean-svg:
2021-07-23 14:07:42 +00:00
rm -f $(GRAPHVIZ_SVG)
2021-07-23 14:07:42 +00:00
graphviz-clean: graphviz-clean-svg