summaryrefslogtreecommitdiff
path: root/usr.bin/make/make.h
diff options
context:
space:
mode:
authorrillig <rillig@NetBSD.org>2022-04-18 15:06:27 +0000
committerrillig <rillig@NetBSD.org>2022-04-18 15:06:27 +0000
commit686b9d31508b5cf03b7362f4e2f8a28d78bef7d8 (patch)
treecca4fc84a4c4f12425cdf1a45acd269d02d56b3b /usr.bin/make/make.h
parent437e498c7a66a13ccb91525f7f4f49e68f107a3c (diff)
make: only switch to POSIX mode if '.POSIX:' is the first line
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/make.html says that in order to make a makefile POSIX-conforming, its first non-comment line must be the special dependency line '.POSIX:' without any source dependencies. Previously, make switched to POSIX mode even if such a line occurred anywhere else, which was allowed by POSIX but was deep in the "unspecified behavior" area. For NetBSD make, there is no big difference since it doesn't ship any <posix.mk> file, this change mainly affects the bmake distribution. Previously, makefiles that contain '.POSIX:' somewhere in the middle could fail due to <posix.mk> resetting .SUFFIXES, among other things. Suggested by Simon J. Gerraty, who also reviewed an earlier version of this change.
Diffstat (limited to 'usr.bin/make/make.h')
-rw-r--r--usr.bin/make/make.h13
1 files changed, 12 insertions, 1 deletions
diff --git a/usr.bin/make/make.h b/usr.bin/make/make.h
index 618a56c53cb..8d9feb1ea0c 100644
--- a/usr.bin/make/make.h
+++ b/usr.bin/make/make.h
@@ -1,4 +1,4 @@
-/* $NetBSD: make.h,v 1.299 2022/03/26 14:02:40 rillig Exp $ */
+/* $NetBSD: make.h,v 1.300 2022/04/18 15:06:27 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -506,6 +506,17 @@ typedef struct GNode {
unsigned lineno;
} GNode;
+/*
+ * Keep track of whether to include <posix.mk> when parsing the line
+ * '.POSIX:'.
+ */
+extern enum PosixState {
+ PS_NOT_YET,
+ PS_MAYBE_NEXT_LINE,
+ PS_NOW_OR_NEVER,
+ PS_TOO_LATE
+} posix_state;
+
/* Error levels for diagnostics during parsing. */
typedef enum ParseErrorLevel {
/*