summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorespie <espie@openbsd.org>2014-11-03 12:48:37 +0000
committerespie <espie@openbsd.org>2014-11-03 12:48:37 +0000
commit9bccb221aada4d2a11d96b879ec05c3c4b5523c4 (patch)
tree035bacfe3ba5ab0ee52be9b07abeb1628585779d
parentFix kernel stack overflow by preventing carp_send_ad_all() from re-entrant (diff)
downloadwireguard-openbsd-9bccb221aada4d2a11d96b879ec05c3c4b5523c4.tar.xz
wireguard-openbsd-9bccb221aada4d2a11d96b879ec05c3c4b5523c4.zip
introspection feature: ${MAKEFILE_LIST} contains the list of makefiles
parsed. name stolen from gmake, from a suggestion from guenther@, to avoid gratuitous confusin. okay guenther@, millert@
-rw-r--r--usr.bin/make/lowparse.c22
-rw-r--r--usr.bin/make/make.17
2 files changed, 13 insertions, 16 deletions
diff --git a/usr.bin/make/lowparse.c b/usr.bin/make/lowparse.c
index be4c41dacca..e189fdd1546 100644
--- a/usr.bin/make/lowparse.c
+++ b/usr.bin/make/lowparse.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lowparse.c,v 1.32 2012/11/07 14:18:41 espie Exp $ */
+/* $OpenBSD: lowparse.c,v 1.33 2014/11/03 12:48:37 espie Exp $ */
/* low-level parsing functions. */
@@ -46,14 +46,10 @@
#ifndef LOCATION_TYPE
#include "location.h"
#endif
+#include "var.h"
-/* XXX check whether we can free filenames at the end, for a proper
- * definition of `end'. */
-
-#if 0
-static LIST fileNames; /* file names to free at end */
-#endif
+#define READ_MAKEFILES "MAKEFILE_LIST"
/* Input stream structure: file or string.
* Files have str == NULL, F != NULL.
@@ -138,7 +134,7 @@ simplify(const char *filename)
{
if (startswith(filename, curdir, curdir_len))
return filename + curdir_len + 1;
- else if (startswith(filename, _PATH_DEFSYSPATH,
+ else if (startswith(filename, _PATH_DEFSYSPATH,
sizeof(_PATH_DEFSYSPATH)-1)) {
size_t sz;
char *buf;
@@ -154,12 +150,10 @@ static struct input_stream *
new_input_file(const char *name, FILE *stream)
{
struct input_stream *istream;
-#if 0
- Lst_AtEnd(&fileNames, name);
-#endif
istream = emalloc(sizeof(*istream));
istream->origin.fname = simplify(name);
+ Var_Append(READ_MAKEFILES, name);
istream->str = NULL;
/* Naturally enough, we start reading at line 0. */
istream->origin.lineno = 0;
@@ -174,7 +168,7 @@ free_input_stream(struct input_stream *istream)
if (istream->F && fileno(istream->F) != STDIN_FILENO)
(void)fclose(istream->F);
free(istream->str);
- /* Note we can't free the file names yet, as they are embedded in GN
+ /* Note we can't free the file names, as they are embedded in GN
* for error reports. */
free(istream);
}
@@ -186,8 +180,8 @@ new_input_string(char *str, const Location *origin)
istream = emalloc(sizeof(*istream));
/* No malloc, name is always taken from an already existing istream
- * and strings are used in for loops, so we need to reset the line counter
- * to an appropriate value. */
+ * and strings are used in for loops, so we need to reset the line
+ * counter to an appropriate value. */
istream->origin = *origin;
istream->F = NULL;
istream->ptr = istream->str = str;
diff --git a/usr.bin/make/make.1 b/usr.bin/make/make.1
index 902b87218ba..37cf7c2a1fc 100644
--- a/usr.bin/make/make.1
+++ b/usr.bin/make/make.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: make.1,v 1.116 2014/10/20 07:27:46 espie Exp $
+.\" $OpenBSD: make.1,v 1.117 2014/11/03 12:48:37 espie Exp $
.\" $NetBSD: make.1,v 1.18 1997/03/10 21:19:53 christos Exp $
.\"
.\" Copyright (c) 1990, 1993
@@ -30,7 +30,7 @@
.\"
.\" from: @(#)make.1 8.4 (Berkeley) 3/19/94
.\"
-.Dd $Mdocdate: October 20 2014 $
+.Dd $Mdocdate: November 3 2014 $
.Dt MAKE 1
.Os
.Sh NAME
@@ -712,6 +712,9 @@ Should that fail,
.Va .OBJDIR
is set to
.Va .CURDIR .
+.It Va MAKEFILE_LIST
+The list of files read by
+.Nm .
.It Va .MAKEFLAGS
The environment variable
.Ev MAKEFLAGS