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
|
.\" Copyright (c) 1990, 1993
|
||||||
.\" The Regents of the University of California. All rights reserved.
|
.\" 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
|
because it is more compatible with other versions of
|
||||||
.Nm
|
.Nm
|
||||||
and cannot be confused with the special target with the same name.
|
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
|
.It Va .MAKE.PID
|
||||||
The process-id of
|
The process-id of
|
||||||
.Nm .
|
.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
|
* Copyright (c) 1988, 1989, 1990, 1993
|
||||||
@ -397,8 +397,9 @@ extern char *progname; /* The program name */
|
|||||||
|
|
||||||
#define MAKEFLAGS ".MAKEFLAGS"
|
#define MAKEFLAGS ".MAKEFLAGS"
|
||||||
#define MAKEOVERRIDES ".MAKEOVERRIDES"
|
#define MAKEOVERRIDES ".MAKEOVERRIDES"
|
||||||
#define MAKE_JOB_PREFIX ".MAKE.JOB.PREFIX"
|
#define MAKE_JOB_PREFIX ".MAKE.JOB.PREFIX" /* prefix for job target output */
|
||||||
#define MAKE_EXPORTED ".MAKE.EXPORTED"
|
#define MAKE_EXPORTED ".MAKE.EXPORTED" /* variables we export */
|
||||||
|
#define MAKE_MAKEFILES ".MAKE.MAKEFILES" /* all the makefiles we read */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* debug control:
|
* 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
|
* Copyright (c) 1988, 1989, 1990, 1993
|
||||||
@ -69,14 +69,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MAKE_NATIVE
|
#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
|
#else
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94";
|
static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94";
|
||||||
#else
|
#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
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
#endif
|
#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();
|
curFile->cond_depth = Cond_save_depth();
|
||||||
|
|
||||||
ParseSetParseFile(name);
|
ParseSetParseFile(name);
|
||||||
|
ParseTrackInput(name);
|
||||||
|
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user