-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME
More file actions
120 lines (94 loc) · 3.99 KB
/
Copy pathREADME
File metadata and controls
120 lines (94 loc) · 3.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
gnumake2dot
===========
Usage
-----
gnumake2dot.sh [-h] [-k] [-o OUTFILE] [--] [INFILE]
Generate a dot file from a supplied, valid GNU Makefile, INFILE.
If INFILE is not supplied, STDIN is taken as input.
The output either gets written to STDOUT if '-' is supplied an OUTFILE,
or if the -o switch is omitted. and write the result to standard output.
With no INFILE or when INFILE is -, read standard input.
-h|-? Write help information to STDOUT.
-k Keep intermediate files.
-n Just print the commands. No execution.
-o OUTFILE Write the result to OUTFILE instead of STDOUT.
eg: All the following, does exactly the same thing.
# gnumake2dot.sh /tmp/hiredis/Makefile >deps.dot
# gnumake2dot.sh -- /tmp/hiredis/Makefile >deps.dot
# gnumake2dot.sh -o deps.dot /tmp/hiredis/Makefile
# gnumake2dot.sh -o deps.dot -- /tmp/hiredis/Makefile
eg: Generate a png of the hiredis' Makefile dependencies.
# gnumake2dot.sh /tmp/hiredis/Makefile | dot -Tpng -o deps.png
Project Goal
------------
The goal of this project is to supply an easy, portable way to
visualize GNU Make dependencies, requiring only a minimal set of
tools as well as the minimum amount of programming.
Motivation
----------
Many other similar tools exist, but they all depend on one or other
form of high-level language like Python, Java, Perl, JavaScript, etc.
Operation
---------
Visualizing Makefile dependencies is not an easy thing to do, as GNU
Make does not supply a structured output of its meta data. The closest
GNU Make comes to this, is by supplying the '-p' switch:
From the make man page:
-p, --print-data-base
Print the data base (rules and variable values) that results
from reading the makefiles; then execute as usual or as
otherwise specified. This also prints the version information
given by the -v switch (see below). To print the data base
without trying to remake any files, use make -p -f/dev/null.
Make's '-p' output is usable after doing some serious filtering. This
is where sh, grep, awk and sed comes in handy.
Filtering could also be done with more powerful languages, but this
will add another dependency to this tool. Tools like sh, make, grep,
awk and sed are almost certainly available on any system where one
would like to debug or visualize Makefile dependencies.
After filtering make's '-p' output, a .dot file gets written, with the
help of the gnumake2dot.awk script.
Installation
------------
1. Clone the git repository:
# git clone git@github.com:wingunder/gnumake2dot.git
2. Make sure that the required tools are installed.
Required tools
--------------
- sh
- make
- grep
- sed
- awk
Optional tools
--------------
- dot (from https://graphviz.gitlab.io/)
The output of the gnumake2dot utility is in the .dot file format. The
gnumake2dot.sh utility can however generate a .dot file output,
without the availability of 'dot'.
Testing
-------
Generate a .dot file output of the ./Makefile:
# ./gnumake2dot.sh ./Makefile
Generate a test.png file, containing a visualization of ./Makefile:
# ./gnumake2dot.sh ./Makefile | dot -Tpng -o test.png
TODO
----
- Remove the grep dependency.
- Remove either the sed or awk dependency.
- Add generation of output formats other than '.dot', like XML,
Json, etc.
Copyright
---------
Copyright (C) 2017 Pieter du Preez <pdupreez+remove_this_and_the_preceeding_plus@gmail.com>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.