Module Name: src
Committed By: sjg
Date: Tue Apr 24 20:12:16 UTC 2012
Modified Files:
src/usr.bin/make: make.1 parse.c
Log Message:
Restore previous behavior - supressing duplicate entries in
.MAKE.MAKEFILES - it is more efficient.
To generate a diff of this commit:
cvs rdiff -u -r1.203 -r1.204 src/usr.bin/make/make.1
cvs rdiff -u -r1.183 -r1.184 src/usr.bin/make/parse.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/make/make.1
diff -u src/usr.bin/make/make.1:1.203 src/usr.bin/make/make.1:1.204
--- src/usr.bin/make/make.1:1.203 Fri Apr 20 05:33:41 2012
+++ src/usr.bin/make/make.1 Tue Apr 24 20:12:16 2012
@@ -1,4 +1,4 @@
-.\" $NetBSD: make.1,v 1.203 2012/04/20 05:33:41 sjg Exp $
+.\" $NetBSD: make.1,v 1.204 2012/04/24 20:12:16 sjg Exp $
.\"
.\" Copyright (c) 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -29,7 +29,7 @@
.\"
.\" from: @(#)make.1 8.4 (Berkeley) 3/19/94
.\"
-.Dd April 20, 2012
+.Dd April 24, 2012
.Dt MAKE 1
.Os
.Sh NAME
@@ -735,6 +735,7 @@ will look for.
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.MODE
Processed after reading all makefiles.
Can affect the mode that
Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.183 src/usr.bin/make/parse.c:1.184
--- src/usr.bin/make/parse.c:1.183 Fri Apr 20 05:33:42 2012
+++ src/usr.bin/make/parse.c Tue Apr 24 20:12:16 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.183 2012/04/20 05:33:42 sjg Exp $ */
+/* $NetBSD: parse.c,v 1.184 2012/04/24 20:12:16 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: parse.c,v 1.183 2012/04/20 05:33:42 sjg Exp $";
+static char rcsid[] = "$NetBSD: parse.c,v 1.184 2012/04/24 20:12:16 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.183 2012/04/20 05:33:42 sjg Exp $");
+__RCSID("$NetBSD: parse.c,v 1.184 2012/04/24 20:12:16 sjg Exp $");
#endif
#endif /* not lint */
#endif
@@ -2239,6 +2239,36 @@ ParseSetParseFile(const char *filename)
free(dirname);
}
+/*
+ * Track the makefiles we read - so makefiles can
+ * set dependencies on them.
+ * Avoid adding anything more than once.
+ */
+
+static void
+ParseTrackInput(const char *name)
+{
+ char *old;
+ char *fp = NULL;
+ size_t name_len = strlen(name);
+
+ old = Var_Value(MAKE_MAKEFILES, VAR_GLOBAL, &fp);
+ if (old) {
+ /* does it contain name? */
+ for (; old != NULL; old = strchr(old, ' ')) {
+ if (*old == ' ')
+ old++;
+ if (memcmp(old, name, name_len) == 0
+ && (old[name_len] == 0 || old[name_len] == ' '))
+ goto cleanup;
+ }
+ }
+ Var_Append (MAKE_MAKEFILES, name, VAR_GLOBAL);
+ cleanup:
+ if (fp) {
+ free(fp);
+ }
+}
/*-
@@ -2264,7 +2294,7 @@ Parse_SetInput(const char *name, int lin
if (name == NULL)
name = curFile->fname;
else
- Var_Append(MAKE_MAKEFILES, name, VAR_GLOBAL);
+ ParseTrackInput(name);
if (DEBUG(PARSE))
fprintf(debug_file, "Parse_SetInput: file %s, line %d, fd %d, nextbuf %p, arg %p\n",