Skip to content

Instantly share code, notes, and snippets.

@adamjstewart
Last active February 9, 2019 19:32
Show Gist options
  • Save adamjstewart/b5ba560959e6d72615455febc2b37747 to your computer and use it in GitHub Desktop.
Save adamjstewart/b5ba560959e6d72615455febc2b37747 to your computer and use it in GitHub Desktop.
Makefile for building Graphviz graphs
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