A number of semi-related changes.
1. make -dx turns on DEBUG_SHELL which causes sh -x to be used where possible. 2. PrintOnError() is now called when make is stopping due to an error. This routine reports the curdir and the value of any variables listed in MAKE_PRINT_VAR_ON_ERROR. 3. Variables set via command line, are propagated to child-makes via MAKEFLAGS. This behaviour appears to be necessary for POSIX (according to the GNU folk anyway). 4. Do not reset MAKEFILE when reading ".depend" as this rather eliminates the usefulness of ${MAKEFILE}. 5. Added ${.newline} as a simple means of being able to include \n in the result of a :@ loop expansion. 6. Set ${MAKE_VERSION} if defined. Need to come up with a useful value. Reviewed: christos
This commit is contained in:
parent
7e716e6849
commit
9cfd89292b
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: compat.c,v 1.33 2001/05/29 17:37:51 christos Exp $ */
|
||||
/* $NetBSD: compat.c,v 1.34 2001/06/01 20:33:37 sjg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
|
||||
|
@ -39,14 +39,14 @@
|
|||
*/
|
||||
|
||||
#ifdef MAKE_BOOTSTRAP
|
||||
static char rcsid[] = "$NetBSD: compat.c,v 1.33 2001/05/29 17:37:51 christos Exp $";
|
||||
static char rcsid[] = "$NetBSD: compat.c,v 1.34 2001/06/01 20:33:37 sjg Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)compat.c 8.2 (Berkeley) 3/19/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: compat.c,v 1.33 2001/05/29 17:37:51 christos Exp $");
|
||||
__RCSID("$NetBSD: compat.c,v 1.34 2001/06/01 20:33:37 sjg Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
|
@ -257,6 +257,9 @@ CompatRunCommand (cmdp, gnp)
|
|||
*/
|
||||
static char *shargv[4] = { "/bin/sh" };
|
||||
|
||||
if (DEBUG(SHELL))
|
||||
shargv[1] = (errCheck ? "-exc" : "-xc");
|
||||
else
|
||||
shargv[1] = (errCheck ? "-ec" : "-c");
|
||||
shargv[2] = cmd;
|
||||
shargv[3] = (char *)NULL;
|
||||
|
@ -479,7 +482,7 @@ CompatMake (gnp, pgnp)
|
|||
} else if (keepgoing) {
|
||||
pgn->flags &= ~REMAKE;
|
||||
} else {
|
||||
printf ("\n\nStop.\n");
|
||||
PrintOnError("\n\nStop.");
|
||||
exit (1);
|
||||
}
|
||||
} else if (gn->made == ERROR) {
|
||||
|
@ -574,7 +577,7 @@ Compat_Run(targs)
|
|||
if (gn != NILGNODE) {
|
||||
Lst_ForEach(gn->commands, CompatRunCommand, (ClientData)gn);
|
||||
if (gn->made == ERROR) {
|
||||
printf("\n\nStop.\n");
|
||||
PrintOnError("\n\nStop.");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: job.c,v 1.48 2001/05/29 17:37:52 christos Exp $ */
|
||||
/* $NetBSD: job.c,v 1.49 2001/06/01 20:33:37 sjg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
|
||||
|
@ -39,14 +39,14 @@
|
|||
*/
|
||||
|
||||
#ifdef MAKE_BOOTSTRAP
|
||||
static char rcsid[] = "$NetBSD: job.c,v 1.48 2001/05/29 17:37:52 christos Exp $";
|
||||
static char rcsid[] = "$NetBSD: job.c,v 1.49 2001/06/01 20:33:37 sjg Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)job.c 8.2 (Berkeley) 3/19/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: job.c,v 1.48 2001/05/29 17:37:52 christos Exp $");
|
||||
__RCSID("$NetBSD: job.c,v 1.49 2001/06/01 20:33:37 sjg Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
|
@ -708,6 +708,12 @@ JobPrintCommand(cmdp, jobp)
|
|||
}
|
||||
}
|
||||
|
||||
if (DEBUG(SHELL) && strcmp(shellName, "sh") == 0 &&
|
||||
(job->flags & JOB_TRACED) == 0) {
|
||||
DBPRINTF("set -%s\n", "x");
|
||||
job->flags |= JOB_TRACED;
|
||||
}
|
||||
|
||||
if ((cp = Check_Cwd_Cmd(cmd)) != NULL) {
|
||||
DBPRINTF("cd %s; ", cp);
|
||||
}
|
||||
|
@ -1280,6 +1286,8 @@ JobExec(job, argv)
|
|||
{
|
||||
int cpid; /* ID of new child */
|
||||
|
||||
job->flags &= ~JOB_TRACED;
|
||||
|
||||
if (DEBUG(JOB)) {
|
||||
int i;
|
||||
|
||||
|
@ -2352,6 +2360,7 @@ Job_CatchChildren(block)
|
|||
}
|
||||
} else {
|
||||
job = (Job *) Lst_Datum(jnode);
|
||||
Job_CatchOutput();
|
||||
(void) Lst_Remove(jobs, jnode);
|
||||
nJobs -= 1;
|
||||
#ifdef REMOTE
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: job.h,v 1.14 2000/12/30 16:38:22 sommerfeld Exp $ */
|
||||
/* $NetBSD: job.h,v 1.15 2001/06/01 20:33:37 sjg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
|
||||
|
@ -130,6 +130,8 @@ typedef struct Job {
|
|||
#define JOB_CONTINUING 0x200 /* We are in the process of resuming this job.
|
||||
* Used to avoid infinite recursion between
|
||||
* JobFinish and JobRestart */
|
||||
#define JOB_TRACED 0x400 /* we've sent 'set -x' */
|
||||
|
||||
union {
|
||||
struct {
|
||||
int op_inPipe; /* Input side of pipe associated
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: main.c,v 1.66 2001/05/29 17:37:52 christos Exp $ */
|
||||
/* $NetBSD: main.c,v 1.67 2001/06/01 20:33:37 sjg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
|
@ -39,7 +39,7 @@
|
|||
*/
|
||||
|
||||
#ifdef MAKE_BOOTSTRAP
|
||||
static char rcsid[] = "$NetBSD: main.c,v 1.66 2001/05/29 17:37:52 christos Exp $";
|
||||
static char rcsid[] = "$NetBSD: main.c,v 1.67 2001/06/01 20:33:37 sjg Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
|
@ -51,7 +51,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\n\
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: main.c,v 1.66 2001/05/29 17:37:52 christos Exp $");
|
||||
__RCSID("$NetBSD: main.c,v 1.67 2001/06/01 20:33:37 sjg Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
|
@ -310,6 +310,9 @@ rearg: while((c = getopt(argc, argv, OPTFLAGS)) != -1) {
|
|||
case 'v':
|
||||
debug |= DEBUG_VAR;
|
||||
break;
|
||||
case 'x':
|
||||
debug |= DEBUG_SHELL;
|
||||
break;
|
||||
default:
|
||||
(void)fprintf(stderr,
|
||||
"%s: illegal argument to d option -- %c\n",
|
||||
|
@ -389,9 +392,10 @@ rearg: while((c = getopt(argc, argv, OPTFLAGS)) != -1) {
|
|||
* on the end of the "create" list.
|
||||
*/
|
||||
for (argv += optind, argc -= optind; *argv; ++argv, --argc)
|
||||
if (Parse_IsVar(*argv))
|
||||
if (Parse_IsVar(*argv)) {
|
||||
Var_Append(MAKEFLAGS, *argv, VAR_GLOBAL);
|
||||
Parse_DoVar(*argv, VAR_CMD);
|
||||
else {
|
||||
} else {
|
||||
if (!**argv)
|
||||
Punt("illegal (null) argument.");
|
||||
if (**argv == '-') {
|
||||
|
@ -612,6 +616,10 @@ main(argc, argv)
|
|||
Var_Set(".CURDIR", curdir, VAR_GLOBAL);
|
||||
Var_Set("MACHINE", machine, VAR_GLOBAL);
|
||||
Var_Set("MACHINE_ARCH", machine_arch, VAR_GLOBAL);
|
||||
#ifdef MAKE_VERSION
|
||||
Var_Set("MAKE_VERSION", MAKE_VERSION, VAR_GLOBAL);
|
||||
#endif
|
||||
Var_Set(".newline", "\n", VAR_GLOBAL); /* handy for :@ loops */
|
||||
|
||||
/*
|
||||
* If the MAKEOBJDIR (or by default, the _PATH_OBJDIR) directory
|
||||
|
@ -979,11 +987,14 @@ ReadMakefile(p, q)
|
|||
FILE *stream;
|
||||
size_t len = MAXPATHLEN;
|
||||
char *name, *path = emalloc(len);
|
||||
int setMAKEFILE;
|
||||
|
||||
if (!strcmp(fname, "-")) {
|
||||
Parse_File("(stdin)", stdin);
|
||||
Var_Set("MAKEFILE", "", VAR_GLOBAL);
|
||||
} else {
|
||||
setMAKEFILE = strcmp(fname, ".depend");
|
||||
|
||||
/* if we've chdir'd, rebuild the path name */
|
||||
if (curdir != objdir && *fname != '/') {
|
||||
size_t plen = strlen(curdir) + strlen(fname) + 2;
|
||||
|
@ -1011,7 +1022,9 @@ ReadMakefile(p, q)
|
|||
* placement of the setting here means it gets set to the last
|
||||
* makefile specified, as it is set by SysV make.
|
||||
*/
|
||||
found: Var_Set("MAKEFILE", fname, VAR_GLOBAL);
|
||||
found:
|
||||
if (setMAKEFILE)
|
||||
Var_Set("MAKEFILE", fname, VAR_GLOBAL);
|
||||
Parse_File(fname, stream);
|
||||
(void)fclose(stream);
|
||||
}
|
||||
|
@ -1411,6 +1424,8 @@ Fatal(va_alist)
|
|||
(void)fprintf(stderr, "\n");
|
||||
(void)fflush(stderr);
|
||||
|
||||
PrintOnError(NULL);
|
||||
|
||||
if (DEBUG(GRAPH2))
|
||||
Targ_PrintGraph(2);
|
||||
Trace_Log(MAKEERROR, 0);
|
||||
|
@ -1453,6 +1468,8 @@ Punt(va_alist)
|
|||
(void)fprintf(stderr, "\n");
|
||||
(void)fflush(stderr);
|
||||
|
||||
PrintOnError(NULL);
|
||||
|
||||
DieHorribly();
|
||||
}
|
||||
|
||||
|
@ -1624,3 +1641,22 @@ PrintAddr(a, b)
|
|||
printf("%lx ", (unsigned long) a);
|
||||
return b ? 0 : 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
PrintOnError(s)
|
||||
char *s;
|
||||
{
|
||||
char tmp[64];
|
||||
|
||||
if (s)
|
||||
printf("%s", s);
|
||||
|
||||
printf("\n%s: stopped in %s\n", progname, curdir);
|
||||
strncpy(tmp, "${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'\n@}",
|
||||
sizeof(tmp) - 1);
|
||||
s = Var_Subst(NULL, tmp, VAR_GLOBAL, 0);
|
||||
if (s && *s)
|
||||
printf("%s", s);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
.\" $NetBSD: make.1,v 1.48 2001/04/04 09:39:07 wiz Exp $
|
||||
.\" $NetBSD: make.1,v 1.49 2001/06/01 20:33:37 sjg Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1990, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
|
@ -136,6 +136,10 @@ Print debugging information about suffix-transformation rules.
|
|||
Print debugging information about target list maintenance.
|
||||
.It Ar v
|
||||
Print debugging information about variable assignment.
|
||||
.It Ar x
|
||||
Run shell commands with
|
||||
.Fl x
|
||||
so the actual commands are printed as they are executed.
|
||||
.El
|
||||
.It Fl e
|
||||
Specify that environmental variables override macro assignments within
|
||||
|
@ -508,6 +512,19 @@ is set to the value of
|
|||
for all programs which
|
||||
.Nm
|
||||
executes.
|
||||
.It Va MAKE_PRINT_VAR_ON_ERROR
|
||||
When
|
||||
.Nm
|
||||
stops due to an error, it prints its name and the value of
|
||||
.Ql Va .CURDIR
|
||||
as well as the value of any variables named in
|
||||
.Ql Va MAKE_PRINT_VAR_ON_ERROR .
|
||||
.It Va .newline
|
||||
This variable is simply assigned a newline character as its value.
|
||||
This allows expansions using the :@ modifier to put a newline between
|
||||
iterations of the loop rather than a space. For example, the printing of
|
||||
.Ql Va MAKE_PRINT_VAR_ON_ERROR
|
||||
could be done as ${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'${.newline}@}.
|
||||
.El
|
||||
.Pp
|
||||
Variable expansion may be modified to select or modify each word of the
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: make.h,v 1.33 2001/01/14 05:34:06 christos Exp $ */
|
||||
/* $NetBSD: make.h,v 1.34 2001/06/01 20:33:37 sjg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
|
@ -385,6 +385,7 @@ extern int debug;
|
|||
#define DEBUG_TARG 0x0100
|
||||
#define DEBUG_VAR 0x0200
|
||||
#define DEBUG_FOR 0x0400
|
||||
#define DEBUG_SHELL 0x0800
|
||||
|
||||
#ifdef __STDC__
|
||||
#define CONCAT(a,b) a##b
|
||||
|
@ -411,5 +412,6 @@ void Make_DoAllVar __P((GNode *));
|
|||
Boolean Make_Run __P((Lst));
|
||||
char * Check_Cwd_Cmd __P((char *));
|
||||
void Check_Cwd __P((char **));
|
||||
void PrintOnError __P((char *));
|
||||
|
||||
#endif /* _MAKE_H_ */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: parse.c,v 1.63 2001/02/23 21:11:38 christos Exp $ */
|
||||
/* $NetBSD: parse.c,v 1.64 2001/06/01 20:33:38 sjg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
|
@ -39,14 +39,14 @@
|
|||
*/
|
||||
|
||||
#ifdef MAKE_BOOTSTRAP
|
||||
static char rcsid[] = "$NetBSD: parse.c,v 1.63 2001/02/23 21:11:38 christos Exp $";
|
||||
static char rcsid[] = "$NetBSD: parse.c,v 1.64 2001/06/01 20:33:38 sjg Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: parse.c,v 1.63 2001/02/23 21:11:38 christos Exp $");
|
||||
__RCSID("$NetBSD: parse.c,v 1.64 2001/06/01 20:33:38 sjg Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
|
@ -2716,6 +2716,7 @@ Parse_File(name, stream)
|
|||
(void)fprintf(stderr,
|
||||
"%s: Fatal errors encountered -- cannot continue\n",
|
||||
progname);
|
||||
PrintOnError(NULL);
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: var.c,v 1.59 2001/05/12 06:48:49 sjg Exp $ */
|
||||
/* $NetBSD: var.c,v 1.60 2001/06/01 20:33:38 sjg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
|
@ -39,14 +39,14 @@
|
|||
*/
|
||||
|
||||
#ifdef MAKE_BOOTSTRAP
|
||||
static char rcsid[] = "$NetBSD: var.c,v 1.59 2001/05/12 06:48:49 sjg Exp $";
|
||||
static char rcsid[] = "$NetBSD: var.c,v 1.60 2001/06/01 20:33:38 sjg Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: var.c,v 1.59 2001/05/12 06:48:49 sjg Exp $");
|
||||
__RCSID("$NetBSD: var.c,v 1.60 2001/06/01 20:33:38 sjg Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
|
@ -1243,15 +1243,16 @@ VarLoopExpand (word, addSpace, buf, loopp)
|
|||
{
|
||||
VarLoop_t *loop = (VarLoop_t *) loopp;
|
||||
char *s;
|
||||
int slen;
|
||||
|
||||
Var_Set(loop->tvar, word, loop->ctxt);
|
||||
s = Var_Subst(NULL, loop->str, loop->ctxt, loop->err);
|
||||
if (s != NULL && *s != '\0') {
|
||||
if (addSpace)
|
||||
if (addSpace && *s != '\n')
|
||||
Buf_AddByte(buf, ' ');
|
||||
Buf_AddBytes(buf, strlen(s), (Byte *)s);
|
||||
Buf_AddBytes(buf, (slen = strlen(s)), (Byte *)s);
|
||||
addSpace = (slen > 0 && s[slen - 1] != '\n');
|
||||
free(s);
|
||||
addSpace = TRUE;
|
||||
}
|
||||
return addSpace;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue