Module Name: src
Committed By: rillig
Date: Tue Dec 28 14:06:43 UTC 2021
Modified Files:
src/usr.bin/make: make.h parse.c suff.c
Log Message:
make: extract OP_NOTARGET into separate function
No binary change, except for line numbers in assertions.
To generate a diff of this commit:
cvs rdiff -u -r1.279 -r1.280 src/usr.bin/make/make.h
cvs rdiff -u -r1.588 -r1.589 src/usr.bin/make/parse.c
cvs rdiff -u -r1.360 -r1.361 src/usr.bin/make/suff.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.h
diff -u src/usr.bin/make/make.h:1.279 src/usr.bin/make/make.h:1.280
--- src/usr.bin/make/make.h:1.279 Mon Dec 27 18:26:22 2021
+++ src/usr.bin/make/make.h Tue Dec 28 14:06:42 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: make.h,v 1.279 2021/12/27 18:26:22 rillig Exp $ */
+/* $NetBSD: make.h,v 1.280 2021/12/28 14:06:42 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -360,8 +360,6 @@ typedef enum GNodeType {
OP_DEPS_FOUND = 1 << 24,
/* Node found while expanding .ALLSRC */
OP_MARK = 1 << 23,
-
- OP_NOTARGET = OP_NOTMAIN | OP_USE | OP_EXEC | OP_TRANSFORM
} GNodeType;
typedef struct GNodeFlags {
@@ -815,6 +813,14 @@ GNode_IsError(const GNode *gn)
return gn->made == ERROR || gn->made == ABORTED;
}
+MAKE_INLINE bool MAKE_ATTR_USE
+GNode_IsMainCandidate(const GNode *gn)
+{
+ /* XXX: What about OP_USEBEFORE? */
+ return (gn->type & (OP_NOTMAIN | OP_USE | OP_EXEC | OP_TRANSFORM)) ==
+ 0;
+}
+
MAKE_INLINE const char * MAKE_ATTR_USE
GNode_VarTarget(GNode *gn) { return GNode_ValueDirect(gn, TARGET); }
MAKE_INLINE const char * MAKE_ATTR_USE
Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.588 src/usr.bin/make/parse.c:1.589
--- src/usr.bin/make/parse.c:1.588 Tue Dec 28 01:27:37 2021
+++ src/usr.bin/make/parse.c Tue Dec 28 14:06:42 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.588 2021/12/28 01:27:37 rillig Exp $ */
+/* $NetBSD: parse.c,v 1.589 2021/12/28 14:06:42 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -109,7 +109,7 @@
#include "pathnames.h"
/* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: parse.c,v 1.588 2021/12/28 01:27:37 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.589 2021/12/28 14:06:42 rillig Exp $");
/* types and constants */
@@ -154,8 +154,7 @@ typedef enum ParseSpecial {
SP_INCLUDES, /* .INCLUDES; not mentioned in the manual page */
SP_INTERRUPT, /* .INTERRUPT */
SP_LIBS, /* .LIBS; not mentioned in the manual page */
- /* .MAIN and we don't have anything user-specified to make */
- SP_MAIN,
+ SP_MAIN, /* .MAIN and no user-specified targets to make */
SP_META, /* .META */
SP_MFLAGS, /* .MFLAGS or .MAKEFLAGS */
SP_NOMETA, /* .NOMETA */
@@ -187,8 +186,8 @@ typedef ListNode SearchPathListNode;
/* result data */
/*
- * The main target to create. This is the first target on the first
- * dependency line in the first makefile.
+ * The main target to create. This is the first target defined in any of the
+ * makefiles.
*/
static GNode *mainNode;
@@ -981,7 +980,7 @@ FindMainTarget(void)
for (ln = targets->first; ln != NULL; ln = ln->next) {
GNode *gn = ln->datum;
- if (!(gn->type & OP_NOTARGET)) {
+ if (GNode_IsMainCandidate(gn)) {
DEBUG1(MAKE, "Setting main node to \"%s\"\n", gn->name);
mainNode = gn;
Targ_SetMain(gn);
Index: src/usr.bin/make/suff.c
diff -u src/usr.bin/make/suff.c:1.360 src/usr.bin/make/suff.c:1.361
--- src/usr.bin/make/suff.c:1.360 Wed Dec 15 12:58:01 2021
+++ src/usr.bin/make/suff.c Tue Dec 28 14:06:42 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: suff.c,v 1.360 2021/12/15 12:58:01 rillig Exp $ */
+/* $NetBSD: suff.c,v 1.361 2021/12/28 14:06:42 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -115,7 +115,7 @@
#include "dir.h"
/* "@(#)suff.c 8.4 (Berkeley) 3/21/94" */
-MAKE_RCSID("$NetBSD: suff.c,v 1.360 2021/12/15 12:58:01 rillig Exp $");
+MAKE_RCSID("$NetBSD: suff.c,v 1.361 2021/12/28 14:06:42 rillig Exp $");
typedef List SuffixList;
typedef ListNode SuffixListNode;
@@ -741,7 +741,7 @@ UpdateTarget(GNode *target, GNode **inou
char *ptr;
if (*inout_main == NULL && *inout_removedMain &&
- !(target->type & OP_NOTARGET)) {
+ GNode_IsMainCandidate(target)) {
DEBUG1(MAKE, "Setting main node to \"%s\"\n", target->name);
*inout_main = target;
Targ_SetMain(target);