Giter Site home page Giter Site logo

makefile2graph's People

Contributors

dholl avatar ignoredambience avatar jilljenn avatar johnbachman avatar lindenb avatar ltrlg avatar qinshulei avatar romangrothausmann avatar sjackman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

makefile2graph's Issues

Support for makefiles with VPATH

Makefile2graph shows incorrect output for makefiles using VPATH. Example:

ake -nd --no-builtin-rules 
GNU Make 4.1
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Reading makefiles...
Reading makefile 'Makefile'...
Updating makefiles....
 Considering target file 'Makefile'.
  Looking for an implicit rule for 'Makefile'.
  No implicit rule found for 'Makefile'.
  Finished prerequisites of target file 'Makefile'.
 No need to remake target 'Makefile'.
Updating goal targets....
Considering target file 'all'.
 File 'all' does not exist.
  Considering target file 'build/main'.
    Considering target file 'build/main.o'.
     Looking for an implicit rule for 'build/main.o'.
     Trying pattern rule with stem 'main'.
     Trying implicit prerequisite 'main.cpp'.
     Found prerequisite 'main.cpp' as VPATH 'src/main.cpp'
     Found an implicit rule for 'build/main.o'.
    No need to remake target 'build/main.o'.
   Finished prerequisites of target file 'build/main'.
   Prerequisite 'build/main.o' is older than target 'build/main'.
   Prerequisite 'build/response.o' is older than target 'build/main'.
   Prerequisite 'build/parse.o' is older than target 'build/main'.
   Prerequisite 'lib/libmagic.so' is older than target 'build/main'.
  No need to remake target 'build/main'.
 Finished prerequisites of target file 'all'.
Must remake target 'all'.
Successfully remade target file 'all'.
make: Nothing to be done for 'all'.

makefile2graph outputs

digraph G {
n2[label="all", color="red"];
n3[label="build/main", color="green"];
n4[label="build/main.o", color="green"];
n11[label="build/parse.o", color="green"];
n7[label="build/response.o", color="green"];
n14[label="lib/libmagic.so", color="green"];
n5[label="main.cpp", color="green"];
n12[label="parse.cpp", color="green"];
n10[label="parse.h", color="green"];
n8[label="response.cpp", color="green"];
n6[label="response.h", color="green"];
n13[label="src/parse.h", color="green"];
n9[label="src/response.h", color="green"];
n3 -> n2 ; 
n4 -> n3 ; 
n11 -> n3 ; 
n7 -> n3 ; 
n14 -> n3 ; 
n5 -> n4 ; 
n6 -> n4 ; 
n12 -> n11 ; 
n13 -> n11 ; 
n10 -> n7 ; 
n8 -> n7 ; 
n9 -> n7 ; 
}

At least half of those should start with src/.

Use colorblind safe colours for ellipses

Hi,

Thanks for this tool; I'm using it to write a tutorial. Would you consider swapping the colours for the ellipses of each file? At the moment they are green/red. This is not a good choice for colorblind readers. A better default (and perhaps softer) might be to take some colours from the palettes available at: https://colorbrewer2.org/#type=qualitative&scheme=Set2&n=3

e.g. I've changed my local copy make2graph L375 to:

				(t->must_remake?"#fc8d62":"#66c2a5") /* https://colorbrewer2.org/#type=qualitative&scheme=Set2&n=3 */

Best wishes, stephen

Show processes as well as inputs and outputs

Before I found this, I found this: https://github.com/TomConlin/MakefileViz

When I used this I found that processes themselves were not visualised. It would be quite cool if it showed the processes that were used as well in between inputs and outputs. I realise that each recipe itself would be considered a process, where the recipes call other processes. Later in the future, this can be used to visualise to create subgraphs within a larger graph.

Some context around the installation procedure and the png file generation procedure

Could it be possible to be a bit more verbose in the README.md when explainin the compilation/installation process? Like saying the output of the compilation is just a binary/blob called make2graph. This would help people using Makefiles, but not used to the build/compilation process of C projects.

Also mentioning some common/standard practices like putting that binary in /usr/local/bin on Unix environments (or any other viable/sensible place in $PATH) helps in giving a bit of context for people not used to compile C projects from source code.

I see there's a bash script called makefile2graph that perhaps could/need to be placed somewhere else (available in $PATH). I am assuming this bash script should automagically take care of locale issues, a bit of context around that locale thing and where to "install it" in a canonical place could help.

Regarding the pipe example into dot to generate a png image: a bit of context around graphviz could help in understanding what that dot command is doing, as the logical connection between dot and the graphviz context was not clear to me and querying a web search engine for "dot png" did not help. In my case on Debian I had to run sudo apt-get install graphviz to then install the dot command.

Thanks for this great visual tool, I find it very helpful when building projects made by a combination of different programming languages, cloud infrastructure building processes, remote deployments in cloud providers, and remote monitoring tools for the build process :-)

Pattern rules with multiple targets not shown

Consider the following Makefile

all: hello.b hello.c

hello.a:
    touch $@

%.b %.c: %.a
    touch $*.b $*.c

Instead of properly connecting the two pattern rule targets, only one of
them is connected the in the dot output

wrong

should-be

I believe this is because the make -d output just says that the second
has "already been considered"

# make -rRBndC example
GNU Make 4.2.1
Built for x86_64-redhat-linux-gnu
Copyright (C) 1988-2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Reading makefiles...
Reading makefile 'Makefile'...
Updating makefiles....
 Considering target file 'Makefile'.
  Looking for an implicit rule for 'Makefile'.
  No implicit rule found for 'Makefile'.
  Finished prerequisites of target file 'Makefile'.
 No need to remake target 'Makefile'.
Updating goal targets....
Considering target file 'all'.
 File 'all' does not exist.
 Looking for an implicit rule for 'all'.
 No implicit rule found for 'all'.
  Considering target file 'hello.b'.
   Looking for an implicit rule for 'hello.b'.
   Trying pattern rule with stem 'hello'.
   Trying implicit prerequisite 'hello.a'.
   Found an implicit rule for 'hello.b'.
    Considering target file 'hello.a'.
     Finished prerequisites of target file 'hello.a'.
    Making 'hello.a' due to always-make flag.
    Must remake target 'hello.a'.
make[1]: Entering directory '/home/dacoda/projects/tea-dragon-society/src/third-party/makefile2graph/test/example'
touch hello.a
    Successfully remade target file 'hello.a'.
   Finished prerequisites of target file 'hello.b'.
   Prerequisite 'hello.a' is newer than target 'hello.b'.
  Must remake target 'hello.b'.
touch hello.b hello.c
  Successfully remade target file 'hello.b'.
  Considering target file 'hello.c'.
  File 'hello.c' was considered already.
 Finished prerequisites of target file 'all'.
Must remake target 'all'.
Successfully remade target file 'all'.
make[1]: Leaving directory '/home/dacoda/projects/tea-dragon-society/src/third-party/makefile2graph/test/example'

With a different flag, however, it seems possible to have make let us
know that it is building more than one file with a single recipe

# make -rRpBC example | grep -C5 'Also makes'
    touch $@

hello.b: hello.a
#  Implicit rule search has been done.
#  Implicit/static pattern stem: 'hello'
#  Also makes: hello.c
#  Last modified 2020-09-18 17:55:32.792450404
#  File has been updated.
#  Successfully updated.
# automatic
# @ := hello.b

'make install' installs docs in incorrect directory

Hi,

I just noticed that make install installs extra documentation in /usr/local/share/makefile2graph when I would have expected it in /usr/local/share/doc/makefile2graph:

install LICENSE README.md screenshot.png /usr/local/share/makefile2graph

I assume that is was a simple mistake, resolved like this:

diff --git a/Makefile b/Makefile
index 1e1fb81..33394aa 100644
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@ prefix = /usr/local
 bindir = $(prefix)/bin
 sharedir = $(prefix)/share
 docdir = $(sharedir)/doc
-pkgdocdir = $(sharedir)/makefile2graph
+pkgdocdir = $(docdir)/makefile2graph
 mandir = $(sharedir)/man
 man1dir = $(mandir)/man1
 

Tag a new release

Could you tag a new stable release so that distributions like homebrew can pick up the new features recently added?

Suggestions:

  • update the M2G_VERSION
  • use Semantic Versioning (instead of CalVer, because CalVer is better suited to large or constantly-changing projects, and SemVer is the most common way to version CLI tools)
    • tag previous releases with the semver scheme

Good program but the description is kind of confusing

It should be as follow in Readme/Compilation:
make
make install

without "make install": "make2graph" is not visible from user. Then the usage should be "make -Bnd | ./YOUR_PATH_OF_MAKE2GRAPH/make2graph > output.dot

In Usage, it is better if you use:
cd YOUR_CODE_REPO
make -Bnd | make2graph | dot -Tpng -o out.png

Sub-Makefile Support

Hi, I think this tool is fun and awesome for visualizing projects.
Are you interested in PRs for adding sub-makefile (recursive make invocation) support? It looks like make -Bnd provides all the output needed for this. From your experience, do you think there's something that makes this much harder, or was it just outside your use case?

Way to visualize target hierarchy, instead of files

Is there any way to use makefile2graph to show the tree of targets, instead of the tree of files?

The use cases I have are often not files, but merely .PHONY targets, which are any kind of jobs, not necessarily compilations, which lead to files being created. They might be something like running tests and outputting test result, or running a linter, which outputs comments about files.

Build failure due to lack of strndup on Mac OS

Hi, thanks for this library.

I'm running Mac OS 10.6.8 and wasn't able to build the repo due to the following compilation error:

$ make
cc -O3 -Wall make2graph.c -o make2graph
make2graph.c: In function ‘targetName’:
make2graph.c:137: warning: implicit declaration of function ‘strndup’
make2graph.c:137: warning: incompatible implicit declaration of built-in function ‘strndup’
Undefined symbols:
"_strndup", referenced from:
_targetName in cczR4fIs.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [make2graph] Error 1

As it turns out strndup is not a standard lib function and is not available on Mac OS and other BSDs, see here: https://bitbucket.org/gward/vcprompt/issue/1/compilation-fails-on-macos-1058

Submitting fix as a pull request shortly.

Reduce number of edges by only saving folders

My dependency tree is rather large. Is it possible for make to not expand the variables and keep the variable names to reduce the number of edges in the graph? I.e. it won't output an edge for each C-file, instead it will output one edge for the variable where the C-files are set. I understand that this is something for make to implement, but I can't find anything in the manual.

show more details about libs

Hi
I try to use makefile2graph but have some issues:
1-instead of CMAKE I create script that manually go through path and run "make files" here is the script: (when each module make refer to some other till project make completely):

for MODULE in \
src/module1 \
src/module2 \
src/module3 \
src/app/module4 \
...
src/app4/moduleN \
do
cd $MODULE; echo
make clean;make
done 

I run below command to generate graph in each module path:
/usr/bin/make -Bnd | ${GDIR}/make2graph | dot -Tpng -o /tmp/test.png

but how can I run this on root of project? (there is no global make file that exist on top of project, script make them one by one)

2-how can I see each module use which lib, now when I run it on each module path it only show that module refer to lib and won't show use which lib!
image


Any idea?
Thanks,

Cannot get target name in "Considering target file 'makefile'.".

Hi Pierre,
Just trying out makefile2graph on a very basic makefile:-

all : file1

file1: file0
cat file0 > file1

I get this error:-

$ make -Bnd | make2graph
Cannot get target name in "Considering target file 'makefile'.".
make: write error

Am I missing something?

New release of makefile2graph

Thanks for writing makefile2graph. The last release was already some years ago and is missing features like e225ea0. Could you maybe tag a new one?

Thanks!

Question

Hi,

I compile a c program to Webassembly. It generates .wasm files.
I want to find the source .c file that generates .wasm file.
Does your tool find this relation between .c file and .wasm file?
I mean, can we consider .wasm file is depended on .c file. So, there is a dependency between .wasm file and .c file.

Lists same file twice

When I run this on my makefile, the same file (ag_census_both_village_summary_combined.RData) is shown twice in the resulting output, once with its relative path ("../data/created/") and once without. Attached makefile (as .txt since Github won't allow it without an extension) and resulting output .txt file.

makefile.txt

mfgraph.txt

make2graph output discrepancy if file already exists

Considering this simple Makefile:

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

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

%.z : %.b
echo "$@" > $@

If 1.a does not exist make2graph yields:
rm 1.a
/opt/make-4.1/bin/make -Bnd 1.z | make2graph | dot -Tpng -o Makefile_1.png

makefile_1

However, if 1.a already exists an additional (false?) dependency is drawn:
touch 1.a
/opt/make-4.1/bin/make -Bnd 1.z | make2graph | dot -Tpng -o Makefile_2.png

makefile_2

Same problem with make-3.81 or j4make

Add LC_ALL=C to description

Make is localized on many platforms, since your parser seems to parse only english output you should maybe add that to the description.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.