From owner-svn-src-stable@freebsd.org Tue Jun 13 00:22:17 2017 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A1F42D8765D; Tue, 13 Jun 2017 00:22:17 +0000 (UTC) (envelope-from sjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 69C65E68; Tue, 13 Jun 2017 00:22:17 +0000 (UTC) (envelope-from sjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v5D0MGgG073955; Tue, 13 Jun 2017 00:22:16 GMT (envelope-from sjg@FreeBSD.org) Received: (from sjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v5D0MFHe073943; Tue, 13 Jun 2017 00:22:15 GMT (envelope-from sjg@FreeBSD.org) Message-Id: <201706130022.v5D0MFHe073943@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sjg set sender to sjg@FreeBSD.org using -f From: "Simon J. Gerraty" Date: Tue, 13 Jun 2017 00:22:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r319884 - in stable/11: contrib/bmake contrib/bmake/PSD.doc contrib/bmake/mk contrib/bmake/mk/sys contrib/bmake/unit-tests usr.bin/bmake X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Jun 2017 00:22:17 -0000 Author: sjg Date: Tue Jun 13 00:22:15 2017 New Revision: 319884 URL: https://svnweb.freebsd.org/changeset/base/319884 Log: Update bmake to 20170510 Approved by: re@ Added: stable/11/contrib/bmake/mk/files.mk - copied unchanged from r318163, head/contrib/bmake/mk/files.mk stable/11/contrib/bmake/mk/sys.debug.mk - copied unchanged from r310304, head/contrib/bmake/mk/sys.debug.mk stable/11/contrib/bmake/mk/sys.vars.mk - copied, changed from r310304, head/contrib/bmake/mk/sys.vars.mk Modified: stable/11/contrib/bmake/ChangeLog stable/11/contrib/bmake/Makefile stable/11/contrib/bmake/PSD.doc/tutorial.ms stable/11/contrib/bmake/arch.c stable/11/contrib/bmake/bmake.1 stable/11/contrib/bmake/bmake.cat1 stable/11/contrib/bmake/compat.c stable/11/contrib/bmake/cond.c stable/11/contrib/bmake/dir.c stable/11/contrib/bmake/for.c stable/11/contrib/bmake/job.c stable/11/contrib/bmake/main.c stable/11/contrib/bmake/make.1 stable/11/contrib/bmake/make.c stable/11/contrib/bmake/make.h stable/11/contrib/bmake/make_malloc.c stable/11/contrib/bmake/meta.c stable/11/contrib/bmake/mk/ChangeLog stable/11/contrib/bmake/mk/FILES stable/11/contrib/bmake/mk/auto.obj.mk stable/11/contrib/bmake/mk/dirdeps.mk stable/11/contrib/bmake/mk/doc.mk stable/11/contrib/bmake/mk/dpadd.mk stable/11/contrib/bmake/mk/final.mk stable/11/contrib/bmake/mk/gendirdeps.mk stable/11/contrib/bmake/mk/inc.mk stable/11/contrib/bmake/mk/init.mk stable/11/contrib/bmake/mk/install-mk stable/11/contrib/bmake/mk/lib.mk stable/11/contrib/bmake/mk/meta.stage.mk stable/11/contrib/bmake/mk/meta.sys.mk stable/11/contrib/bmake/mk/meta2deps.py stable/11/contrib/bmake/mk/meta2deps.sh stable/11/contrib/bmake/mk/mkopt.sh stable/11/contrib/bmake/mk/own.mk stable/11/contrib/bmake/mk/prog.mk stable/11/contrib/bmake/mk/scripts.mk stable/11/contrib/bmake/mk/subdir.mk stable/11/contrib/bmake/mk/sys.mk stable/11/contrib/bmake/mk/sys/AIX.mk stable/11/contrib/bmake/mk/sys/Darwin.mk stable/11/contrib/bmake/mk/sys/Generic.mk stable/11/contrib/bmake/mk/sys/HP-UX.mk stable/11/contrib/bmake/mk/sys/IRIX.mk stable/11/contrib/bmake/mk/sys/Linux.mk stable/11/contrib/bmake/mk/sys/NetBSD.mk stable/11/contrib/bmake/mk/sys/OSF1.mk stable/11/contrib/bmake/mk/sys/OpenBSD.mk stable/11/contrib/bmake/mk/sys/SunOS.mk stable/11/contrib/bmake/mk/sys/UnixWare.mk stable/11/contrib/bmake/nonints.h stable/11/contrib/bmake/os.sh stable/11/contrib/bmake/parse.c stable/11/contrib/bmake/str.c stable/11/contrib/bmake/suff.c stable/11/contrib/bmake/targ.c stable/11/contrib/bmake/unit-tests/modmatch.exp stable/11/contrib/bmake/unit-tests/modmatch.mk stable/11/contrib/bmake/unit-tests/varmisc.exp stable/11/contrib/bmake/unit-tests/varmisc.mk stable/11/contrib/bmake/var.c stable/11/usr.bin/bmake/Makefile Directory Properties: stable/11/ (props changed) Modified: stable/11/contrib/bmake/ChangeLog ============================================================================== --- stable/11/contrib/bmake/ChangeLog Mon Jun 12 23:50:30 2017 (r319883) +++ stable/11/contrib/bmake/ChangeLog Tue Jun 13 00:22:15 2017 (r319884) @@ -1,3 +1,169 @@ +2017-05-10 Simon J. Gerraty + + * Makefile (_MAKE_VERSION): 20170510 + Merge with NetBSD make, pick up + o main.c: Main_SetObjdir: ensure buf2 is in scope + +2017-05-08 Simon J. Gerraty + + * Makefile (_MAKE_VERSION): 20170505 + see mk/ChangeLog + +2017-05-05 Simon J. Gerraty + + * parse.c: not everyone has stdint.h + +2017-05-01 Simon J. Gerraty + + * Makefile (_MAKE_VERSION): 20170501 + see mk/ChangeLog + +2017-04-21 Simon J. Gerraty + + * Makefile (_MAKE_VERSION): 20170421 + Merge with NetBSD make, pick up + o str.c: Str_Match: fix closure tests for [^] and add unit-test. + +2017-04-20 Simon J. Gerraty + + * Makefile (_MAKE_VERSION): 20170420 + Merge with NetBSD make, pick up + o main.c: only use -C arg "as is" if it contains no + relative component. + +2017-04-18 Simon J. Gerraty + + * Makefile (_MAKE_VERSION): 20170418 + Merge with NetBSD make, pick up + o main.c: fix Main_SetObjdir() for relative paths (eg obj). + +2017-04-17 Simon J. Gerraty + + * Makefile (_MAKE_VERSION): 20170417 + Merge with NetBSD make, pick up + o fixes a number of coverity complaints + - check return value of fseek, fcntl + - plug memory leak in Dir_FindFile, Var_LoopExpand, + JobPrintCommand, ParseTraditionalInclude + - use bmake_malloc() where NULL is not tollerated + - use MAKE_ATTR_UNUSED rather that kludges like + return(unused ? 0 : 0) + - use purge_cached_realpaths() rather than abuse cached_realpath() + +2017-04-13 Simon J. Gerraty + + * Makefile (_MAKE_VERSION): 20170413 + Merge with NetBSD make, pick up + o main.c: when setting .OBJDIR ignore '$' in paths. + + * job.c: use MALLOC_OPTIONS to set malloc_options. + +2017-04-11 Simon J. Gerraty + + * Makefile (_MAKE_VERSION): 20170411 + Merge with NetBSD make, pick up + o str.c: Str_Match: allow [^a-z] to behave as expected. + +2017-03-26 Simon J. Gerraty + + * Makefile (_MAKE_VERSION): 20170326 + Merge with NetBSD make, pick up + o main.c: purge relative paths from realpath cache when .OBJDIR + is changed. + +2017-03-11 Simon J. Gerraty + + * Makefile (_MAKE_VERSION): 20170311 + Merge with NetBSD make, pick up + o main.c: only use -C arg "as is" if it starts with '/'. + +2017-03-01 Simon J. Gerraty + + * Makefile (_MAKE_VERSION): 20170301 + Merge with NetBSD make, pick up + o main.c: use -C arg "as is" rather than getcwd() + if they identify the same directory. + o parse.c: ensure loadfile buffer is \n terminated in non-mmap case + +2017-02-01 Simon J. Gerraty + + * Makefile (_MAKE_VERSION): 20170201 + Merge with NetBSD make, pick up + o var.c: allow :_=var and avoid use of special context. + +2017-01-30 Simon J. Gerraty + + * Makefile (_MAKE_VERSION): 20170130 + Merge with NetBSD make, pick up + o var.c: add :range and :_ + o main.c: partially initialize Dir_* before MainParseArgs() + can be called. + If -V, skip Main_ExportMAKEFLAGS() + +2017-01-14 Simon J. Gerraty + + * Makefile (_MAKE_VERSION): 20170114 + Merge with NetBSD make, pick up + o var.c: allow specifying the utc value used by :{gm,local}time + +2016-12-12 Simon J. Gerraty + + * Makefile (_MAKE_VERSION): 20161212 + Merge with NetBSD make, pick up + o main.c: look for obj.${MACHINE}-${MACHINE_ARCH} too. + +2016-12-09 Simon J. Gerraty + + * Makefile (_MAKE_VERSION): 20161209 + Merge with NetBSD make, pick up + o main.c: cleanup setting of .OBJDIR + o parse.c: avoid coredump from (var)=val + +2016-11-26 Simon J. Gerraty + + * Makefile (_MAKE_VERSION): 20161126 + Merge with NetBSD make, pick up + o make.c: Make_OODate: report src node name if path not set + +2016-09-26 Simon J. Gerraty + + * Makefile (_MAKE_VERSION): 20160926 + Merge with NetBSD make, pick up + o support for .DELETE_ON_ERROR: (remove targets that fail) + +2016-09-26 Simon J. Gerraty + + * Makefile MAN: tweak .Dt to match ${PROG} + +2016-08-18 Simon J. Gerraty + + * Makefile (_MAKE_VERSION): 20160818 + its a neater number; pick up whitespace fixes to man page. + +2016-08-17 Simon J. Gerraty + + * Makefile (_MAKE_VERSION): 20160817 + Merge with NetBSD make, pick up + o meta.c: move handling of .MAKE.META.IGNORE_* to meta_ignore() + so we can call it before adding entries to missingFiles. + Thus we do not track files we have been told to ignore. + +2016-08-15 Simon J. Gerraty + + * Makefile (_MAKE_VERSION): 20160815 + Merge with NetBSD make, pick up + o meta_oodate: apply .MAKE.META.IGNORE_FILTER (if defined) to + pathnames, and skip if the expansion is empty. + Useful for dirdeps.mk when checking DIRDEPS_CACHE. + +2016-08-12 Simon J. Gerraty + + * Makefile (_MAKE_VERSION): 20160812 + Merge with NetBSD make, pick up + o meta.c: remove all missingFiles entries that match a deleted + dir. + o main.c: set .ERROR_CMD if possible. + 2016-06-06 Simon J. Gerraty * Makefile (_MAKE_VERSION): 20160606 Modified: stable/11/contrib/bmake/Makefile ============================================================================== --- stable/11/contrib/bmake/Makefile Mon Jun 12 23:50:30 2017 (r319883) +++ stable/11/contrib/bmake/Makefile Tue Jun 13 00:22:15 2017 (r319884) @@ -1,7 +1,7 @@ -# $Id: Makefile,v 1.67 2016/06/07 00:46:12 sjg Exp $ +# $Id: Makefile,v 1.92 2017/05/10 22:29:04 sjg Exp $ # Base version on src date -_MAKE_VERSION= 20160606 +_MAKE_VERSION= 20170510 PROG= bmake @@ -156,7 +156,10 @@ my.history: ${MAKEFILE} .NOPATH: ${MAN} ${MAN}: make.1 my.history @echo making $@ - @sed -e 's/^.Nx/NetBSD/' -e '/^.Nm/s/make/${PROG}/' \ + @sed \ + -e '/^.Dt/s/MAKE/${PROG:tu}/' \ + -e 's/^.Nx/NetBSD/' \ + -e '/^.Nm/s/make/${PROG}/' \ -e '/^.Sh HISTORY/rmy.history' \ -e '/^.Sh HISTORY/,$$s,^.Nm,make,' ${srcdir}/make.1 > $@ Modified: stable/11/contrib/bmake/PSD.doc/tutorial.ms ============================================================================== --- stable/11/contrib/bmake/PSD.doc/tutorial.ms Mon Jun 12 23:50:30 2017 (r319883) +++ stable/11/contrib/bmake/PSD.doc/tutorial.ms Tue Jun 13 00:22:15 2017 (r319884) @@ -1,4 +1,4 @@ -.\" $NetBSD: tutorial.ms,v 1.12 2014/09/30 21:33:14 christos Exp $ +.\" $NetBSD: tutorial.ms,v 1.13 2017/03/01 13:05:11 kre Exp $ .\" Copyright (c) 1988, 1989, 1993 .\" The Regents of the University of California. All rights reserved. .\" @@ -117,6 +117,15 @@ .de No .br .ne 0.5i +.ie n \{\ +.nr g3 \w'NOTE ' +.po -\\n(g3u +.br +NOTE +.br +.po +\\n(g3u +.\} +.el \{\ .po -0.5i .br .mk @@ -148,12 +157,14 @@ .rt .ft \\n(g3 .ps \\n(g4 +.\} .. .de Bp .ie !\\n(.$ .IP \(bu 2 .el .IP "\&" 2 .. -.po +.3i +.ie n .po +\w'NOTE 'u +.el .po +.3i .TL PMake \*- A Tutorial .AU Modified: stable/11/contrib/bmake/arch.c ============================================================================== --- stable/11/contrib/bmake/arch.c Mon Jun 12 23:50:30 2017 (r319883) +++ stable/11/contrib/bmake/arch.c Tue Jun 13 00:22:15 2017 (r319884) @@ -1,4 +1,4 @@ -/* $NetBSD: arch.c,v 1.69 2016/04/06 09:57:00 gson Exp $ */ +/* $NetBSD: arch.c,v 1.70 2017/04/16 20:49:09 riastradh Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: arch.c,v 1.69 2016/04/06 09:57:00 gson Exp $"; +static char rcsid[] = "$NetBSD: arch.c,v 1.70 2017/04/16 20:49:09 riastradh Exp $"; #else #include #ifndef lint #if 0 static char sccsid[] = "@(#)arch.c 8.2 (Berkeley) 1/2/94"; #else -__RCSID("$NetBSD: arch.c,v 1.69 2016/04/06 09:57:00 gson Exp $"); +__RCSID("$NetBSD: arch.c,v 1.70 2017/04/16 20:49:09 riastradh Exp $"); #endif #endif /* not lint */ #endif @@ -726,7 +726,8 @@ ArchStatMember(char *archive, char *member, Boolean ha if (fread(memName, elen, 1, arch) != 1) goto badarch; memName[elen] = '\0'; - fseek(arch, -elen, SEEK_CUR); + if (fseek(arch, -elen, SEEK_CUR) != 0) + goto badarch; if (DEBUG(ARCH) || DEBUG(MAKE)) { fprintf(debug_file, "ArchStat: Extended format entry for %s\n", memName); } @@ -737,7 +738,8 @@ ArchStatMember(char *archive, char *member, Boolean ha Hash_SetValue(he, bmake_malloc(sizeof(struct ar_hdr))); memcpy(Hash_GetValue(he), &arh, sizeof(struct ar_hdr)); } - fseek(arch, (size + 1) & ~1, SEEK_CUR); + if (fseek(arch, (size + 1) & ~1, SEEK_CUR) != 0) + goto badarch; } fclose(arch); @@ -956,7 +958,10 @@ ArchFindMember(char *archive, char *member, struct ar_ * the file at the actual member, rather than its header, but * not here... */ - fseek(arch, -sizeof(struct ar_hdr), SEEK_CUR); + if (fseek(arch, -sizeof(struct ar_hdr), SEEK_CUR) != 0) { + fclose(arch); + return NULL; + } return (arch); } } else @@ -986,10 +991,17 @@ ArchFindMember(char *archive, char *member, struct ar_ } if (strncmp(ename, member, len) == 0) { /* Found as extended name */ - fseek(arch, -sizeof(struct ar_hdr) - elen, SEEK_CUR); + if (fseek(arch, -sizeof(struct ar_hdr) - elen, + SEEK_CUR) != 0) { + fclose(arch); + return NULL; + } return (arch); } - fseek(arch, -elen, SEEK_CUR); + if (fseek(arch, -elen, SEEK_CUR) != 0) { + fclose(arch); + return NULL; + } goto skip; } else #endif @@ -1002,9 +1014,12 @@ skip: * extract the size of the file from the 'size' field of the * header and round it up during the seek. */ - arhPtr->ar_size[sizeof(arhPtr->AR_SIZE)-1] = '\0'; + arhPtr->AR_SIZE[sizeof(arhPtr->AR_SIZE)-1] = '\0'; size = (int)strtol(arhPtr->AR_SIZE, NULL, 10); - fseek(arch, (size + 1) & ~1, SEEK_CUR); + if (fseek(arch, (size + 1) & ~1, SEEK_CUR) != 0) { + fclose(arch); + return NULL; + } } } Modified: stable/11/contrib/bmake/bmake.1 ============================================================================== --- stable/11/contrib/bmake/bmake.1 Mon Jun 12 23:50:30 2017 (r319883) +++ stable/11/contrib/bmake/bmake.1 Tue Jun 13 00:22:15 2017 (r319884) @@ -1,4 +1,4 @@ -.\" $NetBSD: make.1,v 1.259 2016/06/03 07:07:37 wiz Exp $ +.\" $NetBSD: make.1,v 1.266 2017/02/01 18:39:27 sjg Exp $ .\" .\" Copyright (c) 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,8 +29,8 @@ .\" .\" from: @(#)make.1 8.4 (Berkeley) 3/19/94 .\" -.Dd June 2, 2016 -.Dt MAKE 1 +.Dd February 1, 2017 +.Dt BMAKE 1 .Os .Sh NAME .Nm bmake @@ -927,6 +927,9 @@ The default list includes: .It Va .MAKE.META.IGNORE_PATTERNS Provides a list of patterns to match against pathnames. Ignore any that match. +.It Va .MAKE.META.IGNORE_FILTER +Provides a list of variable modifiers to apply to each pathname. +Ignore if the expansion is an empty string. .It Va .MAKE.META.PREFIX Defines the message printed for each meta file updated in "meta verbose" mode. The default value is: @@ -974,7 +977,19 @@ per normal evaluation rules. .It Va MAKE_PRINT_VAR_ON_ERROR When .Nm -stops due to an error, it prints its name and the value of +stops due to an error, it sets +.Ql Va .ERROR_TARGET +to the name of the target that failed, +.Ql Va .ERROR_CMD +to the commands of the failed target, +and in "meta" mode, it also sets +.Ql Va .ERROR_CWD +to the +.Xr getcwd 3 , +and +.Ql Va .ERROR_META_FILE +to the path of the meta file (if any) describing the failed target. +It then 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 . @@ -1190,18 +1205,28 @@ safely through recursive invocations of .Nm . .It Cm \&:R Replaces each word in the variable with everything but its suffix. -.It Cm \&:gmtime +.It Cm \&:range[=count] +The value is an integer sequence representing the words of the original +value, or the supplied +.Va count . +.It Cm \&:gmtime[=utc] The value is a format string for .Xr strftime 3 , -using the current +using .Xr gmtime 3 . +If a +.Va utc +value is not provided or is 0, the current time is used. .It Cm \&:hash Compute a 32-bit hash of the value and encode it as hex digits. -.It Cm \&:localtime +.It Cm \&:localtime[=utc] The value is a format string for .Xr strftime 3 , -using the current +using .Xr localtime 3 . +If a +.Va utc +value is not provided or is 0, the current time is used. .It Cm \&:tA Attempt to convert variable to an absolute path using .Xr realpath 3 , @@ -1401,6 +1426,27 @@ For example. .Pp However a single character variable is often more readable: .Dl ${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'${.newline}@} +.It Cm \&:_[=var] +Save the current variable value in +.Ql $_ +or the named +.Va var +for later reference. +Example usage: +.Bd -literal -offset indent +M_cmpv.units = 1 1000 1000000 +M_cmpv = S,., ,g:_:range:@i@+ $${_:[-$$i]} \&\\ +\\* $${M_cmpv.units:[$$i]}@:S,^,expr 0 ,1:sh + +.Dv .if ${VERSION:${M_cmpv}} < ${3.1.12:L:${M_cmpv}} + +.Ed +Here +.Ql $_ +is used to save the result of the +.Ql :S +modifier which is later referenced using the index values from +.Ql :range . .It Cm \&:U Ns Ar newval If the variable is undefined .Ar newval @@ -1996,6 +2042,14 @@ variable of a target that inherits .Ic .DEFAULT Ns 's commands is set to the target's own name. +.It Ic .DELETE_ON_ERROR +If this target is present in the makefile, it globally causes make to +delete targets whose commands fail. +(By default, only targets whose commands are interrupted during +execution are deleted. +This is the historical behavior.) +This setting can be used to help prevent half-finished or malformed +targets from being left around and corrupting future rebuilds. .It Ic .END Any command lines attached to this target are executed after everything else is done. Modified: stable/11/contrib/bmake/bmake.cat1 ============================================================================== --- stable/11/contrib/bmake/bmake.cat1 Mon Jun 12 23:50:30 2017 (r319883) +++ stable/11/contrib/bmake/bmake.cat1 Tue Jun 13 00:22:15 2017 (r319884) @@ -1,4 +1,4 @@ -MAKE(1) NetBSD General Commands Manual MAKE(1) +BMAKE(1) NetBSD General Commands Manual BMAKE(1) NNAAMMEE bbmmaakkee -- maintain program dependencies @@ -604,6 +604,10 @@ VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNT Provides a list of patterns to match against pathnames. Ignore any that match. + _._M_A_K_E_._M_E_T_A_._I_G_N_O_R_E___F_I_L_T_E_R + Provides a list of variable modifiers to apply to each + pathname. Ignore if the expansion is an empty string. + _._M_A_K_E_._M_E_T_A_._P_R_E_F_I_X Defines the message printed for each meta file updated in "meta verbose" mode. The default value is: @@ -635,9 +639,14 @@ VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNT becomes `$' per normal evaluation rules. _M_A_K_E___P_R_I_N_T___V_A_R___O_N___E_R_R_O_R - When bbmmaakkee stops due to an error, it prints its name and - the value of `_._C_U_R_D_I_R' as well as the value of any vari- - ables named in `_M_A_K_E___P_R_I_N_T___V_A_R___O_N___E_R_R_O_R'. + When bbmmaakkee stops due to an error, it sets `_._E_R_R_O_R___T_A_R_G_E_T' + to the name of the target that failed, `_._E_R_R_O_R___C_M_D' to + the commands of the failed target, and in "meta" mode, it + also sets `_._E_R_R_O_R___C_W_D' to the getcwd(3), and + `_._E_R_R_O_R___M_E_T_A___F_I_L_E' to the path of the meta file (if any) + describing the failed target. It then prints its name + and the value of `_._C_U_R_D_I_R' as well as the value of any + variables named in `_M_A_K_E___P_R_I_N_T___V_A_R___O_N___E_R_R_O_R'. _._n_e_w_l_i_n_e This variable is simply assigned a newline character as its value. This allows expansions using the ::@@ modifier @@ -780,16 +789,20 @@ VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNT ::RR Replaces each word in the variable with everything but its suffix. - ::ggmmttiimmee - The value is a format string for strftime(3), using the current - gmtime(3). + ::rraannggee[[==ccoouunntt]] + The value is an integer sequence representing the words of the orig- + inal value, or the supplied _c_o_u_n_t. + ::ggmmttiimmee[[==uuttcc]] + The value is a format string for strftime(3), using gmtime(3). If a + _u_t_c value is not provided or is 0, the current time is used. + ::hhaasshh Compute a 32-bit hash of the value and encode it as hex digits. - ::llooccaallttiimmee - The value is a format string for strftime(3), using the current - localtime(3). + ::llooccaallttiimmee[[==uuttcc]] + The value is a format string for strftime(3), using localtime(3). + If a _u_t_c value is not provided or is 0, the current time is used. ::ttAA Attempt to convert variable to an absolute path using realpath(3), if that fails, the value is unchanged. @@ -890,6 +903,19 @@ VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNT However a single character variable is often more readable: ${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'${.newline}@} + ::__[[==vvaarr]] + Save the current variable value in `$_' or the named _v_a_r for later + reference. Example usage: + + M_cmpv.units = 1 1000 1000000 + M_cmpv = S,., ,g:_:range:@i@+ $${_:[-$$i]} \ + \* $${M_cmpv.units:[$$i]}@:S,^,expr 0 ,1:sh + + .if ${VERSION:${M_cmpv}} < ${3.1.12:L:${M_cmpv}} + + Here `$_' is used to save the result of the `:S' modifier which is + later referenced using the index values from `:range'. + ::UU_n_e_w_v_a_l If the variable is undefined _n_e_w_v_a_l is the value. If the variable is defined, the existing value is returned. This is another ODE @@ -1276,6 +1302,14 @@ SSPPEECCIIAALL TTAARRGGEETTSS target that inherits ..DDEEFFAAUULLTT's commands is set to the target's own name. + ..DDEELLEETTEE__OONN__EERRRROORR + If this target is present in the makefile, it globally causes + make to delete targets whose commands fail. (By default, only + targets whose commands are interrupted during execution are + deleted. This is the historical behavior.) This setting can be + used to help prevent half-finished or malformed targets from + being left around and corrupting future rebuilds. + ..EENNDD Any command lines attached to this target are executed after everything else is done. @@ -1489,4 +1523,4 @@ BBUUGGSS There is no way of escaping a space character in a filename. -NetBSD 5.1 June 2, 2016 NetBSD 5.1 +NetBSD 7.1_RC1 February 1, 2017 NetBSD 7.1_RC1 Modified: stable/11/contrib/bmake/compat.c ============================================================================== --- stable/11/contrib/bmake/compat.c Mon Jun 12 23:50:30 2017 (r319883) +++ stable/11/contrib/bmake/compat.c Tue Jun 13 00:22:15 2017 (r319884) @@ -1,4 +1,4 @@ -/* $NetBSD: compat.c,v 1.105 2016/05/12 20:28:34 sjg Exp $ */ +/* $NetBSD: compat.c,v 1.106 2016/08/26 23:28:39 dholland 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.105 2016/05/12 20:28:34 sjg Exp $"; +static char rcsid[] = "$NetBSD: compat.c,v 1.106 2016/08/26 23:28:39 dholland 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.105 2016/05/12 20:28:34 sjg Exp $"); +__RCSID("$NetBSD: compat.c,v 1.106 2016/08/26 23:28:39 dholland Exp $"); #endif #endif /* not lint */ #endif @@ -119,6 +119,25 @@ static GNode *curTarg = NULL; static GNode *ENDNode; static void CompatInterrupt(int); +/* + * CompatDeleteTarget -- delete a failed, interrupted, or otherwise + * duffed target if not inhibited by .PRECIOUS. + */ +static void +CompatDeleteTarget(GNode *gn) +{ + if ((gn != NULL) && !Targ_Precious (gn)) { + char *p1; + char *file = Var_Value(TARGET, gn, &p1); + + if (!noExecute && eunlink(file) != -1) { + Error("*** %s removed", file); + } + + free(p1); + } +} + /*- *----------------------------------------------------------------------- * CompatInterrupt -- @@ -132,6 +151,9 @@ static void CompatInterrupt(int); * The target is removed and the process exits. If .INTERRUPT exists, * its commands are run first WITH INTERRUPTS IGNORED.. * + * XXX: is .PRECIOUS supposed to inhibit .INTERRUPT? I doubt it, but I've + * left the logic alone for now. - dholland 20160826 + * *----------------------------------------------------------------------- */ static void @@ -139,16 +161,9 @@ CompatInterrupt(int signo) { GNode *gn; - if ((curTarg != NULL) && !Targ_Precious (curTarg)) { - char *p1; - char *file = Var_Value(TARGET, curTarg, &p1); + CompatDeleteTarget(curTarg); - if (!noExecute && eunlink(file) != -1) { - Error("*** %s removed", file); - } - - free(p1); - + if ((curTarg != NULL) && !Targ_Precious (curTarg)) { /* * Run .INTERRUPT only if hit with interrupt signal */ @@ -158,7 +173,6 @@ CompatInterrupt(int signo) Compat_Make(gn, gn); } } - } if (signo == SIGQUIT) _exit(signo); @@ -447,7 +461,12 @@ again: * continue. */ printf(" (continuing)\n"); + } else { + printf("\n"); } + if (deleteOnError) { + CompatDeleteTarget(gn); + } } else { /* * Continue executing commands for this target. @@ -607,7 +626,7 @@ Compat_Make(void *gnp, void *pgnp) } else if (keepgoing) { pgn->flags &= ~REMAKE; } else { - PrintOnError(gn, "\n\nStop."); + PrintOnError(gn, "\nStop."); exit(1); } } else if (gn->made == ERROR) { @@ -698,7 +717,7 @@ Compat_Run(Lst targs) if (gn != NULL) { Compat_Make(gn, gn); if (gn->made == ERROR) { - PrintOnError(gn, "\n\nStop."); + PrintOnError(gn, "\nStop."); exit(1); } } @@ -739,7 +758,7 @@ Compat_Run(Lst targs) if (errors == 0) { Compat_Make(ENDNode, ENDNode); if (gn->made == ERROR) { - PrintOnError(gn, "\n\nStop."); + PrintOnError(gn, "\nStop."); exit(1); } } Modified: stable/11/contrib/bmake/cond.c ============================================================================== --- stable/11/contrib/bmake/cond.c Mon Jun 12 23:50:30 2017 (r319883) +++ stable/11/contrib/bmake/cond.c Tue Jun 13 00:22:15 2017 (r319884) @@ -1,4 +1,4 @@ -/* $NetBSD: cond.c,v 1.74 2016/02/18 18:29:14 christos Exp $ */ +/* $NetBSD: cond.c,v 1.75 2017/04/16 20:59:04 riastradh Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -70,14 +70,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: cond.c,v 1.74 2016/02/18 18:29:14 christos Exp $"; +static char rcsid[] = "$NetBSD: cond.c,v 1.75 2017/04/16 20:59:04 riastradh Exp $"; #else #include #ifndef lint #if 0 static char sccsid[] = "@(#)cond.c 8.2 (Berkeley) 1/2/94"; #else -__RCSID("$NetBSD: cond.c,v 1.74 2016/02/18 18:29:14 christos Exp $"); +__RCSID("$NetBSD: cond.c,v 1.75 2017/04/16 20:59:04 riastradh Exp $"); #endif #endif /* not lint */ #endif @@ -91,6 +91,7 @@ __RCSID("$NetBSD: cond.c,v 1.74 2016/02/18 18:29:14 ch * */ +#include #include #include /* For strtoul() error checking */ @@ -1174,8 +1175,9 @@ Cond_EvalExpression(const struct If *info, char *line, break; dflt_info = info; } + assert(info != NULL); - if_info = info != NULL ? info : ifs + 4; + if_info = info; condExpr = line; condPushBack = TOK_NONE; Modified: stable/11/contrib/bmake/dir.c ============================================================================== --- stable/11/contrib/bmake/dir.c Mon Jun 12 23:50:30 2017 (r319883) +++ stable/11/contrib/bmake/dir.c Tue Jun 13 00:22:15 2017 (r319884) @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.68 2016/06/07 00:40:00 sjg Exp $ */ +/* $NetBSD: dir.c,v 1.71 2017/04/16 21:14:47 riastradh 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.68 2016/06/07 00:40:00 sjg Exp $"; +static char rcsid[] = "$NetBSD: dir.c,v 1.71 2017/04/16 21:14:47 riastradh 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.68 2016/06/07 00:40:00 sjg Exp $"); +__RCSID("$NetBSD: dir.c,v 1.71 2017/04/16 21:14:47 riastradh Exp $"); #endif #endif /* not lint */ #endif @@ -346,11 +346,13 @@ cached_lstat(const char *pathname, void *st) void Dir_Init(const char *cdname) { - dirSearchPath = Lst_Init(FALSE); - openDirectories = Lst_Init(FALSE); - Hash_InitTable(&mtimes, 0); - Hash_InitTable(&lmtimes, 0); - + if (!cdname) { + dirSearchPath = Lst_Init(FALSE); + openDirectories = Lst_Init(FALSE); + Hash_InitTable(&mtimes, 0); + Hash_InitTable(&lmtimes, 0); + return; + } Dir_InitCur(cdname); dotLast = bmake_malloc(sizeof(Path)); @@ -801,11 +803,11 @@ DirExpandInt(const char *word, Lst path, Lst expansion *----------------------------------------------------------------------- */ static int -DirPrintWord(void *word, void *dummy) +DirPrintWord(void *word, void *dummy MAKE_ATTR_UNUSED) { fprintf(debug_file, "%s ", (char *)word); - return(dummy ? 0 : 0); + return 0; } /*- @@ -1313,8 +1315,14 @@ Dir_FindFile(const char *name, Lst path) fprintf(debug_file, " Trying exact path matches...\n"); } - if (!hasLastDot && cur && (file = DirLookupAbs(cur, name, cp)) != NULL) - return *file?file:NULL; + if (!hasLastDot && cur && ((file = DirLookupAbs(cur, name, cp)) + != NULL)) { + if (file[0] == '\0') { + free(file); + return NULL; + } + return file; + } (void)Lst_Open(path); while ((ln = Lst_Next(path)) != NULL) { @@ -1323,13 +1331,23 @@ Dir_FindFile(const char *name, Lst path) continue; if ((file = DirLookupAbs(p, name, cp)) != NULL) { Lst_Close(path); - return *file?file:NULL; + if (file[0] == '\0') { + free(file); + return NULL; + } + return file; } } Lst_Close(path); - if (hasLastDot && cur && (file = DirLookupAbs(cur, name, cp)) != NULL) - return *file?file:NULL; + if (hasLastDot && cur && ((file = DirLookupAbs(cur, name, cp)) + != NULL)) { + if (file[0] == '\0') { + free(file); + return NULL; + } + return file; + } } /* @@ -1849,10 +1867,10 @@ Dir_PrintDirectories(void) } static int -DirPrintDir(void *p, void *dummy) +DirPrintDir(void *p, void *dummy MAKE_ATTR_UNUSED) { fprintf(debug_file, "%s ", ((Path *)p)->name); - return (dummy ? 0 : 0); + return 0; } void Modified: stable/11/contrib/bmake/for.c ============================================================================== --- stable/11/contrib/bmake/for.c Mon Jun 12 23:50:30 2017 (r319883) +++ stable/11/contrib/bmake/for.c Tue Jun 13 00:22:15 2017 (r319884) @@ -1,4 +1,4 @@ -/* $NetBSD: for.c,v 1.52 2016/02/18 18:29:14 christos Exp $ */ +/* $NetBSD: for.c,v 1.53 2017/04/16 21:04:44 riastradh Exp $ */ /* * Copyright (c) 1992, The Regents of the University of California. @@ -30,14 +30,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: for.c,v 1.52 2016/02/18 18:29:14 christos Exp $"; +static char rcsid[] = "$NetBSD: for.c,v 1.53 2017/04/16 21:04:44 riastradh Exp $"; #else #include #ifndef lint #if 0 static char sccsid[] = "@(#)for.c 8.1 (Berkeley) 6/6/93"; #else -__RCSID("$NetBSD: for.c,v 1.52 2016/02/18 18:29:14 christos Exp $"); +__RCSID("$NetBSD: for.c,v 1.53 2017/04/16 21:04:44 riastradh Exp $"); #endif #endif /* not lint */ #endif @@ -427,7 +427,7 @@ For_Iterate(void *v_arg, size_t *ret_len) for (cp = cmd_cp; (cp = strchr(cp, '$')) != NULL;) { char ech; ch = *++cp; - if ((ch == '(' && (ech = ')')) || (ch == '{' && (ech = '}'))) { + if ((ch == '(' && (ech = ')', 1)) || (ch == '{' && (ech = '}', 1))) { cp++; /* Check variable name against the .for loop variables */ STRLIST_FOREACH(var, &arg->vars, i) { Modified: stable/11/contrib/bmake/job.c ============================================================================== --- stable/11/contrib/bmake/job.c Mon Jun 12 23:50:30 2017 (r319883) +++ stable/11/contrib/bmake/job.c Tue Jun 13 00:22:15 2017 (r319884) @@ -1,4 +1,4 @@ -/* $NetBSD: job.c,v 1.187 2016/05/12 20:28:34 sjg Exp $ */ +/* $NetBSD: job.c,v 1.190 2017/04/16 21:23:43 riastradh 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.187 2016/05/12 20:28:34 sjg Exp $"; +static char rcsid[] = "$NetBSD: job.c,v 1.190 2017/04/16 21:23:43 riastradh 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.187 2016/05/12 20:28:34 sjg Exp $"); +__RCSID("$NetBSD: job.c,v 1.190 2017/04/16 21:23:43 riastradh Exp $"); #endif #endif /* not lint */ #endif @@ -389,7 +389,10 @@ static void JobSigLock(sigset_t *); static void JobSigUnlock(sigset_t *); static void JobSigReset(void); -const char *malloc_options="A"; +#if !defined(MALLOC_OPTIONS) +# define MALLOC_OPTIONS "A" +#endif +const char *malloc_options= MALLOC_OPTIONS; static void job_table_dump(const char *where) @@ -404,6 +407,21 @@ job_table_dump(const char *where) } /* + * Delete the target of a failed, interrupted, or otherwise + * unsuccessful job unless inhibited by .PRECIOUS. + */ +static void +JobDeleteTarget(GNode *gn) +{ + if ((gn->type & (OP_JOIN|OP_PHONY)) == 0 && !Targ_Precious(gn)) { + char *file = (gn->path == NULL ? gn->name : gn->path); + if (!noExecute && eunlink(file) != -1) { + Error("*** %s removed", file); + } + } +} + +/* * JobSigLock/JobSigUnlock * * Signal lock routines to get exclusive access. Currently used to @@ -425,7 +443,7 @@ static void JobSigUnlock(sigset_t *omaskp) static void JobCreatePipe(Job *job, int minfd) { - int i, fd; + int i, fd, flags; if (pipe(job->jobPipe) == -1) Punt("Cannot create pipe: %s", strerror(errno)); @@ -440,8 +458,10 @@ JobCreatePipe(Job *job, int minfd) } /* Set close-on-exec flag for both */ - (void)fcntl(job->jobPipe[0], F_SETFD, FD_CLOEXEC); - (void)fcntl(job->jobPipe[1], F_SETFD, FD_CLOEXEC); + if (fcntl(job->jobPipe[0], F_SETFD, FD_CLOEXEC) == -1) + Punt("Cannot set close-on-exec: %s", strerror(errno)); + if (fcntl(job->jobPipe[1], F_SETFD, FD_CLOEXEC) == -1) + Punt("Cannot set close-on-exec: %s", strerror(errno)); /* * We mark the input side of the pipe non-blocking; we poll(2) the @@ -449,8 +469,12 @@ JobCreatePipe(Job *job, int minfd) * race for the token when a new one becomes available, so the read * from the pipe should not block. */ - fcntl(job->jobPipe[0], F_SETFL, - fcntl(job->jobPipe[0], F_GETFL, 0) | O_NONBLOCK); + flags = fcntl(job->jobPipe[0], F_GETFL, 0); + if (flags == -1) + Punt("Cannot get flags: %s", strerror(errno)); + flags |= O_NONBLOCK; + if (fcntl(job->jobPipe[0], F_SETFL, flags) == -1) + Punt("Cannot set flags: %s", strerror(errno)); } /*- @@ -752,6 +776,7 @@ JobPrintCommand(void *cmdp, void *jobp) * but this one needs to be - use compat mode just for it. */ CompatRunCommand(cmdp, job->node); + free(cmdStart); return 0; } break; @@ -1049,6 +1074,9 @@ JobFinish (Job *job, WAIT_T status) if (job->flags & JOB_IGNERR) { WAIT_STATUS(status) = 0; } else { + if (deleteOnError) { + JobDeleteTarget(job->node); + } PrintOnError(job->node, NULL); } } else if (DEBUG(JOB)) { @@ -1066,6 +1094,9 @@ JobFinish (Job *job, WAIT_T status) } (void)printf("*** [%s] Signal %d\n", job->node->name, WTERMSIG(status)); + if (deleteOnError) { + JobDeleteTarget(job->node); *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***