Makefile for latent-dissent.
Makefile for unnecessary.
Goal: Draw the DAG showing file dependencies implied by the Makefile for a project.
Solution: @lindenb's makefile2graph code.
Here's how I draw these DAGs on my Mac.
First, install Homebrew. In a terminal, run:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Next, install graphviz. Run:
brew install graphviz
Finally, install @lindenb's makefile2graph. Run:
git clone https://github.com/lindenb/makefile2graph.git
cd makefile2graph
make
make install # not sure why I need to run this, but I seem to
To test, run:
make -Bnd | make2graph | dot -Tpng -o makefile-dag.png
ls
open makefile-dag.png
If the file makefile-dag.png
appears in the current directory (i.e., makefile2graph/
) and opens, then makefile2graph works.
To clean up, run:
cd ..
rm -rf makefile2graph
Try on one of your own Makefiles. Open a terminal in your own project directory (with a Makefile) and run:
make -Bnd | make2graph | dot -Tpng -o makefile-dag.png
This should create the file makefile-dag.png
. To open it, run:
open makefile-dag.png
To make it easy to update the png, I add this to the Makefile:
dag: makefile-dag.png
# draw makefile dag
makefile-dag.png: Makefile
make -Bnd | make2graph | dot -Tpng -Gdpi=300 -o makefile-dag.png
Here's an example using @zmjones's eeesr repo.
git clone https://github.com/zmjones/eeesr.git # grab @zmjones project from github
cd eeesr # hop into the main directory
make -Bnd | make2graph | dot -Tpng -Gdpi=300 -o makefile-dag.png # draw dag
open makefile-dag.png # open plot
how to use on windows