summaryrefslogtreecommitdiff
path: root/usr.bin/make/main.c
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/main.c
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/main.c')
-rw-r--r--usr.bin/make/main.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/usr.bin/make/main.c b/usr.bin/make/main.c
index 6a3e26d3450..fa477b3013b 100644
--- a/usr.bin/make/main.c
+++ b/usr.bin/make/main.c
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.579 2022/03/22 23:37:09 rillig Exp $ */
+/* $NetBSD: main.c,v 1.580 2022/04/18 15:06:27 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -111,7 +111,7 @@
#include "trace.h"
/* "@(#)main.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: main.c,v 1.579 2022/03/22 23:37:09 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.580 2022/04/18 15:06:27 rillig Exp $");
#if defined(MAKE_NATIVE) && !defined(lint)
__COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
"The Regents of the University of California. "
@@ -1480,6 +1480,7 @@ main_ReadFiles(void)
if (!opts.noBuiltins)
ReadBuiltinRules();
+ posix_state = PS_MAYBE_NEXT_LINE;
if (!Lst_IsEmpty(&opts.makefiles))
ReadAllMakefiles(&opts.makefiles);
else