Skip to content

Instantly share code, notes, and snippets.

@colindean
Last active October 14, 2019 22:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save colindean/8a323d40a594197edde21de1226ab5b0 to your computer and use it in GitHub Desktop.
Save colindean/8a323d40a594197edde21de1226ab5b0 to your computer and use it in GitHub Desktop.
Generic base Makefile for a directory with Graphviz dot files to generate PNG and SVG
# reusable Graphviz dot -> (PNG,SVG) makefile
DOT=dot
PNGCRUSH=pngcrush
SVGO=svgo
DOTS=$(wildcard *.dot)
PNGS=$(DOTS:.dot=.png)
SVGS=$(DOTS:.dot=.svg)
diagrams: $(PNGS) $(SVGS)
%.png: %.dot
$(DOT) "-Tpng" "$<" -o "$@"
[[ -f "$@" ]] && [[ -n "$(shell command -v $(PNGCRUSH))" ]] && $(PNGCRUSH) -ow "$@"
%.svg: %.dot
$(DOT) "-Tsvg" "$<" -o "$@"
[[ -f "$@" ]] && [[ -n "$(shell command -v $(SVGO))" ]] && $(SVGO) --multipass -i "$@"
clean:
rm $(PNGS) $(SVGS)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment