Module Name:    src
Committed By:   rillig
Date:           Sun Dec 13 16:30:08 UTC 2020

Modified Files:
        src/usr.bin/make: compat.c

Log Message:
make(1): extract MakeBeginNode from Compat_Run

The comment "execute the commands" had once been correct but not
anymore.  Since a few years, not only the commands of the .BEGIN and
.END nodes are executed, instead the nodes are made as usual, including
their dependencies.


To generate a diff of this commit:
cvs rdiff -u -r1.209 -r1.210 src/usr.bin/make/compat.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/compat.c
diff -u src/usr.bin/make/compat.c:1.209 src/usr.bin/make/compat.c:1.210
--- src/usr.bin/make/compat.c:1.209	Sun Dec 13 16:14:40 2020
+++ src/usr.bin/make/compat.c	Sun Dec 13 16:30:08 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat.c,v 1.209 2020/12/13 16:14:40 rillig Exp $	*/
+/*	$NetBSD: compat.c,v 1.210 2020/12/13 16:30:08 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -96,7 +96,7 @@
 #include "pathnames.h"
 
 /*	"@(#)compat.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: compat.c,v 1.209 2020/12/13 16:14:40 rillig Exp $");
+MAKE_RCSID("$NetBSD: compat.c,v 1.210 2020/12/13 16:30:08 rillig Exp $");
 
 static GNode *curTarg = NULL;
 static pid_t compatChild;
@@ -660,6 +660,20 @@ cohorts:
 	MakeNodes(&gn->cohorts, pgn);
 }
 
+static void
+MakeBeginNode(void)
+{
+	GNode *gn = Targ_FindNode(".BEGIN");
+	if (gn == NULL)
+		return;
+
+	Compat_Make(gn, gn);
+	if (GNode_IsError(gn)) {
+		PrintOnError(gn, "\nStop.");
+		exit(1);
+	}
+}
+
 /* Initialize this module and start making.
  *
  * Input:
@@ -688,20 +702,8 @@ Compat_Run(GNodeList *targs)
 	 * detail probably doesn't matter though. */
 	(void)Targ_GetEndNode();
 
-	/*
-	 * If the user has defined a .BEGIN target, execute the commands
-	 * attached to it.
-	 */
-	if (!opts.queryFlag) {
-		gn = Targ_FindNode(".BEGIN");
-		if (gn != NULL) {
-			Compat_Make(gn, gn);
-			if (GNode_IsError(gn)) {
-				PrintOnError(gn, "\nStop.");
-				exit(1);
-			}
-		}
-	}
+	if (!opts.queryFlag)
+		MakeBeginNode();
 
 	/*
 	 * Expand .USE nodes right now, because they can modify the structure

Reply via email to