diff -Nru makefile2graph-1.5.0/debian/changelog makefile2graph-2021.11.06/debian/changelog --- makefile2graph-1.5.0/debian/changelog 2020-12-07 05:27:29.000000000 +0000 +++ makefile2graph-2021.11.06/debian/changelog 2021-11-07 16:41:16.000000000 +0000 @@ -1,3 +1,14 @@ +makefile2graph (2021.11.06-1) unstable; urgency=medium + + [ Jenkins ] + * Set upstream metadata fields: Repository, Repository-Browse. + + [ Andrius Merkys ] + * New upstream version 2021.11.06 + * Bumping copyright years. + + -- Andrius Merkys Sun, 07 Nov 2021 11:41:16 -0500 + makefile2graph (1.5.0-2) unstable; urgency=medium * No-changes source upload. diff -Nru makefile2graph-1.5.0/debian/copyright makefile2graph-2021.11.06/debian/copyright --- makefile2graph-1.5.0/debian/copyright 2020-12-02 08:52:03.000000000 +0000 +++ makefile2graph-2021.11.06/debian/copyright 2021-11-07 16:41:02.000000000 +0000 @@ -8,7 +8,7 @@ License: Expat Files: debian/* -Copyright: 2020, Andrius Merkys +Copyright: 2020-2021, Andrius Merkys License: Expat License: Expat diff -Nru makefile2graph-1.5.0/debian/upstream/metadata makefile2graph-2021.11.06/debian/upstream/metadata --- makefile2graph-1.5.0/debian/upstream/metadata 1970-01-01 00:00:00.000000000 +0000 +++ makefile2graph-2021.11.06/debian/upstream/metadata 2021-11-07 16:38:22.000000000 +0000 @@ -0,0 +1,3 @@ +--- +Repository: https://github.com/lindenb/makefile2graph.git +Repository-Browse: https://github.com/lindenb/makefile2graph diff -Nru makefile2graph-1.5.0/make2graph.c makefile2graph-2021.11.06/make2graph.c --- makefile2graph-1.5.0/make2graph.c 2014-12-31 10:24:43.000000000 +0000 +++ makefile2graph-2021.11.06/make2graph.c 2018-10-05 19:19:28.000000000 +0000 @@ -39,6 +39,7 @@ #include #include #include +#include /* version */ #define M2G_VERSION "1.5.0" @@ -137,7 +138,19 @@ { size_t lenpre = strlen(pre), lenstr = strlen(str); return lenstr < lenpre ? 0 : strncmp(pre, str, lenpre) == 0; - } + } + +static int endsWith(const char *str, const char *suffix) +{ + if (!str || !suffix) + return 0; + size_t lenstr = strlen(str); + size_t lensuffix = strlen(suffix); + if (lensuffix > lenstr) + return 0; + return strncmp(str + lenstr - lensuffix, suffix, lensuffix) == 0; +} + /** extract filename between '`' and "'" * Make v4.0 changed this: the first separator is now "'" @@ -176,8 +189,10 @@ } /** read line character by character */ -static char* readline(FILE* in) +static char* readline(FILE* in, size_t* level) { + assert(level); + *level= 0UL; int c; char* p=NULL; size_t len=0UL; @@ -192,6 +207,10 @@ { p[len++]=c; } + else + { + (*level)++; + } } p[len]=0; return p; @@ -231,11 +250,12 @@ } /** scan the makefile -nd output */ -static void GraphScan(GraphPtr graph,TargetPtr root,FILE* in) +static void GraphScan(GraphPtr graph,TargetPtr root,FILE* in, size_t level) { char* line=NULL; char* makefile_name=NULL; - while((line=readline(in))!=NULL) + size_t iLevel=0UL; + while((line=readline(in, &iLevel))!=NULL) { if(startsWith(line,"Considering target file")) { @@ -247,9 +267,10 @@ free(tName); free(line); //skip lines - while((line=readline(in))!=NULL) + size_t iLevelDump=0UL; + while((line=readline(in, &iLevelDump))!=NULL) { - if(startsWith(line,"Finished prerequisites of target file ")) + if(startsWith(line,"Finished prerequisites of target file ") || endsWith(line, "was considered already.") ) { tName=targetName(line); free(line); @@ -268,10 +289,15 @@ TargetPtr child=GraphGetTarget(graph,tName); + // fprintf(stderr, "a: %zu(%s)->%zu(%s)\n", level, root->name, iLevel, tName); free(tName); - TargetAddChildren(root,child); - GraphScan(graph,child,in); + if(level+1 >= iLevel) + { + TargetAddChildren(root,child); + // fprintf(stderr, "b: %zu(%s)->%zu(%s)\n", level, root->name, iLevel, child->name); + GraphScan(graph,child,in,iLevel+1); + } } else if(startsWith(line,"Must remake target ")) @@ -286,7 +312,7 @@ TargetAddChildren(root,GraphGetTarget(graph,tName)); free(tName); } - else if(startsWith(line,"Finished prerequisites of target file ")) + else if( (startsWith(line,"Finished prerequisites of target file ") || endsWith(line, "was considered already.")) && (level+1 >= iLevel)) { char* tName=targetName(line); if(strcmp(tName,root->name)!=0) @@ -332,10 +358,20 @@ } else { + const char* label=targetLabel(g,t->name); + fprintf(out, + "n%zu[label=\"", + t->id); + while(*label) + { + if(*label=='\"') + fputs("\\\"",out); + else + fputc(*label,out); + label++; + } fprintf(out, - "n%zu[label=\"%s\", color=\"%s\"];\n", - t->id, - targetLabel(g,t->name), + "\", color=\"%s\"];\n", (t->must_remake?"red":"green") ); } @@ -564,7 +600,7 @@ app->root=GraphGetTarget(app,""); if(optind==argc) { - GraphScan(app,app->root,stdin); + GraphScan(app,app->root,stdin,0); } else if(optind+1==argc) { @@ -574,7 +610,7 @@ fprintf(stderr,"Cannot open \"%s\" : \"%s\".\n",argv[optind],strerror(errno)); return EXIT_FAILURE; } - GraphScan(app,app->root,in); + GraphScan(app,app->root,in,0); fclose(in); } else diff -Nru makefile2graph-1.5.0/Makefile makefile2graph-2021.11.06/Makefile --- makefile2graph-1.5.0/Makefile 2014-12-31 10:24:43.000000000 +0000 +++ makefile2graph-2021.11.06/Makefile 2018-10-05 19:19:28.000000000 +0000 @@ -9,7 +9,7 @@ bin_PROGRAMS = make2graph bin_SCRIPTS = makefile2graph pkgdoc_DATA = LICENSE README.md screenshot.png -man1_MANS = make2graph.1 +man1_MANS = make2graph.1 makefile2graph.1 CFLAGS ?= -O3 -Wall diff -Nru makefile2graph-1.5.0/makefile2graph makefile2graph-2021.11.06/makefile2graph --- makefile2graph-1.5.0/makefile2graph 2014-12-31 10:24:43.000000000 +0000 +++ makefile2graph-2021.11.06/makefile2graph 2018-10-05 19:19:28.000000000 +0000 @@ -1,3 +1,4 @@ #!/bin/sh set -eu +export LANG=C exec make -nd "$@" |make2graph diff -Nru makefile2graph-1.5.0/README.md makefile2graph-2021.11.06/README.md --- makefile2graph-1.5.0/README.md 2014-12-31 10:24:43.000000000 +0000 +++ makefile2graph-2021.11.06/README.md 2018-10-05 19:19:28.000000000 +0000 @@ -7,6 +7,8 @@ sub-makefiles are not supported. +![https://travis-ci.org/lindenb/makefile2graph.svg](https://travis-ci.org/lindenb/makefile2graph) + ## History * 2014-12-31 added option `--format`, removed otpions 'x' and 'd' @@ -54,6 +56,9 @@ make -Bnd | make2graph --format x > output.xml ``` +## Locale + +make2graph only parses english messages from GNU make. If you're using another locale, you should set `LC_ALL=C`. ## Examples @@ -316,5 +321,7 @@ > try the gexf+ #gephi output or another grafviz algo like neato > +## See also + * J4Make https://github.com/lindenb/j4make java equivalent of makefile2graph diff -Nru makefile2graph-1.5.0/.travis.yml makefile2graph-2021.11.06/.travis.yml --- makefile2graph-1.5.0/.travis.yml 1970-01-01 00:00:00.000000000 +0000 +++ makefile2graph-2021.11.06/.travis.yml 2018-10-05 19:19:28.000000000 +0000 @@ -0,0 +1,6 @@ +language: C +script: make test +before_install: + - sudo apt-get update -qq + - sudo apt-get install graphviz +