1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-14 14:55:41 +00:00

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
This commit is contained in:
Oliver Eikemeier 2004-07-02 12:30:28 +00:00
parent 7929aa036c
commit f695b5ceca
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=131456
2 changed files with 30 additions and 3 deletions

View File

@ -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

View File

@ -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 == '.') {