From 70ff7eab093a1201886a7bce4f1851c677a14c2a Mon Sep 17 00:00:00 2001 From: joerg Date: Tue, 7 Sep 2010 14:12:27 +0000 Subject: [PATCH] Import bmake-20100808: - boot-strap (TOOL_DIFF): set this to ensure tests use the same version of diff that configure tested - in jobs mode, when we discover we cannot make something, call PrintOnError before exit. - formatting fixes for ignored errors - ensure jobs are cleaned up regardless of where wait() was called. - os.sh (MACHINE_ARCH): watch out for drivel from uname -p - call PrintOnError from JobFinish when we detect an error we are not ignoring. - use bmake_signal() which is a wrapper around sigaction() in place of signal() - add .export-env to allow exporting variables to environment without tracking (so no re-export when the internal value is changed). - fix for .info et al being greedy. - back to using realpath on argv[0] but only if contains '/' and does not start with '/'. --- devel/bmake/files/ChangeLog | 59 ++++++++++++ devel/bmake/files/Makefile.in | 4 +- devel/bmake/files/bmake.1 | 67 ++++++++++++-- devel/bmake/files/bmake.cat1 | 55 +++++++++-- devel/bmake/files/boot-strap | 6 +- devel/bmake/files/compat.c | 24 ++--- devel/bmake/files/job.c | 111 ++++++++++++++--------- devel/bmake/files/main.c | 30 ++++-- devel/bmake/files/make.1 | 67 ++++++++++++-- devel/bmake/files/make.c | 6 +- devel/bmake/files/nonints.h | 10 +- devel/bmake/files/os.sh | 8 +- devel/bmake/files/parse.c | 21 +++-- devel/bmake/files/unit-tests/Makefile.in | 6 +- devel/bmake/files/unit-tests/error | 6 +- devel/bmake/files/util.c | 41 ++------- devel/bmake/files/var.c | 17 +++- 17 files changed, 393 insertions(+), 145 deletions(-) diff --git a/devel/bmake/files/ChangeLog b/devel/bmake/files/ChangeLog index fcb4f720f1fe..19052c5561f7 100644 --- a/devel/bmake/files/ChangeLog +++ b/devel/bmake/files/ChangeLog @@ -1,3 +1,62 @@ +2010-08-08 Simon J. Gerraty + + * boot-strap (TOOL_DIFF): set this to ensure tests use + the same version of diff that configure tested + + * Makefile.in (MAKE_VERSION): bump version to 20100808 + Merge with NetBSD make, pick up + o in jobs mode, when we discover we cannot make something, + call PrintOnError before exit. + +2010-08-06 Simon J. Gerraty + + * Makefile.in (MAKE_VERSION): bump version to 20100806 + Merge with NetBSD make, pick up + o formatting fixes for ignored errors + o ensure jobs are cleaned up regardless of where wait() was called. + +2010-06-28 Simon J. Gerraty + + * Makefile.in (MAKE_VERSION): bump version to 20100618 + * os.sh (MACHINE_ARCH): watch out for drivel from uname -p + +2010-06-16 Simon J. Gerraty + + * Makefile.in (MAKE_VERSION): bump version to 20100616 + Merge with NetBSD make, pick up + o man page update + o call PrintOnError from JobFinish when we detect an error we + are not ignoring. + +2010-06-06 Simon J. Gerraty + + * Makefile.in (MAKE_VERSION): bump version to 20100606 + Merge with NetBSD make, pick up + o man page update + +2010-06-05 Simon J. Gerraty + + * Makefile.in (MAKE_VERSION): bump version to 20100605 + Merge with NetBSD make, pick up + o use bmake_signal() which is a wrapper around sigaction() + in place of signal() + o add .export-env to allow exporting variables to environment + without tracking (so no re-export when the internal value is + changed). + +2010-05-24 Simon J. Gerraty + + * Makefile.in (MAKE_VERSION): bump version to 20100524 + Merge with NetBSD make, pick up + o fix for .info et al being greedy. + +2010-05-23 Simon J. Gerraty + + * Makefile.in (MAKE_VERSION): bump version to 20100520 + Merge with NetBSD make, pick up + o back to using realpath on argv[0] + but only if contains '/' and does not start with '/'. + 2010-05-10 Simon J. Gerraty * boot-strap: use absolute path for bmake when running tests. diff --git a/devel/bmake/files/Makefile.in b/devel/bmake/files/Makefile.in index 10017cf3593b..9b758bb41654 100644 --- a/devel/bmake/files/Makefile.in +++ b/devel/bmake/files/Makefile.in @@ -1,7 +1,7 @@ # $NetBSD: Makefile,v 1.50 2010/04/22 19:15:23 sjg Exp $ # @(#)Makefile 5.2 (Berkeley) 12/28/90 -# $Id: Makefile.in,v 1.1.1.8 2010/05/13 18:37:40 joerg Exp $ +# $Id: Makefile.in,v 1.1.1.9 2010/09/07 14:11:16 joerg Exp $ PROG= bmake SRCS= arch.c buf.c compat.c cond.c dir.c for.c hash.c job.c main.c \ @@ -21,7 +21,7 @@ srcdir= @srcdir@ CC?= @CC@ # Base version on src date -MAKE_VERSION= 20100510 +MAKE_VERSION= 20100808 MACHINE=@machine@ MACHINE_ARCH=@machine_arch@ DEFAULT_SYS_PATH = @default_sys_path@ diff --git a/devel/bmake/files/bmake.1 b/devel/bmake/files/bmake.1 index 7c3a543c7b75..40864ae6ea17 100644 --- a/devel/bmake/files/bmake.1 +++ b/devel/bmake/files/bmake.1 @@ -1,4 +1,4 @@ -.\" $NetBSD: make.1,v 1.171 2010/04/22 19:15:23 sjg Exp $ +.\" $NetBSD: make.1,v 1.179 2010/06/30 01:03:54 dholland Exp $ .\" .\" Copyright (c) 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" from: @(#)make.1 8.4 (Berkeley) 3/19/94 .\" -.Dd April 21, 2010 +.Dd June 30, 2010 .Dt MAKE 1 .Os .Sh NAME @@ -536,11 +536,48 @@ If the result of expanding a variable contains a dollar sign .Pq Ql \&$ the string is expanded again. .Pp -Variable substitution occurs at two distinct times, depending on where +Variable substitution occurs at three distinct times, depending on where the variable is being used. +.Bl -enum +.It Variables in dependency lines are expanded as the line is read. +.It Variables in shell commands are expanded when the shell command is executed. +.It +.Dq .for +loop index variables are expanded on each loop iteration. +Note that other variables are not expanded inside loops so +the following example code: +.Bd -literal -offset indent + +.Dv .for i in 1 2 3 +a+= ${i} +j= ${i} +b+= ${j} +.Dv .endfor + +all: + @echo ${a} + @echo ${b} + +.Ed +will print: +.Bd -literal -offset indent +1 2 3 +3 3 3 + +.Ed +Because while ${a} contains +.Dq 1 2 3 +after the loop is executed, ${b} +contains +.Dq ${j} ${j} ${j} +which expands to +.Dq 3 3 3 +since after the loop completes ${j} contains +.Dq 3 . +.El .Ss Variable classes The four different classes of variables (in order of increasing precedence) are: @@ -576,7 +613,7 @@ The list of sources for this target that were deemed out-of-date; also known as .Ql Va \&? . .It Va .PREFIX -The file prefix of the file, containing only the file portion, no suffix +The file prefix of the target, containing only the file portion, no suffix or preceding directory components; also known as .Ql Va * . .It Va .TARGET @@ -660,7 +697,7 @@ from which generated dependencies are read. The list of variables exported by .Nm . .It Va .MAKE.JOBS -The argument to the +The argument to the .Fl j option. .It Va .MAKE.JOB.PREFIX @@ -791,8 +828,10 @@ is set in the environment or on the command line.) .Pp Variable expansion is performed on the value before it's used, so expressions such as -.Dl ${.CURDIR:C,^/usr/src,/var/obj,} +.Dl ${.CURDIR:S,^/usr/src,/var/obj,} may be used. +This is especially useful with +.Ql Ev MAKEOBJDIR . .Pp .Ql Va .OBJDIR may be modified in the makefile as a global variable. @@ -853,6 +892,8 @@ is set to the value of for all programs which .Nm executes. +.It Ev .TARGETS +The list of targets explicitly specified on the command line, if any. .It Ev VPATH Colon-separated .Pq Dq \&: @@ -902,7 +943,7 @@ The standard shell wildcard characters .Pf ( Ql * , .Ql \&? , and -.Ql Op ) +.Ql Oo Oc ) may be used. The wildcard characters may be escaped with a backslash @@ -1320,6 +1361,15 @@ flag, so should be used with caution. Appending a variable name to .Va .MAKE.EXPORTED is equivalent to exporting a variable. +.It Ic .export-env Ar variable ... +The same as +.Ql .export , +except that the variable is not appended to +.Va .MAKE.EXPORTED . +This allows exporting a value to the environment which is different from that +used by +.Nm +internally. .It Ic .info Ar message The message is printed along with the name of the makefile and line number. .It Ic .undef Ar variable @@ -1582,6 +1632,9 @@ correspond to an actual file; it is always considered to be out of date, and will not be created with the .Fl t option. +Suffix-transformation rules are not applied to +.Ic .PHONY +targets. .It Ic .PRECIOUS When .Nm diff --git a/devel/bmake/files/bmake.cat1 b/devel/bmake/files/bmake.cat1 index 4e7f10932542..a88acfe3147c 100644 --- a/devel/bmake/files/bmake.cat1 +++ b/devel/bmake/files/bmake.cat1 @@ -321,10 +321,37 @@ VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNTTSS If the result of expanding a variable contains a dollar sign (`$') the string is expanded again. - Variable substitution occurs at two distinct times, depending on where - the variable is being used. Variables in dependency lines are expanded - as the line is read. Variables in shell commands are expanded when the - shell command is executed. + Variable substitution occurs at three distinct times, depending on where + the variable is being used. + + 1. Variables in dependency lines are expanded as the line is read. + + 2. Variables in shell commands are expanded when the shell command is + executed. + + 3. ``.for'' loop index variables are expanded on each loop iteration. + Note that other variables are not expanded inside loops so the fol- + lowing example code: + + + .for i in 1 2 3 + a+= ${i} + j= ${i} + b+= ${j} + .endfor + + all: + @echo ${a} + @echo ${b} + + will print: + + 1 2 3 + 3 3 3 + + Because while ${a} contains ``1 2 3'' after the loop is executed, + ${b} contains ``${j} ${j} ${j}'' which expands to ``3 3 3'' since + after the loop completes ${j} contains ``3''. VVaarriiaabbllee ccllaasssseess The four different classes of variables (in order of increasing prece- @@ -358,7 +385,7 @@ VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNTTSS _._O_O_D_A_T_E The list of sources for this target that were deemed out-of-date; also known as `_?'. - _._P_R_E_F_I_X The file prefix of the file, containing only the file + _._P_R_E_F_I_X The file prefix of the target, containing only the file portion, no suffix or preceding directory components; also known as `_*'. @@ -487,8 +514,9 @@ VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNTTSS Variable expansion is performed on the value before it's used, so expressions such as - ${.CURDIR:C,^/usr/src,/var/obj,} - may be used. + ${.CURDIR:S,^/usr/src,/var/obj,} + may be used. This is especially useful with + `MAKEOBJDIR'. `_._O_B_J_D_I_R' may be modified in the makefile as a global variable. In all cases, bbmmaakkee will chdir(2) to `_._O_B_J_D_I_R' @@ -516,6 +544,9 @@ VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNTTSS contains a variable transform. `PWD' is set to the value of `_._O_B_J_D_I_R' for all programs which bbmmaakkee executes. + .TARGETS The list of targets explicitly specified on the command + line, if any. + VPATH Colon-separated (``:'') lists of directories that bbmmaakkee will search for files. The variable is supported for compatibility with old make programs only, use `_._P_A_T_H' @@ -790,6 +821,11 @@ IINNCCLLUUDDEE SSTTAATTEEMMEENNTTSS,, CCOONNDDIITTIIOO Appending a variable name to _._M_A_K_E_._E_X_P_O_R_T_E_D is equivalent to exporting a variable. + ..eexxppoorrtt--eennvv _v_a_r_i_a_b_l_e _._._. + The same as `.export', except that the variable is not appended + to _._M_A_K_E_._E_X_P_O_R_T_E_D. This allows exporting a value to the environ- + ment which is different from that used by bbmmaakkee internally. + ..iinnffoo _m_e_s_s_a_g_e The message is printed along with the name of the makefile and line number. @@ -963,7 +999,8 @@ SSPPEECCIIAALL SSOOUURRCCEESS ((AATTTTRRIIBBUUTTEESS)) ..PPHHOONNYY The target does not correspond to an actual file; it is always considered to be out of date, and will not be created with the - --tt option. + --tt option. Suffix-transformation rules are not applied to + ..PPHHOONNYY targets. ..PPRREECCIIOOUUSS When bbmmaakkee is interrupted, it normally removes any partially @@ -1166,4 +1203,4 @@ HHIISSTTOORRYY bbmmaakkee is derived from NetBSD's make(1). It uses autoconf to facilitate portability to other platforms. -NetBSD 5.0_STABLE April 21, 2010 NetBSD 5.0_STABLE +NetBSD 5.0_STABLE June 30, 2010 NetBSD 5.0_STABLE diff --git a/devel/bmake/files/boot-strap b/devel/bmake/files/boot-strap index e4117008dd0e..44d497c98839 100755 --- a/devel/bmake/files/boot-strap +++ b/devel/bmake/files/boot-strap @@ -53,7 +53,7 @@ # Simon J. Gerraty # RCSid: -# $Id: boot-strap,v 1.1.1.8 2010/05/13 18:37:40 joerg Exp $ +# $Id: boot-strap,v 1.1.1.9 2010/09/07 14:11:15 joerg Exp $ # # @(#) Copyright (c) 2001 Simon J. Gerraty # @@ -293,7 +293,9 @@ if [ -s "${mksrc:-/dev/null}/install-mk" ]; then *) MAKESYSPATH=".../mk:${MAKESYSPATH}";; esac fi -export MAKESYSPATH +# make sure test below uses the same diff that configure did +TOOL_DIFF=`type diff | sed 's,^[^/][^/]*,,;q'` +export MAKESYSPATH TOOL_DIFF if [ "$mksrc" ]; then $objdir/bmake test || exit 1 else diff --git a/devel/bmake/files/compat.c b/devel/bmake/files/compat.c index 7687fe5af22b..78ae80bc03bd 100644 --- a/devel/bmake/files/compat.c +++ b/devel/bmake/files/compat.c @@ -1,4 +1,4 @@ -/* $NetBSD: compat.c,v 1.78 2010/04/23 00:18:50 sjg Exp $ */ +/* $NetBSD: compat.c,v 1.80 2010/08/07 06:44:08 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -70,14 +70,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: compat.c,v 1.78 2010/04/23 00:18:50 sjg Exp $"; +static char rcsid[] = "$NetBSD: compat.c,v 1.80 2010/08/07 06:44:08 sjg Exp $"; #else #include #ifndef lint #if 0 static char sccsid[] = "@(#)compat.c 8.2 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: compat.c,v 1.78 2010/04/23 00:18:50 sjg Exp $"); +__RCSID("$NetBSD: compat.c,v 1.80 2010/08/07 06:44:08 sjg Exp $"); #endif #endif /* not lint */ #endif @@ -384,6 +384,8 @@ again: while (1) { while ((retstat = wait(&reason)) != cpid) { + if (retstat > 0) + JobReapChild(retstat, reason, FALSE); /* not ours? */ if (retstat == -1 && errno != EINTR) { break; } @@ -644,17 +646,17 @@ Compat_Run(Lst targs) Compat_Init(); - if (signal(SIGINT, SIG_IGN) != SIG_IGN) { - signal(SIGINT, CompatInterrupt); + if (bmake_signal(SIGINT, SIG_IGN) != SIG_IGN) { + bmake_signal(SIGINT, CompatInterrupt); } - if (signal(SIGTERM, SIG_IGN) != SIG_IGN) { - signal(SIGTERM, CompatInterrupt); + if (bmake_signal(SIGTERM, SIG_IGN) != SIG_IGN) { + bmake_signal(SIGTERM, CompatInterrupt); } - if (signal(SIGHUP, SIG_IGN) != SIG_IGN) { - signal(SIGHUP, CompatInterrupt); + if (bmake_signal(SIGHUP, SIG_IGN) != SIG_IGN) { + bmake_signal(SIGHUP, CompatInterrupt); } - if (signal(SIGQUIT, SIG_IGN) != SIG_IGN) { - signal(SIGQUIT, CompatInterrupt); + if (bmake_signal(SIGQUIT, SIG_IGN) != SIG_IGN) { + bmake_signal(SIGQUIT, CompatInterrupt); } ENDNode = Targ_FindNode(".END", TARG_CREATE); diff --git a/devel/bmake/files/job.c b/devel/bmake/files/job.c index a96a414622ae..e74831d5d9e7 100644 --- a/devel/bmake/files/job.c +++ b/devel/bmake/files/job.c @@ -1,4 +1,4 @@ -/* $NetBSD: job.c,v 1.149 2010/04/23 00:18:50 sjg Exp $ */ +/* $NetBSD: job.c,v 1.154 2010/08/07 21:28:40 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -70,14 +70,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: job.c,v 1.149 2010/04/23 00:18:50 sjg Exp $"; +static char rcsid[] = "$NetBSD: job.c,v 1.154 2010/08/07 21:28:40 sjg Exp $"; #else #include #ifndef lint #if 0 static char sccsid[] = "@(#)job.c 8.2 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: job.c,v 1.149 2010/04/23 00:18:50 sjg Exp $"); +__RCSID("$NetBSD: job.c,v 1.154 2010/08/07 21:28:40 sjg Exp $"); #endif #endif /* not lint */ #endif @@ -357,7 +357,7 @@ static sigset_t caught_signals; /* Set of signals we handle */ static void JobChildSig(int); static void JobContinueSig(int); -static Job *JobFindPid(int, int); +static Job *JobFindPid(int, int, Boolean); static int JobPrintCommand(void *, void *); static int JobSaveCommand(void *, void *); static void JobClose(Job *); @@ -629,7 +629,7 @@ JobPassSig_suspend(int signo) *----------------------------------------------------------------------- */ static Job * -JobFindPid(int pid, int status) +JobFindPid(int pid, int status, Boolean isJobs) { Job *job; @@ -637,7 +637,7 @@ JobFindPid(int pid, int status) if ((job->job_state == status) && job->pid == pid) return job; } - if (DEBUG(JOB)) + if (DEBUG(JOB) && isJobs) job_table_dump("no pid"); return NULL; } @@ -726,6 +726,7 @@ JobPrintCommand(void *cmdp, void *jobp) shutUp = DEBUG(LOUD) ? FALSE : TRUE; break; case '-': + job->flags |= JOB_IGNERR; errOff = TRUE; break; case '+': @@ -774,7 +775,7 @@ JobPrintCommand(void *cmdp, void *jobp) } if (errOff) { - if ( !(job->flags & JOB_IGNERR) && !noSpecials) { + if (!noSpecials) { if (commandShell->hasErrCtl) { /* * we don't want the error-control commands showing @@ -1032,9 +1033,12 @@ JobFinish (Job *job, WAIT_T status) (void)printf("*** [%s] Error code %d%s\n", job->node->name, WEXITSTATUS(status), - (job->flags & JOB_IGNERR) ? "(ignored)" : ""); - if (job->flags & JOB_IGNERR) + (job->flags & JOB_IGNERR) ? " (ignored)" : ""); + if (job->flags & JOB_IGNERR) { WAIT_STATUS(status) = 0; + } else { + PrintOnError(job->node, NULL); + } } else if (DEBUG(JOB)) { if (job->node != lastNode) { MESSAGE(stdout, job->node); @@ -1243,11 +1247,11 @@ Job_CheckCommands(GNode *gn, void (*abortProc)(const char *, ...)) } if (gn->type & OP_OPTIONAL) { - (void)fprintf(stdout, "%s%s %s(ignored)\n", progname, + (void)fprintf(stdout, "%s%s %s (ignored)\n", progname, msg, gn->name); (void)fflush(stdout); } else if (keepgoing) { - (void)fprintf(stdout, "%s%s %s(continuing)\n", progname, + (void)fprintf(stdout, "%s%s %s (continuing)\n", progname, msg, gn->name); (void)fflush(stdout); return FALSE; @@ -1563,6 +1567,7 @@ JobStart(GNode *gn, int flags) * also dead... */ if (!cmdsOK) { + PrintOnError(gn, NULL); /* provide some clue */ DieHorribly(); } @@ -1937,7 +1942,6 @@ void Job_CatchChildren(void) { int pid; /* pid of dead child */ - Job *job; /* job descriptor for dead child */ WAIT_T status; /* Exit/termination status */ /* @@ -1951,41 +1955,60 @@ Job_CatchChildren(void) (void)fprintf(debug_file, "Process %d exited/stopped status %x.\n", pid, WAIT_STATUS(status)); } + JobReapChild(pid, status, TRUE); + } +} + +/* + * It is possible that wait[pid]() was called from elsewhere, + * this lets us reap jobs regardless. + */ +void +JobReapChild(pid_t pid, WAIT_T status, Boolean isJobs) +{ + Job *job; /* job descriptor for dead child */ + + /* + * Don't even bother if we know there's no one around. + */ + if (jobTokensRunning == 0) + return; - job = JobFindPid(pid, JOB_ST_RUNNING); - if (job == NULL) { + job = JobFindPid(pid, JOB_ST_RUNNING, isJobs); + if (job == NULL) { + if (isJobs) { if (!lurking_children) Error("Child (%d) status %x not in table?", pid, status); - continue; } - if (WIFSTOPPED(status)) { - if (DEBUG(JOB)) { - (void)fprintf(debug_file, "Process %d (%s) stopped.\n", - job->pid, job->node->name); - } - if (!make_suspended) { - switch (WSTOPSIG(status)) { - case SIGTSTP: - (void)printf("*** [%s] Suspended\n", job->node->name); - break; - case SIGSTOP: - (void)printf("*** [%s] Stopped\n", job->node->name); - break; - default: - (void)printf("*** [%s] Stopped -- signal %d\n", - job->node->name, WSTOPSIG(status)); - } - job->job_suspended = 1; + return; /* not ours */ + } + if (WIFSTOPPED(status)) { + if (DEBUG(JOB)) { + (void)fprintf(debug_file, "Process %d (%s) stopped.\n", + job->pid, job->node->name); + } + if (!make_suspended) { + switch (WSTOPSIG(status)) { + case SIGTSTP: + (void)printf("*** [%s] Suspended\n", job->node->name); + break; + case SIGSTOP: + (void)printf("*** [%s] Stopped\n", job->node->name); + break; + default: + (void)printf("*** [%s] Stopped -- signal %d\n", + job->node->name, WSTOPSIG(status)); } - (void)fflush(stdout); - continue; + job->job_suspended = 1; } + (void)fflush(stdout); + return; + } - job->job_state = JOB_ST_FINISHED; - job->exit_status = WAIT_STATUS(status); + job->job_state = JOB_ST_FINISHED; + job->exit_status = WAIT_STATUS(status); - JobFinish(job, status); - } + JobFinish(job, status); } /*- @@ -2185,13 +2208,13 @@ Job_Init(void) /* * Install a SIGCHLD handler. */ - (void)signal(SIGCHLD, JobChildSig); + (void)bmake_signal(SIGCHLD, JobChildSig); sigaddset(&caught_signals, SIGCHLD); #define ADDSIG(s,h) \ - if (signal(s, SIG_IGN) != SIG_IGN) { \ + if (bmake_signal(s, SIG_IGN) != SIG_IGN) { \ sigaddset(&caught_signals, s); \ - (void)signal(s, h); \ + (void)bmake_signal(s, h); \ } /* @@ -2232,7 +2255,7 @@ static void JobSigReset(void) { #define DELSIG(s) \ if (sigismember(&caught_signals, s)) { \ - (void)signal(s, SIG_DFL); \ + (void)bmake_signal(s, SIG_DFL); \ } DELSIG(SIGINT) @@ -2245,7 +2268,7 @@ static void JobSigReset(void) DELSIG(SIGWINCH) DELSIG(SIGCONT) #undef DELSIG - (void)signal(SIGCHLD, SIG_DFL); + (void)bmake_signal(SIGCHLD, SIG_DFL); } /*- diff --git a/devel/bmake/files/main.c b/devel/bmake/files/main.c index 6f5d4ddb42ce..a6ad0b0542a1 100644 --- a/devel/bmake/files/main.c +++ b/devel/bmake/files/main.c @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.186 2010/05/10 15:54:21 sjg Exp $ */ +/* $NetBSD: main.c,v 1.189 2010/08/07 06:44:08 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,7 +69,7 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: main.c,v 1.186 2010/05/10 15:54:21 sjg Exp $"; +static char rcsid[] = "$NetBSD: main.c,v 1.189 2010/08/07 06:44:08 sjg Exp $"; #else #include #ifndef lint @@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\ #if 0 static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: main.c,v 1.186 2010/05/10 15:54:21 sjg Exp $"); +__RCSID("$NetBSD: main.c,v 1.189 2010/08/07 06:44:08 sjg Exp $"); #endif #endif /* not lint */ #endif @@ -812,7 +812,7 @@ main(int argc, char **argv) debug_file = stderr; #ifdef SIGINFO - (void)signal(SIGINFO, siginfo); + (void)bmake_signal(SIGINFO, siginfo); #endif /* * Set the seed to produce a different random sequence @@ -933,7 +933,22 @@ main(int argc, char **argv) * MFLAGS also gets initialized empty, for compatibility. */ Parse_Init(); - p1 = argv[0]; + if (argv[0][0] == '/' || strchr(argv[0], '/') == NULL) { + /* + * Leave alone if it is an absolute path, or if it does + * not contain a '/' in which case we need to find it in + * the path, like execvp(3) and the shells do. + */ + p1 = argv[0]; + } else { + /* + * A relative path, canonicalize it. + */ + p1 = realpath(argv[0], mdpath); + if (!p1 || *p1 != '/' || stat(p1, &sb) < 0) { + p1 = argv[0]; /* realpath failed */ + } + } Var_Set("MAKE", p1, VAR_GLOBAL, 0); Var_Set(".MAKE", p1, VAR_GLOBAL, 0); Var_Set(MAKEFLAGS, "", VAR_GLOBAL, 0); @@ -1680,9 +1695,10 @@ Cmd_Exec(const char *cmd, const char **errnum) /* * Wait for the process to exit. */ - while(((pid = waitpid(cpid, &status, 0)) != cpid) && (pid >= 0)) + while(((pid = waitpid(cpid, &status, 0)) != cpid) && (pid >= 0)) { + JobReapChild(pid, status, FALSE); continue; - + } cc = Buf_Size(&buf); res = Buf_Destroy(&buf, FALSE); diff --git a/devel/bmake/files/make.1 b/devel/bmake/files/make.1 index 5e08e74a4aba..1b89391d5856 100644 --- a/devel/bmake/files/make.1 +++ b/devel/bmake/files/make.1 @@ -1,4 +1,4 @@ -.\" $NetBSD: make.1,v 1.171 2010/04/22 19:15:23 sjg Exp $ +.\" $NetBSD: make.1,v 1.179 2010/06/30 01:03:54 dholland Exp $ .\" .\" Copyright (c) 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" from: @(#)make.1 8.4 (Berkeley) 3/19/94 .\" -.Dd April 21, 2010 +.Dd June 30, 2010 .Dt MAKE 1 .Os .Sh NAME @@ -536,11 +536,48 @@ If the result of expanding a variable contains a dollar sign .Pq Ql \&$ the string is expanded again. .Pp -Variable substitution occurs at two distinct times, depending on where +Variable substitution occurs at three distinct times, depending on where the variable is being used. +.Bl -enum +.It Variables in dependency lines are expanded as the line is read. +.It Variables in shell commands are expanded when the shell command is executed. +.It +.Dq .for +loop index variables are expanded on each loop iteration. +Note that other variables are not expanded inside loops so +the following example code: +.Bd -literal -offset indent + +.Dv .for i in 1 2 3 +a+= ${i} +j= ${i} +b+= ${j} +.Dv .endfor + +all: + @echo ${a} + @echo ${b} + +.Ed +will print: +.Bd -literal -offset indent +1 2 3 +3 3 3 + +.Ed +Because while ${a} contains +.Dq 1 2 3 +after the loop is executed, ${b} +contains +.Dq ${j} ${j} ${j} +which expands to +.Dq 3 3 3 +since after the loop completes ${j} contains +.Dq 3 . +.El .Ss Variable classes The four different classes of variables (in order of increasing precedence) are: @@ -576,7 +613,7 @@ The list of sources for this target that were deemed out-of-date; also known as .Ql Va \&? . .It Va .PREFIX -The file prefix of the file, containing only the file portion, no suffix +The file prefix of the target, containing only the file portion, no suffix or preceding directory components; also known as .Ql Va * . .It Va .TARGET @@ -660,7 +697,7 @@ from which generated dependencies are read. The list of variables exported by .Nm . .It Va .MAKE.JOBS -The argument to the +The argument to the .Fl j option. .It Va .MAKE.JOB.PREFIX @@ -791,8 +828,10 @@ is set in the environment or on the command line.) .Pp Variable expansion is performed on the value before it's used, so expressions such as -.Dl ${.CURDIR:C,^/usr/src,/var/obj,} +.Dl ${.CURDIR:S,^/usr/src,/var/obj,} may be used. +This is especially useful with +.Ql Ev MAKEOBJDIR . .Pp .Ql Va .OBJDIR may be modified in the makefile as a global variable. @@ -853,6 +892,8 @@ is set to the value of for all programs which .Nm executes. +.It Ev .TARGETS +The list of targets explicitly specified on the command line, if any. .It Ev VPATH Colon-separated .Pq Dq \&: @@ -902,7 +943,7 @@ The standard shell wildcard characters .Pf ( Ql * , .Ql \&? , and -.Ql Op ) +.Ql Oo Oc ) may be used. The wildcard characters may be escaped with a backslash @@ -1320,6 +1361,15 @@ flag, so should be used with caution. Appending a variable name to .Va .MAKE.EXPORTED is equivalent to exporting a variable. +.It Ic .export-env Ar variable ... +The same as +.Ql .export , +except that the variable is not appended to +.Va .MAKE.EXPORTED . +This allows exporting a value to the environment which is different from that +used by +.Nm +internally. .It Ic .info Ar message The message is printed along with the name of the makefile and line number. .It Ic .undef Ar variable @@ -1582,6 +1632,9 @@ correspond to an actual file; it is always considered to be out of date, and will not be created with the .Fl t option. +Suffix-transformation rules are not applied to +.Ic .PHONY +targets. .It Ic .PRECIOUS When .Nm diff --git a/devel/bmake/files/make.c b/devel/bmake/files/make.c index 11e2ca8cba3a..d5052793910d 100644 --- a/devel/bmake/files/make.c +++ b/devel/bmake/files/make.c @@ -1,4 +1,4 @@ -/* $NetBSD: make.c,v 1.79 2010/04/07 00:11:27 sjg Exp $ */ +/* $NetBSD: make.c,v 1.81 2010/07/06 03:56:59 dholland Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: make.c,v 1.79 2010/04/07 00:11:27 sjg Exp $"; +static char rcsid[] = "$NetBSD: make.c,v 1.81 2010/07/06 03:56:59 dholland Exp $"; #else #include #ifndef lint #if 0 static char sccsid[] = "@(#)make.c 8.1 (Berkeley) 6/6/93"; #else -__RCSID("$NetBSD: make.c,v 1.79 2010/04/07 00:11:27 sjg Exp $"); +__RCSID("$NetBSD: make.c,v 1.81 2010/07/06 03:56:59 dholland Exp $"); #endif #endif /* not lint */ #endif diff --git a/devel/bmake/files/nonints.h b/devel/bmake/files/nonints.h index da6100ee1fc6..6ba9c3a51ed0 100644 --- a/devel/bmake/files/nonints.h +++ b/devel/bmake/files/nonints.h @@ -1,4 +1,4 @@ -/* $NetBSD: nonints.h,v 1.58 2010/04/07 00:11:27 sjg Exp $ */ +/* $NetBSD: nonints.h,v 1.60 2010/08/07 06:44:08 sjg Exp $ */ /*- * Copyright (c) 1988, 1989, 1990, 1993 @@ -106,6 +106,11 @@ int For_Eval(char *); int For_Accum(char *); void For_Run(int); +/* job.c */ +#ifdef WAIT_T +void JobReapChild(pid_t, WAIT_T, Boolean); +#endif + /* main.c */ void Main_ParseArgLine(const char *); void MakeMode(const char *); @@ -195,3 +200,6 @@ void Var_Dump(GNode *); void Var_ExportVars(void); void Var_Export(char *, int); void Var_UnExport(char *); + +/* util.c */ +void (*bmake_signal(int, void (*)(int)))(int); diff --git a/devel/bmake/files/os.sh b/devel/bmake/files/os.sh index 545986b2da73..487ebfb943eb 100644 --- a/devel/bmake/files/os.sh +++ b/devel/bmake/files/os.sh @@ -17,7 +17,7 @@ # Simon J. Gerraty # RCSid: -# $Id: os.sh,v 1.1.1.5 2010/04/20 13:32:18 joerg Exp $ +# $Id: os.sh,v 1.1.1.6 2010/09/07 14:11:15 joerg Exp $ # # @(#) Copyright (c) 1994 Simon J. Gerraty # @@ -41,6 +41,12 @@ OSMAJOR=`IFS=.; set $OSREL; echo $1` MACHINE=`uname -m` MACHINE_ARCH=`uname -p 2>/dev/null || echo $MACHINE` +# there is at least one case of `uname -p` outputting +# a bunch of usless drivel +case "$MACHINE_ARCH" in +*[!A-Za-z0-9_-]*) MACHINE_ARCH="$MACHINE";; +esac + # we need this here, and it is not always available... Which() { case "$1" in diff --git a/devel/bmake/files/parse.c b/devel/bmake/files/parse.c index 2f35d364b3f8..7c6538e096f3 100644 --- a/devel/bmake/files/parse.c +++ b/devel/bmake/files/parse.c @@ -1,4 +1,4 @@ -/* $NetBSD: parse.c,v 1.163 2010/04/29 23:12:21 sjg Exp $ */ +/* $NetBSD: parse.c,v 1.164 2010/05/24 21:04:49 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: parse.c,v 1.163 2010/04/29 23:12:21 sjg Exp $"; +static char rcsid[] = "$NetBSD: parse.c,v 1.164 2010/05/24 21:04:49 sjg Exp $"; #else #include #ifndef lint #if 0 static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: parse.c,v 1.163 2010/04/29 23:12:21 sjg Exp $"); +__RCSID("$NetBSD: parse.c,v 1.164 2010/05/24 21:04:49 sjg Exp $"); #endif #endif /* not lint */ #endif @@ -510,11 +510,11 @@ Parse_Error(int type, const char *fmt, ...) * variables, print the message and exit(1) (for .error) or just print * a warning if the directive is malformed. */ -static void +static Boolean ParseMessage(char *line) { int mtype; - + switch(*line) { case 'i': mtype = 0; @@ -527,11 +527,13 @@ ParseMessage(char *line) break; default: Parse_Error(PARSE_WARNING, "invalid syntax: \".%s\"", line); - return; + return FALSE; } - while (!isspace((u_char)*line)) + while (isalpha((u_char)*line)) line++; + if (!isspace((u_char)*line)) + return FALSE; /* not for us */ while (isspace((u_char)*line)) line++; @@ -543,6 +545,7 @@ ParseMessage(char *line) /* Terminate immediately. */ exit(1); } + return TRUE; } /*- @@ -2567,8 +2570,8 @@ Parse_File(const char *name, int fd) } else if (strncmp(cp, "info", 4) == 0 || strncmp(cp, "error", 5) == 0 || strncmp(cp, "warning", 7) == 0) { - ParseMessage(cp); - continue; + if (ParseMessage(cp)) + continue; } } diff --git a/devel/bmake/files/unit-tests/Makefile.in b/devel/bmake/files/unit-tests/Makefile.in index 26924a07e7cc..b17f0ad1c136 100644 --- a/devel/bmake/files/unit-tests/Makefile.in +++ b/devel/bmake/files/unit-tests/Makefile.in @@ -1,4 +1,4 @@ -# $Id: Makefile.in,v 1.1.1.7 2010/04/24 20:34:05 joerg Exp $ +# $Id: Makefile.in,v 1.1.1.8 2010/09/07 14:12:27 joerg Exp $ # # $NetBSD: Makefile,v 1.28 2010/04/22 21:41:11 sjg Exp $ # @@ -62,6 +62,8 @@ clean: TEST_MAKE?= ${.MAKE} TOOL_SED?= sed TOOL_TR?= tr +TOOL_DIFF?= diff +DIFF_FLAGS?= @diff_u@ # ensure consistent results from sort(1) LANG= C @@ -85,7 +87,7 @@ test: -e 's,${.CURDIR:C/\./\\\./g}/,,g' \ -e 's,${UNIT_TESTS:C/\./\\\./g}/,,g' > ${.TARGET}.out || { \ tail ${.TARGET}.out; mv ${.TARGET}.out ${.TARGET}.fail; exit 1; } - diff @diff_u@ ${UNIT_TESTS}/${.TARGET}.exp ${.TARGET}.out + ${TOOL_DIFF} ${DIFF_FLAGS} ${UNIT_TESTS}/${.TARGET}.exp ${.TARGET}.out accept: mv test.out ${srcdir}/test.exp diff --git a/devel/bmake/files/unit-tests/error b/devel/bmake/files/unit-tests/error index 364c35ad1048..095a652ec78f 100644 --- a/devel/bmake/files/unit-tests/error +++ b/devel/bmake/files/unit-tests/error @@ -1,6 +1,10 @@ -# $Id: error,v 1.1.1.1 2010/04/20 13:32:42 joerg Exp $ +# $Id: error,v 1.1.1.2 2010/09/07 14:12:27 joerg Exp $ .info just FYI .warning this could be serious .error this is fatal +all: + +.info.html: + @echo this should be ignored diff --git a/devel/bmake/files/util.c b/devel/bmake/files/util.c index 0c9d39be1b05..523ba1b609a4 100644 --- a/devel/bmake/files/util.c +++ b/devel/bmake/files/util.c @@ -1,23 +1,24 @@ -/* $NetBSD: util.c,v 1.49 2010/05/05 07:05:33 sjg Exp $ */ +/* $NetBSD: util.c,v 1.50 2010/06/03 15:40:16 sjg Exp $ */ /* * Missing stuff from OS's * - * $Id: util.c,v 1.1.1.7 2010/05/13 18:37:58 joerg Exp $ + * $Id: util.c,v 1.1.1.8 2010/09/07 14:12:10 joerg Exp $ */ #include "make.h" #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: util.c,v 1.49 2010/05/05 07:05:33 sjg Exp $"; +static char rcsid[] = "$NetBSD: util.c,v 1.50 2010/06/03 15:40:16 sjg Exp $"; #else #ifndef lint -__RCSID("$NetBSD: util.c,v 1.49 2010/05/05 07:05:33 sjg Exp $"); +__RCSID("$NetBSD: util.c,v 1.50 2010/06/03 15:40:16 sjg Exp $"); #endif #endif #include #include +#include #if !defined(HAVE_STRERROR) extern int errno, sys_nerr; @@ -235,24 +236,6 @@ random(void) } #endif -/* turn into bsd signals */ -void (* -signal(int s, void (*a)(int)))(int) -{ - struct sigvec osv, sv; - - (void)sigvector(s, NULL, &osv); - sv = osv; - sv.sv_handler = a; -#ifdef SV_BSDSIG - sv.sv_flags = SV_BSDSIG; -#endif - - if (sigvector(s, &sv, NULL) == -1) - return (BADSIG); - return (osv.sv_handler); -} - #if !defined(__hpux__) && !defined(__hpux) int utimes(char *file, struct timeval tvp[2]) @@ -385,17 +368,9 @@ getcwd(path, sz) } #endif -#if !defined(FORCE_POSIX_SIGNALS) -/* - * If FORCE_POSIX_SIGNALS is defined - * then sigcompat will have done this. - */ -#if defined(sun) && (defined(__svr4__) || defined(__SVR4)) -#include - -/* turn into bsd signals */ +/* force posix signals */ void (* -signal(int s, void (*a)(int)))(int) +bmake_signal(int s, void (*a)(int)))(int) { struct sigaction sa, osa; @@ -408,8 +383,6 @@ signal(int s, void (*a)(int)))(int) else return osa.sa_handler; } -#endif -#endif #if !defined(HAVE_VSNPRINTF) || !defined(HAVE_VASPRINTF) #include diff --git a/devel/bmake/files/var.c b/devel/bmake/files/var.c index 770e688f5c28..d644674c7acd 100644 --- a/devel/bmake/files/var.c +++ b/devel/bmake/files/var.c @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.158 2010/04/21 04:25:27 sjg Exp $ */ +/* $NetBSD: var.c,v 1.159 2010/06/06 01:13:12 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: var.c,v 1.158 2010/04/21 04:25:27 sjg Exp $"; +static char rcsid[] = "$NetBSD: var.c,v 1.159 2010/06/06 01:13:12 sjg Exp $"; #else #include #ifndef lint #if 0 static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: var.c,v 1.158 2010/04/21 04:25:27 sjg Exp $"); +__RCSID("$NetBSD: var.c,v 1.159 2010/06/06 01:13:12 sjg Exp $"); #endif #endif /* not lint */ #endif @@ -682,6 +682,7 @@ Var_Export(char *str, int isExport) char *val; char **av; char *as; + int track; int ac; int i; @@ -690,6 +691,12 @@ Var_Export(char *str, int isExport) return; } + if (strncmp(str, "-env", 4) == 0) { + track = 0; + str += 4; + } else { + track = VAR_EXPORT_PARENT; + } val = Var_Subst(NULL, str, VAR_GLOBAL, 0); av = brk_string(val, &ac, FALSE, &as); for (i = 0; i < ac; i++) { @@ -709,10 +716,10 @@ Var_Export(char *str, int isExport) continue; } } - if (Var_Export1(name, VAR_EXPORT_PARENT)) { + if (Var_Export1(name, track)) { if (VAR_EXPORTED_ALL != var_exportedVars) var_exportedVars = VAR_EXPORTED_YES; - if (isExport) { + if (isExport && track) { Var_Append(MAKE_EXPORTED, name, VAR_GLOBAL); } } -- 2.41.0