Last active
February 9, 2019 19:32
-
-
Save adamjstewart/b5ba560959e6d72615455febc2b37747 to your computer and use it in GitHub Desktop.
Makefile for building Graphviz graphs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SRC := $(wildcard *.dot *.gv) | |
CMD := dot | |
.PHONY: help Makefile | |
# Put it first so that "make" without argument is like "make help". | |
help: | |
@echo Usage: | |
@echo | |
@echo " make format CMD=cmd" | |
@echo | |
@echo -n where format is | |
@dot -T? 2>&1 | grep -o " one of: .*" | |
@echo | |
@echo and cmd is optionally one of: dot [default] neato fdp sfdp twopi circo | |
# Catch-all target: route all unknown targets to $(CMD) -T | |
%: Makefile | |
@# Be careful to strip renderer and formatter from suffix | |
$(foreach src,$(SRC),$(CMD) -T $@ $(src) -o $(addsuffix .$(firstword $(subst :, ,$@)),$(basename $(src)));) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment