Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
M

makefile2graph

> 编程语言
Open source

Creates a graph of dependencies from GNU-Make; Output is a graphiz-dot file or a Gexf-XML file.

668 stars0 likes0 views
WebsiteGitHub

About

Creates a graph of dependencies from GNU-Make; Output is a graphiz-dot file or a Gexf-XML file.

makefile2graph

Creates a graph of dependencies from GNU-Make

Output can be generated for the following formats:

  • Graphviz/dot
  • Gexf-XML
  • PlantUML
  • Mermaid
  • or a list of the deepest independent targets that should be make.

Notice that sub-makefiles are not supported.

History

  • 2023-08-30 added format PlantUML
  • 2023-08-30 added format Mermaid
  • 2023-08-14 added options for setting graph, node, edge, and dirty attributes
  • 2014-12-31 added option --format, removed otpions 'x' and 'd'
  • 2014-12-22 added 'deep' output. I need this when I'm working on a cluster and I need to know the deepest independent targets that should be make.
  • 2014-10-07 print version
  • 2014-10-06 added --root option
  • 2014-09-17 added long_opt , options basename and suffix
  • 2014-09-16 fixed new format for GNU make v4.0

Screenshot

Compilation

bash
make

Options

  • -h|--help help (this screen)
  • -f|--format (format)
    • (d)ot graphiz dot output (default) (x)ml output
    • (g)exf XML output (M)ermaid output (P)lantUML output
    • (E) print the deepest indepedent targets.
    • (L)ist all targets.
  • -b|--basename only print file basename
  • -s|--suffix only print file extension
  • -r|--root show root node
  • -c|--colorscheme (scheme) Set colorscheme applied interleaved to all nodes.
  • -g|--graph-attributes: Sets attributes applied to the graph.
  • -n|--node-attributes: Sets attributes applied to all nodes.
  • -e|--edge-attributes: Sets attributes applied to all edges.
  • -d|--dirty-attributes: Sets attributes applied to dirty nodes only.
  • -v|--version print version

Usage

bash
make -Bnd | make2graph > output.dot
bash
make -Bnd | make2graph | dot -Tpng -o out.png
bash
make -Bnd | make2graph --format x > output.xml
bash
make -Bnd | make2graph --format p -g "skinparam BackgroundColor LightYellow" -n "BackgroundColor Peru" -e "skinparam ArrowColor Blue" -d "BackgroundColor Salmon" > output.puml

Locale

make2graph only parses english messages from GNU make. If you're using another locale, you should set LC_ALL=C.

Examples

Tabix 0.2.5 - DOT

bash
$ cd tabix-0.2.5
$ make -Bnd |make2graph
…

Tabix 0.2.5 - XML

bash
$ cd tabix-0.2.5
$ make -Bnd | make2graph --format x
xml

  
    Pierre Lindenbaum
    Makefile Graph
  
  
    
    
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
    
    
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
    
  

Deep output

deep output was needed when using a cluster: I needed a list of all deepest independant targets that must be re-built.

For the following Makefile

makefile
NUMS=1 2 3 4 5
.PHONY:all clean 
%.c: %.b
	echo "$ $@

%.b: %.a
	echo "$ $@

%.a:
	echo "$@" > $@

all:$(addsuffix .c,${NUMS})

clean:
	rm -f $(foreach P,a b c,$(addsuffix .${P},${NUMS})) 

make a few targets:

bash
$ make  1.a 2.a 3.b 4.c 
echo "1.a" > 1.a
echo "2.a" > 2.a
echo "3.a" > 3.a
echo "3.a" > 3.b
echo "4.a" > 4.a
echo "4.a" > 4.b
echo "4.b" > 4.c
rm 3.a 4.a 4.b

deep output :

bash
$ make -nd  all  | ./make2graph --format e
1.b
2.b
3.c
5.a

build other targets

bash
$ make  1.b 3.c
echo "1.a" > 1.b
echo "3.b" > 3.c

new deep output :

bash
$ make -nd  all  | ./make2graph --format e
1.c
2.b
5.a

Gallery

https://twitter.com/yokofakun/status/514329843065167872

https://twitter.com/yokofakun/status/278086490809040896

Misc

@yokofakun Using your https://t.co/Z1xg8dhW2r, and Graphviz 2.36 for OS X. Large graph. How can I scale it better? pic.twitter.com/d6ZQX2MnqH — Lex Nederbragt (@lexnederbragt) August 20, 2014

try the gexf+ #gephi output or another grafviz algo like neato

See also

  • J4Make java equivalent of makefile2graph

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

C

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言