# makefile2graph **Repository Path**: PDBC/makefile2graph ## Basic Information - **Project Name**: makefile2graph - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2023-11-14 - **Last Updated**: 2023-11-14 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # makefile2graph Creates a graph of dependencies from [GNU-Make](http://www.gnu.org/software/make/manual/make.html) Output can be generated for the following formats: - [Graphviz/dot](http://www.graphviz.org/) - [Gexf-XML](https://gephi.github.io/) - [PlantUML](https://plantuml.com/) - [Mermaid](https://mermaid.js.org/) - or a list of the deepest independent targets that should be make. Notice that sub-makefiles are not supported. ![https://travis-ci.org/lindenb/makefile2graph.svg](https://travis-ci.org/lindenb/makefile2graph) ## History * 2023-08-30 added format [PlantUML](https://plantuml.com/) * 2023-08-30 added format [Mermaid](https://mermaid.js.org/) * 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 ![screenshot.png](screenshot.png) ## 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. - -e|--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 ``` ```dot digraph G { n1[label="", color="green"]; n2[label="Makefile", color="green"]; n4[label="all", color="red"]; n3[label="all-recur", color="red"]; n23[label="bedidx.c", color="green"]; n22[label="bedidx.o", color="red"]; n9[label="bgzf.c", color="green"]; n10[label="bgzf.h", color="green"]; n8[label="bgzf.o", color="red"]; n27[label="bgzip", color="red"]; n29[label="bgzip.c", color="green"]; n28[label="bgzip.o", color="red"]; n18[label="index.c", color="green"]; n17[label="index.o", color="red"]; n20[label="khash.h", color="green"]; n16[label="knetfile.c", color="green"]; n11[label="knetfile.h", color="green"]; n15[label="knetfile.o", color="red"]; n24[label="kseq.h", color="green"]; n21[label="ksort.h", color="green"]; n13[label="kstring.c", color="green"]; n14[label="kstring.h", color="green"]; n12[label="kstring.o", color="red"]; n6[label="lib", color="red"]; n7[label="libtabix.a", color="red"]; n26[label="main.c", color="green"]; n25[label="main.o", color="red"]; n5[label="tabix", color="red"]; n19[label="tabix.h", color="green"]; n2 -> n1 ; n4 -> n1 ; n3 -> n1 ; n27 -> n4 ; n5 -> n4 ; n23 -> n22 ; n20 -> n22 ; n24 -> n22 ; n9 -> n8 ; n10 -> n8 ; n11 -> n8 ; n8 -> n27 ; n28 -> n27 ; n15 -> n27 ; n10 -> n28 ; n29 -> n28 ; n10 -> n17 ; n18 -> n17 ; n20 -> n17 ; n21 -> n17 ; n14 -> n17 ; n19 -> n17 ; n16 -> n15 ; n11 -> n15 ; n13 -> n12 ; n14 -> n12 ; n7 -> n6 ; n22 -> n7 ; n8 -> n7 ; n17 -> n7 ; n15 -> n7 ; n12 -> n7 ; n10 -> n25 ; n14 -> n25 ; n26 -> n25 ; n19 -> n25 ; n6 -> n5 ; n25 -> n5 ; } ``` ### 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 ![workflow](https://pbs.twimg.com/media/ByNEQ7PCAAAxoBt.png) https://twitter.com/yokofakun/status/278086490809040896 ![workflow](https://pbs.twimg.com/media/A9v2MKXCAAA8hmJ.jpg) ## 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](https://github.com/lindenb/j4make) java equivalent of makefile2graph