-
Notifications
You must be signed in to change notification settings - Fork 12
/
makefile
72 lines (57 loc) · 2.03 KB
/
makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# based on https://gist.github.com/sukima/52eacde54bf7861b19ee66a07b864583
# Makefile for PlantUML
# Author: Devin Weaver (@sukima) <[email protected]>
# GistID: 52eacde54bf7861b19ee66a07b864583
#
# This handles SVGs PNGs and ASCII outputs.
# It handles included files with the .iuml extension: !include foo.iuml
# All diagrams have the .puml extension and reside in the diagrams directory
# All output is saved to the output directory
#
# make svg - (default) build all diagrams as SVGs
# make png - build all diagrams as PNGs
# make ascii - build all diagrams as ACII Art text files (.atxt)
# make all - build SVG, PNG, and ASCII files
# make depend - build the dependency cache (also done automatically)
# make clean - clean up build artifacts and output files
#
# Diagrams can be built in parrallel with `make -j`.
# If you installed plantuml from Homebrew (brew install plantuml) use this:
# PLANTUML = plantuml
PLANTUML = plantuml
SRC = imagesAsCode
OUTPUT = images
DEPEND = .depend
SRC_FILES := $(wildcard $(SRC)/*.puml)
.PHONY: default all depend clean ascii svg png atxt
default: png
all: svg png ascii
depend: $(DEPEND)
clean:
rm -rf $(OUTPUT) $(DEPEND)
ascii: atxt
svg png atxt: $(DEPEND)
@$(MAKE) $(patsubst $(SRC)/%.puml,$(OUTPUT)/%.$@,$(shell ls -1t $(SRC_FILES)))
$(OUTPUT)/%.svg: $(SRC)/%.puml
$(PLANTUML) -tsvg $< -o ../$(OUTPUT)
$(OUTPUT)/%.png: $(SRC)/%.puml
$(PLANTUML) -tpng $< -o ../$(OUTPUT)
$(OUTPUT)/%.atxt: $(SRC)/%.puml
$(PLANTUML) -ttxt $< -o ../$(OUTPUT)
$(DEPEND): $(SRC_FILES)
@find_includes() { \
sed \
-e "s,^[[:space:]]*!include \([^<].*[^>]\)$$,$${1}/\1," \
-e t -e d "$$2" \
| paste -sd " " -; \
}; \
echo "# GENERATED BY make depend" > $@; \
echo "# DO NOT EDIT" >> $@; \
echo >> $@; \
for file in $^; do \
name="$$(basename -s .puml "$$file")"; \
includes="$$(find_includes "$(SRC)" "$$file")"; \
printf "$(OUTPUT)/%s.svg: %s\n" "$$name" "$$includes"; \
printf "$(OUTPUT)/%s.png: %s\n" "$$name" "$$includes"; \
printf "$(OUTPUT)/%s.atxt: %s\n" "$$name" "$$includes"; \
done >> $@