summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/make/make.122
-rw-r--r--usr.bin/make/parse.c11
2 files changed, 30 insertions, 3 deletions
diff --git a/usr.bin/make/make.1 b/usr.bin/make/make.1
index 68fb9387284f..68f139fa6be1 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 e245a043c415..65fcf0533223 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 == '.') {