summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authorjmallett <jmallett@FreeBSD.org>2002-09-17 22:31:26 +0000
committerjmallett <jmallett@FreeBSD.org>2002-09-17 22:31:26 +0000
commit7fd8427cf78ed3d6ed80aafb4dd8b2ae5c85715b (patch)
treee9bbc739d9ad215c67355ae9b0a1a298016a17b9 /usr.bin
parent086f36bd966184831309cca6a2187aa38f6b0393 (diff)
downloadFreeBSD-src-7fd8427cf78ed3d6ed80aafb4dd8b2ae5c85715b.zip
FreeBSD-src-7fd8427cf78ed3d6ed80aafb4dd8b2ae5c85715b.tar.gz
Move common use of if (DEBUG(FOO)) printf... to DEBUGF(FOO, ...), using
variable length arguments to a macro. Bump version as this makes DEBUG statements *always* go to stderr rather than sometimes stdout. There are a few stragglers, which I will take care of as soon as I can. Mostly these relate to the need-for-death-of some of the remote job code. Nearby stylistic nits and XXX added/fixed where appropriate.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/make/Makefile2
-rw-r--r--usr.bin/make/arch.c35
-rw-r--r--usr.bin/make/compat.c16
-rw-r--r--usr.bin/make/cond.c12
-rw-r--r--usr.bin/make/dir.c104
-rw-r--r--usr.bin/make/for.c12
-rw-r--r--usr.bin/make/job.c200
-rw-r--r--usr.bin/make/make.c74
-rw-r--r--usr.bin/make/make.h7
-rw-r--r--usr.bin/make/parse.c3
-rw-r--r--usr.bin/make/suff.c108
-rw-r--r--usr.bin/make/targ.c4
-rw-r--r--usr.bin/make/var.c26
13 files changed, 172 insertions, 431 deletions
diff --git a/usr.bin/make/Makefile b/usr.bin/make/Makefile
index 6208a28..88027b21 100644
--- a/usr.bin/make/Makefile
+++ b/usr.bin/make/Makefile
@@ -15,7 +15,7 @@ SRCS+= lstAppend.c lstAtEnd.c lstAtFront.c lstClose.c lstConcat.c \
NOSHARED?= YES
-CFLAGS+=-DMAKE_VERSION=\"5200208240\"
+CFLAGS+=-DMAKE_VERSION=\"5200209170\"
.if defined(_UPGRADING)
CFLAGS+=-D__FBSDID=__RCSID
.endif
diff --git a/usr.bin/make/arch.c b/usr.bin/make/arch.c
index 42d4e22..9eb9bb7 100644
--- a/usr.bin/make/arch.c
+++ b/usr.bin/make/arch.c
@@ -621,8 +621,11 @@ ArchStatMember (archive, member, hash)
goto badarch;
memName[elen] = '\0';
fseek (arch, -elen, SEEK_CUR);
+ /* XXX Multiple levels may be asked for, make this conditional
+ * on one, and use DEBUGF.
+ */
if (DEBUG(ARCH) || DEBUG(MAKE)) {
- printf("ArchStat: Extended format entry for %s\n", memName);
+ fprintf(stderr, "ArchStat: Extended format entry for %s\n", memName);
}
}
#endif
@@ -696,9 +699,7 @@ ArchSVR4Entry(ar, name, size, arch)
strncmp(name, ARLONGNAMES2, sizeof(ARLONGNAMES2) - 1) == 0) {
if (ar->fnametab != NULL) {
- if (DEBUG(ARCH)) {
- printf("Attempted to redefine an SVR4 name table\n");
- }
+ DEBUGF(ARCH, "Attempted to redefine an SVR4 name table\n");
return -1;
}
@@ -710,9 +711,7 @@ ArchSVR4Entry(ar, name, size, arch)
ar->fnamesize = size;
if (fread(ar->fnametab, size, 1, arch) != 1) {
- if (DEBUG(ARCH)) {
- printf("Reading an SVR4 name table failed\n");
- }
+ DEBUGF(ARCH, "Reading an SVR4 name table failed\n");
return -1;
}
eptr = ar->fnametab + size;
@@ -729,9 +728,7 @@ ArchSVR4Entry(ar, name, size, arch)
default:
break;
}
- if (DEBUG(ARCH)) {
- printf("Found svr4 archive name table with %zu entries\n", entry);
- }
+ DEBUGF(ARCH, "Found svr4 archive name table with %zu entries\n", entry);
return 0;
}
@@ -740,22 +737,16 @@ ArchSVR4Entry(ar, name, size, arch)
entry = (size_t) strtol(&name[1], &eptr, 0);
if ((*eptr != ' ' && *eptr != '\0') || eptr == &name[1]) {
- if (DEBUG(ARCH)) {
- printf("Could not parse SVR4 name %s\n", name);
- }
+ DEBUGF(ARCH, "Could not parse SVR4 name %s\n", name);
return 2;
}
if (entry >= ar->fnamesize) {
- if (DEBUG(ARCH)) {
- printf("SVR4 entry offset %s is greater than %zu\n",
- name, ar->fnamesize);
- }
+ DEBUGF(ARCH, "SVR4 entry offset %s is greater than %zu\n",
+ name, ar->fnamesize);
return 2;
}
- if (DEBUG(ARCH)) {
- printf("Replaced %s with %s\n", name, &ar->fnametab[entry]);
- }
+ DEBUGF(ARCH, "Replaced %s with %s\n", name, &ar->fnametab[entry]);
(void) strncpy(name, &ar->fnametab[entry], MAXPATHLEN);
name[MAXPATHLEN] = '\0';
@@ -876,6 +867,9 @@ ArchFindMember (archive, member, arhPtr, mode)
return NULL;
}
ename[elen] = '\0';
+ /*
+ * XXX choose one.
+ */
if (DEBUG(ARCH) || DEBUG(MAKE)) {
printf("ArchFind: Extended format entry for %s\n", ename);
}
@@ -1181,6 +1175,7 @@ Arch_LibOODate (gn)
if (arhPtr != NULL) {
modTimeTOC = (int) strtol(arhPtr->ar_date, NULL, 10);
+ /* XXX choose one. */
if (DEBUG(ARCH) || DEBUG(MAKE)) {
printf("%s modified %s...", RANLIBMAG, Targ_FmtTime(modTimeTOC));
}
diff --git a/usr.bin/make/compat.c b/usr.bin/make/compat.c
index cf2e309..1ff3e53 100644
--- a/usr.bin/make/compat.c
+++ b/usr.bin/make/compat.c
@@ -457,17 +457,13 @@ CompatMake (gnp, pgnp)
* we were modified last. The criteria for datedness are defined by the
* Make_OODate function.
*/
- if (DEBUG(MAKE)) {
- printf("Examining %s...", gn->name);
- }
+ DEBUGF(MAKE, "Examining %s...", gn->name);
if (! Make_OODate(gn)) {
gn->made = UPTODATE;
- if (DEBUG(MAKE)) {
- printf("up-to-date.\n");
- }
+ DEBUGF(MAKE, "up-to-date.\n");
return (0);
- } else if (DEBUG(MAKE)) {
- printf("out-of-date.\n");
+ } else {
+ DEBUGF(MAKE, "out-of-date.\n");
}
/*
@@ -574,9 +570,7 @@ CompatMake (gnp, pgnp)
}
if (gn->cmtime > gn->mtime)
gn->mtime = gn->cmtime;
- if (DEBUG(MAKE)) {
- printf("update time: %s\n", Targ_FmtTime(gn->mtime));
- }
+ DEBUGF(MAKE, "update time: %s\n", Targ_FmtTime(gn->mtime));
#endif
if (!(gn->type & OP_EXEC)) {
pgn->childMade = TRUE;
diff --git a/usr.bin/make/cond.c b/usr.bin/make/cond.c
index 64e7f1a..cfdde15 100644
--- a/usr.bin/make/cond.c
+++ b/usr.bin/make/cond.c
@@ -657,10 +657,8 @@ do_string_compare:
string = (char *)Buf_GetAll(buf, (int *)0);
Buf_Destroy(buf, FALSE);
- if (DEBUG(COND)) {
- printf("lhs = \"%s\", rhs = \"%s\", op = %.2s\n",
- lhs, string, op);
- }
+ DEBUGF(COND, "lhs = \"%s\", rhs = \"%s\", op = %.2s\n",
+ lhs, string, op);
/*
* Null-terminate rhs and perform the comparison.
* t is set to the result.
@@ -720,10 +718,8 @@ do_string_compare:
}
}
- if (DEBUG(COND)) {
- printf("left = %f, right = %f, op = %.2s\n", left,
- right, op);
- }
+ DEBUGF(COND, "left = %f, right = %f, op = %.2s\n", left,
+ right, op);
switch(op[0]) {
case '!':
if (op[1] != '=') {
diff --git a/usr.bin/make/dir.c b/usr.bin/make/dir.c
index 9bb6d6f..e8eb297 100644
--- a/usr.bin/make/dir.c
+++ b/usr.bin/make/dir.c
@@ -541,7 +541,7 @@ DirPrintWord(word, dummy)
void * word;
void * dummy;
{
- printf("%s ", (char *) word);
+ DEBUGF(DIR, "%s ", (char *) word);
return(dummy ? 0 : 0);
}
@@ -569,9 +569,7 @@ Dir_Expand (word, path, expansions)
{
char *cp;
- if (DEBUG(DIR)) {
- printf("expanding \"%s\"...", word);
- }
+ DEBUGF(DIR, "expanding \"%s\"...", word);
cp = strchr(word, '{');
if (cp) {
@@ -655,7 +653,7 @@ Dir_Expand (word, path, expansions)
}
if (DEBUG(DIR)) {
Lst_ForEach(expansions, DirPrintWord, (void *) 0);
- fputc('\n', stdout);
+ DEBUGF(DIR, "\n");
}
}
@@ -705,9 +703,7 @@ Dir_FindFile (name, path)
cp = name;
}
- if (DEBUG(DIR)) {
- printf("Searching for %s...", name);
- }
+ DEBUGF(DIR, "Searching for %s...", name);
/*
* No matter what, we always look for the file in the current directory
* before anywhere else and we *do not* add the ./ to it if it exists.
@@ -716,18 +712,14 @@ Dir_FindFile (name, path)
*/
if ((!hasSlash || (cp - name == 2 && *name == '.')) &&
(Hash_FindEntry (&dot->files, cp) != (Hash_Entry *)NULL)) {
- if (DEBUG(DIR)) {
- printf("in '.'\n");
- }
+ DEBUGF(DIR, "in '.'\n");
hits += 1;
dot->hits += 1;
return (estrdup (name));
}
if (Lst_Open (path) == FAILURE) {
- if (DEBUG(DIR)) {
- printf("couldn't open path, file not found\n");
- }
+ DEBUGF(DIR, "couldn't open path, file not found\n");
misses += 1;
return ((char *) NULL);
}
@@ -742,13 +734,9 @@ Dir_FindFile (name, path)
*/
while ((ln = Lst_Next (path)) != NULL) {
p = (Path *) Lst_Datum (ln);
- if (DEBUG(DIR)) {
- printf("%s...", p->name);
- }
+ DEBUGF(DIR, "%s...", p->name);
if (Hash_FindEntry (&p->files, cp) != (Hash_Entry *)NULL) {
- if (DEBUG(DIR)) {
- printf("here...");
- }
+ DEBUGF(DIR, "here...");
if (hasSlash) {
/*
* If the name had a slash, its initial components and p's
@@ -764,16 +752,12 @@ Dir_FindFile (name, path)
p1 -= 1; p2 -= 1;
}
if (p2 >= name || (p1 >= p->name && *p1 != '/')) {
- if (DEBUG(DIR)) {
- printf("component mismatch -- continuing...");
- }
+ DEBUGF(DIR, "component mismatch -- continuing...");
continue;
}
}
file = str_concat (p->name, cp, STR_ADDSLASH);
- if (DEBUG(DIR)) {
- printf("returning %s\n", file);
- }
+ DEBUGF(DIR, "returning %s\n", file);
Lst_Close (path);
p->hits += 1;
hits += 1;
@@ -788,9 +772,7 @@ Dir_FindFile (name, path)
continue;
}
if (*p1 == '\0' && p2 == cp - 1) {
- if (DEBUG(DIR)) {
- printf("must be here but isn't -- returing NULL\n");
- }
+ DEBUGF(DIR, "must be here but isn't -- returing NULL\n");
Lst_Close (path);
return ((char *) NULL);
}
@@ -810,9 +792,7 @@ Dir_FindFile (name, path)
* end). This phase is only performed if the file is *not* absolute.
*/
if (!hasSlash) {
- if (DEBUG(DIR)) {
- printf("failed.\n");
- }
+ DEBUGF(DIR, "failed.\n");
misses += 1;
return ((char *) NULL);
}
@@ -820,9 +800,7 @@ Dir_FindFile (name, path)
if (*name != '/') {
Boolean checkedDot = FALSE;
- if (DEBUG(DIR)) {
- printf("failed. Trying subdirectories...");
- }
+ DEBUGF(DIR, "failed. Trying subdirectories...");
(void) Lst_Open (path);
while ((ln = Lst_Next (path)) != NULL) {
p = (Path *) Lst_Datum (ln);
@@ -835,15 +813,10 @@ Dir_FindFile (name, path)
file = estrdup(name);
checkedDot = TRUE;
}
- if (DEBUG(DIR)) {
- printf("checking %s...", file);
- }
-
+ DEBUGF(DIR, "checking %s...", file);
if (stat (file, &stb) == 0) {
- if (DEBUG(DIR)) {
- printf("got it.\n");
- }
+ DEBUGF(DIR, "got it.\n");
Lst_Close (path);
@@ -866,10 +839,7 @@ Dir_FindFile (name, path)
* Save the modification time so if it's needed, we don't have
* to fetch it again.
*/
- if (DEBUG(DIR)) {
- printf("Caching %s for %s\n", Targ_FmtTime(stb.st_mtime),
- file);
- }
+ DEBUGF(DIR, "Caching %s for %s\n", Targ_FmtTime(stb.st_mtime), file);
entry = Hash_CreateEntry(&mtimes, (char *) file,
(Boolean *)NULL);
Hash_SetValue(entry, (long)stb.st_mtime);
@@ -880,9 +850,7 @@ Dir_FindFile (name, path)
}
}
- if (DEBUG(DIR)) {
- printf("failed. ");
- }
+ DEBUGF(DIR, "failed. ");
Lst_Close (path);
if (checkedDot) {
@@ -890,9 +858,7 @@ Dir_FindFile (name, path)
* Already checked by the given name, since . was in the path,
* so no point in proceeding...
*/
- if (DEBUG(DIR)) {
- printf("Checked . already, returning NULL\n");
- }
+ DEBUGF(DIR, "Checked . already, returning NULL\n");
return(NULL);
}
}
@@ -933,29 +899,20 @@ Dir_FindFile (name, path)
return ((char *) NULL);
}
#else /* !notdef */
- if (DEBUG(DIR)) {
- printf("Looking for \"%s\"...", name);
- }
+ DEBUGF(DIR, "Looking for \"%s\"...", name);
bigmisses += 1;
entry = Hash_FindEntry(&mtimes, name);
if (entry != (Hash_Entry *)NULL) {
- if (DEBUG(DIR)) {
- printf("got it (in mtime cache)\n");
- }
- return(estrdup(name));
+ DEBUGF(DIR, "got it (in mtime cache)\n");
+ return (estrdup(name));
} else if (stat (name, &stb) == 0) {
entry = Hash_CreateEntry(&mtimes, name, (Boolean *)NULL);
- if (DEBUG(DIR)) {
- printf("Caching %s for %s\n", Targ_FmtTime(stb.st_mtime),
- name);
- }
+ DEBUGF(DIR, "Caching %s for %s\n", Targ_FmtTime(stb.st_mtime), name);
Hash_SetValue(entry, (long)stb.st_mtime);
return (estrdup (name));
} else {
- if (DEBUG(DIR)) {
- printf("failed. Returning NULL\n");
- }
+ DEBUGF(DIR, "failed. Returning NULL\n");
return ((char *)NULL);
}
#endif /* notdef */
@@ -1004,10 +961,8 @@ Dir_MTime (gn)
* see if the file was actually updated, so we need to actually go
* to the filesystem.
*/
- if (DEBUG(DIR)) {
- printf("Using cached time %s for %s\n",
- Targ_FmtTime((time_t)(long)Hash_GetValue(entry)), fullName);
- }
+ DEBUGF(DIR, "Using cached time %s for %s\n",
+ Targ_FmtTime((time_t)(long)Hash_GetValue(entry)), fullName);
stb.st_mtime = (time_t)(long)Hash_GetValue(entry);
Hash_DeleteEntry(&mtimes, entry);
} else if (stat (fullName, &stb) < 0) {
@@ -1061,10 +1016,7 @@ Dir_AddDir (path, name)
(void)Lst_AtEnd (path, (void *)p);
}
} else {
- if (DEBUG(DIR)) {
- printf("Caching %s...", name);
- fflush(stdout);
- }
+ DEBUGF(DIR, "Caching %s...", name);
if ((d = opendir (name)) != (DIR *) NULL) {
p = (Path *) emalloc (sizeof (Path));
@@ -1101,9 +1053,7 @@ Dir_AddDir (path, name)
(void)Lst_AtEnd (openDirectories, (void *)p);
(void)Lst_AtEnd (path, (void *)p);
}
- if (DEBUG(DIR)) {
- printf("done\n");
- }
+ DEBUGF(DIR, "done\n");
}
}
diff --git a/usr.bin/make/for.c b/usr.bin/make/for.c
index de34812..d5aa54d 100644
--- a/usr.bin/make/for.c
+++ b/usr.bin/make/for.c
@@ -192,8 +192,7 @@ For_Eval (line)
ptr++;
wrd = ptr--;
}
- if (DEBUG(FOR))
- (void) fprintf(stderr, "For: Iterator %s List %s\n", forVar, sub);
+ DEBUGF(FOR, "For: Iterator %s List %s\n", forVar, sub);
if (ptr - wrd > 0)
ADDWORD();
else
@@ -211,8 +210,7 @@ For_Eval (line)
if (strncmp(ptr, "endfor", 6) == 0 &&
(isspace((unsigned char) ptr[6]) || !ptr[6])) {
- if (DEBUG(FOR))
- (void) fprintf(stderr, "For: end for %d\n", forLevel);
+ DEBUGF(FOR, "For: end for %d\n", forLevel);
if (--forLevel < 0) {
Parse_Error (level, "for-less endfor");
return 0;
@@ -221,8 +219,7 @@ For_Eval (line)
else if (strncmp(ptr, "for", 3) == 0 &&
isspace((unsigned char) ptr[3])) {
forLevel++;
- if (DEBUG(FOR))
- (void) fprintf(stderr, "For: new loop %d\n", forLevel);
+ DEBUGF(FOR, "For: new loop %d\n", forLevel);
}
}
@@ -258,8 +255,7 @@ ForExec(namep, argp)
For *arg = (For *) argp;
int len;
Var_Set(arg->var, name, VAR_GLOBAL);
- if (DEBUG(FOR))
- (void) fprintf(stderr, "--- %s = %s\n", arg->var, name);
+ DEBUGF(FOR, "--- %s = %s\n", arg->var, name);
Parse_FromString(Var_Subst(arg->var, (char *) Buf_GetAll(arg->buf, &len),
VAR_GLOBAL, FALSE));
Var_Delete(arg->var, VAR_GLOBAL);
diff --git a/usr.bin/make/job.c b/usr.bin/make/job.c
index 8af4b8c..4eae54c 100644
--- a/usr.bin/make/job.c
+++ b/usr.bin/make/job.c
@@ -354,12 +354,7 @@ JobCondPassSig(jobp, signop)
* Assume that sending the signal to job->pid will signal any remote
* job as well.
*/
- if (DEBUG(JOB)) {
- (void) fprintf(stdout,
- "JobCondPassSig passing signal %d to child %d.\n",
- signo, job->pid);
- (void) fflush(stdout);
- }
+ DEBUGF(JOB, "JobCondPassSig passing signal %d to child %d.\n", signo, job->pid);
KILL(job->pid, signo);
#endif
return 0;
@@ -386,10 +381,7 @@ JobPassSig(signo)
sigset_t nmask, omask;
struct sigaction act;
- if (DEBUG(JOB)) {
- (void) fprintf(stdout, "JobPassSig(%d) called.\n", signo);
- (void) fflush(stdout);
- }
+ DEBUGF(JOB, "JobPassSig(%d) called.\n", signo);
Lst_ForEach(jobs, JobCondPassSig, (void *) &signo);
/*
@@ -424,12 +416,7 @@ JobPassSig(signo)
act.sa_flags = 0;
sigaction(signo, &act, NULL);
- if (DEBUG(JOB)) {
- (void) fprintf(stdout,
- "JobPassSig passing signal to self, mask = %x.\n",
- ~0 & ~(1 << (signo-1)));
- (void) fflush(stdout);
- }
+ DEBUGF(JOB, "JobPassSig passing signal to self, mask = %x.\n", ~0 & ~(1 << (signo-1)));
(void) signal(signo, SIG_DFL);
(void) KILL(getpid(), signo);
@@ -547,10 +534,8 @@ JobPrintCommand(cmdp, jobp)
return 0;
}
-#define DBPRINTF(fmt, arg) if (DEBUG(JOB)) { \
- (void) fprintf(stdout, fmt, arg); \
- (void) fflush(stdout); \
- } \
+#define DBPRINTF(fmt, arg) \
+ DEBUGF(JOB, fmt, arg); \
(void) fprintf(job->cmdFILE, fmt, arg); \
(void) fflush(job->cmdFILE);
@@ -824,10 +809,7 @@ JobFinish(job, status)
}
if (WIFEXITED(*status)) {
- if (DEBUG(JOB)) {
- (void) fprintf(stdout, "Process %d exited.\n", job->pid);
- (void) fflush(stdout);
- }
+ DEBUGF(JOB, "Process %d exited.\n", job->pid);
if (WEXITSTATUS(*status) != 0) {
if (usePipes && job->node != lastNode) {
MESSAGE(out, job->node);
@@ -848,10 +830,7 @@ JobFinish(job, status)
(void) fprintf(out, "*** Completed successfully\n");
}
} else if (WIFSTOPPED(*status)) {
- if (DEBUG(JOB)) {
- (void) fprintf(stdout, "Process %d stopped.\n", job->pid);
- (void) fflush(stdout);
- }
+ DEBUGF(JOB, "Process %d stopped.\n", job->pid);
if (usePipes && job->node != lastNode) {
MESSAGE(out, job->node);
lastNode = job->node;
@@ -882,12 +861,7 @@ JobFinish(job, status)
(void) fprintf(out, "*** Continued\n");
}
if (!(job->flags & JOB_CONTINUING)) {
- if (DEBUG(JOB)) {
- (void) fprintf(stdout,
- "Warning: process %d was not continuing.\n",
- job->pid);
- (void) fflush(stdout);
- }
+ DEBUGF(JOB, "Warning: process %d was not continuing.\n", job->pid);
#ifdef notdef
/*
* We don't really want to restart a job from scratch just
@@ -902,20 +876,12 @@ JobFinish(job, status)
Lst_AtEnd(jobs, (void *)job);
nJobs += 1;
if (!(job->flags & JOB_REMOTE)) {
- if (DEBUG(JOB)) {
- (void) fprintf(stdout,
- "Process %d is continuing locally.\n",
- job->pid);
- (void) fflush(stdout);
- }
+ DEBUGF(JOB, "Process %d is continuing locally.\n", job->pid);
nLocal += 1;
}
if (nJobs == maxJobs) {
jobFull = TRUE;
- if (DEBUG(JOB)) {
- (void) fprintf(stdout, "Job queue is full.\n");
- (void) fflush(stdout);
- }
+ DEBUGF(JOB, "Job queue is full.\n");
}
(void) fflush(out);
return;
@@ -1197,14 +1163,13 @@ JobExec(job, argv)
if (DEBUG(JOB)) {
int i;
- (void) fprintf(stdout, "Running %s %sly\n", job->node->name,
- job->flags&JOB_REMOTE?"remote":"local");
- (void) fprintf(stdout, "\tCommand: ");
+ DEBUGF(JOB, "Running %s %sly\n", job->node->name,
+ job->flags&JOB_REMOTE?"remote":"local");
+ DEBUGF(JOB, "\tCommand: ");
for (i = 0; argv[i] != NULL; i++) {
- (void) fprintf(stdout, "%s ", argv[i]);
+ DEBUGF(JOB, "%s ", argv[i]);
}
- (void) fprintf(stdout, "\n");
- (void) fflush(stdout);
+ DEBUGF(JOB, "\n");
}
/*
@@ -1474,10 +1439,7 @@ JobRestart(job)
}
(void)Lst_AtFront(stoppedJobs, (void *)job);
jobFull = TRUE;
- if (DEBUG(JOB)) {
- (void) fprintf(stdout, "Job queue is full.\n");
- (void) fflush(stdout);
- }
+ DEBUGF(JOB, "Job queue is full.\n");
return;
}
#ifdef REMOTE
@@ -1497,10 +1459,7 @@ JobRestart(job)
nJobs += 1;
if (nJobs == maxJobs) {
jobFull = TRUE;
- if (DEBUG(JOB)) {
- (void) fprintf(stdout, "Job queue is full.\n");
- (void) fflush(stdout);
- }
+ DEBUGF(JOB, "Job queue is full.\n");
}
} else if (job->flags & JOB_RESTART) {
/*
@@ -1515,10 +1474,7 @@ JobRestart(job)
JobMakeArgv(job, argv);
- if (DEBUG(JOB)) {
- (void) fprintf(stdout, "Restarting %s...", job->node->name);
- (void) fflush(stdout);
- }
+ DEBUGF(JOB, "Restarting %s...", job->node->name);
#ifdef REMOTE
if ((job->node->type&OP_NOEXPORT) ||
(nLocal < maxLocal && runLocalFirst)
@@ -1534,25 +1490,16 @@ JobRestart(job)
* Can't be exported and not allowed to run locally -- put it
* back on the hold queue and mark the table full
*/
- if (DEBUG(JOB)) {
- (void) fprintf(stdout, "holding\n");
- (void) fflush(stdout);
- }
+ DEBUGF(JOB, "holding\n");
(void)Lst_AtFront(stoppedJobs, (void *)job);
jobFull = TRUE;
- if (DEBUG(JOB)) {
- (void) fprintf(stdout, "Job queue is full.\n");
- (void) fflush(stdout);
- }
+ DEBUGF(JOB, "Job queue is full.\n");
return;
} else {
/*
* Job may be run locally.
*/
- if (DEBUG(JOB)) {
- (void) fprintf(stdout, "running locally\n");
- (void) fflush(stdout);
- }
+ DEBUGF(JOB, "running locally\n");
job->flags &= ~JOB_REMOTE;
}
}
@@ -1561,10 +1508,7 @@ JobRestart(job)
/*
* Can be exported. Hooray!
*/
- if (DEBUG(JOB)) {
- (void) fprintf(stdout, "exporting\n");
- (void) fflush(stdout);
- }
+ DEBUGF(JOB, "exporting\n");
job->flags |= JOB_REMOTE;
}
#endif
@@ -1574,10 +1518,7 @@ JobRestart(job)
* The job has stopped and needs to be restarted. Why it stopped,
* we don't know...
*/
- if (DEBUG(JOB)) {
- (void) fprintf(stdout, "Resuming %s...", job->node->name);
- (void) fflush(stdout);
- }
+ DEBUGF(JOB, "Resuming %s...", job->node->name);
if (((job->flags & JOB_REMOTE) ||
(nLocal < maxLocal) ||
#ifdef REMOTE
@@ -1617,10 +1558,7 @@ JobRestart(job)
JobFinish(job, &status);
job->flags &= ~(JOB_RESUME|JOB_CONTINUING);
- if (DEBUG(JOB)) {
- (void) fprintf(stdout, "done\n");
- (void) fflush(stdout);
- }
+ DEBUGF(JOB, "done\n");
} else {
Error("couldn't resume %s: %s",
job->node->name, strerror(errno));
@@ -1633,16 +1571,10 @@ JobRestart(job)
* Job cannot be restarted. Mark the table as full and
* place the job back on the list of stopped jobs.
*/
- if (DEBUG(JOB)) {
- (void) fprintf(stdout, "table full\n");
- (void) fflush(stdout);
- }
+ DEBUGF(JOB, "table full\n");
(void) Lst_AtFront(stoppedJobs, (void *)job);
jobFull = TRUE;
- if (DEBUG(JOB)) {
- (void) fprintf(stdout, "Job queue is full.\n");
- (void) fflush(stdout);
- }
+ DEBUGF(JOB, "Job queue is full.\n");
}
}
}
@@ -1935,10 +1867,7 @@ JobStart(gn, flags, previous)
*/
jobFull = TRUE;
- if (DEBUG(JOB)) {
- (void) fprintf(stdout, "Can only run job locally.\n");
- (void) fflush(stdout);
- }
+ DEBUGF(JOB, "Can only run job locally.\n");
job->flags |= JOB_RESTART;
(void) Lst_AtEnd(stoppedJobs, (void *)job);
} else {
@@ -1948,10 +1877,7 @@ JobStart(gn, flags, previous)
* at least say the table is full.
*/
jobFull = TRUE;
- if (DEBUG(JOB)) {
- (void) fprintf(stdout, "Local job queue is full.\n");
- (void) fflush(stdout);
- }
+ DEBUGF(JOB, "Local job queue is full.\n");
}
JobExec(job, argv);
}
@@ -2059,9 +1985,7 @@ end_loop:
nRead = read(job->inPipe, &job->outBuf[job->curPos],
JOB_BUFSIZE - job->curPos);
if (nRead < 0) {
- if (DEBUG(JOB)) {
- warn("JobDoOutput(piperead)");
- }
+ DEBUGF(JOB, "JobDoOutput(piperead)");
nr = 0;
} else {
nr = nRead;
@@ -2246,11 +2170,7 @@ Job_CatchChildren(block)
while ((pid = waitpid((pid_t) -1, &status,
(block?0:WNOHANG)|WUNTRACED)) > 0)
{
- if (DEBUG(JOB)) {
- (void) fprintf(stdout, "Process %d exited or stopped.\n", pid);
- (void) fflush(stdout);
- }
-
+ DEBUGF(JOB, "Process %d exited or stopped.\n", pid);
jnode = Lst_Find(jobs, (void *)&pid, JobCmpPid);
@@ -2271,18 +2191,11 @@ Job_CatchChildren(block)
job = (Job *) Lst_Datum(jnode);
(void) Lst_Remove(jobs, jnode);
nJobs -= 1;
- if (jobFull && DEBUG(JOB)) {
- (void) fprintf(stdout, "Job queue is no longer full.\n");
- (void) fflush(stdout);
- }
+ DEBUGF(JOB, "Job queue is no longer full.\n");
jobFull = FALSE;
#ifdef REMOTE
if (!(job->flags & JOB_REMOTE)) {
- if (DEBUG(JOB)) {
- (void) fprintf(stdout,
- "Job queue has one fewer local process.\n");
- (void) fflush(stdout);
- }
+ DEBUGF(JOB, "Job queue has one fewer local process.\n");
nLocal -= 1;
}
#else
@@ -2825,12 +2738,8 @@ JobInterrupt(runINTERRUPT, signo)
}
#else
if (job->pid) {
- if (DEBUG(JOB)) {
- (void) fprintf(stdout,
- "JobInterrupt passing signal to child %d.\n",
- job->pid);
- (void) fflush(stdout);
- }
+ DEBUGF(JOB, "JobInterrupt passing signal to child %d.\n",
+ job->pid);
KILL(job->pid, signo);
}
#endif /* RMT_WANTS_SIGNALS */
@@ -2842,12 +2751,8 @@ JobInterrupt(runINTERRUPT, signo)
job = (Job *) Lst_Datum(ln);
if (job->flags & JOB_RESTART) {
- if (DEBUG(JOB)) {
- (void) fprintf(stdout, "%s%s",
- "JobInterrupt skipping job on stopped queue",
- "-- it was waiting to be restarted.\n");
- (void) fflush(stdout);
- }
+ DEBUGF(JOB, "JobInterrupt skipping job on stopped queue"
+ "-- it was waiting to be restarted.\n");
continue;
}
if (!Targ_Precious(job->node)) {
@@ -2861,12 +2766,7 @@ JobInterrupt(runINTERRUPT, signo)
/*
* Resume the thing so it will take the signal.
*/
- if (DEBUG(JOB)) {
- (void) fprintf(stdout,
- "JobInterrupt passing CONT to stopped child %d.\n",
- job->pid);
- (void) fflush(stdout);
- }
+ DEBUGF(JOB, "JobInterrupt passing CONT to stopped child %d.\n", job->pid);
KILL(job->pid, SIGCONT);
#ifdef RMT_WANTS_SIGNALS
if (job->flags & JOB_REMOTE) {
@@ -2884,12 +2784,8 @@ JobInterrupt(runINTERRUPT, signo)
JobFinish(job, &status);
}
} else if (job->pid) {
- if (DEBUG(JOB)) {
- (void) fprintf(stdout,
- "JobInterrupt passing interrupt to stopped child %d.\n",
- job->pid);
- (void) fflush(stdout);
- }
+ DEBUGF(JOB, "JobInterrupt passing interrupt to stopped child %d.\n",
+ job->pid);
KILL(job->pid, SIGINT);
}
#endif /* RMT_WANTS_SIGNALS */
@@ -3047,10 +2943,7 @@ JobFlagForMigration(hostID)
Job *job; /* job descriptor for dead child */
LstNode jnode; /* list element for finding job */
- if (DEBUG(JOB)) {
- (void) fprintf(stdout, "JobFlagForMigration(%d) called.\n", hostID);
- (void) fflush(stdout);
- }
+ DEBUGF(JOB, "JobFlagForMigration(%d) called.\n", hostID);
jnode = Lst_Find(jobs, (void *)hostID, JobCmpRmtID);
if (jnode == NULL) {
@@ -3064,12 +2957,7 @@ JobFlagForMigration(hostID)
}
job = (Job *) Lst_Datum(jnode);
- if (DEBUG(JOB)) {
- (void) fprintf(stdout,
- "JobFlagForMigration(%d) found job '%s'.\n", hostID,
- job->node->name);
- (void) fflush(stdout);
- }
+ DEBUGF(JOB, "JobFlagForMigration(%d) found job '%s'.\n", hostID, job->node->name);
KILL(job->pid, SIGSTOP);
@@ -3097,11 +2985,7 @@ static void
JobRestartJobs()
{
while (!jobFull && !Lst_IsEmpty(stoppedJobs)) {
- if (DEBUG(JOB)) {
- (void) fprintf(stdout,
- "Job queue is not full. Restarting a stopped job.\n");
- (void) fflush(stdout);
- }
+ DEBUGF(JOB, "Job queue is not full. Restarting a stopped job.\n");
JobRestart((Job *)Lst_DeQueue(stoppedJobs));
}
}
diff --git a/usr.bin/make/make.c b/usr.bin/make/make.c
index 2db6635..b8773f9 100644
--- a/usr.bin/make/make.c
+++ b/usr.bin/make/make.c
@@ -156,12 +156,10 @@ Make_OODate (gn)
*/
if ((gn->type & (OP_JOIN|OP_USE|OP_EXEC)) == 0) {
(void) Dir_MTime (gn);
- if (DEBUG(MAKE)) {
- if (gn->mtime != 0) {
- printf ("modified %s...", Targ_FmtTime(gn->mtime));
- } else {
- printf ("non-existent...");
- }
+ if (gn->mtime != 0) {
+ DEBUGF(MAKE, "modified %s...", Targ_FmtTime(gn->mtime));
+ } else {
+ DEBUGF(MAKE, "non-existent...");
}
}
@@ -184,14 +182,10 @@ Make_OODate (gn)
* If the node is a USE node it is *never* out of date
* no matter *what*.
*/
- if (DEBUG(MAKE)) {
- printf(".USE node...");
- }
+ DEBUGF(MAKE, ".USE node...");
oodate = FALSE;
} else if (gn->type & OP_LIB) {
- if (DEBUG(MAKE)) {
- printf("library...");
- }
+ DEBUGF(MAKE, "library...");
/*
* always out of date if no children and :: target
@@ -204,23 +198,19 @@ Make_OODate (gn)
* A target with the .JOIN attribute is only considered
* out-of-date if any of its children was out-of-date.
*/
- if (DEBUG(MAKE)) {
- printf(".JOIN node...");
- }
+ DEBUGF(MAKE, ".JOIN node...");
oodate = gn->childMade;
} else if (gn->type & (OP_FORCE|OP_EXEC|OP_PHONY)) {
/*
* A node which is the object of the force (!) operator or which has
* the .EXEC attribute is always considered out-of-date.
*/
- if (DEBUG(MAKE)) {
- if (gn->type & OP_FORCE) {
- printf("! operator...");
- } else if (gn->type & OP_PHONY) {
- printf(".PHONY node...");
- } else {
- printf(".EXEC node...");
- }
+ if (gn->type & OP_FORCE) {
+ DEBUGF(MAKE, "! operator...");
+ } else if (gn->type & OP_PHONY) {
+ DEBUGF(MAKE, ".PHONY node...");
+ } else {
+ DEBUGF(MAKE, ".EXEC node...");
}
oodate = TRUE;
} else if ((gn->mtime < gn->cmtime) ||
@@ -234,22 +224,18 @@ Make_OODate (gn)
* :: operator is out-of-date. Why? Because that's the way Make does
* it.
*/
- if (DEBUG(MAKE)) {
- if (gn->mtime < gn->cmtime) {
- printf("modified before source...");
- } else if (gn->mtime == 0) {
- printf("non-existent and no sources...");
- } else {
- printf(":: operator and no sources...");
- }
+ if (gn->mtime < gn->cmtime) {
+ DEBUGF(MAKE, "modified before source...");
+ } else if (gn->mtime == 0) {
+ DEBUGF(MAKE, "non-existent and no sources...");
+ } else {
+ DEBUGF(MAKE, ":: operator and no sources...");
}
oodate = TRUE;
} else {
#if 0
/* WHY? */
- if (DEBUG(MAKE)) {
- printf("source %smade...", gn->childMade ? "" : "not ");
- }
+ DEBUGF(MAKE, "source %smade...", gn->childMade ? "" : "not ");
oodate = gn->childMade;
#else
oodate = FALSE;
@@ -471,9 +457,7 @@ Make_Update (cgn)
if (noExecute || (cgn->type & OP_SAVE_CMDS) || Dir_MTime(cgn) == 0) {
cgn->mtime = now;
}
- if (DEBUG(MAKE)) {
- printf("update time: %s\n", Targ_FmtTime(cgn->mtime));
- }
+ DEBUGF(MAKE, "update time: %s\n", Targ_FmtTime(cgn->mtime));
#endif
}
@@ -678,9 +662,7 @@ MakeStartJobs ()
while (!Job_Full() && !Lst_IsEmpty (toBeMade)) {
gn = (GNode *) Lst_DeQueue (toBeMade);
- if (DEBUG(MAKE)) {
- printf ("Examining %s...", gn->name);
- }
+ DEBUGF(MAKE, "Examining %s...", gn->name);
/*
* Make sure any and all predecessors that are going to be made,
* have been.
@@ -692,9 +674,7 @@ MakeStartJobs ()
GNode *pgn = (GNode *)Lst_Datum(ln);
if (pgn->make && pgn->made == UNMADE) {
- if (DEBUG(MAKE)) {
- printf("predecessor %s not made yet.\n", pgn->name);
- }
+ DEBUGF(MAKE, "predecessor %s not made yet.\n", pgn->name);
break;
}
}
@@ -711,18 +691,14 @@ MakeStartJobs ()
numNodes--;
if (Make_OODate (gn)) {
- if (DEBUG(MAKE)) {
- printf ("out-of-date\n");
- }
+ DEBUGF(MAKE, "out-of-date\n");
if (queryFlag) {
return (TRUE);
}
Make_DoAllVar (gn);
Job_Make (gn);
} else {
- if (DEBUG(MAKE)) {
- printf ("up-to-date\n");
- }
+ DEBUGF(MAKE, "up-to-date\n");
gn->made = UPTODATE;
if (gn->type & OP_JOIN) {
/*
diff --git a/usr.bin/make/make.h b/usr.bin/make/make.h
index 465ee38..6976a89 100644
--- a/usr.bin/make/make.h
+++ b/usr.bin/make/make.h
@@ -338,6 +338,13 @@ extern int debug;
#define CONCAT(a,b) a##b
#define DEBUG(module) (debug & CONCAT(DEBUG_,module))
+#define DEBUGF(module,fmt,args...) \
+do { \
+ if (DEBUG(module)) { \
+ fprintf(stderr, fmt, ##args); \
+ fflush(stderr); \
+ } \
+} while (0)
#define ISDOT(c) ((c)[0] == '.' && (((c)[1] == '\0') || ((c)[1] == '/')))
#define ISDOTDOT(c) ((c)[0] == '.' && ISDOT(&((c)[1])))
diff --git a/usr.bin/make/parse.c b/usr.bin/make/parse.c
index d848c62..8a8b91a 100644
--- a/usr.bin/make/parse.c
+++ b/usr.bin/make/parse.c
@@ -1813,8 +1813,7 @@ Parse_FromString(str)
{
IFile *oldFile; /* state associated with this file */
- if (DEBUG(FOR))
- (void) fprintf(stderr, "%s\n----\n", str);
+ DEBUGF(FOR, "%s\n----\n", str);
oldFile = (IFile *) emalloc (sizeof (IFile));
oldFile->lineno = lineno;
diff --git a/usr.bin/make/suff.c b/usr.bin/make/suff.c
index 5da296c..e6665da 100644
--- a/usr.bin/make/suff.c
+++ b/usr.bin/make/suff.c
@@ -414,25 +414,19 @@ SuffInsert (l, s)
}
Lst_Close (l);
- if (DEBUG(SUFF)) {
- printf("inserting %s(%d)...", s->name, s->sNum);
- }
+ DEBUGF(SUFF, "inserting %s(%d)...", s->name, s->sNum);
if (ln == NULL) {
- if (DEBUG(SUFF)) {
- printf("at end of list\n");
- }
+ DEBUGF(SUFF, "at end of list\n");
(void)Lst_AtEnd (l, (void *)s);
s->refCount++;
(void)Lst_AtEnd(s->ref, (void *) l);
} else if (s2->sNum != s->sNum) {
- if (DEBUG(SUFF)) {
- printf("before %s(%d)\n", s2->name, s2->sNum);
- }
+ DEBUGF(SUFF, "before %s(%d)\n", s2->name, s2->sNum);
(void)Lst_Insert (l, ln, (void *)s);
s->refCount++;
(void)Lst_AtEnd(s->ref, (void *) l);
- } else if (DEBUG(SUFF)) {
- printf("already there\n");
+ } else {
+ DEBUGF(SUFF, "already there\n");
}
}
@@ -625,10 +619,8 @@ Suff_AddTransform (line)
/*
* link the two together in the proper relationship and order
*/
- if (DEBUG(SUFF)) {
- printf("defining transformation from `%s' to `%s'\n",
- s->name, t->name);
- }
+ DEBUGF(SUFF, "defining transformation from `%s' to `%s'\n",
+ s->name, t->name);
SuffInsert (t->children, s);
SuffInsert (s->parents, t);
@@ -666,10 +658,8 @@ Suff_EndTransform(gnp, dummy)
(void)SuffParseTransform(gn->name, &s, &t);
- if (DEBUG(SUFF)) {
- printf("deleting transformation from `%s' to `%s'\n",
- s->name, t->name);
- }
+ DEBUGF(SUFF, "deleting transformation from `%s' to `%s'\n",
+ s->name, t->name);
/*
* Remove the source from the target's children list. We check for a
@@ -685,8 +675,8 @@ Suff_EndTransform(gnp, dummy)
* Remove the target from the source's parents list
*/
SuffRemove(s->parents, t);
- } else if ((gn->type & OP_TRANSFORM) && DEBUG(SUFF)) {
- printf("transformation %s complete\n", gn->name);
+ } else if (gn->type & OP_TRANSFORM) {
+ DEBUGF(SUFF, "transformation %s complete\n", gn->name);
}
return(dummy ? 0 : 0);
@@ -1160,9 +1150,7 @@ SuffFindThem (srcs, slst)
while (!Lst_IsEmpty (srcs)) {
s = (Src *) Lst_DeQueue (srcs);
- if (DEBUG(SUFF)) {
- printf ("\ttrying %s...", s->file);
- }
+ DEBUGF(SUFF, "\ttrying %s...", s->file);
/*
* A file is considered to exist if either a node exists in the
@@ -1185,16 +1173,14 @@ SuffFindThem (srcs, slst)
break;
}
- if (DEBUG(SUFF)) {
- printf ("not there\n");
- }
+ DEBUGF(SUFF, "not there\n");
SuffAddLevel (srcs, s);
Lst_AtEnd(slst, (void *) s);
}
- if (DEBUG(SUFF) && rs) {
- printf ("got it\n");
+ if (rs) {
+ DEBUGF(SUFF, "got it\n");
}
return (rs);
}
@@ -1280,9 +1266,7 @@ SuffFindCmds (targ, slst)
Lst_AtEnd(targ->cp, (void *) ret);
#endif
Lst_AtEnd(slst, (void *) ret);
- if (DEBUG(SUFF)) {
- printf ("\tusing existing source %s\n", s->name);
- }
+ DEBUGF(SUFF, "\tusing existing source %s\n", s->name);
return (ret);
}
}
@@ -1333,9 +1317,7 @@ SuffExpandChildren(cgnp, pgnp)
* the children list.
*/
if (strchr(cgn->name, '$') != (char *)NULL) {
- if (DEBUG(SUFF)) {
- printf("Expanding \"%s\"...", cgn->name);
- }
+ DEBUGF(SUFF, "Expanding \"%s\"...", cgn->name);
cp = Var_Subst(NULL, cgn->name, pgn, TRUE);
if (cp != (char *)NULL) {
@@ -1424,9 +1406,7 @@ SuffExpandChildren(cgnp, pgnp)
while(!Lst_IsEmpty(members)) {
gn = (GNode *)Lst_DeQueue(members);
- if (DEBUG(SUFF)) {
- printf("%s...", gn->name);
- }
+ DEBUGF(SUFF, "%s...", gn->name);
if (Lst_Member(pgn->children, (void *)gn) == NULL) {
(void)Lst_Append(pgn->children, prevLN, (void *)gn);
prevLN = Lst_Succ(prevLN);
@@ -1447,9 +1427,7 @@ SuffExpandChildren(cgnp, pgnp)
ln = Lst_Member(pgn->children, (void *)cgn);
pgn->unmade--;
Lst_Remove(pgn->children, ln);
- if (DEBUG(SUFF)) {
- printf("\n");
- }
+ DEBUGF(SUFF, "\n");
} else if (Dir_HasWildcards(cgn->name)) {
Lst exp; /* List of expansions */
Lst path; /* Search path along which to expand */
@@ -1465,16 +1443,12 @@ SuffExpandChildren(cgnp, pgnp)
cp = cgn->name + strlen(cgn->name);
ln = Lst_Find(sufflist, (void *)cp, SuffSuffIsSuffixP);
- if (DEBUG(SUFF)) {
- printf("Wildcard expanding \"%s\"...", cgn->name);
- }
+ DEBUGF(SUFF, "Wildcard expanding \"%s\"...", cgn->name);
if (ln != NULL) {
Suff *s = (Suff *)Lst_Datum(ln);
- if (DEBUG(SUFF)) {
- printf("suffix is \"%s\"...", s->name);
- }
+ DEBUGF(SUFF, "suffix is \"%s\"...", s->name);
path = s->searchPath;
} else {
/*
@@ -1495,9 +1469,7 @@ SuffExpandChildren(cgnp, pgnp)
*/
cp = (char *)Lst_DeQueue(exp);
- if (DEBUG(SUFF)) {
- printf("%s...", cp);
- }
+ DEBUGF(SUFF, "%s...", cp);
gn = Targ_FindNode(cp, TARG_CREATE);
/*
@@ -1524,9 +1496,7 @@ SuffExpandChildren(cgnp, pgnp)
ln = Lst_Member(pgn->children, (void *)cgn);
pgn->unmade--;
Lst_Remove(pgn->children, ln);
- if (DEBUG(SUFF)) {
- printf("\n");
- }
+ DEBUGF(SUFF, "\n");
}
return(0);
@@ -1610,9 +1580,7 @@ SuffApplyTransform(tGn, sGn, t, s)
gn = (GNode *)Lst_Datum(ln);
- if (DEBUG(SUFF)) {
- printf("\tapplying %s -> %s to \"%s\"\n", s->name, t->name, tGn->name);
- }
+ DEBUGF(SUFF, "\tapplying %s -> %s to \"%s\"\n", s->name, t->name, tGn->name);
/*
* Record last child for expansion purposes
@@ -1718,9 +1686,7 @@ SuffFindArchiveDeps(gn, slst)
/*
* Didn't know what it was -- use .NULL suffix if not in make mode
*/
- if (DEBUG(SUFF)) {
- printf("using null suffix\n");
- }
+ DEBUGF(SUFF, "using null suffix\n");
ms = suffNull;
}
@@ -1749,10 +1715,8 @@ SuffFindArchiveDeps(gn, slst)
/*
* Got one -- apply it
*/
- if (!SuffApplyTransform(gn, mem, (Suff *)Lst_Datum(ln), ms) &&
- DEBUG(SUFF))
- {
- printf("\tNo transformation from %s -> %s\n",
+ if (!SuffApplyTransform(gn, mem, (Suff *)Lst_Datum(ln), ms)) {
+ DEBUGF(SUFF, "\tNo transformation from %s -> %s\n",
ms->name, ((Suff *)Lst_Datum(ln))->name);
}
}
@@ -1895,9 +1859,7 @@ SuffFindNormalDeps(gn, slst)
* Handle target of unknown suffix...
*/
if (Lst_IsEmpty(targs) && suffNull != NULL) {
- if (DEBUG(SUFF)) {
- printf("\tNo known suffix on %s. Using .NULL suffix\n", gn->name);
- }
+ DEBUGF(SUFF, "\tNo known suffix on %s. Using .NULL suffix\n", gn->name);
targ = (Src *)emalloc(sizeof (Src));
targ->file = estrdup(gn->name);
@@ -1918,12 +1880,10 @@ SuffFindNormalDeps(gn, slst)
if (Lst_IsEmpty(gn->commands) && Lst_IsEmpty(gn->children))
SuffAddLevel(srcs, targ);
else {
- if (DEBUG(SUFF))
- printf("not ");
+ DEBUGF(SUFF, "not ");
}
- if (DEBUG(SUFF))
- printf("adding suffix rules\n");
+ DEBUGF(SUFF, "adding suffix rules\n");
(void)Lst_AtEnd(targs, (void *)targ);
}
@@ -1971,9 +1931,7 @@ SuffFindNormalDeps(gn, slst)
Lst_ForEach(gn->children, SuffExpandChildren, (void *)gn);
if (targ == NULL) {
- if (DEBUG(SUFF)) {
- printf("\tNo valid suffix on %s\n", gn->name);
- }
+ DEBUGF(SUFF, "\tNo valid suffix on %s\n", gn->name);
sfnd_abort:
/*
@@ -2216,9 +2174,7 @@ SuffFindDeps (gn, slst)
gn->type |= OP_DEPS_FOUND;
}
- if (DEBUG(SUFF)) {
- printf ("SuffFindDeps (%s)\n", gn->name);
- }
+ DEBUGF(SUFF, "SuffFindDeps (%s)\n", gn->name);
if (gn->type & OP_ARCHV) {
SuffFindArchiveDeps(gn, slst);
diff --git a/usr.bin/make/targ.c b/usr.bin/make/targ.c
index a9bf383..86bd080 100644
--- a/usr.bin/make/targ.c
+++ b/usr.bin/make/targ.c
@@ -488,7 +488,7 @@ Targ_PrintType (type)
int tbit;
#define PRINTBIT(attr) case CONCAT(OP_,attr): printf("." #attr " "); break
-#define PRINTDBIT(attr) case CONCAT(OP_,attr): if (DEBUG(TARG)) printf("." #attr " "); break
+#define PRINTDBIT(attr) case CONCAT(OP_,attr): DEBUGF(TARG, "." #attr " "); break
type &= ~OP_OPMASK;
@@ -509,7 +509,7 @@ Targ_PrintType (type)
PRINTBIT(NOTMAIN);
PRINTDBIT(LIB);
/*XXX: MEMBER is defined, so CONCAT(OP_,MEMBER) gives OP_"%" */
- case OP_MEMBER: if (DEBUG(TARG)) printf(".MEMBER "); break;
+ case OP_MEMBER: DEBUGF(TARG, ".MEMBER "); break;
PRINTDBIT(ARCHV);
}
}
diff --git a/usr.bin/make/var.c b/usr.bin/make/var.c
index d0ab186..472e737 100644
--- a/usr.bin/make/var.c
+++ b/usr.bin/make/var.c
@@ -396,9 +396,7 @@ VarAdd (name, val, ctxt)
(void) Lst_AtFront (ctxt->context, (void *)v);
(void) Lst_AtEnd (allVars, (void *) v);
- if (DEBUG(VAR)) {
- fprintf(stderr, "%s:%s = %s\n", ctxt->name, name, val);
- }
+ DEBUGF(VAR, "%s:%s = %s\n", ctxt->name, name, val);
}
@@ -446,9 +444,7 @@ Var_Delete(name, ctxt)
{
LstNode ln;
- if (DEBUG(VAR)) {
- fprintf(stderr, "%s:delete %s\n", ctxt->name, name);
- }
+ DEBUGF(VAR, "%s:delete %s\n", ctxt->name, name);
ln = Lst_Find(ctxt->context, (void *)name, VarCmp);
if (ln != NULL) {
Var *v;
@@ -503,9 +499,7 @@ Var_Set (name, val, ctxt)
Buf_Discard(v->val, Buf_Size(v->val));
Buf_AddBytes(v->val, strlen(val), (Byte *)val);
- if (DEBUG(VAR)) {
- fprintf(stderr, "%s:%s = %s\n", ctxt->name, name, val);
- }
+ DEBUGF(VAR, "%s:%s = %s\n", ctxt->name, name, val);
}
/*
* Any variables given on the command line are automatically exported
@@ -556,10 +550,8 @@ Var_Append (name, val, ctxt)
Buf_AddByte(v->val, (Byte)' ');
Buf_AddBytes(v->val, strlen(val), (Byte *)val);
- if (DEBUG(VAR)) {
- fprintf(stderr, "%s:%s = %s\n", ctxt->name, name,
- (char *) Buf_GetAll(v->val, (int *)NULL));
- }
+ DEBUGF(VAR, "%s:%s = %s\n", ctxt->name, name,
+ (char *) Buf_GetAll(v->val, (int *)NULL));
if (v->flags & VAR_FROM_ENV) {
/*
@@ -1780,9 +1772,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr)
char *newStr; /* New value to return */
char termc; /* Character which terminated scan */
- if (DEBUG(VAR)) {
- fprintf(stderr, "Applying :%c to \"%s\"\n", *tstr, str);
- }
+ DEBUGF(VAR, "Applying :%c to \"%s\"\n", *tstr, str);
switch (*tstr) {
case 'U':
if (tstr[1] == endc || tstr[1] == ':') {
@@ -2251,9 +2241,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr)
}
}
}
- if (DEBUG(VAR)) {
- fprintf(stderr, "Result is \"%s\"\n", newStr);
- }
+ DEBUGF(VAR, "Result is \"%s\"\n", newStr);
if (*freePtr) {
free (str);
OpenPOWER on IntegriCloud