Closely related to How to display dependencies given in a makefile as a tree? But the answers given there is not satisfactory (i.e. do not work).

Is there a tool to visualize the Directed Acylic Graphs (DAGs) coded up in standard Makefiles? eg, a shell-script for post-processing through Unix pipes can be an acceptable solution as well (maybe there is a pandoc filter to convert MakeFiles to graphviz or LaTeX).

I don't strictly need a tool that directly typesets this graphical visualisation? Just a common file-format translation of the makefile to a graph-viz file or something similar would suffice.

  • 1
    You can use dot etc. from the graphviz package to render DAGs. Transforming a (simple) makefile (explicit direct dependencies) into dot format is an exercise in shell programming, or perl etc. (split lines with colon in part before colon and part after colon).
    – dirkt
    Oct 25, 2017 at 17:11
  • @dirkt, is there a rudimentary shell script available somewhere? I am really new to *nix programming Oct 25, 2017 at 17:26
  • Is your makefile recursive: does it include $(MAKE) or make. If so it will be slow, and generating this graph will be very very hard. (Recursion is usually good, but recursive make is bad.) Jul 2, 2019 at 8:02

1 Answer 1


I believe makefile2graph does exactly what the original post author wanted.

For the full installation and usage example:

  • Installation (make sure graphviz is installed, e.g. with sudo apt install graphviz on Debian systems)
cd /my/install/dir
git clone https://github.com/lindenb/makefile2graph
cd makefile2graph
  • Generate PNG (no need to use dedicated variable GDIR if you add makefile2graph's path to your PATH variable)
cd /path/to/my/makefile
make -Bnd |  ${GDIR}/make2graph | dot -Tpng -o my_graph.png

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .