diff options
author | eik <eik@FreeBSD.org> | 2004-07-02 12:30:28 +0000 |
---|---|---|
committer | eik <eik@FreeBSD.org> | 2004-07-02 12:30:28 +0000 |
commit | 71279faf28b796aebc6a45c29df7470b9bf2dc50 (patch) | |
tree | 819a8833196211840fa7dea8ca4cf61e2f470375 | |
parent | 7bc770a2546e8a5f93ee931634d4064b3b6e08f2 (diff) | |
download | FreeBSD-src-71279faf28b796aebc6a45c29df7470b9bf2dc50.zip FreeBSD-src-71279faf28b796aebc6a45c29df7470b9bf2dc50.tar.gz |
New variable `.MAKEFILE_LIST', useful for tracing, debugging and dependency tracking.
Use
make -V .MAKEFILE_LIST | tr \ \\n | awk '$0==".." {l--; next} {l++; printf "%*s%s\n", l, " ", $0}'
to print a tree of all included makefiles.
Approved by: joerg
MFC after: 1 week
-rw-r--r-- | usr.bin/make/make.1 | 22 | ||||
-rw-r--r-- | usr.bin/make/parse.c | 11 |
2 files changed, 30 insertions, 3 deletions
diff --git a/usr.bin/make/make.1 b/usr.bin/make/make.1 index 68fb938..68f139f 100644 --- a/usr.bin/make/make.1 +++ b/usr.bin/make/make.1 @@ -32,7 +32,7 @@ .\" @(#)make.1 8.8 (Berkeley) 6/13/95 .\" $FreeBSD$ .\" -.Dd April 12, 2004 +.Dd July 2, 2004 .Dt MAKE 1 .Os .Sh NAME @@ -460,7 +460,7 @@ In addition, .Nm sets or knows about the following internal variables or environment variables: -.Bl -tag -width MAKEFLAGS +.Bl -tag -width MAKEFILE_LIST .It Va \&$ A single dollar sign .Ql \&$ , @@ -529,6 +529,19 @@ utility sets .Va .OBJDIR to the canonical path given by .Xr getcwd 3 . +.It Va .MAKEFILE_LIST +As +.Nm +reads various makefiles, including the default files and any +obtained from the command line and +.Ql Ic \&.include +directives, their names will be automatically appended to the +.Va .MAKEFILE_LIST +variable. +They are added right before +.Nm +begins to parse them, so that the name of the current makefile is the +last word in this variable. .It Va .MAKEFLAGS The environment variable .Ev MAKEFLAGS @@ -1230,6 +1243,11 @@ default .Ev MAKEOBJDIRPREFIX directory. .El +.Sh EXAMPLES +.Bl -tag -width indent +.It Li "make \-V .MAKEFILE_LIST | tr \e\ \e\en" +Lists all included makefiles in order visited. +.El .Sh BUGS The determination of .Va .OBJDIR diff --git a/usr.bin/make/parse.c b/usr.bin/make/parse.c index e245a04..65fcf05 100644 --- a/usr.bin/make/parse.c +++ b/usr.bin/make/parse.c @@ -1777,6 +1777,8 @@ ParseDoInclude (char *file) * Pop to previous file */ (void) ParseEOF(0); + } else { + Var_Append(".MAKEFILE_LIST", fullname, VAR_GLOBAL); } } @@ -1919,6 +1921,8 @@ ParseTraditionalInclude (char *file) * Pop to previous file */ (void) ParseEOF(1); + } else { + Var_Append(".MAKEFILE_LIST", fullname, VAR_GLOBAL); } } #endif @@ -1945,13 +1949,16 @@ ParseEOF (int opened) IFile *ifile; /* the state on the top of the includes stack */ if (Lst_IsEmpty (includes)) { + Var_Append(".MAKEFILE_LIST", "..", VAR_GLOBAL); return (DONE); } ifile = (IFile *) Lst_DeQueue (includes); free (curFile.fname); - if (opened && curFile.F) + if (opened && curFile.F) { (void) fclose (curFile.F); + Var_Append(".MAKEFILE_LIST", "..", VAR_GLOBAL); + } if (curFile.p) { free(curFile.p->str); free(curFile.p); @@ -2379,6 +2386,8 @@ Parse_File(char *name, FILE *stream) curFile.lineno = 0; fatals = 0; + Var_Append(".MAKEFILE_LIST", name, VAR_GLOBAL); + do { while ((line = ParseReadLine ()) != NULL) { if (*line == '.') { |