Use .MAKE.MAKEFILES to track all the makefiles that have been read
so they can be used in dependency rules.
This commit is contained in:
parent
c97e9c4ea7
commit
e73405e272
@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: make.1,v 1.133 2007/10/05 15:27:45 sjg Exp $
|
||||
.\" $NetBSD: make.1,v 1.134 2007/10/08 20:26:36 sjg Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1990, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
@ -580,6 +580,14 @@ The preferred variable to use is the environment variable
|
||||
because it is more compatible with other versions of
|
||||
.Nm
|
||||
and cannot be confused with the special target with the same name.
|
||||
.It Va .MAKE.EXPORTED
|
||||
The list of variables exported by
|
||||
.Nm .
|
||||
.It Va .MAKE.MAKEFILES
|
||||
The list of makefiles read by
|
||||
.Nm ,
|
||||
which is useful for tracking dependencies.
|
||||
Each makefile is recorded only once, regardless of the number of times read.
|
||||
.It Va .MAKE.PID
|
||||
The process-id of
|
||||
.Nm .
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: make.h,v 1.69 2007/10/05 15:27:45 sjg Exp $ */
|
||||
/* $NetBSD: make.h,v 1.70 2007/10/08 20:26:36 sjg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
@ -397,8 +397,9 @@ extern char *progname; /* The program name */
|
||||
|
||||
#define MAKEFLAGS ".MAKEFLAGS"
|
||||
#define MAKEOVERRIDES ".MAKEOVERRIDES"
|
||||
#define MAKE_JOB_PREFIX ".MAKE.JOB.PREFIX"
|
||||
#define MAKE_EXPORTED ".MAKE.EXPORTED"
|
||||
#define MAKE_JOB_PREFIX ".MAKE.JOB.PREFIX" /* prefix for job target output */
|
||||
#define MAKE_EXPORTED ".MAKE.EXPORTED" /* variables we export */
|
||||
#define MAKE_MAKEFILES ".MAKE.MAKEFILES" /* all the makefiles we read */
|
||||
|
||||
/*
|
||||
* debug control:
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: parse.c,v 1.136 2007/10/05 15:27:45 sjg Exp $ */
|
||||
/* $NetBSD: parse.c,v 1.137 2007/10/08 20:26:36 sjg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
@ -69,14 +69,14 @@
|
||||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: parse.c,v 1.136 2007/10/05 15:27:45 sjg Exp $";
|
||||
static char rcsid[] = "$NetBSD: parse.c,v 1.137 2007/10/08 20:26:36 sjg Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: parse.c,v 1.136 2007/10/05 15:27:45 sjg Exp $");
|
||||
__RCSID("$NetBSD: parse.c,v 1.137 2007/10/08 20:26:36 sjg Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
@ -1915,6 +1915,48 @@ ParseSetParseFile(const char *filename)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Track the makefiles we read - so makefiles can
|
||||
* set dependencies on them.
|
||||
* Avoid adding anything more than once.
|
||||
*/
|
||||
#define TRACK_INPUT_FMT "${.PARSEDIR}/${.PARSEFILE}"
|
||||
|
||||
static void
|
||||
ParseTrackInput(const char *name)
|
||||
{
|
||||
char tmp[sizeof(TRACK_INPUT_FMT) + 1];
|
||||
char *val;
|
||||
char *old;
|
||||
char *cp;
|
||||
char *fp = NULL;
|
||||
|
||||
strncpy(tmp, TRACK_INPUT_FMT, sizeof(tmp));
|
||||
val = Var_Subst(NULL, tmp, VAR_GLOBAL, 0);
|
||||
old = Var_Value(MAKE_MAKEFILES, VAR_GLOBAL, &fp);
|
||||
if (old) {
|
||||
/* does it contain val? */
|
||||
if ((cp = strstr(old, val))) {
|
||||
int n = strlen(val);
|
||||
|
||||
/*
|
||||
* It only counts if at the start/end
|
||||
* or bounded by ' '
|
||||
*/
|
||||
if ((cp[n] == '\0' || cp[n] == ' ') &&
|
||||
(cp == old || cp[-1] == ' ')) {
|
||||
goto cleanup; /* we already have it */
|
||||
}
|
||||
}
|
||||
}
|
||||
Var_Append (MAKE_MAKEFILES, val, VAR_GLOBAL);
|
||||
cleanup:
|
||||
free(val);
|
||||
if (fp) {
|
||||
free(fp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*-
|
||||
*---------------------------------------------------------------------
|
||||
@ -1962,6 +2004,7 @@ Parse_SetInput(const char *name, int line, int fd, char *buf)
|
||||
curFile->cond_depth = Cond_save_depth();
|
||||
|
||||
ParseSetParseFile(name);
|
||||
ParseTrackInput(name);
|
||||
|
||||
if (buf == NULL) {
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user