Module Name: src
Committed By: rillig
Date: Mon Oct 26 21:34:10 UTC 2020
Modified Files:
src/usr.bin/make: compat.c cond.c job.c job.h main.c make.c make.h
parse.c targ.c var.c
Log Message:
make(1): group the command line options and arguments
By having a single struct that holds all command line options and
arguments, it is easy to see in the code when such a command line
argument is modified. It also cleans up the namespace since the command
line options don't follow a common naming style. Having them in a
struct also means that there is a single place for putting the
documentation, not two as before.
The struct also suggests to extract the initialization code out of main,
which is still too large, having more than 400 lines of code and
covering far too many topics.
To generate a diff of this commit:
cvs rdiff -u -r1.168 -r1.169 src/usr.bin/make/compat.c \
src/usr.bin/make/cond.c
cvs rdiff -u -r1.289 -r1.290 src/usr.bin/make/job.c
cvs rdiff -u -r1.57 -r1.58 src/usr.bin/make/job.h
cvs rdiff -u -r1.390 -r1.391 src/usr.bin/make/main.c
cvs rdiff -u -r1.180 -r1.181 src/usr.bin/make/make.c
cvs rdiff -u -r1.172 -r1.173 src/usr.bin/make/make.h
cvs rdiff -u -r1.400 -r1.401 src/usr.bin/make/parse.c
cvs rdiff -u -r1.124 -r1.125 src/usr.bin/make/targ.c
cvs rdiff -u -r1.589 -r1.590 src/usr.bin/make/var.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.168 src/usr.bin/make/compat.c:1.169
--- src/usr.bin/make/compat.c:1.168 Sat Oct 24 04:40:45 2020
+++ src/usr.bin/make/compat.c Mon Oct 26 21:34:10 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: compat.c,v 1.168 2020/10/24 04:40:45 rillig Exp $ */
+/* $NetBSD: compat.c,v 1.169 2020/10/26 21:34:10 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.168 2020/10/24 04:40:45 rillig Exp $");
+MAKE_RCSID("$NetBSD: compat.c,v 1.169 2020/10/26 21:34:10 rillig Exp $");
static GNode *curTarg = NULL;
static pid_t compatChild;
@@ -113,7 +113,7 @@ CompatDeleteTarget(GNode *gn)
char *file_freeIt;
const char *file = Var_Value(TARGET, gn, &file_freeIt);
- if (!noExecute && eunlink(file) != -1) {
+ if (!opts.noExecute && eunlink(file) != -1) {
Error("*** %s removed", file);
}
@@ -420,7 +420,7 @@ Compat_RunCommand(const char *cmdp, GNod
}
#endif
gn->made = ERROR;
- if (keepgoing) {
+ if (opts.keepgoing) {
/* Abort the current target, but let others continue. */
printf(" (continuing)\n");
} else {
@@ -526,7 +526,7 @@ Compat_Make(GNode *gn, GNode *pgn)
* If the user is just seeing if something is out-of-date, exit now
* to tell him/her "yes".
*/
- if (queryFlag) {
+ if (opts.queryFlag) {
exit(1);
}
@@ -551,7 +551,7 @@ Compat_Make(GNode *gn, GNode *pgn)
* Our commands are ok, but we still have to worry about the -t
* flag...
*/
- if (!touchFlag || (gn->type & OP_MAKE)) {
+ if (!opts.touchFlag || (gn->type & OP_MAKE)) {
curTarg = gn;
#ifdef USE_META
if (useMeta && !NoExecute(gn)) {
@@ -586,7 +586,7 @@ Compat_Make(GNode *gn, GNode *pgn)
pgn->flags |= CHILDMADE;
Make_TimeStamp(pgn, gn);
}
- } else if (keepgoing) {
+ } else if (opts.keepgoing) {
pgn->flags &= ~(unsigned)REMAKE;
} else {
PrintOnError(gn, "\nStop.");
@@ -659,7 +659,7 @@ Compat_Run(GNodeList *targs)
* If the user has defined a .BEGIN target, execute the commands attached
* to it.
*/
- if (!queryFlag) {
+ if (!opts.queryFlag) {
gn = Targ_FindNode(".BEGIN");
if (gn != NULL) {
Compat_Make(gn, gn);
Index: src/usr.bin/make/cond.c
diff -u src/usr.bin/make/cond.c:1.168 src/usr.bin/make/cond.c:1.169
--- src/usr.bin/make/cond.c:1.168 Sat Oct 24 04:51:19 2020
+++ src/usr.bin/make/cond.c Mon Oct 26 21:34:10 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: cond.c,v 1.168 2020/10/24 04:51:19 rillig Exp $ */
+/* $NetBSD: cond.c,v 1.169 2020/10/26 21:34:10 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -93,7 +93,7 @@
#include "dir.h"
/* "@(#)cond.c 8.2 (Berkeley) 1/2/94" */
-MAKE_RCSID("$NetBSD: cond.c,v 1.168 2020/10/24 04:51:19 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.169 2020/10/26 21:34:10 rillig Exp $");
/*
* The parsing of conditional expressions is based on this grammar:
@@ -294,7 +294,7 @@ FuncMake(size_t argLen MAKE_ATTR_UNUSED,
{
StringListNode *ln;
- for (ln = create->first; ln != NULL; ln = ln->next)
+ for (ln = opts.create->first; ln != NULL; ln = ln->next)
if (Str_Match(ln->datum, arg))
return TRUE;
return FALSE;
Index: src/usr.bin/make/job.c
diff -u src/usr.bin/make/job.c:1.289 src/usr.bin/make/job.c:1.290
--- src/usr.bin/make/job.c:1.289 Mon Oct 26 20:11:02 2020
+++ src/usr.bin/make/job.c Mon Oct 26 21:34:10 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: job.c,v 1.289 2020/10/26 20:11:02 rillig Exp $ */
+/* $NetBSD: job.c,v 1.290 2020/10/26 21:34:10 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -143,7 +143,7 @@
#include "trace.h"
/* "@(#)job.c 8.2 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: job.c,v 1.289 2020/10/26 20:11:02 rillig Exp $");
+MAKE_RCSID("$NetBSD: job.c,v 1.290 2020/10/26 21:34:10 rillig Exp $");
/* A shell defines how the commands are run. All commands for a target are
* written into a single file, which is then given to the shell to execute
@@ -402,7 +402,7 @@ enum { npseudojobs = 2 }; /* number of p
#define TARG_FMT "%s %s ---\n" /* Default format */
#define MESSAGE(fp, gn) \
- if (maxJobs != 1 && targPrefix && *targPrefix) \
+ if (opts.maxJobs != 1 && targPrefix && *targPrefix) \
(void)fprintf(fp, TARG_FMT, targPrefix, gn->name)
static sigset_t caught_signals; /* Set of signals we handle */
@@ -449,7 +449,7 @@ JobDeleteTarget(GNode *gn)
return;
if (Targ_Precious(gn))
return;
- if (noExecute)
+ if (opts.noExecute)
return;
file = GNode_Path(gn);
@@ -1083,7 +1083,7 @@ JobFinish(Job *job, int status)
/*
* Set aborting if any error.
*/
- if (errors && !keepgoing && (aborting != ABORT_INTERRUPT)) {
+ if (errors && !opts.keepgoing && (aborting != ABORT_INTERRUPT)) {
/*
* If we found any errors in this batch of children and the -k flag
* wasn't given, we set the aborting flag so no more jobs get
@@ -1235,7 +1235,7 @@ Job_CheckCommands(GNode *gn, void (*abor
return TRUE;
}
- if (keepgoing) {
+ if (opts.keepgoing) {
(void)fprintf(stdout, "%s: don't know how to make %s (%s)\n",
progname, gn->name, "continuing");
(void)fflush(stdout);
@@ -1524,8 +1524,8 @@ JobStart(GNode *gn, int flags)
* need to reopen it to feed it to the shell. If the -n flag *was* given,
* we just set the file to be stdout. Cute, huh?
*/
- if (((gn->type & OP_MAKE) && !(noRecursiveExecute)) ||
- (!noExecute && !touchFlag)) {
+ if (((gn->type & OP_MAKE) && !opts.noRecursiveExecute) ||
+ (!opts.noExecute && !opts.touchFlag)) {
/*
* tfile is the name of a file into which all shell commands are
* put. It is removed before the child shell is executed, unless
@@ -1824,7 +1824,7 @@ end_loop:
* our own free will.
*/
if (*cp != '\0') {
- if (!beSilent && job->node != lastNode) {
+ if (!opts.beSilent && job->node != lastNode) {
MESSAGE(stdout, job->node);
lastNode = job->node;
}
@@ -2117,9 +2117,9 @@ Job_Init(void)
{
Job_SetPrefix();
/* Allocate space for all the job info */
- job_table = bmake_malloc((size_t)maxJobs * sizeof *job_table);
- memset(job_table, 0, (size_t)maxJobs * sizeof *job_table);
- job_table_end = job_table + maxJobs;
+ job_table = bmake_malloc((size_t)opts.maxJobs * sizeof *job_table);
+ memset(job_table, 0, (size_t)opts.maxJobs * sizeof *job_table);
+ job_table_end = job_table + opts.maxJobs;
wantToken = 0;
aborting = 0;
@@ -2150,9 +2150,9 @@ Job_Init(void)
/* Preallocate enough for the maximum number of jobs. */
fds = bmake_malloc(sizeof(*fds) *
- (npseudojobs + (size_t)maxJobs) * nfds_per_job());
+ (npseudojobs + (size_t)opts.maxJobs) * nfds_per_job());
jobfds = bmake_malloc(sizeof(*jobfds) *
- (npseudojobs + (size_t)maxJobs) * nfds_per_job());
+ (npseudojobs + (size_t)opts.maxJobs) * nfds_per_job());
/* These are permanent entries and take slots 0 and 1 */
watchfd(&tokenWaitJob);
@@ -2474,10 +2474,10 @@ JobInterrupt(int runINTERRUPT, int signo
JobSigUnlock(&mask);
- if (runINTERRUPT && !touchFlag) {
+ if (runINTERRUPT && !opts.touchFlag) {
interrupt = Targ_FindNode(".INTERRUPT");
if (interrupt != NULL) {
- ignoreErrors = FALSE;
+ opts.ignoreErrors = FALSE;
JobRun(interrupt);
}
}
@@ -2730,7 +2730,7 @@ Job_TokenWithdraw(void)
DEBUG3(JOB, "Job_TokenWithdraw(%d): aborting %d, running %d\n",
getpid(), aborting, jobTokensRunning);
- if (aborting || (jobTokensRunning >= maxJobs))
+ if (aborting || (jobTokensRunning >= opts.maxJobs))
return FALSE;
count = read(tokenWaitJob.inPipe, &tok, 1);
Index: src/usr.bin/make/job.h
diff -u src/usr.bin/make/job.h:1.57 src/usr.bin/make/job.h:1.58
--- src/usr.bin/make/job.h:1.57 Fri Oct 23 07:14:32 2020
+++ src/usr.bin/make/job.h Mon Oct 26 21:34:10 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: job.h,v 1.57 2020/10/23 07:14:32 rillig Exp $ */
+/* $NetBSD: job.h,v 1.58 2020/10/26 21:34:10 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -192,7 +192,6 @@ extern const char *shellName;
extern char *shellErrFlag;
extern int jobTokensRunning; /* tokens currently "out" */
-extern int maxJobs; /* Max jobs we can run */
void Shell_Init(void);
const char *Shell_GetNewline(void);
Index: src/usr.bin/make/main.c
diff -u src/usr.bin/make/main.c:1.390 src/usr.bin/make/main.c:1.391
--- src/usr.bin/make/main.c:1.390 Sun Oct 25 19:19:07 2020
+++ src/usr.bin/make/main.c Mon Oct 26 21:34:10 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.390 2020/10/25 19:19:07 rillig Exp $ */
+/* $NetBSD: main.c,v 1.391 2020/10/26 21:34:10 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -118,7 +118,7 @@
#include "trace.h"
/* "@(#)main.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: main.c,v 1.390 2020/10/25 19:19:07 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.391 2020/10/26 21:34:10 rillig Exp $");
#if defined(MAKE_NATIVE) && !defined(lint)
__COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
"The Regents of the University of California. "
@@ -129,38 +129,18 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19
#define DEFMAXLOCAL DEFMAXJOBS
#endif
-StringList * create; /* Targets to be made */
+CmdOpts opts;
time_t now; /* Time at start of make */
GNode *DEFAULT; /* .DEFAULT node */
Boolean allPrecious; /* .PRECIOUS given on line by itself */
Boolean deleteOnError; /* .DELETE_ON_ERROR: set */
-static Boolean noBuiltins; /* -r flag */
-static StringList * makefiles; /* ordered list of makefiles to read */
-static int printVars; /* -[vV] argument */
-#define COMPAT_VARS 1
-#define EXPAND_VARS 2
-static StringList * variables; /* list of variables to print
- * (for -v and -V) */
-int maxJobs; /* -j argument */
static int maxJobTokens; /* -j argument */
-Boolean compatMake; /* -B argument */
-DebugFlags debug; /* -d argument */
Boolean debugVflag; /* -dV */
-Boolean noExecute; /* -n flag */
-Boolean noRecursiveExecute; /* -N flag */
-Boolean keepgoing; /* -k flag */
-Boolean queryFlag; /* -q flag */
-Boolean touchFlag; /* -t flag */
-Boolean enterFlag; /* -w flag */
Boolean enterFlagObj; /* -w and objdir != srcdir */
-Boolean ignoreErrors; /* -i flag */
-Boolean beSilent; /* -s flag */
+
Boolean oldVars; /* variable substitution style */
-Boolean checkEnvFirst; /* -e flag */
-Boolean parseWarnFatal; /* -W flag */
static int jp_0 = -1, jp_1 = -1; /* ends of parent job pipe */
-Boolean varNoExportEnv; /* -X flag */
Boolean doing_depend; /* Set while reading .depend */
static Boolean jobsRunning; /* TRUE if the jobs might be running */
static const char * tracefile;
@@ -176,8 +156,6 @@ char *makeDependfile;
pid_t myPid;
int makelevel;
-FILE *debug_file;
-
Boolean forceJobs = FALSE;
extern SearchPath *parseIncPath;
@@ -221,8 +199,8 @@ parse_debug_option_F(const char *modules
size_t len;
char *fname;
- if (debug_file != stdout && debug_file != stderr)
- fclose(debug_file);
+ if (opts.debug_file != stdout && opts.debug_file != stderr)
+ fclose(opts.debug_file);
if (*modules == '+') {
modules++;
@@ -231,11 +209,11 @@ parse_debug_option_F(const char *modules
mode = "w";
if (strcmp(modules, "stdout") == 0) {
- debug_file = stdout;
+ opts.debug_file = stdout;
return;
}
if (strcmp(modules, "stderr") == 0) {
- debug_file = stderr;
+ opts.debug_file = stderr;
return;
}
@@ -247,8 +225,8 @@ parse_debug_option_F(const char *modules
if (strcmp(fname + len - 3, ".%d") == 0)
snprintf(fname + len - 2, 20, "%d", getpid());
- debug_file = fopen(fname, mode);
- if (!debug_file) {
+ opts.debug_file = fopen(fname, mode);
+ if (!opts.debug_file) {
fprintf(stderr, "Cannot open debug file %s\n",
fname);
usage();
@@ -264,81 +242,81 @@ parse_debug_options(const char *argvalue
for (modules = argvalue; *modules; ++modules) {
switch (*modules) {
case '0': /* undocumented, only intended for tests */
- debug &= DEBUG_LINT;
+ opts.debug &= DEBUG_LINT;
break;
case 'A':
- debug = ~(0|DEBUG_LINT);
+ opts.debug = ~(0|DEBUG_LINT);
break;
case 'a':
- debug |= DEBUG_ARCH;
+ opts.debug |= DEBUG_ARCH;
break;
case 'C':
- debug |= DEBUG_CWD;
+ opts.debug |= DEBUG_CWD;
break;
case 'c':
- debug |= DEBUG_COND;
+ opts.debug |= DEBUG_COND;
break;
case 'd':
- debug |= DEBUG_DIR;
+ opts.debug |= DEBUG_DIR;
break;
case 'e':
- debug |= DEBUG_ERROR;
+ opts.debug |= DEBUG_ERROR;
break;
case 'f':
- debug |= DEBUG_FOR;
+ opts.debug |= DEBUG_FOR;
break;
case 'g':
if (modules[1] == '1') {
- debug |= DEBUG_GRAPH1;
+ opts.debug |= DEBUG_GRAPH1;
++modules;
}
else if (modules[1] == '2') {
- debug |= DEBUG_GRAPH2;
+ opts.debug |= DEBUG_GRAPH2;
++modules;
}
else if (modules[1] == '3') {
- debug |= DEBUG_GRAPH3;
+ opts.debug |= DEBUG_GRAPH3;
++modules;
}
break;
case 'h':
- debug |= DEBUG_HASH;
+ opts.debug |= DEBUG_HASH;
break;
case 'j':
- debug |= DEBUG_JOB;
+ opts.debug |= DEBUG_JOB;
break;
case 'L':
- debug |= DEBUG_LINT;
+ opts.debug |= DEBUG_LINT;
break;
case 'l':
- debug |= DEBUG_LOUD;
+ opts.debug |= DEBUG_LOUD;
break;
case 'M':
- debug |= DEBUG_META;
+ opts.debug |= DEBUG_META;
break;
case 'm':
- debug |= DEBUG_MAKE;
+ opts.debug |= DEBUG_MAKE;
break;
case 'n':
- debug |= DEBUG_SCRIPT;
+ opts.debug |= DEBUG_SCRIPT;
break;
case 'p':
- debug |= DEBUG_PARSE;
+ opts.debug |= DEBUG_PARSE;
break;
case 's':
- debug |= DEBUG_SUFF;
+ opts.debug |= DEBUG_SUFF;
break;
case 't':
- debug |= DEBUG_TARG;
+ opts.debug |= DEBUG_TARG;
break;
case 'V':
debugVflag = TRUE;
break;
case 'v':
- debug |= DEBUG_VAR;
+ opts.debug |= DEBUG_VAR;
break;
case 'x':
- debug |= DEBUG_SHELL;
+ opts.debug |= DEBUG_SHELL;
break;
case 'F':
parse_debug_option_F(modules + 1);
@@ -355,8 +333,8 @@ debug_setbuf:
* Make the debug_file unbuffered, and make
* stdout line buffered (unless debugfile == stdout).
*/
- setvbuf(debug_file, NULL, _IONBF, 0);
- if (debug_file != stdout) {
+ setvbuf(opts.debug_file, NULL, _IONBF, 0);
+ if (opts.debug_file != stdout) {
setvbuf(stdout, NULL, _IOLBF, 0);
}
}
@@ -426,7 +404,7 @@ MainParseArgJobsInternal(const char *arg
#endif
jp_0 = -1;
jp_1 = -1;
- compatMake = TRUE;
+ opts.compatMake = TRUE;
} else {
Var_Append(MAKEFLAGS, "-J", VAR_GLOBAL);
Var_Append(MAKEFLAGS, argvalue, VAR_GLOBAL);
@@ -439,8 +417,8 @@ MainParseArgJobs(const char *argvalue)
char *p;
forceJobs = TRUE;
- maxJobs = (int)strtol(argvalue, &p, 0);
- if (*p != '\0' || maxJobs < 1) {
+ opts.maxJobs = (int)strtol(argvalue, &p, 0);
+ if (*p != '\0' || opts.maxJobs < 1) {
(void)fprintf(stderr,
"%s: illegal argument to -j -- must be positive integer!\n",
progname);
@@ -449,7 +427,7 @@ MainParseArgJobs(const char *argvalue)
Var_Append(MAKEFLAGS, "-j", VAR_GLOBAL);
Var_Append(MAKEFLAGS, argvalue, VAR_GLOBAL);
Var_Set(".MAKE.JOBS", argvalue, VAR_GLOBAL);
- maxJobTokens = maxJobs;
+ maxJobTokens = opts.maxJobs;
}
static void
@@ -476,7 +454,7 @@ MainParseArg(char c, const char *argvalu
case '\0':
break;
case 'B':
- compatMake = TRUE;
+ opts.compatMake = TRUE;
Var_Append(MAKEFLAGS, "-B", VAR_GLOBAL);
Var_Set(MAKE_MODE, "compat", VAR_GLOBAL);
break;
@@ -498,12 +476,12 @@ MainParseArg(char c, const char *argvalu
MainParseArgJobsInternal(argvalue);
break;
case 'N':
- noExecute = TRUE;
- noRecursiveExecute = TRUE;
+ opts.noExecute = TRUE;
+ opts.noRecursiveExecute = TRUE;
Var_Append(MAKEFLAGS, "-N", VAR_GLOBAL);
break;
case 'S':
- keepgoing = FALSE;
+ opts.keepgoing = FALSE;
Var_Append(MAKEFLAGS, "-S", VAR_GLOBAL);
break;
case 'T':
@@ -513,16 +491,17 @@ MainParseArg(char c, const char *argvalu
break;
case 'V':
case 'v':
- printVars = c == 'v' ? EXPAND_VARS : COMPAT_VARS;
- Lst_Append(variables, bmake_strdup(argvalue));
+ opts.printVars = c == 'v' ? EXPAND_VARS : COMPAT_VARS;
+ Lst_Append(opts.variables, bmake_strdup(argvalue));
+ /* XXX: Why always -V? */
Var_Append(MAKEFLAGS, "-V", VAR_GLOBAL);
Var_Append(MAKEFLAGS, argvalue, VAR_GLOBAL);
break;
case 'W':
- parseWarnFatal = TRUE;
+ opts.parseWarnFatal = TRUE;
break;
case 'X':
- varNoExportEnv = TRUE;
+ opts.varNoExportEnv = TRUE;
Var_Append(MAKEFLAGS, "-X", VAR_GLOBAL);
break;
case 'd':
@@ -536,49 +515,49 @@ MainParseArg(char c, const char *argvalu
parse_debug_options(argvalue);
break;
case 'e':
- checkEnvFirst = TRUE;
+ opts.checkEnvFirst = TRUE;
Var_Append(MAKEFLAGS, "-e", VAR_GLOBAL);
break;
case 'f':
- Lst_Append(makefiles, bmake_strdup(argvalue));
+ Lst_Append(opts.makefiles, bmake_strdup(argvalue));
break;
case 'i':
- ignoreErrors = TRUE;
+ opts.ignoreErrors = TRUE;
Var_Append(MAKEFLAGS, "-i", VAR_GLOBAL);
break;
case 'j':
MainParseArgJobs(argvalue);
break;
case 'k':
- keepgoing = TRUE;
+ opts.keepgoing = TRUE;
Var_Append(MAKEFLAGS, "-k", VAR_GLOBAL);
break;
case 'm':
MainParseArgSysInc(argvalue);
break;
case 'n':
- noExecute = TRUE;
+ opts.noExecute = TRUE;
Var_Append(MAKEFLAGS, "-n", VAR_GLOBAL);
break;
case 'q':
- queryFlag = TRUE;
+ opts.queryFlag = TRUE;
/* Kind of nonsensical, wot? */
Var_Append(MAKEFLAGS, "-q", VAR_GLOBAL);
break;
case 'r':
- noBuiltins = TRUE;
+ opts.noBuiltins = TRUE;
Var_Append(MAKEFLAGS, "-r", VAR_GLOBAL);
break;
case 's':
- beSilent = TRUE;
+ opts.beSilent = TRUE;
Var_Append(MAKEFLAGS, "-s", VAR_GLOBAL);
break;
case 't':
- touchFlag = TRUE;
+ opts.touchFlag = TRUE;
Var_Append(MAKEFLAGS, "-t", VAR_GLOBAL);
break;
case 'w':
- enterFlag = TRUE;
+ opts.enterFlag = TRUE;
Var_Append(MAKEFLAGS, "-w", VAR_GLOBAL);
break;
default:
@@ -677,7 +656,7 @@ rearg:
Punt("illegal (null) argument.");
if (*argv[1] == '-' && !dashDash)
goto rearg;
- Lst_Append(create, bmake_strdup(argv[1]));
+ Lst_Append(opts.create, bmake_strdup(argv[1]));
}
}
@@ -753,7 +732,7 @@ Main_SetObjdir(const char *fmt, ...)
Dir_InitDot();
purge_cached_realpaths();
rc = TRUE;
- if (enterFlag && strcmp(objdir, curdir) != 0)
+ if (opts.enterFlag && strcmp(objdir, curdir) != 0)
enterFlagObj = TRUE;
}
}
@@ -847,7 +826,7 @@ MakeMode(const char *mode)
if (mode[0] != '\0') {
if (strstr(mode, "compat")) {
- compatMake = TRUE;
+ opts.compatMake = TRUE;
forceJobs = FALSE;
}
#if USE_META
@@ -892,14 +871,14 @@ doPrintVars(void)
StringListNode *ln;
Boolean expandVars;
- if (printVars == EXPAND_VARS)
+ if (opts.printVars == EXPAND_VARS)
expandVars = TRUE;
else if (debugVflag)
expandVars = FALSE;
else
expandVars = getBoolean(".MAKE.EXPAND_VARIABLES", FALSE);
- for (ln = variables->first; ln != NULL; ln = ln->next) {
+ for (ln = opts.variables->first; ln != NULL; ln = ln->next) {
const char *varname = ln->datum;
PrintVar(varname, expandVars);
}
@@ -917,12 +896,12 @@ runTargets(void)
* we consult the parsing module to find the main target(s)
* to create.
*/
- if (Lst_IsEmpty(create))
+ if (Lst_IsEmpty(opts.create))
targs = Parse_MainName();
else
- targs = Targ_FindList(create);
+ targs = Targ_FindList(opts.create);
- if (!compatMake) {
+ if (!opts.compatMake) {
/*
* Initialize job module before traversing the graph
* now that any .BEGIN and .END targets have been read.
@@ -930,7 +909,7 @@ runTargets(void)
* (to prevent the .BEGIN from being executed should
* it exist).
*/
- if (!queryFlag) {
+ if (!opts.queryFlag) {
Job_Init();
jobsRunning = TRUE;
}
@@ -959,12 +938,12 @@ InitVarTargets(void)
{
StringListNode *ln;
- if (Lst_IsEmpty(create)) {
+ if (Lst_IsEmpty(opts.create)) {
Var_Set(".TARGETS", "", VAR_GLOBAL);
return;
}
- for (ln = create->first; ln != NULL; ln = ln->next) {
+ for (ln = opts.create->first; ln != NULL; ln = ln->next) {
char *name = ln->datum;
Var_Append(".TARGETS", name, VAR_GLOBAL);
}
@@ -1103,7 +1082,7 @@ main(int argc, char **argv)
struct utsname utsname;
/* default to writing debug to stderr */
- debug_file = stderr;
+ opts.debug_file = stderr;
#ifdef SIGINFO
(void)bmake_signal(SIGINFO, siginfo);
@@ -1174,27 +1153,27 @@ main(int argc, char **argv)
VAR_GLOBAL);
Var_Set(MAKE_DEPENDFILE, ".depend", VAR_GLOBAL);
- create = Lst_New();
- makefiles = Lst_New();
- printVars = 0;
+ opts.create = Lst_New();
+ opts.makefiles = Lst_New();
+ opts.printVars = 0;
debugVflag = FALSE;
- variables = Lst_New();
- beSilent = FALSE; /* Print commands as executed */
- ignoreErrors = FALSE; /* Pay attention to non-zero returns */
- noExecute = FALSE; /* Execute all commands */
- noRecursiveExecute = FALSE; /* Execute all .MAKE targets */
- keepgoing = FALSE; /* Stop on error */
+ opts.variables = Lst_New();
+ opts.beSilent = FALSE; /* Print commands as executed */
+ opts.ignoreErrors = FALSE; /* Pay attention to non-zero returns */
+ opts.noExecute = FALSE; /* Execute all commands */
+ opts.noRecursiveExecute = FALSE; /* Execute all .MAKE targets */
+ opts.keepgoing = FALSE; /* Stop on error */
allPrecious = FALSE; /* Remove targets when interrupted */
deleteOnError = FALSE; /* Historical default behavior */
- queryFlag = FALSE; /* This is not just a check-run */
- noBuiltins = FALSE; /* Read the built-in rules */
- touchFlag = FALSE; /* Actually update targets */
- debug = 0; /* No debug verbosity, please. */
+ opts.queryFlag = FALSE; /* This is not just a check-run */
+ opts.noBuiltins = FALSE; /* Read the built-in rules */
+ opts.touchFlag = FALSE; /* Actually update targets */
+ opts.debug = 0; /* No debug verbosity, please. */
jobsRunning = FALSE;
- maxJobs = DEFMAXLOCAL; /* Set default local max concurrency */
- maxJobTokens = maxJobs;
- compatMake = FALSE; /* No compat mode */
+ opts.maxJobs = DEFMAXLOCAL; /* Set default local max concurrency */
+ maxJobTokens = opts.maxJobs;
+ opts.compatMake = FALSE; /* No compat mode */
ignorePWD = FALSE;
/*
@@ -1288,7 +1267,7 @@ main(int argc, char **argv)
MainParseArgs(argc, argv);
- if (enterFlag)
+ if (opts.enterFlag)
printf("%s: Entering directory `%s'\n", progname, curdir);
/*
@@ -1376,7 +1355,7 @@ main(int argc, char **argv)
* makefiles, or the default makefile and Makefile, in that order,
* if no makefiles were given on the command line.
*/
- if (!noBuiltins) {
+ if (!opts.noBuiltins) {
sysMkPath = Lst_New();
Dir_Expand(_PATH_DEFSYSMK,
Lst_IsEmpty(sysIncPath) ? defIncPath : sysIncPath,
@@ -1389,10 +1368,10 @@ main(int argc, char **argv)
(char *)sysMkPath->first->datum);
}
- if (makefiles->first != NULL) {
+ if (opts.makefiles->first != NULL) {
StringListNode *ln;
- for (ln = makefiles->first; ln != NULL; ln = ln->next) {
+ for (ln = opts.makefiles->first; ln != NULL; ln = ln->next) {
if (ReadMakefile(ln->datum) != 0)
Fatal("%s: cannot open %s.",
progname, (char *)ln->datum);
@@ -1401,13 +1380,14 @@ main(int argc, char **argv)
(void)Var_Subst("${" MAKEFILE_PREFERENCE "}",
VAR_CMD, VARE_WANTRES, &p1);
/* TODO: handle errors */
- (void)str2Lst_Append(makefiles, p1, NULL);
- (void)Lst_ForEachUntil(makefiles, ReadMakefileSucceeded, NULL);
+ (void)str2Lst_Append(opts.makefiles, p1, NULL);
+ (void)Lst_ForEachUntil(opts.makefiles,
+ ReadMakefileSucceeded, NULL);
free(p1);
}
/* In particular suppress .depend for '-r -V .OBJDIR -f /dev/null' */
- if (!noBuiltins || !printVars) {
+ if (!opts.noBuiltins || !opts.printVars) {
/* ignore /dev/null and anything starting with "no" */
(void)Var_Subst("${.MAKE.DEPENDFILE:N/dev/null:Nno*:T}",
VAR_CMD, VARE_WANTRES, &makeDependfile);
@@ -1427,7 +1407,7 @@ main(int argc, char **argv)
Var_Append("MFLAGS", Var_Value(MAKEFLAGS, VAR_GLOBAL, &p1), VAR_GLOBAL);
bmake_free(p1);
- if (!forceJobs && !compatMake &&
+ if (!forceJobs && !opts.compatMake &&
Var_Exists(".MAKE.JOBS", VAR_GLOBAL)) {
char *value;
int n;
@@ -1440,12 +1420,12 @@ main(int argc, char **argv)
progname);
exit(1);
}
- if (n != maxJobs) {
+ if (n != opts.maxJobs) {
Var_Append(MAKEFLAGS, "-j", VAR_GLOBAL);
Var_Append(MAKEFLAGS, value, VAR_GLOBAL);
}
- maxJobs = n;
- maxJobTokens = maxJobs;
+ opts.maxJobs = n;
+ maxJobTokens = opts.maxJobs;
forceJobs = TRUE;
free(value);
}
@@ -1454,16 +1434,16 @@ main(int argc, char **argv)
* Be compatible if user did not specify -j and did not explicitly
* turned compatibility on
*/
- if (!compatMake && !forceJobs) {
- compatMake = TRUE;
+ if (!opts.compatMake && !forceJobs) {
+ opts.compatMake = TRUE;
}
- if (!compatMake)
+ if (!opts.compatMake)
Job_ServerStart(maxJobTokens, jp_0, jp_1);
DEBUG5(JOB, "job_pipe %d %d, maxjobs %d, tokens %d, compat %d\n",
- jp_0, jp_1, maxJobs, maxJobTokens, compatMake ? 1 : 0);
+ jp_0, jp_1, opts.maxJobs, maxJobTokens, opts.compatMake ? 1 : 0);
- if (!printVars)
+ if (!opts.printVars)
Main_ExportMAKEFLAGS(TRUE); /* initial export */
@@ -1516,7 +1496,7 @@ main(int argc, char **argv)
Targ_PrintGraph(1);
/* print the values of any variables requested by the user */
- if (printVars) {
+ if (opts.printVars) {
doPrintVars();
outOfDate = FALSE;
} else {
@@ -1524,9 +1504,9 @@ main(int argc, char **argv)
}
#ifdef CLEANUP
- Lst_Free(variables);
- Lst_Free(makefiles);
- Lst_Destroy(create, free);
+ Lst_Free(opts.variables);
+ Lst_Free(opts.makefiles);
+ Lst_Destroy(opts.create, free);
#endif
/* print the graph now it's been processed if the user requested it */
@@ -1537,7 +1517,7 @@ main(int argc, char **argv)
if (enterFlagObj)
printf("%s: Leaving directory `%s'\n", progname, objdir);
- if (enterFlag)
+ if (opts.enterFlag)
printf("%s: Leaving directory `%s'\n", progname, curdir);
#ifdef USE_META
@@ -1760,7 +1740,7 @@ Error(const char *fmt, ...)
va_list ap;
FILE *err_file;
- err_file = debug_file;
+ err_file = opts.debug_file;
if (err_file == stdout)
err_file = stderr;
(void)fflush(stdout);
Index: src/usr.bin/make/make.c
diff -u src/usr.bin/make/make.c:1.180 src/usr.bin/make/make.c:1.181
--- src/usr.bin/make/make.c:1.180 Sun Oct 25 21:51:48 2020
+++ src/usr.bin/make/make.c Mon Oct 26 21:34:10 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: make.c,v 1.180 2020/10/25 21:51:48 rillig Exp $ */
+/* $NetBSD: make.c,v 1.181 2020/10/26 21:34:10 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -107,7 +107,7 @@
#include "job.h"
/* "@(#)make.c 8.1 (Berkeley) 6/6/93" */
-MAKE_RCSID("$NetBSD: make.c,v 1.180 2020/10/25 21:51:48 rillig Exp $");
+MAKE_RCSID("$NetBSD: make.c,v 1.181 2020/10/26 21:34:10 rillig Exp $");
/* Sequence # to detect recursion. */
static unsigned int checked = 1;
@@ -126,7 +126,7 @@ debug_printf(const char *fmt, ...)
va_list args;
va_start(args, fmt);
- vfprintf(debug_file, fmt, args);
+ vfprintf(opts.debug_file, fmt, args);
va_end(args);
}
@@ -180,7 +180,7 @@ GNode_FprintDetails(FILE *f, const char
Boolean
NoExecute(GNode *gn)
{
- return (gn->type & OP_MAKE) ? noRecursiveExecute : noExecute;
+ return (gn->type & OP_MAKE) ? opts.noRecursiveExecute : opts.noExecute;
}
/* Update the youngest child of the node, according to the given child. */
@@ -978,7 +978,7 @@ MakeStartJobs(void)
gn->made = BEINGMADE;
if (Make_OODate(gn)) {
DEBUG0(MAKE, "out-of-date\n");
- if (queryFlag) {
+ if (opts.queryFlag) {
return TRUE;
}
Make_DoAllVar(gn);
@@ -1017,10 +1017,10 @@ MakePrintStatusOrderNode(GNode *ogn, GNo
gn->name, gn->cohort_num, ogn->name, ogn->cohort_num);
GNode_FprintDetails(stdout, "(", ogn, ")\n");
- if (DEBUG(MAKE) && debug_file != stdout) {
+ if (DEBUG(MAKE) && opts.debug_file != stdout) {
debug_printf(" `%s%s' has .ORDER dependency against %s%s ",
gn->name, gn->cohort_num, ogn->name, ogn->cohort_num);
- GNode_FprintDetails(debug_file, "(", ogn, ")\n");
+ GNode_FprintDetails(opts.debug_file, "(", ogn, ")\n");
}
}
@@ -1060,9 +1060,9 @@ MakePrintStatus(GNode *gn, int *errors)
(*errors)++;
printf("`%s%s' was not built", gn->name, gn->cohort_num);
GNode_FprintDetails(stdout, " (", gn, ")!\n");
- if (DEBUG(MAKE) && debug_file != stdout) {
+ if (DEBUG(MAKE) && opts.debug_file != stdout) {
debug_printf("`%s%s' was not built", gn->name, gn->cohort_num);
- GNode_FprintDetails(debug_file, " (", gn, ")!\n");
+ GNode_FprintDetails(opts.debug_file, " (", gn, ")!\n");
}
/* Most likely problem is actually caused by .ORDER */
MakePrintStatusOrder(gn);
@@ -1071,7 +1071,7 @@ MakePrintStatus(GNode *gn, int *errors)
/* Errors - already counted */
printf("`%s%s' not remade because of errors.\n",
gn->name, gn->cohort_num);
- if (DEBUG(MAKE) && debug_file != stdout)
+ if (DEBUG(MAKE) && opts.debug_file != stdout)
debug_printf("`%s%s' not remade because of errors.\n",
gn->name, gn->cohort_num);
break;
@@ -1322,7 +1322,7 @@ Make_Run(GNodeList *targs)
Targ_PrintGraph(1);
}
- if (queryFlag) {
+ if (opts.queryFlag) {
/*
* We wouldn't do any work unless we could start some jobs in the
* next loop... (we won't actually start any, of course, this is just
Index: src/usr.bin/make/make.h
diff -u src/usr.bin/make/make.h:1.172 src/usr.bin/make/make.h:1.173
--- src/usr.bin/make/make.h:1.172 Sun Oct 25 21:51:49 2020
+++ src/usr.bin/make/make.h Mon Oct 26 21:34:10 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: make.h,v 1.172 2020/10/25 21:51:49 rillig Exp $ */
+/* $NetBSD: make.h,v 1.173 2020/10/26 21:34:10 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -420,40 +420,13 @@ typedef enum CondEvalResult {
/*
* Global Variables
*/
-extern StringList *create; /* The list of target names specified on the
- * command line. used to resolve #if
- * make(...) statements */
extern SearchPath *dirSearchPath;
/* The list of directories to search when
* looking for targets */
-
-extern Boolean compatMake; /* True if we are make compatible */
-extern Boolean ignoreErrors; /* True if should ignore all errors */
-extern Boolean beSilent; /* True if should print no commands */
-extern Boolean noExecute; /* True if should execute almost nothing */
-extern Boolean noRecursiveExecute;
- /* True if should execute nothing */
extern Boolean allPrecious; /* True if every target is precious */
extern Boolean deleteOnError; /* True if failed targets should be deleted */
-extern Boolean keepgoing; /* True if should continue on unaffected
- * portions of the graph when an error occurs
- * in one portion */
-extern Boolean touchFlag; /* TRUE if targets should just be 'touched'
- * if out of date. Set by the -t flag */
-extern Boolean queryFlag; /* TRUE if we aren't supposed to really make
- * anything, just see if the targets are out-
- * of-date */
extern Boolean doing_depend; /* TRUE if processing .depend */
-extern Boolean checkEnvFirst; /* TRUE if environment should be searched for
- * variables before the global context */
-
-extern Boolean parseWarnFatal; /* TRUE if makefile parsing warnings are
- * treated as errors */
-
-extern Boolean varNoExportEnv; /* TRUE if we should not export variables
- * set on the command line to the env. */
-
extern GNode *DEFAULT; /* .DEFAULT rule */
extern GNode *VAR_INTERNAL; /* Variables defined internally by make
@@ -529,17 +502,9 @@ typedef enum DebugFlags {
DEBUG_LINT = 1 << 20
} DebugFlags;
-/*
- * debug control:
- * There is one bit per module. It is up to the module what debug
- * information to print.
- */
-extern FILE *debug_file; /* Output is written here - default stderr */
-extern DebugFlags debug;
-
#define CONCAT(a,b) a##b
-#define DEBUG(module) (debug & CONCAT(DEBUG_,module))
+#define DEBUG(module) (opts.debug & CONCAT(DEBUG_,module))
void debug_printf(const char *, ...) MAKE_ATTR_PRINTFLIKE(1, 2);
@@ -567,6 +532,83 @@ void debug_printf(const char *, ...) MAK
if (!DEBUG(module)) (void)0; \
else debug_printf(fmt, arg1, arg2, arg3, arg4, arg5)
+typedef enum PrintVarsMode {
+ COMPAT_VARS = 1,
+ EXPAND_VARS
+} PrintVarsMode;
+
+/* Command line options */
+typedef struct CmdOpts {
+ /* -B: whether we are make compatible */
+ Boolean compatMake;
+
+ /* -d: debug control: There is one bit per module. It is up to the
+ * module what debug information to print. */
+ DebugFlags debug;
+
+ /* -df: debug output is written here - default stderr */
+ FILE *debug_file;
+
+ /* -e: check environment variables before global variables */
+ Boolean checkEnvFirst;
+
+ /* -f: the makefiles to read */
+ StringList *makefiles;
+
+ /* -i: if true, ignore all errors from shell commands */
+ Boolean ignoreErrors;
+
+ /* -j: the maximum number of jobs that can run in parallel;
+ * this is coordinated with the submakes */
+ int maxJobs;
+
+ /* -k: if true, continue on unaffected portions of the graph when an
+ * error occurs in one portion */
+ Boolean keepgoing;
+
+ /* -N: execute no commands from the targets */
+ Boolean noRecursiveExecute;
+
+ /* -n: execute almost no commands from the targets */
+ Boolean noExecute;
+
+ /* -q: if true, we aren't supposed to really make anything, just see if
+ * the targets are out-of-date */
+ Boolean queryFlag;
+
+ /* -r: raw mode, without loading the builtin rules. */
+ Boolean noBuiltins;
+
+ /* -s: don't echo the shell commands before executing them */
+ Boolean beSilent;
+
+ /* -t: touch the targets if they are out-of-date, but don't actually
+ * make them */
+ Boolean touchFlag;
+
+ /* -[Vv]: print expanded or unexpanded selected variables */
+ PrintVarsMode printVars;
+ /* -[Vv]: the variables to print */
+ StringList *variables;
+
+ /* -W: if true, makefile parsing warnings are treated as errors */
+ Boolean parseWarnFatal;
+
+ /* -w: print Entering and Leaving for submakes */
+ Boolean enterFlag;
+
+ /* -X: if true, do not export variables set on the command line to the
+ * environment. */
+ Boolean varNoExportEnv;
+
+ /* The target names specified on the command line.
+ * Used to resolve .if make(...) statements. */
+ StringList *create;
+
+} CmdOpts;
+
+extern CmdOpts opts;
+
#include "nonints.h"
void Make_TimeStamp(GNode *, GNode *);
Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.400 src/usr.bin/make/parse.c:1.401
--- src/usr.bin/make/parse.c:1.400 Sun Oct 25 13:06:12 2020
+++ src/usr.bin/make/parse.c Mon Oct 26 21:34:10 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.400 2020/10/25 13:06:12 rillig Exp $ */
+/* $NetBSD: parse.c,v 1.401 2020/10/26 21:34:10 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -131,7 +131,7 @@
#include "pathnames.h"
/* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: parse.c,v 1.400 2020/10/25 13:06:12 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.401 2020/10/26 21:34:10 rillig Exp $");
/* types and constants */
@@ -668,9 +668,9 @@ ParseVErrorInternal(FILE *f, const char
if (type == PARSE_INFO)
return;
- if (type == PARSE_FATAL || parseWarnFatal)
+ if (type == PARSE_FATAL || opts.parseWarnFatal)
fatals++;
- if (parseWarnFatal && !fatal_warning_error_printed) {
+ if (opts.parseWarnFatal && !fatal_warning_error_printed) {
Error("parsing warnings being treated as errors");
fatal_warning_error_printed = TRUE;
}
@@ -687,9 +687,10 @@ ParseErrorInternal(const char *cfname, s
ParseVErrorInternal(stderr, cfname, clineno, type, fmt, ap);
va_end(ap);
- if (debug_file != stderr && debug_file != stdout) {
+ if (opts.debug_file != stderr && opts.debug_file != stdout) {
va_start(ap, fmt);
- ParseVErrorInternal(debug_file, cfname, clineno, type, fmt, ap);
+ ParseVErrorInternal(opts.debug_file, cfname, clineno, type,
+ fmt, ap);
va_end(ap);
}
}
@@ -718,9 +719,10 @@ Parse_Error(ParseErrorLevel type, const
ParseVErrorInternal(stderr, fname, lineno, type, fmt, ap);
va_end(ap);
- if (debug_file != stderr && debug_file != stdout) {
+ if (opts.debug_file != stderr && opts.debug_file != stdout) {
va_start(ap, fmt);
- ParseVErrorInternal(debug_file, fname, lineno, type, fmt, ap);
+ ParseVErrorInternal(opts.debug_file, fname, lineno, type,
+ fmt, ap);
va_end(ap);
}
}
@@ -910,7 +912,7 @@ ParseDoSrcMain(const char *src)
* invoked if the user didn't specify a target on the command
* line. This is to allow #ifmake's to succeed, or something...
*/
- Lst_Append(create, bmake_strdup(src));
+ Lst_Append(opts.create, bmake_strdup(src));
/*
* Add the name to the .TARGETS variable as well, so the user can
* employ that, if desired.
@@ -1125,7 +1127,7 @@ ParseDoDependencyTargetSpecial(ParseSpec
Lst_Append(*inout_paths, dirSearchPath);
break;
case Main:
- if (!Lst_IsEmpty(create)) {
+ if (!Lst_IsEmpty(opts.create)) {
*inout_specType = Not;
}
break;
@@ -1152,10 +1154,10 @@ ParseDoDependencyTargetSpecial(ParseSpec
deleteOnError = TRUE;
break;
case NotParallel:
- maxJobs = 1;
+ opts.maxJobs = 1;
break;
case SingleShell:
- compatMake = TRUE;
+ opts.compatMake = TRUE;
break;
case Order:
predecessor = NULL;
@@ -1361,10 +1363,10 @@ ParseDoDependencySourcesEmpty(ParseSpeci
allPrecious = TRUE;
break;
case Ignore:
- ignoreErrors = TRUE;
+ opts.ignoreErrors = TRUE;
break;
case Silent:
- beSilent = TRUE;
+ opts.beSilent = TRUE;
break;
case ExPath:
ClearPaths(paths);
Index: src/usr.bin/make/targ.c
diff -u src/usr.bin/make/targ.c:1.124 src/usr.bin/make/targ.c:1.125
--- src/usr.bin/make/targ.c:1.124 Sun Oct 25 21:51:49 2020
+++ src/usr.bin/make/targ.c Mon Oct 26 21:34:10 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: targ.c,v 1.124 2020/10/25 21:51:49 rillig Exp $ */
+/* $NetBSD: targ.c,v 1.125 2020/10/26 21:34:10 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -121,7 +121,7 @@
#include "dir.h"
/* "@(#)targ.c 8.2 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: targ.c,v 1.124 2020/10/25 21:51:49 rillig Exp $");
+MAKE_RCSID("$NetBSD: targ.c,v 1.125 2020/10/26 21:34:10 rillig Exp $");
static GNodeList *allTargets; /* the list of all targets found so far */
#ifdef CLEANUP
@@ -305,14 +305,14 @@ Targ_FindList(StringList *names)
Boolean
Targ_Ignore(GNode *gn)
{
- return ignoreErrors || gn->type & OP_IGNORE;
+ return opts.ignoreErrors || gn->type & OP_IGNORE;
}
/* Return true if be silent when creating gn. */
Boolean
Targ_Silent(GNode *gn)
{
- return beSilent || gn->type & OP_SILENT;
+ return opts.beSilent || gn->type & OP_SILENT;
}
/* See if the given target is precious. */
@@ -449,7 +449,7 @@ void
Targ_PrintNode(GNode *gn, int pass)
{
debug_printf("# %s%s", gn->name, gn->cohort_num);
- GNode_FprintDetails(debug_file, ", ", gn, "\n");
+ GNode_FprintDetails(opts.debug_file, ", ", gn, "\n");
if (gn->flags == 0)
return;
Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.589 src/usr.bin/make/var.c:1.590
--- src/usr.bin/make/var.c:1.589 Sun Oct 25 21:51:49 2020
+++ src/usr.bin/make/var.c Mon Oct 26 21:34:10 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.589 2020/10/25 21:51:49 rillig Exp $ */
+/* $NetBSD: var.c,v 1.590 2020/10/26 21:34:10 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -121,7 +121,7 @@
#include "metachar.h"
/* "@(#)var.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.589 2020/10/25 21:51:49 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.590 2020/10/26 21:34:10 rillig Exp $");
#define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
#define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -380,7 +380,7 @@ VarFind(const char *name, GNode *ctxt, V
if (var == NULL && (flags & FIND_CMD) && ctxt != VAR_CMD)
var = GNode_FindVar(VAR_CMD, name, nameHash);
- if (!checkEnvFirst && var == NULL && (flags & FIND_GLOBAL) &&
+ if (!opts.checkEnvFirst && var == NULL && (flags & FIND_GLOBAL) &&
ctxt != VAR_GLOBAL)
{
var = GNode_FindVar(VAR_GLOBAL, name, nameHash);
@@ -398,7 +398,7 @@ VarFind(const char *name, GNode *ctxt, V
return VarNew(varname, varname, env, VAR_FROM_ENV);
}
- if (checkEnvFirst && (flags & FIND_GLOBAL) && ctxt != VAR_GLOBAL) {
+ if (opts.checkEnvFirst && (flags & FIND_GLOBAL) && ctxt != VAR_GLOBAL) {
var = GNode_FindVar(VAR_GLOBAL, name, nameHash);
if (var == NULL && ctxt != VAR_INTERNAL)
var = GNode_FindVar(VAR_INTERNAL, name, nameHash);
@@ -844,7 +844,7 @@ Var_Set_with_flags(const char *name, con
* that the command-line settings continue to override
* Makefile settings.
*/
- if (!varNoExportEnv)
+ if (!opts.varNoExportEnv)
setenv(name, val ? val : "", 1);
Var_Append(MAKEOVERRIDES, name, VAR_GLOBAL);