From owner-svn-src-head@FreeBSD.ORG Tue Apr 2 21:31:15 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 8F9DF617; Tue, 2 Apr 2013 21:31:15 +0000 (UTC) (envelope-from sjg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 7EA99CD6; Tue, 2 Apr 2013 21:31:15 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r32LVFZV058868; Tue, 2 Apr 2013 21:31:15 GMT (envelope-from sjg@svn.freebsd.org) Received: (from sjg@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r32LVBtO058844; Tue, 2 Apr 2013 21:31:11 GMT (envelope-from sjg@svn.freebsd.org) Message-Id: <201304022131.r32LVBtO058844@svn.freebsd.org> From: "Simon J. Gerraty" Date: Tue, 2 Apr 2013 21:31:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r249033 - in head: contrib/bmake contrib/bmake/mk contrib/bmake/unit-tests usr.bin/bmake usr.bin/bmake/unit-tests X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Apr 2013 21:31:15 -0000 Author: sjg Date: Tue Apr 2 21:31:11 2013 New Revision: 249033 URL: http://svnweb.freebsd.org/changeset/base/249033 Log: Update to bmake-20130330 Added: head/contrib/bmake/unit-tests/export-env - copied unchanged from r248991, vendor/NetBSD/bmake/dist/unit-tests/export-env Modified: head/contrib/bmake/ChangeLog head/contrib/bmake/FILES head/contrib/bmake/Makefile head/contrib/bmake/bmake.1 head/contrib/bmake/bmake.cat1 head/contrib/bmake/boot-strap head/contrib/bmake/configure head/contrib/bmake/configure.in head/contrib/bmake/dir.c head/contrib/bmake/job.c head/contrib/bmake/job.h head/contrib/bmake/main.c head/contrib/bmake/make.1 head/contrib/bmake/make.h head/contrib/bmake/meta.c head/contrib/bmake/meta.h head/contrib/bmake/mk/ChangeLog head/contrib/bmake/mk/dirdeps.mk head/contrib/bmake/mk/gendirdeps.mk head/contrib/bmake/mk/install-mk head/contrib/bmake/mk/meta.stage.mk head/contrib/bmake/mk/meta2deps.py head/contrib/bmake/mk/meta2deps.sh head/contrib/bmake/mk/sys.dependfile.mk head/contrib/bmake/parse.c head/contrib/bmake/unit-tests/Makefile.in head/contrib/bmake/unit-tests/test.exp head/contrib/bmake/var.c head/usr.bin/bmake/Makefile head/usr.bin/bmake/config.h head/usr.bin/bmake/unit-tests/Makefile Directory Properties: head/contrib/bmake/ (props changed) Modified: head/contrib/bmake/ChangeLog ============================================================================== --- head/contrib/bmake/ChangeLog Tue Apr 2 19:39:31 2013 (r249032) +++ head/contrib/bmake/ChangeLog Tue Apr 2 21:31:11 2013 (r249033) @@ -1,3 +1,47 @@ +2013-03-30 Simon J. Gerraty + + * Makefile (MAKE_VERSION): 20130330 + Merge with NetBSD make, pick up + o meta.c: refine the handling of .OODATE in commands. + Rather than suppress command comparison for the entire script + as though .NOMETA_CMP had been used, only suppress it for the + one command line. + This allows something like ${.OODATE:M.NOMETA_CMP} to be used to + suppress comparison of a command without otherwise affecting it. + o make.1: document that + +2013-03-22 Simon J. Gerraty + + * Makefile (MAKE_VERSION): 20130321 + yes, not quite right but its a cooler number. + Merge with NetBSD make, pick up + o parse.c: fix ParseGmakeExport to be portable + and add a unit-test. + * meta.c: call meta_init() before makefiles are read and if built + with filemon support set .MAKE.PATH_FILEMON to _PATH_FILEMON + this let's makefiles test for support. + Call meta_mode_init() to process .MAKE.MODE. + +2013-03-13 Simon J. Gerraty + + * Makefile (MAKE_VERSION): 20130305 + Merge with NetBSD make, pick up + o run .STALE: target when a dependency from .depend is missing. + o job.c: add Job_RunTarget() for the above and .BEGIN + +2013-03-03 Simon J. Gerraty + + * Makefile (MAKE_VERSION): 20130303 + Merge with NetBSD make, pick up + o main.c: set .MAKE.OS to utsname.sysname + o job.c: more checks for read and poll errors + o var.c: lose VarChangeCase() saves 4% time + +2013-03-02 Simon J. Gerraty + + * boot-strap: remove MAKEOBJDIRPREFIX from environment since we + want to use MAKEOBJDIR + 2013-01-27 Simon J. Gerraty * Merge with NetBSD make, pick up Modified: head/contrib/bmake/FILES ============================================================================== --- head/contrib/bmake/FILES Tue Apr 2 19:39:31 2013 (r249032) +++ head/contrib/bmake/FILES Tue Apr 2 21:31:11 2013 (r249033) @@ -102,6 +102,7 @@ unit-tests/dotwait unit-tests/error unit-tests/export unit-tests/export-all +unit-tests/export-env unit-tests/forloop unit-tests/forsubst unit-tests/hash Modified: head/contrib/bmake/Makefile ============================================================================== --- head/contrib/bmake/Makefile Tue Apr 2 19:39:31 2013 (r249032) +++ head/contrib/bmake/Makefile Tue Apr 2 21:31:11 2013 (r249033) @@ -1,7 +1,7 @@ -# $Id: Makefile,v 1.5 2013/01/28 19:31:58 sjg Exp $ +# $Id: Makefile,v 1.10 2013/03/31 05:57:19 sjg Exp $ # Base version on src date -MAKE_VERSION= 20130123 +MAKE_VERSION= 20130330 PROG= bmake @@ -187,14 +187,14 @@ MANDIR= ${SHAREDIR}/man .if !exists(.depend) ${OBJS}: config.h .endif -.if ${MK_AUTOCONF_MK} == "yes" -.include -.endif # make sure that MAKE_VERSION gets updated. main.o: ${SRCS} ${MAKEFILE} # start-delete2 for bsd.after-import.mk +.if ${MK_AUTOCONF_MK} == "yes" +.include +.endif SHARE_MK?=${SHAREDIR}/mk MKSRC=${srcdir}/mk INSTALL?=${srcdir}/install-sh Modified: head/contrib/bmake/bmake.1 ============================================================================== --- head/contrib/bmake/bmake.1 Tue Apr 2 19:39:31 2013 (r249032) +++ head/contrib/bmake/bmake.1 Tue Apr 2 21:31:11 2013 (r249033) @@ -1,4 +1,4 @@ -.\" $NetBSD: make.1,v 1.210 2013/01/27 18:52:01 sjg Exp $ +.\" $NetBSD: make.1,v 1.213 2013/03/31 05:49:51 sjg 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 January 23, 2013 +.Dd March 30, 2013 .Dt MAKE 1 .Os .Sh NAME @@ -874,6 +874,13 @@ by appending their names to is re-exported whenever .Ql Va .MAKEOVERRIDES is modified. +.It Va .MAKE.PATH_FILEMON +If +.Nm +was built with +.Xr filemon 4 +support, this is set to the path of the device node. +This allows makefiles to test for this support. .It Va .MAKE.PID The process-id of .Nm . @@ -1757,6 +1764,20 @@ targets. Ignore differences in commands when deciding if target is out of date. This is useful if the command contains a value which always changes. If the number of commands change, though, the target will still be out of date. +The same effect applies to any command line that uses the variable +.Va .OODATE , +which can be used for that purpose even when not otherwise needed or desired: +.Bd -literal -offset indent + +skip-compare-for-some: + @echo this will be compared + @echo this will not ${.OODATE:M.NOMETA_CMP} + @echo this will also be compared + +.Ed +The +.Cm \&:M +pattern suppresses any expansion of the unwanted variable. .It Ic .NOPATH Do not search for the target in the directories specified by .Ic .PATH . @@ -2008,6 +2029,10 @@ If no sources are specified, the .Ic .SILENT attribute is applied to every command in the file. +.It Ic .STALE +This target gets run when a dependency file contains stale entries, having +.Va .ALLSRC +set to the name of that dependency file. .It Ic .SUFFIXES Each source specifies a suffix to .Nm . Modified: head/contrib/bmake/bmake.cat1 ============================================================================== --- head/contrib/bmake/bmake.cat1 Tue Apr 2 19:39:31 2013 (r249032) +++ head/contrib/bmake/bmake.cat1 Tue Apr 2 21:31:11 2013 (r249033) @@ -565,6 +565,11 @@ VVAARRIIAABBLLEE AASSSSIIGG `MAKEFLAGS' is re-exported whenever `_._M_A_K_E_O_V_E_R_R_I_D_E_S' is modified. + _._M_A_K_E_._P_A_T_H___F_I_L_E_M_O_N + If bbmmaakkee was built with filemon(4) support, this is set + to the path of the device node. This allows makefiles to + test for this support. + _._M_A_K_E_._P_I_D The process-id of bbmmaakkee. _._M_A_K_E_._P_P_I_D The parent process-id of bbmmaakkee. @@ -1106,7 +1111,19 @@ SSPPEECCIIAALL SSOOUURRCCEE Ignore differences in commands when deciding if target is out of date. This is useful if the command contains a value which always changes. If the number of commands change, though, the - target will still be out of date. + target will still be out of date. The same effect applies to + any command line that uses the variable _._O_O_D_A_T_E, which can be + used for that purpose even when not otherwise needed or + desired: + + + skip-compare-for-some: + @echo this will be compared + @echo this will not ${.OODATE:M.NOMETA_CMP} + @echo this will also be compared + + The ::MM pattern suppresses any expansion of the unwanted vari- + able. ..NNOOPPAATTHH Do not search for the target in the directories specified by ..PPAATTHH. @@ -1278,6 +1295,9 @@ SSPPEECCIIAALL TTAARRGGEETT sources are specified, the ..SSIILLEENNTT attribute is applied to every command in the file. + ..SSTTAALLEE This target gets run when a dependency file contains stale + entries, having _._A_L_L_S_R_C set to the name of that dependency file. + ..SSUUFFFFIIXXEESS Each source specifies a suffix to bbmmaakkee. If no sources are specified, any previously specified suffixes are deleted. It @@ -1340,4 +1360,4 @@ BBUUGGSS There is no way of escaping a space character in a filename. -NetBSD 5.1 January 23, 2013 NetBSD 5.1 +NetBSD 5.1 March 30, 2013 NetBSD 5.1 Modified: head/contrib/bmake/boot-strap ============================================================================== --- head/contrib/bmake/boot-strap Tue Apr 2 19:39:31 2013 (r249032) +++ head/contrib/bmake/boot-strap Tue Apr 2 21:31:11 2013 (r249033) @@ -111,7 +111,7 @@ # Simon J. Gerraty # RCSid: -# $Id: boot-strap,v 1.42 2013/01/25 20:20:33 sjg Exp $ +# $Id: boot-strap,v 1.43 2013/03/02 18:55:23 sjg Exp $ # # @(#) Copyright (c) 2001 Simon J. Gerraty # @@ -159,6 +159,9 @@ source_rc() { cmd_args="$@" +# clear some things from the environment that we care about +unset MAKEOBJDIR MAKEOBJDIRPREFIX + # --install[-host-target] will set this INSTALL_PREFIX= # other things we pass to install step Modified: head/contrib/bmake/configure ============================================================================== Binary file (source and/or target). No diff available. Modified: head/contrib/bmake/configure.in ============================================================================== --- head/contrib/bmake/configure.in Tue Apr 2 19:39:31 2013 (r249032) +++ head/contrib/bmake/configure.in Tue Apr 2 21:31:11 2013 (r249033) @@ -1,10 +1,10 @@ dnl dnl RCSid: -dnl $Id: configure.in,v 1.46 2012/12/28 21:28:18 sjg Exp $ +dnl $Id: configure.in,v 1.48 2013/03/04 21:25:57 sjg Exp $ dnl dnl Process this file with autoconf to produce a configure script dnl -AC_INIT([bmake], [20121212], [sjg@NetBSD.org]) +AC_INIT([bmake], [20130303], [sjg@NetBSD.org]) AC_CONFIG_HEADER(config.h) dnl make srcdir absolute Modified: head/contrib/bmake/dir.c ============================================================================== --- head/contrib/bmake/dir.c Tue Apr 2 19:39:31 2013 (r249032) +++ head/contrib/bmake/dir.c Tue Apr 2 21:31:11 2013 (r249033) @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.65 2012/06/12 19:21:50 joerg Exp $ */ +/* $NetBSD: dir.c,v 1.67 2013/03/05 22:01:43 christos Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -70,14 +70,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: dir.c,v 1.65 2012/06/12 19:21:50 joerg Exp $"; +static char rcsid[] = "$NetBSD: dir.c,v 1.67 2013/03/05 22:01:43 christos Exp $"; #else #include #ifndef lint #if 0 static char sccsid[] = "@(#)dir.c 8.2 (Berkeley) 1/2/94"; #else -__RCSID("$NetBSD: dir.c,v 1.65 2012/06/12 19:21:50 joerg Exp $"); +__RCSID("$NetBSD: dir.c,v 1.67 2013/03/05 22:01:43 christos Exp $"); #endif #endif /* not lint */ #endif @@ -145,6 +145,7 @@ __RCSID("$NetBSD: dir.c,v 1.65 2012/06/1 #include "make.h" #include "hash.h" #include "dir.h" +#include "job.h" /* * A search path consists of a Lst of Path structures. A Path structure @@ -1463,9 +1464,11 @@ Dir_MTime(GNode *gn, Boolean recheck) * so that we give that to the compiler. */ gn->path = bmake_strdup(fullName); - fprintf(stdout, - "%s: ignoring stale %s for %s, found %s\n", - progname, makeDependfile, gn->name, fullName); + if (!Job_RunTarget(".STALE", gn->fname)) + fprintf(stdout, + "%s: %s, %d: ignoring stale %s for %s, " + "found %s\n", progname, gn->fname, gn->lineno, + makeDependfile, gn->name, fullName); } } } Modified: head/contrib/bmake/job.c ============================================================================== --- head/contrib/bmake/job.c Tue Apr 2 19:39:31 2013 (r249032) +++ head/contrib/bmake/job.c Tue Apr 2 21:31:11 2013 (r249033) @@ -1,4 +1,4 @@ -/* $NetBSD: job.c,v 1.165 2013/01/26 15:52:59 christos Exp $ */ +/* $NetBSD: job.c,v 1.172 2013/03/05 22:01:43 christos 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.165 2013/01/26 15:52:59 christos Exp $"; +static char rcsid[] = "$NetBSD: job.c,v 1.172 2013/03/05 22:01:43 christos 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.165 2013/01/26 15:52:59 christos Exp $"); +__RCSID("$NetBSD: job.c,v 1.172 2013/03/05 22:01:43 christos Exp $"); #endif #endif /* not lint */ #endif @@ -142,6 +142,7 @@ __RCSID("$NetBSD: job.c,v 1.165 2013/01/ #include #include "wait.h" +#include #include #include #if !defined(USE_SELECT) && defined(HAVE_POLL_H) @@ -1245,8 +1246,10 @@ Job_CheckCommands(GNode *gn, void (*abor static const char msg[] = ": don't know how to make"; if (gn->flags & FROM_DEPEND) { - fprintf(stdout, "%s: ignoring stale %s for %s\n", - progname, makeDependfile, gn->name); + if (!Job_RunTarget(".STALE", gn->fname)) + fprintf(stdout, "%s: %s, %d: ignoring stale %s for %s\n", + progname, gn->fname, gn->lineno, makeDependfile, + gn->name); return TRUE; } @@ -2063,32 +2066,45 @@ Job_CatchOutput(void) (void)fflush(stdout); /* The first fd in the list is the job token pipe */ - nready = poll(fds + 1 - wantToken, nfds - 1 + wantToken, POLL_MSEC); + do { + nready = poll(fds + 1 - wantToken, nfds - 1 + wantToken, POLL_MSEC); + } while (nready < 0 && errno == EINTR); - if (nready < 0 || readyfd(&childExitJob)) { + if (nready < 0) + Punt("poll: %s", strerror(errno)); + + if (nready > 0 && readyfd(&childExitJob)) { char token = 0; - nready -= 1; - while (read(childExitJob.inPipe, &token, 1) == -1 && errno == EAGAIN) - continue; - if (token == DO_JOB_RESUME[0]) - /* Complete relay requested from our SIGCONT handler */ - JobRestartJobs(); - Job_CatchChildren(); + ssize_t count; + count = read(childExitJob.inPipe, &token, 1); + switch (count) { + case 0: + Punt("unexpected eof on token pipe"); + case -1: + Punt("token pipe read: %s", strerror(errno)); + case 1: + if (token == DO_JOB_RESUME[0]) + /* Complete relay requested from our SIGCONT handler */ + JobRestartJobs(); + break; + default: + abort(); + } + --nready; } - if (nready <= 0) - return; - - if (wantToken && readyfd(&tokenWaitJob)) - nready--; + Job_CatchChildren(); + if (nready == 0) + return; for (i = 2; i < nfds; i++) { if (!fds[i].revents) continue; job = jobfds[i]; - if (job->job_state != JOB_ST_RUNNING) - continue; - JobDoOutput(job, FALSE); + if (job->job_state == JOB_ST_RUNNING) + JobDoOutput(job, FALSE); + if (--nready == 0) + return; } } @@ -2179,8 +2195,6 @@ Job_SetPrefix(void) void Job_Init(void) { - GNode *begin; /* node for commands to do at the very start */ - /* Allocate space for all the job info */ job_table = bmake_malloc(maxJobs * sizeof *job_table); memset(job_table, 0, maxJobs * sizeof *job_table); @@ -2256,15 +2270,7 @@ Job_Init(void) ADDSIG(SIGCONT, JobContinueSig) #undef ADDSIG - begin = Targ_FindNode(".BEGIN", TARG_NOCREATE); - - if (begin != NULL) { - JobRun(begin); - if (begin->made == ERROR) { - PrintOnError(begin, "\n\nStop."); - exit(1); - } - } + (void)Job_RunTarget(".BEGIN", NULL); postCommands = Targ_FindNode(".END", TARG_CREATE); } @@ -2930,6 +2936,38 @@ Job_TokenWithdraw(void) return TRUE; } +/*- + *----------------------------------------------------------------------- + * Job_RunTarget -- + * Run the named target if found. If a filename is specified, then + * set that to the sources. + * + * Results: + * None + * + * Side Effects: + * exits if the target fails. + * + *----------------------------------------------------------------------- + */ +Boolean +Job_RunTarget(const char *target, const char *fname) { + GNode *gn = Targ_FindNode(target, TARG_NOCREATE); + + if (gn == NULL) + return FALSE; + + if (fname) + Var_Set(ALLSRC, fname, gn, 0); + + JobRun(gn); + if (gn->made == ERROR) { + PrintOnError(gn, "\n\nStop."); + exit(1); + } + return TRUE; +} + #ifdef USE_SELECT int emul_poll(struct pollfd *fd, int nfd, int timeout) Modified: head/contrib/bmake/job.h ============================================================================== --- head/contrib/bmake/job.h Tue Apr 2 19:39:31 2013 (r249032) +++ head/contrib/bmake/job.h Tue Apr 2 21:31:11 2013 (r249033) @@ -1,4 +1,4 @@ -/* $NetBSD: job.h,v 1.40 2010/09/13 15:36:57 sjg Exp $ */ +/* $NetBSD: job.h,v 1.41 2013/03/05 22:01:44 christos Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -268,5 +268,6 @@ void Job_TokenReturn(void); Boolean Job_TokenWithdraw(void); void Job_ServerStart(int, int, int); void Job_SetPrefix(void); +Boolean Job_RunTarget(const char *, const char *); #endif /* _JOB_H_ */ Modified: head/contrib/bmake/main.c ============================================================================== --- head/contrib/bmake/main.c Tue Apr 2 19:39:31 2013 (r249032) +++ head/contrib/bmake/main.c Tue Apr 2 21:31:11 2013 (r249033) @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.205 2013/01/26 15:53:00 christos Exp $ */ +/* $NetBSD: main.c,v 1.210 2013/03/23 05:31:29 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,7 +69,7 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: main.c,v 1.205 2013/01/26 15:53:00 christos Exp $"; +static char rcsid[] = "$NetBSD: main.c,v 1.210 2013/03/23 05:31:29 sjg Exp $"; #else #include #ifndef lint @@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19 #if 0 static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: main.c,v 1.205 2013/01/26 15:53:00 christos Exp $"); +__RCSID("$NetBSD: main.c,v 1.210 2013/03/23 05:31:29 sjg Exp $"); #endif #endif /* not lint */ #endif @@ -119,9 +119,7 @@ __RCSID("$NetBSD: main.c,v 1.205 2013/01 #include #include #include -#ifdef MAKE_NATIVE #include -#endif #include "wait.h" #include @@ -768,7 +766,7 @@ MakeMode(const char *mode) } #if USE_META if (strstr(mode, "meta")) - meta_init(mode); + meta_mode_init(mode); #endif } if (mp) @@ -813,9 +811,7 @@ main(int argc, char **argv) static char defsyspath[] = _PATH_DEFSYSPATH; char found_path[MAXPATHLEN + 1]; /* for searching for sys.mk */ struct timeval rightnow; /* to initialize random seed */ -#ifdef MAKE_NATIVE struct utsname utsname; -#endif /* default to writing debug to stderr */ debug_file = stderr; @@ -834,7 +830,7 @@ main(int argc, char **argv) progname++; else progname = argv[0]; -#ifdef RLIMIT_NOFILE +#if defined(MAKE_NATIVE) || (defined(HAVE_SETRLIMIT) && defined(RLIMIT_NOFILE)) /* * get rid of resource limit on file descriptors */ @@ -848,6 +844,12 @@ main(int argc, char **argv) } #endif + if (uname(&utsname) == -1) { + (void)fprintf(stderr, "%s: uname failed (%s).\n", progname, + strerror(errno)); + exit(2); + } + /* * Get the name of this type of MACHINE from utsname * so we can share an executable for similar machines. @@ -858,11 +860,6 @@ main(int argc, char **argv) */ if (!machine) { #ifdef MAKE_NATIVE - if (uname(&utsname) == -1) { - (void)fprintf(stderr, "%s: uname failed (%s).\n", progname, - strerror(errno)); - exit(2); - } machine = utsname.machine; #else #ifdef MAKE_MACHINE @@ -892,6 +889,7 @@ main(int argc, char **argv) */ Var_Init(); /* Initialize the lists of variables for * parsing arguments */ + Var_Set(".MAKE.OS", utsname.sysname, VAR_GLOBAL, 0); Var_Set("MACHINE", machine, VAR_GLOBAL, 0); Var_Set("MACHINE_ARCH", machine_arch, VAR_GLOBAL, 0); #ifdef MAKE_VERSION @@ -987,6 +985,9 @@ main(int argc, char **argv) } Job_SetPrefix(); +#ifdef USE_META + meta_init(); +#endif /* * First snag any flags out of the MAKE environment variable. * (Note this is *not* MAKEFLAGS since /bin/make uses that and it's @@ -1697,7 +1698,7 @@ Finish(int errors) } /* - * enunlink -- + * eunlink -- * Remove a file carefully, avoiding directories. */ int Modified: head/contrib/bmake/make.1 ============================================================================== --- head/contrib/bmake/make.1 Tue Apr 2 19:39:31 2013 (r249032) +++ head/contrib/bmake/make.1 Tue Apr 2 21:31:11 2013 (r249033) @@ -1,4 +1,4 @@ -.\" $NetBSD: make.1,v 1.210 2013/01/27 18:52:01 sjg Exp $ +.\" $NetBSD: make.1,v 1.213 2013/03/31 05:49:51 sjg 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 January 23, 2013 +.Dd March 30, 2013 .Dt MAKE 1 .Os .Sh NAME @@ -874,6 +874,13 @@ by appending their names to is re-exported whenever .Ql Va .MAKEOVERRIDES is modified. +.It Va .MAKE.PATH_FILEMON +If +.Nm +was built with +.Xr filemon 4 +support, this is set to the path of the device node. +This allows makefiles to test for this support. .It Va .MAKE.PID The process-id of .Nm . @@ -1757,6 +1764,20 @@ targets. Ignore differences in commands when deciding if target is out of date. This is useful if the command contains a value which always changes. If the number of commands change, though, the target will still be out of date. +The same effect applies to any command line that uses the variable +.Va .OODATE , +which can be used for that purpose even when not otherwise needed or desired: +.Bd -literal -offset indent + +skip-compare-for-some: + @echo this will be compared + @echo this will not ${.OODATE:M.NOMETA_CMP} + @echo this will also be compared + +.Ed +The +.Cm \&:M +pattern suppresses any expansion of the unwanted variable. .It Ic .NOPATH Do not search for the target in the directories specified by .Ic .PATH . @@ -2008,6 +2029,10 @@ If no sources are specified, the .Ic .SILENT attribute is applied to every command in the file. +.It Ic .STALE +This target gets run when a dependency file contains stale entries, having +.Va .ALLSRC +set to the name of that dependency file. .It Ic .SUFFIXES Each source specifies a suffix to .Nm . Modified: head/contrib/bmake/make.h ============================================================================== --- head/contrib/bmake/make.h Tue Apr 2 19:39:31 2013 (r249032) +++ head/contrib/bmake/make.h Tue Apr 2 21:31:11 2013 (r249033) @@ -1,4 +1,4 @@ -/* $NetBSD: make.h,v 1.89 2012/06/12 19:21:51 joerg Exp $ */ +/* $NetBSD: make.h,v 1.90 2013/02/25 01:57:14 dholland Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -103,7 +103,7 @@ ((__GNUC__ == (x) && __GNUC_MINOR__ >= (y)) || \ (__GNUC__ > (x))) #else /* defined(__GNUC__) */ -#define MAKE_GNUC_PREREQx, y) 0 +#define MAKE_GNUC_PREREQ(x, y) 0 #endif /* defined(__GNUC__) */ #if MAKE_GNUC_PREREQ(2, 7) Modified: head/contrib/bmake/meta.c ============================================================================== --- head/contrib/bmake/meta.c Tue Apr 2 19:39:31 2013 (r249032) +++ head/contrib/bmake/meta.c Tue Apr 2 21:31:11 2013 (r249033) @@ -1,4 +1,4 @@ -/* $NetBSD: meta.c,v 1.26 2013/01/19 04:23:37 sjg Exp $ */ +/* $NetBSD: meta.c,v 1.29 2013/03/31 05:49:51 sjg Exp $ */ /* * Implement 'meta' mode. @@ -539,8 +539,24 @@ boolValue(char *s) return TRUE; } +/* + * Initialization we need before reading makefiles. + */ +void +meta_init() +{ +#ifdef USE_FILEMON + /* this allows makefiles to test if we have filemon support */ + Var_Set(".MAKE.PATH_FILEMON", _PATH_FILEMON, VAR_GLOBAL, 0); +#endif +} + + +/* + * Initialization we need after reading makefiles. + */ void -meta_init(const char *make_mode) +meta_mode_init(const char *make_mode) { static int once = 0; char *cp; @@ -1037,6 +1053,7 @@ meta_oodate(GNode *gn, Boolean oodate) char *tp = Lst_Datum(ln); Lst_Remove(missingFiles, ln); free(tp); + ln = NULL; /* we're done with it */ } } break; @@ -1196,17 +1213,19 @@ meta_oodate(GNode *gn, Boolean oodate) oodate = TRUE; } else { char *cmd = (char *)Lst_Datum(ln); + Boolean hasOODATE = FALSE; - if (!needOODATE) { - if (strstr(cmd, "$?")) - needOODATE = TRUE; - else if ((cp = strstr(cmd, ".OODATE"))) { - /* check for $[{(].OODATE[)}] */ - if (cp > cmd + 2 && cp[-2] == '$') - needOODATE = TRUE; - } - if (needOODATE && DEBUG(META)) - fprintf(debug_file, "%s: %d: cannot compare commands using .OODATE\n", fname, lineno); + if (strstr(cmd, "$?")) + hasOODATE = TRUE; + else if ((cp = strstr(cmd, ".OODATE"))) { + /* check for $[{(].OODATE[:)}] */ + if (cp > cmd + 2 && cp[-2] == '$') + hasOODATE = TRUE; + } + if (hasOODATE) { + needOODATE = TRUE; + if (DEBUG(META)) + fprintf(debug_file, "%s: %d: cannot compare command using .OODATE\n", fname, lineno); } cmd = Var_Subst(NULL, cmd, gn, TRUE); @@ -1235,7 +1254,7 @@ meta_oodate(GNode *gn, Boolean oodate) if (buf[x - 1] == '\n') buf[x - 1] = '\0'; } - if (!needOODATE && + if (!hasOODATE && !(gn->type & OP_NOMETA_CMP) && strcmp(p, cmd) != 0) { if (DEBUG(META)) Modified: head/contrib/bmake/meta.h ============================================================================== --- head/contrib/bmake/meta.h Tue Apr 2 19:39:31 2013 (r249032) +++ head/contrib/bmake/meta.h Tue Apr 2 21:31:11 2013 (r249033) @@ -1,4 +1,4 @@ -/* $NetBSD: meta.h,v 1.2 2011/03/30 22:03:49 sjg Exp $ */ +/* $NetBSD: meta.h,v 1.3 2013/03/23 05:31:29 sjg Exp $ */ /* * Things needed for 'meta' mode. @@ -41,7 +41,8 @@ typedef struct BuildMon { extern Boolean useMeta; struct Job; /* not defined yet */ -void meta_init(const char *); +void meta_init(void); +void meta_mode_init(const char *); void meta_job_start(struct Job *, GNode *); void meta_job_child(struct Job *); void meta_job_error(struct Job *, GNode *, int, int); Modified: head/contrib/bmake/mk/ChangeLog ============================================================================== --- head/contrib/bmake/mk/ChangeLog Tue Apr 2 19:39:31 2013 (r249032) +++ head/contrib/bmake/mk/ChangeLog Tue Apr 2 21:31:11 2013 (r249033) @@ -1,3 +1,71 @@ +2013-03-30 Simon J. Gerraty + + * meta2deps.py (MetaFile.__init__): ensure self.cwd is initialized. + * install-mk (MK_VERSION): bump version + +2013-03-21 Simon J. Gerraty + + * install-mk (MK_VERSION): bump version + * gendirdeps.mk: do not apply :tA to DPADD entries, since we lose + any trailing /., rather apply :tA only when needed. + * gendirdeps.mk: better mimic meta2deps handling of .dirdep files. + * meta.stage.mk (LN_CP_SCRIPT): Add LnCp to do the ln||cp dance + consistently. + * dirdeps.mk: better describe the dance in sys.mk for TARGET_SPEC. + +2013-03-18 Simon J. Gerraty + + * gendirdeps.mk: revert the dance around .MAKE.DEPENDFILE_DEFAULT + it is simpler to just not update when say building for "host" + (where we know we apply filters to DIRDEPS), and using a + non-machine qualified dependfile. + +2013-03-16 Simon J. Gerraty + + * dirdeps.mk: improve DIRDEPS filtering by allowing DEP_SKIP_DIR + and DEP_DIRDEPS_FILTER to vary by DEP_MACHINE and DEP_TARGET_SPEC + * gendirdeps.mk: ensure _objroot has trailing / if it needs it. + * meta2deps.py: if machine is "host", then also trim + self.host_target from any OBJROOTS. + + +2013-03-11 Simon J. Gerraty + + * gendirdeps.mk: if .MAKE.DEPENDFILE_DEFAULT is not machine + qualified but _DEPENDFILE is, and .MAKE.DEPENDFILE_DEFAULT exists + but _DEPENDFILE does not, compare the new _DEPENDFILE against + .MAKE.DEPENDFILE_DEFAULT and discard if the same. + +2013-03-08 Simon J. Gerraty + + * meta.stage.mk: use STAGE_TARGETS to control .ORDER + and hook to all: via staging: + +2013-03-07 Simon J. Gerraty + + * sys.dependfile.mk (.MAKE.DEPENDFILE_DEFAULT): + use a separate variable for the default .MAKE.DEPENDFILE value + so that it can be controlled independently of + .MAKE.DEPENDFILE_PREFERENCE + + * meta.stage.mk: throw error if cp fails etc. + Stage*() return early if passed no args. + .ORDER stage_* + +2013-03-03 Simon J. Gerraty + + * install-mk (MK_VERSION): bump version + * gendirdeps.mk: handle multiple M2D_OBJROOTS better. + +2013-02-10 Simon J. Gerraty + + * install-mk (MK_VERSION): bump version to 20130210 + * import latest dirdeps.mk, gendirdeps.mk and meta2deps.py + from Juniper. + o dirdeps.mk now fully supports TARGET_SPEC consisting of more + than just MACHINE. + o no longer use DEP_MACHINE from Makefile.depend* so remove it. + 2013-01-23 Simon J. Gerraty * install-mk (MK_VERSION): bump version to 20130123 Modified: head/contrib/bmake/mk/dirdeps.mk ============================================================================== --- head/contrib/bmake/mk/dirdeps.mk Tue Apr 2 19:39:31 2013 (r249032) +++ head/contrib/bmake/mk/dirdeps.mk Tue Apr 2 21:31:11 2013 (r249033) @@ -1,6 +1,7 @@ -# $Id: dirdeps.mk,v 1.23 2012/11/06 05:44:03 sjg Exp $ +# $Id: dirdeps.mk,v 1.28 2013/03/25 21:11:43 sjg Exp $ -# Copyright (c) 2010-2012, Juniper Networks, Inc. +# Copyright (c) 2010-2013, Juniper Networks, Inc. +# All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -33,21 +34,31 @@ # This is what we do with DIRDEPS # DIRDEPS: -# This is a list of directories - relative to SRCTOP, it is only -# of interest to .MAKE.LEVEL 0. +# This is a list of directories - relative to SRCTOP, it is +# normally only of interest to .MAKE.LEVEL 0. # In some cases the entry may be qualified with a . -# suffix, for example to force building something for the pseudo +# or . suffix (see TARGET_SPEC_VARS below), +# for example to force building something for the pseudo # machines "host" or "common" regardless of current ${MACHINE}. -# All unqualified entries end up being qualified with .${MACHINE} -# and _DIRDEPS_USE below, uses the suffix to set MACHINE +# +# All unqualified entries end up being qualified with .${TARGET_SPEC} +# and partially qualified (if TARGET_SPEC_VARS has multiple +# entries) are also expanded to a full .. +# The _DIRDEPS_USE target uses the suffix to set TARGET_SPEC # correctly when visiting each entry. # -# Each entry is also converted into a set of paths to look for -# Makefile.depend. to learn the dependencies of each. -# Each Makefile.depend. sets DEP_RELDIR to be the +# The fully qualified directory entries are used to construct a +# dependency graph that will drive the build later. +# +# Also, for each fully qualified directory target, we will search +# using ${.MAKE.DEPENDFILE_PREFERENCE} to find additional +# dependencies. We use Makefile.depend (default value for +# .MAKE.DEPENDFILE_PREFIX) to refer to these makefiles to +# distinguish them from others. +# +# Each Makefile.depend file sets DEP_RELDIR to be the # the RELDIR (path relative to SRCTOP) for its directory, and -# DEP_MACHINE to its suffix (), further since -# each Makefile.depend. includes dirdeps.mk, this +# since each Makefile.depend file includes dirdeps.mk, this # processing is recursive and results in .MAKE.LEVEL 0 learning the # dependencies of the tree wrt the initial directory (_DEP_RELDIR). # @@ -55,38 +66,49 @@ # Indicates whether .MAKE.LEVEL 0 builds anything: # if "no" sub-makes are used to build everything, # if "yes" sub-makes are only used to build for other machines. +# It is best to use "no", but this can require fixing some +# makefiles to not do anything at .MAKE.LEVEL 0. # # TARGET_SPEC_VARS -# All the description above (and below) assumes is the -# only data needed to control the build. -# This is not always the case. So in addition to setting -# MACHINE in the build environment we set TARGET_SPEC which is -# composed of the values of TARGET_SPEC_VARS separated by -# commas. The default is just MACHINE. +# The default value is just MACHINE, and for most environments +# this is sufficient. The _DIRDEPS_USE target actually sets +# both MACHINE and TARGET_SPEC to the suffix of the current +# target so that in the general case TARGET_SPEC can be ignored. # -# If more that MACHINE is needed then sys.mk needs to decompose +# If more than MACHINE is needed then sys.mk needs to decompose # TARGET_SPEC and set the relevant variables accordingly. -# It is important that MACHINE be included in TARGET_SPEC_VARS -# since if there is more the value passed as MACHINE will infact -# be the TARGET_SPEC. +# It is important that MACHINE be included in and actually be +# the first member of TARGET_SPEC_VARS. This allows other +# variables to be considered optional, and some of the treatment +# below relies on MACHINE being the first entry. # Note: TARGET_SPEC cannot contain any '.'s so the target -# tripple used by compiler folk won't work (directly anyway). +# triple used by compiler folk won't work (directly anyway). # # For example: # -# # variables other than MACHINE might be optional +# # Always list MACHINE first, +# # other variables might be optional. # TARGET_SPEC_VARS = MACHINE TARGET_OS # .if ${TARGET_SPEC:Uno:M*,*} != "" # _tspec := ${TARGET_SPEC:S/,/ /g} # MACHINE := ${_tspec:[1]} # TARGET_OS := ${_tspec:[2]} # # etc. +# # We need to stop that TARGET_SPEC affecting any submakes +# # and deal with MACHINE=${TARGET_SPEC} in the environment. +# TARGET_SPEC = +# # export but do not track +# .export-env TARGET_SPEC +# .export ${TARGET_SPEC_VARS} # .for v in ${TARGET_SPEC_VARS:O:u} # .if empty($v) # .undef $v # .endif # .endfor # .endif +# # make sure we know what TARGET_SPEC is +# # as we may need it to find Makefile.depend* +# TARGET_SPEC = ${TARGET_SPEC_VARS:@v@${$v:U}@:ts,} # .if ${.MAKE.LEVEL} == 0 @@ -100,14 +122,48 @@ # do some setup we only need once _CURDIR ?= ${.CURDIR} +# make sure these are empty to start with +_DEP_TARGET_SPEC = +_DIRDEP_CHECKED = + # If TARGET_SPEC_VARS is other than just MACHINE # it should be set by sys.mk or similar by now. # TARGET_SPEC must not contain any '.'s. TARGET_SPEC_VARS ?= MACHINE +# this is what we started with TARGET_SPEC = ${TARGET_SPEC_VARS:@v@${$v:U}@:ts,} +# this is what we mostly use below +DEP_TARGET_SPEC = ${TARGET_SPEC_VARS:S,^,DEP_,:@v@${$v:U}@:ts,} +# make sure we have defaults +.for v in ${TARGET_SPEC_VARS} +DEP_$v ?= ${$v} +.endfor + +.if ${TARGET_SPEC_VARS:[#]} > 1 +# Ok, this gets more complex (putting it mildly). +# In order to stay sane, we need to ensure that all the build_dirs +# we compute below are fully qualified wrt DEP_TARGET_SPEC. +# The makefiles may only partially specify (eg. MACHINE only), +# so we need to construct a set of modifiers to fill in the gaps. +# jot 10 should output 1 2 3 .. 10 +JOT ?= jot +_tspec_x := ${${JOT} ${TARGET_SPEC_VARS:[#]}:L:sh} +# this handles unqualified entries +M_dep_qual_fixes = C;(/[^/.,]+)$$;\1.${DEP_TARGET_SPEC}; +# there needs to be at least one item missing for these to make sense +.for i in ${_tspec_x:[2..-1]} +_tspec_m$i := ${TARGET_SPEC_VARS:[2..$i]:@w@[^,]+@:ts,} +_tspec_a$i := ,${TARGET_SPEC_VARS:[$i..-1]:@v@$${DEP_$v}@:ts,} +M_dep_qual_fixes += C;(\.${_tspec_m$i})$$;\1${_tspec_a$i}; +.endfor *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***