[Midnightbsd-cvs] src [11138] vendor/NetBSD/bmake/dist: update bmake to 20170720

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Tue Jun 26 20:17:23 EDT 2018


Revision: 11138
          http://svnweb.midnightbsd.org/src/?rev=11138
Author:   laffer1
Date:     2018-06-26 20:17:22 -0400 (Tue, 26 Jun 2018)
Log Message:
-----------
update bmake to 20170720

Modified Paths:
--------------
    vendor/NetBSD/bmake/dist/ChangeLog
    vendor/NetBSD/bmake/dist/FILES
    vendor/NetBSD/bmake/dist/Makefile
    vendor/NetBSD/bmake/dist/PSD.doc/Makefile
    vendor/NetBSD/bmake/dist/PSD.doc/tutorial.ms
    vendor/NetBSD/bmake/dist/README
    vendor/NetBSD/bmake/dist/arch.c
    vendor/NetBSD/bmake/dist/bmake.1
    vendor/NetBSD/bmake/dist/bmake.cat1
    vendor/NetBSD/bmake/dist/boot-strap
    vendor/NetBSD/bmake/dist/buf.h
    vendor/NetBSD/bmake/dist/compat.c
    vendor/NetBSD/bmake/dist/cond.c
    vendor/NetBSD/bmake/dist/config.h.in
    vendor/NetBSD/bmake/dist/configure
    vendor/NetBSD/bmake/dist/configure.in
    vendor/NetBSD/bmake/dist/dir.c
    vendor/NetBSD/bmake/dist/dir.h
    vendor/NetBSD/bmake/dist/dirname.c
    vendor/NetBSD/bmake/dist/for.c
    vendor/NetBSD/bmake/dist/getopt.c
    vendor/NetBSD/bmake/dist/hash.h
    vendor/NetBSD/bmake/dist/job.c
    vendor/NetBSD/bmake/dist/lst.h
    vendor/NetBSD/bmake/dist/lst.lib/lstInt.h
    vendor/NetBSD/bmake/dist/lst.lib/lstRemove.c
    vendor/NetBSD/bmake/dist/machine.sh
    vendor/NetBSD/bmake/dist/main.c
    vendor/NetBSD/bmake/dist/make-bootstrap.sh.in
    vendor/NetBSD/bmake/dist/make.1
    vendor/NetBSD/bmake/dist/make.c
    vendor/NetBSD/bmake/dist/make.h
    vendor/NetBSD/bmake/dist/make_malloc.c
    vendor/NetBSD/bmake/dist/meta.c
    vendor/NetBSD/bmake/dist/meta.h
    vendor/NetBSD/bmake/dist/mk/ChangeLog
    vendor/NetBSD/bmake/dist/mk/FILES
    vendor/NetBSD/bmake/dist/mk/auto.dep.mk
    vendor/NetBSD/bmake/dist/mk/auto.obj.mk
    vendor/NetBSD/bmake/dist/mk/autodep.mk
    vendor/NetBSD/bmake/dist/mk/dep.mk
    vendor/NetBSD/bmake/dist/mk/dirdeps.mk
    vendor/NetBSD/bmake/dist/mk/doc.mk
    vendor/NetBSD/bmake/dist/mk/dpadd.mk
    vendor/NetBSD/bmake/dist/mk/final.mk
    vendor/NetBSD/bmake/dist/mk/gendirdeps.mk
    vendor/NetBSD/bmake/dist/mk/host-target.mk
    vendor/NetBSD/bmake/dist/mk/inc.mk
    vendor/NetBSD/bmake/dist/mk/init.mk
    vendor/NetBSD/bmake/dist/mk/install-mk
    vendor/NetBSD/bmake/dist/mk/lib.mk
    vendor/NetBSD/bmake/dist/mk/libnames.mk
    vendor/NetBSD/bmake/dist/mk/links.mk
    vendor/NetBSD/bmake/dist/mk/meta.autodep.mk
    vendor/NetBSD/bmake/dist/mk/meta.stage.mk
    vendor/NetBSD/bmake/dist/mk/meta.subdir.mk
    vendor/NetBSD/bmake/dist/mk/meta.sys.mk
    vendor/NetBSD/bmake/dist/mk/meta2deps.py
    vendor/NetBSD/bmake/dist/mk/meta2deps.sh
    vendor/NetBSD/bmake/dist/mk/mk-files.txt
    vendor/NetBSD/bmake/dist/mk/nls.mk
    vendor/NetBSD/bmake/dist/mk/own.mk
    vendor/NetBSD/bmake/dist/mk/prog.mk
    vendor/NetBSD/bmake/dist/mk/rst2htm.mk
    vendor/NetBSD/bmake/dist/mk/scripts.mk
    vendor/NetBSD/bmake/dist/mk/subdir.mk
    vendor/NetBSD/bmake/dist/mk/sys/AIX.mk
    vendor/NetBSD/bmake/dist/mk/sys/Darwin.mk
    vendor/NetBSD/bmake/dist/mk/sys/Generic.mk
    vendor/NetBSD/bmake/dist/mk/sys/HP-UX.mk
    vendor/NetBSD/bmake/dist/mk/sys/IRIX.mk
    vendor/NetBSD/bmake/dist/mk/sys/Linux.mk
    vendor/NetBSD/bmake/dist/mk/sys/NetBSD.mk
    vendor/NetBSD/bmake/dist/mk/sys/OSF1.mk
    vendor/NetBSD/bmake/dist/mk/sys/OpenBSD.mk
    vendor/NetBSD/bmake/dist/mk/sys/SunOS.mk
    vendor/NetBSD/bmake/dist/mk/sys/UnixWare.mk
    vendor/NetBSD/bmake/dist/mk/sys.clean-env.mk
    vendor/NetBSD/bmake/dist/mk/sys.dependfile.mk
    vendor/NetBSD/bmake/dist/mk/sys.mk
    vendor/NetBSD/bmake/dist/mk/warnings.mk
    vendor/NetBSD/bmake/dist/nonints.h
    vendor/NetBSD/bmake/dist/os.sh
    vendor/NetBSD/bmake/dist/parse.c
    vendor/NetBSD/bmake/dist/sprite.h
    vendor/NetBSD/bmake/dist/str.c
    vendor/NetBSD/bmake/dist/suff.c
    vendor/NetBSD/bmake/dist/targ.c
    vendor/NetBSD/bmake/dist/unit-tests/Makefile.in
    vendor/NetBSD/bmake/dist/var.c

Added Paths:
-----------
    vendor/NetBSD/bmake/dist/metachar.c
    vendor/NetBSD/bmake/dist/metachar.h
    vendor/NetBSD/bmake/dist/mk/cython.mk
    vendor/NetBSD/bmake/dist/mk/files.mk
    vendor/NetBSD/bmake/dist/mk/manifest.mk
    vendor/NetBSD/bmake/dist/mk/mkopt.sh
    vendor/NetBSD/bmake/dist/mk/sys.debug.mk
    vendor/NetBSD/bmake/dist/mk/sys.vars.mk
    vendor/NetBSD/bmake/dist/mk/whats.mk
    vendor/NetBSD/bmake/dist/unit-tests/comment.exp
    vendor/NetBSD/bmake/dist/unit-tests/comment.mk
    vendor/NetBSD/bmake/dist/unit-tests/cond1.exp
    vendor/NetBSD/bmake/dist/unit-tests/cond1.mk
    vendor/NetBSD/bmake/dist/unit-tests/cond2.exp
    vendor/NetBSD/bmake/dist/unit-tests/cond2.mk
    vendor/NetBSD/bmake/dist/unit-tests/doterror.exp
    vendor/NetBSD/bmake/dist/unit-tests/doterror.mk
    vendor/NetBSD/bmake/dist/unit-tests/dotwait.exp
    vendor/NetBSD/bmake/dist/unit-tests/dotwait.mk
    vendor/NetBSD/bmake/dist/unit-tests/error.exp
    vendor/NetBSD/bmake/dist/unit-tests/error.mk
    vendor/NetBSD/bmake/dist/unit-tests/escape.exp
    vendor/NetBSD/bmake/dist/unit-tests/escape.mk
    vendor/NetBSD/bmake/dist/unit-tests/export-all.exp
    vendor/NetBSD/bmake/dist/unit-tests/export-all.mk
    vendor/NetBSD/bmake/dist/unit-tests/export-env.exp
    vendor/NetBSD/bmake/dist/unit-tests/export-env.mk
    vendor/NetBSD/bmake/dist/unit-tests/export.exp
    vendor/NetBSD/bmake/dist/unit-tests/export.mk
    vendor/NetBSD/bmake/dist/unit-tests/forloop.exp
    vendor/NetBSD/bmake/dist/unit-tests/forloop.mk
    vendor/NetBSD/bmake/dist/unit-tests/forsubst.exp
    vendor/NetBSD/bmake/dist/unit-tests/forsubst.mk
    vendor/NetBSD/bmake/dist/unit-tests/hash.exp
    vendor/NetBSD/bmake/dist/unit-tests/hash.mk
    vendor/NetBSD/bmake/dist/unit-tests/impsrc.exp
    vendor/NetBSD/bmake/dist/unit-tests/impsrc.mk
    vendor/NetBSD/bmake/dist/unit-tests/misc.exp
    vendor/NetBSD/bmake/dist/unit-tests/misc.mk
    vendor/NetBSD/bmake/dist/unit-tests/moderrs.exp
    vendor/NetBSD/bmake/dist/unit-tests/moderrs.mk
    vendor/NetBSD/bmake/dist/unit-tests/modmatch.exp
    vendor/NetBSD/bmake/dist/unit-tests/modmatch.mk
    vendor/NetBSD/bmake/dist/unit-tests/modmisc.exp
    vendor/NetBSD/bmake/dist/unit-tests/modmisc.mk
    vendor/NetBSD/bmake/dist/unit-tests/modorder.exp
    vendor/NetBSD/bmake/dist/unit-tests/modorder.mk
    vendor/NetBSD/bmake/dist/unit-tests/modts.exp
    vendor/NetBSD/bmake/dist/unit-tests/modts.mk
    vendor/NetBSD/bmake/dist/unit-tests/modword.exp
    vendor/NetBSD/bmake/dist/unit-tests/modword.mk
    vendor/NetBSD/bmake/dist/unit-tests/order.exp
    vendor/NetBSD/bmake/dist/unit-tests/order.mk
    vendor/NetBSD/bmake/dist/unit-tests/phony-end.exp
    vendor/NetBSD/bmake/dist/unit-tests/phony-end.mk
    vendor/NetBSD/bmake/dist/unit-tests/posix.exp
    vendor/NetBSD/bmake/dist/unit-tests/posix.mk
    vendor/NetBSD/bmake/dist/unit-tests/posix1.exp
    vendor/NetBSD/bmake/dist/unit-tests/posix1.mk
    vendor/NetBSD/bmake/dist/unit-tests/qequals.exp
    vendor/NetBSD/bmake/dist/unit-tests/qequals.mk
    vendor/NetBSD/bmake/dist/unit-tests/suffixes.exp
    vendor/NetBSD/bmake/dist/unit-tests/suffixes.mk
    vendor/NetBSD/bmake/dist/unit-tests/sunshcmd.exp
    vendor/NetBSD/bmake/dist/unit-tests/sunshcmd.mk
    vendor/NetBSD/bmake/dist/unit-tests/sysv.exp
    vendor/NetBSD/bmake/dist/unit-tests/sysv.mk
    vendor/NetBSD/bmake/dist/unit-tests/ternary.exp
    vendor/NetBSD/bmake/dist/unit-tests/ternary.mk
    vendor/NetBSD/bmake/dist/unit-tests/unexport-env.exp
    vendor/NetBSD/bmake/dist/unit-tests/unexport-env.mk
    vendor/NetBSD/bmake/dist/unit-tests/unexport.exp
    vendor/NetBSD/bmake/dist/unit-tests/unexport.mk
    vendor/NetBSD/bmake/dist/unit-tests/varcmd.exp
    vendor/NetBSD/bmake/dist/unit-tests/varcmd.mk
    vendor/NetBSD/bmake/dist/unit-tests/varmisc.exp
    vendor/NetBSD/bmake/dist/unit-tests/varmisc.mk
    vendor/NetBSD/bmake/dist/unit-tests/varshell.exp
    vendor/NetBSD/bmake/dist/unit-tests/varshell.mk

Removed Paths:
-------------
    vendor/NetBSD/bmake/dist/missing/
    vendor/NetBSD/bmake/dist/unit-tests/comment
    vendor/NetBSD/bmake/dist/unit-tests/cond1
    vendor/NetBSD/bmake/dist/unit-tests/doterror
    vendor/NetBSD/bmake/dist/unit-tests/dotwait
    vendor/NetBSD/bmake/dist/unit-tests/error
    vendor/NetBSD/bmake/dist/unit-tests/export
    vendor/NetBSD/bmake/dist/unit-tests/export-all
    vendor/NetBSD/bmake/dist/unit-tests/export-env
    vendor/NetBSD/bmake/dist/unit-tests/forloop
    vendor/NetBSD/bmake/dist/unit-tests/forsubst
    vendor/NetBSD/bmake/dist/unit-tests/hash
    vendor/NetBSD/bmake/dist/unit-tests/misc
    vendor/NetBSD/bmake/dist/unit-tests/moderrs
    vendor/NetBSD/bmake/dist/unit-tests/modmatch
    vendor/NetBSD/bmake/dist/unit-tests/modmisc
    vendor/NetBSD/bmake/dist/unit-tests/modorder
    vendor/NetBSD/bmake/dist/unit-tests/modts
    vendor/NetBSD/bmake/dist/unit-tests/modword
    vendor/NetBSD/bmake/dist/unit-tests/order
    vendor/NetBSD/bmake/dist/unit-tests/phony-end
    vendor/NetBSD/bmake/dist/unit-tests/posix
    vendor/NetBSD/bmake/dist/unit-tests/qequals
    vendor/NetBSD/bmake/dist/unit-tests/sunshcmd
    vendor/NetBSD/bmake/dist/unit-tests/sysv
    vendor/NetBSD/bmake/dist/unit-tests/ternary
    vendor/NetBSD/bmake/dist/unit-tests/test.exp
    vendor/NetBSD/bmake/dist/unit-tests/unexport
    vendor/NetBSD/bmake/dist/unit-tests/unexport-env
    vendor/NetBSD/bmake/dist/unit-tests/varcmd

Property Changed:
----------------
    vendor/NetBSD/bmake/dist/mk/meta2deps.py
    vendor/NetBSD/bmake/dist/mk/meta2deps.sh
    vendor/NetBSD/bmake/dist/mk/stage-install.sh

Modified: vendor/NetBSD/bmake/dist/ChangeLog
===================================================================
--- vendor/NetBSD/bmake/dist/ChangeLog	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/ChangeLog	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,8 +1,463 @@
+2017-07-20  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* Makefile (_MAKE_VERSION): 20170720
+	  Merge with NetBSD make, pick up
+	  o compat.c: pass SIGINT etc onto child and wait for it to exit
+	    before we self-terminate.
+
+2017-07-11  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* Makefile (_MAKE_VERSION): 20170711
+	  forgot to update after merge on 20170708 ;-)
+	  o main.c: refactor to reduce size of main function.
+	    add -v option to always fully expand values.
+	  o meta.c: ensure command output in meta file has ending newline
+	    even when filemon not being used.
+	    When matching ${.MAKE.META.IGNORE_PATTERNS} do not use
+	    pathname via ':L' since any ':' in pathname breaks that.
+	    Instead set a '${.p.}' to pathname in the target context and
+	    use that.
+
+2017-05-10  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* 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  <sjg at bad.crufty.net>
+
+	* Makefile (_MAKE_VERSION): 20170505
+	  see mk/ChangeLog
+
+2017-05-05  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* parse.c: not everyone has stdint.h
+
+2017-05-01  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* Makefile (_MAKE_VERSION): 20170501
+	  see mk/ChangeLog
+
+2017-04-21  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* 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  <sjg at bad.crufty.net>
+
+	* 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  <sjg at bad.crufty.net>
+
+	* 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  <sjg at bad.crufty.net>
+
+	* 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  <sjg at bad.crufty.net>
+
+	* 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  <sjg at bad.crufty.net>
+
+	* 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  <sjg at bad.crufty.net>
+
+	* 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  <sjg at bad.crufty.net>
+
+	* 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  <sjg at bad.crufty.net>
+
+	* 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  <sjg at bad.crufty.net>
+
+	* 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  <sjg at bad.crufty.net>
+
+	* 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  <sjg at bad.crufty.net>
+
+	* 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  <sjg at bad.crufty.net>
+
+	* 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  <sjg at bad.crufty.net>
+
+	* 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  <sjg at bad.crufty.net>
+
+	* 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  <sjg at bad.crufty.net>
+
+	* 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  <sjg at bad.crufty.net>
+
+	* Makefile MAN: tweak .Dt to match ${PROG}
+
+2016-08-18  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* Makefile (_MAKE_VERSION): 20160818
+	  its a neater number; pick up whitespace fixes to man page.
+
+2016-08-17  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* 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  <sjg at bad.crufty.net>
+
+	* 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  <sjg at bad.crufty.net>
+
+	* 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  <sjg at bad.crufty.net>
+
+	* Makefile (_MAKE_VERSION): 20160606
+	  Merge with NetBSD make, pick up
+	  o dir.c: extend mtimes cache to others via cached_stat()
+
+2016-06-04  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* Makefile (_MAKE_VERSION): 20160604
+	  Merge with NetBSD make, pick up
+	  o meta.c: missing filemon data is only relevant if we read a
+	    meta file.
+	    Also do not return oodate for a missing metafile if gn->path
+	    points to .CURDIR
+	
+2016-06-02  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* Makefile (_MAKE_VERSION): 20160602
+	  Merge with NetBSD make, pick up
+	  o cached_realpath(): avoid hitting filesystem more than necessary.
+	  o meta.c: refactor need_meta decision, add knobs for 
+	    missing meta file and filemon data wrt out-of-datedness.
+
+2016-05-28  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* Makefile (_MAKE_VERSION): 20160528
+
+	* boot-strap, make-bootstrap.sh.in: Makefile now uses _MAKE_VERSION 
+
+2016-05-12  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* Makefile (_MAKE_VERSION): 20160512
+	  Merge with NetBSD make, pick up
+	  o meta.c: ignore paths that match .MAKE.META.IGNORE_PATTERNS
+	    this is useful for gcov builds.
+	  o propagate errors from filemon(4).
+	
+2016-05-09  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* Makefile (_MAKE_VERSION): 20160509
+	  Merge with NetBSD make, pick up
+	  o remove use of non-standard types u_int etc.
+	  o meta.c: apply realpath() before matching against metaIgnorePaths
+
+2016-04-04  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* Makefile (_MAKE_VERSION): 20160404
+	  Merge with NetBSD make, pick up
+	  o allow makefile to set .MAKE.JOBS
+
+	* Makefile (PROG_NAME): use ${_MAKE_VERSION}
+
+2016-03-15  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* Makefile (_MAKE_VERSION): 20160315
+	  Merge with NetBSD make, pick up
+	  o fix handling of archive members
+
+2016-03-13  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* Makefile (_MAKE_VERSION): rename variable to avoid interference
+	  with checks for ${MAKE_VERSION}
+
+2016-03-10  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* Makefile (MAKE_VERSION): 20160310
+	  Merge with NetBSD make, pick up
+	  o meta.c: treat missing Read file same as Write, incase we Delete it.
+
+2016-03-07  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* Makefile (MAKE_VERSION): 20160307
+	  Merge with NetBSD make, pick up
+	  o var.c: fix :ts\nnn to be octal by default.
+	  o meta.c: meta_finish() to cleanup memory.
+
+2016-02-26  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* Makefile (MAKE_VERSION): 20160226
+	  Merge with NetBSD make, pick up
+	  o meta.c: allow meta file for makeDepend if makefiles want it.
+
+2016-02-19  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* var.c: default .MAKE.SAVE_DOLLARS to FALSE
+	  for backwards compatability.
+
+	* Makefile (MAKE_VERSION): 20160220
+	  Merge with NetBSD make, pick up
+	  o var.c: add knob to control handling of '$$' in :=
+
+2016-02-18  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* Makefile (MAKE_VERSION): 20160218
+	  Merge with NetBSD make, pick up
+	  o var.c: add .export-literal allows us to fix sys.clean-env.mk
+	    post the changes to Var_Subst.
+	    Var_Subst now takes flags, and does not consume '$$' in :=
+
+2016-02-17  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* Makefile (MAKE_VERSION): 20160217
+	  Merge with NetBSD make, pick up
+	  o var.c: preserve '$$' in :=
+	  o parse.c: add .dinclude for handling included 
+	    makefile like .depend
+
+2015-12-20  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* Makefile (MAKE_VERSION): 20151220
+	  Merge with NetBSD make, pick up
+	  o suff.c: re-initialize suffNull when clearing suffixes.
+
+2015-12-01  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* Makefile (MAKE_VERSION): 20151201
+	  Merge with NetBSD make, pick up
+	  o cond.c: CondCvtArg: avoid access beyond end of empty buffer.
+	  o meta.c: meta_oodate: use lstat(2) for checking link target
+	    in case it is a symlink.
+	  o var.c: avoid calling brk_string and Var_Export1 with empty
+	    strings.
+	
+2015-11-26  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* Makefile (MAKE_VERSION): 20151126
+	  Merge with NetBSD make, pick up
+	  o parse.c: ParseTrackInput don't access beyond 
+	    end of old value.
+	
+2015-10-22  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* Makefile (MAKE_VERSION): 20151022
+
+	* Add support for BSD/OS which lacks inttypes.h
+	  and really needs sys/param.h for sys/sysctl.h
+	  also 'type' is not a shell builtin.
+
+	* var.c: eliminate uint32_t and need for inttypes.h
+	
+	* main.c: PrintOnError flush stdout before run .ERROR
+
+	* parse.c: cope with _SC_PAGESIZE not being defined.
+
+	
+2015-10-20  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* Makefile (MAKE_VERSION): 20151020
+	  Merge with NetBSD make, pick up
+	  o var.c: fix uninitialized var 
+
+2015-10-12  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* var.c: the conditional expressions used with ':?' can be
+	expensive, if already discarding do not evaluate or expand
+	anything. 
+
+2015-10-10  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* Makefile (MAKE_VERSION): 20151010
+	  Merge with NetBSD make, pick up
+	  o Add Boolean wantit flag to Var_Subst and Var_Parse
+	    when FALSE we know we are discarding the result and can
+	    skip operations like Cmd_Exec.
+
+2015-10-09  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* Makefile (MAKE_VERSION): 20151009
+	  Merge with NetBSD make, pick up
+	  o var.c: don't check for NULL before free()
+	  o meta.c: meta_oodate, do not hard code ignore of makeDependfile
+
+2015-09-10  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* Makefile (MAKE_VERSION): 20150910
+	  Merge with NetBSD make, pick up
+	  o main.c: with -w print Enter/Leaving messages for objdir too
+	    if necessary.
+	  o centralize shell metachar handling
+	
+	* FILES: add metachar.[ch]
+
+2015-06-06  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* Makefile (MAKE_VERSION): 20150606
+	  Merge with NetBSD make, pick up
+	  o make.1: document .OBJDIR target
+
+2015-05-05  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* Makefile (MAKE_VERSION): 20150505
+	  Merge with NetBSD make, pick up
+	  o cond.c: be strict about lhs of comparison when evaluating .if
+	    but less so when called from variable expansion.
+	  o unit-tests/cond2.mk: test various error conditions
+
+2015-05-04  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* machine.sh (MACHINE): Add Bitrig 
+	  patch from joerg at netbsd.org
+
+2015-04-18  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* Makefile (MAKE_VERSION): 20150418
+	  Merge with NetBSD make, pick up
+	  o job.c: use memmove() rather than memcpy()
+
+	* unit-tests/varshell.mk: SunOS cannot handle the TERMINATED_BY_SIGNAL
+	  case, so skip it.
+
+2015-04-11  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* Makefile (MAKE_VERSION): 20150411
+	  bump version - only mk/ changes.
+	
+2015-04-10  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* Makefile (MAKE_VERSION): 20150410
+	  Merge with NetBSD make, pick up
+	  o document different handling of '-' in jobs mode vs compat
+	  o fix jobs mode so that '-' only applies to whole job
+	    when shell lacks hasErrCtl
+	  o meta.c: use separate vars to track lcwd and latestdir (read)
+	    per process
+	
+2015-04-01  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* Makefile (MAKE_VERSION): 20150401
+	  Merge with NetBSD make, pick up
+	  o meta.c: close meta file in child
+	
+	* Makefile: use BINDIR.bmake if set.
+	  Same for MANDIR and SHAREDIR
+	  Handy for testing release candidates
+	  in various environments.
+	
+2015-03-26  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* move initialization of savederr to block where it is used
+	  to avoid spurious warning from gcc5
+
+2014-11-11  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* Makefile (MAKE_VERSION): 20141111
+	  just a cooler number
+
+2014-11-05  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* Makefile (MAKE_VERSION): 20141105
+	  Merge with NetBSD make, pick up
+	  o revert major overhaul of suffix handling
+	    and POSIX compliance - too much breakage
+	    and impossible to make backwards compatible.
+	  o we still have the new unit test structure which is ok.
+	  o meta.c ensure "-- filemon" is at start of line.
+
+2014-09-17  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* configure.in: test that result of getconf PATH_MAX is numeric
+	  and discard if not.  Apparently needed for Hurd.
+
+2014-08-30  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* Makefile (MAKE_VERSION): 20140830
+	  Merge with NetBSD make, pick up
+	  o major overhaul of suffix handling
+	  o improved POSIX compliance
+	  o overhauled unit-tests
+
 2014-06-20  Simon J. Gerraty  <sjg at bad.crufty.net>
 
 	* Makefile (MAKE_VERSION): 20140620
 	  Merge with NetBSD make, pick up
-	  o var.c return varNoError rather than var_Error for ::= modidiers.
+	  o var.c return varNoError rather than var_Error for ::= modifiers.
 
 2014-05-22  Simon J. Gerraty  <sjg at bad.crufty.net>
 

Modified: vendor/NetBSD/bmake/dist/FILES
===================================================================
--- vendor/NetBSD/bmake/dist/FILES	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/FILES	2018-06-27 00:17:22 UTC (rev 11138)
@@ -71,6 +71,8 @@
 makefile.in
 meta.c
 meta.h
+metachar.c
+metachar.h
 missing/sys/cdefs.h
 mkdeps.sh
 nonints.h
@@ -92,35 +94,76 @@
 trace.c
 trace.h
 unit-tests/Makefile.in
-unit-tests/comment
-unit-tests/cond1
-unit-tests/doterror
-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
-unit-tests/misc
-unit-tests/moderrs
-unit-tests/modmatch
-unit-tests/modmisc
-unit-tests/modorder
-unit-tests/modts
-unit-tests/modword
-unit-tests/order
-unit-tests/phony-end
-unit-tests/posix
-unit-tests/qequals
-unit-tests/sunshcmd
-unit-tests/sysv
-unit-tests/ternary
-unit-tests/test.exp
-unit-tests/unexport
-unit-tests/unexport-env
-unit-tests/varcmd
+unit-tests/comment.exp
+unit-tests/comment.mk
+unit-tests/cond1.exp
+unit-tests/cond1.mk
+unit-tests/cond2.exp
+unit-tests/cond2.mk
+unit-tests/doterror.exp
+unit-tests/doterror.mk
+unit-tests/dotwait.exp
+unit-tests/dotwait.mk
+unit-tests/error.exp
+unit-tests/error.mk
+unit-tests/escape.exp
+unit-tests/escape.mk
+unit-tests/export-all.exp
+unit-tests/export-all.mk
+unit-tests/export-env.exp
+unit-tests/export-env.mk
+unit-tests/export.exp
+unit-tests/export.mk
+unit-tests/forloop.exp
+unit-tests/forloop.mk
+unit-tests/forsubst.exp
+unit-tests/forsubst.mk
+unit-tests/hash.exp
+unit-tests/hash.mk
+unit-tests/impsrc.exp
+unit-tests/impsrc.mk
+unit-tests/misc.exp
+unit-tests/misc.mk
+unit-tests/moderrs.exp
+unit-tests/moderrs.mk
+unit-tests/modmatch.exp
+unit-tests/modmatch.mk
+unit-tests/modmisc.exp
+unit-tests/modmisc.mk
+unit-tests/modorder.exp
+unit-tests/modorder.mk
+unit-tests/modts.exp
+unit-tests/modts.mk
+unit-tests/modword.exp
+unit-tests/modword.mk
+unit-tests/order.exp
+unit-tests/order.mk
+unit-tests/phony-end.exp
+unit-tests/phony-end.mk
+unit-tests/posix.exp
+unit-tests/posix.mk
+unit-tests/posix1.exp
+unit-tests/posix1.mk
+unit-tests/qequals.exp
+unit-tests/qequals.mk
+unit-tests/suffixes.exp
+unit-tests/suffixes.mk
+unit-tests/sunshcmd.exp
+unit-tests/sunshcmd.mk
+unit-tests/sysv.exp
+unit-tests/sysv.mk
+unit-tests/ternary.exp
+unit-tests/ternary.mk
+unit-tests/unexport-env.exp
+unit-tests/unexport-env.mk
+unit-tests/unexport.exp
+unit-tests/unexport.mk
+unit-tests/varcmd.exp
+unit-tests/varcmd.mk
+unit-tests/varmisc.exp
+unit-tests/varmisc.mk
+unit-tests/varshell.exp
+unit-tests/varshell.mk
 util.c
 var.c
 wait.h

Modified: vendor/NetBSD/bmake/dist/Makefile
===================================================================
--- vendor/NetBSD/bmake/dist/Makefile	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/Makefile	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,7 +1,7 @@
-#	$Id: Makefile,v 1.27 2014/06/20 14:51:54 sjg Exp $
+#	$Id: Makefile,v 1.95 2017/07/20 19:36:13 sjg Exp $
 
 # Base version on src date
-MAKE_VERSION= 20140620
+_MAKE_VERSION= 20170720
 
 PROG=	bmake
 
@@ -18,6 +18,7 @@
 	make.c \
 	make_malloc.c \
 	meta.c \
+	metachar.c \
 	parse.c \
 	str.c \
 	strlist.c \
@@ -75,7 +76,7 @@
 CFLAGS+= -D_PATH_DEFSYSPATH=\"${DEFAULT_SYS_PATH}\"
 CFLAGS+= -I. -I${srcdir} ${XDEFS} -DMAKE_NATIVE
 CFLAGS+= ${COPTS.${.ALLSRC:M*.c:T:u}}
-COPTS.main.c+= "-DMAKE_VERSION=\"${MAKE_VERSION}\""
+COPTS.main.c+= "-DMAKE_VERSION=\"${_MAKE_VERSION}\""
 
 # meta mode can be useful even without filemon 
 FILEMON_H ?= /usr/include/dev/filemon/filemon.h
@@ -94,7 +95,7 @@
 # we skip a lot of this when building as part of FreeBSD etc.
 
 # list of OS's which are derrived from BSD4.4
-BSD44_LIST= NetBSD FreeBSD OpenBSD DragonFly
+BSD44_LIST= NetBSD FreeBSD OpenBSD DragonFly MirBSD Bitrig
 # we are...
 OS!= uname -s
 # are we 4.4BSD ?
@@ -130,9 +131,9 @@
 .include <own.mk>
 
 .if ${MK_PROG_VERSION} == "yes"
-PROG_NAME= ${PROG}-${MAKE_VERSION}
+PROG_NAME= ${PROG}-${_MAKE_VERSION}
 .if ${MK_PROG_LINK} == "yes"
-SYMLINKS+= ${PROG}-${MAKE_VERSION} ${BINDIR}/${PROG}
+SYMLINKS+= ${PROG_NAME} ${BINDIR}/${PROG}
 .endif
 .endif
 
@@ -155,7 +156,10 @@
 .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 > $@
 
@@ -180,9 +184,9 @@
 COPTS.var.c += -Wno-format-nonliteral
 
 # Force these
-SHAREDIR= ${prefix}/share
-BINDIR= ${prefix}/bin
-MANDIR= ${SHAREDIR}/man
+SHAREDIR= ${SHAREDIR.bmake:U${prefix}/share}
+BINDIR= ${BINDIR.bmake:U${prefix}/bin}
+MANDIR= ${MANDIR.bmake:U${SHAREDIR}/man}
 
 .if !exists(.depend)
 ${OBJS}: config.h

Modified: vendor/NetBSD/bmake/dist/PSD.doc/Makefile
===================================================================
--- vendor/NetBSD/bmake/dist/PSD.doc/Makefile	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/PSD.doc/Makefile	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,8 +1,10 @@
-#	$NetBSD: Makefile,v 1.2 1995/06/14 15:20:23 christos Exp $
+#	$NetBSD: Makefile,v 1.4 2014/07/05 19:22:43 dholland Exp $
 #	@(#)Makefile	8.1 (Berkeley) 8/14/93
 
-DIR=	psd/12.make
+SECTION=reference/ref1
+ARTICLE=make
 SRCS=	tutorial.ms
 MACROS=	-ms
+EXTRAHTMLFILES=make1.png make2.png
 
 .include <bsd.doc.mk>

Modified: vendor/NetBSD/bmake/dist/PSD.doc/tutorial.ms
===================================================================
--- vendor/NetBSD/bmake/dist/PSD.doc/tutorial.ms	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/PSD.doc/tutorial.ms	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,4 +1,4 @@
-.\"	$NetBSD: tutorial.ms,v 1.11 2011/08/18 15:19:30 sjg 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.
 .\"
@@ -67,6 +67,16 @@
 .\"
 .EH 'PSD:12-%''PMake \*- A Tutorial'
 .OH 'PMake \*- A Tutorial''PSD:12-%'
+.\" Ix is an indexing macro similar to .IX but I've disabled it for now
+.\" Since that would require 2 passes and I am not in the mood for that.
+.de Ix
+..
+.\" Rd is section (region) define and Rm is region mention? Again disable for
+.\" now.
+.de Rd
+..
+.de Rm
+..
 .\" xH is a macro to provide numbered headers that are automatically stuffed
 .\" into a table-of-contents, properly indented, etc. If the first argument
 .\" is numeric, it is taken as the depth for numbering (as for .NH), else
@@ -107,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 
@@ -138,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: vendor/NetBSD/bmake/dist/README
===================================================================
--- vendor/NetBSD/bmake/dist/README	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/README	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,47 +1,52 @@
 			       bmake
+			       *****
 
-This directory contains a port of the BSD make tool (from NetBSD)
-I have run it on SunOS,Solaris,HP-UX,AIX,IRIX,FreeBSD and Linux.
+This directory contains a port of the BSD make tool (from NetBSD).
+Since 1993 I have run it on AIX, BSDi, Darwin, FreeBSD, HP-UX, IRIX,
+Linux, Minix, OSF, Solaris, SunOS and even UTS.
+Others have run it on many more systems.
 
-Version 3 was re-worked from scratch to better facilitate
-importing newer make(1) versions from NetBSD.  The original code base
-was NetBSD-1.0, so version 3 was built by doing a fresh import of the
-NetBSD-1.0 usr.bin/make, adding the autoconf and other portability
-patches to sync it with bmake v2, and then NetBSD's make 
-of Feb 20, 2000 was imported and conflicts dealt with.
-NetBSD's make was again imported on June 6 and December 15, 2000.
+Currently each release is tested on NetBSD, FreeBSD, Solaris and Linux.
 
-In 2003 bmake switched to a date based version (first was 20030714)
+Since 2003 bmake switched to a date based version (first was 20030714)
 which generally represents the date it was last merged with NetBSD's
 make.  Since then, NetBSD's make is imported within a week of any
 interesting changes, so that bmake tracks it very closely.
 
-Building:
+Building
+========
 
-The preferred way to bootstrap bmake is:
+The preferred way to bootstrap bmake is::
 
-./bmake/boot-strap
+	./bmake/boot-strap
 
 there are a number of args - most of which get passed to configure,
 eg.
+::
 
-./bmake/boot-strap --prefix=/opt
+	./bmake/boot-strap --prefix=/opt
 
 see the boot-strap script for details.
 
+For folk that hate to read anything, since 20121212 you can also use
+the GNU standard process of::
+
+	./configure; make; make install
+
 To make much use of bmake you will need the bsd.*.mk macros or my
-portable *.mk macros.  See 
+portable *.mk macros which are included with bmake since 20121212
+and separately available from
 http://www.crufty.net/ftp/pub/sjg/mk.tar.gz
 which will be links to the latest versions.
 
-On a non-BSD system, you would want to unpack mk[-YYYYmmdd].tar.gz in
-the same directory as bmake (so ./mk and ./bmake exist), and
-./bmake/boot-strap will do the rest.
+Porting
+=======
 
-If you want to do it all by hand then read boot-strap first to get the
-idea.
+If you encounter a system that bmake does not build or work on *out of
+the box*, I welcome patches.
+If you can provide access to a suitable machine - even better.
 
-Even if you have an earlier version of bmake installed, use boot-strap
-to ensure that all goes well.
+More info can be found at http://www.crufty.net/help/sjg/bmake.htm
 
---sjg
+--sjg <sjg at crufty.net>
+

Modified: vendor/NetBSD/bmake/dist/arch.c
===================================================================
--- vendor/NetBSD/bmake/dist/arch.c	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/arch.c	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,4 +1,4 @@
-/*	$NetBSD: arch.c,v 1.63 2012/06/12 19:21:50 joerg Exp $	*/
+/*	$NetBSD: arch.c,v 1.70 2017/04/16 20:49:09 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: arch.c,v 1.63 2012/06/12 19:21:50 joerg Exp $";
+static char rcsid[] = "$NetBSD: arch.c,v 1.70 2017/04/16 20:49:09 riastradh Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
@@ -76,7 +76,7 @@
 #if 0
 static char sccsid[] = "@(#)arch.c	8.2 (Berkeley) 1/2/94";
 #else
-__RCSID("$NetBSD: arch.c,v 1.63 2012/06/12 19:21:50 joerg Exp $");
+__RCSID("$NetBSD: arch.c,v 1.70 2017/04/16 20:49:09 riastradh Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -136,7 +136,6 @@
 #include    <sys/stat.h>
 #include    <sys/time.h>
 #include    <sys/param.h>
-#include    <ctype.h>
 #ifdef HAVE_AR_H
 #include    <ar.h>
 #else
@@ -156,7 +155,6 @@
 #if defined(HAVE_RANLIB_H) && !(defined(__ELF__) || defined(NO_RANLIB))
 #include    <ranlib.h>
 #endif
-#include    <fcntl.h>
 #include    <stdio.h>
 #include    <stdlib.h>
 #ifdef HAVE_UTIME_H
@@ -254,8 +252,7 @@
 	free(Hash_GetValue(entry));
 
     free(a->name);
-    if (a->fnametab)
-	free(a->fnametab);
+    free(a->fnametab);
     Hash_DeleteTable(&a->members);
     free(a);
 }
@@ -310,9 +307,10 @@
 	    void	*freeIt;
 	    char	*result;
 
-	    result = Var_Parse(cp, ctxt, TRUE, &length, &freeIt);
-	    if (freeIt)
-		free(freeIt);
+	    result = Var_Parse(cp, ctxt, VARF_UNDEFERR|VARF_WANTRES,
+			       &length, &freeIt);
+	    free(freeIt);
+
 	    if (result == var_Error) {
 		return(FAILURE);
 	    } else {
@@ -325,7 +323,7 @@
 
     *cp++ = '\0';
     if (subLibName) {
-	libName = Var_Subst(NULL, libName, ctxt, TRUE);
+	libName = Var_Subst(NULL, libName, ctxt, VARF_UNDEFERR|VARF_WANTRES);
     }
 
 
@@ -351,9 +349,10 @@
 		void	*freeIt;
 		char	*result;
 
-		result = Var_Parse(cp, ctxt, TRUE, &length, &freeIt);
-		if (freeIt)
-		    free(freeIt);
+		result = Var_Parse(cp, ctxt, VARF_UNDEFERR|VARF_WANTRES,
+				   &length, &freeIt);
+		free(freeIt);
+
 		if (result == var_Error) {
 		    return(FAILURE);
 		} else {
@@ -404,7 +403,8 @@
 	    char    *oldMemName = memName;
 	    size_t   sz;
 
-	    memName = Var_Subst(NULL, memName, ctxt, TRUE);
+	    memName = Var_Subst(NULL, memName, ctxt,
+				VARF_UNDEFERR|VARF_WANTRES);
 
 	    /*
 	     * Now form an archive spec and recurse to deal with nested
@@ -726,7 +726,8 @@
 		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 @@
 	    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);
@@ -759,8 +761,7 @@
 badarch:
     fclose(arch);
     Hash_DeleteTable(&ar->members);
-    if (ar->fnametab)
-	free(ar->fnametab);
+    free(ar->fnametab);
     free(ar);
     return NULL;
 }
@@ -833,7 +834,7 @@
 	    }
 	if (DEBUG(ARCH)) {
 	    fprintf(debug_file, "Found svr4 archive name table with %lu entries\n",
-	            (u_long)entry);
+	            (unsigned long)entry);
 	}
 	return 0;
     }
@@ -851,7 +852,7 @@
     if (entry >= ar->fnamesize) {
 	if (DEBUG(ARCH)) {
 	    fprintf(debug_file, "SVR4 entry offset %s is greater than %lu\n",
-		   name, (u_long)ar->fnamesize);
+		   name, (unsigned long)ar->fnamesize);
 	}
 	return 2;
     }
@@ -957,7 +958,10 @@
 		 * 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
@@ -987,10 +991,17 @@
 		}
 		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
@@ -1003,9 +1014,12 @@
 	     * 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;
+	    }
 	}
     }
 
@@ -1045,10 +1059,10 @@
     arch = ArchFindMember(Var_Value(ARCHIVE, gn, &p1),
 			  Var_Value(MEMBER, gn, &p2),
 			  &arh, "r+");
-    if (p1)
-	free(p1);
-    if (p2)
-	free(p2);
+
+    free(p1);
+    free(p2);
+
     snprintf(arh.AR_DATE, sizeof(arh.AR_DATE), "%-12ld", (long) now);
 
     if (arch != NULL) {
@@ -1127,11 +1141,10 @@
     arhPtr = ArchStatMember(Var_Value(ARCHIVE, gn, &p1),
 			     Var_Value(MEMBER, gn, &p2),
 			     TRUE);
-    if (p1)
-	free(p1);
-    if (p2)
-	free(p2);
 
+    free(p1);
+    free(p2);
+
     if (arhPtr != NULL) {
 	modTime = (time_t)strtol(arhPtr->AR_DATE, NULL, 10);
     } else {

Modified: vendor/NetBSD/bmake/dist/bmake.1
===================================================================
--- vendor/NetBSD/bmake/dist/bmake.1	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/bmake.1	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,4 +1,4 @@
-.\"	$NetBSD: make.1,v 1.229 2014/01/19 10:23:29 apb Exp $
+.\"	$NetBSD: make.1,v 1.271 2017/07/03 21:34:20 wiz 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 February 14, 2014
-.Dt MAKE 1
+.Dd June 22, 2017
+.Dt BMAKE 1
 .Os
 .Sh NAME
 .Nm bmake
@@ -48,6 +48,7 @@
 .Op Fl m Ar directory
 .Op Fl T Ar file
 .Op Fl V Ar variable
+.Op Fl v Ar variable
 .Op Ar variable=value
 .Op Ar target ...
 .Sh DESCRIPTION
@@ -206,11 +207,11 @@
 .It Ar V
 Force the
 .Fl V
-option to print raw values of variables.
+option to print raw values of variables, overriding the default behavior
+set via
+.Va .MAKE.EXPAND_VARIABLES .
 .It Ar v
 Print debugging information about variable assignment.
-.It Ar w
-Print entering and leaving directory messages, pre and post processing.
 .It Ar x
 Run shell commands with
 .Fl x
@@ -295,7 +296,7 @@
 will search for the specified file or directory named in the remaining part
 of the argument string.
 The search starts with the current directory of
-the Makefile and then works upward towards the root of the filesystem.
+the Makefile and then works upward towards the root of the file system.
 If the search is successful, then the resulting directory replaces the
 .Qq \&.../
 specification in the
@@ -336,22 +337,43 @@
 Rather than re-building a target as specified in the makefile, create it
 or update its modification time to make it appear up-to-date.
 .It Fl V Ar variable
-Print
-.Nm Ns 's
-idea of the value of
-.Ar variable ,
-in the global context.
+Print the value of
+.Ar variable .
 Do not build any targets.
 Multiple instances of this option may be specified;
 the variables will be printed one per line,
 with a blank line for each null or undefined variable.
+The value printed is extracted from the global context after all
+makefiles have been read.
+By default, the raw variable contents (which may
+include additional unexpanded variable references) are shown.
 If
 .Ar variable
 contains a
 .Ql \&$
-then the value will be expanded before printing.
+then the value will be recursively expanded to its complete resultant
+text before printing.
+The expanded value will also be printed if
+.Va .MAKE.EXPAND_VARIABLES
+is set to true and
+the
+.Fl dV
+option has not been used to override it.
+Note that loop-local and target-local variables, as well as values
+taken temporarily by global variables during makefile processing, are
+not accessible via this option.
+The
+.Fl dv
+debug mode can be used to see these at the cost of generating
+substantial extraneous output.
+.It Fl v Ar variable
+Like
+.Fl V
+but the variable is always expanded to its complete value.
 .It Fl W
 Treat any warnings during makefile parsing as errors.
+.It Fl w
+Print entering and leaving directory messages, pre and post processing.
 .It Fl X
 Don't export variables passed on the command line to the environment
 individually.
@@ -441,17 +463,29 @@
 need not necessarily be used to describe existing files.
 Expansion is in directory order, not alphabetically as done in the shell.
 .Sh SHELL COMMANDS
-Each target may have associated with it a series of shell commands, normally
+Each target may have associated with it one or more lines of shell
+commands, normally
 used to create the target.
-Each of the commands in this script
+Each of the lines in this script
 .Em must
 be preceded by a tab.
-While any target may appear on a dependency line, only one of these
-dependencies may be followed by a creation script, unless the
+(For historical reasons, spaces are not accepted.)
+While targets can appear in many dependency lines if desired, by
+default only one of these rules may be followed by a creation
+script.
+If the
 .Ql Ic \&::
-operator is used.
+operator is used, however, all rules may include scripts and the
+scripts are executed in the order found.
 .Pp
-If the first characters of the command line are any combination of
+Each line is treated as a separate shell command, unless the end of
+line is escaped with a backslash
+.Pq Ql \e
+in which case that line and the next are combined.
+.\" The escaped newline is retained and passed to the shell, which
+.\" normally ignores it.
+.\" However, the tab at the beginning of the following line is removed.
+If the first characters of the command are any combination of
 .Ql Ic @ ,
 .Ql Ic + ,
 or
@@ -469,6 +503,7 @@
 except that the effect can be limited to a single line of a script.
 A
 .Ql Ic \-
+in compatibility mode
 causes any non-zero exit status of the command line to be ignored.
 .Pp
 When
@@ -477,23 +512,22 @@
 .Fl j Ar max_jobs ,
 the entire script for the target is fed to a
 single instance of the shell.
-.Pp
 In compatibility (non-jobs) mode, each command is run in a separate process.
 If the command contains any shell meta characters
 .Pq Ql #=|^(){};&<>*?[]:$`\e\en
-it will be passed to the shell, otherwise
+it will be passed to the shell; otherwise
 .Nm
 will attempt direct execution.
+If a line starts with
+.Ql Ic \-
+and the shell has ErrCtl enabled then failure of the command line
+will be ignored as in compatibility mode.
+Otherwise
+.Ql Ic \-
+affects the entire job;
+the script will stop at the first command line that fails,
+but the target will not be deemed to have failed.
 .Pp
-Since
-.Nm
-will
-.Xr chdir 2
-to
-.Ql Va .OBJDIR
-before executing any targets, each child process
-starts with that as its current working directory.
-.Pp
 Makefiles should be written so that the mode of
 .Nm
 operation does not change their behavior.
@@ -500,20 +534,32 @@
 For example, any command which needs to use
 .Dq cd
 or
-.Dq chdir ,
-without side-effect should be put in parenthesis:
+.Dq chdir
+without potentially changing the directory for subsequent commands
+should be put in parentheses so it executes in a subshell.
+To force the use of one shell, escape the line breaks so as to make
+the whole script one command.
+For example:
 .Bd -literal -offset indent
-
 avoid-chdir-side-effects:
 	@echo Building $@ in `pwd`
-	@(cd ${.CURDIR} && ${.MAKE} $@)
+	@(cd ${.CURDIR} && ${MAKE} $@)
 	@echo Back in `pwd`
 
 ensure-one-shell-regardless-of-mode:
-	@echo Building $@ in `pwd`; \\
-	(cd ${.CURDIR} && ${.MAKE} $@); \\
+	@echo Building $@ in `pwd`; \e
+	(cd ${.CURDIR} && ${MAKE} $@); \e
 	echo Back in `pwd`
 .Ed
+.Pp
+Since
+.Nm
+will
+.Xr chdir 2
+to
+.Ql Va .OBJDIR
+before executing any targets, each child process
+starts with that as its current working directory.
 .Sh VARIABLE ASSIGNMENTS
 Variables in make are much like variables in the shell, and, by tradition,
 consist of all upper-case letters.
@@ -624,22 +670,29 @@
 Variables defined as part of the command line.
 .It Local variables
 Variables that are defined specific to a certain target.
+.El
+.Pp
+Local variables are all built in and their values vary magically from
+target to target.
+It is not currently possible to define new local variables.
 The seven local variables are as follows:
-.Bl -tag -width ".ARCHIVE"
+.Bl -tag -width ".ARCHIVE" -offset indent
 .It Va .ALLSRC
 The list of all sources for this target; also known as
-.Ql Va \&\*[Gt] .
+.Ql Va \&> .
 .It Va .ARCHIVE
-The name of the archive file.
+The name of the archive file; also known as
+.Ql Va \&! .
 .It Va .IMPSRC
 In suffix-transformation rules, the name/path of the source from which the
 target is to be transformed (the
 .Dq implied
 source); also known as
-.Ql Va \&\*[Lt] .
+.Ql Va \&< .
 It is not defined in explicit rules.
 .It Va .MEMBER
-The name of the archive member.
+The name of the archive member; also known as
+.Ql Va % .
 .It Va .OODATE
 The list of sources for this target that were deemed out-of-date; also
 known as
@@ -648,31 +701,44 @@
 The file prefix of the target, containing only the file portion, no suffix
 or preceding directory components; also known as
 .Ql Va * .
+The suffix must be one of the known suffixes declared with
+.Ic .SUFFIXES
+or it will not be recognized.
 .It Va .TARGET
 The name of the target; also known as
 .Ql Va @ .
+For compatibility with other makes this is an alias for
+.Ic .ARCHIVE
+in archive member rules.
 .El
 .Pp
 The shorter forms
-.Ql Va @ ,
+.Ql ( Va > ,
+.Ql Va \&! ,
+.Ql Va < ,
+.Ql Va % ,
 .Ql Va \&? ,
-.Ql Va \&\*[Lt] ,
-.Ql Va \&\*[Gt] ,
+.Ql Va * ,
 and
-.Ql Va *
+.Ql Va @ )
 are permitted for backward
-compatibility with historical makefiles and are not recommended.
-The six variables
-.Ql Va "@F" ,
-.Ql Va "@D" ,
-.Ql Va "\*[Lt]F" ,
-.Ql Va "\*[Lt]D" ,
-.Ql Va "*F" ,
+compatibility with historical makefiles and legacy POSIX make and are
+not recommended.
+.Pp
+Variants of these variables with the punctuation followed immediately by
+.Ql D
+or
+.Ql F ,
+e.g.
+.Ql Va $(@D) ,
+are legacy forms equivalent to using the
+.Ql :H
 and
-.Ql Va "*D"
-are permitted for compatibility with
+.Ql :T
+modifiers.
+These forms are accepted for compatibility with
 .At V
-makefiles and are not recommended.
+makefiles and POSIX but are not recommended.
 .Pp
 Four of the local variables may be used in sources on dependency lines
 because they expand to the proper value for each target on the line.
@@ -682,7 +748,6 @@
 .Ql Va .ARCHIVE ,
 and
 .Ql Va .MEMBER .
-.El
 .Ss Additional built-in variables
 In addition,
 .Nm
@@ -733,6 +798,10 @@
 A boolean that controls the default behavior of the
 .Fl V
 option.
+If true, variable values printed with
+.Fl V
+are fully expanded; if false, the raw variable contents (which may
+include additional unexpanded variable references) are shown.
 .It Va .MAKE.EXPORTED
 The list of variables exported by
 .Nm .
@@ -803,7 +872,7 @@
 .Nm
 runs in.
 It can contain a number of keywords:
-.Bl -hang -width ignore-cmd
+.Bl -hang -width missing-filemon=bf.
 .It Pa compat
 Like
 .Fl B ,
@@ -827,8 +896,19 @@
 This can be overridden by setting
 .Va bf
 to a value which represents True.
+.It Pa missing-meta= Ar bf
+If
+.Va bf
+is True, then a missing .meta file makes the target out-of-date.
+.It Pa missing-filemon= Ar bf
+If
+.Va bf
+is True, then missing filemon data makes the target out-of-date.
+.It Pa nofilemon
+Do not use
+.Xr filemon 4 .
 .It Pa env
-For debugging, it can be useful to inlcude the environment
+For debugging, it can be useful to include the environment
 in the .meta file.
 .It Pa verbose
 If in "meta" mode, print a clue about the target being built.
@@ -870,6 +950,12 @@
 because the contents are expected to change over time.
 The default list includes:
 .Ql Pa /dev /etc /proc /tmp /var/run /var/tmp
+.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:
@@ -878,7 +964,7 @@
 This variable is used to record the names of variables assigned to
 on the command line, so that they may be exported as part of
 .Ql Ev MAKEFLAGS .
-This behaviour can be disabled by assigning an empty value to
+This behavior can be disabled by assigning an empty value to
 .Ql Va .MAKEOVERRIDES
 within a makefile.
 Extra variables can be exported from a makefile
@@ -901,10 +987,35 @@
 .It Va .MAKE.PPID
 The parent process-id of
 .Nm .
+.It Va .MAKE.SAVE_DOLLARS
+value should be a boolean that controls whether
+.Ql $$
+are preserved when doing
+.Ql :=
+assignments.
+The default is false, for backwards compatibility.
+Set to true for compatability with other makes.
+If set to false,
+.Ql $$
+becomes
+.Ql $
+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 .
@@ -953,14 +1064,15 @@
 .Ql Ev MAKEOBJDIR .
 .Pp
 .Ql Va .OBJDIR
-may be modified in the makefile as a global variable.
+may be modified in the makefile via the special target
+.Ql Ic .OBJDIR .
 In all cases,
 .Nm
 will
 .Xr chdir 2
-to
+to the specified directory if it exists, and set
 .Ql Va .OBJDIR
-and set
+and
 .Ql Ev PWD
 to that directory before executing any targets.
 .
@@ -1003,7 +1115,7 @@
 to the value of
 .Ql Ev PWD
 instead.
-This behaviour is disabled if
+This behavior is disabled if
 .Ql Ev MAKEOBJDIRPREFIX
 is set or
 .Ql Ev MAKEOBJDIR
@@ -1073,7 +1185,7 @@
 As a consequence of the way values are split into words, matched,
 and then joined, a construct like
 .Dl ${VAR:M*}
-will normalise the inter-word spacing, removing all leading and
+will normalize the inter-word spacing, removing all leading and
 trailing space, and converting multiple consecutive spaces
 to single spaces.
 .
@@ -1093,7 +1205,7 @@
 The results will be different each time you are referring to the
 modified variable; use the assignment with expansion
 .Pq Ql Cm \&:=
-to prevent such behaviour.
+to prevent such behavior.
 For example,
 .Bd -literal -offset indent
 LIST=			uno due tre quattro
@@ -1119,18 +1231,28 @@
 .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 32bit hash of the value and encode it as hex digits.
-.It Cm \&:localtime
+Compute a 32-bit hash of the value and encode it as hex digits.
+.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 ,
@@ -1191,7 +1313,7 @@
 Inside
 .Ar new_string ,
 an ampersand
-.Pq Ql \*[Am]
+.Pq Ql &
 is replaced by
 .Ar old_string
 (without any
@@ -1330,6 +1452,27 @@
 .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 at + $${_:[-$$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
@@ -1403,7 +1546,7 @@
 .Pp
 Ordinarily, a value is treated as a sequence of words
 delimited by white space.
-Some modifiers suppress this behaviour,
+Some modifiers suppress this behavior,
 causing a value to be treated as a single word
 (possibly containing embedded white space).
 An empty value, or a value that consists entirely of white-space,
@@ -1489,6 +1632,7 @@
 .Nm
 .Ql include file ...
 is also accepted.
+.Pp
 If the include statement is written as
 .Cm .-include
 or as
@@ -1495,6 +1639,13 @@
 .Cm .sinclude
 then errors locating and/or opening include files are ignored.
 .Pp
+If the include statement is written as
+.Cm .dinclude
+not only are errors locating and/or opening include files ignored,
+but stale dependencies within the included file will be ignored
+just like
+.Va .MAKE.DEPENDFILE .
+.Pp
 Conditional expressions are also preceded by a single dot as the first
 character of a line.
 The possible conditionals are as follows:
@@ -1530,6 +1681,10 @@
 used by
 .Nm
 internally.
+.It Ic .export-literal Ar variable ...
+The same as
+.Ql .export-env ,
+except that variables in the value are not expanded.
 .It Ic .info Ar message
 The message is printed along with the name of the makefile and line number.
 .It Ic .undef Ar variable
@@ -1622,7 +1777,7 @@
 .Bl -tag -width "Cm XX"
 .It Cm \&|\&|
 Logical OR.
-.It Cm \&\*[Am]\*[Am]
+.It Cm \&&&
 Logical
 .Tn AND ;
 of higher precedence than
@@ -1639,7 +1794,7 @@
 may be used to logically negate an entire
 conditional.
 It is of higher precedence than
-.Ql Ic \&\*[Am]\*[Am] .
+.Ql Ic \&&& .
 .Pp
 The value of
 .Ar expression
@@ -1913,6 +2068,14 @@
 .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.
@@ -1961,6 +2124,15 @@
 Synonym for
 .Ic .NOTPARALLEL ,
 for compatibility with other pmake variants.
+.It Ic .OBJDIR
+The source is a new value for
+.Ql Va .OBJDIR .
+If it exists,
+.Nm
+will
+.Xr chdir 2
+to it and update the value of
+.Ql Va .OBJDIR .
 .It Ic .ORDER
 The named targets are made in sequence.
 This ordering does not add targets to the list of targets to be made.
@@ -2018,7 +2190,7 @@
 pairs.
 .Bl -tag -width hasErrCtls
 .It Ar name
-This is the minimal specification, used to select one of the builtin
+This is the minimal specification, used to select one of the built-in
 shell specs;
 .Ar sh ,
 .Ar ksh ,
@@ -2119,19 +2291,87 @@
 system makefile directory
 .El
 .Sh COMPATIBILITY
-The basic make syntax is compatible between different versions of make,
+The basic make syntax is compatible between different versions of make;
 however the special variables, variable modifiers and conditionals are not.
+.Ss Older versions
+An incomplete list of changes in older versions of
+.Nm :
 .Pp
+The way that .for loop variables are substituted changed after
+NetBSD 5.0
+so that they still appear to be variable expansions.
+In particular this stops them being treated as syntax, and removes some
+obscure problems using them in .if statements.
+.Pp
 The way that parallel makes are scheduled changed in
 NetBSD 4.0
 so that .ORDER and .WAIT apply recursively to the dependent nodes.
 The algorithms used may change again in the future.
+.Ss Other make dialects
+Other make dialects (GNU make, SVR4 make, POSIX make, etc.) do not
+support most of the features of
+.Nm
+as described in this manual.
+Most notably:
+.Bl -bullet -offset indent
+.It
+The
+.Ic .WAIT
+and
+.Ic .ORDER
+declarations and most functionality pertaining to parallelization.
+(GNU make supports parallelization but lacks these features needed to
+control it effectively.)
+.It
+Directives, including for loops and conditionals and most of the
+forms of include files.
+(GNU make has its own incompatible and less powerful syntax for
+conditionals.)
+.It
+All built-in variables that begin with a dot.
+.It
+Most of the special sources and targets that begin with a dot,
+with the notable exception of
+.Ic .PHONY ,
+.Ic .PRECIOUS ,
+and
+.Ic .SUFFIXES .
+.It
+Variable modifiers, except for the
+.Dl :old=new
+string substitution, which does not portably support globbing with
+.Ql %
+and historically only works on declared suffixes.
+.It
+The
+.Ic $>
+variable even in its short form; most makes support this functionality
+but its name varies.
+.El
 .Pp
-The way that .for loop variables are substituted changed after
-NetBSD 5.0
-so that they still appear to be variable expansions.
-In particular this stops them being treated as syntax, and removes some
-obscure problems using them in .if statements.
+Some features are somewhat more portable, such as assignment with
+.Ic += ,
+.Ic ?= ,
+and
+.Ic != .
+The
+.Ic .PATH
+functionality is based on an older feature
+.Ic VPATH
+found in GNU make and many versions of SVR4 make; however,
+historically its behavior is too ill-defined (and too buggy) to rely
+upon.
+.Pp
+The
+.Ic $@
+and
+.Ic $<
+variables are more or less universally portable, as is the
+.Ic $(MAKE)
+variable.
+Basic use of suffix rules (for files only in the current directory,
+not trying to chain transformations together, etc.) is also reasonably
+portable.
 .Sh SEE ALSO
 .Xr mkdep 1
 .Sh HISTORY

Modified: vendor/NetBSD/bmake/dist/bmake.cat1
===================================================================
--- vendor/NetBSD/bmake/dist/bmake.cat1	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/bmake.cat1	2018-06-27 00:17:22 UTC (rev 11138)
@@ -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
@@ -6,8 +6,8 @@
 SSYYNNOOPPSSIISS
      bbmmaakkee [--BBeeiikkNNnnqqrrssttWWwwXX] [--CC _d_i_r_e_c_t_o_r_y] [--DD _v_a_r_i_a_b_l_e] [--dd _f_l_a_g_s]
            [--ff _m_a_k_e_f_i_l_e] [--II _d_i_r_e_c_t_o_r_y] [--JJ _p_r_i_v_a_t_e] [--jj _m_a_x___j_o_b_s]
-           [--mm _d_i_r_e_c_t_o_r_y] [--TT _f_i_l_e] [--VV _v_a_r_i_a_b_l_e] [_v_a_r_i_a_b_l_e_=_v_a_l_u_e]
-           [_t_a_r_g_e_t _._._.]
+           [--mm _d_i_r_e_c_t_o_r_y] [--TT _f_i_l_e] [--VV _v_a_r_i_a_b_l_e] [--vv _v_a_r_i_a_b_l_e]
+           [_v_a_r_i_a_b_l_e_=_v_a_l_u_e] [_t_a_r_g_e_t _._._.]
 
 DDEESSCCRRIIPPTTIIOONN
      bbmmaakkee is a program designed to simplify the maintenance of other pro-
@@ -118,13 +118,12 @@
              _t       Print debugging information about target list mainte-
                      nance.
 
-             _V       Force the --VV option to print raw values of variables.
+             _V       Force the --VV option to print raw values of variables,
+                     overriding the default behavior set via
+                     _._M_A_K_E_._E_X_P_A_N_D___V_A_R_I_A_B_L_E_S.
 
              _v       Print debugging information about variable assignment.
 
-             _w       Print entering and leaving directory messages, pre and
-                     post processing.
-
              _x       Run shell commands with --xx so the actual commands are
                      printed as they are executed.
 
@@ -181,11 +180,11 @@
              then bbmmaakkee will search for the specified file or directory named
              in the remaining part of the argument string.  The search starts
              with the current directory of the Makefile and then works upward
-             towards the root of the filesystem.  If the search is successful,
-             then the resulting directory replaces the ".../" specification in
-             the --mm argument.  If used, this feature allows bbmmaakkee to easily
-             search in the current source tree for customized sys.mk files
-             (e.g., by using ".../mk/sys.mk" as an argument).
+             towards the root of the file system.  If the search is success-
+             ful, then the resulting directory replaces the ".../" specifica-
+             tion in the --mm argument.  If used, this feature allows bbmmaakkee to
+             easily search in the current source tree for customized sys.mk
+             files (e.g., by using ".../mk/sys.mk" as an argument).
 
      --nn      Display the commands that would have been executed, but do not
              actually execute them unless the target depends on the .MAKE spe-
@@ -212,15 +211,31 @@
              to-date.
 
      --VV _v_a_r_i_a_b_l_e
-             Print bbmmaakkee's idea of the value of _v_a_r_i_a_b_l_e, in the global con-
-             text.  Do not build any targets.  Multiple instances of this
-             option may be specified; the variables will be printed one per
-             line, with a blank line for each null or undefined variable.  If
-             _v_a_r_i_a_b_l_e contains a `$' then the value will be expanded before
-             printing.
+             Print the value of _v_a_r_i_a_b_l_e.  Do not build any targets.  Multiple
+             instances of this option may be specified; the variables will be
+             printed one per line, with a blank line for each null or unde-
+             fined variable.  The value printed is extracted from the global
+             context after all makefiles have been read.  By default, the raw
+             variable contents (which may include additional unexpanded vari-
+             able references) are shown.  If _v_a_r_i_a_b_l_e contains a `$' then the
+             value will be recursively expanded to its complete resultant text
+             before printing.  The expanded value will also be printed if
+             _._M_A_K_E_._E_X_P_A_N_D___V_A_R_I_A_B_L_E_S is set to true and the --ddVV option has not
+             been used to override it.  Note that loop-local and target-local
+             variables, as well as values taken temporarily by global vari-
+             ables during makefile processing, are not accessible via this
+             option.  The --ddvv debug mode can be used to see these at the cost
+             of generating substantial extraneous output.
 
+     --vv _v_a_r_i_a_b_l_e
+             Like --VV but the variable is always expanded to its complete
+             value.
+
      --WW      Treat any warnings during makefile parsing as errors.
 
+     --ww      Print entering and leaving directory messages, pre and post pro-
+             cessing.
+
      --XX      Don't export variables passed on the command line to the environ-
              ment individually.  Variables passed on the command line are
              still exported via the _M_A_K_E_F_L_A_G_S environment variable.  This
@@ -273,46 +288,55 @@
      done in the shell.
 
 SSHHEELLLL CCOOMMMMAANNDDSS
-     Each target may have associated with it a series of shell commands, nor-
-     mally used to create the target.  Each of the commands in this script
-     _m_u_s_t be preceded by a tab.  While any target may appear on a dependency
-     line, only one of these dependencies may be followed by a creation
-     script, unless the `::::' operator is used.
+     Each target may have associated with it one or more lines of shell com-
+     mands, normally used to create the target.  Each of the lines in this
+     script _m_u_s_t be preceded by a tab.  (For historical reasons, spaces are
+     not accepted.)  While targets can appear in many dependency lines if
+     desired, by default only one of these rules may be followed by a creation
+     script.  If the `::::' operator is used, however, all rules may include
+     scripts and the scripts are executed in the order found.
 
-     If the first characters of the command line are any combination of `@@',
-     `++', or `--', the command is treated specially.  A `@@' causes the command
-     not to be echoed before it is executed.  A `++' causes the command to be
-     executed even when --nn is given.  This is similar to the effect of the
-     .MAKE special source, except that the effect can be limited to a single
-     line of a script.  A `--' causes any non-zero exit status of the command
-     line to be ignored.
+     Each line is treated as a separate shell command, unless the end of line
+     is escaped with a backslash (`\') in which case that line and the next
+     are combined.  If the first characters of the command are any combination
+     of `@@', `++', or `--', the command is treated specially.  A `@@' causes the
+     command not to be echoed before it is executed.  A `++' causes the command
+     to be executed even when --nn is given.  This is similar to the effect of
+     the .MAKE special source, except that the effect can be limited to a sin-
+     gle line of a script.  A `--' in compatibility mode causes any non-zero
+     exit status of the command line to be ignored.
 
      When bbmmaakkee is run in jobs mode with --jj _m_a_x___j_o_b_s, the entire script for
-     the target is fed to a single instance of the shell.
+     the target is fed to a single instance of the shell.  In compatibility
+     (non-jobs) mode, each command is run in a separate process.  If the com-
+     mand contains any shell meta characters (`#=|^(){};&<>*?[]:$`\\n') it
+     will be passed to the shell; otherwise bbmmaakkee will attempt direct execu-
+     tion.  If a line starts with `--' and the shell has ErrCtl enabled then
+     failure of the command line will be ignored as in compatibility mode.
+     Otherwise `--' affects the entire job; the script will stop at the first
+     command line that fails, but the target will not be deemed to have
+     failed.
 
-     In compatibility (non-jobs) mode, each command is run in a separate
-     process.  If the command contains any shell meta characters
-     (`#=|^(){};&<>*?[]:$`\\n') it will be passed to the shell, otherwise
-     bbmmaakkee will attempt direct execution.
-
-     Since bbmmaakkee will chdir(2) to `_._O_B_J_D_I_R' before executing any targets, each
-     child process starts with that as its current working directory.
-
      Makefiles should be written so that the mode of bbmmaakkee operation does not
      change their behavior.  For example, any command which needs to use
-     ``cd'' or ``chdir'', without side-effect should be put in parenthesis:
+     ``cd'' or ``chdir'' without potentially changing the directory for subse-
+     quent commands should be put in parentheses so it executes in a subshell.
+     To force the use of one shell, escape the line breaks so as to make the
+     whole script one command.  For example:
 
-
            avoid-chdir-side-effects:
                    @echo Building $@ in `pwd`
-                   @(cd ${.CURDIR} && ${.MAKE} $@)
+                   @(cd ${.CURDIR} && ${MAKE} $@)
                    @echo Back in `pwd`
 
            ensure-one-shell-regardless-of-mode:
                    @echo Building $@ in `pwd`; \
-                   (cd ${.CURDIR} && ${.MAKE} $@); \
+                   (cd ${.CURDIR} && ${MAKE} $@); \
                    echo Back in `pwd`
 
+     Since bbmmaakkee will chdir(2) to `_._O_B_J_D_I_R' before executing any targets, each
+     child process starts with that as its current working directory.
+
 VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNTTSS
      Variables in make are much like variables in the shell, and, by tradi-
      tion, consist of all upper-case letters.
@@ -402,41 +426,50 @@
              Variables defined as part of the command line.
 
      Local variables
-             Variables that are defined specific to a certain target.  The
-             seven local variables are as follows:
+             Variables that are defined specific to a certain target.
 
-             _._A_L_L_S_R_C   The list of all sources for this target; also known as
-                       `_>'.
+     Local variables are all built in and their values vary magically from
+     target to target.  It is not currently possible to define new local vari-
+     ables.  The seven local variables are as follows:
 
-             _._A_R_C_H_I_V_E  The name of the archive file.
+           _._A_L_L_S_R_C   The list of all sources for this target; also known as
+                     `_>'.
 
-             _._I_M_P_S_R_C   In suffix-transformation rules, the name/path of the
-                       source from which the target is to be transformed (the
-                       ``implied'' source); also known as `_<'.  It is not
-                       defined in explicit rules.
+           _._A_R_C_H_I_V_E  The name of the archive file; also known as `_!'.
 
-             _._M_E_M_B_E_R   The name of the archive member.
+           _._I_M_P_S_R_C   In suffix-transformation rules, the name/path of the
+                     source from which the target is to be transformed (the
+                     ``implied'' source); also known as `_<'.  It is not
+                     defined in explicit rules.
 
-             _._O_O_D_A_T_E   The list of sources for this target that were deemed
-                       out-of-date; also known as `_?'.
+           _._M_E_M_B_E_R   The name of the archive member; also known as `_%'.
 
-             _._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 `_*'.
+           _._O_O_D_A_T_E   The list of sources for this target that were deemed out-
+                     of-date; also known as `_?'.
 
-             _._T_A_R_G_E_T   The name of the target; also known as `_@'.
+           _._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 `_*'.  The suffix must be one of the known
+                     suffixes declared with ..SSUUFFFFIIXXEESS or it will not be recog-
+                     nized.
 
-             The shorter forms `_@', `_?', `_<', `_>', and `_*' are permitted for
-             backward compatibility with historical makefiles and are not rec-
-             ommended.  The six variables `_@_F', `_@_D', `_<_F', `_<_D', `_*_F', and
-             `_*_D' are permitted for compatibility with AT&T System V UNIX
-             makefiles and are not recommended.
+           _._T_A_R_G_E_T   The name of the target; also known as `_@'.  For compati-
+                     bility with other makes this is an alias for ..AARRCCHHIIVVEE in
+                     archive member rules.
 
-             Four of the local variables may be used in sources on dependency
-             lines because they expand to the proper value for each target on
-             the line.  These variables are `_._T_A_R_G_E_T', `_._P_R_E_F_I_X', `_._A_R_C_H_I_V_E',
-             and `_._M_E_M_B_E_R'.
+     The shorter forms (`_>', `_!', `_<', `_%', `_?', `_*', and `_@') are permitted
+     for backward compatibility with historical makefiles and legacy POSIX
+     make and are not recommended.
 
+     Variants of these variables with the punctuation followed immediately by
+     `D' or `F', e.g.  `_$_(_@_D_)', are legacy forms equivalent to using the `:H'
+     and `:T' modifiers.  These forms are accepted for compatibility with AT&T
+     System V UNIX makefiles and POSIX but are not recommended.
+
+     Four of the local variables may be used in sources on dependency lines
+     because they expand to the proper value for each target on the line.
+     These variables are `_._T_A_R_G_E_T', `_._P_R_E_F_I_X', `_._A_R_C_H_I_V_E', and `_._M_E_M_B_E_R'.
+
    AAddddiittiioonnaall bbuuiilltt--iinn vvaarriiaabblleess
      In addition, bbmmaakkee sets or knows about the following variables:
 
@@ -470,7 +503,10 @@
 
      _._M_A_K_E_._E_X_P_A_N_D___V_A_R_I_A_B_L_E_S
                      A boolean that controls the default behavior of the --VV
-                     option.
+                     option.  If true, variable values printed with --VV are
+                     fully expanded; if false, the raw variable contents
+                     (which may include additional unexpanded variable refer-
+                     ences) are shown.
 
      _._M_A_K_E_._E_X_P_O_R_T_E_D  The list of variables exported by bbmmaakkee.
 
@@ -513,38 +549,52 @@
                      mode that bbmmaakkee runs in.  It can contain a number of key-
                      words:
 
-                     _c_o_m_p_a_t      Like --BB, puts bbmmaakkee into "compat" mode.
+                     _c_o_m_p_a_t               Like --BB, puts bbmmaakkee into "compat"
+                                          mode.
 
-                     _m_e_t_a        Puts bbmmaakkee into "meta" mode, where meta files
-                                 are created for each target to capture the
-                                 command run, the output generated and if
-                                 filemon(4) is available, the system calls
-                                 which are of interest to bbmmaakkee.  The captured
-                                 output can be very useful when diagnosing
-                                 errors.
+                     _m_e_t_a                 Puts bbmmaakkee into "meta" mode, where
+                                          meta files are created for each tar-
+                                          get to capture the command run, the
+                                          output generated and if filemon(4)
+                                          is available, the system calls which
+                                          are of interest to bbmmaakkee.  The cap-
+                                          tured output can be very useful when
+                                          diagnosing errors.
 
-                     _c_u_r_d_i_r_O_k_= _b_f Normally bbmmaakkee will not create .meta files
-                                 in `_._C_U_R_D_I_R'.  This can be overridden by set-
-                                 ting _b_f to a value which represents True.
+                     _c_u_r_d_i_r_O_k_= _b_f         Normally bbmmaakkee will not create .meta
+                                          files in `_._C_U_R_D_I_R'.  This can be
+                                          overridden by setting _b_f to a value
+                                          which represents True.
 
-                     _e_n_v         For debugging, it can be useful to inlcude
-                                 the environment in the .meta file.
+                     _m_i_s_s_i_n_g_-_m_e_t_a_= _b_f     If _b_f is True, then a missing .meta
+                                          file makes the target out-of-date.
 
-                     _v_e_r_b_o_s_e     If in "meta" mode, print a clue about the
-                                 target being built.  This is useful if the
-                                 build is otherwise running silently.  The
-                                 message printed the value of:
-                                 _._M_A_K_E_._M_E_T_A_._P_R_E_F_I_X.
+                     _m_i_s_s_i_n_g_-_f_i_l_e_m_o_n_= _b_f  If _b_f is True, then missing filemon
+                                          data makes the target out-of-date.
 
-                     _i_g_n_o_r_e_-_c_m_d  Some makefiles have commands which are simply
-                                 not stable.  This keyword causes them to be
-                                 ignored for determining whether a target is
-                                 out of date in "meta" mode.  See also
-                                 ..NNOOMMEETTAA__CCMMPP.
+                     _n_o_f_i_l_e_m_o_n            Do not use filemon(4).
 
-                     _s_i_l_e_n_t_= _b_f  If _b_f is True, when a .meta file is created,
-                                 mark the target ..SSIILLEENNTT.
+                     _e_n_v                  For debugging, it can be useful to
+                                          include the environment in the .meta
+                                          file.
 
+                     _v_e_r_b_o_s_e              If in "meta" mode, print a clue
+                                          about the target being built.  This
+                                          is useful if the build is otherwise
+                                          running silently.  The message
+                                          printed the value of:
+                                          _._M_A_K_E_._M_E_T_A_._P_R_E_F_I_X.
+
+                     _i_g_n_o_r_e_-_c_m_d           Some makefiles have commands which
+                                          are simply not stable.  This keyword
+                                          causes them to be ignored for deter-
+                                          mining whether a target is out of
+                                          date in "meta" mode.  See also
+                                          ..NNOOMMEETTAA__CCMMPP.
+
+                     _s_i_l_e_n_t_= _b_f           If _b_f is True, when a .meta file is
+                                          created, mark the target ..SSIILLEENNTT.
+
      _._M_A_K_E_._M_E_T_A_._B_A_I_L_I_W_I_C_K
                      In "meta" mode, provides a list of prefixes which match
                      the directories controlled by bbmmaakkee.  If a file that was
@@ -568,6 +618,14 @@
                      The default list includes: `_/_d_e_v _/_e_t_c _/_p_r_o_c _/_t_m_p _/_v_a_r_/_r_u_n
                      _/_v_a_r_/_t_m_p'
 
+     _._M_A_K_E_._M_E_T_A_._I_G_N_O_R_E___P_A_T_T_E_R_N_S
+                     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:
@@ -575,7 +633,7 @@
 
      _._M_A_K_E_O_V_E_R_R_I_D_E_S  This variable is used to record the names of variables
                      assigned to on the command line, so that they may be
-                     exported as part of `MAKEFLAGS'.  This behaviour can be
+                     exported as part of `MAKEFLAGS'.  This behavior can be
                      disabled by assigning an empty value to `_._M_A_K_E_O_V_E_R_R_I_D_E_S'
                      within a makefile.  Extra variables can be exported from
                      a makefile by appending their names to `_._M_A_K_E_O_V_E_R_R_I_D_E_S'.
@@ -591,10 +649,22 @@
 
      _._M_A_K_E_._P_P_I_D      The parent process-id of bbmmaakkee.
 
+     _._M_A_K_E_._S_A_V_E___D_O_L_L_A_R_S
+                     value should be a boolean that controls whether `$$' are
+                     preserved when doing `:=' assignments.  The default is
+                     false, for backwards compatibility.  Set to true for com-
+                     patability with other makes.  If set to false, `$$'
+                     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
@@ -631,10 +701,10 @@
                      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'
-                     and set `PWD' to that directory before executing any tar-
-                     gets.
+                     `_._O_B_J_D_I_R' may be modified in the makefile via the special
+                     target `..OOBBJJDDIIRR'.  In all cases, bbmmaakkee will chdir(2) to
+                     the specified directory if it exists, and set `_._O_B_J_D_I_R'
+                     and `PWD' to that directory before executing any targets.
 
      _._P_A_R_S_E_D_I_R       A path to the directory of the current `_M_a_k_e_f_i_l_e' being
                      parsed.
@@ -654,7 +724,7 @@
                      sets `_._C_U_R_D_I_R' to the canonical path given by getcwd(3).
                      However, if the environment variable `PWD' is set and
                      gives a path to the current directory, then bbmmaakkee sets
-                     `_._C_U_R_D_I_R' to the value of `PWD' instead.  This behaviour
+                     `_._C_U_R_D_I_R' to the value of `PWD' instead.  This behavior
                      is disabled if `MAKEOBJDIRPREFIX' is set or `MAKEOBJDIR'
                      contains a variable transform.  `PWD' is set to the value
                      of `_._O_B_J_D_I_R' for all programs which bbmmaakkee executes.
@@ -701,7 +771,7 @@
           of the way values are split into words, matched, and then joined, a
           construct like
                 ${VAR:M*}
-          will normalise the inter-word spacing, removing all leading and
+          will normalize the inter-word spacing, removing all leading and
           trailing space, and converting multiple consecutive spaces to single
           spaces.
 
@@ -714,7 +784,7 @@
 
      ::OOxx  Randomize words in variable.  The results will be different each
           time you are referring to the modified variable; use the assignment
-          with expansion (`::==') to prevent such behaviour.  For example,
+          with expansion (`::==') to prevent such behavior.  For example,
 
                 LIST=                   uno due tre quattro
                 RANDOM_LIST=            ${LIST:Ox}
@@ -737,16 +807,20 @@
 
      ::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 32bit hash of the value and encode it as hex digits.
+          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.
@@ -847,6 +921,19 @@
           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 at + $${_:[-$$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
@@ -898,13 +985,13 @@
           tions related to the way in which the value is divided into words.
 
           Ordinarily, a value is treated as a sequence of words delimited by
-          white space.  Some modifiers suppress this behaviour, causing a
-          value to be treated as a single word (possibly containing embedded
-          white space).  An empty value, or a value that consists entirely of
-          white-space, is treated as a single word.  For the purposes of the
-          `::[[]]' modifier, the words are indexed both forwards using positive
-          integers (where index 1 represents the first word), and backwards
-          using negative integers (where index -1 represents the last word).
+          white space.  Some modifiers suppress this behavior, causing a value
+          to be treated as a single word (possibly containing embedded white
+          space).  An empty value, or a value that consists entirely of white-
+          space, is treated as a single word.  For the purposes of the `::[[]]'
+          modifier, the words are indexed both forwards using positive inte-
+          gers (where index 1 represents the first word), and backwards using
+          negative integers (where index -1 represents the last word).
 
           The _r_a_n_g_e is subjected to variable expansion, and the expanded
           result is then interpreted as follows:
@@ -941,9 +1028,15 @@
      used, the including makefile's directory and any directories specified
      using the --II option are searched before the system makefile directory.
      For compatibility with other versions of bbmmaakkee `include file ...' is also
-     accepted.  If the include statement is written as ..--iinncclluuddee or as
-     ..ssiinncclluuddee then errors locating and/or opening include files are ignored.
+     accepted.
 
+     If the include statement is written as ..--iinncclluuddee or as ..ssiinncclluuddee then
+     errors locating and/or opening include files are ignored.
+
+     If the include statement is written as ..ddiinncclluuddee not only are errors
+     locating and/or opening include files ignored, but stale dependencies
+     within the included file will be ignored just like _._M_A_K_E_._D_E_P_E_N_D_F_I_L_E.
+
      Conditional expressions are also preceded by a single dot as the first
      character of a line.  The possible conditionals are as follows:
 
@@ -966,6 +1059,10 @@
              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.
 
+     ..eexxppoorrtt--lliitteerraall _v_a_r_i_a_b_l_e _._._.
+             The same as `.export-env', except that variables in the value are
+             not expanded.
+
      ..iinnffoo _m_e_s_s_a_g_e
              The message is printed along with the name of the makefile and
              line number.
@@ -1223,6 +1320,14 @@
               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.
 
@@ -1255,6 +1360,9 @@
               Synonym for ..NNOOTTPPAARRAALLLLEELL, for compatibility with other pmake
               variants.
 
+     ..OOBBJJDDIIRR  The source is a new value for `_._O_B_J_D_I_R'.  If it exists, bbmmaakkee
+              will chdir(2) to it and update the value of `_._O_B_J_D_I_R'.
+
      ..OORRDDEERR   The named targets are made in sequence.  This ordering does not
               add targets to the list of targets to be made.  Since the depen-
               dents of a target do not get built until the target itself could
@@ -1288,7 +1396,7 @@
               sources are a set of _f_i_e_l_d_=_v_a_l_u_e pairs.
 
               _n_a_m_e        This is the minimal specification, used to select
-                          one of the builtin shell specs; _s_h, _k_s_h, and _c_s_h.
+                          one of the built-in shell specs; _s_h, _k_s_h, and _c_s_h.
 
               _p_a_t_h        Specifies the path to the shell.
 
@@ -1356,13 +1464,12 @@
      /usr/share/mk  system makefile directory
 
 CCOOMMPPAATTIIBBIILLIITTYY
-     The basic make syntax is compatible between different versions of make,
+     The basic make syntax is compatible between different versions of make;
      however the special variables, variable modifiers and conditionals are
      not.
 
-     The way that parallel makes are scheduled changed in NetBSD 4.0 so that
-     .ORDER and .WAIT apply recursively to the dependent nodes.  The algo-
-     rithms used may change again in the future.
+   OOllddeerr vveerrssiioonnss
+     An incomplete list of changes in older versions of bbmmaakkee:
 
      The way that .for loop variables are substituted changed after NetBSD 5.0
      so that they still appear to be variable expansions.  In particular this
@@ -1369,6 +1476,46 @@
      stops them being treated as syntax, and removes some obscure problems
      using them in .if statements.
 
+     The way that parallel makes are scheduled changed in NetBSD 4.0 so that
+     .ORDER and .WAIT apply recursively to the dependent nodes.  The algo-
+     rithms used may change again in the future.
+
+   OOtthheerr mmaakkee ddiiaalleeccttss
+     Other make dialects (GNU make, SVR4 make, POSIX make, etc.) do not sup-
+     port most of the features of bbmmaakkee as described in this manual.  Most
+     notably:
+
+           ++oo   The ..WWAAIITT and ..OORRDDEERR declarations and most functionality per-
+               taining to parallelization.  (GNU make supports parallelization
+               but lacks these features needed to control it effectively.)
+
+           ++oo   Directives, including for loops and conditionals and most of
+               the forms of include files.  (GNU make has its own incompatible
+               and less powerful syntax for conditionals.)
+
+           ++oo   All built-in variables that begin with a dot.
+
+           ++oo   Most of the special sources and targets that begin with a dot,
+               with the notable exception of ..PPHHOONNYY, ..PPRREECCIIOOUUSS, and ..SSUUFFFFIIXXEESS.
+
+           ++oo   Variable modifiers, except for the
+                     :old=new
+               string substitution, which does not portably support globbing
+               with `%' and historically only works on declared suffixes.
+
+           ++oo   The $$>> variable even in its short form; most makes support this
+               functionality but its name varies.
+
+     Some features are somewhat more portable, such as assignment with ++==, ??==,
+     and !!==.  The ..PPAATTHH functionality is based on an older feature VVPPAATTHH found
+     in GNU make and many versions of SVR4 make; however, historically its
+     behavior is too ill-defined (and too buggy) to rely upon.
+
+     The $$@@ and $$<< variables are more or less universally portable, as is the
+     $$((MMAAKKEE)) variable.  Basic use of suffix rules (for files only in the cur-
+     rent directory, not trying to chain transformations together, etc.) is
+     also reasonably portable.
+
 SSEEEE AALLSSOO
      mkdep(1)
 
@@ -1394,4 +1541,4 @@
 
      There is no way of escaping a space character in a filename.
 
-NetBSD 5.1                     February 14, 2014                    NetBSD 5.1
+NetBSD 7.1_RC1                   June 22, 2017                  NetBSD 7.1_RC1

Modified: vendor/NetBSD/bmake/dist/boot-strap
===================================================================
--- vendor/NetBSD/bmake/dist/boot-strap	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/boot-strap	2018-06-27 00:17:22 UTC (rev 11138)
@@ -111,7 +111,7 @@
 #	Simon J. Gerraty <sjg at crufty.net>
 
 # RCSid:
-#	$Id: boot-strap,v 1.45 2014/04/05 22:56:54 sjg Exp $
+#	$Id: boot-strap,v 1.49 2016/05/29 00:09:14 sjg Exp $
 #
 #	@(#) Copyright (c) 2001 Simon J. Gerraty
 #
@@ -395,8 +395,15 @@
     )
 }
 
+# there is actually a shell where type is not a builtin
+# if type is missing, which(1) had better exists!
+if (type cat) > /dev/null 2>&1; then
+which() {
+        type "$@" | sed 's,[()],,g;s,^[^/][^/]*,,;q'
+}
+fi
 # make sure test below uses the same diff that configure did
-TOOL_DIFF=`type diff | sed 's,[()],,g;s,^[^/][^/]*,,;q'`
+TOOL_DIFF=`which diff`
 export TOOL_DIFF
 
 op_configure() {
@@ -444,7 +451,7 @@
 		op_install
 	else
 		op_test
-		MAKE_VERSION=`sed -n '/^MAKE_VERSION/ { s,.*=  *,,;p; }' $srcdir/Makefile`
+		MAKE_VERSION=`sed -n '/^_MAKE_VERSION/ { s,.*=  *,,;p; }' $srcdir/Makefile`
 		echo You can install by running:
 		echo
 		echo $0 $cmd_args op=install

Modified: vendor/NetBSD/bmake/dist/buf.h
===================================================================
--- vendor/NetBSD/bmake/dist/buf.h	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/buf.h	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,4 +1,4 @@
-/*	$NetBSD: buf.h,v 1.17 2012/04/24 20:26:58 sjg Exp $	*/
+/*	$NetBSD: buf.h,v 1.19 2017/05/31 22:02:06 maya Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -77,8 +77,8 @@
  *	Header for users of the buf library.
  */
 
-#ifndef _BUF_H
-#define _BUF_H
+#ifndef MAKE_BUF_H
+#define MAKE_BUF_H
 
 typedef char Byte;
 
@@ -116,4 +116,4 @@
 Byte *Buf_Destroy(Buffer *, Boolean);
 Byte *Buf_DestroyCompact(Buffer *);
 
-#endif /* _BUF_H */
+#endif /* MAKE_BUF_H */

Modified: vendor/NetBSD/bmake/dist/compat.c
===================================================================
--- vendor/NetBSD/bmake/dist/compat.c	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/compat.c	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat.c,v 1.94 2014/01/03 00:02:01 sjg Exp $	*/
+/*	$NetBSD: compat.c,v 1.107 2017/07/20 19:29:54 sjg Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,7 +70,7 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: compat.c,v 1.94 2014/01/03 00:02:01 sjg Exp $";
+static char rcsid[] = "$NetBSD: compat.c,v 1.107 2017/07/20 19:29:54 sjg Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
@@ -77,7 +77,7 @@
 #if 0
 static char sccsid[] = "@(#)compat.c	8.2 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: compat.c,v 1.94 2014/01/03 00:02:01 sjg Exp $");
+__RCSID("$NetBSD: compat.c,v 1.107 2017/07/20 19:29:54 sjg Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -111,35 +111,33 @@
 #include    "hash.h"
 #include    "dir.h"
 #include    "job.h"
+#include    "metachar.h"
 #include    "pathnames.h"
 
-/*
- * The following array is used to make a fast determination of which
- * characters are interpreted specially by the shell.  If a command
- * contains any of these characters, it is executed by the shell, not
- * directly by us.
- */
 
-static char 	    meta[256];
-
 static GNode	    *curTarg = NULL;
 static GNode	    *ENDNode;
 static void CompatInterrupt(int);
+static pid_t compatChild;
+static int compatSigno;
 
+/*
+ * CompatDeleteTarget -- delete a failed, interrupted, or otherwise
+ * duffed target if not inhibited by .PRECIOUS.
+ */
 static void
-Compat_Init(void)
+CompatDeleteTarget(GNode *gn)
 {
-    const char *cp;
+    if ((gn != NULL) && !Targ_Precious (gn)) {
+	char	  *p1;
+	char 	  *file = Var_Value(TARGET, gn, &p1);
 
-    Shell_Init();		/* setup default shell */
-    
-    for (cp = "~#=|^(){};&<>*?[]:$`\\\n"; *cp != '\0'; cp++) {
-	meta[(unsigned char) *cp] = 1;
+	if (!noExecute && eunlink(file) != -1) {
+	    Error("*** %s removed", file);
+	}
+
+	free(p1);
     }
-    /*
-     * The null character serves as a sentinel in the string.
-     */
-    meta[0] = 1;
 }
 
 /*-
@@ -155,6 +153,9 @@
  *	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
@@ -162,16 +163,9 @@
 {
     GNode   *gn;
 
+    CompatDeleteTarget(curTarg);
+
     if ((curTarg != NULL) && !Targ_Precious (curTarg)) {
-	char	  *p1;
-	char 	  *file = Var_Value(TARGET, curTarg, &p1);
-
-	if (!noExecute && eunlink(file) != -1) {
-	    Error("*** %s removed", file);
-	}
-	if (p1)
-	    free(p1);
-
 	/*
 	 * Run .INTERRUPT only if hit with interrupt signal
 	 */
@@ -181,12 +175,20 @@
 		Compat_Make(gn, gn);
 	    }
 	}
-
     }
     if (signo == SIGQUIT)
 	_exit(signo);
-    bmake_signal(signo, SIG_DFL);
-    kill(myPid, signo);
+    /*
+     * If there is a child running, pass the signal on
+     * we will exist after it has exited.
+     */
+    compatSigno = signo;
+    if (compatChild > 0) {
+	KILLPG(compatChild, signo);
+    } else {
+	bmake_signal(signo, SIG_DFL);
+	kill(myPid, signo);
+    }
 }
 

 /*-
@@ -236,7 +238,7 @@
     doIt = FALSE;
     
     cmdNode = Lst_Member(gn->commands, cmd);
-    cmdStart = Var_Subst(NULL, cmd, gn, FALSE);
+    cmdStart = Var_Subst(NULL, cmd, gn, VARF_WANTRES);
 
     /*
      * brk_string will return an argv with a NULL in av[0], thus causing
@@ -271,8 +273,8 @@
 	    break;
 	case '+':
 	    doIt = TRUE;
-	    if (!meta[0])		/* we came here from jobs */
-		Compat_Init();
+	    if (!shellName)		/* we came here from jobs */
+		Shell_Init();
 	    break;
 	}
 	cmd++;
@@ -300,11 +302,13 @@
      * Search for meta characters in the command. If there are no meta
      * characters, there's no need to execute a shell to execute the
      * command.
+     *
+     * Additionally variable assignments and empty commands
+     * go to the shell. Therefore treat '=' and ':' like shell
+     * meta characters as documented in make(1).
      */
-    for (cp = cmd; !meta[(unsigned char)*cp]; cp++) {
-	continue;
-    }
-    useShell = (*cp != '\0');
+    
+    useShell = needshell(cmd, FALSE);
 #endif
 
     /*
@@ -377,7 +381,7 @@
     /*
      * Fork and execute the single command. If the fork fails, we abort.
      */
-    cpid = vFork();
+    compatChild = cpid = vFork();
     if (cpid < 0) {
 	Fatal("Could not fork");
     }
@@ -395,10 +399,10 @@
 	execError("exec", av[0]);
 	_exit(1);
     }
-    if (mav)
-	free(mav);
-    if (bp)
-	free(bp);
+
+    free(mav);
+    free(bp);
+
     Lst_Replace(cmdNode, NULL);
 
 #ifdef USE_META
@@ -468,7 +472,12 @@
 			 * continue.
 			 */
 			printf(" (continuing)\n");
+		    } else {
+			printf("\n");
 		    }
+		    if (deleteOnError) {
+			    CompatDeleteTarget(gn);
+		    }
 		} else {
 		    /*
 		     * Continue executing commands for this target.
@@ -485,7 +494,12 @@
 	}
     }
     free(cmdStart);
-
+    compatChild = 0;
+    if (compatSigno) {
+	bmake_signal(compatSigno, SIG_DFL);
+	kill(myPid, compatSigno);
+    }
+    
     return (status);
 }
 

@@ -512,8 +526,8 @@
     GNode *gn = (GNode *)gnp;
     GNode *pgn = (GNode *)pgnp;
 
-    if (!meta[0])		/* we came here from jobs */
-	Compat_Init();
+    if (!shellName)		/* we came here from jobs */
+	Shell_Init();
     if (gn->made == UNMADE && (gn == pgn || (pgn->type & OP_MADE) == 0)) {
 	/*
 	 * First mark ourselves to be made, then apply whatever transformations
@@ -537,8 +551,7 @@
 	if (Lst_Member(gn->iParents, pgn) != NULL) {
 	    char *p1;
 	    Var_Set(IMPSRC, Var_Value(TARGET, gn, &p1), pgn, 0);
-	    if (p1)
-		free(p1);
+	    free(p1);
 	}
 
 	/*
@@ -608,7 +621,8 @@
 	}
 #ifdef USE_META
 	if (useMeta && !NoExecute(gn)) {
-	    meta_job_finish(NULL);
+	    if (meta_job_finish(NULL) != 0)
+		gn->made = ERROR;
 	}
 #endif
 
@@ -628,7 +642,7 @@
 	} else if (keepgoing) {
 	    pgn->flags &= ~REMAKE;
 	} else {
-	    PrintOnError(gn, "\n\nStop.");
+	    PrintOnError(gn, "\nStop.");
 	    exit(1);
 	}
     } else if (gn->made == ERROR) {
@@ -641,8 +655,7 @@
 	if (Lst_Member(gn->iParents, pgn) != NULL) {
 	    char *p1;
 	    Var_Set(IMPSRC, Var_Value(TARGET, gn, &p1), pgn, 0);
-	    if (p1)
-		free(p1);
+	    free(p1);
 	}
 	switch(gn->made) {
 	    case BEINGMADE:
@@ -693,7 +706,8 @@
     GNode   	  *gn = NULL;/* Current root target */
     int	    	  errors;   /* Number of targets not remade due to errors */
 
-    Compat_Init();
+    if (!shellName)
+	Shell_Init();
 
     if (bmake_signal(SIGINT, SIG_IGN) != SIG_IGN) {
 	bmake_signal(SIGINT, CompatInterrupt);
@@ -719,7 +733,7 @@
 	if (gn != NULL) {
 	    Compat_Make(gn, gn);
             if (gn->made == ERROR) {
-                PrintOnError(gn, "\n\nStop.");
+                PrintOnError(gn, "\nStop.");
                 exit(1);
             }
 	}
@@ -760,7 +774,7 @@
     if (errors == 0) {
 	Compat_Make(ENDNode, ENDNode);
 	if (gn->made == ERROR) {
-	    PrintOnError(gn, "\n\nStop.");
+	    PrintOnError(gn, "\nStop.");
 	    exit(1);
 	}
     }

Modified: vendor/NetBSD/bmake/dist/cond.c
===================================================================
--- vendor/NetBSD/bmake/dist/cond.c	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/cond.c	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,4 +1,4 @@
-/*	$NetBSD: cond.c,v 1.67 2012/11/03 13:59:27 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,7 +70,7 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: cond.c,v 1.67 2012/11/03 13:59:27 christos Exp $";
+static char rcsid[] = "$NetBSD: cond.c,v 1.75 2017/04/16 20:59:04 riastradh Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
@@ -77,7 +77,7 @@
 #if 0
 static char sccsid[] = "@(#)cond.c	8.2 (Berkeley) 1/2/94";
 #else
-__RCSID("$NetBSD: cond.c,v 1.67 2012/11/03 13:59:27 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 @@
  *
  */
 
+#include    <assert.h>
 #include    <ctype.h>
 #include    <errno.h>    /* For strtoul() error checking */
 
@@ -181,6 +182,15 @@
 static unsigned int	cond_depth = 0;  	/* current .if nesting level */
 static unsigned int	cond_min_depth = 0;  	/* depth at makefile open */
 
+/*
+ * Indicate when we should be strict about lhs of comparisons.
+ * TRUE when Cond_EvalExpression is called from Cond_Eval (.if etc)
+ * FALSE when Cond_EvalExpression is called from var.c:ApplyModifiers
+ * since lhs is already expanded and we cannot tell if 
+ * it was a variable reference or not.
+ */
+static Boolean lhsStrict;
+
 static int
 istoken(const char *str, const char *tok, size_t len)
 {
@@ -280,10 +290,10 @@
 	    int		len;
 	    void	*freeIt;
 
-	    cp2 = Var_Parse(cp, VAR_CMD, TRUE, &len, &freeIt);
+	    cp2 = Var_Parse(cp, VAR_CMD, VARF_UNDEFERR|VARF_WANTRES,
+			    &len, &freeIt);
 	    Buf_AddBytes(&buf, strlen(cp2), cp2);
-	    if (freeIt)
-		free(freeIt);
+	    free(freeIt);
 	    cp += len;
 	    continue;
 	}
@@ -337,8 +347,8 @@
     } else {
 	result = FALSE;
     }
-    if (p1)
-	free(p1);
+
+    free(p1);
     return (result);
 }
 

@@ -481,6 +491,10 @@
     double d_val;
 
     errno = 0;
+    if (!*str) {
+	*value = (double)0;
+	return TRUE;
+    }
     l_val = strtoul(str, &eptr, str[1] == 'x' ? 16 : 10);
     ech = *eptr;
     if (ech == 0 && errno != ERANGE) {
@@ -517,7 +531,7 @@
  */
 /* coverity:[+alloc : arg-*2] */
 static char *
-CondGetString(Boolean doEval, Boolean *quoted, void **freeIt)
+CondGetString(Boolean doEval, Boolean *quoted, void **freeIt, Boolean strictLHS)
 {
     Buffer buf;
     char *cp;
@@ -561,8 +575,9 @@
 	    break;
 	case '$':
 	    /* if we are in quotes, then an undefined variable is ok */
-	    str = Var_Parse(condExpr, VAR_CMD, (qt ? 0 : doEval),
-			    &len, freeIt);
+	    str = Var_Parse(condExpr, VAR_CMD,
+			    ((!qt && doEval) ? VARF_UNDEFERR : 0) |
+			    VARF_WANTRES, &len, freeIt);
 	    if (str == var_Error) {
 		if (*freeIt) {
 		    free(*freeIt);
@@ -601,6 +616,16 @@
 	    condExpr--;			/* don't skip over next char */
 	    break;
 	default:
+	    if (strictLHS && !qt && *start != '$' &&
+		!isdigit((unsigned char) *start)) {
+		/* lhs must be quoted, a variable reference or number */
+		if (*freeIt) {
+		    free(*freeIt);
+		    *freeIt = NULL;
+		}
+		str = NULL;
+		goto cleanup;
+	    }
 	    Buf_AddByte(&buf, *condExpr);
 	    break;
 	}
@@ -648,7 +673,7 @@
      * Parse the variable spec and skip over it, saving its
      * value in lhs.
      */
-    lhs = CondGetString(doEval, &lhsQuoted, &lhsFree);
+    lhs = CondGetString(doEval, &lhsQuoted, &lhsFree, lhsStrict);
     if (!lhs)
 	goto done;
 
@@ -709,7 +734,7 @@
 	goto done;
     }
 
-    rhs = CondGetString(doEval, &rhsQuoted, &rhsFree);
+    rhs = CondGetString(doEval, &rhsQuoted, &rhsFree, FALSE);
     if (!rhs)
 	goto done;
 
@@ -782,10 +807,8 @@
     }
 
 done:
-    if (lhsFree)
-	free(lhsFree);
-    if (rhsFree)
-	free(rhsFree);
+    free(lhsFree);
+    free(rhsFree);
     return t;
 }
 
@@ -804,7 +827,7 @@
     /* We do all the work here and return the result as the length */
     *argPtr = NULL;
 
-    val = Var_Parse(cp - 1, VAR_CMD, FALSE, &length, &freeIt);
+    val = Var_Parse(cp - 1, VAR_CMD, VARF_WANTRES, &length, &freeIt);
     /*
      * Advance *linePtr to beyond the closing ). Note that
      * we subtract one because 'length' is calculated from 'cp - 1'.
@@ -825,8 +848,7 @@
      * true/false here.
      */
     length = *val ? 2 : 1;
-    if (freeIt)
-	free(freeIt);
+    free(freeIt);
     return length;
 }
 
@@ -877,8 +899,7 @@
 	}
 	/* Evaluate the argument using the required function. */
 	t = !doEval || fn_def->fn_proc(arglen, arg);
-	if (arg)
-	    free(arg);
+	free(arg);
 	condExpr = cp;
 	return t;
     }
@@ -910,8 +931,7 @@
      * be empty - even if it contained a variable expansion.
      */
     t = !doEval || if_info->defProc(arglen, arg) != if_info->doNot;
-    if (arg)
-	free(arg);
+    free(arg);
     return t;
 }
 
@@ -1135,7 +1155,7 @@
  *-----------------------------------------------------------------------
  */
 int
-Cond_EvalExpression(const struct If *info, char *line, Boolean *value, int eprint)
+Cond_EvalExpression(const struct If *info, char *line, Boolean *value, int eprint, Boolean strictLHS)
 {
     static const struct If *dflt_info;
     const struct If *sv_if_info = if_info;
@@ -1143,6 +1163,8 @@
     Token sv_condPushBack = condPushBack;
     int rval;
 
+    lhsStrict = strictLHS;
+
     while (*line == ' ' || *line == '\t')
 	line++;
 
@@ -1153,8 +1175,9 @@
 		break;
 	dflt_info = info;
     }
+    assert(info != NULL);
 
-    if_info = info != NULL ? info : ifs + 4;
+    if_info = info;
     condExpr = line;
     condPushBack = TOK_NONE;
 
@@ -1359,7 +1382,7 @@
     }
 
     /* And evaluate the conditional expresssion */
-    if (Cond_EvalExpression(ifp, line, &value, 1) == COND_INVALID) {
+    if (Cond_EvalExpression(ifp, line, &value, 1, TRUE) == COND_INVALID) {
 	/* Syntax error in conditional, error message already output. */
 	/* Skip everything to matching .endif */
 	cond_state[cond_depth] = SKIP_TO_ELSE;

Modified: vendor/NetBSD/bmake/dist/config.h.in
===================================================================
--- vendor/NetBSD/bmake/dist/config.h.in	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/config.h.in	2018-06-27 00:17:22 UTC (rev 11138)
@@ -59,6 +59,12 @@
 /* Define to 1 if you have the `killpg' function. */
 #undef HAVE_KILLPG
 
+/* Define to 1 if you have the <libgen.h> header file. */
+#undef HAVE_LIBGEN_H
+
+/* Define to 1 if you have the <limits.h> header file. */
+#undef HAVE_LIMITS_H
+
 /* Define to 1 if you have the <memory.h> header file. */
 #undef HAVE_MEMORY_H
 
@@ -158,6 +164,9 @@
    */
 #undef HAVE_SYS_NDIR_H
 
+/* Define to 1 if you have the <sys/param.h> header file. */
+#undef HAVE_SYS_PARAM_H
+
 /* Define to 1 if you have the <sys/select.h> header file. */
 #undef HAVE_SYS_SELECT_H
 
@@ -304,6 +313,11 @@
 /* Define to 1 if you need to in order for `stat' and other things to work. */
 #undef _POSIX_SOURCE
 
+/* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
+   <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
+   #define below would cause a syntax error. */
+#undef _UINT32_T
+
 /* C99 function name */
 #undef __func__
 
@@ -310,6 +324,9 @@
 /* Define to empty if `const' does not conform to ANSI C. */
 #undef const
 
+/* Define to `int' if <sys/types.h> does not define. */
+#undef mode_t
+
 /* Define to `long int' if <sys/types.h> does not define. */
 #undef off_t
 
@@ -319,5 +336,9 @@
 /* Define to `unsigned int' if <sys/types.h> does not define. */
 #undef size_t
 
+/* Define to the type of an unsigned integer type of width exactly 32 bits if
+   such a type exists and the standard includes do not define it. */
+#undef uint32_t
+
 /* Define as `fork' if `vfork' does not work. */
 #undef vfork

Modified: vendor/NetBSD/bmake/dist/configure
===================================================================
--- vendor/NetBSD/bmake/dist/configure	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/configure	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.64 for bmake 20140214.
+# Generated by GNU Autoconf 2.64 for bmake 20160606.
 #
 # Report bugs to <sjg at NetBSD.org>.
 #
@@ -549,8 +549,8 @@
 # Identity of this package.
 PACKAGE_NAME='bmake'
 PACKAGE_TARNAME='bmake'
-PACKAGE_VERSION='20140214'
-PACKAGE_STRING='bmake 20140214'
+PACKAGE_VERSION='20160606'
+PACKAGE_STRING='bmake 20160606'
 PACKAGE_BUGREPORT='sjg at NetBSD.org'
 PACKAGE_URL=''
 
@@ -1221,7 +1221,7 @@
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures bmake 20140214 to adapt to many kinds of systems.
+\`configure' configures bmake 20160606 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1282,7 +1282,7 @@
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of bmake 20140214:";;
+     short | recursive ) echo "Configuration of bmake 20160606:";;
    esac
   cat <<\_ACEOF
 
@@ -1387,7 +1387,7 @@
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-bmake configure 20140214
+bmake configure 20160606
 generated by GNU Autoconf 2.64
 
 Copyright (C) 2009 Free Software Foundation, Inc.
@@ -1742,6 +1742,58 @@
 
 } # ac_fn_c_check_type
 
+# ac_fn_c_find_uintX_t LINENO BITS VAR
+# ------------------------------------
+# Finds an unsigned integer type with width BITS, setting cache variable VAR
+# accordingly.
+ac_fn_c_find_uintX_t ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uint$2_t" >&5
+$as_echo_n "checking for uint$2_t... " >&6; }
+if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
+  $as_echo_n "(cached) " >&6
+else
+  eval "$3=no"
+     for ac_type in uint$2_t 'unsigned int' 'unsigned long int' \
+	 'unsigned long long int' 'unsigned short int' 'unsigned char'; do
+       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(($ac_type) -1 >> ($2 - 1) == 1)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  case $ac_type in #(
+  uint$2_t) :
+    eval "$3=yes" ;; #(
+  *) :
+    eval "$3=\$ac_type" ;;
+esac
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+       eval as_val=\$$3
+   if test "x$as_val" = x""no; then :
+
+else
+  break
+fi
+     done
+fi
+eval ac_res=\$$3
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+
+} # ac_fn_c_find_uintX_t
+
 # ac_fn_c_check_decl LINENO SYMBOL VAR
 # ------------------------------------
 # Tests whether SYMBOL is declared, setting cache variable VAR accordingly.
@@ -1908,7 +1960,7 @@
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by bmake $as_me 20140214, which was
+It was created by bmake $as_me 20160606, which was
 generated by GNU Autoconf 2.64.  Invocation command line was
 
   $ $0 $@
@@ -4247,6 +4299,8 @@
 
 if test -x /usr/bin/getconf; then
    bmake_path_max=`getconf PATH_MAX / 2> /dev/null`
+   # only a numeric response is useful
+   test ${bmake_path_max:-0} -gt 0 2> /dev/null || bmake_path_max=
 fi
 bmake_path_max=${bmake_path_max:-1024}
 if test $bmake_path_max -gt 1024; then
@@ -4567,10 +4621,41 @@
 
 fi
 
+for ac_header in sys/param.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "sys/param.h" "ac_cv_header_sys_param_h" "$ac_includes_default"
+if test "x$ac_cv_header_sys_param_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_SYS_PARAM_H 1
+_ACEOF
+
+fi
+
+done
+
+for ac_header in sys/sysctl.h
+do :
+  ac_fn_c_check_header_compile "$LINENO" "sys/sysctl.h" "ac_cv_header_sys_sysctl_h" "#ifdef HAVE_SYS_PARAM_H
+# include <sys/param.h>
+# endif
+
+"
+if test "x$ac_cv_header_sys_sysctl_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_SYS_SYSCTL_H 1
+_ACEOF
+
+fi
+
+done
+
+
 for ac_header in \
 	ar.h \
 	err.h \
 	fcntl.h \
+	libgen.h \
+	limits.h \
 	paths.h \
 	poll.h \
 	ranlib.h \
@@ -4578,7 +4663,6 @@
 	sys/mman.h \
 	sys/select.h \
 	sys/socket.h \
-	sys/sysctl.h \
 	sys/time.h \
 	sys/uio.h \
 	unistd.h \
@@ -4971,6 +5055,17 @@
 
 fi
 
+ac_fn_c_check_type "$LINENO" "mode_t" "ac_cv_type_mode_t" "$ac_includes_default"
+if test "x$ac_cv_type_mode_t" = x""yes; then :
+
+else
+
+cat >>confdefs.h <<_ACEOF
+#define mode_t int
+_ACEOF
+
+fi
+
 ac_fn_c_check_type "$LINENO" "off_t" "ac_cv_type_off_t" "$ac_includes_default"
 if test "x$ac_cv_type_off_t" = x""yes; then :
 
@@ -5004,6 +5099,20 @@
 
 fi
 
+ac_fn_c_find_uintX_t "$LINENO" "32" "ac_cv_c_uint32_t"
+case $ac_cv_c_uint32_t in #(
+  no|yes) ;; #(
+  *)
+
+$as_echo "#define _UINT32_T 1" >>confdefs.h
+
+
+cat >>confdefs.h <<_ACEOF
+#define uint32_t $ac_cv_c_uint32_t
+_ACEOF
+;;
+  esac
+
 ac_fn_c_check_decl "$LINENO" "sys_siglist" "ac_cv_have_decl_sys_siglist" "#include <signal.h>
 /* NetBSD declares sys_siglist in unistd.h.  */
 #ifdef HAVE_UNISTD_H
@@ -6404,7 +6513,7 @@
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by bmake $as_me 20140214, which was
+This file was extended by bmake $as_me 20160606, which was
 generated by GNU Autoconf 2.64.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -6464,7 +6573,7 @@
 _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_version="\\
-bmake config.status 20140214
+bmake config.status 20160606
 configured by $0, generated by GNU Autoconf 2.64,
   with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
 

Modified: vendor/NetBSD/bmake/dist/configure.in
===================================================================
--- vendor/NetBSD/bmake/dist/configure.in	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/configure.in	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,11 +1,11 @@
 dnl
 dnl RCSid:
-dnl	$Id: configure.in,v 1.52 2014/02/15 22:27:59 sjg Exp $
+dnl	$Id: configure.in,v 1.57 2016/06/07 00:49:44 sjg Exp $
 dnl
 dnl Process this file with autoconf to produce a configure script
 dnl
 AC_PREREQ(2.50)
-AC_INIT([bmake], [20140214], [sjg at NetBSD.org])
+AC_INIT([bmake], [20160606], [sjg at NetBSD.org])
 AC_CONFIG_HEADERS(config.h)
 
 dnl make srcdir absolute
@@ -82,6 +82,8 @@
 dnl Hurd refuses to define PATH_MAX or MAXPATHLEN
 if test -x /usr/bin/getconf; then
    bmake_path_max=`getconf PATH_MAX / 2> /dev/null`
+   # only a numeric response is useful
+   test ${bmake_path_max:-0} -gt 0 2> /dev/null || bmake_path_max=
 fi
 bmake_path_max=${bmake_path_max:-1024}
 if test $bmake_path_max -gt 1024; then
@@ -99,10 +101,20 @@
 AC_HEADER_SYS_WAIT
 AC_HEADER_DIRENT
 dnl Keep this list sorted
+AC_CHECK_HEADERS(sys/param.h)
+dnl On BSDi at least we really need sys/param.h for sys/sysctl.h
+AC_CHECK_HEADERS([sys/sysctl.h], [], [],
+[#ifdef HAVE_SYS_PARAM_H
+# include <sys/param.h>
+# endif
+])
+
 AC_CHECK_HEADERS( \
 	ar.h \
 	err.h \
 	fcntl.h \
+	libgen.h \
+	limits.h \
 	paths.h \
 	poll.h \
 	ranlib.h \
@@ -110,7 +122,6 @@
 	sys/mman.h \
 	sys/select.h \
 	sys/socket.h \
-	sys/sysctl.h \
 	sys/time.h \
 	sys/uio.h \
 	unistd.h \
@@ -137,9 +148,11 @@
 AC_C___ATTRIBUTE__
 AC_C_BIGENDIAN
 AC_C_CONST
+AC_TYPE_MODE_T
 AC_TYPE_OFF_T
 AC_TYPE_PID_T
 AC_TYPE_SIZE_T
+AC_TYPE_UINT32_T
 AC_DECL_SYS_SIGLIST
 AC_HEADER_TIME
 AC_STRUCT_TM

Modified: vendor/NetBSD/bmake/dist/dir.c
===================================================================
--- vendor/NetBSD/bmake/dist/dir.c	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/dir.c	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.c,v 1.67 2013/03/05 22:01:43 christos 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,7 +70,7 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: dir.c,v 1.67 2013/03/05 22:01:43 christos Exp $";
+static char rcsid[] = "$NetBSD: dir.c,v 1.71 2017/04/16 21:14:47 riastradh Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
@@ -77,7 +77,7 @@
 #if 0
 static char sccsid[] = "@(#)dir.c	8.2 (Berkeley) 1/2/94";
 #else
-__RCSID("$NetBSD: dir.c,v 1.67 2013/03/05 22:01:43 christos Exp $");
+__RCSID("$NetBSD: dir.c,v 1.71 2017/04/16 21:14:47 riastradh Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -244,6 +244,7 @@
 			     * be two rules to update a single file, so this
 			     * should be ok, but... */
 
+static Hash_Table lmtimes;  /* same as mtimes but for lstat */
 
 static int DirFindName(const void *, const void *);
 static int DirMatchFiles(const char *, Path *, Lst);
@@ -256,6 +257,80 @@
 static char *DirFindDot(Boolean, const char *, const char *);
 static char *DirLookupAbs(Path *, const char *, const char *);
 
+
+/*
+ * We use stat(2) a lot, cache the results
+ * mtime and mode are all we care about.
+ */
+struct cache_st {
+    time_t mtime;
+    mode_t  mode;
+};
+
+/* minimize changes below */
+static time_t
+Hash_GetTimeValue(Hash_Entry *entry)
+{
+    struct cache_st *cst;
+
+    cst = entry->clientPtr;
+    return cst->mtime;
+}
+
+#define CST_LSTAT 1
+#define CST_UPDATE 2
+
+static int
+cached_stats(Hash_Table *htp, const char *pathname, struct stat *st, int flags)
+{
+    Hash_Entry *entry;
+    struct cache_st *cst;
+    int rc;
+
+    if (!pathname || !pathname[0])
+	return -1;
+
+    entry = Hash_FindEntry(htp, pathname);
+
+    if (entry && (flags & CST_UPDATE) == 0) {
+	cst = entry->clientPtr;
+
+	memset(st, 0, sizeof(*st));
+	st->st_mtime = cst->mtime;
+	st->st_mode = cst->mode;
+	return 0;
+    }
+
+    rc = (flags & CST_LSTAT) ? lstat(pathname, st) : stat(pathname, st);
+    if (rc == -1)
+	return -1;
+
+    if (st->st_mtime == 0)
+	st->st_mtime = 1;      /* avoid confusion with missing file */
+
+    if (!entry)
+	entry = Hash_CreateEntry(htp, pathname, NULL);
+    if (!entry->clientPtr)
+	entry->clientPtr = bmake_malloc(sizeof(*cst));
+    cst = entry->clientPtr;
+    cst->mtime = st->st_mtime;
+    cst->mode = st->st_mode;
+
+    return 0;
+}
+
+int
+cached_stat(const char *pathname, void *st)
+{
+    return cached_stats(&mtimes, pathname, st, 0);
+}
+
+int
+cached_lstat(const char *pathname, void *st)
+{
+    return cached_stats(&lmtimes, pathname, st, CST_LSTAT);
+}
+
 /*-
  *-----------------------------------------------------------------------
  * Dir_Init --
@@ -271,10 +346,13 @@
 void
 Dir_Init(const char *cdname)
 {
-    dirSearchPath = Lst_Init(FALSE);
-    openDirectories = Lst_Init(FALSE);
-    Hash_InitTable(&mtimes, 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));
@@ -725,11 +803,11 @@
  *-----------------------------------------------------------------------
  */
 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;
 }
 
 /*-
@@ -901,7 +979,6 @@
 DirLookupSubdir(Path *p, const char *name)
 {
     struct stat	  stb;		/* Buffer for stat, if necessary */
-    Hash_Entry	 *entry;	/* Entry for mtimes table */
     char 	 *file;		/* the current filename to check */
 
     if (p != dot) {
@@ -917,9 +994,7 @@
 	fprintf(debug_file, "checking %s ...\n", file);
     }
 
-    if (stat(file, &stb) == 0) {
-	if (stb.st_mtime == 0)
-		stb.st_mtime = 1;
+    if (cached_stat(file, &stb) == 0) {
 	/*
 	 * Save the modification time so if it's needed, we don't have
 	 * to fetch it again.
@@ -928,8 +1003,6 @@
 	    fprintf(debug_file, "   Caching %s for %s\n", Targ_FmtTime(stb.st_mtime),
 		    file);
 	}
-	entry = Hash_CreateEntry(&mtimes, file, NULL);
-	Hash_SetTimeValue(entry, stb.st_mtime);
 	nearmisses += 1;
 	return (file);
     }
@@ -1242,8 +1315,14 @@
 	    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) {
@@ -1252,13 +1331,23 @@
 		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;
+	}
     }
 
     /*
@@ -1312,15 +1401,11 @@
 	    fprintf(debug_file, "   got it (in mtime cache)\n");
 	}
 	return(bmake_strdup(name));
-    } else if (stat(name, &stb) == 0) {
-	if (stb.st_mtime == 0)
-		stb.st_mtime = 1;
-	entry = Hash_CreateEntry(&mtimes, name, NULL);
+    } else if (cached_stat(name, &stb) == 0) {
 	if (DEBUG(DIR)) {
 	    fprintf(debug_file, "   Caching %s for %s\n", Targ_FmtTime(stb.st_mtime),
 		    name);
 	}
-	Hash_SetTimeValue(entry, stb.st_mtime);
 	return (bmake_strdup(name));
     } else {
 	if (DEBUG(DIR)) {
@@ -1368,7 +1453,7 @@
 
 		/* try and stat(2) it ... */
 		snprintf(try, sizeof(try), "%s/%s", dirbase, search_path);
-		if (stat(try, &st) != -1) {
+		if (cached_stat(try, &st) != -1) {
 			/*
 			 * success!  if we found a file, chop off
 			 * the filename so we return a directory.
@@ -1489,12 +1574,12 @@
     else
 	entry = NULL;
     if (entry != NULL) {
+	stb.st_mtime = Hash_GetTimeValue(entry);
 	if (DEBUG(DIR)) {
 	    fprintf(debug_file, "Using cached time %s for %s\n",
-		    Targ_FmtTime(Hash_GetTimeValue(entry)), fullName);
+		    Targ_FmtTime(stb.st_mtime), fullName);
 	}
-	stb.st_mtime = Hash_GetTimeValue(entry);
-    } else if (stat(fullName, &stb) < 0) {
+    } else if (cached_stats(&mtimes, fullName, &stb, recheck ? CST_UPDATE : 0) < 0) {
 	if (gn->type & OP_MEMBER) {
 	    if (fullName != gn->path)
 		free(fullName);
@@ -1502,18 +1587,8 @@
 	} else {
 	    stb.st_mtime = 0;
 	}
-    } else {
-	if (stb.st_mtime == 0) {
-		/*
-		 * 0 handled specially by the code, if the time is really 0,
-		 * return something else instead
-		 */
-		stb.st_mtime = 1;
-	}
-	entry = Hash_CreateEntry(&mtimes, fullName, NULL);
-	Hash_SetTimeValue(entry, stb.st_mtime);
     }
-	
+
     if (fullName && gn->path == NULL) {
 	gn->path = fullName;
     }
@@ -1792,10 +1867,10 @@
 }
 
 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: vendor/NetBSD/bmake/dist/dir.h
===================================================================
--- vendor/NetBSD/bmake/dist/dir.h	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/dir.h	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.h,v 1.15 2012/04/07 18:29:08 christos Exp $	*/
+/*	$NetBSD: dir.h,v 1.18 2017/05/31 22:02:06 maya Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -75,8 +75,8 @@
 /* dir.h --
  */
 
-#ifndef	_DIR
-#define	_DIR
+#ifndef	MAKE_DIR_H
+#define	MAKE_DIR_H
 
 typedef struct Path {
     char         *name;	    	/* Name of directory */
@@ -105,4 +105,4 @@
 void Dir_Destroy(void *);
 void * Dir_CopyDir(void *);
 
-#endif /* _DIR */
+#endif /* MAKE_DIR_H */

Modified: vendor/NetBSD/bmake/dist/dirname.c
===================================================================
--- vendor/NetBSD/bmake/dist/dirname.c	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/dirname.c	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,4 +1,4 @@
-/*	$NetBSD: dirname.c,v 1.11 2009/11/24 13:34:20 tnozaki Exp $	*/
+/*	$NetBSD: dirname.c,v 1.13 2014/07/16 10:52:26 christos Exp $	*/
 
 /*-
  * Copyright (c) 1997, 2002 The NetBSD Foundation, Inc.
@@ -35,7 +35,10 @@
 #ifndef HAVE_DIRNAME
 
 #include <sys/cdefs.h>
-
+#include <sys/param.h>
+#ifdef HAVE_LIBGEN_H
+#include <libgen.h>
+#endif
 #ifdef HAVE_LIMITS_H
 #include <limits.h>
 #endif
@@ -45,12 +48,15 @@
 #ifndef PATH_MAX
 # define PATH_MAX 1024
 #endif
+#ifndef MIN
+# define MIN(a, b) ((a < b) ? a : b)
+#endif
 
-char *
-dirname(char *path)
+
+static size_t
+xdirname_r(const char *path, char *buf, size_t buflen)
 {
-	static char result[PATH_MAX];
-	const char *lastp;
+	const char *endp;
 	size_t len;
 
 	/*
@@ -57,39 +63,58 @@
 	 * If `path' is a null pointer or points to an empty string,
 	 * return a pointer to the string ".".
 	 */
-	if ((path == NULL) || (*path == '\0'))
-		goto singledot;
+	if (path == NULL || *path == '\0') {
+		path = ".";
+		len = 1;
+		goto out;
+	}
 
-
 	/* Strip trailing slashes, if any. */
-	lastp = path + strlen(path) - 1;
-	while (lastp != path && *lastp == '/')
-		lastp--;
+	endp = path + strlen(path) - 1;
+	while (endp != path && *endp == '/')
+		endp--;
 
-	/* Terminate path at the last occurence of '/'. */
-	do {
-		if (*lastp == '/') {
-			/* Strip trailing slashes, if any. */
-			while (lastp != path && *lastp == '/')
-				lastp--;
+	/* Find the start of the dir */
+	while (endp > path && *endp != '/')
+		endp--;
 
-			/* ...and copy the result into the result buffer. */
-			len = (lastp - path) + 1 /* last char */;
-			if (len > (PATH_MAX - 1))
-				len = PATH_MAX - 1;
+	if (endp == path) {
+		path = *endp == '/' ? "/" : ".";
+		len = 1;
+		goto out;
+	}
 
-			memcpy(result, path, len);
-			result[len] = '\0';
+	do
+		endp--;
+	while (endp > path && *endp == '/');
 
-			return (result);
-		}
-	} while (--lastp >= path);
+	len = endp - path + 1;
+out:
+	if (buf != NULL && buflen != 0) {
+		buflen = MIN(len, buflen - 1);
+		memcpy(buf, path, buflen);
+		buf[buflen] = '\0';
+	}
+	return len;
+}
 
-	/* No /'s found, return a pointer to the string ".". */
-singledot:
-	result[0] = '.';
-	result[1] = '\0';
+char *
+dirname(char *path)
+{
+	static char result[PATH_MAX];
+	(void)xdirname_r(path, result, sizeof(result));
+	return result;
+}
 
-	return (result);
+#ifdef MAIN
+#include <stdlib.h>
+#include <stdio.h>
+
+int
+main(int argc, char *argv[])
+{
+	printf("%s\n", dirname(argv[1]));
+	exit(0);
 }
 #endif
+#endif

Modified: vendor/NetBSD/bmake/dist/for.c
===================================================================
--- vendor/NetBSD/bmake/dist/for.c	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/for.c	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,4 +1,4 @@
-/*	$NetBSD: for.c,v 1.49 2012/06/03 04:29:40 sjg 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,7 +30,7 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: for.c,v 1.49 2012/06/03 04:29:40 sjg Exp $";
+static char rcsid[] = "$NetBSD: for.c,v 1.53 2017/04/16 21:04:44 riastradh Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)for.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: for.c,v 1.49 2012/06/03 04:29:40 sjg Exp $");
+__RCSID("$NetBSD: for.c,v 1.53 2017/04/16 21:04:44 riastradh Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -216,7 +216,7 @@
      * We can't do the escapes here - because we don't know whether
      * we are substuting into ${...} or $(...).
      */
-    sub = Var_Subst(NULL, ptr, VAR_GLOBAL, FALSE);
+    sub = Var_Subst(NULL, ptr, VAR_GLOBAL, VARF_WANTRES);
 
     /*
      * Split into words allowing for quoted strings.
@@ -427,7 +427,7 @@
     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: vendor/NetBSD/bmake/dist/getopt.c
===================================================================
--- vendor/NetBSD/bmake/dist/getopt.c	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/getopt.c	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,3 +1,5 @@
+/*	$NetBSD: getopt.c,v 1.29 2014/06/05 22:00:22 christos Exp $	*/
+
 /*
  * Copyright (c) 1987, 1993, 1994
  *	The Regents of the University of California.  All rights reserved.
@@ -10,11 +12,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
@@ -35,12 +33,8 @@
 # include "config.h"
 #endif
 #if !defined(HAVE_GETOPT) || defined(WANT_GETOPT_LONG) || defined(BROKEN_GETOPT)
+#include <sys/cdefs.h>
 
-#if defined(LIBC_SCCS) && !defined(lint)
-/* static char sccsid[] = "from: @(#)getopt.c	8.2 (Berkeley) 4/2/94"; */
-static char *rcsid = "$Id: getopt.c,v 1.3 1999/01/08 02:14:18 sjg Exp $";
-#endif /* LIBC_SCCS and not lint */
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -61,13 +55,10 @@
  *	Parse argc/argv argument vector.
  */
 int
-getopt(nargc, nargv, ostr)
-	int nargc;
-	char * const *nargv;
-	const char *ostr;
+getopt(int nargc, char * const nargv[], const char *ostr)
 {
 	extern char *__progname;
-	static char *place = EMSG;		/* option letter processing */
+	static const char *place = EMSG; 	/* option letter processing */
 	char *oli;				/* option letter list index */
 
 #ifndef BSD4_4
@@ -79,43 +70,63 @@
 	}
 #endif
 	
-	if (optreset || !*place) {		/* update scanning pointer */
+	if (optreset || *place == 0) {		/* update scanning pointer */
 		optreset = 0;
-		if (optind >= nargc || *(place = nargv[optind]) != '-') {
+		place = nargv[optind];
+		if (optind >= nargc || *place++ != '-') {
+			/* Argument is absent or is not an option */
 			place = EMSG;
 			return (-1);
 		}
-		if (place[1] && *++place == '-'	/* found "--" */
-		    && !place[1]) {		/* and not "--foo" */
+		optopt = *place++;
+		if (optopt == '-' && *place == 0) {
+			/* "--" => end of options */
 			++optind;
 			place = EMSG;
 			return (-1);
 		}
-	}					/* option letter okay? */
-	if ((optopt = (int)*place++) == (int)':' ||
-	    !(oli = strchr(ostr, optopt))) {
-		/*
-		 * if the user didn't specify '-' as an option,
-		 * assume it means -1.
-		 */
-		if (optopt == (int)'-')
-			return (-1);
-		if (!*place)
+		if (optopt == 0) {
+			/* Solitary '-', treat as a '-' option
+			   if the program (eg su) is looking for it. */
+			place = EMSG;
+			if (strchr(ostr, '-') == NULL)
+				return -1;
+			optopt = '-';
+		}
+	} else
+		optopt = *place++;
+
+	/* See if option letter is one the caller wanted... */
+	if (optopt == ':' || (oli = strchr(ostr, optopt)) == NULL) {
+		if (*place == 0)
 			++optind;
 		if (opterr && *ostr != ':')
 			(void)fprintf(stderr,
-			    "%s: illegal option -- %c\n", __progname, optopt);
+			    "%s: unknown option -- %c\n", __progname, optopt);
 		return (BADCH);
 	}
-	if (*++oli != ':') {			/* don't need argument */
+
+	/* Does this option need an argument? */
+	if (oli[1] != ':') {
+		/* don't need argument */
 		optarg = NULL;
-		if (!*place)
+		if (*place == 0)
 			++optind;
-	}
-	else {					/* need an argument */
-		if (*place)			/* no white space */
-			optarg = place;
-		else if (nargc <= ++optind) {	/* no arg */
+	} else {
+		/* Option-argument is either the rest of this argument or the
+		   entire next argument. */
+		if (*place)
+			optarg = __UNCONST(place);
+		else if (oli[2] == ':')
+			/*
+			 * GNU Extension, for optional arguments if the rest of
+			 * the argument is empty, we return NULL
+			 */
+			optarg = NULL;
+		else if (nargc > ++optind)
+			optarg = nargv[optind];
+		else {
+			/* option-argument absent */
 			place = EMSG;
 			if (*ostr == ':')
 				return (BADARG);
@@ -125,12 +136,10 @@
 				    __progname, optopt);
 			return (BADCH);
 		}
-	 	else				/* white space */
-			optarg = nargv[optind];
 		place = EMSG;
 		++optind;
 	}
-	return (optopt);			/* dump back option letter */
+	return (optopt);			/* return option letter */
 }
 #endif
 #ifdef MAIN

Modified: vendor/NetBSD/bmake/dist/hash.h
===================================================================
--- vendor/NetBSD/bmake/dist/hash.h	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/hash.h	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,4 +1,4 @@
-/*	$NetBSD: hash.h,v 1.10 2009/01/24 10:59:09 dsl Exp $	*/
+/*	$NetBSD: hash.h,v 1.12 2017/05/31 21:07:03 maya Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -78,8 +78,8 @@
  * 	which maintains hash tables.
  */
 
-#ifndef	_HASH
-#define	_HASH
+#ifndef	_HASH_H
+#define	_HASH_H
 
 /*
  * The following defines one entry in the hash table.
@@ -89,10 +89,7 @@
     struct Hash_Entry *next;		/* Used to link together all the
     					 * entries associated with the same
 					 * bucket. */
-    union {
-	void	      *clientPtr;	/* Arbitrary pointer */
-	time_t	      clientTime;	/* Arbitrary Time */
-    } clientInfo;
+    void	      *clientPtr;	/* Arbitrary pointer */
     unsigned	      namehash;		/* hash value of key */
     char	      name[1];		/* key string */
 } Hash_Entry;
@@ -125,8 +122,7 @@
  *     Hash_Entry *h;
  */
 
-#define Hash_GetValue(h) ((h)->clientInfo.clientPtr)
-#define Hash_GetTimeValue(h) ((h)->clientInfo.clientTime)
+#define Hash_GetValue(h) ((h)->clientPtr)
 
 /*
  * Hash_SetValue(h, val);
@@ -134,8 +130,7 @@
  *     char *val;
  */
 
-#define Hash_SetValue(h, val) ((h)->clientInfo.clientPtr = (val))
-#define Hash_SetTimeValue(h, val) ((h)->clientInfo.clientTime = (val))
+#define Hash_SetValue(h, val) ((h)->clientPtr = (val))
 
 /*
  * Hash_Size(n) returns the number of words in an object of n bytes
@@ -151,4 +146,4 @@
 Hash_Entry *Hash_EnumFirst(Hash_Table *, Hash_Search *);
 Hash_Entry *Hash_EnumNext(Hash_Search *);
 
-#endif /* _HASH */
+#endif /* _HASH_H */

Modified: vendor/NetBSD/bmake/dist/job.c
===================================================================
--- vendor/NetBSD/bmake/dist/job.c	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/job.c	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,4 +1,4 @@
-/*	$NetBSD: job.c,v 1.176 2013/08/04 16:48:15 sjg Exp $	*/
+/*	$NetBSD: job.c,v 1.191 2017/07/20 19:29:54 sjg Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,7 +70,7 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: job.c,v 1.176 2013/08/04 16:48:15 sjg Exp $";
+static char rcsid[] = "$NetBSD: job.c,v 1.191 2017/07/20 19:29:54 sjg Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
@@ -77,7 +77,7 @@
 #if 0
 static char sccsid[] = "@(#)job.c	8.2 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: job.c,v 1.176 2013/08/04 16:48:15 sjg Exp $");
+__RCSID("$NetBSD: job.c,v 1.191 2017/07/20 19:29:54 sjg Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -144,7 +144,6 @@
 
 #include <assert.h>
 #include <errno.h>
-#include <fcntl.h>
 #if !defined(USE_SELECT) && defined(HAVE_POLL_H)
 #include <poll.h>
 #else
@@ -172,6 +171,22 @@
 # define STATIC static
 
 /*
+ * FreeBSD: traditionally .MAKE is not required to
+ * pass jobs queue to sub-makes.
+ * Use .MAKE.ALWAYS_PASS_JOB_QUEUE=no to disable.
+ */
+#define MAKE_ALWAYS_PASS_JOB_QUEUE ".MAKE.ALWAYS_PASS_JOB_QUEUE"
+static int Always_pass_job_queue = TRUE;
+/*
+ * FreeBSD: aborting entire parallel make isn't always
+ * desired. When doing tinderbox for example, failure of
+ * one architecture should not stop all.
+ * We still want to bail on interrupt though.
+ */
+#define MAKE_JOB_ERROR_TOKEN "MAKE_JOB_ERROR_TOKEN"
+static int Job_error_token = TRUE;
+
+/*
  * error handling variables
  */
 static int     	errors = 0;	    /* number of errors reported */
@@ -349,11 +364,6 @@
 	    (void)fprintf(fp, TARG_FMT, targPrefix, gn->name)
 
 static sigset_t caught_signals;	/* Set of signals we handle */
-#if defined(SYSV)
-#define KILLPG(pid, sig)	kill(-(pid), (sig))
-#else
-#define KILLPG(pid, sig)	killpg((pid), (sig))
-#endif
 
 static void JobChildSig(int);
 static void JobContinueSig(int);
@@ -374,7 +384,10 @@
 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)
@@ -389,6 +402,21 @@
 }
 
 /*
+ * 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
@@ -410,7 +438,7 @@
 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));
@@ -425,8 +453,10 @@
     }
     
     /* Set close-on-exec flag for both */
-    (void)fcntl(job->jobPipe[0], F_SETFD, 1);
-    (void)fcntl(job->jobPipe[1], F_SETFD, 1);
+    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
@@ -434,8 +464,12 @@
      * 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));
 }
 
 /*-
@@ -715,7 +749,7 @@
 
     numCommands += 1;
 
-    cmdStart = cmd = Var_Subst(NULL, cmd, job->node, FALSE);
+    cmdStart = cmd = Var_Subst(NULL, cmd, job->node, VARF_WANTRES);
 
     cmdTemplate = "%s\n";
 
@@ -728,7 +762,6 @@
 	    shutUp = DEBUG(LOUD) ? FALSE : TRUE;
 	    break;
 	case '-':
-	    job->flags |= JOB_IGNERR;
 	    errOff = TRUE;
 	    break;
 	case '+':
@@ -738,6 +771,7 @@
 		 * but this one needs to be - use compat mode just for it.
 		 */
 		CompatRunCommand(cmdp, job->node);
+		free(cmdStart);
 		return 0;
 	    }
 	    break;
@@ -807,6 +841,7 @@
 		 * to ignore errors. Set cmdTemplate to use the weirdness
 		 * instead of the simple "%s\n" template.
 		 */
+		job->flags |= JOB_IGNERR;
 		if (!(job->flags & JOB_SILENT) && !shutUp) {
 			if (commandShell->hasEchoCtl) {
 				DBPRINTF("%s\n", commandShell->echoOff);
@@ -866,8 +901,7 @@
     
     DBPRINTF(cmdTemplate, cmd);
     free(cmdStart);
-    if (escCmd)
-        free(escCmd);
+    free(escCmd);
     if (errOff) {
 	/*
 	 * If echoing is already off, there's no point in issuing the
@@ -903,7 +937,7 @@
 static int
 JobSaveCommand(void *cmd, void *gn)
 {
-    cmd = Var_Subst(NULL, (char *)cmd, (GNode *)gn, FALSE);
+    cmd = Var_Subst(NULL, (char *)cmd, (GNode *)gn, VARF_WANTRES);
     (void)Lst_AtEnd(postCommands->commands, cmd);
     return(0);
 }
@@ -1035,6 +1069,9 @@
 		if (job->flags & JOB_IGNERR) {
 		    WAIT_STATUS(status) = 0;
 		} else {
+		    if (deleteOnError) {
+			JobDeleteTarget(job->node);
+		    }
 		    PrintOnError(job->node, NULL);
 		}
 	    } else if (DEBUG(JOB)) {
@@ -1052,6 +1089,9 @@
 	    }
 	    (void)printf("*** [%s] Signal %d\n",
 			job->node->name, WTERMSIG(status));
+	    if (deleteOnError) {
+		JobDeleteTarget(job->node);
+	    }
 	}
 	(void)fflush(stdout);
     }
@@ -1058,7 +1098,11 @@
 
 #ifdef USE_META
     if (useMeta) {
-	meta_job_finish(job);
+	int x;
+
+	if ((x = meta_job_finish(job)) != 0 && status == 0) {
+	    status = x;
+	}
     }
 #endif
     
@@ -1234,8 +1278,7 @@
 	     */
 	    Make_HandleUse(DEFAULT, gn);
 	    Var_Set(IMPSRC, Var_Value(TARGET, gn, &p1), gn, 0);
-	    if (p1)
-		free(p1);
+	    free(p1);
 	} else if (Dir_MTime(gn, 0) == 0 && (gn->type & OP_SPECIAL) == 0) {
 	    /*
 	     * The node wasn't the target of an operator we have no .DEFAULT
@@ -1357,15 +1400,28 @@
 	    execError("dup2", "job->cmdFILE");
 	    _exit(1);
 	}
-	(void)fcntl(0, F_SETFD, 0);
-	(void)lseek(0, (off_t)0, SEEK_SET);
+	if (fcntl(0, F_SETFD, 0) == -1) {
+	    execError("fcntl clear close-on-exec", "stdin");
+	    _exit(1);
+	}
+	if (lseek(0, (off_t)0, SEEK_SET) == -1) {
+	    execError("lseek to 0", "stdin");
+	    _exit(1);
+	}
 
-	if (job->node->type & OP_MAKE) {
+	if (Always_pass_job_queue ||
+	    (job->node->type & (OP_MAKE | OP_SUBMAKE))) {
 		/*
 		 * Pass job token pipe to submakes.
 		 */
-		fcntl(tokenWaitJob.inPipe, F_SETFD, 0);
-		fcntl(tokenWaitJob.outPipe, F_SETFD, 0);		
+		if (fcntl(tokenWaitJob.inPipe, F_SETFD, 0) == -1) {
+		    execError("clear close-on-exec", "tokenWaitJob.inPipe");
+		    _exit(1);
+		}
+		if (fcntl(tokenWaitJob.outPipe, F_SETFD, 0) == -1) {
+		    execError("clear close-on-exec", "tokenWaitJob.outPipe");
+		    _exit(1);
+		}
 	}
 	
 	/*
@@ -1382,7 +1438,10 @@
 	 * it before routing the shell's error output to the same place as
 	 * its standard output.
 	 */
-	(void)fcntl(1, F_SETFD, 0);
+	if (fcntl(1, F_SETFD, 0) == -1) {
+	    execError("clear close-on-exec", "stdout");
+	    _exit(1);
+	}
 	if (dup2(1, 2) == -1) {
 	    execError("dup2", "1, 2");
 	    _exit(1);
@@ -1598,7 +1657,7 @@
 	if (job->cmdFILE == NULL) {
 	    Punt("Could not fdopen %s", tfile);
 	}
-	(void)fcntl(FILENO(job->cmdFILE), F_SETFD, 1);
+	(void)fcntl(FILENO(job->cmdFILE), F_SETFD, FD_CLOEXEC);
 	/*
 	 * Send the commands to the command file, flush all its buffers then
 	 * rewind and remove the thing.
@@ -1894,16 +1953,16 @@
 		(void)fflush(stdout);
 	    }
 	}
-	if (i < max - 1) {
-	    /* shift the remaining characters down */
-	    (void)memcpy(job->outBuf, &job->outBuf[i + 1], max - (i + 1));
+	/*
+	 * max is the last offset still in the buffer. Move any remaining
+	 * characters to the start of the buffer and update the end marker
+	 * curPos.
+	 */
+	if (i < max) {
+	    (void)memmove(job->outBuf, &job->outBuf[i + 1], max - (i + 1));
 	    job->curPos = max - (i + 1);
-
 	} else {
-	    /*
-	     * We have written everything out, so we just start over
-	     * from the start of the buffer. No copying. No nothing.
-	     */
+	    assert(i == max);
 	    job->curPos = 0;
 	}
     }
@@ -2194,7 +2253,8 @@
 	Var_Set(MAKE_JOB_PREFIX, "---", VAR_GLOBAL, 0);
     }
 
-    targPrefix = Var_Subst(NULL, "${" MAKE_JOB_PREFIX "}", VAR_GLOBAL, 0);
+    targPrefix = Var_Subst(NULL, "${" MAKE_JOB_PREFIX "}",
+			   VAR_GLOBAL, VARF_WANTRES);
 }
 
 /*-
@@ -2226,6 +2286,12 @@
 
     lastNode =	  NULL;
 
+    Always_pass_job_queue = getBoolean(MAKE_ALWAYS_PASS_JOB_QUEUE,
+				       Always_pass_job_queue);
+
+    Job_error_token = getBoolean(MAKE_JOB_ERROR_TOKEN, Job_error_token);
+
+
     /*
      * There is a non-zero chance that we already have children.
      * eg after 'make -f- <<EOF'
@@ -2401,8 +2467,7 @@
 	line++;
     }
 
-    if (shellArgv)
-	free(UNCONST(shellArgv));
+    free(UNCONST(shellArgv));
 
     memset(&newShell, 0, sizeof(newShell));
 
@@ -2577,12 +2642,7 @@
 
 	gn = job->node;
 
-	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);
-	    }
-	}
+	JobDeleteTarget(gn);
 	if (job->pid) {
 	    if (DEBUG(JOB)) {
 		(void)fprintf(debug_file,
@@ -2650,8 +2710,7 @@
 Job_End(void)
 {
 #ifdef CLEANUP
-    if (shellArgv)
-	free(shellArgv);
+    free(shellArgv);
 #endif
 }
 
@@ -2821,6 +2880,12 @@
 {
     char tok = JOB_TOKENS[aborting], tok1;
 
+    if (!Job_error_token && aborting == ABORT_ERROR) {
+	if (jobTokensRunning == 0)
+	    return;
+	tok = '+';			/* no error token */
+    }
+
     /* If we are depositing an error token flush everything else */
     while (tok != '+' && read(tokenWaitJob.inPipe, &tok1, 1) == 1)
 	continue;
@@ -2827,7 +2892,7 @@
 
     if (DEBUG(JOB))
 	fprintf(debug_file, "(%d) aborting %d, deposit token %c\n",
-	    getpid(), aborting, JOB_TOKENS[aborting]);
+	    getpid(), aborting, tok);
     while (write(tokenWaitJob.outPipe, &tok, 1) == -1 && errno == EAGAIN)
 	continue;
 }
@@ -2850,8 +2915,8 @@
 	/* Pipe passed in from parent */
 	tokenWaitJob.inPipe = jp_0;
 	tokenWaitJob.outPipe = jp_1;
-	(void)fcntl(jp_0, F_SETFD, 1);
-	(void)fcntl(jp_1, F_SETFD, 1);
+	(void)fcntl(jp_0, F_SETFD, FD_CLOEXEC);
+	(void)fcntl(jp_1, F_SETFD, FD_CLOEXEC);
 	return;
     }
 

Modified: vendor/NetBSD/bmake/dist/lst.h
===================================================================
--- vendor/NetBSD/bmake/dist/lst.h	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/lst.h	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,4 +1,4 @@
-/*	$NetBSD: lst.h,v 1.18 2009/01/23 21:58:27 dsl Exp $	*/
+/*	$NetBSD: lst.h,v 1.20 2014/09/07 20:55:34 joerg Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.

Modified: vendor/NetBSD/bmake/dist/lst.lib/lstInt.h
===================================================================
--- vendor/NetBSD/bmake/dist/lst.lib/lstInt.h	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/lst.lib/lstInt.h	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,4 +1,4 @@
-/*	$NetBSD: lstInt.h,v 1.20 2009/01/24 14:43:29 dsl Exp $	*/
+/*	$NetBSD: lstInt.h,v 1.22 2014/09/07 20:55:34 joerg Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993

Modified: vendor/NetBSD/bmake/dist/lst.lib/lstRemove.c
===================================================================
--- vendor/NetBSD/bmake/dist/lst.lib/lstRemove.c	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/lst.lib/lstRemove.c	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,4 +1,4 @@
-/*	$NetBSD: lstRemove.c,v 1.14 2008/12/13 15:19:29 dsl Exp $	*/
+/*	$NetBSD: lstRemove.c,v 1.16 2014/09/07 20:55:34 joerg Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -33,7 +33,7 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: lstRemove.c,v 1.14 2008/12/13 15:19:29 dsl Exp $";
+static char rcsid[] = "$NetBSD: lstRemove.c,v 1.16 2014/09/07 20:55:34 joerg Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
@@ -40,7 +40,7 @@
 #if 0
 static char sccsid[] = "@(#)lstRemove.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: lstRemove.c,v 1.14 2008/12/13 15:19:29 dsl Exp $");
+__RCSID("$NetBSD: lstRemove.c,v 1.16 2014/09/07 20:55:34 joerg Exp $");
 #endif
 #endif /* not lint */
 #endif

Modified: vendor/NetBSD/bmake/dist/machine.sh
===================================================================
--- vendor/NetBSD/bmake/dist/machine.sh	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/machine.sh	2018-06-27 00:17:22 UTC (rev 11138)
@@ -2,7 +2,7 @@
 # derrived from /etc/rc_d/os.sh
 
 # RCSid:
-#	$Id: machine.sh,v 1.16 2010/10/17 00:05:51 sjg Exp $
+#	$Id: machine.sh,v 1.17 2015/05/05 00:10:54 sjg Exp $
 #
 #	@(#) Copyright (c) 1994-2002 Simon J. Gerraty
 #
@@ -49,6 +49,10 @@
 	arch=`Which arch /usr/bin:/usr/ucb:$PATH`
 	MACHINE_ARCH=`$arch -s`;
 	;;
+Bitrig)
+	MACHINE=$OS$OSMAJOR.$machine
+	MACHINE_ARCH=`uname -m`;
+	;;
 *BSD)
 	MACHINE=$OS$OSMAJOR.$machine
 	;;

Modified: vendor/NetBSD/bmake/dist/main.c
===================================================================
--- vendor/NetBSD/bmake/dist/main.c	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/main.c	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.226 2014/02/07 17:23:35 pooka Exp $	*/
+/*	$NetBSD: main.c,v 1.272 2017/06/19 19:58:24 christos Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: main.c,v 1.226 2014/02/07 17:23:35 pooka Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.272 2017/06/19 19:58:24 christos Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
@@ -81,7 +81,7 @@
 #if 0
 static char sccsid[] = "@(#)main.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: main.c,v 1.226 2014/02/07 17:23:35 pooka Exp $");
+__RCSID("$NetBSD: main.c,v 1.272 2017/06/19 19:58:24 christos Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -99,14 +99,14 @@
  *
  *	Error			Print a tagged error message. The global
  *				MAKE variable must have been defined. This
- *				takes a format string and two optional
- *				arguments for it.
+ *				takes a format string and optional arguments
+ *				for it.
  *
  *	Fatal			Print an error message and exit. Also takes
- *				a format string and two arguments.
+ *				a format string and arguments for it.
  *
  *	Punt			Aborts all jobs and exits with a message. Also
- *				takes a format string and two arguments.
+ *				takes a format string and arguments for it.
  *
  *	Finish			Finish things up by printing the number of
  *				errors which occurred, as passed to it, and
@@ -125,7 +125,6 @@
 #include "wait.h"
 
 #include <errno.h>
-#include <fcntl.h>
 #include <signal.h>
 #include <stdarg.h>
 #include <stdio.h>
@@ -156,10 +155,13 @@
 time_t			now;		/* Time at start of make */
 GNode			*DEFAULT;	/* .DEFAULT node */
 Boolean			allPrecious;	/* .PRECIOUS given on line by itself */
+Boolean			deleteOnError;	/* .DELETE_ON_ERROR: set */
 
 static Boolean		noBuiltins;	/* -r flag */
 static Lst		makefiles;	/* ordered list of makefiles to read */
-static Boolean		printVars;	/* print value of one or more vars */
+static int		printVars;	/* -[vV] argument */
+#define COMPAT_VARS 1
+#define EXPAND_VARS 2
 static Lst		variables;	/* list of variables to print */
 int			maxJobs;	/* -j argument */
 static int		maxJobTokens;	/* -j argument */
@@ -172,6 +174,7 @@
 Boolean			queryFlag;	/* -q flag */
 Boolean			touchFlag;	/* -t flag */
 Boolean			enterFlag;	/* -w flag */
+Boolean			enterFlagObj;	/* -w and objdir != srcdir */
 Boolean			ignoreErrors;	/* -i flag */
 Boolean			beSilent;	/* -s flag */
 Boolean			oldVars;	/* variable substitution style */
@@ -186,6 +189,7 @@
 static void		MainParseArgs(int, char **);
 static int		ReadMakefile(const void *, const void *);
 static void		usage(void) MAKE_ATTR_DEAD;
+static void		purge_cached_realpaths(void);
 
 static Boolean		ignorePWD;	/* if we use -C, PWD is meaningless */
 static char objdir[MAXPATHLEN + 1];	/* where we chdir'ed to */
@@ -335,7 +339,7 @@
 				goto debug_setbuf;
 			}
 			len = strlen(modules);
-			fname = malloc(len + 20);
+			fname = bmake_malloc(len + 20);
 			memcpy(fname, modules, len + 1);
 			/* Let the filename be modified by the pid */
 			if (strcmp(fname + len - 3, ".%d") == 0)
@@ -366,6 +370,32 @@
 	}
 }
 
+/*
+ * does path contain any relative components
+ */
+static int
+is_relpath(const char *path)
+{
+	const char *cp;
+
+	if (path[0] != '/')
+		return TRUE;
+	cp = path;
+	do {
+		cp = strstr(cp, "/.");
+		if (!cp)
+			break;
+		cp += 2;
+		if (cp[0] == '/' || cp[0] == '\0')
+			return TRUE;
+		else if (cp[0] == '.') {
+			if (cp[1] == '/' || cp[1] == '\0')
+				return TRUE;
+		}
+	} while (cp);
+	return FALSE;
+}
+
 /*-
  * MainParseArgs --
  *	Parse a given argument vector. Called from main() and from
@@ -388,11 +418,12 @@
 	int arginc;
 	char *argvalue;
 	const char *getopt_def;
+	struct stat sa, sb;
 	char *optscan;
 	Boolean inOption, dashDash = FALSE;
 	char found_path[MAXPATHLEN + 1];	/* for searching for sys.mk */
 
-#define OPTFLAGS "BC:D:I:J:NST:V:WXd:ef:ij:km:nqrstw"
+#define OPTFLAGS "BC:D:I:J:NST:V:WXd:ef:ij:km:nqrstv:w"
 /* Can't actually use getopt(3) because rescanning is not portable */
 
 	getopt_def = OPTFLAGS;
@@ -456,6 +487,12 @@
 				(void)fprintf(stderr, "%s: %s.\n", progname, strerror(errno));
 				exit(2);
 			}
+			if (!is_relpath(argvalue) &&
+			    stat(argvalue, &sa) != -1 &&
+			    stat(curdir, &sb) != -1 &&
+			    sa.st_ino == sb.st_ino &&
+			    sa.st_dev == sb.st_dev)
+				strncpy(curdir, argvalue, MAXPATHLEN);
 			ignorePWD = TRUE;
 			break;
 		case 'D':
@@ -511,8 +548,9 @@
 			Var_Append(MAKEFLAGS, argvalue, VAR_GLOBAL);
 			break;
 		case 'V':
+		case 'v':
 			if (argvalue == NULL) goto noarg;
-			printVars = TRUE;
+			printVars = c == 'v' ? EXPAND_VARS : COMPAT_VARS;
 			(void)Lst_AtEnd(variables, argvalue);
 			Var_Append(MAKEFLAGS, "-V", VAR_GLOBAL);
 			Var_Append(MAKEFLAGS, argvalue, VAR_GLOBAL);
@@ -695,8 +733,7 @@
 #endif
 	buf = bmake_malloc(len = strlen(line) + strlen(argv0) + 2);
 	(void)snprintf(buf, len, "%s %s", argv0, line);
-	if (p1)
-		free(p1);
+	free(p1);
 
 	argv = brk_string(buf, &argc, TRUE, &args);
 	if (argv == NULL) {
@@ -712,22 +749,22 @@
 }
 
 Boolean
-Main_SetObjdir(const char *path)
+Main_SetObjdir(const char *fmt, ...)
 {
 	struct stat sb;
-	char *p = NULL;
+	char *path;
 	char buf[MAXPATHLEN + 1];
+	char buf2[MAXPATHLEN + 1];
 	Boolean rc = FALSE;
+	va_list ap;
 
-	/* expand variable substitutions */
-	if (strchr(path, '$') != 0) {
-		snprintf(buf, MAXPATHLEN, "%s", path);
-		path = p = Var_Subst(NULL, buf, VAR_GLOBAL, 0);
-	}
+	va_start(ap, fmt);
+	vsnprintf(path = buf, MAXPATHLEN, fmt, ap);
+	va_end(ap);
 
 	if (path[0] != '/') {
-		snprintf(buf, MAXPATHLEN, "%s/%s", curdir, path);
-		path = buf;
+		snprintf(buf2, MAXPATHLEN, "%s/%s", curdir, path);
+		path = buf2;
 	}
 
 	/* look for the directory and try to chdir there */
@@ -740,15 +777,38 @@
 			Var_Set(".OBJDIR", objdir, VAR_GLOBAL, 0);
 			setenv("PWD", objdir, 1);
 			Dir_InitDot();
+			purge_cached_realpaths();
 			rc = TRUE;
+			if (enterFlag && strcmp(objdir, curdir) != 0)
+				enterFlagObj = TRUE;
 		}
 	}
 
-	if (p)
-		free(p);
 	return rc;
 }
 
+static Boolean
+Main_SetVarObjdir(const char *var, const char *suffix)
+{
+	char *p, *path, *xpath;
+
+	if ((path = Var_Value(var, VAR_CMD, &p)) == NULL)
+		return FALSE;
+
+	/* expand variable substitutions */
+	if (strchr(path, '$') != 0)
+		xpath = Var_Subst(NULL, path, VAR_GLOBAL, VARF_WANTRES);
+	else
+		xpath = path;
+
+	(void)Main_SetObjdir("%s%s", xpath, suffix);
+
+	if (xpath != path)
+		free(xpath);
+	free(p);
+	return TRUE;
+}
+
 /*-
  * ReadAllMakefiles --
  *	wrapper around ReadMakefile() to read all.
@@ -803,7 +863,8 @@
     char *mp = NULL;
 
     if (!mode)
-	mode = mp = Var_Subst(NULL, "${" MAKE_MODE ":tl}", VAR_GLOBAL, 0);
+	mode = mp = Var_Subst(NULL, "${" MAKE_MODE ":tl}",
+			      VAR_GLOBAL, VARF_WANTRES);
 
     if (mode && *mode) {
 	if (strstr(mode, "compat")) {
@@ -815,10 +876,93 @@
 	    meta_mode_init(mode);
 #endif
     }
-    if (mp)
-	free(mp);
+
+    free(mp);
 }
 
+static void
+doPrintVars(void)
+{
+	LstNode ln;
+	Boolean expandVars;
+
+	if (printVars == EXPAND_VARS)
+		expandVars = TRUE;
+	else if (debugVflag)
+		expandVars = FALSE;
+	else
+		expandVars = getBoolean(".MAKE.EXPAND_VARIABLES", FALSE);
+
+	for (ln = Lst_First(variables); ln != NULL;
+	    ln = Lst_Succ(ln)) {
+		char *var = (char *)Lst_Datum(ln);
+		char *value;
+		char *p1;
+		
+		if (strchr(var, '$')) {
+			value = p1 = Var_Subst(NULL, var, VAR_GLOBAL,
+			    VARF_WANTRES);
+		} else if (expandVars) {
+			char tmp[128];
+			int len = snprintf(tmp, sizeof(tmp), "${%s}", var);
+							
+			if (len >= (int)sizeof(tmp))
+				Fatal("%s: variable name too big: %s",
+				    progname, var);
+			value = p1 = Var_Subst(NULL, tmp, VAR_GLOBAL,
+			    VARF_WANTRES);
+		} else {
+			value = Var_Value(var, VAR_GLOBAL, &p1);
+		}
+		printf("%s\n", value ? value : "");
+		free(p1);
+	}
+}
+
+static Boolean
+runTargets(void)
+{
+	Lst targs;	/* target nodes to create -- passed to Make_Init */
+	Boolean outOfDate; 	/* FALSE if all targets up to date */
+
+	/*
+	 * Have now read the entire graph and need to make a list of
+	 * targets to create. If none was given on the command line,
+	 * we consult the parsing module to find the main target(s)
+	 * to create.
+	 */
+	if (Lst_IsEmpty(create))
+		targs = Parse_MainName();
+	else
+		targs = Targ_FindList(create, TARG_CREATE);
+
+	if (!compatMake) {
+		/*
+		 * Initialize job module before traversing the graph
+		 * now that any .BEGIN and .END targets have been read.
+		 * This is done only if the -q flag wasn't given
+		 * (to prevent the .BEGIN from being executed should
+		 * it exist).
+		 */
+		if (!queryFlag) {
+			Job_Init();
+			jobsRunning = TRUE;
+		}
+
+		/* Traverse the graph, checking on all the targets */
+		outOfDate = Make_Run(targs);
+	} else {
+		/*
+		 * Compat_Init will take care of creating all the
+		 * targets as well as initializing the module.
+		 */
+		Compat_Run(targs);
+		outOfDate = FALSE;
+	}
+	Lst_Destroy(targs, NULL);
+	return outOfDate;
+}
+
 /*-
  * main --
  *	The main function, for obvious reasons. Initializes variables
@@ -839,8 +983,7 @@
 int
 main(int argc, char **argv)
 {
-	Lst targs;	/* target nodes to create -- passed to Make_Init */
-	Boolean outOfDate = FALSE; 	/* FALSE if all targets up to date */
+	Boolean outOfDate; 	/* FALSE if all targets up to date */
 	struct stat sb, sa;
 	char *p1, *path;
 	char mdpath[MAXPATHLEN];
@@ -969,7 +1112,7 @@
 
 	create = Lst_Init(FALSE);
 	makefiles = Lst_Init(FALSE);
-	printVars = FALSE;
+	printVars = 0;
 	debugVflag = FALSE;
 	variables = Lst_Init(FALSE);
 	beSilent = FALSE;		/* Print commands as executed */
@@ -978,6 +1121,7 @@
 	noRecursiveExecute = FALSE;	/* Execute all .MAKE targets */
 	keepgoing = FALSE;		/* Stop on error */
 	allPrecious = FALSE;		/* Remove targets when interrupted */
+	deleteOnError = FALSE;		/* Historical default behavior */
 	queryFlag = FALSE;		/* This is not just a check-run */
 	noBuiltins = FALSE;		/* Read the built-in rules */
 	touchFlag = FALSE;		/* Actually update targets */
@@ -1013,7 +1157,7 @@
 	    /*
 	     * A relative path, canonicalize it.
 	     */
-	    p1 = realpath(argv[0], mdpath);
+	    p1 = cached_realpath(argv[0], mdpath);
 	    if (!p1 || *p1 != '/' || stat(p1, &sb) < 0) {
 		p1 = argv[0];		/* realpath failed */
 	    }
@@ -1052,6 +1196,8 @@
 #ifdef USE_META
 	meta_init();
 #endif
+	Dir_Init(NULL);		/* Dir_* safe to call from MainParseArgs */
+
 	/*
 	 * First snag any flags out of the MAKE environment variable.
 	 * (Note this is *not* MAKEFLAGS since /bin/make uses that and it's
@@ -1127,38 +1273,21 @@
 	 * MAKEOBJDIR is set in the environment, try only that value
 	 * and fall back to .CURDIR if it does not exist.
 	 *
-	 * Otherwise, try _PATH_OBJDIR.MACHINE, _PATH_OBJDIR, and
-	 * finally _PATH_OBJDIRPREFIX`pwd`, in that order.  If none
+	 * Otherwise, try _PATH_OBJDIR.MACHINE-MACHINE_ARCH, _PATH_OBJDIR.MACHINE,
+	 * and * finally _PATH_OBJDIRPREFIX`pwd`, in that order.  If none
 	 * of these paths exist, just use .CURDIR.
 	 */
 	Dir_Init(curdir);
-	(void)Main_SetObjdir(curdir);
+	(void)Main_SetObjdir("%s", curdir);
 
-	if ((path = Var_Value("MAKEOBJDIRPREFIX", VAR_CMD, &p1)) != NULL) {
-		(void)snprintf(mdpath, MAXPATHLEN, "%s%s", path, curdir);
-		(void)Main_SetObjdir(mdpath);
-		free(p1);
-	} else if ((path = Var_Value("MAKEOBJDIR", VAR_CMD, &p1)) != NULL) {
-		(void)Main_SetObjdir(path);
-		free(p1);
-	} else {
-		(void)snprintf(mdpath, MAXPATHLEN, "%s.%s", _PATH_OBJDIR, machine);
-		if (!Main_SetObjdir(mdpath) && !Main_SetObjdir(_PATH_OBJDIR)) {
-			(void)snprintf(mdpath, MAXPATHLEN, "%s%s", 
-					_PATH_OBJDIRPREFIX, curdir);
-			(void)Main_SetObjdir(mdpath);
-		}
-	}
+	if (!Main_SetVarObjdir("MAKEOBJDIRPREFIX", curdir) &&
+	    !Main_SetVarObjdir("MAKEOBJDIR", "") &&
+	    !Main_SetObjdir("%s.%s-%s", _PATH_OBJDIR, machine, machine_arch) &&
+	    !Main_SetObjdir("%s.%s", _PATH_OBJDIR, machine) &&
+	    !Main_SetObjdir("%s", _PATH_OBJDIR))
+		(void)Main_SetObjdir("%s%s", _PATH_OBJDIRPREFIX, curdir);
 
 	/*
-	 * Be compatible if user did not specify -j and did not explicitly
-	 * turned compatibility on
-	 */
-	if (!compatMake && !forceJobs) {
-		compatMake = TRUE;
-	}
-	
-	/*
 	 * Initialize archive, target and suffix modules in preparation for
 	 * parsing the makefile(s)
 	 */
@@ -1249,7 +1378,7 @@
 			    (char *)Lst_Datum(ln));
 	} else {
 	    p1 = Var_Subst(NULL, "${" MAKEFILE_PREFERENCE "}",
-		VAR_CMD, 0);
+		VAR_CMD, VARF_WANTRES);
 	    if (p1) {
 		(void)str2Lst_Append(makefiles, p1, NULL);
 		(void)Lst_Find(makefiles, NULL, ReadMakefile);
@@ -1260,18 +1389,50 @@
 	/* In particular suppress .depend for '-r -V .OBJDIR -f /dev/null' */
 	if (!noBuiltins || !printVars) {
 	    makeDependfile = Var_Subst(NULL, "${.MAKE.DEPENDFILE:T}",
-		VAR_CMD, 0);
+		VAR_CMD, VARF_WANTRES);
 	    doing_depend = TRUE;
 	    (void)ReadMakefile(makeDependfile, NULL);
 	    doing_depend = FALSE;
 	}
 
+	if (enterFlagObj)
+		printf("%s: Entering directory `%s'\n", progname, objdir);
+	
 	MakeMode(NULL);
 
 	Var_Append("MFLAGS", Var_Value(MAKEFLAGS, VAR_GLOBAL, &p1), VAR_GLOBAL);
-	if (p1)
-	    free(p1);
+	free(p1);
 
+	if (!forceJobs && !compatMake &&
+	    Var_Exists(".MAKE.JOBS", VAR_GLOBAL)) {
+	    char *value;
+	    int n;
+
+	    value = Var_Subst(NULL, "${.MAKE.JOBS}", VAR_GLOBAL, VARF_WANTRES);
+	    n = strtol(value, NULL, 0);
+	    if (n < 1) {
+		(void)fprintf(stderr, "%s: illegal value for .MAKE.JOBS -- must be positive integer!\n",
+		    progname);
+		exit(1);
+	    }
+	    if (n != maxJobs) {
+		Var_Append(MAKEFLAGS, "-j", VAR_GLOBAL);
+		Var_Append(MAKEFLAGS, value, VAR_GLOBAL);
+	    }
+	    maxJobs = n;
+	    maxJobTokens = maxJobs;
+	    forceJobs = TRUE;
+	    free(value);
+	}
+
+	/*
+	 * Be compatible if user did not specify -j and did not explicitly
+	 * turned compatibility on
+	 */
+	if (!compatMake && !forceJobs) {
+	    compatMake = TRUE;
+	}
+
 	if (!compatMake)
 	    Job_ServerStart(maxJobTokens, jp_0, jp_1);
 	if (DEBUG(JOB))
@@ -1278,8 +1439,9 @@
 	    fprintf(debug_file, "job_pipe %d %d, maxjobs %d, tokens %d, compat %d\n",
 		jp_0, jp_1, maxJobs, maxJobTokens, compatMake);
 
-	Main_ExportMAKEFLAGS(TRUE);	/* initial export */
-
+	if (!printVars)
+	    Main_ExportMAKEFLAGS(TRUE);	/* initial export */
+	
 	/*
 	 * For compatibility, look at the directories in the VPATH variable
 	 * and add them to the search path, if the variable is defined. The
@@ -1295,7 +1457,7 @@
 		 */
 		static char VPATH[] = "${VPATH}";
 
-		vpath = Var_Subst(NULL, VPATH, VAR_CMD, FALSE);
+		vpath = Var_Subst(NULL, VPATH, VAR_CMD, VARF_WANTRES);
 		path = vpath;
 		do {
 			/* skip to end of directory */
@@ -1329,72 +1491,13 @@
 
 	/* print the values of any variables requested by the user */
 	if (printVars) {
-		LstNode ln;
-		Boolean expandVars;
-
-		if (debugVflag)
-			expandVars = FALSE;
-		else
-			expandVars = getBoolean(".MAKE.EXPAND_VARIABLES", FALSE);
-		for (ln = Lst_First(variables); ln != NULL;
-		    ln = Lst_Succ(ln)) {
-			char *var = (char *)Lst_Datum(ln);
-			char *value;
-			
-			if (strchr(var, '$')) {
-				value = p1 = Var_Subst(NULL, var, VAR_GLOBAL, 0);
-			} else if (expandVars) {
-				char tmp[128];
-								
-				if (snprintf(tmp, sizeof(tmp), "${%s}", var) >= (int)(sizeof(tmp)))
-					Fatal("%s: variable name too big: %s",
-					      progname, var);
-				value = p1 = Var_Subst(NULL, tmp, VAR_GLOBAL, 0);
-			} else {
-				value = Var_Value(var, VAR_GLOBAL, &p1);
-			}
-			printf("%s\n", value ? value : "");
-			if (p1)
-				free(p1);
-		}
+		doPrintVars();
+		outOfDate = FALSE;
 	} else {
-		/*
-		 * Have now read the entire graph and need to make a list of
-		 * targets to create. If none was given on the command line,
-		 * we consult the parsing module to find the main target(s)
-		 * to create.
-		 */
-		if (Lst_IsEmpty(create))
-			targs = Parse_MainName();
-		else
-			targs = Targ_FindList(create, TARG_CREATE);
-
-		if (!compatMake) {
-			/*
-			 * Initialize job module before traversing the graph
-			 * now that any .BEGIN and .END targets have been read.
-			 * This is done only if the -q flag wasn't given
-			 * (to prevent the .BEGIN from being executed should
-			 * it exist).
-			 */
-			if (!queryFlag) {
-				Job_Init();
-				jobsRunning = TRUE;
-			}
-
-			/* Traverse the graph, checking on all the targets */
-			outOfDate = Make_Run(targs);
-		} else {
-			/*
-			 * Compat_Init will take care of creating all the
-			 * targets as well as initializing the module.
-			 */
-			Compat_Run(targs);
-		}
+		outOfDate = runTargets();
 	}
 
 #ifdef CLEANUP
-	Lst_Destroy(targs, NULL);
 	Lst_Destroy(variables, NULL);
 	Lst_Destroy(makefiles, NULL);
 	Lst_Destroy(create, (FreeProc *)free);
@@ -1406,9 +1509,14 @@
 
 	Trace_Log(MAKEEND, 0);
 
+	if (enterFlagObj)
+		printf("%s: Leaving directory `%s'\n", progname, objdir);
 	if (enterFlag)
 		printf("%s: Leaving directory `%s'\n", progname, curdir);
 
+#ifdef USE_META
+	meta_finish();
+#endif
 	Suff_End();
         Targ_End();
 	Arch_End();
@@ -1477,8 +1585,7 @@
 			name = Dir_FindFile(fname,
 				Lst_IsEmpty(sysIncPath) ? defIncPath : sysIncPath);
 		if (!name || (fd = open(name, O_RDONLY)) == -1) {
-			if (name)
-				free(name);
+			free(name);
 			free(path);
 			return(-1);
 		}
@@ -1522,7 +1629,8 @@
     WAIT_T	status;		/* command exit status */
     Buffer	buf;		/* buffer to store the result */
     char	*cp;
-    int		cc;
+    int		cc;		/* bytes read, or -1 */
+    int		savederr;	/* saved errno */
 
 
     *errnum = NULL;
@@ -1579,6 +1687,7 @@
 	 */
 	(void)close(fds[1]);
 
+	savederr = 0;
 	Buf_Init(&buf, 0);
 
 	do {
@@ -1588,6 +1697,8 @@
 		Buf_AddBytes(&buf, cc, result);
 	}
 	while (cc > 0 || (cc == -1 && errno == EINTR));
+	if (cc == -1)
+	    savederr = errno;
 
 	/*
 	 * Close the input side of the pipe.
@@ -1604,7 +1715,7 @@
 	cc = Buf_Size(&buf);
 	res = Buf_Destroy(&buf, FALSE);
 
-	if (cc == 0)
+	if (savederr != 0)
 	    *errnum = "Couldn't read shell's output for \"%s\"";
 
 	if (WIFSIGNALED(status))
@@ -1845,11 +1956,71 @@
 "usage: %s [-BeikNnqrstWwX] \n\
             [-C directory] [-D variable] [-d flags] [-f makefile]\n\
             [-I directory] [-J private] [-j max_jobs] [-m directory] [-T file]\n\
-            [-V variable] [variable=value] [target ...]\n", progname);
+            [-V variable] [-v variable] [variable=value] [target ...]\n",
+	    progname);
 	exit(2);
 }
 
+/*
+ * realpath(3) can get expensive, cache results...
+ */
+static GNode *cached_realpaths = NULL;
 
+static GNode *
+get_cached_realpaths(void)
+{
+
+    if (!cached_realpaths) {
+	cached_realpaths = Targ_NewGN("Realpath");
+#ifndef DEBUG_REALPATH_CACHE
+	cached_realpaths->flags = INTERNAL;
+#endif
+    }
+
+    return cached_realpaths;
+}
+
+/* purge any relative paths */
+static void
+purge_cached_realpaths(void)
+{
+    GNode *cache = get_cached_realpaths();
+    Hash_Entry *he, *nhe;
+    Hash_Search hs;
+
+    he = Hash_EnumFirst(&cache->context, &hs);
+    while (he) {
+	nhe = Hash_EnumNext(&hs);
+	if (he->name[0] != '/') {
+	    if (DEBUG(DIR))
+		fprintf(stderr, "cached_realpath: purging %s\n", he->name);
+	    Hash_DeleteEntry(&cache->context, he);
+	}
+	he = nhe;
+    }
+}
+
+char *
+cached_realpath(const char *pathname, char *resolved)
+{
+    GNode *cache;
+    char *rp, *cp;
+
+    if (!pathname || !pathname[0])
+	return NULL;
+
+    cache = get_cached_realpaths();
+
+    if ((rp = Var_Value(pathname, cache, &cp)) != NULL) {
+	/* a hit */
+	strlcpy(resolved, rp, MAXPATHLEN);
+    } else if ((rp = realpath(pathname, resolved)) != NULL) {
+	Var_Set(pathname, rp, cache, 0);
+    }
+    free(cp);
+    return rp ? resolved : NULL;
+}
+
 int
 PrintAddr(void *a, void *b)
 {
@@ -1858,6 +2029,14 @@
 }
 
 
+static int
+addErrorCMD(void *cmdp, void *gnp MAKE_ATTR_UNUSED)
+{
+    if (cmdp == NULL)
+	return 1;			/* stop */
+    Var_Append(".ERROR_CMD", cmdp, VAR_GLOBAL);
+    return 0;
+}
 
 void
 PrintOnError(GNode *gn, const char *s)
@@ -1878,15 +2057,19 @@
 	 * We can print this even if there is no .ERROR target.
 	 */
 	Var_Set(".ERROR_TARGET", gn->name, VAR_GLOBAL, 0);
+	Var_Delete(".ERROR_CMD", VAR_GLOBAL);
+	Lst_ForEach(gn->commands, addErrorCMD, gn);
     }
     strncpy(tmp, "${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'\n@}",
 	    sizeof(tmp) - 1);
-    cp = Var_Subst(NULL, tmp, VAR_GLOBAL, 0);
+    cp = Var_Subst(NULL, tmp, VAR_GLOBAL, VARF_WANTRES);
     if (cp) {
 	if (*cp)
 	    printf("%s", cp);
 	free(cp);
     }
+    fflush(stdout);
+
     /*
      * Finally, see if there is a .ERROR target, and run it if so.
      */
@@ -1910,7 +2093,7 @@
     
     strncpy(tmp, "${.MAKEFLAGS} ${.MAKEOVERRIDES:O:u:@v@$v=${$v:Q}@}",
 	    sizeof(tmp));
-    s = Var_Subst(NULL, tmp, VAR_CMD, 0);
+    s = Var_Subst(NULL, tmp, VAR_CMD, VARF_WANTRES);
     if (s && *s) {
 #ifdef POSIX
 	setenv("MAKEFLAGS", s, 1);
@@ -1932,7 +2115,8 @@
 	 * Honor $TMPDIR but only if it is valid.
 	 * Ensure it ends with /.
 	 */
-	tmpdir = Var_Subst(NULL, "${TMPDIR:tA:U" _PATH_TMP "}/", VAR_GLOBAL, 0);
+	tmpdir = Var_Subst(NULL, "${TMPDIR:tA:U" _PATH_TMP "}/", VAR_GLOBAL,
+			   VARF_WANTRES);
 	if (stat(tmpdir, &st) < 0 || !S_ISDIR(st.st_mode)) {
 	    free(tmpdir);
 	    tmpdir = bmake_strdup(_PATH_TMP);
@@ -1972,6 +2156,44 @@
     return fd;
 }
 
+/*
+ * Convert a string representation of a boolean.
+ * Anything that looks like "No", "False", "Off", "0" etc,
+ * is FALSE, otherwise TRUE.
+ */
+Boolean
+s2Boolean(const char *s, Boolean bf)
+{
+    if (s) {
+	switch(*s) {
+	case '\0':			/* not set - the default wins */
+	    break;
+	case '0':
+	case 'F':
+	case 'f':
+	case 'N':
+	case 'n':
+	    bf = FALSE;
+	    break;
+	case 'O':
+	case 'o':
+	    switch (s[1]) {
+	    case 'F':
+	    case 'f':
+		bf = FALSE;
+		break;
+	    default:
+		bf = TRUE;
+		break;
+	    }
+	    break;
+	default:
+	    bf = TRUE;
+	    break;
+	}
+    }
+    return (bf);
+}
 
 /*
  * Return a Boolean based on setting of a knob.
@@ -1986,32 +2208,11 @@
     char tmp[64];
     char *cp;
 
-    if (snprintf(tmp, sizeof(tmp), "${%s:tl}", name) < (int)(sizeof(tmp))) {
-	cp = Var_Subst(NULL, tmp, VAR_GLOBAL, 0);
+    if (snprintf(tmp, sizeof(tmp), "${%s:U:tl}", name) < (int)(sizeof(tmp))) {
+	cp = Var_Subst(NULL, tmp, VAR_GLOBAL, VARF_WANTRES);
 
 	if (cp) {
-	    switch(*cp) {
-	    case '\0':			/* not set - the default wins */
-		break;
-	    case '0':
-	    case 'f':
-	    case 'n':
-		bf = FALSE;
-		break;
-	    case 'o':
-		switch (cp[1]) {
-		case 'f':
-		    bf = FALSE;
-		    break;
-		default:
-		    bf = TRUE;
-		    break;
-		}
-		break;
-	    default:
-		bf = TRUE;
-		break;
-	    }
+	    bf = s2Boolean(cp, bf);
 	    free(cp);
 	}
     }

Modified: vendor/NetBSD/bmake/dist/make-bootstrap.sh.in
===================================================================
--- vendor/NetBSD/bmake/dist/make-bootstrap.sh.in	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/make-bootstrap.sh.in	2018-06-27 00:17:22 UTC (rev 11138)
@@ -13,7 +13,7 @@
 CC="@CC@"
 CFLAGS="@CFLAGS@ -I. -I${srcdir} @DEFS@ @CPPFLAGS@ -DMAKE_NATIVE ${XDEFS} -DBMAKE_PATH_MAX=@bmake_path_max@"
 
-MAKE_VERSION=`sed -n '/^MAKE_VERSION=/s,.*=[^0-9]*,,p' $srcdir/Makefile`
+MAKE_VERSION=`sed -n '/^_MAKE_VERSION=/s,.*=[^0-9]*,,p' $srcdir/Makefile`
 
 MDEFS="-DMAKE_VERSION=\"$MAKE_VERSION\" \
 -D at force_machine@MACHINE=\"@machine@\" -DMACHINE_ARCH=\"@machine_arch@\" \
@@ -52,7 +52,7 @@
 }
 
 BASE_OBJECTS="arch.o buf.o compat.o cond.o dir.o for.o getopt hash.o \
-job.o make.o make_malloc.o parse.o sigcompat.o str.o strlist.o \
+job.o make.o make_malloc.o metachar.o parse.o sigcompat.o str.o strlist.o \
 suff.o targ.o trace.o var.o util.o"
 
 LST_OBJECTS="lstAppend.o lstDupl.o lstInit.o lstOpen.o \

Modified: vendor/NetBSD/bmake/dist/make.1
===================================================================
--- vendor/NetBSD/bmake/dist/make.1	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/make.1	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,4 +1,4 @@
-.\"	$NetBSD: make.1,v 1.230 2014/02/15 18:55:30 sjg Exp $
+.\"	$NetBSD: make.1,v 1.271 2017/07/03 21:34:20 wiz 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 February 14, 2014
+.Dd June 22, 2017
 .Dt MAKE 1
 .Os
 .Sh NAME
@@ -48,6 +48,7 @@
 .Op Fl m Ar directory
 .Op Fl T Ar file
 .Op Fl V Ar variable
+.Op Fl v Ar variable
 .Op Ar variable=value
 .Op Ar target ...
 .Sh DESCRIPTION
@@ -206,11 +207,11 @@
 .It Ar V
 Force the
 .Fl V
-option to print raw values of variables.
+option to print raw values of variables, overriding the default behavior
+set via
+.Va .MAKE.EXPAND_VARIABLES .
 .It Ar v
 Print debugging information about variable assignment.
-.It Ar w
-Print entering and leaving directory messages, pre and post processing.
 .It Ar x
 Run shell commands with
 .Fl x
@@ -295,7 +296,7 @@
 will search for the specified file or directory named in the remaining part
 of the argument string.
 The search starts with the current directory of
-the Makefile and then works upward towards the root of the filesystem.
+the Makefile and then works upward towards the root of the file system.
 If the search is successful, then the resulting directory replaces the
 .Qq \&.../
 specification in the
@@ -336,22 +337,43 @@
 Rather than re-building a target as specified in the makefile, create it
 or update its modification time to make it appear up-to-date.
 .It Fl V Ar variable
-Print
-.Nm Ns 's
-idea of the value of
-.Ar variable ,
-in the global context.
+Print the value of
+.Ar variable .
 Do not build any targets.
 Multiple instances of this option may be specified;
 the variables will be printed one per line,
 with a blank line for each null or undefined variable.
+The value printed is extracted from the global context after all
+makefiles have been read.
+By default, the raw variable contents (which may
+include additional unexpanded variable references) are shown.
 If
 .Ar variable
 contains a
 .Ql \&$
-then the value will be expanded before printing.
+then the value will be recursively expanded to its complete resultant
+text before printing.
+The expanded value will also be printed if
+.Va .MAKE.EXPAND_VARIABLES
+is set to true and
+the
+.Fl dV
+option has not been used to override it.
+Note that loop-local and target-local variables, as well as values
+taken temporarily by global variables during makefile processing, are
+not accessible via this option.
+The
+.Fl dv
+debug mode can be used to see these at the cost of generating
+substantial extraneous output.
+.It Fl v Ar variable
+Like
+.Fl V
+but the variable is always expanded to its complete value.
 .It Fl W
 Treat any warnings during makefile parsing as errors.
+.It Fl w
+Print entering and leaving directory messages, pre and post processing.
 .It Fl X
 Don't export variables passed on the command line to the environment
 individually.
@@ -441,17 +463,29 @@
 need not necessarily be used to describe existing files.
 Expansion is in directory order, not alphabetically as done in the shell.
 .Sh SHELL COMMANDS
-Each target may have associated with it a series of shell commands, normally
+Each target may have associated with it one or more lines of shell
+commands, normally
 used to create the target.
-Each of the commands in this script
+Each of the lines in this script
 .Em must
 be preceded by a tab.
-While any target may appear on a dependency line, only one of these
-dependencies may be followed by a creation script, unless the
+(For historical reasons, spaces are not accepted.)
+While targets can appear in many dependency lines if desired, by
+default only one of these rules may be followed by a creation
+script.
+If the
 .Ql Ic \&::
-operator is used.
+operator is used, however, all rules may include scripts and the
+scripts are executed in the order found.
 .Pp
-If the first characters of the command line are any combination of
+Each line is treated as a separate shell command, unless the end of
+line is escaped with a backslash
+.Pq Ql \e
+in which case that line and the next are combined.
+.\" The escaped newline is retained and passed to the shell, which
+.\" normally ignores it.
+.\" However, the tab at the beginning of the following line is removed.
+If the first characters of the command are any combination of
 .Ql Ic @ ,
 .Ql Ic + ,
 or
@@ -469,6 +503,7 @@
 except that the effect can be limited to a single line of a script.
 A
 .Ql Ic \-
+in compatibility mode
 causes any non-zero exit status of the command line to be ignored.
 .Pp
 When
@@ -477,23 +512,22 @@
 .Fl j Ar max_jobs ,
 the entire script for the target is fed to a
 single instance of the shell.
-.Pp
 In compatibility (non-jobs) mode, each command is run in a separate process.
 If the command contains any shell meta characters
 .Pq Ql #=|^(){};&<>*?[]:$`\e\en
-it will be passed to the shell, otherwise
+it will be passed to the shell; otherwise
 .Nm
 will attempt direct execution.
+If a line starts with
+.Ql Ic \-
+and the shell has ErrCtl enabled then failure of the command line
+will be ignored as in compatibility mode.
+Otherwise
+.Ql Ic \-
+affects the entire job;
+the script will stop at the first command line that fails,
+but the target will not be deemed to have failed.
 .Pp
-Since
-.Nm
-will
-.Xr chdir 2
-to
-.Ql Va .OBJDIR
-before executing any targets, each child process
-starts with that as its current working directory.
-.Pp
 Makefiles should be written so that the mode of
 .Nm
 operation does not change their behavior.
@@ -500,20 +534,32 @@
 For example, any command which needs to use
 .Dq cd
 or
-.Dq chdir ,
-without side-effect should be put in parenthesis:
+.Dq chdir
+without potentially changing the directory for subsequent commands
+should be put in parentheses so it executes in a subshell.
+To force the use of one shell, escape the line breaks so as to make
+the whole script one command.
+For example:
 .Bd -literal -offset indent
-
 avoid-chdir-side-effects:
 	@echo Building $@ in `pwd`
-	@(cd ${.CURDIR} && ${.MAKE} $@)
+	@(cd ${.CURDIR} && ${MAKE} $@)
 	@echo Back in `pwd`
 
 ensure-one-shell-regardless-of-mode:
-	@echo Building $@ in `pwd`; \\
-	(cd ${.CURDIR} && ${.MAKE} $@); \\
+	@echo Building $@ in `pwd`; \e
+	(cd ${.CURDIR} && ${MAKE} $@); \e
 	echo Back in `pwd`
 .Ed
+.Pp
+Since
+.Nm
+will
+.Xr chdir 2
+to
+.Ql Va .OBJDIR
+before executing any targets, each child process
+starts with that as its current working directory.
 .Sh VARIABLE ASSIGNMENTS
 Variables in make are much like variables in the shell, and, by tradition,
 consist of all upper-case letters.
@@ -624,22 +670,29 @@
 Variables defined as part of the command line.
 .It Local variables
 Variables that are defined specific to a certain target.
+.El
+.Pp
+Local variables are all built in and their values vary magically from
+target to target.
+It is not currently possible to define new local variables.
 The seven local variables are as follows:
-.Bl -tag -width ".ARCHIVE"
+.Bl -tag -width ".ARCHIVE" -offset indent
 .It Va .ALLSRC
 The list of all sources for this target; also known as
-.Ql Va \&\*[Gt] .
+.Ql Va \&> .
 .It Va .ARCHIVE
-The name of the archive file.
+The name of the archive file; also known as
+.Ql Va \&! .
 .It Va .IMPSRC
 In suffix-transformation rules, the name/path of the source from which the
 target is to be transformed (the
 .Dq implied
 source); also known as
-.Ql Va \&\*[Lt] .
+.Ql Va \&< .
 It is not defined in explicit rules.
 .It Va .MEMBER
-The name of the archive member.
+The name of the archive member; also known as
+.Ql Va % .
 .It Va .OODATE
 The list of sources for this target that were deemed out-of-date; also
 known as
@@ -648,31 +701,44 @@
 The file prefix of the target, containing only the file portion, no suffix
 or preceding directory components; also known as
 .Ql Va * .
+The suffix must be one of the known suffixes declared with
+.Ic .SUFFIXES
+or it will not be recognized.
 .It Va .TARGET
 The name of the target; also known as
 .Ql Va @ .
+For compatibility with other makes this is an alias for
+.Ic .ARCHIVE
+in archive member rules.
 .El
 .Pp
 The shorter forms
-.Ql Va @ ,
+.Ql ( Va > ,
+.Ql Va \&! ,
+.Ql Va < ,
+.Ql Va % ,
 .Ql Va \&? ,
-.Ql Va \&\*[Lt] ,
-.Ql Va \&\*[Gt] ,
+.Ql Va * ,
 and
-.Ql Va *
+.Ql Va @ )
 are permitted for backward
-compatibility with historical makefiles and are not recommended.
-The six variables
-.Ql Va "@F" ,
-.Ql Va "@D" ,
-.Ql Va "\*[Lt]F" ,
-.Ql Va "\*[Lt]D" ,
-.Ql Va "*F" ,
+compatibility with historical makefiles and legacy POSIX make and are
+not recommended.
+.Pp
+Variants of these variables with the punctuation followed immediately by
+.Ql D
+or
+.Ql F ,
+e.g.
+.Ql Va $(@D) ,
+are legacy forms equivalent to using the
+.Ql :H
 and
-.Ql Va "*D"
-are permitted for compatibility with
+.Ql :T
+modifiers.
+These forms are accepted for compatibility with
 .At V
-makefiles and are not recommended.
+makefiles and POSIX but are not recommended.
 .Pp
 Four of the local variables may be used in sources on dependency lines
 because they expand to the proper value for each target on the line.
@@ -682,7 +748,6 @@
 .Ql Va .ARCHIVE ,
 and
 .Ql Va .MEMBER .
-.El
 .Ss Additional built-in variables
 In addition,
 .Nm
@@ -725,6 +790,17 @@
 because it is more compatible with other versions of
 .Nm
 and cannot be confused with the special target with the same name.
+.It Va .MAKE.ALWAYS_PASS_JOB_QUEUE
+Tells
+.Nm
+whether to pass the descriptors of the job token queue
+even if the target is not tagged with
+.Ic .MAKE
+The default is 
+.Ql Pa yes
+for backwards compatability with
+.Fx 9.0
+and earlier.
 .It Va .MAKE.DEPENDFILE
 Names the makefile (default
 .Ql Pa .depend )
@@ -733,6 +809,10 @@
 A boolean that controls the default behavior of the
 .Fl V
 option.
+If true, variable values printed with
+.Fl V
+are fully expanded; if false, the raw variable contents (which may
+include additional unexpanded variable references) are shown.
 .It Va .MAKE.EXPORTED
 The list of variables exported by
 .Nm .
@@ -803,7 +883,7 @@
 .Nm
 runs in.
 It can contain a number of keywords:
-.Bl -hang -width ignore-cmd
+.Bl -hang -width missing-filemon=bf.
 .It Pa compat
 Like
 .Fl B ,
@@ -827,8 +907,19 @@
 This can be overridden by setting
 .Va bf
 to a value which represents True.
+.It Pa missing-meta= Ar bf
+If
+.Va bf
+is True, then a missing .meta file makes the target out-of-date.
+.It Pa missing-filemon= Ar bf
+If
+.Va bf
+is True, then missing filemon data makes the target out-of-date.
+.It Pa nofilemon
+Do not use
+.Xr filemon 4 .
 .It Pa env
-For debugging, it can be useful to inlcude the environment
+For debugging, it can be useful to include the environment
 in the .meta file.
 .It Pa verbose
 If in "meta" mode, print a clue about the target being built.
@@ -870,6 +961,12 @@
 because the contents are expected to change over time.
 The default list includes:
 .Ql Pa /dev /etc /proc /tmp /var/run /var/tmp
+.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:
@@ -878,7 +975,7 @@
 This variable is used to record the names of variables assigned to
 on the command line, so that they may be exported as part of
 .Ql Ev MAKEFLAGS .
-This behaviour can be disabled by assigning an empty value to
+This behavior can be disabled by assigning an empty value to
 .Ql Va .MAKEOVERRIDES
 within a makefile.
 Extra variables can be exported from a makefile
@@ -901,10 +998,35 @@
 .It Va .MAKE.PPID
 The parent process-id of
 .Nm .
+.It Va .MAKE.SAVE_DOLLARS
+value should be a boolean that controls whether
+.Ql $$
+are preserved when doing
+.Ql :=
+assignments.
+The default is false, for backwards compatibility.
+Set to true for compatability with other makes.
+If set to false,
+.Ql $$
+becomes
+.Ql $
+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 .
@@ -953,14 +1075,15 @@
 .Ql Ev MAKEOBJDIR .
 .Pp
 .Ql Va .OBJDIR
-may be modified in the makefile as a global variable.
+may be modified in the makefile via the special target
+.Ql Ic .OBJDIR .
 In all cases,
 .Nm
 will
 .Xr chdir 2
-to
+to the specified directory if it exists, and set
 .Ql Va .OBJDIR
-and set
+and
 .Ql Ev PWD
 to that directory before executing any targets.
 .
@@ -1003,7 +1126,7 @@
 to the value of
 .Ql Ev PWD
 instead.
-This behaviour is disabled if
+This behavior is disabled if
 .Ql Ev MAKEOBJDIRPREFIX
 is set or
 .Ql Ev MAKEOBJDIR
@@ -1073,7 +1196,7 @@
 As a consequence of the way values are split into words, matched,
 and then joined, a construct like
 .Dl ${VAR:M*}
-will normalise the inter-word spacing, removing all leading and
+will normalize the inter-word spacing, removing all leading and
 trailing space, and converting multiple consecutive spaces
 to single spaces.
 .
@@ -1093,7 +1216,7 @@
 The results will be different each time you are referring to the
 modified variable; use the assignment with expansion
 .Pq Ql Cm \&:=
-to prevent such behaviour.
+to prevent such behavior.
 For example,
 .Bd -literal -offset indent
 LIST=			uno due tre quattro
@@ -1119,18 +1242,28 @@
 .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 32bit hash of the value and encode it as hex digits.
-.It Cm \&:localtime
+Compute a 32-bit hash of the value and encode it as hex digits.
+.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 ,
@@ -1191,7 +1324,7 @@
 Inside
 .Ar new_string ,
 an ampersand
-.Pq Ql \*[Am]
+.Pq Ql &
 is replaced by
 .Ar old_string
 (without any
@@ -1330,6 +1463,27 @@
 .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 at + $${_:[-$$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
@@ -1403,7 +1557,7 @@
 .Pp
 Ordinarily, a value is treated as a sequence of words
 delimited by white space.
-Some modifiers suppress this behaviour,
+Some modifiers suppress this behavior,
 causing a value to be treated as a single word
 (possibly containing embedded white space).
 An empty value, or a value that consists entirely of white-space,
@@ -1489,6 +1643,7 @@
 .Nm
 .Ql include file ...
 is also accepted.
+.Pp
 If the include statement is written as
 .Cm .-include
 or as
@@ -1495,6 +1650,13 @@
 .Cm .sinclude
 then errors locating and/or opening include files are ignored.
 .Pp
+If the include statement is written as
+.Cm .dinclude
+not only are errors locating and/or opening include files ignored,
+but stale dependencies within the included file will be ignored
+just like
+.Va .MAKE.DEPENDFILE .
+.Pp
 Conditional expressions are also preceded by a single dot as the first
 character of a line.
 The possible conditionals are as follows:
@@ -1530,6 +1692,10 @@
 used by
 .Nm
 internally.
+.It Ic .export-literal Ar variable ...
+The same as
+.Ql .export-env ,
+except that variables in the value are not expanded.
 .It Ic .info Ar message
 The message is printed along with the name of the makefile and line number.
 .It Ic .undef Ar variable
@@ -1622,7 +1788,7 @@
 .Bl -tag -width "Cm XX"
 .It Cm \&|\&|
 Logical OR.
-.It Cm \&\*[Am]\*[Am]
+.It Cm \&&&
 Logical
 .Tn AND ;
 of higher precedence than
@@ -1639,7 +1805,7 @@
 may be used to logically negate an entire
 conditional.
 It is of higher precedence than
-.Ql Ic \&\*[Am]\*[Am] .
+.Ql Ic \&&& .
 .Pp
 The value of
 .Ar expression
@@ -1913,6 +2079,14 @@
 .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.
@@ -1961,6 +2135,15 @@
 Synonym for
 .Ic .NOTPARALLEL ,
 for compatibility with other pmake variants.
+.It Ic .OBJDIR
+The source is a new value for
+.Ql Va .OBJDIR .
+If it exists,
+.Nm
+will
+.Xr chdir 2
+to it and update the value of
+.Ql Va .OBJDIR .
 .It Ic .ORDER
 The named targets are made in sequence.
 This ordering does not add targets to the list of targets to be made.
@@ -2018,7 +2201,7 @@
 pairs.
 .Bl -tag -width hasErrCtls
 .It Ar name
-This is the minimal specification, used to select one of the builtin
+This is the minimal specification, used to select one of the built-in
 shell specs;
 .Ar sh ,
 .Ar ksh ,
@@ -2119,19 +2302,87 @@
 system makefile directory
 .El
 .Sh COMPATIBILITY
-The basic make syntax is compatible between different versions of make,
+The basic make syntax is compatible between different versions of make;
 however the special variables, variable modifiers and conditionals are not.
+.Ss Older versions
+An incomplete list of changes in older versions of
+.Nm :
 .Pp
+The way that .for loop variables are substituted changed after
+.Nx 5.0
+so that they still appear to be variable expansions.
+In particular this stops them being treated as syntax, and removes some
+obscure problems using them in .if statements.
+.Pp
 The way that parallel makes are scheduled changed in
 .Nx 4.0
 so that .ORDER and .WAIT apply recursively to the dependent nodes.
 The algorithms used may change again in the future.
+.Ss Other make dialects
+Other make dialects (GNU make, SVR4 make, POSIX make, etc.) do not
+support most of the features of
+.Nm
+as described in this manual.
+Most notably:
+.Bl -bullet -offset indent
+.It
+The
+.Ic .WAIT
+and
+.Ic .ORDER
+declarations and most functionality pertaining to parallelization.
+(GNU make supports parallelization but lacks these features needed to
+control it effectively.)
+.It
+Directives, including for loops and conditionals and most of the
+forms of include files.
+(GNU make has its own incompatible and less powerful syntax for
+conditionals.)
+.It
+All built-in variables that begin with a dot.
+.It
+Most of the special sources and targets that begin with a dot,
+with the notable exception of
+.Ic .PHONY ,
+.Ic .PRECIOUS ,
+and
+.Ic .SUFFIXES .
+.It
+Variable modifiers, except for the
+.Dl :old=new
+string substitution, which does not portably support globbing with
+.Ql %
+and historically only works on declared suffixes.
+.It
+The
+.Ic $>
+variable even in its short form; most makes support this functionality
+but its name varies.
+.El
 .Pp
-The way that .for loop variables are substituted changed after
-.Nx 5.0
-so that they still appear to be variable expansions.
-In particular this stops them being treated as syntax, and removes some
-obscure problems using them in .if statements.
+Some features are somewhat more portable, such as assignment with
+.Ic += ,
+.Ic ?= ,
+and
+.Ic != .
+The
+.Ic .PATH
+functionality is based on an older feature
+.Ic VPATH
+found in GNU make and many versions of SVR4 make; however,
+historically its behavior is too ill-defined (and too buggy) to rely
+upon.
+.Pp
+The
+.Ic $@
+and
+.Ic $<
+variables are more or less universally portable, as is the
+.Ic $(MAKE)
+variable.
+Basic use of suffix rules (for files only in the current directory,
+not trying to chain transformations together, etc.) is also reasonably
+portable.
 .Sh SEE ALSO
 .Xr mkdep 1
 .Sh HISTORY

Modified: vendor/NetBSD/bmake/dist/make.c
===================================================================
--- vendor/NetBSD/bmake/dist/make.c	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/make.c	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.c,v 1.88 2012/11/09 18:53:05 sjg Exp $	*/
+/*	$NetBSD: make.c,v 1.96 2016/11/10 23:41:58 sjg Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: make.c,v 1.88 2012/11/09 18:53:05 sjg Exp $";
+static char rcsid[] = "$NetBSD: make.c,v 1.96 2016/11/10 23:41:58 sjg Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
@@ -76,7 +76,7 @@
 #if 0
 static char sccsid[] = "@(#)make.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: make.c,v 1.88 2012/11/09 18:53:05 sjg Exp $");
+__RCSID("$NetBSD: make.c,v 1.96 2016/11/10 23:41:58 sjg Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -308,7 +308,7 @@
 	if (DEBUG(MAKE)) {
 	    if (gn->cmgn != NULL && gn->mtime < gn->cmgn->mtime) {
 		fprintf(debug_file, "modified before source %s...",
-		    gn->cmgn->path);
+		    gn->cmgn->path ? gn->cmgn->path : gn->cmgn->name);
 	    } else if (gn->mtime == 0) {
 		fprintf(debug_file, "non-existent and no sources...");
 	    } else {
@@ -482,10 +482,9 @@
 	    if (gn->uname == NULL) {
 		gn->uname = gn->name;
 	    } else {
-		if (gn->name)
-		    free(gn->name);
+		free(gn->name);
 	    }
-	    gn->name = Var_Subst(NULL, gn->uname, pgn, FALSE);
+	    gn->name = Var_Subst(NULL, gn->uname, pgn, VARF_WANTRES);
 	    if (gn->name && gn->uname && strcmp(gn->name, gn->uname) != 0) {
 		/* See if we have a target for this node. */
 		tgn = Targ_FindNode(gn->name, TARG_NOCREATE);
@@ -563,7 +562,7 @@
  *	in the comments below.
  *
  * Results:
- *	returns 0 if the gnode does not exist, or it's filesystem
+ *	returns 0 if the gnode does not exist, or its filesystem
  *	time if it does.
  *
  * Side Effects:
@@ -692,8 +691,7 @@
     checked++;
 
     cname = Var_Value(TARGET, cgn, &p1);
-    if (p1)
-	free(p1);
+    free(p1);
 
     if (DEBUG(MAKE))
 	fprintf(debug_file, "Make_Update: %s%s\n", cgn->name, cgn->cohort_num);
@@ -838,8 +836,7 @@
 		    Var_Set(PREFIX, cpref, pgn, 0);
 	    }
 	}
-	if (p1)
-	    free(p1);
+	free(p1);
 	Lst_Close(cgn->iParents);
     }
 }
@@ -907,8 +904,7 @@
 	}
 	if (allsrc != NULL)
 		Var_Append(ALLSRC, allsrc, pgn);
-	if (p2)
-	    free(p2);
+	free(p2);
 	if (pgn->type & OP_JOIN) {
 	    if (cgn->made == MADE) {
 		Var_Append(OODATE, child, pgn);
@@ -934,8 +930,7 @@
 	     */
 	    Var_Append(OODATE, child, pgn);
 	}
-	if (p1)
-	    free(p1);
+	free(p1);
     }
     return (0);
 }
@@ -981,8 +976,7 @@
     if (gn->type & OP_JOIN) {
 	char *p1;
 	Var_Set(TARGET, Var_Value(ALLSRC, gn, &p1), gn, 0);
-	if (p1)
-	    free(p1);
+	free(p1);
     }
     gn->flags |= DONE_ALLSRC;
 }

Modified: vendor/NetBSD/bmake/dist/make.h
===================================================================
--- vendor/NetBSD/bmake/dist/make.h	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/make.h	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.h,v 1.92 2013/09/04 15:38:26 sjg Exp $	*/
+/*	$NetBSD: make.h,v 1.103 2017/07/20 19:29:54 sjg Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -88,6 +88,7 @@
 #include <sys/param.h>
 
 #include <ctype.h>
+#include <fcntl.h>
 #include <stdio.h>
 #include <stdlib.h>
 #ifdef HAVE_STRING_H
@@ -98,6 +99,10 @@
 #include <unistd.h>
 #include <sys/cdefs.h>
 
+#ifndef FD_CLOEXEC
+#define FD_CLOEXEC 1
+#endif
+
 #if defined(__GNUC__)
 #define	MAKE_GNUC_PREREQ(x, y)						\
 	((__GNUC__ == (x) && __GNUC_MINOR__ >= (y)) ||			\
@@ -194,6 +199,7 @@
 #define DONE_ALLSRC	0x40	/* We do it once only */
 #define CYCLE		0x1000  /* Used by MakePrintStatus */
 #define DONECYCLE	0x2000  /* Used by MakePrintStatus */
+#define INTERNAL	0x4000	/* Internal use only */
     enum enum_made {
 	UNMADE, DEFERRED, REQUESTED, BEINGMADE,
 	MADE, UPTODATE, ERROR, ABORTED
@@ -289,6 +295,7 @@
 #define OP_NOMETA	0x00080000  /* .NOMETA do not create a .meta file */
 #define OP_META		0x00100000  /* .META we _do_ want a .meta file */
 #define OP_NOMETA_CMP	0x00200000  /* Do not compare commands in .meta file */
+#define OP_SUBMAKE	0x00400000  /* Possibly a submake node */
 /* Attributes applied by PMake */
 #define OP_TRANSFORM	0x80000000  /* The node is a transformation rule */
 #define OP_MEMBER 	0x40000000  /* Target is a member of an archive */
@@ -382,6 +389,7 @@
 extern Boolean  noExecute;    	/* True if should execute nothing */
 extern Boolean  noRecursiveExecute;    	/* True if should execute nothing */
 extern Boolean  allPrecious;   	/* True if every target is precious */
+extern Boolean  deleteOnError;	/* True if failed targets should be deleted */
 extern Boolean  keepgoing;    	/* True if should continue on unaffected
 				 * portions of the graph when have an error
 				 * in one portion */
@@ -496,10 +504,16 @@
 void Check_Cwd(const char **);
 void PrintOnError(GNode *, const char *);
 void Main_ExportMAKEFLAGS(Boolean);
-Boolean Main_SetObjdir(const char *);
+Boolean Main_SetObjdir(const char *, ...) MAKE_ATTR_PRINTFLIKE(1, 2);
 int mkTempFile(const char *, char **);
 int str2Lst_Append(Lst, char *, const char *);
+int cached_lstat(const char *, void *);
+int cached_stat(const char *, void *);
 
+#define	VARF_UNDEFERR	1
+#define	VARF_WANTRES	2
+#define	VARF_ASSIGN	4
+
 #ifdef __GNUC__
 #define UNCONST(ptr)	({ 		\
     union __unconst {			\
@@ -518,8 +532,21 @@
 #define MAX(a, b) ((a > b) ? a : b)
 #endif
 
+/* At least GNU/Hurd systems lack hardcoded MAXPATHLEN/PATH_MAX */
+#ifdef HAVE_LIMITS_H
+#include <limits.h>
+#endif
 #ifndef MAXPATHLEN
-#define MAXPATHLEN BMAKE_PATH_MAX
+#define MAXPATHLEN	BMAKE_PATH_MAX
 #endif
+#ifndef PATH_MAX
+#define PATH_MAX	MAXPATHLEN
+#endif
 
+#if defined(SYSV)
+#define KILLPG(pid, sig)	kill(-(pid), (sig))
+#else
+#define KILLPG(pid, sig)	killpg((pid), (sig))
+#endif
+
 #endif /* _MAKE_H_ */

Modified: vendor/NetBSD/bmake/dist/make_malloc.c
===================================================================
--- vendor/NetBSD/bmake/dist/make_malloc.c	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/make_malloc.c	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,4 +1,4 @@
-/*	$NetBSD: make_malloc.c,v 1.10 2012/06/20 17:46:28 sjg Exp $	*/
+/*	$NetBSD: make_malloc.c,v 1.11 2017/04/16 20:20:24 dholland Exp $	*/
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
 
 #ifdef MAKE_NATIVE
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: make_malloc.c,v 1.10 2012/06/20 17:46:28 sjg Exp $");
+__RCSID("$NetBSD: make_malloc.c,v 1.11 2017/04/16 20:20:24 dholland Exp $");
 #endif
 
 #include <stdio.h>
@@ -39,13 +39,13 @@
 #include "make.h"
 
 #ifndef USE_EMALLOC
-static void enomem(void) MAKE_ATTR_DEAD;
+static MAKE_ATTR_DEAD void enomem(void);
 
 /*
  * enomem --
  *	die when out of memory.
  */
-static void
+static MAKE_ATTR_DEAD void
 enomem(void)
 {
 	(void)fprintf(stderr, "%s: %s.\n", progname, strerror(ENOMEM));

Modified: vendor/NetBSD/bmake/dist/meta.c
===================================================================
--- vendor/NetBSD/bmake/dist/meta.c	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/meta.c	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,4 +1,4 @@
-/*      $NetBSD: meta.c,v 1.33 2013/10/01 05:37:17 sjg Exp $ */
+/*      $NetBSD: meta.c,v 1.68 2017/07/09 04:54:00 sjg Exp $ */
 
 /*
  * Implement 'meta' mode.
@@ -6,7 +6,7 @@
  * --sjg
  */
 /*
- * Copyright (c) 2009-2010, Juniper Networks, Inc.
+ * Copyright (c) 2009-2016, Juniper Networks, Inc.
  * Portions Copyright (c) 2009, John Birrell.
  * 
  * Redistribution and use in source and binary forms, with or without
@@ -37,8 +37,11 @@
 #endif
 #include <sys/stat.h>
 #include <sys/ioctl.h>
-#include <fcntl.h>
+#ifdef HAVE_LIBGEN_H
 #include <libgen.h>
+#elif !defined(HAVE_DIRNAME)
+char * dirname(char *);
+#endif
 #include <errno.h>
 #if !defined(HAVE_CONFIG_H) || defined(HAVE_ERR_H)
 #include <err.h>
@@ -56,18 +59,30 @@
 
 static BuildMon Mybm;			/* for compat */
 static Lst metaBailiwick;		/* our scope of control */
+static char *metaBailiwickStr;		/* string storage for the list */
 static Lst metaIgnorePaths;		/* paths we deliberately ignore */
+static char *metaIgnorePathsStr;	/* string storage for the list */
 
 #ifndef MAKE_META_IGNORE_PATHS
 #define MAKE_META_IGNORE_PATHS ".MAKE.META.IGNORE_PATHS"
 #endif
+#ifndef MAKE_META_IGNORE_PATTERNS
+#define MAKE_META_IGNORE_PATTERNS ".MAKE.META.IGNORE_PATTERNS"
+#endif
+#ifndef MAKE_META_IGNORE_FILTER
+#define MAKE_META_IGNORE_FILTER ".MAKE.META.IGNORE_FILTER"
+#endif
 
 Boolean useMeta = FALSE;
 static Boolean useFilemon = FALSE;
 static Boolean writeMeta = FALSE;
+static Boolean metaMissing = FALSE;	/* oodate if missing */
+static Boolean filemonMissing = FALSE;	/* oodate if missing */
 static Boolean metaEnv = FALSE;		/* don't save env unless asked */
 static Boolean metaVerbose = FALSE;
 static Boolean metaIgnoreCMDs = FALSE;	/* ignore CMDs in .meta files */
+static Boolean metaIgnorePatterns = FALSE; /* do we need to do pattern matches */
+static Boolean metaIgnoreFilter = FALSE;   /* do we have more complex filtering? */
 static Boolean metaCurdirOk = FALSE;	/* write .meta in .CURDIR Ok? */
 static Boolean metaSilent = FALSE;	/* if we have a .meta be SILENT */
 
@@ -144,8 +159,8 @@
 	err(1, "Could not set filemon file descriptor!");
     }
     /* we don't need these once we exec */
-    (void)fcntl(pbm->mon_fd, F_SETFD, 1);
-    (void)fcntl(pbm->filemon_fd, F_SETFD, 1);
+    (void)fcntl(pbm->mon_fd, F_SETFD, FD_CLOEXEC);
+    (void)fcntl(pbm->filemon_fd, F_SETFD, FD_CLOEXEC);
 }
 
 /*
@@ -152,31 +167,33 @@
  * Read the build monitor output file and write records to the target's
  * metadata file.
  */
-static void
+static int
 filemon_read(FILE *mfp, int fd)
 {
-    FILE *fp;
     char buf[BUFSIZ];
+    int n;
+    int error;
 
     /* Check if we're not writing to a meta data file.*/
     if (mfp == NULL) {
 	if (fd >= 0)
 	    close(fd);			/* not interested */
-	return;
+	return 0;
     }
     /* rewind */
     (void)lseek(fd, (off_t)0, SEEK_SET);
-    if ((fp = fdopen(fd, "r")) == NULL)
-	err(1, "Could not read build monitor file '%d'", fd);
 
-    fprintf(mfp, "-- filemon acquired metadata --\n");
+    error = 0;
+    fprintf(mfp, "\n-- filemon acquired metadata --\n");
 
-    while (fgets(buf, sizeof(buf), fp)) {
-	fprintf(mfp, "%s", buf);
+    while ((n = read(fd, buf, sizeof(buf))) > 0) {
+	if ((int)fwrite(buf, 1, n, mfp) < n)
+	    error = EIO;
     }
     fflush(mfp);
-    clearerr(fp);
-    fclose(fp);
+    if (close(fd) < 0)
+	error = errno;
+    return error;
 }
 #endif
 
@@ -224,27 +241,16 @@
 }
 
 static char *
-meta_name(struct GNode *gn, char *mname, size_t mnamelen,
+meta_name(char *mname, size_t mnamelen,
 	  const char *dname,
-	  const char *tname)
+	  const char *tname,
+	  const char *cwd)
 {
     char buf[MAXPATHLEN];
-    char cwd[MAXPATHLEN];
     char *rp;
     char *cp;
     char *tp;
-    char *p[4];				/* >= number of possible uses */
-    int i;
 
-    i = 0;
-    if (!dname)
-	dname = Var_Value(".OBJDIR", gn, &p[i++]);
-    if (!tname)
-	tname = Var_Value(TARGET, gn, &p[i++]);
-
-    if (realpath(dname, cwd))
-	dname = cwd;
-
     /*
      * Weed out relative paths from the target file name.
      * We have to be careful though since if target is a
@@ -253,7 +259,7 @@
      * basename as given to us.
      */
     if ((cp = strrchr(tname, '/'))) {
-	if (realpath(tname, buf)) {
+	if (cached_realpath(tname, buf)) {
 	    if ((rp = strrchr(buf, '/'))) {
 		rp++;
 		cp++;
@@ -298,10 +304,6 @@
 	}
     }
     free(tp);
-    for (i--; i >= 0; i--) {
-	if (p[i])
-	    free(p[i]);
-    }
     return (mname);
 }
 
@@ -327,7 +329,7 @@
     }
     cp = strchr(cmd, '$');
     if ((cp)) {
-	mp = Var_Subst(NULL, cmd, gn, FALSE);
+	mp = Var_Subst(NULL, cmd, gn, VARF_WANTRES);
 	cmd = mp;
     }
     cp2 = strstr(cmd, p_make);
@@ -352,8 +354,7 @@
 	    }
 	}
     }
-    if (mp)
-	free(mp);
+    free(mp);
     return (rc);
 }
 
@@ -370,11 +371,10 @@
     char *cp = NULL;
 
     if (strchr(cmd, '$')) {
-	cmd = cp = Var_Subst(NULL, cmd, mfp->gn, FALSE);
+	cmd = cp = Var_Subst(NULL, cmd, mfp->gn, VARF_WANTRES);
     }
     fprintf(mfp->fp, "CMD %s\n", cmd);
-    if (cp)
-	free(cp);
+    free(cp);
     return 0;
 }
 
@@ -383,29 +383,26 @@
  */
 #define SKIP_META_TYPE(_type) do { \
     if ((gn->type & __CONCAT(OP_, _type))) {	\
-	if (DEBUG(META)) { \
+	if (verbose) { \
 	    fprintf(debug_file, "Skipping meta for %s: .%s\n", \
 		    gn->name, __STRING(_type));		       \
 	} \
-	return (NULL); \
+	return FALSE; \
     } \
 } while (0)
 
-static FILE *
-meta_create(BuildMon *pbm, GNode *gn)
+
+/*
+ * Do we need/want a .meta file ?
+ */
+static Boolean
+meta_needed(GNode *gn, const char *dname,
+	     char *objdir, int verbose)
 {
-    meta_file_t mf;
-    char buf[MAXPATHLEN];
-    char objdir[MAXPATHLEN];
-    char **ptr;
-    const char *dname;
-    const char *tname;
-    char *fname;
-    const char *cp;
-    char *p[4];				/* >= possible uses */
-    int i;
     struct stat fs;
 
+    if (verbose)
+	verbose = DEBUG(META);
     
     /* This may be a phony node which we don't want meta data for... */
     /* Skip .meta for .BEGIN, .END, .ERROR etc as well. */
@@ -418,54 +415,76 @@
 	SKIP_META_TYPE(MAKE);
     }
 
-    mf.fp = NULL;
-    
-    i = 0;
-    
-    dname = Var_Value(".OBJDIR", gn, &p[i++]);
-    tname = Var_Value(TARGET, gn, &p[i++]);
-    
-    /* The object directory may not exist. Check it.. */
-    if (stat(dname, &fs) != 0) {
-	if (DEBUG(META))
-	    fprintf(debug_file, "Skipping meta for %s: no .OBJDIR\n",
-		    gn->name);
-	goto out;
-    }
     /* Check if there are no commands to execute. */
     if (Lst_IsEmpty(gn->commands)) {
-	if (DEBUG(META))
+	if (verbose)
 	    fprintf(debug_file, "Skipping meta for %s: no commands\n",
 		    gn->name);
-	goto out;
+	return FALSE;
     }
+    if ((gn->type & (OP_META|OP_SUBMAKE)) == OP_SUBMAKE) {
+	/* OP_SUBMAKE is a bit too aggressive */
+	if (Lst_ForEach(gn->commands, is_submake, gn)) {
+	    if (DEBUG(META))
+		fprintf(debug_file, "Skipping meta for %s: .SUBMAKE\n",
+			gn->name);
+	    return FALSE;
+	}
+    }
 
+    /* The object directory may not exist. Check it.. */
+    if (cached_stat(dname, &fs) != 0) {
+	if (verbose)
+	    fprintf(debug_file, "Skipping meta for %s: no .OBJDIR\n",
+		    gn->name);
+	return FALSE;
+    }
+
     /* make sure these are canonical */
-    if (realpath(dname, objdir))
+    if (cached_realpath(dname, objdir))
 	dname = objdir;
 
     /* If we aren't in the object directory, don't create a meta file. */
     if (!metaCurdirOk && strcmp(curdir, dname) == 0) {
-	if (DEBUG(META))
+	if (verbose)
 	    fprintf(debug_file, "Skipping meta for %s: .OBJDIR == .CURDIR\n",
 		    gn->name);
-	goto out;
+	return FALSE;
     }
-    if (!(gn->type & OP_META)) {
-	/* We do not generate .meta files for sub-makes */
-	if (Lst_ForEach(gn->commands, is_submake, gn)) {
-	    if (DEBUG(META))
-		fprintf(debug_file, "Skipping meta for %s: .MAKE\n",
-			gn->name);
-	    goto out;
-	}
-    }
+    return TRUE;
+}
 
+    
+static FILE *
+meta_create(BuildMon *pbm, GNode *gn)
+{
+    meta_file_t mf;
+    char buf[MAXPATHLEN];
+    char objdir[MAXPATHLEN];
+    char **ptr;
+    const char *dname;
+    const char *tname;
+    char *fname;
+    const char *cp;
+    char *p[4];				/* >= possible uses */
+    int i;
+
+    mf.fp = NULL;
+    i = 0;
+
+    dname = Var_Value(".OBJDIR", gn, &p[i++]);
+    tname = Var_Value(TARGET, gn, &p[i++]);
+
+    /* if this succeeds objdir is realpath of dname */
+    if (!meta_needed(gn, dname, objdir, TRUE))
+	goto out;
+    dname = objdir;
+
     if (metaVerbose) {
 	char *mp;
 
 	/* Describe the target we are building */
-	mp = Var_Subst(NULL, "${" MAKE_META_PREFIX "}", gn, 0);
+	mp = Var_Subst(NULL, "${" MAKE_META_PREFIX "}", gn, VARF_WANTRES);
 	if (*mp)
 	    fprintf(stdout, "%s\n", mp);
 	free(mp);
@@ -479,15 +498,12 @@
 
     fflush(stdout);
 
-    if (strcmp(cp, makeDependfile) == 0)
-	goto out;
-
     if (!writeMeta)
 	/* Don't create meta data. */
 	goto out;
 
-    fname = meta_name(gn, pbm->meta_fname, sizeof(pbm->meta_fname),
-		      dname, tname);
+    fname = meta_name(pbm->meta_fname, sizeof(pbm->meta_fname),
+		      dname, tname, objdir);
 
 #ifdef DEBUG_META_MODE
     if (DEBUG(META))
@@ -523,8 +539,7 @@
     }
  out:
     for (i--; i >= 0; i--) {
-	if (p[i])
-	    free(p[i]);
+	free(p[i]);
     }
 
     return (mf.fp);
@@ -557,6 +572,10 @@
 }
 
 
+#define get_mode_bf(bf, token) \
+    if ((cp = strstr(make_mode, token))) \
+	bf = boolValue(&cp[sizeof(token) - 1])
+
 /*
  * Initialization we need after reading makefiles.
  */
@@ -579,17 +598,13 @@
 	    writeMeta = FALSE;
 	if (strstr(make_mode, "nofilemon"))
 	    useFilemon = FALSE;
-	if ((cp = strstr(make_mode, "curdirok="))) {
-	    metaCurdirOk = boolValue(&cp[9]);
-	}
-	if ((cp = strstr(make_mode, "silent="))) {
-	    metaSilent = boolValue(&cp[7]);
-	}
 	if (strstr(make_mode, "ignore-cmd"))
 	    metaIgnoreCMDs = TRUE;
-	/* for backwards compatability */
-	Var_Set(".MAKE.META_CREATED", "${.MAKE.META.CREATED}", VAR_GLOBAL, 0);
-	Var_Set(".MAKE.META_FILES", "${.MAKE.META.FILES}", VAR_GLOBAL, 0);
+	if (useFilemon)
+	    get_mode_bf(filemonMissing, "missing-filemon=");
+	get_mode_bf(metaCurdirOk, "curdirok=");
+	get_mode_bf(metaMissing, "missing-meta=");
+	get_mode_bf(metaSilent, "silent=");
     }
     if (metaVerbose && !Var_Exists(MAKE_META_PREFIX, VAR_GLOBAL)) {
 	/*
@@ -608,9 +623,10 @@
      * We consider ourselves master of all within ${.MAKE.META.BAILIWICK}
      */
     metaBailiwick = Lst_Init(FALSE);
-    cp = Var_Subst(NULL, "${.MAKE.META.BAILIWICK:O:u:tA}", VAR_GLOBAL, 0);
-    if (cp) {
-	str2Lst_Append(metaBailiwick, cp, NULL);
+    metaBailiwickStr = Var_Subst(NULL, "${.MAKE.META.BAILIWICK:O:u:tA}",
+	VAR_GLOBAL, VARF_WANTRES);
+    if (metaBailiwickStr) {
+	str2Lst_Append(metaBailiwick, metaBailiwickStr, NULL);
     }
     /*
      * We ignore any paths that start with ${.MAKE.META.IGNORE_PATHS}
@@ -618,11 +634,26 @@
     metaIgnorePaths = Lst_Init(FALSE);
     Var_Append(MAKE_META_IGNORE_PATHS,
 	       "/dev /etc /proc /tmp /var/run /var/tmp ${TMPDIR}", VAR_GLOBAL);
-    cp = Var_Subst(NULL,
-		   "${" MAKE_META_IGNORE_PATHS ":O:u:tA}", VAR_GLOBAL, 0);
-    if (cp) {
-	str2Lst_Append(metaIgnorePaths, cp, NULL);
+    metaIgnorePathsStr = Var_Subst(NULL,
+		   "${" MAKE_META_IGNORE_PATHS ":O:u:tA}", VAR_GLOBAL,
+		   VARF_WANTRES);
+    if (metaIgnorePathsStr) {
+	str2Lst_Append(metaIgnorePaths, metaIgnorePathsStr, NULL);
     }
+
+    /*
+     * We ignore any paths that match ${.MAKE.META.IGNORE_PATTERNS}
+     */
+    cp = NULL;
+    if (Var_Value(MAKE_META_IGNORE_PATTERNS, VAR_GLOBAL, &cp)) {
+	metaIgnorePatterns = TRUE;
+	free(cp);
+    }
+    cp = NULL;
+    if (Var_Value(MAKE_META_IGNORE_FILTER, VAR_GLOBAL, &cp)) {
+	metaIgnoreFilter = TRUE;
+	free(cp);
+    }
 }
 
 /*
@@ -662,7 +693,6 @@
 {
 #ifdef USE_FILEMON
     BuildMon *pbm;
-    pid_t pid;
 
     if (job != NULL) {
 	pbm = &job->bm;
@@ -669,10 +699,15 @@
     } else {
 	pbm = &Mybm;
     }
-    pid = getpid();
-    if (pbm->mfp != NULL && useFilemon) {
-	if (ioctl(pbm->filemon_fd, FILEMON_SET_PID, &pid) < 0) {
-	    err(1, "Could not set filemon pid!");
+    if (pbm->mfp != NULL) {
+	close(fileno(pbm->mfp));
+	if (useFilemon) {
+	    pid_t pid;
+
+	    pid = getpid();
+	    if (ioctl(pbm->filemon_fd, FILEMON_SET_PID, &pid) < 0) {
+		err(1, "Could not set filemon pid!");
+	    }
 	}
     }
 #endif
@@ -686,13 +721,13 @@
 
     if (job != NULL) {
 	pbm = &job->bm;
-    } else {
 	if (!gn)
 	    gn = job->node;
+    } else {
 	pbm = &Mybm;
     }
     if (pbm->mfp != NULL) {
-	fprintf(pbm->mfp, "*** Error code %d%s\n",
+	fprintf(pbm->mfp, "\n*** Error code %d%s\n",
 		status,
 		(flags & JOB_IGNERR) ?
 		"(ignored)" : "");
@@ -702,7 +737,7 @@
     }
     getcwd(cwd, sizeof(cwd));
     Var_Set(".ERROR_CWD", cwd, VAR_GLOBAL, 0);
-    if (pbm && pbm->meta_fname[0]) {
+    if (pbm->meta_fname[0]) {
 	Var_Set(".ERROR_META_FILE", pbm->meta_fname, VAR_GLOBAL, 0);
     }
     meta_job_finish(job);
@@ -726,7 +761,8 @@
 	    if (!meta_prefix) {
 		char *cp2;
 
-		meta_prefix = Var_Subst(NULL, "${" MAKE_META_PREFIX "}", VAR_GLOBAL, 0);
+		meta_prefix = Var_Subst(NULL, "${" MAKE_META_PREFIX "}",
+					VAR_GLOBAL, VARF_WANTRES);
 		if ((cp2 = strchr(meta_prefix, '$')))
 		    meta_prefix_len = cp2 - meta_prefix;
 		else
@@ -742,27 +778,36 @@
     }
 }
 
-void
+int
 meta_cmd_finish(void *pbmp)
 {
-#ifdef USE_FILEMON
+    int error = 0;
     BuildMon *pbm = pbmp;
+    int x;
 
     if (!pbm)
 	pbm = &Mybm;
 
+#ifdef USE_FILEMON
     if (pbm->filemon_fd >= 0) {
-	close(pbm->filemon_fd);
-	filemon_read(pbm->mfp, pbm->mon_fd);
+	if (close(pbm->filemon_fd) < 0)
+	    error = errno;
+	x = filemon_read(pbm->mfp, pbm->mon_fd);
+	if (error == 0 && x != 0)
+	    error = x;
 	pbm->filemon_fd = pbm->mon_fd = -1;
-    }
+    } else
 #endif
+	fprintf(pbm->mfp, "\n");	/* ensure end with newline */
+    return error;
 }
 
-void
+int
 meta_job_finish(Job *job)
 {
     BuildMon *pbm;
+    int error = 0;
+    int x;
 
     if (job != NULL) {
 	pbm = &job->bm;
@@ -770,13 +815,25 @@
 	pbm = &Mybm;
     }
     if (pbm->mfp != NULL) {
-	meta_cmd_finish(pbm);
-	fclose(pbm->mfp);
+	error = meta_cmd_finish(pbm);
+	x = fclose(pbm->mfp);
+	if (error == 0 && x != 0)
+	    error = errno;
 	pbm->mfp = NULL;
 	pbm->meta_fname[0] = '\0';
     }
+    return error;
 }
 
+void
+meta_finish(void)
+{
+    Lst_Destroy(metaBailiwick, NULL);
+    free(metaBailiwickStr);
+    Lst_Destroy(metaIgnorePaths, NULL);
+    free(metaIgnorePathsStr);
+}
+
 /*
  * Fetch a full line from fp - growing bufp if needed
  * Return length in bufp.
@@ -805,6 +862,8 @@
 	    newsz = ROUNDUP((fs.st_size / 2), BUFSIZ);
 	    if (newsz <= bufsz)
 		newsz = ROUNDUP(fs.st_size, BUFSIZ);
+	    if (newsz <= bufsz)
+		return x;		/* truncated */
 	    if (DEBUG(META)) 
 		fprintf(debug_file, "growing buffer %u -> %u\n",
 			(unsigned)bufsz, (unsigned)newsz);
@@ -822,6 +881,7 @@
     return 0;
 }
 
+/* Lst_ForEach wants 1 to stop search */
 static int
 prefix_match(void *p, void *q)
 {
@@ -832,7 +892,33 @@
     return (0 == strncmp(path, prefix, n));
 }
 
+/*
+ * looking for exact or prefix/ match to
+ * Lst_Find wants 0 to stop search
+ */
 static int
+path_match(const void *p, const void *q)
+{
+    const char *prefix = q;
+    const char *path = p;
+    size_t n = strlen(prefix);
+    int rc;
+
+    if ((rc = strncmp(path, prefix, n)) == 0) {
+	switch (path[n]) {
+	case '\0':
+	case '/':
+	    break;
+	default:
+	    rc = 1;
+	    break;
+	}
+    }
+    return rc;
+}
+
+/* Lst_Find wants 0 to stop search */
+static int
 string_match(const void *p, const void *q)
 {
     const char *p1 = p;
@@ -842,11 +928,73 @@
 }
 
 
+static int
+meta_ignore(GNode *gn, const char *p)
+{
+    char fname[MAXPATHLEN];
+
+    if (p == NULL)
+	return TRUE;
+
+    if (*p == '/') {
+	cached_realpath(p, fname); /* clean it up */
+	if (Lst_ForEach(metaIgnorePaths, prefix_match, fname)) {
+#ifdef DEBUG_META_MODE
+	    if (DEBUG(META))
+		fprintf(debug_file, "meta_oodate: ignoring path: %s\n",
+			p);
+#endif
+	    return TRUE;
+	}
+    }
+
+    if (metaIgnorePatterns) {
+	char *pm;
+
+	Var_Set(".p.", p, gn, 0);
+	pm = Var_Subst(NULL,
+		       "${" MAKE_META_IGNORE_PATTERNS ":@m@${.p.:M$m}@}",
+		       gn, VARF_WANTRES);
+	if (*pm) {
+#ifdef DEBUG_META_MODE
+	    if (DEBUG(META))
+		fprintf(debug_file, "meta_oodate: ignoring pattern: %s\n",
+			p);
+#endif
+	    free(pm);
+	    return TRUE;
+	}
+	free(pm);
+    }
+
+    if (metaIgnoreFilter) {
+	char *fm;
+
+	/* skip if filter result is empty */
+	snprintf(fname, sizeof(fname),
+		 "${%s:L:${%s:ts:}}",
+		 p, MAKE_META_IGNORE_FILTER);
+	fm = Var_Subst(NULL, fname, gn, VARF_WANTRES);
+	if (*fm == '\0') {
+#ifdef DEBUG_META_MODE
+	    if (DEBUG(META))
+		fprintf(debug_file, "meta_oodate: ignoring filtered: %s\n",
+			p);
+#endif
+	    free(fm);
+	    return TRUE;
+	}
+	free(fm);
+    }
+    return FALSE;
+}
+
 /*
  * When running with 'meta' functionality, a target can be out-of-date
- * if any of the references in it's meta data file is more recent.
+ * if any of the references in its meta data file is more recent.
  * We have to track the latestdir on a per-process basis.
  */
+#define LCWD_VNAME_FMT ".meta.%d.lcwd"
 #define LDIR_VNAME_FMT ".meta.%d.ldir"
 
 /*
@@ -872,11 +1020,16 @@
 {
     static char *tmpdir = NULL;
     static char cwd[MAXPATHLEN];
+    char lcwd_vname[64];
     char ldir_vname[64];
+    char lcwd[MAXPATHLEN];
     char latestdir[MAXPATHLEN];
     char fname[MAXPATHLEN];
     char fname1[MAXPATHLEN];
     char fname2[MAXPATHLEN];
+    char fname3[MAXPATHLEN];
+    const char *dname;
+    const char *tname;
     char *p;
     char *cp;
     char *link_src;
@@ -886,10 +1039,23 @@
     FILE *fp;
     Boolean needOODATE = FALSE;
     Lst missingFiles;
-    
+    char *pa[4];			/* >= possible uses */
+    int i;
+    int have_filemon = FALSE;
+
     if (oodate)
 	return oodate;		/* we're done */
 
+    i = 0;
+
+    dname = Var_Value(".OBJDIR", gn, &pa[i++]);
+    tname = Var_Value(TARGET, gn, &pa[i++]);
+
+    /* if this succeeds fname3 is realpath of dname */
+    if (!meta_needed(gn, dname, fname3, FALSE))
+	goto oodate_out;
+    dname = fname3;
+
     missingFiles = Lst_Init(FALSE);
 
     /*
@@ -900,7 +1066,7 @@
      */
     Make_DoAllVar(gn);
 
-    meta_name(gn, fname, sizeof(fname), NULL, NULL);
+    meta_name(fname, sizeof(fname), dname, tname, dname);
 
 #ifdef DEBUG_META_MODE
     if (DEBUG(META))
@@ -913,7 +1079,6 @@
 	int lineno = 0;
 	int lastpid = 0;
 	int pid;
-	int f = 0;
 	int x;
 	LstNode ln;
 	struct stat fs;
@@ -928,6 +1093,8 @@
 		err(1, "Could not get current working directory");
 	    cwdlen = strlen(cwd);
 	}
+	strlcpy(lcwd, cwd, sizeof(lcwd));
+	strlcpy(latestdir, cwd, sizeof(latestdir));
 
 	if (!tmpdir) {
 	    tmpdir = getTmpdir();
@@ -950,13 +1117,13 @@
 	    link_src = NULL;
 	    move_target = NULL;
 	    /* Find the start of the build monitor section. */
-	    if (!f) {
+	    if (!have_filemon) {
 		if (strncmp(buf, "-- filemon", 10) == 0) {
-		    f = 1;
+		    have_filemon = TRUE;
 		    continue;
 		}
 		if (strncmp(buf, "# buildmon", 10) == 0) {
-		    f = 1;
+		    have_filemon = TRUE;
 		    continue;
 		}
 	    }		    
@@ -968,7 +1135,7 @@
 		fprintf(debug_file, "%s: %d: %s\n", fname, lineno, buf);
 #endif
 	    strsep(&p, " ");
-	    if (f) {
+	    if (have_filemon) {
 		/*
 		 * We are in the 'filemon' output section.
 		 * Each record from filemon follows the general form:
@@ -1011,18 +1178,23 @@
 			char *tp;
 		    
 			if (lastpid > 0) {
-			    /* We need to remember this. */
+			    /* We need to remember these. */
+			    Var_Set(lcwd_vname, lcwd, VAR_GLOBAL, 0);
 			    Var_Set(ldir_vname, latestdir, VAR_GLOBAL, 0);
 			}
+			snprintf(lcwd_vname, sizeof(lcwd_vname), LCWD_VNAME_FMT, pid);
 			snprintf(ldir_vname, sizeof(ldir_vname), LDIR_VNAME_FMT, pid);
 			lastpid = pid;
 			ldir = Var_Value(ldir_vname, VAR_GLOBAL, &tp);
 			if (ldir) {
 			    strlcpy(latestdir, ldir, sizeof(latestdir));
-			    if (tp)
-				free(tp);
-			} else 
-			    strlcpy(latestdir, cwd, sizeof(latestdir));
+			    free(tp);
+			}
+			ldir = Var_Value(lcwd_vname, VAR_GLOBAL, &tp);
+			if (ldir) {
+			    strlcpy(lcwd, ldir, sizeof(lcwd));
+			    free(tp);
+			}
 		    }
 		    /* Skip past the pid. */
 		    if (strsep(&p, " ") == NULL)
@@ -1029,7 +1201,9 @@
 			continue;
 #ifdef DEBUG_META_MODE
 		    if (DEBUG(META))
-			fprintf(debug_file, "%s: %d: cwd=%s ldir=%s\n", fname, lineno, cwd, latestdir);
+			    fprintf(debug_file, "%s: %d: %d: %c: cwd=%s lcwd=%s ldir=%s\n",
+				    fname, lineno,
+				    pid, buf[0], cwd, lcwd, latestdir);
 #endif
 		    break;
 		}
@@ -1039,6 +1213,7 @@
 		/* Process according to record type. */
 		switch (buf[0]) {
 		case 'X':		/* eXit */
+		    Var_Delete(lcwd_vname, VAR_GLOBAL);
 		    Var_Delete(ldir_vname, VAR_GLOBAL);
 		    lastpid = 0;	/* no need to save ldir_vname */
 		    break;
@@ -1050,15 +1225,30 @@
 
 			child = atoi(p);
 			if (child > 0) {
+			    snprintf(cldir, sizeof(cldir), LCWD_VNAME_FMT, child);
+			    Var_Set(cldir, lcwd, VAR_GLOBAL, 0);
 			    snprintf(cldir, sizeof(cldir), LDIR_VNAME_FMT, child);
 			    Var_Set(cldir, latestdir, VAR_GLOBAL, 0);
+#ifdef DEBUG_META_MODE
+			    if (DEBUG(META))
+				    fprintf(debug_file, "%s: %d: %d: cwd=%s lcwd=%s ldir=%s\n",
+					    fname, lineno,
+					    child, cwd, lcwd, latestdir);
+#endif
 			}
 		    }
 		    break;
 
 		case 'C':		/* Chdir */
-		    /* Update the latest directory. */
-		    strlcpy(latestdir, p, sizeof(latestdir));
+		    /* Update lcwd and latest directory. */
+		    strlcpy(latestdir, p, sizeof(latestdir));	
+		    strlcpy(lcwd, p, sizeof(lcwd));
+		    Var_Set(lcwd_vname, lcwd, VAR_GLOBAL, 0);
+		    Var_Set(ldir_vname, lcwd, VAR_GLOBAL, 0);
+#ifdef DEBUG_META_MODE
+		    if (DEBUG(META))
+			fprintf(debug_file, "%s: %d: cwd=%s ldir=%s\n", fname, lineno, cwd, lcwd);
+#endif
 		    break;
 
 		case 'M':		/* renaMe */
@@ -1080,12 +1270,19 @@
 		    /* FALLTHROUGH */
 		case 'D':		/* unlink */
 		    if (*p == '/' && !Lst_IsEmpty(missingFiles)) {
-			/* remove p from the missingFiles list if present */
-			if ((ln = Lst_Find(missingFiles, p, string_match)) != NULL) {
-			    char *tp = Lst_Datum(ln);
-			    Lst_Remove(missingFiles, ln);
-			    free(tp);
-			    ln = NULL;	/* we're done with it */
+			/* remove any missingFiles entries that match p */
+			if ((ln = Lst_Find(missingFiles, p,
+					   path_match)) != NULL) {
+			    LstNode nln;
+			    char *tp;
+
+			    do {
+				nln = Lst_FindFrom(missingFiles, Lst_Succ(ln),
+						   p, path_match);
+				tp = Lst_Datum(ln);
+				Lst_Remove(missingFiles, ln);
+				free(tp);
+			    } while ((ln = nln) != NULL);
 			}
 		    }
 		    if (buf[0] == 'M') {
@@ -1148,8 +1345,12 @@
 		    if ((strstr("tmp", p)))
 			break;
 
-		    if (stat(p, &fs) < 0) {
-			Lst_AtEnd(missingFiles, bmake_strdup(p));
+		    if ((link_src != NULL && cached_lstat(p, &fs) < 0) ||
+			(link_src == NULL && cached_stat(p, &fs) < 0)) {
+			if (!meta_ignore(gn, p)) {
+			    if (Lst_Find(missingFiles, p, string_match) == NULL)
+				Lst_AtEnd(missingFiles, bmake_strdup(p));
+			}
 		    }
 		    break;
 		check_link_src:
@@ -1167,26 +1368,9 @@
 		     * be part of the dependencies because
 		     * they are _expected_ to change.
 		     */
-		    if (*p == '/' &&
-			Lst_ForEach(metaIgnorePaths, prefix_match, p)) {
-#ifdef DEBUG_META_MODE
-			if (DEBUG(META))
-			    fprintf(debug_file, "meta_oodate: ignoring: %s\n",
-				    p);
-#endif
+		    if (meta_ignore(gn, p))
 			break;
-		    }
-
-		    if ((cp = strrchr(p, '/'))) {
-			cp++;
-			/*
-			 * We don't normally expect to see this,
-			 * but we do expect it to change.
-			 */
-			if (strcmp(cp, makeDependfile) == 0)
-			    break;
-		    }
-
+		    
 		    /*
 		     * The rest of the record is the file name.
 		     * Check if it's not an absolute path.
@@ -1207,11 +1391,16 @@
 			    snprintf(fname1, sizeof(fname1), "%s/%s", latestdir, p);
 			    sdirs[sdx++] = fname1;
 
-			    if (strcmp(latestdir, cwd) != 0) {
-				/* Check vs cwd */
-				snprintf(fname2, sizeof(fname2), "%s/%s", cwd, p);
+			    if (strcmp(latestdir, lcwd) != 0) {
+				/* Check vs lcwd */
+				snprintf(fname2, sizeof(fname2), "%s/%s", lcwd, p);
 				sdirs[sdx++] = fname2;
 			    }
+			    if (strcmp(lcwd, cwd) != 0) {
+				/* Check vs cwd */
+				snprintf(fname3, sizeof(fname3), "%s/%s", cwd, p);
+				sdirs[sdx++] = fname3;
+			    }
 			}
 			sdirs[sdx++] = NULL;
 
@@ -1220,7 +1409,7 @@
 			    if (DEBUG(META))
 				fprintf(debug_file, "%s: %d: looking for: %s\n", fname, lineno, *sdp);
 #endif
-			    if (stat(*sdp, &fs) == 0) {
+			    if (cached_stat(*sdp, &fs) == 0) {
 				found = 1;
 				p = *sdp;
 			    }
@@ -1237,7 +1426,7 @@
 				oodate = TRUE;
 			    } else if (S_ISDIR(fs.st_mode)) {
 				/* Update the latest directory. */
-				realpath(p, latestdir);
+				cached_realpath(p, latestdir);
 			    }
 			} else if (errno == ENOENT && *p == '/' &&
 				   strncmp(p, cwd, cwdlen) != 0) {
@@ -1245,11 +1434,14 @@
 			     * A referenced file outside of CWD is missing.
 			     * We cannot catch every eventuality here...
 			     */
-			    if (DEBUG(META))
-				fprintf(debug_file, "%s: %d: file '%s' may have moved?...\n", fname, lineno, p);
-			    oodate = TRUE;
+			    if (Lst_Find(missingFiles, p, string_match) == NULL)
+				    Lst_AtEnd(missingFiles, bmake_strdup(p));
 			}
 		    }
+		    if (buf[0] == 'E') {
+			/* previous latestdir is no longer relevant */
+			strlcpy(latestdir, lcwd, sizeof(latestdir));
+		    }
 		    break;
 		default:
 		    break;
@@ -1281,7 +1473,7 @@
 			if (DEBUG(META))
 			    fprintf(debug_file, "%s: %d: cannot compare command using .OODATE\n", fname, lineno);
 		    }
-		    cmd = Var_Subst(NULL, cmd, gn, TRUE);
+		    cmd = Var_Subst(NULL, cmd, gn, VARF_WANTRES|VARF_UNDEFERR);
 
 		    if ((cp = strchr(cmd, '\n'))) {
 			int n;
@@ -1343,15 +1535,33 @@
 		fprintf(debug_file, "%s: missing files: %s...\n",
 			fname, (char *)Lst_Datum(Lst_First(missingFiles)));
 	    oodate = TRUE;
-	    Lst_Destroy(missingFiles, (FreeProc *)free);
 	}
-    } else {
-	if ((gn->type & OP_META)) {
+	if (!oodate && !have_filemon && filemonMissing) {
 	    if (DEBUG(META))
-		fprintf(debug_file, "%s: required but missing\n", fname);
+		fprintf(debug_file, "%s: missing filemon data\n", fname);
 	    oodate = TRUE;
 	}
+    } else {
+	if (writeMeta && metaMissing) {
+	    cp = NULL;
+
+	    /* if target is in .CURDIR we do not need a meta file */
+	    if (gn->path && (cp = strrchr(gn->path, '/')) && cp > gn->path) {
+		if (strncmp(curdir, gn->path, (cp - gn->path)) != 0) {
+		    cp = NULL;		/* not in .CURDIR */
+		}
+	    }
+	    if (!cp) {
+		if (DEBUG(META))
+		    fprintf(debug_file, "%s: required but missing\n", fname);
+		oodate = TRUE;
+		needOODATE = TRUE;	/* assume the worst */
+	    }
+	}
     }
+
+    Lst_Destroy(missingFiles, (FreeProc *)free);
+
     if (oodate && needOODATE) {
 	/*
 	 * Target uses .OODATE which is empty; or we wouldn't be here.
@@ -1360,9 +1570,13 @@
 	 */
 	Var_Delete(OODATE, gn);
 	Var_Set(OODATE, Var_Value(ALLSRC, gn, &cp), gn, 0);
-	if (cp)
-	    free(cp);
+	free(cp);
     }
+
+ oodate_out:
+    for (i--; i >= 0; i--) {
+	free(pa[i]);
+    }
     return oodate;
 }
 
@@ -1388,8 +1602,8 @@
     if (pipe(childPipe) < 0)
 	Punt("Cannot create pipe: %s", strerror(errno));
     /* Set close-on-exec flag for both */
-    (void)fcntl(childPipe[0], F_SETFD, 1);
-    (void)fcntl(childPipe[1], F_SETFD, 1);
+    (void)fcntl(childPipe[0], F_SETFD, FD_CLOEXEC);
+    (void)fcntl(childPipe[1], F_SETFD, FD_CLOEXEC);
 }
 
 void
@@ -1414,6 +1628,7 @@
     while (fgets(buf, sizeof(buf), fp)) {
 	meta_job_output(NULL, buf, "");
 	printf("%s", buf);
+	fflush(stdout);
     }
     fclose(fp);
 }

Modified: vendor/NetBSD/bmake/dist/meta.h
===================================================================
--- vendor/NetBSD/bmake/dist/meta.h	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/meta.h	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,4 +1,4 @@
-/*      $NetBSD: meta.h,v 1.3 2013/03/23 05:31:29 sjg Exp $ */
+/*      $NetBSD: meta.h,v 1.5 2016/05/12 20:28:34 sjg Exp $ */
 
 /*
  * Things needed for 'meta' mode.
@@ -42,13 +42,14 @@
 
 struct Job;				/* not defined yet */
 void meta_init(void);
+void meta_finish(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);
 void meta_job_output(struct Job *, char *, const char *);
-void meta_cmd_finish(void *);
-void meta_job_finish(struct Job *);
+int  meta_cmd_finish(void *);
+int  meta_job_finish(struct Job *);
 Boolean meta_oodate(GNode *, Boolean);
 void meta_compat_start(void);
 void meta_compat_child(void);

Added: vendor/NetBSD/bmake/dist/metachar.c
===================================================================
--- vendor/NetBSD/bmake/dist/metachar.c	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/metachar.c	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,88 @@
+/*	$NetBSD: metachar.c,v 1.5 2015/06/19 08:03:35 mlelstv Exp $	*/
+
+/*-
+ * Copyright (c) 2015 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if HAVE_NBTOOL_CONFIG_H
+#include "nbtool_config.h"
+#endif
+
+#if defined(MAKE_NATIVE) || defined(HAVE_NBTOOL_CONFIG_H)
+#include <sys/cdefs.h>
+#endif
+
+#if defined(__RCSID) && !defined(lint)
+__RCSID("$NetBSD: metachar.c,v 1.5 2015/06/19 08:03:35 mlelstv Exp $");
+#endif
+
+#include "metachar.h"
+/*
+ * The following array is used to make a fast determination of which
+ * characters are interpreted specially by the shell.  If a command
+ * contains any of these characters, it is executed by the shell, not
+ * directly by us.
+ *
+ * perhaps move it to ctype?
+ */
+
+unsigned char _metachar[128] = {
+//    nul   soh   stx   etx   eot   enq   ack   bel
+	1,    0,    0,    0,    0,    0,    0,    0,
+//     bs    ht    nl    vt    np    cr    so    si
+	0,    0,    1,    0,	0,    0,    0,    0,
+//    dle   dc1   dc2   dc3   dc4   nak   syn   etb
+	0,    0,    0,    0,    0,    0,    0,    0,
+//    can    em   sub   esc    fs    gs    rs    us
+	0,    0,    0,    0,    0,    0,    0,    0,
+//     sp     !     "     #     $     %     &     '
+	0,    1,    1,    1,    1,    0,    1,    1,
+//      (     )     *     +     ,     -     .     /
+	1,    1,    1,    0,    0,    0,    0,    0,
+//      0     1     2     3     4     5     6     7
+	0,    0,    0,    0,    0,    0,    0,    0,
+//      8     9     :     ;     <     =     >     ?
+	0,    0,    0,    1,    1,    0,    1,    1,
+//      @     A     B     C     D     E     F     G
+	0,    0,    0,    0,    0,    0,    0,    0,
+//      H     I     J     K     L     M     N     O
+	0,    0,    0,    0,    0,    0,    0,    0,
+//      P     Q     R     S     T     U     V     W
+	0,    0,    0,    0,    0,    0,    0,    0,
+//      X     Y     Z     [     \     ]     ^     _
+	0,    0,    0,    1,    1,    1,    1,    0,
+//      `     a     b     c     d     e     f     g
+	1,    0,    0,    0,    0,    0,    0,    0,
+//      h     i     j     k     l     m     n     o
+	0,    0,    0,    0,    0,    0,    0,    0,
+//      p     q     r     s     t     u     v     w
+	0,    0,    0,    0,    0,    0,    0,    0,
+//      x     y     z     {     |     }     ~   del
+	0,    0,    0,    1,    1,    1,    1,    0,
+};
+

Added: vendor/NetBSD/bmake/dist/metachar.h
===================================================================
--- vendor/NetBSD/bmake/dist/metachar.h	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/metachar.h	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,61 @@
+/*	$NetBSD: metachar.h,v 1.4 2015/06/21 20:26:02 christos Exp $	*/
+
+/*-
+ * Copyright (c) 2015 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef _METACHAR_H
+#define _METACHAR_H
+
+#include <ctype.h>
+
+extern unsigned char _metachar[];
+
+#define ismeta(c)	_metachar[(c) & 0x7f]
+
+static inline int
+hasmeta(const char *cmd)
+{
+	while (!ismeta(*cmd))
+		cmd++;
+
+	return *cmd != '\0';
+}
+
+static inline int
+needshell(const char *cmd, int white)
+{
+	while (!ismeta(*cmd) && *cmd != ':' && *cmd != '=') {
+		if (white && isspace((unsigned char)*cmd))
+			break;
+		cmd++;
+	}
+
+	return *cmd != '\0';
+}
+
+#endif /* _METACHAR_H */

Modified: vendor/NetBSD/bmake/dist/mk/ChangeLog
===================================================================
--- vendor/NetBSD/bmake/dist/mk/ChangeLog	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/mk/ChangeLog	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,3 +1,551 @@
+2017-06-30  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* install-mk (MK_VERSION): 20170630
+
+	* meta.stage.mk: avoid triggering stage_* targets with nothing to do.
+
+2017-05-23  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* meta2deps.py: take special care of '..'
+
+2017-05-15  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* install-mk (MK_VERSION): 20170515
+
+	* dirdeps.mk (DEP_EXPORT_VARS): on rare occasions it is
+	useful/necessary for a Makefile.depend file to export some knobs.
+	This is complicated when we are doing DIRDEPS_CACHE, so we will
+	handle export of any variables listed in DEP_EXPORT_VARS.
+
+2017-05-08  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* install-mk (MK_VERSION): 20170505
+
+	* meta2deps.py: fix botched indenation.
+
+2017-05-05  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* sys/*.mk: Remove setting of MAKE it is unnecessary and
+	  in many cases wrong (basname rather than full path)
+
+	* scripts.mk (SCRIPTSGROUPS): make this more like files.mk and inc.mk
+
+	* init.mk: define realbuild to simplify logic in {lib,prog}.mk etc
+
+2017-05-01  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* install-mk (MK_VERSION): 20170501
+
+	* doc.mk: fix typo in DOC_INSTALL_OWN
+
+	* inc.mk: handle INCGROUPS similar to freebsd
+
+	* files.mk: add something for files too
+
+	* add staging logic to lib.mk prog.mk etc.
+
+2017-04-24  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* install-mk (MK_VERSION): 20170424
+
+	* dirdeps.mk: set NO_DIRDEPS when bootstrapping.
+	  also target of bootstrap-this when sed is needed should be ${_want:T}
+
+2017-04-18  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* install-mk (MK_VERSION): 20170418
+
+	* auto.obj.mk: if using MAKEOBJDIRPREFIX check if it is a
+	  prefix match for .CURDIR - in which case .CURDIR *is* __objdir.
+
+2017-04-01  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* install-mk (MK_VERSION): 20170401
+
+	* meta2deps.py: add is_src so we can check if obj dependency
+	  is also a src dependency.
+
+2017-03-26  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* install-mk (MK_VERSION): 20170326
+
+	* meta.stage.mk: do nothing if NO_STAGING is defined.
+
+2017-03-24  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* auto.obj.mk: handle the case of __objdir=obj or obj.${MACHINE} etc.
+
+2017-03-18  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* mkopt.sh: treat WITH_*=NO like no; ie. WITHOUT_*
+
+2017-03-01  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* install-mk (MK_VERSION): 20170301
+
+	* dirdeps.mk (_build_all_dirs): update this outside test for empty
+	  DIRDEPS.
+
+	* meta.stage.mk: allow multiple inclusion to the extent it makes
+	  sense.
+
+2017-02-14  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* prog.mk (install_links): depends on realinstall
+
+2017-02-12  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* install-mk (MK_VERSION): 20170212
+
+	* dpadd.mk: avoid applying :T:R twice to DPLIBS entries
+
+2017-01-30  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* install-mk (MK_VERSION): 20170130
+
+	* dirdeps.mk: use :range if we can.
+
+	* sys.vars.mk: provide M_cmpv if MAKE_VERSION >= 20170130
+
+	* meta2deps.py: clean paths without using realpath() where possible.
+	  fix sort_unique.
+
+2016-12-12  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* install-mk (MK_VERSION): 20161212
+	
+	* meta2deps.py: set pid_cwd[pid] when we process 'C'hdir, 
+	rather than when we detect pid change.
+
+2016-12-07  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* install-mk (MK_VERSION): 20161207
+
+	* meta.stage.mk: add stage_as_and_symlink for staging packages.
+	  We build foo.tgz stage_as foo-${VERSION}.tgz but want to be able
+	  to use foo.tgz to reference the latest staged version - so we
+	  make foo.tgz a symlink to it.
+	  Using a target to do both operations ensures we stay in sync.
+	
+2016-11-26  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* install-mk (MK_VERSION): 20161126
+
+	* dirdeps.mk: set DIRDEPS_CACHE before we include local.dirdeps.mk
+	  so it can add dependencies.
+
+2016-10-10  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* dirdeps.mk: set DEP_* before we expand .MAKE.DEPENDFILE_PREFERENCE
+	  do that they can influence the result correctly.
+
+	* dirdeps.mk (${DIRDEPS_CACHE}): make sure we pass on TARGET_SPEC
+
+	* dirdeps.mk: Add ONLY_TARGET_SPEC_LIST and NOT_TARGET_SPEC_LIST
+	  similar to ONLY_MACHINE_LIST and NOT_MACHINE_LIST
+
+2016-10-05  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* dirdeps.mk: remove dependence on jot (normal situations anyway).
+	  Before we read another Makefile.depend* set DEP_* vars from
+	  _DEP_TARGET_SPEC in case it uses any of them with :=
+	  When bootstrapping, trim any ,* from extention of chosen _src
+	  Makefile.depend* to get the machine value we subst for.
+
+2016-09-30  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* dirdeps.mk: use TARGET_SPEC_VARS to qualify components added to
+	  DEP_SKIP_DIR and DEP_DIRDEPS_FILTER
+
+	* sys.mk: extract some bits to sys.{debug,vars}.mk
+	  for easier re-use by others.
+
+2016-09-23  Simon Gerraty  <sjg at sjg-mba13>
+
+	* lib.mk: Use ${PICO} for extension for PIC objects.
+	  default to .pico (like NetBSD) safe on case insensitive filesystem.
+
+2016-08-19  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* meta.sys.mk (META_COOKIE_TOUCH): use ${.OBJDIR}/${.TARGET:T} as default
+
+2016-08-15  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* install-mk (MK_VERSION): 20160815
+
+	* dirdeps.mk (.MAKE.META.IGNORE_FILTER): set filter to only
+	consider Makefile.depend* when checking if DIRDEPS_CACHE is up-to-date.
+
+2016-08-13  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* meta.sys.mk (.MAKE.META.IGNORE_PATHS): 
+	  in meta mode we can ignore the mtime of makefiles
+
+2016-08-02  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* install-mk (MK_VERSION): 20160802
+	
+	* lib.mk (libinstall): depends on beforinstall
+
+	* prog.mk (proginstall): depends on beforinstall
+	  patch from Lauri Tirkkonen
+	
+	* dirdeps.mk (bootstrap): When bootstrapping; creat
+	.MAKE.DEPENDFILE_DEFAULT and allow additional filtering via
+	.MAKE.DEPENDFILE_BOOTSTRAP_SED
+
+	* dirdeps.mk: move some comments to where they make sense.
+
+2016-07-27  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* dirdeps.mk (DIRDEPS_CACHE): no dirname.
+
+2016-06-02  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* install-mk (MK_VERSION): 20160602
+	* meta.autodep.mk: when passing META_FILES to gendirdeps.mk
+	  do not apply :T to META_XTRAS
+	  patch from Bryan Drewery at FreeBSD.org.
+
+2016-05-30  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* install-mk (MK_VERSION): 20160530
+	* meta.stage.mk: we assume ${CLEANFILES} gets .NOPATH
+	  make it so.
+	
+2016-05-12  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* install-mk (MK_VERSION): 20160512
+
+	* dpadd.mk: always include local.dpadd.mk if it exists
+	  remove some things that better belong in local.dpadd.mk
+	  skip INCLUDES_* for staged libs unless SRC_* defined.
+
+	* own.mk: add INCLUDEDIR
+	
+2016-04-18  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* dirdeps.mk: when doing -f dirdeps.mk if target suppies no
+	  TARGET_MACHINE - :E will be empty or match part of path, use
+	  ${MACHINE}
+
+2016-04-07  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* meta.autodep.mk: issue a warning if UPDATE_DEPENDFILE=NO due to
+	  NO_FILEMON_COOKIE  
+
+	* dirdeps.mk: move the logic that allows for 
+	  make -f dirdeps.mk some/dir.${TARGET_SPEC}
+	  inside the check for !target(_DIRDEP_USE)
+
+2016-04-04  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* Use <> when including local*.mk and others which may exist
+	  elsewhere so that user can better control what they get.
+	
+	* meta.autodep.mk (NO_FILEMON_COOKIE): 
+	  create a cookie if we ever build dir with nofilemon
+	  so that UPDATE_DEPENDFILE will be forced to NO until cleaned.
+
+2016-04-01  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* install-mk (MK_VERSION): 20160401
+	
+	* meta2deps.py: fix old print statement when debugging.
+
+	* gendirdeps.mk: META2DEPS_CMD append M2D_EXCLUDES with -X
+	  patch from Bryan Drewery
+
+2016-03-22  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* install-mk (MK_VERSION): 20160317 (St. Pats)
+	
+	* warnings.mk: g++ does not like -Wimplicit
+	
+	* sys.mk sys/*.mk lib.mk prog.mk: use CXX_SUFFIXES to handle the
+	  pelthora of common suffixes for C++
+	
+	* lib.mk: use .So for shared objects
+
+2016-03-15  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* install-mk (MK_VERSION): 20160315
+
+	* meta.stage.mk (LN_CP_SCRIPT): do not ln(1) if we have to chmod(1)
+	  normally only applies to scripts.
+	
+	* dirdeps.mk: NO_DIRDEPS_BELOW to supress DIRDEPS below RELDIR as
+	  well as outside it. 
+
+2016-03-10  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* install-mk (MK_VERSION): 20160310
+
+	* dirdeps.mk: use targets rather than a list to track DIRDEPS that
+	  we have processed; the list gets very inefficient as number of
+	  DIRDEPS gets large.
+
+	* sys.dependfile.mk: fix comment wrt MACHINE
+
+	* meta.autodep.mk: ignore staged DPADDs when bootstrapping.
+	  patch from Bryan Drewery
+
+2016-03-02  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* meta2deps.sh: don't ignore subdirs.
+	  patch from Bryan Drewery
+
+2016-02-26  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* install-mk (MK_VERSION): 20160226
+
+	* gendirdeps.mk: mark _DEPENDFILE .NOMETA
+
+2016-02-20  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* dirdeps.mk: we shouldn't normally include .depend but if we do
+	  use .dinclude if we can.
+
+2016-02-18  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* install-mk (MK_VERSION): 20160218
+	* sys.clean-env.mk: with recent change to Var_Subst()
+	  we cannot use the '$$' trick, but .export-literal does the job
+	  we need.
+	* auto.dep.mk: make use .dinclude if we can.
+	
+
+2016-02-05  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* dirdeps.mk: 
+	  Add _build_all_dirs such that local.dirdeps.mk can
+	  add fully qualified dirs to it.
+	  These will be built normally but the current 
+	  DEP_RELDIR will not depend on then (to avoid cycles).
+	  This makes it easy to hook things like unit-tests into build.
+	
+
+2016-01-21  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* dirdeps.mk: add bootstrap-empty
+
+2015-12-12  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* install-mk (MK_VERSION): 20151212
+	* auto.obj.mk: do not require MAKEOBJDIRPREFIX to exist.
+	  only apply :tA to __objdir when comparing to .OBJDIR
+
+2015-11-14  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* install-mk (MK_VERSION): 20151111
+
+	* meta.sys.mk: include sys.dependfile.mk
+
+	* sys.mk (OPTIONS_DEFAULT_NO): use options.mk
+	  to set MK_AUTO_OBJ and MK_DIRDEPS_BUILD
+	  include local.sys.env.mk early
+	  include local.sys.mk later
+	
+	* own.mk (OPTIONS_DEFAULT_NO): AUTO_OBJ etc moved to sys.mk
+
+2015-11-13  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* meta.sys.mk (META_COOKIE_TOUCH):
+	  add ${META_COOKIE_TOUCH} to the end of scripts to touch cookie
+
+	* meta.stage.mk: stage_libs should ignore SYMLINKS.
+
+2015-10-23  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* install-mk (MK_VERSION): 20151022
+
+	* sys.mk: BSD/OS does not have 'type' as a shell builtin.
+
+2015-10-20  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* install-mk (MK_VERSION): 20151020
+	
+	* dirdeps.mk: Add logic for 
+	  make -f dirdeps.mk some/dir.${TARGET_SPEC}
+
+2015-10-14  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* install-mk (MK_VERSION): 20151010
+
+2015-10-02  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* meta.stage.mk: use staging: ${STAGE_TARGETS:...
+	  to have stage_lins run last in non-jobs mode.
+	  Use .ORDER only for jobs mode.
+
+2015-09-02  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* rst2htm.mk: allow for per target flags etc.
+
+2015-09-01  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* install-mk (MK_VERSION): 20150901
+
+	* doc.mk: create dir if needed use DOC_INSTALL_OWN
+
+2015-06-15  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* install-mk (MK_VERSION): 20150615
+	
+	* auto.obj.mk: allow use of MAKEOBJDIRPREFIX too.
+	  Follow make's normal precedence rules.
+	
+	* gendirdeps.mk: allow customization of the header.
+	  eg. for FreeBSD: 
+	  GENDIRDEPS_HEADER= echo '\# ${FreeBSD:L:@v@$$$v$$ @:M*F*}';
+
+	* meta.autodep.mk: ignore dirdeps.cache*
+	
+	* meta.stage.mk: when bootstrapping options it can be handy to
+	  throw warnings rather than errors for staging conflicts.
+
+	* meta.sys.mk: include local.meta.sys.mk for customization
+
+2015-06-06  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* install-mk (MK_VERSION): 20150606
+	
+	* dirdeps.mk: don't rely on manually maintained Makefile.depend
+	  to set DEP_RELDIR and reset DIRDEPS.
+	  By setting DEP_RELDIR ourselves we can skip :tA
+	
+	* gendirdeps.mk: skip setting DEP_RELDIR.
+
+2015-05-24  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* dirdeps.mk: avoid wildcards like make(bootstrap*)
+
+2015-05-20  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* install-mk (MK_VERSION): 20150520
+
+	* dirdeps.mk: when we are building dirdeps cache file we *want*
+	  meta_oodate to look at all the Makefile.depend files, so
+	  set .MAKE.DEPENDFILE to something that won't match.
+
+	* meta.stage.mk: for STAGE_AS_* basename of file may not be unique
+	  so first use absolute path as key.
+	  Also skip staging at level 0. 
+
+2015-04-30  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* install-mk (MK_VERSION): 20150430
+	
+	* dirdeps.mk: fix _count_dirdeps for non-cache case.
+
+2015-04-16  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* install-mk (MK_VERSION): 20150411
+	  bump version
+	
+	* own.mk: put AUTO_OBJ in OPTIONS_DEFAULT_NO rather than YES.
+	  it is here mainly for documentation purposes, since
+	  if using auto.obj.mk it is better done via sys.mk
+
+2015-04-01  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* install-mk (MK_VERSION): 20150401
+	
+	* meta2deps.sh: support @list
+	
+	* meta2deps.py: updates from Juniper
+	  o add EXCLUDES 
+	  o skip bogus input files.
+	  o treat 'M' and 'L' as both an 'R' and a 'W'
+
+2015-03-03  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* install-mk (MK_VERSION): 20150303
+	
+	* dirdeps.mk: if MK_DIRDEPS_CACHE is yes, use dirdeps-cache
+	  which is built via sub-make so we have a .meta file to tell if
+	  it is out-of-date. 
+	  The dirdeps-cache contains the same dependency rules that we
+	  normaly construct on the fly.
+	  This adds a few seconds overhead when the cache is out of date,
+	  but for a large target, the savings can be significant (10-20min).
+
+2014-11-18  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* install-mk (MK_VERSION): 20141118
+	
+	* meta.stage.mk: add stale_staged
+	
+	* dirdeps.mk (_DIRDEP_USE_LEVEL): allow this to be tweaked
+	  only useful under very rare conditions such as
+	  FreeBSD's make universe.
+
+	* auto.obj.mk: Allow MK_AUTO_OBJ to set MKOBJDIRS=auto
+	
+2014-11-11  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* install-mk (MK_VERSION): 20141111
+
+	* mkopt.sh: use consistent semantics for _mk_opt and _mk_opts
+
+2014-11-09  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* FILES: include mkopt.sh which allows handling options in shell
+	  scripts in a manner compatible with options.mk
+
+2014-10-12  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* meta.stage.mk: ensure only _STAGED_DIRS under objroot are used
+	  for GENDIRDEPS_FILTER to avoid surprises.
+
+2014-10-10  Simon J. Gerraty  <sjg at bad.crufty.net>
+	
+	* dirdeps.mk (NSkipHostDir): this needs SRCTOP prepended since by
+	  the time it is applied to __depdirs they have.
+	
+	* dirdeps.mk fix filtering of _machines since M_dep_qual_fixes
+	  expects patterns like *.${MACHINE}
+	
+	* cython.mk (pyprefix?): use pyprefix to find python bits
+	  since prefix might be something else (where we install our
+	  stuff)
+	
+2014-09-11  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* install-mk (MK_VERSION): 20140911
+	
+	* dirdeps.mk: add bootstrap target to simplify adding support for
+	  new MACHINE.
+	
+2014-09-01  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* gendirdeps.mk: Add handling of GENDIRDEPS_FILTER_DIR_VARS and
+	  GENDIRDEPS_FILTER_VARS to make it easier to produce sharable
+	  Makefile.depend files.
+
+2014-08-28  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* install-mk (MK_VERSION): 20140828
+	
+	* cython.mk: capture logic for building python extension modules
+	  with Cython.
+
+2014-08-08  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* meta.stage.mk (_STAGE_AS_BASENAME_USE): Add StageAs variant
+
+2014-08-02  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* install-mk (MK_VERSION): 20140801
+
+	* dep.mk: use explicit MKDEP_MK rather than overload MKDEP to
+	identify the autodep.mk variant. 
+	
+	* sys.dependfile.mk: delete .MAKE.DEPENDFILE if its
+	initial value does not match .MAKE.DEPENDFILE_PREFIX
+
+	* meta.autodep.mk: if _bootstrap_dirdeps add RELDIR to DIRDEPS
+
 2014-05-22  Simon J. Gerraty  <sjg at bad.crufty.net>
 
 	* install-mk (MK_VERSION): 20140522
@@ -275,7 +823,7 @@
 	  needed.
 	* gendirdeps.mk: only produce unqualified deps if no
 	  .MAKE.DEPENDFILE_PREFERENCE ends in .${MACHINE}
-	* meta.subdir.mk: apply SUBDIREPS_FILTER
+	* meta.subdir.mk: apply SUBDIRDEPS_FILTER
 	
 2012-04-20  Simon J. Gerraty  <sjg at bad.crufty.net>
 

Modified: vendor/NetBSD/bmake/dist/mk/FILES
===================================================================
--- vendor/NetBSD/bmake/dist/mk/FILES	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/mk/FILES	2018-06-27 00:17:22 UTC (rev 11138)
@@ -5,9 +5,11 @@
 autoconf.mk
 autodep.mk
 auto.dep.mk
+cython.mk
 dep.mk
 doc.mk
 dpadd.mk
+files.mk
 final.mk
 host-target.mk
 host.libnames.mk
@@ -20,7 +22,9 @@
 libs.mk
 links.mk
 man.mk
+manifest.mk
 mk-files.txt
+mkopt.sh
 nls.mk
 obj.mk
 options.mk
@@ -35,7 +39,9 @@
 subdir.mk
 sys.mk
 sys.clean-env.mk
+sys.debug.mk
 sys.dependfile.mk
+sys.vars.mk
 sys/AIX.mk
 sys/Darwin.mk
 sys/Generic.mk
@@ -49,6 +55,7 @@
 sys/UnixWare.mk
 target-flags.mk
 warnings.mk
+whats.mk
 yacc.mk
 dirdeps.mk
 gendirdeps.mk

Modified: vendor/NetBSD/bmake/dist/mk/auto.dep.mk
===================================================================
--- vendor/NetBSD/bmake/dist/mk/auto.dep.mk	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/mk/auto.dep.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,6 +1,6 @@
 #
 # RCSid:
-#	$Id: auto.dep.mk,v 1.2 2010/04/19 17:37:19 sjg Exp $
+#	$Id: auto.dep.mk,v 1.5 2016/04/05 15:58:37 sjg Exp $
 #
 #	@(#) Copyright (c) 2010, Simon J. Gerraty
 #
@@ -18,7 +18,7 @@
 # This module provides automagic dependency generation along the
 # lines suggested in the GNU make.info
 
-# set MKDEP=auto.dep and dep.mk will include us
+# set MKDEP_MK=auto.dep.mk and dep.mk will include us
 
 # This version differs from autodep.mk, in that 
 # we use ${.TARGET:T}.d rather than ${.TARGET:T:R}.d
@@ -45,6 +45,7 @@
 
 CLEANFILES += .depend ${.MAKE.DEPENDFILE} *.d
 
+.if ${MAKE_VERSION} < 20160218
 # skip generating dependfile for misc targets
 .if ${.TARGETS:Uall:M*all} != ""
 .END:	${.MAKE.DEPENDFILE}
@@ -60,5 +61,14 @@
 	- at for f in ${.ALLSRC:M*o:T:O:u:%=%.d}; do \
 		echo ".-include \"$$f\""; \
 	done > $@
+.else
+# we have .dinclude
+.if empty(_SKIP_BUILD)
+_all_objs = ${OBJS} ${POBJS} ${SOBJS}
+.for d in ${_all_objs:M*o:T:O:u:%=%.d}
+.dinclude <$d>
+.endfor
+.endif
 
 .endif
+.endif

Modified: vendor/NetBSD/bmake/dist/mk/auto.obj.mk
===================================================================
--- vendor/NetBSD/bmake/dist/mk/auto.obj.mk	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/mk/auto.obj.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,4 +1,4 @@
-# $Id: auto.obj.mk,v 1.8 2011/08/08 17:35:20 sjg Exp $
+# $Id: auto.obj.mk,v 1.14 2017/04/18 23:53:18 sjg Exp $
 #
 #	@(#) Copyright (c) 2004, Simon J. Gerraty
 #
@@ -34,11 +34,22 @@
 # if MKOBJDIRS is set to auto (and NOOBJ isn't defined) do some magic...
 # This will automatically create objdirs as needed.
 # Skip it if we are just doing 'clean'.
+.if ${MK_AUTO_OBJ:Uno} == "yes"
+MKOBJDIRS= auto
+.endif
 .if !defined(NOOBJ) && !defined(NO_OBJ) && ${MKOBJDIRS:Uno} == auto
 # Use __objdir here so it is easier to tweak without impacting
 # the logic.
-__objdir?= ${MAKEOBJDIR}
-.if ${.OBJDIR} != ${__objdir}
+.if !empty(MAKEOBJDIRPREFIX)
+.if ${.CURDIR:M${MAKEOBJDIRPREFIX}/*} != ""
+# we are already in obj tree!
+__objdir?= ${.CURDIR}
+.endif
+__objdir?= ${MAKEOBJDIRPREFIX}${.CURDIR}
+.endif
+__objdir?= ${MAKEOBJDIR:Uobj}
+__objdir:= ${__objdir}
+.if ${.OBJDIR:tA} != ${__objdir:tA}
 # We need to chdir, make the directory if needed
 .if !exists(${__objdir}/) && \
 	(${.TARGETS} == "" || ${.TARGETS:Nclean*:N*clean:Ndestroy*} != "")
@@ -49,8 +60,11 @@
 .endif
 # This causes make to use the specified directory as .OBJDIR
 .OBJDIR: ${__objdir}
-.if ${.OBJDIR} != ${__objdir} && ${__objdir_made:Uno:M${__objdir}/*} != ""
-.error could not use ${__objdir}
+.if ${.OBJDIR:tA} != ${__objdir:tA} && ${__objdir_made:Uno:M${__objdir}/*} != ""
+# watch out for __objdir being relative path
+.if !(${__objdir:M/*} == "" && ${.OBJDIR:tA} == ${${.CURDIR}/${__objdir}:L:tA})
+.error could not use ${__objdir}: .OBJDIR=${.OBJDIR}
 .endif
 .endif
 .endif
+.endif

Modified: vendor/NetBSD/bmake/dist/mk/autodep.mk
===================================================================
--- vendor/NetBSD/bmake/dist/mk/autodep.mk	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/mk/autodep.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,6 +1,6 @@
 #
 # RCSid:
-#	$Id: autodep.mk,v 1.33 2014/04/05 22:56:54 sjg Exp $
+#	$Id: autodep.mk,v 1.36 2016/04/05 15:58:37 sjg Exp $
 #
 #	@(#) Copyright (c) 1999-2010, Simon J. Gerraty
 #
@@ -19,18 +19,17 @@
 # The depend target is mainly for backwards compatibility,
 # dependencies are normally updated as part of compilation.
 
-# set MKDEP=autodep and dep.mk will include us
 .if !target(__${.PARSEFILE}__)
 __${.PARSEFILE}__:
 
-# different versions of bsd.dep.mk use these
-MKDEP=autodep
-MKDEPCMD=autodep
-
 DEPENDFILE?= .depend
 .for d in ${DEPENDFILE:N.depend}
 # bmake only groks .depend
-.-include "$d"
+.if ${MAKE_VERSION} < 20160218
+.-include <$d>
+.else
+.dinclude <$d>
+.endif
 .endfor
 
 # it does nothing if SRCS is not defined or is empty
@@ -80,6 +79,9 @@
 CC_MD?=${CC}
 CXX_MD?=${CXX}
 
+# should have been set by sys.mk
+CXX_SUFFIXES?= .cc .cpp .cxx .C
+
 # so we can do an explicit make depend, but not otherwise
 .if make(depend)
 .SUFFIXES:	.d
@@ -105,7 +107,7 @@
 	@echo updating dependencies for $<
 	@${SHELL} -ec "${CC_MD} -M ${CPPFLAGS_MD} ${AINC} $< | sed '/:/s/^/$@ /' > $@" || { ${RM} -f $@; false; }
 
-.cc.d .cpp.d .C.d .cxx.d:
+${CXX_SUFFIXES:%=%.d}:
 	@echo updating dependencies for $<
 	@${SHELL} -ec "${CXX_MD} -M ${CXXFLAGS_MD} $< | sed '/:/s/^/$@ /' > $@" || { ${RM} -f $@; false; }
 .else
@@ -125,7 +127,7 @@
 .s.d .S.d:
 	${CC_MD} ${CFLAGS_MD:S/D//} ${CPPFLAGS_MD} ${AINC} $< > $@ || { ${RM} -f $@; false; }
 
-.cc.d .cpp.d .C.d .cxx.d:
+${CXX_SUFFIXES:%=%.d}:
 	${CXX_MD} ${CFLAGS_MD:S/D//} ${CXXFLAGS_MD} $< > $@ || { ${RM} -f $@; false; }
 .endif
 

Added: vendor/NetBSD/bmake/dist/mk/cython.mk
===================================================================
--- vendor/NetBSD/bmake/dist/mk/cython.mk	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/mk/cython.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,96 @@
+# RCSid:
+#	$Id: cython.mk,v 1.6 2014/10/15 06:23:51 sjg Exp $
+#
+#	@(#) Copyright (c) 2014, Simon J. Gerraty
+#
+#	This file is provided in the hope that it will
+#	be of use.  There is absolutely NO WARRANTY.
+#	Permission to copy, redistribute or otherwise
+#	use this file is hereby granted provided that 
+#	the above copyright notice and this notice are
+#	left intact. 
+#      
+#	Please send copies of changes and bug-fixes to:
+#	sjg at crufty.net
+#
+
+# this is what we build
+CYTHON_MODULE = ${CYTHON_MODULE_NAME}${CYTHON_PYVERSION}.so
+
+CYTHON_MODULE_NAME?= it
+CYTHON_SRCS?= ${CYTHON_MODULE_NAME}.pyx
+
+# this is where we save generated src
+CYTHON_SAVEGENDIR?= ${.CURDIR}/gen
+
+# pyprefix is where python bits are
+# which may not be where we want to put ours (prefix)
+.if exists(/usr/pkg/include)
+pyprefix?= /usr/pkg
+.endif
+pyprefix?= /usr/local
+
+PYTHON_VERSION?= 2.7
+PYTHON_H?= ${pyprefix}/include/python${PYTHON_VERSION}/Python.h
+PYVERSION:= ${PYTHON_VERSION:C,\..*,,}
+
+# set this empty if you don't want to handle multiple versions
+.if !defined(CYTHON_PYVERSION)
+CYTHON_PYVERSION:= ${PYVERSION}
+.endif
+
+CFLAGS+= -I${PYTHON_H:H}
+
+CYTHON_GENSRCS= ${CYTHON_SRCS:R:S,$,${CYTHON_PYVERSION}.c,}
+SRCS+= ${CYTHON_GENSRCS}
+
+.SUFFIXES: .pyx .c .So
+
+CYTHON?= ${pyprefix}/bin/cython
+
+# if we don't have cython we can use pre-generated srcs
+.if ${type ${CYTHON} 2> /dev/null || echo:L:sh:M/*} == ""
+.PATH: ${CYTHON_SAVEGENDIR}
+.else
+
+.if !empty(CYTHON_PYVERSION)
+.for c in ${CYTHON_SRCS}
+${c:R}${CYTHON_PYVERSION}.${c:E}: $c
+	ln -sf ${.ALLSRC:M*pyx} ${.TARGET}
+.endfor
+.endif
+
+.pyx.c:
+	${CYTHON} ${CYTHON_FLAGS} -${PYVERSION} -o ${.TARGET} ${.IMPSRC}
+
+
+save-gen: ${CYTHON_GENSRCS}
+	mkdir -p ${CYTHON_SAVEGENDIR}
+	cp -p ${.ALLSRC} ${CYTHON_SAVEGENDIR}
+
+.endif
+
+COMPILE.c?= ${CC} -c ${CFLAGS}
+
+.c.So:
+	${COMPILE.c} ${PICFLAG} ${CC_PIC} ${.IMPSRC} -o ${.TARGET}
+
+${CYTHON_MODULE}: ${SRCS:S,.c,.So,}
+	${CC} ${CC_SHARED:U-shared} -o ${.TARGET} ${.ALLSRC:M*.So} ${LDADD}
+
+# conf.host_target() is limited to uname -m rather than uname -p
+_HOST_MACHINE!= uname -m
+.if ${HOST_TARGET:M*${_HOST_MACHINE}} == ""
+PY_HOST_TARGET:= ${HOST_TARGET:S,${_HOST_ARCH:U${uname -p:L:sh}}$,${_HOST_MACHINE},}
+.endif
+
+MODULE_BINDIR?= ${.CURDIR:H}/${PY_HOST_TARGET:U${HOST_TARGET}}
+
+build-cython-module: ${CYTHON_MODULE}
+
+install-cython-module: ${CYTHON_MODULE}
+	test -d ${DESTDIR}${MODULE_BINDIR} || \
+	${INSTALL} -d ${DESTDIR}${MODULE_BINDIR}
+	${INSTALL} -m 755 ${.ALLSRC} ${DESTDIR}${MODULE_BINDIR}
+
+CLEANFILES+= *.So ${CYTHON_MODULE}

Modified: vendor/NetBSD/bmake/dist/mk/dep.mk
===================================================================
--- vendor/NetBSD/bmake/dist/mk/dep.mk	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/mk/dep.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,4 +1,4 @@
-# $Id: dep.mk,v 1.16 2012/11/11 22:37:02 sjg Exp $
+# $Id: dep.mk,v 1.17 2014/08/04 05:12:27 sjg Exp $
 
 .if !target(__${.PARSEFILE}__)
 __${.PARSEFILE}__:
@@ -34,21 +34,15 @@
 
 .NOPATH:	.depend
 
-.if ${MKDEP} == "auto.dep" && make(depend)
+.if ${MKDEP_MK:Uno} == "auto.dep.mk" && make(depend)
 # auto.dep.mk does not "do" depend
 MK_AUTODEP= no
 .endif
 
 .if ${MK_AUTODEP} == yes
-.if ${MKDEP:T:S,auto,,} != ${MKDEP:T}
-.include <${MKDEP}.mk>
+MKDEP_MK ?= autodep.mk
+.include <${MKDEP_MK}>
 .else
-.include <autodep.mk>
-.endif
-.else
-.if ${MKDEP:T:S,auto,,} != ${MKDEP:T}
-MKDEP = ${MKDEP_CMD}
-.endif
 MKDEP_ENV_VARS += CC CXX
 .for v in ${MKDEP_ENV_VARS:O:u}
 .if !empty($v)

Modified: vendor/NetBSD/bmake/dist/mk/dirdeps.mk
===================================================================
--- vendor/NetBSD/bmake/dist/mk/dirdeps.mk	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/mk/dirdeps.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,4 +1,4 @@
-# $Id: dirdeps.mk,v 1.35 2014/05/03 06:27:56 sjg Exp $
+# $Id: dirdeps.mk,v 1.89 2017/05/17 17:41:47 sjg Exp $
 
 # Copyright (c) 2010-2013, Juniper Networks, Inc.
 # All rights reserved.
@@ -56,9 +56,12 @@
 #	.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
-#	since each Makefile.depend file includes dirdeps.mk, this
+#	Before each Makefile.depend file is read, we set 
+#	DEP_RELDIR to be the RELDIR (path relative to SRCTOP) for
+#	its directory, and DEP_MACHINE etc according to the .<target_spec>
+#	represented by the suffix of the corresponding target.
+#	
+#	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).
 #
@@ -110,21 +113,78 @@
 #		# as we may need it to find Makefile.depend*
 #		TARGET_SPEC = ${TARGET_SPEC_VARS:@v@${$v:U}@:ts,}
 #	
+#	The following variables can influence the initial DIRDEPS
+#	computation with regard to the TARGET_SPECs that will be
+#	built.
+#	Most should also be considered by init.mk
+#	
+#	ONLY_TARGET_SPEC_LIST
+#		Defines a list of TARGET_SPECs for which the current
+#		directory can be built.
+#		If ALL_MACHINES is defined, we build for all the
+#		TARGET_SPECs listed.
+#
+#	ONLY_MACHINE_LIST
+#		As for ONLY_TARGET_SPEC_LIST but only specifies
+#		MACHINEs.
+#
+#	NOT_TARGET_SPEC_LIST
+#		A list of TARGET_SPECs for which the current
+#		directory should not be built.
+#
+#	NOT_MACHINE_LIST
+#		A list of MACHINEs the current directory should not be
+#		built for.
+#
 
-.if ${.MAKE.LEVEL} == 0
+.if !target(bootstrap) && (make(bootstrap) || \
+	make(bootstrap-this) || \
+	make(bootstrap-recurse) || \
+	make(bootstrap-empty))
+# disable most of below
+.MAKE.LEVEL = 1
+.endif
+
+# touch this at your peril
+_DIRDEP_USE_LEVEL?= 0
+.if ${.MAKE.LEVEL} == ${_DIRDEP_USE_LEVEL}
 # only the first instance is interested in all this
 
-# First off, we want to know what ${MACHINE} to build for.
-# This can be complicated if we are using a mixture of ${MACHINE} specific
-# and non-specific Makefile.depend*
+.if !target(_DIRDEP_USE)
 
-.if !target(_DIRDEP_USE)
 # do some setup we only need once
 _CURDIR ?= ${.CURDIR}
+_OBJDIR ?= ${.OBJDIR}
 
+now_utc = ${%s:L:gmtime}
+.if !defined(start_utc)
+start_utc := ${now_utc}
+.endif
+
+.if ${MAKEFILE:T} == ${.PARSEFILE} && empty(DIRDEPS) && ${.TARGETS:Uall:M*/*} != ""
+# This little trick let's us do
+#
+# mk -f dirdeps.mk some/dir.${TARGET_SPEC}
+#
+all:
+${.TARGETS:Nall}: all
+DIRDEPS := ${.TARGETS:M*[/.]*}
+# so that -DNO_DIRDEPS works
+DEP_RELDIR := ${DIRDEPS:[1]:R}
+# this will become DEP_MACHINE below
+TARGET_MACHINE := ${DIRDEPS:[1]:E:C/,.*//}
+.if ${TARGET_MACHINE:N*/*} == ""
+TARGET_MACHINE := ${MACHINE}
+.endif
+# disable DIRDEPS_CACHE as it does not like this trick
+MK_DIRDEPS_CACHE = no
+.endif
+
+# make sure we get the behavior we expect
+.MAKE.SAVE_DOLLARS = no
+
 # 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.
@@ -145,9 +205,15 @@
 # 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}
+.if ${MAKE_VERSION} >= 20170130
+_tspec_x := ${TARGET_SPEC_VARS:range}
+.elif ${TARGET_SPEC_VARS:[#]} > 10
+# seriously? better have jot(1) or equivalent to produce suitable sequence
+_tspec_x := ${${JOT:Ujot} ${TARGET_SPEC_VARS:[#]}:L:sh}
+.else
+# we can provide the sequence ourselves
+_tspec_x := ${1 2 3 4 5 6 7 8 9 10:L:[1..${TARGET_SPEC_VARS:[#]}]}
+.endif
 # 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
@@ -193,6 +259,10 @@
 
 .endif				# !target(_DIRDEP_USE)
 
+# First off, we want to know what ${MACHINE} to build for.
+# This can be complicated if we are using a mixture of ${MACHINE} specific
+# and non-specific Makefile.depend*
+
 # if we were included recursively _DEP_TARGET_SPEC should be valid.
 .if empty(_DEP_TARGET_SPEC)
 # we may or may not have included a dependfile yet
@@ -201,7 +271,7 @@
 .else
 _last_dependfile := ${.MAKE.MAKEFILES:M*/${.MAKE.DEPENDFILE_PREFIX}*:[-1]}
 .endif
-.if !empty(_debug_reldir)
+.if ${_debug_reldir:U0}
 .info ${DEP_RELDIR}.${DEP_TARGET_SPEC}: _last_dependfile='${_last_dependfile}'
 .endif
 
@@ -214,7 +284,7 @@
 .endif
 .if !empty(_last_dependfile)
 # record that we've read dependfile for this
-_DIRDEP_CHECKED += ${_CURDIR}.${TARGET_SPEC}
+_dirdeps_checked.${_CURDIR}.${TARGET_SPEC}:
 .endif
 .endif
 
@@ -234,10 +304,8 @@
 DEP_MACHINE := ${_DEP_TARGET_SPEC}
 .endif
 
-# pickup customizations
-# as below you can use !target(_DIRDEP_USE) to protect things
-# which should only be done once.
-.-include "local.dirdeps.mk"
+# reset each time through
+_build_all_dirs =
 
 # the first time we are included the _DIRDEP_USE target will not be defined
 # we can use this as a clue to do initialization and other one time things.
@@ -257,10 +325,30 @@
 # remember the initial value of DEP_RELDIR - we test for it below.
 _DEP_RELDIR := ${DEP_RELDIR}
 
+.endif
+
+# DIRDEPS_CACHE can be very handy for debugging.
+# Also if repeatedly building the same target, 
+# we can avoid the overhead of re-computing the tree dependencies.
+MK_DIRDEPS_CACHE ?= no
+BUILD_DIRDEPS_CACHE ?= no
+BUILD_DIRDEPS ?= yes
+
+.if ${MK_DIRDEPS_CACHE} == "yes"
+# this is where we will cache all our work
+DIRDEPS_CACHE ?= ${_OBJDIR:tA}/dirdeps.cache${.TARGETS:Nall:O:u:ts-:S,/,_,g:S,^,.,:N.}
+.endif
+
+# pickup customizations
+# as below you can use !target(_DIRDEP_USE) to protect things
+# which should only be done once.
+.-include <local.dirdeps.mk>
+
+.if !target(_DIRDEP_USE)
 # things we skip for host tools
 SKIP_HOSTDIR ?=
 
-NSkipHostDir = ${SKIP_HOSTDIR:N*.host:S,$,.host,:N.host:${M_ListToSkip}}
+NSkipHostDir = ${SKIP_HOSTDIR:N*.host*:S,$,.host*,:N.host*:S,^,${SRCTOP}/,:${M_ListToSkip}}
 
 # things we always skip
 # SKIP_DIRDEPS allows for adding entries on command line.
@@ -269,14 +357,24 @@
 
 DEP_SKIP_DIR = ${SKIP_DIR} \
 	${SKIP_DIR.${DEP_TARGET_SPEC}:U} \
-	${SKIP_DIR.${DEP_MACHINE}:U} \
-	${SKIP_DIRDEPS.${DEP_MACHINE}:U}
+	${TARGET_SPEC_VARS:@v@${SKIP_DIR.${DEP_$v}:U}@} \
+	${SKIP_DIRDEPS.${DEP_TARGET_SPEC}:U} \
+	${TARGET_SPEC_VARS:@v@${SKIP_DIRDEPS.${DEP_$v}:U}@}
 
+
 NSkipDir = ${DEP_SKIP_DIR:${M_ListToSkip}}
 
-.if defined(NO_DIRDEPS) || defined(NODIRDEPS) || defined(WITHOUT_DIRDEPS)
-# confine ourselves to the original dir
+.if defined(NODIRDEPS) || defined(WITHOUT_DIRDEPS)
+NO_DIRDEPS =
+.elif defined(WITHOUT_DIRDEPS_BELOW)
+NO_DIRDEPS_BELOW =
+.endif
+
+.if defined(NO_DIRDEPS)
+# confine ourselves to the original dir and below.
 DIRDEPS_FILTER += M${_DEP_RELDIR}*
+.elif defined(NO_DIRDEPS_BELOW)
+DIRDEPS_FILTER += M${_DEP_RELDIR}
 .endif
 
 # this is what we run below
@@ -300,7 +398,7 @@
 .ifdef ALL_MACHINES
 # this is how you limit it to only the machines we have been built for
 # previously.
-.if empty(ONLY_MACHINE_LIST)
+.if empty(ONLY_TARGET_SPEC_LIST) && empty(ONLY_MACHINE_LIST)
 .if !empty(ALL_MACHINE_LIST)
 # ALL_MACHINE_LIST is the list of all legal machines - ignore anything else
 _machine_list != cd ${_CURDIR} && 'ls' -1 ${ALL_MACHINE_LIST:O:u:@m@${.MAKE.DEPENDFILE:T:R}.$m@} 2> /dev/null; echo
@@ -309,7 +407,7 @@
 .endif
 _only_machines := ${_machine_list:${NIgnoreFiles:UN*.bak}:E:O:u}
 .else
-_only_machines := ${ONLY_MACHINE_LIST}
+_only_machines := ${ONLY_TARGET_SPEC_LIST:U} ${ONLY_MACHINE_LIST:U}
 .endif
 
 .if empty(_only_machines)
@@ -318,23 +416,105 @@
 .endif
 
 .else				# ! ALL_MACHINES
-# if ONLY_MACHINE_LIST is set, we are limited to that
+# if ONLY_TARGET_SPEC_LIST or ONLY_MACHINE_LIST is set, we are limited to that.
+# Note that ONLY_TARGET_SPEC_LIST should be fully qualified.
 # if TARGET_MACHINE is set - it is really the same as ONLY_MACHINE_LIST
 # otherwise DEP_MACHINE is it - so DEP_MACHINE will match.
+_only_machines := ${ONLY_TARGET_SPEC_LIST:U:M${DEP_MACHINE},*}
+.if empty(_only_machines)
 _only_machines := ${ONLY_MACHINE_LIST:U${TARGET_MACHINE:U${DEP_MACHINE}}:M${DEP_MACHINE}}
 .endif
+.endif
 
 .if !empty(NOT_MACHINE_LIST)
 _only_machines := ${_only_machines:${NOT_MACHINE_LIST:${M_ListToSkip}}}
 .endif
+.if !empty(NOT_TARGET_SPEC_LIST)
+# we must first qualify
+_dm := ${DEP_MACHINE}
+_only_machines := ${_only_machines:M*,*} ${_only_machines:N*,*:@DEP_MACHINE@${DEP_TARGET_SPEC}@:S,^,.,:${M_dep_qual_fixes:ts:}:O:u:S,^.,,}
+DEP_MACHINE := ${_dm}
+_only_machines := ${_only_machines:${NOT_TARGET_SPEC_LIST:${M_ListToSkip}}}
+.endif
+# clean up
+_only_machines := ${_only_machines:O:u}
 
 # make sure we have a starting place?
 DIRDEPS ?= ${RELDIR}
 .endif				# target 
 
-_debug_reldir := ${DEBUG_DIRDEPS:@x@${DEP_RELDIR:M$x}${${DEP_RELDIR}.${DEP_MACHINE}:L:M$x}@}
-_debug_search := ${DEBUG_DIRDEPS:@x@${DEP_RELDIR:M$x}${${DEP_RELDIR}.depend:L:M$x}@}
+.if !defined(NO_DIRDEPS) && !defined(NO_DIRDEPS_BELOW)
+.if ${MK_DIRDEPS_CACHE} == "yes"
 
+# just ensure this exists
+build-dirdeps:
+
+M_oneperline = @x@\\${.newline}	$$x@
+
+.if ${BUILD_DIRDEPS_CACHE} == "no" 
+.if !target(dirdeps-cached)
+# we do this via sub-make
+BUILD_DIRDEPS = no
+
+# ignore anything but these
+.MAKE.META.IGNORE_FILTER = M*/${.MAKE.DEPENDFILE_PREFIX}*
+
+dirdeps: dirdeps-cached
+dirdeps-cached:	${DIRDEPS_CACHE} .MAKE
+	@echo "${TRACER}Using ${DIRDEPS_CACHE}"
+	@MAKELEVEL=${.MAKE.LEVEL} ${.MAKE} -C ${_CURDIR} -f ${DIRDEPS_CACHE} \
+		dirdeps MK_DIRDEPS_CACHE=no BUILD_DIRDEPS=no
+
+# these should generally do
+BUILD_DIRDEPS_MAKEFILE ?= ${MAKEFILE}
+BUILD_DIRDEPS_TARGETS ?= ${.TARGETS}
+
+# we need the .meta file to ensure we update if 
+# any of the Makefile.depend* changed.
+# We do not want to compare the command line though.
+${DIRDEPS_CACHE}:	.META .NOMETA_CMP
+	+@{ echo '# Autogenerated - do NOT edit!'; echo; \
+	echo 'BUILD_DIRDEPS=no'; echo; \
+	echo '.include <dirdeps.mk>'; \
+	} > ${.TARGET}.new
+	+ at MAKELEVEL=${.MAKE.LEVEL} DIRDEPS_CACHE=${DIRDEPS_CACHE} \
+	DIRDEPS="${DIRDEPS}" \
+	TARGET_SPEC=${TARGET_SPEC} \
+	MAKEFLAGS= ${.MAKE} -C ${_CURDIR} -f ${BUILD_DIRDEPS_MAKEFILE} \
+	${BUILD_DIRDEPS_TARGETS} BUILD_DIRDEPS_CACHE=yes \
+	.MAKE.DEPENDFILE=.none \
+	${.MAKEFLAGS:tW:S,-D ,-D,g:tw:M*WITH*} \
+	3>&1 1>&2 | sed 's,${SRCTOP},$${SRCTOP},g' >> ${.TARGET}.new && \
+	mv ${.TARGET}.new ${.TARGET}
+
+.endif
+.elif !target(_count_dirdeps)
+# we want to capture the dirdeps count in the cache
+.END: _count_dirdeps
+_count_dirdeps: .NOMETA
+	@echo '.info $${.newline}$${TRACER}Makefiles read: total=${.MAKE.MAKEFILES:[#]} depend=${.MAKE.MAKEFILES:M*depend*:[#]} dirdeps=${.ALLTARGETS:M${SRCTOP}*:O:u:[#]}' >&3
+
+.endif
+.elif !make(dirdeps) && !target(_count_dirdeps)
+beforedirdeps: _count_dirdeps
+_count_dirdeps: .NOMETA
+	@echo "${TRACER}Makefiles read: total=${.MAKE.MAKEFILES:[#]} depend=${.MAKE.MAKEFILES:M*depend*:[#]} dirdeps=${.ALLTARGETS:M${SRCTOP}*:O:u:[#]} seconds=`expr ${now_utc} - ${start_utc}`"
+
+.endif
+.endif
+
+.if ${BUILD_DIRDEPS} == "yes"
+.if ${DEBUG_DIRDEPS:@x@${DEP_RELDIR:M$x}${${DEP_RELDIR}.${DEP_MACHINE}:L:M$x}@} != ""
+_debug_reldir = 1
+.else
+_debug_reldir = 0
+.endif
+.if ${DEBUG_DIRDEPS:@x@${DEP_RELDIR:M$x}${${DEP_RELDIR}.depend:L:M$x}@} != ""
+_debug_search = 1
+.else
+_debug_search = 0
+.endif
+
 # the rest is done repeatedly for every Makefile.depend we read.
 # if we are anything but the original dir we care only about the
 # machine type we were included for..
@@ -347,7 +527,7 @@
 
 # on rare occasions, there can be a need for extra help
 _dep_hack := ${_this_dir}/${.MAKE.DEPENDFILE_PREFIX}.inc
-.-include "${_dep_hack}"
+.-include <${_dep_hack}>
 
 .if ${DEP_RELDIR} != ${_DEP_RELDIR} || ${DEP_TARGET_SPEC} != ${TARGET_SPEC}
 # this should be all
@@ -368,8 +548,11 @@
 # we need to tweak _machines
 _dm := ${DEP_MACHINE}
 # apply the same filtering that we do when qualifying DIRDEPS.
-_machines := ${_machines:@DEP_MACHINE@${DEP_TARGET_SPEC}@:${M_dep_qual_fixes:ts:}:O:u}
+# M_dep_qual_fixes expects .${MACHINE}* so add (and remove) '.'
+# Again we expect that any already qualified machines are fully qualified.
+_machines := ${_machines:M*,*} ${_machines:N*,*:@DEP_MACHINE@${DEP_TARGET_SPEC}@:S,^,.,:${M_dep_qual_fixes:ts:}:O:u:S,^.,,}
 DEP_MACHINE := ${_dm}
+_machines := ${_machines:O:u}
 .endif
 
 # reset each time through
@@ -383,12 +566,16 @@
 _build_dirs += ${_machines:N${DEP_TARGET_SPEC}:@m@${_CURDIR}.$m@}
 .if ${DEP_TARGET_SPEC} == ${TARGET_SPEC}
 # pickup local dependencies now
+.if ${MAKE_VERSION} < 20160220
 .-include <.depend>
+.else
+.dinclude <.depend>
 .endif
 .endif
 .endif
+.endif
 
-.if !empty(_debug_reldir)
+.if ${_debug_reldir}
 .info ${DEP_RELDIR}.${DEP_TARGET_SPEC}: DIRDEPS='${DIRDEPS}'
 .info ${DEP_RELDIR}.${DEP_TARGET_SPEC}: _machines='${_machines}' 
 .endif
@@ -397,7 +584,7 @@
 # these we reset each time through as they can depend on DEP_MACHINE
 DEP_DIRDEPS_FILTER = \
 	${DIRDEPS_FILTER.${DEP_TARGET_SPEC}:U} \
-	${DIRDEPS_FILTER.${DEP_MACHINE}:U} \
+	${TARGET_SPEC_VARS:@v@${DIRDEPS_FILTER.${DEP_$v}:U}@} \
 	${DIRDEPS_FILTER:U} 
 .if empty(DEP_DIRDEPS_FILTER)
 # something harmless
@@ -419,7 +606,7 @@
 __qual_depdirs += ${__hostdpadd}
 .endif
 
-.if !empty(_debug_reldir)
+.if ${_debug_reldir}
 .info depdirs=${__depdirs}
 .info qualified=${__qual_depdirs}
 .info unqualified=${__unqual_depdirs}
@@ -429,7 +616,8 @@
 _build_dirs += \
 	${__qual_depdirs:M*.host:${NSkipHostDir}:N.host} \
 	${__qual_depdirs:N*.host} \
-	${_machines:@m@${__unqual_depdirs:@d@$d.$m@}@}
+	${_machines:Mhost*:@m@${__unqual_depdirs:@d@$d.$m@}@:${NSkipHostDir}:N.host} \
+	${_machines:Nhost*:@m@${__unqual_depdirs:@d@$d.$m@}@}
 
 # qualify everything now
 _build_dirs := ${_build_dirs:${M_dep_qual_fixes:ts:}:O:u}
@@ -436,48 +624,88 @@
 
 .endif				# empty DIRDEPS
 
+_build_all_dirs += ${_build_dirs}
+_build_all_dirs := ${_build_all_dirs:O:u}
+
 # Normally if doing make -V something,
 # we do not want to waste time chasing DIRDEPS
 # but if we want to count the number of Makefile.depend* read, we do.
 .if ${.MAKEFLAGS:M-V${_V_READ_DIRDEPS}} == ""
-.if !empty(_build_dirs)
+.if !empty(_build_all_dirs)
+.if ${BUILD_DIRDEPS_CACHE} == "yes"
+x!= { echo; echo '\# ${DEP_RELDIR}.${DEP_TARGET_SPEC}'; \
+	echo 'dirdeps: ${_build_all_dirs:${M_oneperline}}'; echo; } >&3; echo
+x!= { ${_build_all_dirs:@x@${target($x):?:echo '$x: _DIRDEP_USE';}@} echo; } >&3; echo
+.if !empty(DEP_EXPORT_VARS)
+# Discouraged, but there are always exceptions.
+# Handle it here rather than explain how.
+x!= { echo; ${DEP_EXPORT_VARS:@v at echo '$v=${$v}';@} echo '.export ${DEP_EXPORT_VARS}'; echo; } >&3; echo
+.endif
+.else
 # this makes it all happen
-dirdeps: ${_build_dirs}
-${_build_dirs}:	_DIRDEP_USE
+dirdeps: ${_build_all_dirs}
+.endif
+${_build_all_dirs}:	_DIRDEP_USE
 
-.if !empty(_debug_reldir)
+.if ${_debug_reldir}
 .info ${DEP_RELDIR}.${DEP_TARGET_SPEC}: needs: ${_build_dirs}
 .endif
 
+.if !empty(DEP_EXPORT_VARS)
+.export ${DEP_EXPORT_VARS}
+DEP_EXPORT_VARS=
+.endif
+
 # this builds the dependency graph
 .for m in ${_machines}
 # it would be nice to do :N${.TARGET}
 .if !empty(__qual_depdirs)
 .for q in ${__qual_depdirs:${M_dep_qual_fixes:ts:}:E:O:u:N$m}
-.if !empty(_debug_reldir) || ${DEBUG_DIRDEPS:@x@${${DEP_RELDIR}.$m:L:M$x}${${DEP_RELDIR}.$q:L:M$x}@} != ""
+.if ${_debug_reldir} || ${DEBUG_DIRDEPS:@x@${${DEP_RELDIR}.$m:L:M$x}${${DEP_RELDIR}.$q:L:M$x}@} != ""
 .info ${DEP_RELDIR}.$m: graph: ${_build_dirs:M*.$q}
 .endif
+.if ${BUILD_DIRDEPS_CACHE} == "yes"
+x!= { echo; echo '${_this_dir}.$m: ${_build_dirs:M*.$q:${M_oneperline}}'; echo; } >&3; echo
+.else
 ${_this_dir}.$m: ${_build_dirs:M*.$q}
+.endif
 .endfor
 .endif
-.if !empty(_debug_reldir)
+.if ${_debug_reldir}
 .info ${DEP_RELDIR}.$m: graph: ${_build_dirs:M*.$m:N${_this_dir}.$m}
 .endif
+.if ${BUILD_DIRDEPS_CACHE} == "yes"
+x!= { echo; echo '${_this_dir}.$m: ${_build_dirs:M*.$m:N${_this_dir}.$m:${M_oneperline}}'; echo; } >&3; echo
+.else
 ${_this_dir}.$m: ${_build_dirs:M*.$m:N${_this_dir}.$m}
+.endif
 .endfor
 
 .endif
 
 # Now find more dependencies - and recurse.
-.for d in ${_build_dirs}
-.if ${_DIRDEP_CHECKED:M$d} == ""
+.for d in ${_build_all_dirs}
+.if !target(_dirdeps_checked.$d)
 # once only
-_DIRDEP_CHECKED += $d
-.if !empty(_debug_search)
+_dirdeps_checked.$d:
+.if ${_debug_search}
 .info checking $d
 .endif
-# Note: _build_dirs is fully qualifed so d:R is always the directory
+# Note: _build_all_dirs is fully qualifed so d:R is always the directory
 .if exists(${d:R})
+# we pass _DEP_TARGET_SPEC to tell the next step what we want
+_DEP_TARGET_SPEC := ${d:E}
+# some makefiles may still look at this
+_DEP_MACHINE := ${d:E:C/,.*//}
+# set these too in case Makefile.depend* uses them
+.if ${TARGET_SPEC_VARS:[#]} > 1
+_dtspec := ${_DEP_TARGET_SPEC:S/,/ /g}
+.for i in ${_tspec_x}
+DEP_${TARGET_SPEC_VARS:[$i]} := ${_dtspec:[$i]}
+.endfor
+.else
+DEP_MACHINE := ${_DEP_MACHINE}
+.endif
 # Warning: there is an assumption here that MACHINE is always 
 # the first entry in TARGET_SPEC_VARS.
 # If TARGET_SPEC and MACHINE are insufficient, you have a problem.
@@ -485,14 +713,15 @@
 .if !empty(_m)
 # M_dep_qual_fixes isn't geared to Makefile.depend
 _qm := ${_m:C;(\.depend)$;\1.${d:E};:${M_dep_qual_fixes:ts:}}
-.if !empty(_debug_search)
+.if ${_debug_search}
 .info Looking for ${_qm}
 .endif
-# we pass _DEP_TARGET_SPEC to tell the next step what we want
-_DEP_TARGET_SPEC := ${d:E}
-# some makefiles may still look at this
-_DEP_MACHINE := ${d:E:C/,.*//}
-.if !empty(_debug_reldir) && ${_qm} != ${_m}
+# set this "just in case" 
+# we can skip :tA since we computed the path above
+DEP_RELDIR := ${_m:H:S,${SRCTOP}/,,}
+# and reset this
+DIRDEPS =
+.if ${_debug_reldir} && ${_qm} != ${_m}
 .info loading ${_m} for ${d:E}
 .endif
 .include <${_m}>
@@ -502,12 +731,75 @@
 .endfor
 
 .endif				# -V
+.endif				# BUILD_DIRDEPS
 
 .elif ${.MAKE.LEVEL} > 42
 .error You should have stopped recursing by now.
 .else
-_DEP_RELDIR := ${DEP_RELDIR}
+# we are building something
+DEP_RELDIR := ${RELDIR}
+_DEP_RELDIR := ${RELDIR}
 # pickup local dependencies
+.if ${MAKE_VERSION} < 20160220
 .-include <.depend>
+.else
+.dinclude <.depend>
 .endif
+.endif
 
+# bootstrapping new dependencies made easy?
+.if !target(bootstrap) && (make(bootstrap) || \
+	make(bootstrap-this) || \
+	make(bootstrap-recurse) || \
+	make(bootstrap-empty))
+
+# if we are bootstrapping create the default
+_want = ${.CURDIR}/${.MAKE.DEPENDFILE_DEFAULT:T}
+
+.if exists(${_want})
+# stop here
+${.TARGETS:Mboot*}:
+.elif !make(bootstrap-empty)
+# find a Makefile.depend to use as _src
+_src != cd ${.CURDIR} && for m in ${.MAKE.DEPENDFILE_PREFERENCE:T:S,${MACHINE},*,}; do test -s $$m || continue; echo $$m; break; done; echo
+.if empty(_src)
+.error cannot find any of ${.MAKE.DEPENDFILE_PREFERENCE:T}${.newline}Use: bootstrap-empty
+.endif
+
+_src?= ${.MAKE.DEPENDFILE}
+
+.MAKE.DEPENDFILE_BOOTSTRAP_SED+= -e 's/${_src:E:C/,.*//}/${MACHINE}/g'
+
+# just create Makefile.depend* for this dir
+bootstrap-this:	.NOTMAIN
+	@echo Bootstrapping ${RELDIR}/${_want:T} from ${_src:T}; \
+	echo You need to build ${RELDIR} to correctly populate it.
+.if ${_src:T} != ${.MAKE.DEPENDFILE_PREFIX:T}
+	(cd ${.CURDIR} && sed ${.MAKE.DEPENDFILE_BOOTSTRAP_SED} ${_src} > ${_want:T})
+.else
+	cp ${.CURDIR}/${_src:T} ${_want}
+.endif
+
+# create Makefile.depend* for this dir and its dependencies
+bootstrap: bootstrap-recurse
+bootstrap-recurse: bootstrap-this
+
+_mf := ${.PARSEFILE}
+bootstrap-recurse:	.NOTMAIN .MAKE
+	@cd ${SRCTOP} && \
+	for d in `cd ${RELDIR} && ${.MAKE} -B -f ${"${.MAKEFLAGS:M-n}":?${_src}:${.MAKE.DEPENDFILE:T}} -V DIRDEPS`; do \
+		test -d $$d || d=$${d%.*}; \
+		test -d $$d || continue; \
+		echo "Checking $$d for bootstrap ..."; \
+		(cd $$d && ${.MAKE} -f ${_mf} bootstrap-recurse); \
+	done
+
+.endif
+
+# create an empty Makefile.depend* to get the ball rolling.
+bootstrap-empty: .NOTMAIN .NOMETA
+	@echo Creating empty ${RELDIR}/${_want:T}; \
+	echo You need to build ${RELDIR} to correctly populate it.
+	@{ echo DIRDEPS=; echo ".include <dirdeps.mk>"; } > ${_want}
+
+.endif

Modified: vendor/NetBSD/bmake/dist/mk/doc.mk
===================================================================
--- vendor/NetBSD/bmake/dist/mk/doc.mk	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/mk/doc.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,4 +1,4 @@
-# $Id: doc.mk,v 1.4 2012/11/11 22:37:02 sjg Exp $
+# $Id: doc.mk,v 1.6 2017/05/01 21:24:10 sjg Exp $
 
 .if !target(__${.PARSEFILE}__)
 __${.PARSEFILE}__:
@@ -47,17 +47,19 @@
 .else
 FILES?=	${SRCS}
 install:
-	${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 444 \
-	    Makefile ${FILES} ${EXTRA} ${DESTDIR}${BINDIR}/${DIR}
+	test -d ${DESTDIR}${DOCDIR}/${DIR} || \
+	    ${INSTALL} -d ${DOC_INSTALL_OWN} -m ${DIRMODE} ${DESTDIR}${DOCDIR}/${DIR}
+	${INSTALL} ${COPY} ${DOC_INSTALL_OWN} -m ${DOCMODE} \
+	    Makefile ${FILES} ${EXTRA} ${DESTDIR}${DOCDIR}/${DIR}
 .endif
 
 spell: ${SRCS}
 	spell ${SRCS} | sort | comm -23 - spell.ok > paper.spell
 
-BINDIR?=	/usr/share/doc
-BINGRP?=	bin
-BINOWN?=	bin
-BINMODE?=	444
+.include <own.mk>
 
-.include <own.mk>
+.if !empty(DOCOWN)
+DOC_INSTALL_OWN?= -o ${DOCOWN} -g ${DOCGRP}
 .endif
+
+.endif

Modified: vendor/NetBSD/bmake/dist/mk/dpadd.mk
===================================================================
--- vendor/NetBSD/bmake/dist/mk/dpadd.mk	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/mk/dpadd.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,4 +1,4 @@
-# $Id: dpadd.mk,v 1.19 2014/04/05 22:56:54 sjg Exp $
+# $Id: dpadd.mk,v 1.23 2017/02/13 16:46:01 sjg Exp $
 #
 #	@(#) Copyright (c) 2004, Simon J. Gerraty
 #
@@ -21,71 +21,91 @@
 _OBJDIR?= ${.OBJDIR}
 _CURDIR?= ${.CURDIR}
 
+.if ${_CURDIR} == ${SRCTOP}
+RELDIR=.
+RELTOP=.
+.else
+RELDIR?= ${_CURDIR:S,${SRCTOP}/,,}
+.if ${RELDIR} == ${_CURDIR}
+RELDIR?= ${_OBJDIR:S,${OBJTOP}/,,}
+.endif
+RELTOP?= ${RELDIR:C,[^/]+,..,g}
+.endif
+RELOBJTOP?= ${OBJTOP}
+RELSRCTOP?= ${SRCTOP}
+
+# we get included just about everywhere so this is handy...
+# C*DEBUG_XTRA are for defining on cmd line etc 
+# so do not use in makefiles.
+.ifdef CFLAGS_DEBUG_XTRA
+CFLAGS_LAST += ${CFLAGS_DEBUG_XTRA}
+.endif
+.ifdef CXXFLAGS_DEBUG_XTRA
+CXXFLAGS_LAST += ${CXXFLAGS_DEBUG_XTRA}
+.endif
+
+.-include <local.dpadd.mk>
+
 # DPLIBS helps us ensure we keep DPADD and LDADD in sync
 DPLIBS+= ${DPLIBS_LAST}
-DPADD+= ${DPLIBS}
-.for __lib in ${DPLIBS:T:R}
-LDADD+= ${LDADD_${__lib}:U${__lib:T:R:S/lib/-l/:C/\.so.*//}}
+DPADD+= ${DPLIBS:N-*}
+.for __lib in ${DPLIBS}
+.if "${_lib:M-*}" != ""
+LDADD += ${__lib}
+.else
+LDADD += ${LDADD_${__lib:T:R}:U${__lib:T:R:S/lib/-l/:C/\.so.*//}}
+.endif
 .endfor
 
 # DPADD can contain things other than libs
-__dpadd_libs = ${DPADD:M*/lib*}
+__dpadd_libs := ${DPADD:M*/lib*}
 
 # some libs have dependencies...
 # DPLIBS_* allows bsd.libnames.mk to flag libs which must be included
 # in DPADD for a given library.
-.for __lib in ${__dpadd_libs:@d@${DPLIBS_${d:T:R}}@}
+# Gather all such dependencies into __ldadd_all_xtras
+# dups will be dealt with later.
+# Note: libfoo_pic uses DPLIBS_libfoo
+__ldadd_all_xtras=
+.for __lib in ${__dpadd_libs:@d@${DPLIBS_${d:T:R:S,_pic,,}}@}
+__ldadd_all_xtras+= ${LDADD_${__lib}:U${__lib:T:R:S/lib/-l/:C/\.so.*//}}
 .if "${DPADD:M${__lib}}" == ""
 DPADD+= ${__lib}
-LDADD+= ${LDADD_${__lib}:U${__lib:T:R:S/lib/-l/:C/\.so.*//}}
 .endif
 .endfor
 # Last of all... for libc and libgcc
 DPADD+= ${DPADD_LAST}
 
+# de-dupuplicate __ldadd_all_xtras into __ldadd_xtras
+# in reverse order so that libs end up listed after all that needed them.
+__ldadd_xtras=
+.for __lib in ${__ldadd_all_xtras:[-1..1]}
+.if "${__ldadd_xtras:M${__lib}}" == "" || ${NEED_IMPLICIT_LDADD:tl:Uno} != "no"
+__ldadd_xtras+= ${__lib}
+.endif
+.endfor
+
+.if !empty(__ldadd_xtras)
+# now back to the original order
+__ldadd_xtras:= ${__ldadd_xtras:[-1..1]}
+LDADD+= ${__ldadd_xtras}
+.endif
+
 # Convert DPADD into -I and -L options and add them to CPPFLAGS and LDADD
 # For the -I's convert the path to a relative one.  For separate objdirs
 # the DPADD paths will be to the obj tree so we need to subst anyway.
 
-# If USE_PROFILE is yes, then check for profiled versions of libs
-# and use them.
+# update this
+__dpadd_libs := ${DPADD:M*/lib*}
 
-USE_PROFILE?=no
-.if defined(LIBDL) && exists(${LIBDL})
-.if defined(PROG) && (make(${PROG}_p) || ${USE_PROFILE} == yes) && \
-	defined(LDFLAGS) && ${LDFLAGS:M-export-dynamic}
-# building profiled version of a prog that needs dlopen to work
-DPLIBS+= ${LIBDL}
-.endif
-.endif
-
-.if defined(LIBDMALLOC) && exists(${LIBDMALLOC})
-.if defined(USE_DMALLOC) && ${USE_DMALLOC} != no
-.if !defined(NO_DMALLOC)
-CPPFLAGS+= -DUSE_DMALLOC
-.endif
-DPLIBS+= ${LIBDMALLOC}
-.endif
-.endif
-
 # Order -L's to search ours first.
 # Avoids picking up old versions already installed.
 __dpadd_libdirs := ${__dpadd_libs:R:H:S/^/-L/g:O:u:N-L}
 LDADD += ${__dpadd_libdirs:M-L${OBJTOP}/*}
-LDADD += ${__dpadd_libdirs:N-L${OBJTOP}/*}
-
-.if ${.CURDIR} == ${SRCTOP}
-RELDIR=.
-RELTOP=.
-.else
-RELDIR?= ${.CURDIR:S,${SRCTOP}/,,}
-.if ${RELDIR} == ${.CURDIR}
-RELDIR?= ${.OBJDIR:S,${OBJTOP}/,,}
+LDADD += ${__dpadd_libdirs:N-L${OBJTOP}/*:N-L${HOST_LIBDIR:U/usr/lib}}
+.if defined(HOST_LIBDIR) && ${HOST_LIBDIR} != "/usr/lib"
+LDADD+= -L${HOST_LIBDIR}
 .endif
-RELTOP?= ${RELDIR:C,[^/]+,..,g}
-.endif
-RELOBJTOP?= ${OBJTOP}
-RELSRCTOP?= ${SRCTOP}
 
 .if !make(dpadd)
 .ifdef LIB
@@ -109,7 +129,8 @@
 DPMAGIC_LIBS += ${__dpadd_libs} \
 	${__dpadd_libs:@d@${DPMAGIC_LIBS_${d:T:R}}@}
 
-.for __lib in ${DPMAGIC_LIBS:O:u}
+# we skip this for staged libs
+.for __lib in ${DPMAGIC_LIBS:O:u:N${STAGE_OBJTOP:Unot}*/lib/*}
 # 
 # if SRC_libfoo is not set, then we assume that the srcdir corresponding
 # to where we found the library is correct.
@@ -127,6 +148,35 @@
 
 .endfor
 
+# even for staged libs we sometimes 
+# need to allow direct -I to avoid cicular dependencies 
+.for __lib in ${DPMAGIC_LIBS:O:u:T:R}
+.if !empty(SRC_${__lib}) && empty(INCLUDES_${__lib})
+# must be a staged lib
+.if exists(${SRC_${__lib}}/h)
+INCLUDES_${__lib} = -I${SRC_${__lib}}/h
+.else
+INCLUDES_${__lib} = -I${SRC_${__lib}}
+.endif
+.endif
+.endfor
+
+# when linking a shared lib, avoid non pic libs
+SHLDADD+= ${LDADD:N-[lL]*}
+.for __lib in ${__dpadd_libs:u}
+.if defined(SHLIB_NAME) && ${LDADD:M-l${__lib:T:R:S,lib,,}} != ""
+.if ${__lib:T:N*_pic.a:N*.so} == "" || exists(${__lib:R}.so)
+SHLDADD+= -l${__lib:T:R:S,lib,,}
+.elif exists(${__lib:R}_pic.a)
+SHLDADD+= -l${__lib:T:R:S,lib,,}_pic
+.else
+.warning ${RELDIR}.${TARGET_SPEC} needs ${__lib:T:R}_pic.a
+SHLDADD+= -l${__lib:T:R:S,lib,,}
+.endif
+SHLDADD+= -L${__lib:H}
+.endif
+.endfor
+
 # Now for the bits we actually need
 __dpadd_incs=
 .for __lib in ${__dpadd_libs:u}
@@ -134,21 +184,26 @@
 __ldadd=-l${__lib:T:R:S,lib,,}
 LDADD := ${LDADD:S,^${__ldadd}$,${__ldadd}_p,g}
 .endif
+.endfor
 
 #
-# Some libs generate headers, so we potentially need both
-# the src dir and the obj dir.
-# If ${INCLUDES_libfoo} contains a word ending in /h, we assume that either
-# 1. it does not generate headers or
-# 2. INCLUDES_libfoo will have been set correctly
-# XXX it gets ugly avoiding duplicates... 
-# use :? to ensure .for does not prevent correct evaluation
-#
 # We take care of duplicate suppression later.
-__dpadd_incs += ${"${INCLUDES_${__lib:T:R}:M*/h}":? :-I${OBJ_${__lib:T:R}}}
-__dpadd_incs += ${INCLUDES_${__lib:T:R}}
-.endfor
+# don't apply :T:R too early
+__dpadd_incs += ${__dpadd_libs:u:@x@${INCLUDES_${x:T:R}}@}
+__dpadd_incs += ${__dpadd_libs:O:u:@s@${SRC_LIBS_${s:T:R}:U}@:@x@${INCLUDES_${x:T:R}}@}
 
+__dpadd_last_incs += ${__dpadd_libs:u:@x@${INCLUDES_LAST_${x:T:R}}@}
+__dpadd_last_incs += ${__dpadd_libs:O:u:@s@${SRC_LIBS_${s:T:R}:U}@:@x@${INCLUDES_LAST_${x:T:R}}@}
+
+.if defined(HOSTPROG) || ${MACHINE} == "host"
+# we want any -I/usr/* last
+__dpadd_last_incs := \
+	${__dpadd_last_incs:N-I/usr/*} \
+	${__dpadd_incs:M-I/usr/*} \
+	${__dpadd_last_incs:M-I/usr/*} 
+__dpadd_incs := ${__dpadd_incs:N-I/usr/*}
+.endif
+
 #
 # eliminate any duplicates - but don't mess with the order
 # force evaluation now - to avoid giving make a headache
@@ -164,13 +219,21 @@
 .endfor
 .endfor
 
+.for t in CFLAGS_LAST CXXFLAGS_LAST
+# avoid duplicates
+__$t_incs:=${$t:M-I*:u}
+.for i in ${__dpadd_last_incs}
+.if "${__$t_incs:M$i}" == ""
+$t+= $i
+__$t_incs+= $i
+.endif
+.endfor
+.endfor
+
 # This target is used to gather a list of
 # dir: ${DPADD}
 # entries
 .if make(*dpadd*)
-# allow overrides
-.-include "dpadd++.mk"
-
 .if !target(dpadd)
 dpadd:	.NOTMAIN
 .if defined(DPADD) && ${DPADD} != ""
@@ -193,4 +256,17 @@
 .PATH: ${SRC_PATHADD}
 .endif
 
+# after all that, if doing -n we don't care
+.if ${.MAKEFLAGS:Ux:M-n} != ""
+DPADD =
+.elif ${.MAKE.MODE:Mmeta*} != "" && exists(${.MAKE.DEPENDFILE})
+DPADD_CLEAR_DPADD ?= yes
+.if ${DPADD_CLEAR_DPADD} == "yes"
+# save this
+__dpadd_libs := ${__dpadd_libs}
+# we have made what use of it we can of DPADD
+DPADD =
 .endif
+.endif
+
+.endif

Added: vendor/NetBSD/bmake/dist/mk/files.mk
===================================================================
--- vendor/NetBSD/bmake/dist/mk/files.mk	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/mk/files.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,83 @@
+# $Id: files.mk,v 1.6 2017/05/07 02:21:02 sjg Exp $
+#
+#	@(#) Copyright (c) 2017, Simon J. Gerraty
+#
+#	This file is provided in the hope that it will
+#	be of use.  There is absolutely NO WARRANTY.
+#	Permission to copy, redistribute or otherwise
+#	use this file is hereby granted provided that 
+#	the above copyright notice and this notice are
+#	left intact. 
+#      
+#	Please send copies of changes and bug-fixes to:
+#	sjg at crufty.net
+#
+
+.include <init.mk>
+
+FILES_INSTALL_OWN ?= -o ${SHAREOWN} -g ${SHAREGRP}
+FILESMODE ?= ${SHAREMODE}
+FILES_COPY ?= -C
+
+FILESGROUPS ?= FILES
+FILESGROUPS := ${FILESGROUPS:O:u}
+
+.if !target(buildfiles)
+.for group in ${FILESGROUPS}
+buildfiles: ${${group}}
+.endfor
+.endif
+buildfiles:
+realbuild: buildfiles
+
+# there is no default FILESDIR so
+# ignore group if ${group}DIR is not defined
+.for group in ${FILESGROUPS}
+.if !empty(${group}) && defined(${group}DIR)
+.if ${group} != "FILES"
+${group}_INSTALL_OWN ?= ${FILES_INSTALL_OWN}
+.endif
+# incase we are staging
+STAGE_DIR.${group} ?= ${STAGE_OBJTOP}${${group}DIR}
+
+.for file in ${${group}:O:u}
+${group}_INSTALL_OWN.${file:T} ?= ${${group}_INSTALL_OWN}
+${group}DIR.${file:T} ?= ${${group}DIR}
+file_mkdir_list += ${${group}DIR.${file:T}}
+
+.if defined(${group}NAME.${file:T})
+STAGE_AS_SETS += ${group}
+STAGE_AS_${file} = ${${group}NAME.${file:T}}
+stage_as.${group}: ${file}
+
+installfiles: installfiles.${group}.${file:T}
+installfiles.${group}.${file:T}: ${file} file_mkdirs
+	${INSTALL} ${FILES_COPY} ${${group}_INSTALL_OWN.${file:T}} \
+	-m ${FILESMODE} ${.ALLSRC:Nfile_mkdirs} ${DESTDIR}${${group}DIR}/${${group}NAME.${file:T}}
+
+.else
+STAGE_SETS += ${group}
+stage_files.${group}: ${file}
+installfiles.${group}: ${file}
+installfiles: installfiles.${group}
+.endif
+
+.endfor				# file
+
+installfiles.${group}: file_mkdirs
+	${INSTALL} ${FILES_COPY} ${${group}_INSTALL_OWN} -m ${FILESMODE} \
+	${.ALLSRC:Nfile_mkdirs:O:u} ${DESTDIR}${${group}DIR}
+
+.endif				# !empty
+.endfor				# group
+
+file_mkdirs:
+	@for d in ${file_mkdir_list:O:u}; do \
+		test -d ${DESTDIR}$$d || \
+		${INSTALL} -d ${FILES_INSTALL_OWN} -m 775 ${DESTDIR}$$d; \
+	done
+
+beforeinstall:
+installfiles:
+realinstall:	installfiles
+.ORDER: beforeinstall installfiles

Modified: vendor/NetBSD/bmake/dist/mk/final.mk
===================================================================
--- vendor/NetBSD/bmake/dist/mk/final.mk	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/mk/final.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,14 +1,22 @@
-# $Id: final.mk,v 1.5 2011/03/11 05:22:38 sjg Exp $
+# $Id: final.mk,v 1.8 2017/05/07 20:30:08 sjg Exp $
 
 .if !target(__${.PARSEFILE}__)
 __${.PARSEFILE}__:
 
 # provide a hook for folk who want to do scary stuff
-.-include "${.CURDIR}/../Makefile-final.inc"
+.-include <${.CURDIR:H}/Makefile-final.inc>
 
-.if !empty(STAGE)
+.if ${MK_STAGING} == "yes"
+.include <meta.stage.mk>
+.elif !empty(STAGE)
 .-include <stage.mk>
 .endif
 
 .-include <local.final.mk>
+
+.if empty(_SKIP_BUILD)
+install: realinstall
 .endif
+realinstall:
+
+.endif

Modified: vendor/NetBSD/bmake/dist/mk/gendirdeps.mk
===================================================================
--- vendor/NetBSD/bmake/dist/mk/gendirdeps.mk	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/mk/gendirdeps.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,4 +1,4 @@
-# $Id: gendirdeps.mk,v 1.25 2014/03/14 21:28:37 sjg Exp $
+# $Id: gendirdeps.mk,v 1.33 2016/10/11 22:37:28 sjg Exp $
 
 # Copyright (c) 2010-2013, Juniper Networks, Inc.
 # All rights reserved.
@@ -82,7 +82,7 @@
 .export META_FILES
 
 # pickup customizations
-.-include "local.gendirdeps.mk"
+.-include <local.gendirdeps.mk>
 
 # these are actually prefixes that we'll skip
 # they should all be absolute paths
@@ -93,6 +93,17 @@
 _skip_gendirdeps =
 .endif
 
+# Below we will turn _{VAR} into ${VAR} which keeps this simple
+# GENDIRDEPS_FILTER_DIR_VARS is a list of dirs to be substiuted for.
+# GENDIRDEPS_FILTER_VARS is more general.
+# In each case order matters.
+.if !empty(GENDIRDEPS_FILTER_DIR_VARS)
+GENDIRDEPS_FILTER += ${GENDIRDEPS_FILTER_DIR_VARS:@v at S,${$v},_{${v}},@}
+.endif
+.if !empty(GENDIRDEPS_FILTER_VARS)
+GENDIRDEPS_FILTER += ${GENDIRDEPS_FILTER_VARS:@v at S,/${$v}/,/_{${v}}/,@:NS,//,*:u}
+.endif
+
 # this (*should* be set in meta.sys.mk) 
 # is the script that extracts what we want.
 META2DEPS ?= ${.PARSEDIR}/meta2deps.sh
@@ -127,7 +138,8 @@
 .endif
 META2DEPS_CMD += \
 	-R ${RELDIR} -H ${HOST_TARGET} \
-	${M2D_OBJROOTS:O:u:@o at -O $o@}
+	${M2D_OBJROOTS:O:u:@o at -O $o@} \
+	${M2D_EXCLUDES:O:u:@o at -X $o@} \
 
 
 M2D_OBJROOTS += ${OBJTOP} ${_OBJROOT} ${_objroot}
@@ -134,6 +146,9 @@
 .if defined(SB_OBJROOT)
 M2D_OBJROOTS += ${SB_OBJROOT}
 .endif
+.if defined(STAGE_ROOT)
+M2D_OBJROOTS += ${STAGE_ROOT}
+.endif
 .if ${.MAKE.DEPENDFILE_PREFERENCE:U${.MAKE.DEPENDFILE}:M*.${MACHINE}} == ""
 # meta2deps.py only groks objroot
 # so we need to give it what it expects
@@ -146,7 +161,7 @@
 .endif
 
 # we are only interested in the dirs
-# sepecifically those we read something from.
+# specifically those we read something from.
 # we canonicalize them to keep things simple
 # if we are using a split-fs sandbox, it gets a little messier.
 _objtop := ${_OBJTOP:tA}
@@ -244,6 +259,7 @@
 
 .if ${DEBUG_GENDIRDEPS:Uno:@x@${RELDIR:M$x}@} != ""
 .info ${RELDIR}: M2D_OBJROOTS=${M2D_OBJROOTS}
+.info ${RELDIR}: M2D_EXCLUDES=${M2D_EXCLUDES}
 .info ${RELDIR}: dir_list='${dir_list}'
 .info ${RELDIR}: dpadd_dir_list='${dpadd_dir_list}'
 .info ${RELDIR}: dirdep_list='${dirdep_list}'
@@ -298,9 +314,8 @@
 # .depend may contain things we don't want.
 # The sed command at the end of the stream, allows for the filters
 # to output _{VAR} tokens which we will turn into proper ${VAR} references.
-${_DEPENDFILE}: ${CAT_DEPEND:M.depend} ${META_FILES:O:u:@m@${exists($m):?$m:}@} ${_this} ${META2DEPS}
-	@(echo '# Autogenerated - do NOT edit!'; echo; \
-	echo 'DEP_RELDIR := $${_PARSEDIR:S,$${SRCTOP}/,,}'; echo; \
+${_DEPENDFILE}: .NOMETA ${CAT_DEPEND:M.depend} ${META_FILES:O:u:@m@${exists($m):?$m:}@} ${_this} ${META2DEPS}
+	@(${GENDIRDEPS_HEADER} echo '# Autogenerated - do NOT edit!'; echo; \
 	echo 'DIRDEPS = \'; \
 	echo '${DIRDEPS:@d@	$d \\${.newline}@}'; echo; \
 	${_include_src_dirdeps} \
@@ -319,9 +334,8 @@
 
 all:	${_DEPENDFILE}
 
-${_DEPENDFILE}: ${MAKEFILE} ${_this}
-	@(echo '# Autogenerated - do NOT edit!'; echo; \
-	echo 'DEP_RELDIR := $${_PARSEDIR:S,$${SRCTOP}/,,}'; echo; \
+${_DEPENDFILE}: .NOMETA ${MAKEFILE} ${_this}
+	@(${GENDIRDEPS_HEADER} echo '# Autogenerated - do NOT edit!'; echo; \
 	echo 'DIRDEPS = \'; \
 	echo '${DIRDEPS:@d@	$d \\${.newline}@}'; echo; \
 	echo '.include <dirdeps.mk>'; \

Modified: vendor/NetBSD/bmake/dist/mk/host-target.mk
===================================================================
--- vendor/NetBSD/bmake/dist/mk/host-target.mk	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/mk/host-target.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,5 +1,5 @@
 # RCSid:
-#	$Id: host-target.mk,v 1.7 2014/05/16 17:54:52 sjg Exp $
+#	$Id: host-target.mk,v 1.11 2015/10/25 00:07:20 sjg Exp $
 
 # Host platform information; may be overridden
 .if !defined(_HOST_OSNAME)
@@ -10,24 +10,33 @@
 _HOST_OSREL  !=	uname -r
 .export _HOST_OSREL
 .endif
+.if !defined(_HOST_MACHINE)
+_HOST_MACHINE != uname -m
+.export _HOST_MACHINE
+.endif
 .if !defined(_HOST_ARCH)
-_HOST_ARCH   !=	uname -p 2>/dev/null || uname -m
+# for NetBSD prefer $MACHINE (amd64 rather than x86_64)
+.if ${_HOST_OSNAME:NNetBSD} == ""
+_HOST_ARCH := ${_HOST_MACHINE}
+.else
+_HOST_ARCH != uname -p 2> /dev/null || uname -m
 # uname -p may produce garbage on linux
-.if ${_HOST_ARCH:[\#]} > 1
-_HOST_ARCH != uname -m
+.if ${_HOST_ARCH:[\#]} > 1 || ${_HOST_ARCH:Nunknown} == ""
+_HOST_ARCH := ${_HOST_MACHINE}
 .endif
+.endif
 .export _HOST_ARCH
 .endif
 .if !defined(HOST_MACHINE)
-HOST_MACHINE != uname -m
+HOST_MACHINE := ${_HOST_MACHINE}
 .export HOST_MACHINE
 .endif
 
 HOST_OSMAJOR := ${_HOST_OSREL:C/[^0-9].*//}
-HOST_OSTYPE  :=	${_HOST_OSNAME}-${_HOST_OSREL:C/\([^\)]*\)//}-${_HOST_ARCH}
+HOST_OSTYPE  :=	${_HOST_OSNAME:S,/,,g}-${_HOST_OSREL:C/\([^\)]*\)//}-${_HOST_ARCH}
 HOST_OS      :=	${_HOST_OSNAME}
 host_os      :=	${_HOST_OSNAME:tl}
-HOST_TARGET  := ${host_os}${HOST_OSMAJOR}-${_HOST_ARCH}
+HOST_TARGET  := ${host_os:S,/,,g}${HOST_OSMAJOR}-${_HOST_ARCH}
 
 # tr is insanely non-portable, accommodate the lowest common denominator
 TR ?= tr

Modified: vendor/NetBSD/bmake/dist/mk/inc.mk
===================================================================
--- vendor/NetBSD/bmake/dist/mk/inc.mk	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/mk/inc.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,4 +1,4 @@
-# $Id: inc.mk,v 1.3 2011/03/11 05:23:05 sjg Exp $
+# $Id: inc.mk,v 1.7 2017/05/06 17:29:45 sjg Exp $
 #
 #	@(#) Copyright (c) 2008, Simon J. Gerraty
 #
@@ -15,8 +15,6 @@
 
 .include <init.mk>
 
-includes:	${INCS}
-
 .if !empty(LIBOWN)
 INC_INSTALL_OWN ?= -o ${LIBOWN} -g ${LIBGRP}
 .endif
@@ -24,12 +22,68 @@
 INC_COPY ?= -C
 INCSDIR ?= ${INCDIR}
 
-realinstall:	incinstall
+STAGE_INCSDIR?= ${STAGE_OBJTOP}${INCSDIR}
+
+# accommodate folk used to freebsd
+INCGROUPS ?= ${INCSGROUPS:UINCS}
+INCGROUPS := ${INCGROUPS:O:u}
+
+.if !target(buildincludes)
+.for group in ${INCGROUPS}
+buildincludes: ${${group}}
+.endfor
+.endif
+buildincludes:
+includes: buildincludes
+
 .if !target(incinstall)
-incinstall:
-.if !empty(INCS)
-	[ -d ${DESTDIR}${INCSDIR} ] || \
-	${INSTALL} -d ${INC_INSTALL_OWN} -m 775 ${DESTDIR}${INCSDIR}
-	${INSTALL} ${INC_COPY} ${INC_INSTALL_OWN} -m ${INCMODE} ${INCS} ${DESTDIR}${INCSDIR}
+.for group in ${INCGROUPS}
+.if !empty(${group})
+.if ${group} != "INC"
+${group}_INSTALL_OWN ?= ${INC_INSTALL_OWN}
+${group}DIR ?= ${INCDIR}
 .endif
+# incase we are staging
+STAGE_DIR.${group} ?= ${STAGE_OBJTOP}${${group}DIR}
+
+.for header in ${${group}:O:u}
+${group}_INSTALL_OWN.${header:T} ?= ${${group}_INSTALL_OWN}
+${group}DIR.${header:T} ?= ${${group}DIR}
+inc_mkdir_list += ${${group}DIR.${header:T}}
+
+.if defined(${group}NAME.${header:T})
+STAGE_AS_SETS += ${group}
+STAGE_AS_${header} = ${${group}NAME.${header:T}}
+stage_as.${group}: ${header}
+
+incinstall: incinstall.${group}.${header:T}
+incinstall.${group}.${header:T}: ${header} inc_mkdirs
+	${INSTALL} ${INC_COPY} ${${group}_INSTALL_OWN.${header:T}} -m ${INCMODE} ${.ALLSRC:Ninc_mkdirs} ${DESTDIR}${${group}DIR}/${${group}NAME.${header:T}}
+
+.else
+STAGE_SETS += ${group}
+stage_files.${group}: ${header}
+incinstall.${group}: ${header}
+incinstall: incinstall.${group}
 .endif
+
+.endfor				# header
+
+incinstall.${group}: inc_mkdirs
+	${INSTALL} ${INC_COPY} ${${group}_INSTALL_OWN} -m ${INCMODE} \
+	${.ALLSRC:Ninc_mkdirs:O:u} ${DESTDIR}${${group}DIR}
+
+.endif				# !empty
+.endfor				# group
+
+inc_mkdirs:
+	@for d in ${inc_mkdir_list:O:u}; do \
+		test -d ${DESTDIR}$$d || \
+		${INSTALL} -d ${INC_INSTALL_OWN} -m 775 ${DESTDIR}$$d; \
+	done
+
+.endif				# !target(incinstall)
+
+beforeinstall:
+realinstall:	incinstall
+.ORDER: beforeinstall incinstall

Modified: vendor/NetBSD/bmake/dist/mk/init.mk
===================================================================
--- vendor/NetBSD/bmake/dist/mk/init.mk	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/mk/init.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,4 +1,4 @@
-# $Id: init.mk,v 1.9 2013/07/18 05:46:24 sjg Exp $
+# $Id: init.mk,v 1.15 2017/05/07 20:27:54 sjg Exp $
 #
 #	@(#) Copyright (c) 2002, Simon J. Gerraty
 #
@@ -23,11 +23,14 @@
 .endif
 
 .-include <local.init.mk>
-.-include "${.CURDIR:H}/Makefile.inc"
+.-include <${.CURDIR:H}/Makefile.inc>
 .include <own.mk>
 
 .MAIN:		all
 
+# should have been set by sys.mk
+CXX_SUFFIXES?= .cc .cpp .cxx .C
+
 .if !empty(WARNINGS_SET) || !empty(WARNINGS_SET_${MACHINE_ARCH})
 .include <warnings.mk>
 .endif
@@ -47,4 +50,20 @@
 _SKIP_BUILD = not building at level 0
 .endif
 
+.if !defined(.PARSEDIR)
+# no-op is the best we can do if not bmake.
+.WAIT:
 .endif
+
+# define this once for consistency
+.if empty(_SKIP_BUILD)
+# beforebuild is a hook for things that must be done early
+all: beforebuild .WAIT realbuild
+.else
+all: .PHONY
+.warning ${_SKIP_BUILD}
+.endif
+beforebuild:
+realbuild:
+
+.endif

Modified: vendor/NetBSD/bmake/dist/mk/install-mk
===================================================================
--- vendor/NetBSD/bmake/dist/mk/install-mk	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/mk/install-mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -55,7 +55,7 @@
 #       Simon J. Gerraty <sjg at crufty.net>
 
 # RCSid:
-#	$Id: install-mk,v 1.100 2014/05/23 01:30:36 sjg Exp $
+#	$Id: install-mk,v 1.148 2017/06/30 23:46:15 sjg Exp $
 #
 #	@(#) Copyright (c) 1994 Simon J. Gerraty
 #
@@ -70,7 +70,7 @@
 #	sjg at crufty.net
 #
 
-MK_VERSION=20140522
+MK_VERSION=20170630
 OWNER=
 GROUP=
 MODE=444
@@ -176,7 +176,7 @@
 [ "$OWNER" ] && $SKIP_MKFILES Do chown $OWNER $mk_files $sys_mk_files
 # if this is a BSD system the bsd.*.mk should exist and be used.
 if [ -z "$SKIP_BSD_MK" ]; then
-	for f in dep doc init lib links man nls obj own prog subdir
+	for f in dep doc files inc init lib links man nls obj own prog subdir
 	do
 		b=bsd.$f.mk
 		[ -s $b ] || Do ln -s $f.mk $b

Modified: vendor/NetBSD/bmake/dist/mk/lib.mk
===================================================================
--- vendor/NetBSD/bmake/dist/mk/lib.mk	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/mk/lib.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,4 +1,4 @@
-# $Id: lib.mk,v 1.51 2014/05/23 01:30:36 sjg Exp $
+# $Id: lib.mk,v 1.62 2017/06/11 03:24:04 sjg Exp $
 
 .if !target(__${.PARSEFILE}__)
 __${.PARSEFILE}__:
@@ -9,44 +9,35 @@
 NEED_SOLINKS?= yes
 .endif
 
-.if exists(${.CURDIR}/shlib_version)
-SHLIB_MAJOR != . ${.CURDIR}/shlib_version ; echo $$major
-SHLIB_MINOR != . ${.CURDIR}/shlib_version ; echo $$minor
+SHLIB_VERSION_FILE?= ${.CURDIR}/shlib_version
+.if !defined(SHLIB_MAJOR) && exists(${SHLIB_VERSION_FILE})
+SHLIB_MAJOR != . ${SHLIB_VERSION_FILE} ; echo $$major
+SHLIB_MINOR != . ${SHLIB_VERSION_FILE} ; echo $$minor
+SHLIB_TEENY != . ${SHLIB_VERSION_FILE} ; echo $$teeny
 .endif
 
-print-shlib-major:
-.if defined(SHLIB_MAJOR) && ${MK_PIC} != "no"
-	@echo ${SHLIB_MAJOR}
+.for x in major minor teeny
+print-shlib-$x:
+.if defined(SHLIB_${x:tu}) && ${MK_PIC} != "no"
+	@echo ${SHLIB_${x:tu}}
 .else
 	@false
 .endif
+.endfor
 
-print-shlib-minor:
-.if defined(SHLIB_MINOR) && ${MK_PIC} != "no"
-	@echo ${SHLIB_MINOR}
-.else
-	@false
-.endif
-
-print-shlib-teeny:
-.if defined(SHLIB_TEENY) && ${MK_PIC} != "no"
-	@echo ${SHLIB_TEENY}
-.else
-	@false
-.endif
-
 SHLIB_FULLVERSION ?= ${${SHLIB_MAJOR} ${SHLIB_MINOR} ${SHLIB_TEENY}:L:ts.}
 SHLIB_FULLVERSION := ${SHLIB_FULLVERSION}
 
 # add additional suffixes not exported.
 # .po is used for profiling object files.
-# .so is used for PIC object files.
-.SUFFIXES: .out .a .ln .so .po .o .s .S .c .cc .C .m .F .f .r .y .l .cl .p .h
+# ${PICO} is used for PIC object files.
+PICO?= .pico
+.SUFFIXES: .out .a .ln ${PICO} .po .o .s .S .c .cc .C .m .F .f .r .y .l .cl .p .h
 .SUFFIXES: .sh .m4 .m
 
 CFLAGS+=	${COPTS}
 
-# Derrived from NetBSD-1.6
+# Originally derrived from NetBSD-1.6
 
 # Set PICFLAGS to cc flags for producing position-independent code,
 # if not already set.  Includes -DPIC, if required.
@@ -62,12 +53,12 @@
 #			with ELF, also set shared-lib version for ld.so.
 # SHLIB_LDSTARTFILE:	support .o file, call C++ file-level constructors
 # SHLIB_LDENDFILE:	support .o file, call C++ file-level destructors
-# FPICFLAGS:		flags for ${FC} to compile .[fF] files to .so objects.
+# FPICFLAGS:		flags for ${FC} to compile .[fF] files to ${PICO} objects.
 # CPPICFLAGS:		flags for ${CPP} to preprocess .[sS] files for ${AS}
-# CPICFLAGS:		flags for ${CC} to compile .[cC] files to .so objects.
+# CPICFLAGS:		flags for ${CC} to compile .[cC] files to ${PICO} objects.
 # CAPICFLAGS		flags for {$CC} to compiling .[Ss] files
 #		 	(usually just ${CPPPICFLAGS} ${CPICFLAGS})
-# APICFLAGS:		flags for ${AS} to assemble .[sS] to .so objects.
+# APICFLAGS:		flags for ${AS} to assemble .[sS] to ${PICO} objects.
 
 .if ${TARGET_OSNAME} == "NetBSD"
 .if ${MACHINE_ARCH} == "alpha"
@@ -162,7 +153,7 @@
 LD_so=sl
 DLLIB=
 # HPsUX lorder does not grok anything but .o
-LD_sobjs=`${LORDER} ${OBJS} | ${TSORT} | sed 's,\.o,.so,'`
+LD_sobjs=`${LORDER} ${OBJS} | ${TSORT} | sed 's,\.o,${PICO},'`
 LD_pobjs=`${LORDER} ${OBJS} | ${TSORT} | sed 's,\.o,.po,'`
 .elif ${TARGET_OSNAME} == "OSF1"
 LD_shared= -msym -shared -expect_unresolved '*'
@@ -169,7 +160,7 @@
 LD_solib= -all lib${LIB}_pic.a
 DLLIB=
 # lorder does not grok anything but .o
-LD_sobjs=`${LORDER} ${OBJS} | ${TSORT} | sed 's,\.o,.so,'`
+LD_sobjs=`${LORDER} ${OBJS} | ${TSORT} | sed 's,\.o,${PICO},'`
 LD_pobjs=`${LORDER} ${OBJS} | ${TSORT} | sed 's,\.o,.po,'`
 AR_cq= -cqs
 .elif ${TARGET_OSNAME} == "FreeBSD"
@@ -250,11 +241,11 @@
 DLLIB ?= -ldl
 .endif
 
-# some libs have lots of objects, and scanning all .o, .po and .So meta files
+# some libs have lots of objects, and scanning all .o, .po and ${PICO} meta files
 # is a waste of time, this tells meta.autodep.mk to just pick one 
-# (typically .So)
+# (typically ${PICO})
 # yes, 42 is a random number.
-.if ${MK_META_MODE} == "yes" && ${SRCS:Uno:[\#]} > 42
+.if ${MK_DIRDEPS_BUILD} == "yes" && ${SRCS:Uno:[\#]} > 42
 OPTIMIZE_OBJECT_META_FILES ?= yes
 .endif
 
@@ -273,47 +264,43 @@
 	${COMPILE.c} ${.IMPSRC}
 
 # for the normal .a we do not want to strip symbols
-.cc.o .C.o:
+${CXX_SUFFIXES:%=%.o}:
 	${COMPILE.cc} ${.IMPSRC}
 
 .S.o .s.o:
-	@echo ${COMPILE.S} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC}
-	@${COMPILE.S} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} 
+	${COMPILE.S} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} 
 
 .if (${LD_X} == "")
 .c.po:
 	${COMPILE.c} ${CC_PG} ${PROFFLAGS} ${.IMPSRC} -o ${.TARGET}
 
-.cc.po .C.po:
+${CXX_SUFFIXES:%=%.po}:
 	${COMPILE.cc} -pg ${.IMPSRC} -o ${.TARGET}
 
-.S.so .s.so:
+.S${PICO} .s${PICO}:
 	${COMPILE.S} ${PICFLAG} ${CC_PIC} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}
 .else
 .c.po:
-	@echo ${COMPILE.c} ${CC_PG} ${PROFFLAGS} ${.IMPSRC} -o ${.TARGET}
-	@${COMPILE.c} ${CC_PG} ${PROFFLAGS} ${.IMPSRC} -o ${.TARGET}.o
+	${COMPILE.c} ${CC_PG} ${PROFFLAGS} ${.IMPSRC} -o ${.TARGET}.o
 	@${LD} ${LD_X} ${LD_r} ${.TARGET}.o -o ${.TARGET}
 	@rm -f ${.TARGET}.o
 
-.cc.po .C.po:
-	@echo ${COMPILE.cc} ${CXX_PG} ${PROFFLAGS} ${.IMPSRC} -o ${.TARGET}
-	@${COMPILE.cc} ${CXX_PG} ${.IMPSRC} -o ${.TARGET}.o
-	@${LD} ${LD_X} ${LD_r} ${.TARGET}.o -o ${.TARGET}
+${CXX_SUFFIXES:%=%.po}:
+	${COMPILE.cc} ${CXX_PG} ${.IMPSRC} -o ${.TARGET}.o
+	${LD} ${LD_X} ${LD_r} ${.TARGET}.o -o ${.TARGET}
 	@rm -f ${.TARGET}.o
 
-.S.so .s.so:
-	@echo ${COMPILE.S} ${PICFLAG} ${CC_PIC} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}
-	@${COMPILE.S} ${PICFLAG} ${CC_PIC} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}.o
-	@${LD} ${LD_x} ${LD_r} ${.TARGET}.o -o ${.TARGET}
+.S${PICO} .s${PICO}:
+	${COMPILE.S} ${PICFLAG} ${CC_PIC} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}.o
+	${LD} ${LD_x} ${LD_r} ${.TARGET}.o -o ${.TARGET}
 	@rm -f ${.TARGET}.o
 .endif
 
 .if (${LD_x} == "")
-.c.so:
+.c${PICO}:
 	${COMPILE.c} ${PICFLAG} ${CC_PIC} ${.IMPSRC} -o ${.TARGET}
 
-.cc.so .C.so:
+${CXX_SUFFIXES:%=%${PICO}}:
 	${COMPILE.cc} ${PICFLAG} ${CC_PIC} ${.IMPSRC} -o ${.TARGET}
 
 .S.po .s.po:
@@ -320,22 +307,19 @@
 	${COMPILE.S} ${PROFFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}
 .else
 
-.c.so:
-	@echo ${COMPILE.c} ${PICFLAG} ${CC_PIC} ${.IMPSRC} -o ${.TARGET}
-	@${COMPILE.c} ${PICFLAG} ${CC_PIC} ${.IMPSRC} -o ${.TARGET}.o
-	@${LD} ${LD_x} ${LD_r} ${.TARGET}.o -o ${.TARGET}
+.c${PICO}:
+	${COMPILE.c} ${PICFLAG} ${CC_PIC} ${.IMPSRC} -o ${.TARGET}.o
+	${LD} ${LD_x} ${LD_r} ${.TARGET}.o -o ${.TARGET}
 	@rm -f ${.TARGET}.o
 
-.cc.so .C.so:
-	@echo ${COMPILE.cc} ${PICFLAG} ${CC_PIC} ${.IMPSRC} -o ${.TARGET}
-	@${COMPILE.cc} ${PICFLAG} ${CC_PIC} ${.IMPSRC} -o ${.TARGET}.o
-	@${LD} ${LD_x} ${LD_r} ${.TARGET}.o -o ${.TARGET}
+${CXX_SUFFIXES:%=%${PICO}}:
+	${COMPILE.cc} ${PICFLAG} ${CC_PIC} ${.IMPSRC} -o ${.TARGET}.o
+	${LD} ${LD_x} ${LD_r} ${.TARGET}.o -o ${.TARGET}
 	@rm -f ${.TARGET}.o
 
 .S.po .s.po:
-	@echo ${COMPILE.S} ${PROFFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}
-	@${COMPILE.S} ${PROFFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}.o
-	@${LD} ${LD_X} ${LD_r} ${.TARGET}.o -o ${.TARGET}
+	${COMPILE.S} ${PROFFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}.o
+	${LD} ${LD_X} ${LD_r} ${.TARGET}.o -o ${.TARGET}
 	@rm -f ${.TARGET}.o
 
 .endif
@@ -384,19 +368,18 @@
 .include <dpadd.mk>
 .endif
 
+.if empty(LIB)
+_LIBS=
+.endif
+
 .if !defined(_SKIP_BUILD)
-all: prebuild .WAIT ${_LIBS} 
-# a hook for things that must be done early
-prebuild:
-.if !defined(.PARSEDIR)
-# no-op is the best we can do if not bmake.
-.WAIT:
+realbuild: ${_LIBS} 
 .endif
-.endif
+
 all: _SUBDIRUSE
 
 .for s in ${SRCS:N*.h:M*/*}
-${.o .so .po .lo:L:@o@${s:T:R}$o@}: $s
+${.o ${PICO} .po .lo:L:@o@${s:T:R}$o@}: $s
 .endfor
 
 OBJS+=	${SRCS:T:N*.h:R:S/$/.o/g}
@@ -428,7 +411,7 @@
 .else  # MK_LIBTOOL=yes
 
 lib${LIB}.a:: ${OBJS}
-	@echo building standard ${LIB} library
+	@${META_NOECHO} building standard ${LIB} library
 	@rm -f ${.TARGET}
 	@${AR} ${AR_cq} ${.TARGET} ${LD_objs}
 	${RANLIB} ${.TARGET}
@@ -436,15 +419,15 @@
 POBJS+=	${OBJS:.o=.po}
 .NOPATH:	${POBJS}
 lib${LIB}_p.a:: ${POBJS}
-	@echo building profiled ${LIB} library
+	@${META_NOECHO} building profiled ${LIB} library
 	@rm -f ${.TARGET}
 	@${AR} ${AR_cq} ${.TARGET} ${LD_pobjs}
 	${RANLIB} ${.TARGET}
 
-SOBJS+=	${OBJS:.o=.so}
+SOBJS+=	${OBJS:.o=${PICO}}
 .NOPATH:	${SOBJS}
 lib${LIB}_pic.a:: ${SOBJS}
-	@echo building shared object ${LIB} library
+	@${META_NOECHO} building shared object ${LIB} library
 	@rm -f ${.TARGET}
 	@${AR} ${AR_cq} ${.TARGET} ${LD_sobjs}
 	${RANLIB} ${.TARGET}
@@ -454,7 +437,7 @@
 # bound to be non-portable...
 # this is known to work for NetBSD 1.6 and FreeBSD 4.2
 lib${LIB}.${LD_so}: ${SOLIB} ${DPADD}
-	@echo building shared ${LIB} library \(version ${SHLIB_FULLVERSION}\)
+	@${META_NOECHO} building shared ${LIB} library \(version ${SHLIB_FULLVERSION}\)
 	@rm -f ${.TARGET}
 .if ${TARGET_OSNAME} == "NetBSD" || ${TARGET_OSNAME} == "FreeBSD"
 .if ${OBJECT_FMT} == "ELF"
@@ -478,7 +461,7 @@
 .NOPATH:	${LOBJS}
 LLIBS?=	-lc
 llib-l${LIB}.ln: ${LOBJS}
-	@echo building llib-l${LIB}.ln
+	@${META_NOECHO} building llib-l${LIB}.ln
 	@rm -f llib-l${LIB}.ln
 	@${LINT} -C${LIB} ${LOBJS} ${LLIBS}
 
@@ -502,7 +485,7 @@
 .if defined(SRCS) && (!defined(MKDEP) || ${MKDEP} != autodep)
 afterdepend: .depend
 	@(TMP=/tmp/_depend$$$$; \
-	    sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.po \1.so \1.ln:/' \
+	    sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.po \1${PICO} \1.ln:/' \
 	      < .depend > $$TMP; \
 	    mv $$TMP .depend)
 .endif
@@ -518,10 +501,8 @@
 
 .include <links.mk>
 
-.if !target(realinstall)
+.if !target(libinstall) && !empty(LIB)
 realinstall: libinstall
-.endif
-.if !target(libinstall)
 libinstall:
 	[ -d ${DESTDIR}/${LIBDIR} ] || \
 	${INSTALL} -d ${LIB_INSTALL_OWN} -m 775 ${DESTDIR}${LIBDIR}
@@ -561,12 +542,19 @@
 .endif
 .endif
 
+.if ${MK_MAN} != "no"
 install: maninstall _SUBDIRUSE
 maninstall: afterinstall
+.endif
 afterinstall: realinstall
+libinstall: beforeinstall
 realinstall: beforeinstall
 .endif
 
+.if defined(FILES) || defined(FILESGROUPS)
+.include <files.mk>
+.endif
+
 .if ${MK_MAN} != "no"
 .include <man.mk>
 .endif
@@ -599,5 +587,10 @@
 .endfor
 	@touch ${.TARGET}
 
+.if !empty(LIB)
+STAGE_LIBDIR?= ${STAGE_OBJTOP}${LIBDIR}
+stage_libs: ${_LIBS}
+.endif
+
 .include <final.mk>
 .endif

Modified: vendor/NetBSD/bmake/dist/mk/libnames.mk
===================================================================
--- vendor/NetBSD/bmake/dist/mk/libnames.mk	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/mk/libnames.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,4 +1,4 @@
-# $Id: libnames.mk,v 1.7 2009/12/25 07:34:03 sjg Exp $
+# $Id: libnames.mk,v 1.8 2016/04/05 15:58:37 sjg Exp $
 #
 #	@(#) Copyright (c) 2007-2009, Simon J. Gerraty
 #
@@ -16,7 +16,7 @@
 DLIBEXT ?= .a
 DSHLIBEXT ?= .so
 
-.-include "local.libnames.mk"
-.-include "sjg.libnames.mk"
-.-include "fwall.libnames.mk"
-.-include "host.libnames.mk"
+.-include <local.libnames.mk>
+.-include <sjg.libnames.mk>
+.-include <fwall.libnames.mk>
+.-include <host.libnames.mk>

Modified: vendor/NetBSD/bmake/dist/mk/links.mk
===================================================================
--- vendor/NetBSD/bmake/dist/mk/links.mk	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/mk/links.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,4 +1,4 @@
-# $Id: links.mk,v 1.5 2005/07/11 18:01:05 sjg Exp $
+# $Id: links.mk,v 1.6 2014/09/29 17:14:40 sjg Exp $
 #
 #	@(#) Copyright (c) 2005, Simon J. Gerraty
 #
@@ -22,10 +22,15 @@
 
 __SYMLINK_SCRIPT= \
 		${ECHO} "$$t -> $$l"; \
-		mkdir -p `dirname $$t`; \
-		rm -f $$t; \
-		${LN} -s $$l $$t
+		case `'ls' -l $$t 2> /dev/null` in \
+		*"> $$l") ;; \
+		*) \
+			mkdir -p `dirname $$t`; \
+			rm -f $$t; \
+			${LN} -s $$l $$t;; \
+		esac
 
+
 __LINK_SCRIPT= \
 		${ECHO} "$$t -> $$l"; \
 		mkdir -p `dirname $$t`; \

Added: vendor/NetBSD/bmake/dist/mk/manifest.mk
===================================================================
--- vendor/NetBSD/bmake/dist/mk/manifest.mk	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/mk/manifest.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,66 @@
+# $Id: manifest.mk,v 1.2 2014/10/31 18:06:17 sjg Exp $
+#
+#	@(#) Copyright (c) 2014, Simon J. Gerraty
+#
+#	This file is provided in the hope that it will
+#	be of use.  There is absolutely NO WARRANTY.
+#	Permission to copy, redistribute or otherwise
+#	use this file is hereby granted provided that 
+#	the above copyright notice and this notice are
+#	left intact. 
+#      
+#	Please send copies of changes and bug-fixes to:
+#	sjg at crufty.net
+#
+
+# generate mtree style manifest supported by makefs in FreeBSD
+
+# input looks like
+# MANIFEST= my.mtree
+# for each MANIFEST we have a list of dirs
+# ${MANIFEST}.DIRS += bin sbin usr/bin ...
+# for each dir we have a ${MANIFEST}.SRCS.$dir
+# that provides the absolute path to the contents
+# ${MANIFEST}.SRCS.bin += ${OBJTOP}/bin/sh/sh 
+# ${MANIFEST}.SYMLINKS is a list of src target pairs
+# for each file/dir there are a number of attributes
+# UID GID MODE FLAGS
+# which can be set per dir, per file or we use defaults
+# eg.  
+# MODE.sbin = 550
+# MODE.usr/sbin = 550
+# MODE.dirs = 555
+# means that sbin and usr/sbin get 550 all other dirs get 555
+# MODE.usr/bin/passwd = 4555
+# MODE.usr/bin.files = 555
+# MODE.usr/sbin.files = 500
+# means passwd gets 4555 other files in usr/bin get 555 and
+# files in usr/sbin get 500
+# STORE defaults to basename of src and target directory
+# but we can use 
+# ${MANIFEST}.SRCS.sbin += ${OBJTOP}/bin/sh-static/sh-static
+# STORE.sbin/sh-static = sbin/sh
+#
+# the above is a little overkill but means we can easily adapt to
+# different formats
+
+UID.dirs ?= 0
+GID.dirs ?= 0
+MODE.dirs ?= 775
+FLAGS.dirs ?= 
+
+UID.files ?= 0
+GID.files ?= 0
+MODE.files ?= 555
+
+# a is attribute name d is dirname
+M_DIR_ATTR = L:@a@$${$$a.$$d:U$${$$a.dirs}}@
+# as above and s is set to the name we store f as
+M_FILE_ATTR = L:@a@$${$$a.$$s:U$${$$a.$$d.files:U$${$$a.files}}}@
+
+# this produces the body of the manifest
+# there should typically be a header prefixed
+_GEN_MTREE_MANIFEST_USE: .USE
+	@(${${.TARGET}.DIRS:O:u:@d at echo '$d type=dir uid=${UID:${M_DIR_ATTR}} gid=${GID:${M_DIR_ATTR}} mode=${MODE:${M_DIR_ATTR}} ${FLAGS:${M_DIR_ATTR}}';@} \
+	${${.TARGET}.DIRS:O:u:@d@${${.TARGET}.SRCS.$d:O:u:@f at echo '${s::=${STORE.$d/${f:T}:U$d/${f:T}}}$s contents="$f" type=file uid=${UID:${M_FILE_ATTR}} gid=${GID:${M_FILE_ATTR}} mode=${MODE:${M_FILE_ATTR}} ${FLAGS:${M_FILE_ATTR}}';@}@} \
+	set ${${.TARGET}.SYMLINKS}; while test $$# -ge 2; do echo "$$2 type=link link=$$1"; shift 2; done) > ${.TARGET}

Modified: vendor/NetBSD/bmake/dist/mk/meta.autodep.mk
===================================================================
--- vendor/NetBSD/bmake/dist/mk/meta.autodep.mk	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/mk/meta.autodep.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,4 +1,4 @@
-# $Id: meta.autodep.mk,v 1.35 2014/05/09 00:05:46 sjg Exp $
+# $Id: meta.autodep.mk,v 1.45 2016/06/03 17:22:32 sjg Exp $
 
 #
 #	@(#) Copyright (c) 2010, Simon J. Gerraty
@@ -18,7 +18,7 @@
 .if !target(__${_this}__)
 __${_this}__: .NOTMAIN
 
-.-include "local.autodep.mk"
+.-include <local.autodep.mk>
 
 .if defined(SRCS)
 # it would be nice to be able to query .SUFFIXES
@@ -50,8 +50,26 @@
 .endif
 
 _CURDIR ?= ${.CURDIR}
+_OBJDIR ?= ${.OBJDIR}
+_OBJTOP ?= ${OBJTOP}
+_OBJROOT ?= ${OBJROOT:U${_OBJTOP}}
 _DEPENDFILE := ${_CURDIR}/${.MAKE.DEPENDFILE:T}
 
+.if ${.MAKE.LEVEL} > 0 || ${BUILD_AT_LEVEL0:Uyes:tl} == "yes"
+# do not allow auto update if we ever built this dir without filemon
+NO_FILEMON_COOKIE = .nofilemon
+CLEANFILES += ${NO_FILEMON_COOKIE}
+.if ${.MAKE.MODE:Uno:Mnofilemon} != ""
+UPDATE_DEPENDFILE = NO
+all: ${NO_FILEMON_COOKIE}
+${NO_FILEMON_COOKIE}: .NOMETA
+	@echo UPDATE_DEPENDFILE=NO > ${.TARGET}
+.elif exists(${NO_FILEMON_COOKIE})
+UPDATE_DEPENDFILE = NO
+.warning ${RELDIR} built with nofilemon; UPDATE_DEPENDFILE=NO
+.endif
+.endif
+
 .if ${.MAKE.LEVEL} == 0
 .if ${BUILD_AT_LEVEL0:Uyes:tl} == "no"
 UPDATE_DEPENDFILE = NO
@@ -83,7 +101,7 @@
 .endif
 
 .if ${WANT_UPDATE_DEPENDFILE:Uno:tl} != "no"
-.if ${.MAKE.MODE:Mmeta*} == "" || ${.MAKE.MODE:M*read*} != ""
+.if ${.MAKE.MODE:Uno:Mmeta*} == "" || ${.MAKE.MODE:Uno:M*read*} != ""
 UPDATE_DEPENDFILE = no
 .endif
 
@@ -97,6 +115,8 @@
 # for example the result of running configure
 # just make sure this is not empty
 META_FILE_FILTER ?= N.meta
+# never consider these
+META_FILE_FILTER += Ndirdeps.cache*
 
 .if !empty(DPADD)
 # if we have any non-libs in DPADD, 
@@ -188,9 +208,9 @@
 # anything which matches ${_OBJROOT}* but not ${_OBJTOP}*
 # needs to be qualified in DIRDEPS
 # The pseudo machine "host" is used for HOST_TARGET
-DIRDEPS = \
+DIRDEPS += \
 	${DPADD:M${_OBJTOP}*:H:C,${_OBJTOP}[^/]*/,,:N.:O:u} \
-	${DPADD:M${_OBJROOT}*:N${_OBJTOP}*:H:S,${_OBJROOT},,:C,^([^/]+)/(.*),\2.\1,:S,${HOST_TARGET}$,host,:N.*:O:u}
+	${DPADD:M${_OBJROOT}*:N${_OBJTOP}*:N${STAGE_ROOT:U${_OBJTOP}}/*:H:S,${_OBJROOT},,:C,^([^/]+)/(.*),\2.\1,:S,${HOST_TARGET}$,host,:N.*:O:u}
 
 .endif
 .endif
@@ -246,7 +266,7 @@
 	DPADD='${FORCE_DPADD:O:u}' ${_gendirdeps_mutex} \
 	MAKESYSPATH=${_makesyspath} \
 	${.MAKE} -f gendirdeps.mk RELDIR=${RELDIR} _DEPENDFILE=${_DEPENDFILE} \
-	META_FILES='${META_XTRAS:T:O:u} ${META_FILES:T:O:u:${META_FILE_FILTER:ts:}}')
+	META_FILES='${META_XTRAS:O:u} ${META_FILES:T:O:u:${META_FILE_FILTER:ts:}}')
 	@test -s $@ && touch $@; :
 .endif
 
@@ -254,6 +274,9 @@
 .endif
 
 .if ${_bootstrap_dirdeps} == "yes"
+.if ${BUILD_AT_LEVEL0:Uno} == "no"
+DIRDEPS+= ${RELDIR}.${TARGET_SPEC:U${MACHINE}}
+.endif
 # make sure this is included at least once
 .include <dirdeps.mk>
 .else

Modified: vendor/NetBSD/bmake/dist/mk/meta.stage.mk
===================================================================
--- vendor/NetBSD/bmake/dist/mk/meta.stage.mk	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/mk/meta.stage.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,6 +1,6 @@
-# $Id: meta.stage.mk,v 1.30 2013/04/19 16:32:57 sjg Exp $
+# $Id: meta.stage.mk,v 1.54 2017/07/06 23:20:33 sjg Exp $
 #
-#	@(#) Copyright (c) 2011, Simon J. Gerraty
+#	@(#) Copyright (c) 2011-2017, Simon J. Gerraty
 #
 #	This file is provided in the hope that it will
 #	be of use.  There is absolutely NO WARRANTY.
@@ -13,8 +13,10 @@
 #	sjg at crufty.net
 #
 
+.ifndef NO_STAGING
+
 .if !target(__${.PARSEFILE}__)
-__${.PARSEFILE}__:
+# the guard target is defined later
 
 .if ${.MAKE.DEPENDFILE_PREFERENCE:U${.MAKE.DEPENDFILE}:M*.${MACHINE}} != ""
 # this is generally safer anyway
@@ -23,8 +25,10 @@
 _dirdep = ${RELDIR}
 .endif
 
+CLEANFILES+= .dirdep
+
 # this allows us to trace dependencies back to their src dir
-.dirdep:
+.dirdep:	.NOPATH
 	@echo '${_dirdep}' > $@
 
 .if defined(NO_POSIX_SHELL) || ${type printf:L:sh:Mbuiltin} == ""
@@ -35,7 +39,13 @@
 _stage_target_dirname = $${t%/*}
 .endif
 
+_OBJROOT ?= ${OBJROOT:U${OBJTOP:H}}
+.if ${_OBJROOT:M*/} != ""
+_objroot ?= ${_OBJROOT:tA}/
+.else
 _objroot ?= ${_OBJROOT:tA}
+.endif
+
 # make sure this is global
 _STAGED_DIRS ?=
 .export _STAGED_DIRS
@@ -46,13 +56,22 @@
 # convert _STAGED_DIRS into suitable filters
 GENDIRDEPS_FILTER += Nnot-empty-is-important \
 	${_STAGED_DIRS:O:u:M${OBJTOP}*:S,${OBJTOP}/,N,} \
-	${_STAGED_DIRS:O:u:N${OBJTOP}*:S,${_objroot},,:C,^([^/]+)/(.*),N\2.\1,:S,${HOST_TARGET},.host,}
+	${_STAGED_DIRS:O:u:M${_objroot}*:N${OBJTOP}*:S,${_objroot},,:C,^([^/]+)/(.*),N\2.\1,:S,${HOST_TARGET},.host,}
 
 LN_CP_SCRIPT = LnCp() { \
   rm -f $$2 2> /dev/null; \
-  ln $$1 $$2 2> /dev/null || \
+  { [ -z "$$mode" ] && ${LN:Uln} $$1 $$2 2> /dev/null; } || \
   cp -p $$1 $$2; }
 
+# a staging conflict should cause an error
+# a warning is handy when bootstapping different options.
+STAGE_CONFLICT?= ERROR
+.if ${STAGE_CONFLICT:tl} == "error"
+STAGE_CONFLICT_ACTION= exit 1;
+.else
+STAGE_CONFLICT_ACTION=
+.endif
+
 # it is an error for more than one src dir to try and stage
 # the same file
 STAGE_DIRDEP_SCRIPT = ${LN_CP_SCRIPT}; StageDirdep() { \
@@ -59,8 +78,8 @@
   t=$$1; \
   if [ -s $$t.dirdep ]; then \
 	cmp -s .dirdep $$t.dirdep && return; \
-	echo "ERROR: $$t installed by `cat $$t.dirdep` not ${_dirdep}" >&2; \
-	exit 1; \
+	echo "${STAGE_CONFLICT}: $$t installed by `cat $$t.dirdep` not ${_dirdep}" >&2; \
+	${STAGE_CONFLICT_ACTION} \
   fi; \
   LnCp .dirdep $$t.dirdep || exit 1; }
 
@@ -110,33 +129,51 @@
   done; :; }
 
 # this is simple, a list of the "staged" files depends on this,
-_STAGE_BASENAME_USE:	.USE ${.TARGET:T}
+_STAGE_BASENAME_USE:	.USE .dirdep ${.TARGET:T}
 	@${STAGE_FILE_SCRIPT}; StageFiles ${.TARGET:H:${STAGE_DIR_FILTER}} ${.TARGET:T}
 
+_STAGE_AS_BASENAME_USE:        .USE .dirdep ${.TARGET:T}
+	@${STAGE_AS_SCRIPT}; StageAs ${.TARGET:H:${STAGE_DIR_FILTER}} ${.TARGET:T} ${STAGE_AS_${.TARGET:T}:U${.TARGET:T}}
+
+
+.endif				# first time
+
+
 .if !empty(STAGE_INCSDIR)
+.if !empty(STAGE_INCS)
+stage_incs: ${STAGE_INCS}
+.endif
+.if target(stage_incs) || !empty(.ALLTARGETS:Mstage_includes)
 STAGE_TARGETS += stage_incs
-STAGE_INCS ?= ${.ALLSRC:N.dirdep}
-
+STAGE_INCS ?= ${.ALLSRC:N.dirdep:Nstage_*}
+stage_includes: stage_incs
 stage_incs:	.dirdep
 	@${STAGE_FILE_SCRIPT}; StageFiles ${STAGE_INCSDIR:${STAGE_DIR_FILTER}} ${STAGE_INCS}
 	@touch $@
+
 .endif
+.endif
 
 .if !empty(STAGE_LIBDIR)
+.if !empty(STAGE_LIBS)
+stage_libs: ${STAGE_LIBS}
+.endif
+.if target(stage_libs)
 STAGE_TARGETS += stage_libs
-
-STAGE_LIBS ?= ${.ALLSRC:N.dirdep}
-
+STAGE_LIBS ?= ${.ALLSRC:N.dirdep:Nstage_*}
 stage_libs:	.dirdep
 	@${STAGE_FILE_SCRIPT}; StageFiles ${STAGE_LIBDIR:${STAGE_DIR_FILTER}} ${STAGE_LIBS}
+.if !defined(NO_SHLIB_LINKS)
 .if !empty(SHLIB_LINKS)
 	@${STAGE_LINKS_SCRIPT}; StageLinks -s ${STAGE_LIBDIR:${STAGE_DIR_FILTER}} \
 	${SHLIB_LINKS:@t@${STAGE_LIBS:T:M$t.*} $t@}
 .elif !empty(SHLIB_LINK) && !empty(SHLIB_NAME)
-	@${STAGE_LINKS_SCRIPT}; StageLinks -s ${STAGE_LIBDIR:${STAGE_DIR_FILTER}} ${SHLIB_NAME} ${SHLIB_LINK} ${SYMLINKS:T}
+	@${STAGE_LINKS_SCRIPT}; StageLinks -s ${STAGE_LIBDIR:${STAGE_DIR_FILTER}} ${SHLIB_NAME} ${SHLIB_LINK}
 .endif
+.endif
 	@touch $@
 .endif
+.endif
 
 .if !empty(STAGE_DIR)
 STAGE_SETS += _default
@@ -146,8 +183,6 @@
 STAGE_FILES._default = ${STAGE_FILES}
 STAGE_LINKS._default = ${STAGE_LINKS}
 STAGE_SYMLINKS._default = ${STAGE_SYMLINKS}
-STAGE_FILES ?= ${.ALLSRC:N.dirdep:Nstage_*}
-STAGE_SYMLINKS ?= ${.ALLSRC:T:N.dirdep:Nstage_*}
 .endif
 
 .if !empty(STAGE_SETS)
@@ -155,22 +190,34 @@
 
 # some makefiles need to populate multiple directories
 .for s in ${STAGE_SETS:O:u}
-STAGE_FILES.$s ?= ${.ALLSRC:N.dirdep}
-STAGE_SYMLINKS.$s ?= ${.ALLSRC:N.dirdep}
-STAGE_LINKS_DIR.$s ?= ${STAGE_OBJTOP}
-STAGE_SYMLINKS_DIR.$s ?= ${STAGE_OBJTOP}
-
+.if !empty(STAGE_FILES.$s)
+stage_files.$s: ${STAGE_FILES.$s}
+.endif
+.if target(stage_files.$s) || target(stage_files${s:S,^,.,:N._default})
 STAGE_TARGETS += stage_files
+STAGE_FILES.$s ?= ${.ALLSRC:N.dirdep:Nstage_*}
+.if !target(.stage_files.$s)
+.stage_files.$s:
 .if $s != "_default"
 stage_files:	stage_files.$s
 stage_files.$s:	.dirdep
 .else
+STAGE_FILES ?= ${.ALLSRC:N.dirdep:Nstage_*}
 stage_files:	.dirdep
 .endif
 	@${STAGE_FILE_SCRIPT}; StageFiles ${FLAGS.$@} ${STAGE_FILES_DIR.$s:U${STAGE_DIR.$s}:${STAGE_DIR_FILTER}} ${STAGE_FILES.$s}
 	@touch $@
+.endif
+.endif
 
+.if !empty(STAGE_LINKS.$s)
+stage_links.$s:
+.endif
+.if target(stage_links.$s) || target(stage_links${s:S,^,.,:N._default})
+STAGE_LINKS_DIR.$s ?= ${STAGE_OBJTOP}
 STAGE_TARGETS += stage_links
+.if !target(.stage_links.$s)
+.stage_links.$s:
 .if $s != "_default"
 stage_links:	stage_links.$s
 stage_links.$s:	.dirdep
@@ -179,8 +226,17 @@
 .endif
 	@${STAGE_LINKS_SCRIPT}; StageLinks ${STAGE_LINKS_DIR.$s:U${STAGE_DIR.$s}:${STAGE_DIR_FILTER}} ${STAGE_LINKS.$s}
 	@touch $@
+.endif
+.endif
 
+.if !empty(STAGE_SYMLINKS.$s)
+stage_symlinks.$s:
+.endif
+.if target(stage_symlinks.$s) || target(stage_symlinks${s:S,^,.,:N._default})
+STAGE_SYMLINKS_DIR.$s ?= ${STAGE_OBJTOP}
 STAGE_TARGETS += stage_symlinks
+.if !target(.stage_symlinks.$s)
+.stage_symlinks.$s:
 .if $s != "_default"
 stage_symlinks:	stage_symlinks.$s
 stage_symlinks.$s:	.dirdep
@@ -189,6 +245,8 @@
 .endif
 	@${STAGE_LINKS_SCRIPT}; StageLinks -s ${STAGE_SYMLINKS_DIR.$s:U${STAGE_DIR.$s}:${STAGE_DIR_FILTER}} ${STAGE_SYMLINKS.$s}
 	@touch $@
+.endif
+.endif
 
 .endfor
 .endif
@@ -196,37 +254,70 @@
 .if !empty(STAGE_AS_SETS)
 CLEANFILES += ${STAGE_AS_SETS:@s at stage*$s@}
 
-STAGE_TARGETS += stage_as
-
 # sometimes things need to be renamed as they are staged
 # each ${file} will be staged as ${STAGE_AS_${file:T}}
 # one could achieve the same with SYMLINKS
+# stage_as_and_symlink makes the original name a symlink to the new name
+# it is the same as using stage_as and stage_symlinks but ensures
+# both operations happen together
 .for s in ${STAGE_AS_SETS:O:u}
-STAGE_AS.$s ?= ${.ALLSRC:N.dirdep}
-
+.if !empty(STAGE_AS.$s)
+stage_as.$s: ${STAGE_AS.$s}
+.endif
+.if target(stage_as.$s)
+STAGE_TARGETS += stage_as
+STAGE_AS.$s ?= ${.ALLSRC:N.dirdep:Nstage_*}
+.if !target(.stage_as.$s)
+.stage_as.$s:
 stage_as:	stage_as.$s
 stage_as.$s:	.dirdep
-	@${STAGE_AS_SCRIPT}; StageAs ${FLAGS.$@} ${STAGE_FILES_DIR.$s:U${STAGE_DIR.$s}:${STAGE_DIR_FILTER}} ${STAGE_AS.$s:@f@$f ${STAGE_AS_${f:T}:U${f:T}}@}
+	@${STAGE_AS_SCRIPT}; StageAs ${FLAGS.$@} ${STAGE_FILES_DIR.$s:U${STAGE_DIR.$s}:${STAGE_DIR_FILTER}} ${STAGE_AS.$s:@f@$f ${STAGE_AS_${f:tA}:U${STAGE_AS_${f:T}:U${f:T}}}@}
 	@touch $@
+.endif
+.endif
 
+.if !empty(STAGE_AS_AND_SYMLINK.$s)
+stage_as_and_symlink.$s: ${STAGE_AS_AND_SYMLINK.$s}
+.endif
+.if target(stage_as_and_symlink.$s)
+STAGE_TARGETS += stage_as_and_symlink
+STAGE_AS_AND_SYMLINK.$s ?= ${.ALLSRC:N.dirdep:Nstage_*}
+.if !target(.stage_as_and_symlink.$s)
+.stage_as_and_symlink.$s:
+stage_as_and_symlink:	stage_as_and_symlink.$s
+stage_as_and_symlink.$s:	.dirdep
+	@${STAGE_AS_SCRIPT}; StageAs ${FLAGS.$@} ${STAGE_FILES_DIR.$s:U${STAGE_DIR.$s}:${STAGE_DIR_FILTER}} ${STAGE_AS_AND_SYMLINK.$s:@f@$f ${STAGE_AS_${f:tA}:U${STAGE_AS_${f:T}:U${f:T}}}@}
+	@${STAGE_LINKS_SCRIPT}; StageLinks -s ${STAGE_FILES_DIR.$s:U${STAGE_DIR.$s}:${STAGE_DIR_FILTER}} ${STAGE_AS_AND_SYMLINK.$s:@f@${STAGE_AS_${f:tA}:U${STAGE_AS_${f:T}:U${f:T}}} $f@}
+	@touch $@
+.endif
+.endif
+
 .endfor
 .endif
 
-CLEANFILES += ${STAGE_TARGETS}
+CLEANFILES += ${STAGE_TARGETS} stage_incs stage_includes
 
+# this lot also only makes sense the first time...
+.if !target(__${.PARSEFILE}__)
+__${.PARSEFILE}__:
+
 # stage_*links usually needs to follow any others.
+# for non-jobs mode the order here matters
+staging: ${STAGE_TARGETS:N*_links} ${STAGE_TARGETS:M*_links}
+
+.if ${.MAKE.JOBS:U0} > 0 && ${STAGE_TARGETS:U:M*_links} != ""
+# the above isn't sufficient
 .for t in ${STAGE_TARGETS:N*links:O:u}
 .ORDER: $t stage_links
-.ORDER: $t stage_symlinks
 .endfor
+.endif
 
-# make sure this exists
-staging:
-
 # generally we want staging to wait until everything else is done
 STAGING_WAIT ?= .WAIT
 
+.if ${.MAKE.LEVEL} > 0
 all: ${STAGING_WAIT} staging
+.endif
 
 .if exists(${.PARSEDIR}/stage-install.sh) && !defined(STAGE_INSTALL)
 # this will run install(1) and then followup with .dirdep files.
@@ -240,5 +331,32 @@
 beforeinstall: .dirdep
 .endif
 .endif
+.NOPATH: ${STAGE_FILES}
 
+.if !empty(STAGE_TARGETS)
+# for backwards compat make sure they exist
+${STAGE_TARGETS}:
+
+.NOPATH: ${CLEANFILES}
+
+MK_STALE_STAGED?= no
+.if ${MK_STALE_STAGED} == "yes"
+all: stale_staged
+# get a list of paths that we have just staged
+# get a list of paths that we have previously staged to those same dirs
+# anything in the 2nd list but not the first is stale - remove it.
+stale_staged: staging .NOMETA
+	@egrep '^[WL] .*${STAGE_OBJTOP}' /dev/null ${.MAKE.META.FILES:M*stage_*} | \
+	sed "/\.dirdep/d;s,.* '*\(${STAGE_OBJTOP}/[^ '][^ ']*\).*,\1," | \
+	sort > ${.TARGET}.staged1
+	@grep -l '${_dirdep}' /dev/null ${_STAGED_DIRS:M${STAGE_OBJTOP}*:O:u:@d@$d/*.dirdep@} | \
+	sed 's,\.dirdep,,' | sort > ${.TARGET}.staged2
+	@comm -13 ${.TARGET}.staged1 ${.TARGET}.staged2 > ${.TARGET}.stale
+	@test ! -s ${.TARGET}.stale || { \
+		echo "Removing stale staged files..."; \
+		sed 's,.*,& &.dirdep,' ${.TARGET}.stale | xargs rm -f; }
+
 .endif
+.endif
+.endif
+.endif

Modified: vendor/NetBSD/bmake/dist/mk/meta.subdir.mk
===================================================================
--- vendor/NetBSD/bmake/dist/mk/meta.subdir.mk	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/mk/meta.subdir.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,4 +1,4 @@
-# $Id: meta.subdir.mk,v 1.10 2012/07/03 05:26:46 sjg Exp $
+# $Id: meta.subdir.mk,v 1.11 2015/11/24 22:26:51 sjg Exp $
 
 #
 #	@(#) Copyright (c) 2010, Simon J. Gerraty
@@ -62,7 +62,7 @@
 DIRDEPS =
 .else
 # clean up if needed
-DIRDEPS := ${DIRDEPS:S,^./,,:S,/./,/,g:${SUBDIREPS_FILTER:Uu}}
+DIRDEPS := ${DIRDEPS:S,^./,,:S,/./,/,g:${SUBDIRDEPS_FILTER:Uu}}
 .endif
 # we just dealt with it, if we leave it defined,
 # dirdeps.mk will compute some interesting combinations.

Modified: vendor/NetBSD/bmake/dist/mk/meta.sys.mk
===================================================================
--- vendor/NetBSD/bmake/dist/mk/meta.sys.mk	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/mk/meta.sys.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,4 +1,4 @@
-# $Id: meta.sys.mk,v 1.16 2012/07/03 05:26:00 sjg Exp $
+# $Id: meta.sys.mk,v 1.32 2017/06/11 03:24:04 sjg Exp $
 
 #
 #	@(#) Copyright (c) 2010, Simon J. Gerraty
@@ -20,7 +20,15 @@
 .if ${MAKE_VERSION:U0} > 20100901
 .if !target(.ERROR)
 
+.-include <local.meta.sys.mk>
 
+# absoulte path to what we are reading.
+_PARSEDIR = ${.PARSEDIR:tA}
+
+.if !defined(SYS_MK_DIR)
+SYS_MK_DIR := ${_PARSEDIR}
+.endif
+
 META_MODE += meta verbose
 .MAKE.MODE ?= ${META_MODE}
 
@@ -47,17 +55,6 @@
 .endif
 .endif
 
-# make defaults .MAKE.DEPENDFILE to .depend
-# that won't work for us.
-.if ${.MAKE.DEPENDFILE} == ".depend"
-.undef .MAKE.DEPENDFILE
-.endif
-
-# if you don't cross build for multiple MACHINEs concurrently, then
-# .MAKE.DEPENDFILE = Makefile.depend
-# probably makes sense - you can set that in local.sys.mk 
-.MAKE.DEPENDFILE ?= Makefile.depend.${MACHINE}
-
 # we use the pseudo machine "host" for the build host.
 # this should be taken care of before we get here
 .if ${OBJTOP:Ua} == ${HOST_OBJTOP:Ub}
@@ -69,6 +66,7 @@
 # for example, if using Makefild.depend for multiple machines,
 # allowing only MACHINE0 to update can keep things simple.
 MACHINE0 := ${MACHINE}
+.export MACHINE0
 
 .if defined(PYTHON) && exists(${PYTHON})
 # we prefer the python version of this - it is much faster
@@ -105,9 +103,44 @@
 .endif
 
 # Are we, after all, in meta mode?
-.if ${.MAKE.MODE:Mmeta*} != ""
-MKDEP = meta.autodep
+.if ${.MAKE.MODE:Uno:Mmeta*} != ""
+MKDEP_MK = meta.autodep.mk
 
+.if ${.MAKE.MAKEFILES:M*sys.dependfile.mk} == ""
+# this does all the smarts of setting .MAKE.DEPENDFILE
+.-include <sys.dependfile.mk>
+# check if we got anything sane
+.if ${.MAKE.DEPENDFILE} == ".depend"
+.undef .MAKE.DEPENDFILE
+.endif
+.MAKE.DEPENDFILE ?= Makefile.depend
+.endif
+
+# we can afford to use cookies to prevent some targets
+# re-running needlessly
+META_COOKIE_TOUCH?= touch ${COOKIE.${.TARGET}:U${.OBJDIR}/${.TARGET:T}}
+META_NOPHONY=
+META_NOECHO= :
+
+# some targets involve old pre-built targets
+# ignore mtime of shell
+# and mtime of makefiles does not matter in meta mode
+.MAKE.META.IGNORE_PATHS += \
+        ${MAKEFILE} \
+        ${SHELL} \
+        ${SYS_MK_DIR}
+
+.if ${UPDATE_DEPENDFILE:Uyes:tl} != "no"
+.if ${.MAKEFLAGS:Uno:M-k} != ""
+# make this more obvious
+.warning Setting UPDATE_DEPENDFILE=NO due to -k
+UPDATE_DEPENDFILE= NO
+.export UPDATE_DEPENDFILE
+.elif !exists(/dev/filemon)
+.error ${.newline}ERROR: The filemon module (/dev/filemon) is not loaded.
+.endif
+.endif
+
 .if ${.MAKE.LEVEL} == 0
 # make sure dirdeps target exists and do it first
 all: dirdeps .WAIT
@@ -121,19 +154,16 @@
 # tell dirdeps.mk what we want
 BUILD_AT_LEVEL0 = no
 .endif
-
-.if ${.MAKE.DEPENDFILE:E} == ${MACHINE}
+.if ${.TARGETS:Nall} == "" 
 # it works best if we do everything via sub-makes
 BUILD_AT_LEVEL0 ?= no
 .endif
-BUILD_AT_LEVEL0 ?= yes
-.endif
 
-# if we think we are updating dependencies, 
-# then filemon had better be present
-.if ${UPDATE_DEPENDFILE:Uyes:tl} != "no" && !exists(/dev/filemon)
-.error ${.newline}ERROR: The filemon module (/dev/filemon) is not loaded.
 .endif
-
+.else
+META_COOKIE_TOUCH=
+# some targets need to be .PHONY in non-meta mode
+META_NOPHONY= .PHONY
+META_NOECHO= echo
 .endif
 .endif

Modified: vendor/NetBSD/bmake/dist/mk/meta2deps.py
===================================================================
--- vendor/NetBSD/bmake/dist/mk/meta2deps.py	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/mk/meta2deps.py	2018-06-27 00:17:22 UTC (rev 11138)
@@ -37,7 +37,7 @@
 
 """
 RCSid:
-	$Id: meta2deps.py,v 1.17 2014/04/05 22:56:54 sjg Exp $
+	$Id: meta2deps.py,v 1.27 2017/05/24 00:04:04 sjg Exp $
 
 	Copyright (c) 2011-2013, Juniper Networks, Inc.
 	All rights reserved.
@@ -90,6 +90,12 @@
     for d in [last_dir, cwd]:
         if not d:
             continue
+        if path == '..':
+            dw = d.split('/')
+            p = '/'.join(dw[:-1])
+            if not p:
+                p = '/'
+            return p
         p = '/'.join([d,path])
         if debug > 2:
             print("looking for:", p, end=' ', file=debug_out)
@@ -103,19 +109,39 @@
         return p
     return None
 
+def cleanpath(path):
+    """cleanup path without using realpath(3)"""
+    if path.startswith('/'):
+        r = '/'
+    else:
+        r = ''
+    p = []
+    w = path.split('/')
+    for d in w:
+        if not d or d == '.':
+            continue
+        if d == '..':
+            try:
+                p.pop()
+                continue
+            except:
+                break
+        p.append(d)
+
+    return r + '/'.join(p)
+
 def abspath(path, cwd, last_dir=None, debug=0, debug_out=sys.stderr):
     """
     Return an absolute path, resolving via cwd or last_dir if needed.
-    this gets called a lot, so we try to avoid calling realpath
-    until we know we have something.
+    this gets called a lot, so we try to avoid calling realpath.
     """
     rpath = resolve(path, cwd, last_dir, debug, debug_out)
     if rpath:
         path = rpath
-    if (path.find('./') > 0 or
-        path.endswith('/..') or
-        os.path.islink(path)):
-        return os.path.realpath(path)
+    if (path.find('/') < 0 or
+        path.find('./') > 0 or
+        path.endswith('/..')):
+        path = cleanpath(path)
     return path
 
 def sort_unique(list, cmp=None, key=None, reverse=False):
@@ -125,6 +151,7 @@
     for e in list:
         if e == le:
             continue
+        le = e
         nl.append(e)
     return nl
 
@@ -142,7 +169,7 @@
     host_target = None
     srctops = []
     objroots = []
-    
+    excludes = []
     seen = {}
     obj_deps = []
     src_deps = []
@@ -152,35 +179,39 @@
         """if name is set we will parse it now.
         conf can have the follwing keys:
 
-        SRCTOPS	list of tops of the src tree(s).
+        SRCTOPS list of tops of the src tree(s).
 
-        CURDIR	the src directory 'bmake' was run from.
+        CURDIR  the src directory 'bmake' was run from.
 
-        RELDIR	the relative path from SRCTOP to CURDIR
+        RELDIR  the relative path from SRCTOP to CURDIR
 
-        MACHINE	the machine we built for.
-        	set to 'none' if we are not cross-building.
-		More specifically if machine cannot be deduced from objdirs.
+        MACHINE the machine we built for.
+                set to 'none' if we are not cross-building.
+                More specifically if machine cannot be deduced from objdirs.
 
         TARGET_SPEC
-        	Sometimes MACHINE isn't enough.
+                Sometimes MACHINE isn't enough.
                 
         HOST_TARGET
-		when we build for the pseudo machine 'host'
-		the object tree uses HOST_TARGET rather than MACHINE.
+                when we build for the pseudo machine 'host'
+                the object tree uses HOST_TARGET rather than MACHINE.
 
         OBJROOTS a list of the common prefix for all obj dirs it might
-		end in '/' or '-'.
+                end in '/' or '-'.
 
-        DPDEPS	names an optional file to which per file dependencies
-		will be appended.
-		For example if 'some/path/foo.h' is read from SRCTOP
-		then 'DPDEPS_some/path/foo.h +=' "RELDIR" is output.
-		This can allow 'bmake' to learn all the dirs within
- 		the tree that depend on 'foo.h'
+        DPDEPS  names an optional file to which per file dependencies
+                will be appended.
+                For example if 'some/path/foo.h' is read from SRCTOP
+                then 'DPDEPS_some/path/foo.h +=' "RELDIR" is output.
+                This can allow 'bmake' to learn all the dirs within
+                the tree that depend on 'foo.h'
 
-        debug	desired debug level
+        EXCLUDES
+                A list of paths to ignore.
+                ccache(1) can otherwise be trouble.
 
+        debug   desired debug level
+
         debug_out open file to send debug output to (sys.stderr)
 
         """
@@ -223,8 +254,9 @@
                     if objroot.endswith(e):
                         # this is not what we want - fix it
                         objroot = objroot[0:-len(e)]
-                        if e.endswith('/'):
-                            objroot += '/'
+
+                if objroot[-1] != '/':
+                    objroot += '/'
                 if not objroot in self.objroots:
                     self.objroots.append(objroot)
                     _objroot = os.path.realpath(objroot)
@@ -236,11 +268,14 @@
             # we want the longest match
             self.srctops.sort(reverse=True)
             self.objroots.sort(reverse=True)
-            
+
+            self.excludes = getv(conf, 'EXCLUDES', [])
+
             if self.debug:
                 print("host_target=", self.host_target, file=self.debug_out)
                 print("srctops=", self.srctops, file=self.debug_out)
                 print("objroots=", self.objroots, file=self.debug_out)
+                print("excludes=", self.excludes, file=self.debug_out)
 
             self.dirdep_re = re.compile(r'([^/]+)/(.+)')
 
@@ -257,6 +292,7 @@
                 self.dpdeps = None      # we cannot do it?
 
         self.cwd = os.getcwd()          # make sure this is initialized
+        self.last_dir = self.cwd
 
         if name:
             self.try_parse()
@@ -283,6 +319,9 @@
             return None
         for f in sort_unique(self.file_deps):
             print('DPDEPS_%s += %s' % (f, self.reldir), file=out)
+        # these entries provide for reverse DIRDEPS lookup
+        for f in self.obj_deps:
+            print('DEPDIRS_%s += %s' % (f, self.reldir), file=out)
 
     def seenit(self, dir):
         """rememer that we have seen dir."""
@@ -350,20 +389,20 @@
     def parse(self, name=None, file=None):
         """A meta file looks like:
         
-	# Meta data file "path"
-	CMD "command-line"
-	CWD "cwd"
-	TARGET "target"
-	-- command output --
-	-- filemon acquired metadata --
-	# buildmon version 3
-	V 3
-	C "pid" "cwd"
-	E "pid" "path"
+        # Meta data file "path"
+        CMD "command-line"
+        CWD "cwd"
+        TARGET "target"
+        -- command output --
+        -- filemon acquired metadata --
+        # buildmon version 3
+        V 3
+        C "pid" "cwd"
+        E "pid" "path"
         F "pid" "child"
-	R "pid" "path"
-	W "pid" "path"
-	X "pid" "status"
+        R "pid" "path"
+        W "pid" "path"
+        X "pid" "status"
         D "pid" "path"
         L "pid" "src" "target"
         M "pid" "old" "new"
@@ -379,7 +418,7 @@
             self.name = name;
         if file:
             f = file
-            cwd = last_dir = self.cwd
+            cwd = self.last_dir = self.cwd
         else:
             f = open(self.name, 'r')
         skip = True
@@ -412,7 +451,7 @@
                         interesting += 'W'
                     """
                 elif w[0] == 'CWD':
-                    self.cwd = cwd = last_dir = w[1]
+                    self.cwd = cwd = self.last_dir = w[1]
                     self.seenit(cwd)    # ignore this
                     if self.debug:
                         print("%s: CWD=%s" % (self.name, cwd), file=self.debug_out)
@@ -421,10 +460,9 @@
             pid = int(w[1])
             if pid != last_pid:
                 if last_pid:
-                    pid_cwd[last_pid] = cwd
-                    pid_last_dir[last_pid] = last_dir
+                    pid_last_dir[last_pid] = self.last_dir
                 cwd = getv(pid_cwd, pid, self.cwd)
-                last_dir = getv(pid_last_dir, pid, self.cwd)
+                self.last_dir = getv(pid_last_dir, pid, self.cwd)
                 last_pid = pid
 
             # process operations
@@ -438,7 +476,8 @@
                 cwd = abspath(w[2], cwd, None, self.debug, self.debug_out)
                 if cwd.endswith('/.'):
                     cwd = cwd[0:-2]
-                last_dir = cwd
+                self.last_dir = pid_last_dir[pid] = cwd
+                pid_cwd[pid] = cwd
                 if self.debug > 1:
                     print("cwd=", cwd, file=self.debug_out)
                 continue
@@ -449,80 +488,107 @@
                 continue
             # file operations
             if w[0] in 'ML':
-                path = w[2].strip("'")
-            else:
+                # these are special, tread src as read and
+                # target as write
+                self.parse_path(w[1].strip("'"), cwd, 'R', w)
+                self.parse_path(w[2].strip("'"), cwd, 'W', w)
+                continue
+            elif w[0] in 'ERWS':
                 path = w[2]
-            # we are never interested in .dirdep files as dependencies
-            if path.endswith('.dirdep'):
+                self.parse_path(path, cwd, w[0], w)
+
+        if not file:
+            f.close()
+
+    def is_src(self, base, dir, rdir):
+        """is base in srctop"""
+        for dir in [dir,rdir]:
+            if not dir:
                 continue
-            # we don't want to resolve the last component if it is
-            # a symlink
-            path = resolve(path, cwd, last_dir, self.debug, self.debug_out)
-            if not path:
-                continue
-            dir,base = os.path.split(path)
-            if dir in self.seen:
-                if self.debug > 2:
-                    print("seen:", dir, file=self.debug_out)
-                continue
-            # we can have a path in an objdir which is a link
-            # to the src dir, we may need to add dependencies for each
-            rdir = dir
-            dir = abspath(dir, cwd, last_dir, self.debug, self.debug_out)
-            if rdir == dir or rdir.find('./') > 0:
-                rdir = None
-            # now put path back together
             path = '/'.join([dir,base])
-            if self.debug > 1:
-                print("raw=%s rdir=%s dir=%s path=%s" % (w[2], rdir, dir, path), file=self.debug_out)
-            if w[0] in 'SRWL':
-                if w[0] == 'W' and path.endswith('.dirdep'):
-                    continue
-                if path in [last_dir, cwd, self.cwd, self.curdir]:
-                    if self.debug > 1:
-                        print("skipping:", path, file=self.debug_out)
-                    continue
-                if os.path.isdir(path):
-                    if w[0] in 'RW':
-                        last_dir = path;
-                    if self.debug > 1:
-                        print("ldir=", last_dir, file=self.debug_out)
-                    continue
+            srctop = self.find_top(path, self.srctops)
+            if srctop:
+                if self.dpdeps:
+                    self.add(self.file_deps, path.replace(srctop,''), 'file')
+                self.add(self.src_deps, dir.replace(srctop,''), 'src')
+                self.seenit(dir)
+                return True
+        return False
 
-            if w[0] in 'REWML':
-                # finally, we get down to it
-                if dir == self.cwd or dir == self.curdir:
+    def parse_path(self, path, cwd, op=None, w=[]):
+        """look at a path for the op specified"""
+
+        if not op:
+            op = w[0]
+
+        # we are never interested in .dirdep files as dependencies
+        if path.endswith('.dirdep'):
+            return
+        for p in self.excludes:
+            if p and path.startswith(p):
+                if self.debug > 2:
+                    print("exclude:", p, path, file=self.debug_out)
+                return
+        # we don't want to resolve the last component if it is
+        # a symlink
+        path = resolve(path, cwd, self.last_dir, self.debug, self.debug_out)
+        if not path:
+            return
+        dir,base = os.path.split(path)
+        if dir in self.seen:
+            if self.debug > 2:
+                print("seen:", dir, file=self.debug_out)
+            return
+        # we can have a path in an objdir which is a link
+        # to the src dir, we may need to add dependencies for each
+        rdir = dir
+        dir = abspath(dir, cwd, self.last_dir, self.debug, self.debug_out)
+        rdir = os.path.realpath(dir)
+        if rdir == dir:
+            rdir = None
+        # now put path back together
+        path = '/'.join([dir,base])
+        if self.debug > 1:
+            print("raw=%s rdir=%s dir=%s path=%s" % (w[2], rdir, dir, path), file=self.debug_out)
+        if op in 'RWS':
+            if path in [self.last_dir, cwd, self.cwd, self.curdir]:
+                if self.debug > 1:
+                    print("skipping:", path, file=self.debug_out)
+                return
+            if os.path.isdir(path):
+                if op in 'RW':
+                    self.last_dir = path;
+                if self.debug > 1:
+                    print("ldir=", self.last_dir, file=self.debug_out)
+                return
+
+        if op in 'ERW':
+            # finally, we get down to it
+            if dir == self.cwd or dir == self.curdir:
+                return
+            if self.is_src(base, dir, rdir):
+                self.seenit(w[2])
+                if not rdir:
+                    return
+
+            objroot = None
+            for dir in [dir,rdir]:
+                if not dir:
                     continue
-                srctop = self.find_top(path, self.srctops)
-                if srctop:
-                    if self.dpdeps:
-                        self.add(self.file_deps, path.replace(srctop,''), 'file')
-                    self.add(self.src_deps, dir.replace(srctop,''), 'src')
-                    self.seenit(w[2])
-                    self.seenit(dir)
-                    if rdir and not rdir.startswith(srctop):
-                        dir = rdir      # for below
-                        rdir = None
-                    else:
-                        continue
-
-                objroot = None
-                for dir in [dir,rdir]:
-                    if not dir:
-                        continue
-                    objroot = self.find_top(dir, self.objroots)
-                    if objroot:
-                        break
+                objroot = self.find_top(dir, self.objroots)
                 if objroot:
-                    ddep = self.find_obj(objroot, dir, path, w[2])
-                    if ddep:
-                        self.add(self.obj_deps, ddep, 'obj')
-                else:
-                    # don't waste time looking again
-                    self.seenit(w[2])
-                    self.seenit(dir)
-        if not file:
-            f.close()
+                    break
+            if objroot:
+                ddep = self.find_obj(objroot, dir, path, w[2])
+                if ddep:
+                    self.add(self.obj_deps, ddep, 'obj')
+                    if self.dpdeps and objroot.endswith('/stage/'):
+                        sp = '/'.join(path.replace(objroot,'').split('/')[1:])
+                        self.add(self.file_deps, sp, 'file')
+            else:
+                # don't waste time looking again
+                self.seenit(w[2])
+                self.seenit(dir)
 
                             
 def main(argv, klass=MetaFile, xopts='', xoptf=None):
@@ -529,18 +595,18 @@
     """Simple driver for class MetaFile.
 
     Usage:
-    	script [options] [key=value ...] "meta" ...
+        script [options] [key=value ...] "meta" ...
         
     Options and key=value pairs contribute to the
     dictionary passed to MetaFile.
 
     -S "SRCTOP"
-		add "SRCTOP" to the "SRCTOPS" list.
+                add "SRCTOP" to the "SRCTOPS" list.
 
     -C "CURDIR"
     
     -O "OBJROOT"
-    		add "OBJROOT" to the "OBJROOTS" list.
+                add "OBJROOT" to the "OBJROOTS" list.
 
     -m "MACHINE"
 
@@ -550,7 +616,7 @@
 
     -D "DPDEPS"
     
-    -d	bumps debug level
+    -d  bumps debug level
 
     """
     import getopt
@@ -568,6 +634,7 @@
     conf = {
         'SRCTOPS': [],
         'OBJROOTS': [],
+        'EXCLUDES': [],
         }
 
     try:
@@ -589,7 +656,7 @@
     debug = 0
     output = True
     
-    opts, args = getopt.getopt(argv[1:], 'a:dS:C:O:R:m:D:H:qT:' + xopts)
+    opts, args = getopt.getopt(argv[1:], 'a:dS:C:O:R:m:D:H:qT:X:' + xopts)
     for o, a in opts:
         if o == '-a':
             conf['MACHINE_ARCH'] = a
@@ -615,6 +682,9 @@
             conf['MACHINE'] = a
         elif o == '-T':
             conf['TARGET_SPEC'] = a
+        elif o == '-X':
+            if a not in conf['EXCLUDES']:
+                conf['EXCLUDES'].append(a)
         elif xoptf:
             xoptf(o, a, conf)
 
@@ -649,16 +719,21 @@
         for k,v in list(conf.items()):
             print("%s=%s" % (k,v), file=debug_out)
 
+    m = None
     for a in args:
         if a.endswith('.meta'):
+            if not os.path.exists(a):
+                continue
             m = klass(a, conf)
         elif a.startswith('@'):
             # there can actually multiple files per line
             for line in open(a[1:]):
                 for f in line.strip().split():
+                    if not os.path.exists(f):
+                        continue
                     m = klass(f, conf)
 
-    if output:
+    if output and m:
         print(m.dirdeps())
 
         print(m.src_dirdeps('\nsrc:'))


Property changes on: vendor/NetBSD/bmake/dist/mk/meta2deps.py
___________________________________________________________________
Deleted: svn:executable
Modified: vendor/NetBSD/bmake/dist/mk/meta2deps.sh
===================================================================
--- vendor/NetBSD/bmake/dist/mk/meta2deps.sh	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/mk/meta2deps.sh	2018-06-27 00:17:22 UTC (rev 11138)
@@ -52,7 +52,7 @@
 #	$SB/obj-i386/bsd/gnu/lib/csu
 #	$SB/obj-i386/bsd/gnu/lib/libgcc
 #	$SB/obj-i386/bsd/include
-#	$SB/obj-i386/bsd/lib/csu/i386-elf
+#	$SB/obj-i386/bsd/lib/csu/i386
 #	$SB/obj-i386/bsd/lib/libc
 #	$SB/src/bsd/include
 #	$SB/src/bsd/sys/i386/include
@@ -77,7 +77,7 @@
 
 
 # RCSid:
-#	$Id: meta2deps.sh,v 1.7 2014/04/05 22:56:54 sjg Exp $
+#	$Id: meta2deps.sh,v 1.12 2016/12/13 20:44:16 sjg Exp $
 
 # Copyright (c) 2010-2013, Juniper Networks, Inc.
 # All rights reserved.
@@ -139,10 +139,15 @@
     eval "$name=\"$list\""
 }
 
+_excludes_f() {
+    egrep -v "$EXCLUDES"
+}
+
 meta2deps() {
     DPDEPS=
     SRCTOPS=$SRCTOP
     OBJROOTS=
+    EXCLUDES=
     while :
     do
 	case "$1" in
@@ -153,6 +158,7 @@
 	-H) HOST_TARGET=$2; shift 2;;
 	-S) add_list SRCTOPS $2; shift 2;;
 	-O) add_list OBJROOTS $2; shift 2;;
+	-X) add_list EXCLUDES '|' $2; shift 2;;
 	-R) RELDIR=$2; shift 2;;
 	-T) TARGET_SPEC=$2; shift 2;;
 	*) break;;
@@ -212,8 +218,26 @@
     seenit=
     seensrc=
     lpid=
-    cat /dev/null "$@" |
-    sed -e 's,^CWD,C C,;/^[CREFL] /!d' -e "s,',,g" |
+    case "$EXCLUDES" in
+    "") _excludes=cat;;
+    *) _excludes=_excludes_f;;
+    esac
+    # handle @list files
+    case "$@" in
+    *@[!.]*)
+	for f in "$@"
+	do
+	    case "$f" in
+	    *.meta) cat $f;;
+	    @*) xargs cat < ${f#@};;
+	    *) cat $f;;
+	    esac
+	done
+	;;
+    *) cat /dev/null "$@";;
+    esac 2> /dev/null |
+    sed -e 's,^CWD,C C,;/^[CREFLM] /!d' -e "s,',,g" |
+    $_excludes |
     while read op pid path junk
     do
 	: op=$op pid=$pid path=$path
@@ -231,7 +255,7 @@
 	*)
 	    case "$lpid" in
 	    "") ;;
-	    *) eval ldir_$lpid=$ldir cwd_$lpid=$cwd;;
+	    *) eval ldir_$lpid=$ldir;;
 	    esac
 	    eval ldir=\${ldir_$pid:-$CWD} cwd=\${cwd_$pid:-$CWD}
 	    lpid=$pid
@@ -247,9 +271,11 @@
 	    esac
 	    # watch out for temp dirs that no longer exist
 	    test -d ${cwd:-/dev/null/no/such} || cwd=$CWD
+	    eval cwd_$pid=$cwd
 	    continue
 	    ;;
-	F,*)  eval cwd_$path=$cwd ldir_$path=$ldir
+	F,*) # $path is new pid  
+	    eval cwd_$path=$cwd ldir_$path=$ldir
 	    continue
 	    ;;	  
 	*)  dir=${path%/*}
@@ -285,7 +311,7 @@
 	*)  seen=$dir;;
 	esac
 	case "$dir" in
-	${CURDIR:-.}|${CURDIR:-.}/*|"") continue;;
+	${CURDIR:-.}|"") continue;;
 	$src_re)
 	    # avoid repeating ourselves...
 	    case "$DPDEPS,$seensrc," in


Property changes on: vendor/NetBSD/bmake/dist/mk/meta2deps.sh
___________________________________________________________________
Deleted: svn:executable
Modified: vendor/NetBSD/bmake/dist/mk/mk-files.txt
===================================================================
--- vendor/NetBSD/bmake/dist/mk/mk-files.txt	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/mk/mk-files.txt	2018-06-27 00:17:22 UTC (rev 11138)
@@ -432,13 +432,27 @@
 ``warnings-sets.mk`` if it exists and you use that to make any local
 customizations. 
 
+rst2htm.mk
+----------
+
+Logic to simplify generating HTML (and PDF) documents from ReStructuredText.
+
+cython.mk
+---------
+
+Logic to build Python C interface modules using Cython_
+
+.. _Cython: http://www.cython.org/
+
 Meta mode
 =========
 
 The 20110505 and later versions of ``mk-files`` include a number of
-makefile contributed by Juniper Networks, Inc.  
-These allow the latest version of bmake_ to run in `meta mode`_.
+makefiles contributed by Juniper Networks, Inc.  
+These allow the latest version of bmake_ to run in `meta mode`_
+see `dirdeps.mk`_
 
+.. _`dirdeps.mk`: /help/sjg/dirdeps.htm
 .. _`meta mode`: bmake-meta-mode.htm
 
 Install
@@ -463,5 +477,5 @@
 .. _mk.tar.gz: http://www.crufty.net/ftp/pub/sjg/mk.tar.gz
 
 :Author: sjg at crufty.net
-:Revision: $Id: mk-files.txt,v 1.15 2011/06/08 07:06:18 sjg Exp $
+:Revision: $Id: mk-files.txt,v 1.16 2014/09/05 04:41:16 sjg Exp $
 :Copyright: Crufty.NET

Added: vendor/NetBSD/bmake/dist/mk/mkopt.sh
===================================================================
--- vendor/NetBSD/bmake/dist/mk/mkopt.sh	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/mk/mkopt.sh	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,103 @@
+:
+# $Id: mkopt.sh,v 1.11 2017/03/18 21:36:42 sjg Exp $
+#
+#	@(#) Copyright (c) 2014, Simon J. Gerraty
+#
+#	This file is provided in the hope that it will
+#	be of use.  There is absolutely NO WARRANTY.
+#	Permission to copy, redistribute or otherwise
+#	use this file is hereby granted provided that 
+#	the above copyright notice and this notice are
+#	left intact. 
+#      
+#	Please send copies of changes and bug-fixes to:
+#	sjg at crufty.net
+#
+
+# handle WITH[OUT]_* options in a manner compatible with
+# options.mk and bsd.mkopt.mk in recent FreeBSD
+
+# no need to be included more than once
+_MKOPT_SH=:
+_MKOPT_PREFIX=${_MKOPT_PREFIX:-MK_}
+
+#
+# _mk_opt default OPT
+#
+# Set MK_$OPT
+#
+# The semantics are simple, if MK_$OPT has no value
+# WITHOUT_$OPT results in MK_$OPT=no
+# otherwise WITH_$OPT results in MK_$OPT=yes.
+# Note WITHOUT_$OPT overrides WITH_$OPT.
+#
+# For backwards compatability reasons we treat WITH_$OPT=no
+# the same as WITHOUT_$OPT.
+#
+_mk_opt() {
+    _d=$1
+    _mo=${_MKOPT_PREFIX}$2 _wo=WITHOUT_$2 _wi=WITH_$2
+    eval "_mov=\$$_mo _wov=\$$_wo _wiv=\$$_wi"
+
+    case "$_wiv" in
+    [Nn][Oo]) _wov=no;;
+    esac
+    _v=${_mov:-${_wov:+no}}
+    _v=${_v:-${_wiv:+yes}}
+    _v=${_v:-$_d}
+    _opt_list="$_opt_list $_mo"
+    case "$_v" in
+    yes|no) ;;			# sane
+    0|[NnFf]*) _v=no;;		# they mean no
+    1|[YyTt]*) _v=yes;;		# they mean yes
+    *) _v=$_d;;			# ignore bogus value
+    esac
+    eval "$_mo=$_v"
+}
+
+#
+# _mk_opts default opt ... [default [opt] ...]
+#
+# see _mk_opts_defaults for example
+#
+_mk_opts() {
+    _d=no
+    for _o in "$@"
+    do
+	case "$_o" in
+	*/*) # option is dirname default comes from basename
+	    eval "_d=\$${_MKOPT_PREFIX}${_o#*/}"
+	    _o=${_o%/*}
+	    ;;
+	yes|no) _d=$_o; continue;;
+	esac
+	_mk_opt $_d $_o
+    done
+}
+
+# handle either options.mk style OPTIONS_DEFAULT_*
+# or FreeBSD's new bsd.mkopt.mk style __DEFAULT_*_OPTIONS
+_mk_opts_defaults() {
+    _mk_opts no $OPTIONS_DEFAULT_NO $__DEFAULT_NO_OPTIONS \
+	yes $OPTIONS_DEFAULT_YES $__DEFAULT_YES_OPTIONS \
+	$OPTIONS_DEFAULT_DEPENDENT $__DEFAULT_DEPENDENT_OPTIONS
+}
+
+case "/$0" in
+*/mkopt*)
+    _list=no
+    while :
+    do
+	case "$1" in
+	*=*) eval "$1"; shift;;
+	--no|no) _list="$_list no"; shift;;
+	--yes|yes) _list="$_list yes"; shift;;
+	-DWITH*) eval "${1#-D}=1"; shift;;
+	[A-Z]*) _list="$_list $1"; shift;;
+	*) break;;
+	esac
+    done
+    _mk_opts $_list
+    ;;
+esac
+

Modified: vendor/NetBSD/bmake/dist/mk/nls.mk
===================================================================
--- vendor/NetBSD/bmake/dist/mk/nls.mk	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/mk/nls.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,9 +1,8 @@
 #	$NetBSD: bsd.nls.mk,v 1.3 1996/10/18 02:34:45 thorpej Exp $
 
 .if !target(.MAIN)
-.if exists(${.CURDIR}/../Makefile.inc)
-.include "${.CURDIR}/../Makefile.inc"
-.endif
+# init.mk not included
+.-include <${.CURDIR:H}/Makefile.inc>
 
 .MAIN: all
 .endif

Modified: vendor/NetBSD/bmake/dist/mk/own.mk
===================================================================
--- vendor/NetBSD/bmake/dist/mk/own.mk	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/mk/own.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,4 +1,4 @@
-# $Id: own.mk,v 1.27 2013/07/18 05:46:24 sjg Exp $
+# $Id: own.mk,v 1.36 2017/07/08 21:58:46 sjg Exp $
 
 .if !target(__${.PARSEFILE}__)
 __${.PARSEFILE}__:
@@ -7,7 +7,7 @@
 .include "init.mk"
 .endif
 
-.ifndef NOMAKECONF
+.if !defined(NOMAKECONF) && !defined(NO_MAKECONF)
 MAKECONF?=	/etc/mk.conf
 .-include "${MAKECONF}"
 .endif
@@ -20,8 +20,8 @@
 TARGET_HOST?= ${HOST_TARGET}
 
 # these may or may not exist
-.-include "${TARGET_HOST}.mk"
-.-include "config.mk"
+.-include <${TARGET_HOST}.mk>
+.-include <config.mk>
 
 RM?= rm
 LN?= ln
@@ -35,7 +35,7 @@
 .endif
 
 # FreeBSD at least does not set this
-MACHINE_ARCH?=${MACHINE}
+MACHINE_ARCH?=	${MACHINE}
 # we need to make sure these are defined too in case sys.mk fails to.
 COMPILE.s?=	${CC} ${AFLAGS} -c
 LINK.s?=	${CC} ${AFLAGS} ${LDFLAGS}
@@ -79,7 +79,7 @@
 
 # we really like to have SRCTOP and OBJTOP defined...
 .if !defined(SRCTOP) || !defined(OBJTOP)
-.-include "srctop.mk"
+.-include <srctop.mk>
 .endif
 
 .if !defined(SRCTOP) || !defined(OBJTOP)
@@ -93,12 +93,10 @@
 	GPROF \
 	LIBTOOL \
 	LINT \
-	META_MODE \
 
 OPTIONS_DEFAULT_YES+= \
 	ARCHIVE \
 	AUTODEP \
-	AUTO_OBJ \
 	CRYPTO \
 	DOC \
 	DPADD_MK \
@@ -119,6 +117,7 @@
 	PICINSTALL/LINKLIB \
 	PICLIB/PIC \
 	PROFILE/LINKLIB \
+	STAGING_PROG/STAGING \
 
 .include <options.mk>
 
@@ -130,9 +129,10 @@
 USERGRP!=  id -g
 .export USERGRP
 .endif
-.for x in BIN CONF DOC INFO KMOD LIB MAN NLS SHARE
+.for x in BIN CONF DOC INC INFO FILES KMOD LIB MAN NLS PROG SHARE
 $xOWN=  ${USER}
 $xGRP=  ${USERGRP}
+$x_INSTALL_OWN=
 .endfor
 .endif
 .endif
@@ -143,7 +143,11 @@
 BINOWN?=	root
 BINMODE?=	555
 NONBINMODE?=	444
+DIRMODE?=	755
 
+INCLUDEDIR?=	${prefix}/include
+INCDIR?=	${INCLUDEDIR}
+
 # Define MANZ to have the man pages compressed (gzip)
 #MANZ=		1
 
@@ -153,6 +157,7 @@
 MANOWN?=	${BINOWN}
 MANMODE?=	${NONBINMODE}
 
+INCLUDEDIR?=	${libprefix}/include
 LIBDIR?=	${libprefix}/lib
 SHLIBDIR?=	${libprefix}/lib
 .if ${USE_SHLIBDIR:Uno} == "yes"
@@ -182,6 +187,10 @@
 KMODOWN?=	${BINOWN}
 KMODMODE?=	${NONBINMODE}
 
+SHAREGRP?=	${BINGRP}
+SHAREOWN?=	${BINOWN}
+SHAREMODE?=	${NONBINMODE}
+
 COPY?=		-c
 STRIP_FLAG?=	-s
 
@@ -242,4 +251,19 @@
 MK_NLS=		no
 .endif
 
+# :U incase not using our sys.mk
+.if ${MK_META_MODE:Uno} == "yes"
+# should all be set by sys.mk if not default
+TARGET_SPEC_VARS ?= MACHINE
+.if ${TARGET_SPEC_VARS:[#]} > 1
+TARGET_SPEC_VARS_REV := ${TARGET_SPEC_VARS:[-1..1]}
+.else
+TARGET_SPEC_VARS_REV = ${TARGET_SPEC_VARS}
 .endif
+.if ${MK_STAGING} == "yes"
+STAGE_ROOT?= ${OBJROOT}/stage
+STAGE_OBJTOP?= ${STAGE_ROOT}/${TARGET_SPEC_VARS_REV:ts/}
+.endif
+.endif
+
+.endif

Modified: vendor/NetBSD/bmake/dist/mk/prog.mk
===================================================================
--- vendor/NetBSD/bmake/dist/mk/prog.mk	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/mk/prog.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,4 +1,4 @@
-#	$Id: prog.mk,v 1.25 2013/07/18 05:46:24 sjg Exp $
+#	$Id: prog.mk,v 1.32 2017/05/06 17:30:09 sjg Exp $
 
 .if !target(__${.PARSEFILE}__)
 __${.PARSEFILE}__:
@@ -66,21 +66,17 @@
 	@${CC} ${CFLAGS} -c x.c -o ${.TARGET}
 	@rm -f x.c
 
-.cc.o:
+${CXX_SUFFIXES:%=%.o}:
 	${CXX} -E ${CXXFLAGS} ${.IMPSRC} | xstr -c -
 	@mv -f x.c x.cc
 	@${CXX} ${CXXFLAGS} -c x.cc -o ${.TARGET}
 	@rm -f x.cc
-
-.C.o:
-	${CXX} -E ${CXXFLAGS} ${.IMPSRC} | xstr -c -
-	@mv -f x.c x.C
-	@${CXX} ${CXXFLAGS} -c x.C -o ${.TARGET}
-	@rm -f x.C
 .endif
 
 
 .if defined(PROG)
+BINDIR ?= ${prefix}/bin
+
 SRCS?=	${PROG}.c
 .for s in ${SRCS:N*.h:N*.sh:M*/*}
 ${.o .po .lo:L:@o@${s:T:R}$o@}: $s
@@ -132,8 +128,9 @@
 .endif	# defined(PROG)
 
 .if !defined(_SKIP_BUILD)
-all: ${PROG}
+realbuild: ${PROG}
 .endif
+
 all: _SUBDIRUSE
 
 .if !target(clean)
@@ -197,6 +194,8 @@
 
 maninstall: afterinstall
 afterinstall: realinstall
+install_links: realinstall
+proginstall: beforeinstall
 realinstall: beforeinstall
 .endif
 
@@ -212,6 +211,10 @@
 .NOPATH:	${OBJS}
 .endif
 
+.if defined(FILES) || defined(FILESGROUPS)
+.include <files.mk>
+.endif
+
 .if ${MK_MAN} != "no"
 .include <man.mk>
 .endif
@@ -223,6 +226,20 @@
 .include <obj.mk>
 .include <dep.mk>
 .include <subdir.mk>
+
+.if !empty(PROG) && ${MK_STAGING_PROG} == "yes"
+STAGE_BINDIR ?= ${STAGE_OBJTOP}${BINDIR}
+STAGE_DIR.prog ?= ${STAGE_BINDIR}
+.if ${PROG_NAME:U${PROG}} != ${PROG}
+STAGE_AS_SETS += prog
+STAGE_AS_${PROG} = ${PROG_NAME}
+stage_as.prog: ${PROG}
+.else
+STAGE_SETS += prog
+stage_files.prog: ${PROG}
+.endif
+.endif
+
 .include <final.mk>
 
 .endif

Modified: vendor/NetBSD/bmake/dist/mk/rst2htm.mk
===================================================================
--- vendor/NetBSD/bmake/dist/mk/rst2htm.mk	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/mk/rst2htm.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,4 +1,4 @@
-# $Id: rst2htm.mk,v 1.9 2014/02/22 01:52:41 sjg Exp $
+# $Id: rst2htm.mk,v 1.10 2015/09/08 22:17:46 sjg Exp $
 #
 #	@(#) Copyright (c) 2009, Simon J. Gerraty
 #
@@ -26,8 +26,13 @@
 RST2S5 ?= rst2s5.py
 # the following will run RST2S5 if the target name contains the word 'slides'
 # otherwise it uses RST2HTML
-RST2HTM = ${"${.TARGET:T:M*slides*}":?${RST2S5} ${RST2S5_FLAGS}:${RST2HTML} ${RST2HTML_FLAGS}}
+RST2HTM = ${"${.TARGET:T:M*slides*}":?${RST2S5}:${RST2HTML}}
+RST2HTM_SLIDES_FLAGS ?= ${RST2S5_FLAGS}
+RST2HTM_DOC_FLAGS ?= ${RST2HTML_FLAGS}
+RST2HTM_FLAGS ?= ${"${.TARGET:T:M*slides*}":?${RST2HTM_SLIDES_FLAGS}:${RST2HTM_DOC_FLAGS}}
 
+RST2PDF_FLAGS ?= ${"${.TARGET:T:M*slides*}":?${RST2PDF_SLIDES_FLAGS}:${RST2PDF_DOC_FLAGS}}
+
 RST_SUFFIXES ?= .rst .txt
 
 CLEANFILES += ${HTMFILES}
@@ -37,10 +42,10 @@
 .SUFFIXES: ${RST_SUFFIXES} .htm .pdf
 
 ${RST_SUFFIXES:@s@$s.htm@}:
-	${RST2HTM} ${.IMPSRC} ${.TARGET}
+	${RST2HTM} ${RST2HTM_FLAGS} ${FLAGS.${.TARGET}} ${.IMPSRC} ${.TARGET}
 
 ${RST_SUFFIXES:@s@$s.pdf@}:
-	${RST2PDF} ${.IMPSRC} ${.TARGET}
+	${RST2PDF} ${RST2PDF_FLAGS} ${FLAGS.${.TARGET}} ${.IMPSRC} ${.TARGET}
 
 .for s in ${RSTSRCS:O:u}
 ${s:R:T}.htm: $s

Modified: vendor/NetBSD/bmake/dist/mk/scripts.mk
===================================================================
--- vendor/NetBSD/bmake/dist/mk/scripts.mk	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/mk/scripts.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,52 +1,91 @@
-# $Id: scripts.mk,v 1.2 2006/11/09 01:55:18 sjg Exp $
+# $Id: scripts.mk,v 1.3 2017/05/06 17:29:45 sjg Exp $
+#
+#	@(#) Copyright (c) 2006, Simon J. Gerraty
+#
+#	This file is provided in the hope that it will
+#	be of use.  There is absolutely NO WARRANTY.
+#	Permission to copy, redistribute or otherwise
+#	use this file is hereby granted provided that 
+#	the above copyright notice and this notice are
+#	left intact. 
+#      
+#	Please send copies of changes and bug-fixes to:
+#	sjg at crufty.net
+#
 
 .include <init.mk>
 
-.if defined(SCRIPTS) 
+SCRIPTSGROUPS ?= SCRIPTS
+SCRIPTSGROUPS := ${SCRIPTSGROUPS:O:u}
 
-all:	${SCRIPTS}
-
-.PHONY:		scriptsinstall
-install:	scriptsinstall
-
-.if !target(scriptsinstall)
 SCRIPTSDIR?=	${BINDIR}
 SCRIPTSOWN?=	${BINOWN}
 SCRIPTSGRP?=	${BINGRP}
 SCRIPTSMODE?=	${BINMODE}
 
+SCRIPTS_INSTALL_OWN?= -o ${SCRIPTSOWN} -g ${SCRIPTSGRP}
+SCRIPTS_COPY ?= -C
+
 # how we get script name from src
 SCRIPTSNAME_MOD?=T:R
 
-script_targets= ${SCRIPTS:@s@${DESTDIR}${SCRIPTSDIR_$s:U${SCRIPTSDIR}}/${SCRIPTSNAME_$s:U${s:${SCRIPTSNAME_MOD}}}@}
+.if !target(buildfiles)
+.for group in ${SCRIPTSGROUPS}
+buildfiles: ${${group}}
+.endfor
+.endif
+buildfiles:
+realbuild: buildfiles
 
-scriptsinstall:: ${script_targets}
-
-.PRECIOUS: ${script_targets}
-.if !defined(UPDATE)
-.PHONY: ${script_targets}
+.for group in ${SCRIPTSGROUPS}
+.if !empty(${group}) && defined(${group}DIR)
+.if ${group} != "SCRIPTS"
+${group}_INSTALL_OWN ?= ${SCRIPTS_INSTALL_OWN}
 .endif
+# incase we are staging
+STAGE_DIR.${group} ?= ${STAGE_OBJTOP}${${group}DIR}
 
-INSTALL_FLAGS?= ${RENAME} ${PRESERVE} ${COPY} ${INSTPRIV} \
-	-o ${OWN_${.TARGET:T}:U${SCRIPTSOWN}} \
-	-g ${GRP_${.TARGET:T}:U${SCRIPTSGRP}} \
-	-m ${MODE_${.TARGET:T}:U${SCRIPTSMODE}}
+.for script in ${${group}:O:u}
+${group}_INSTALL_OWN.${script:T} ?= ${${group}_INSTALL_OWN}
+${group}DIR.${script:T} ?= ${${group}DIR_${script:T}:U${${group}DIR}}
+script_mkdir_list += ${${group}DIR.${script:T}}
 
-__SCRIPTINSTALL_USE: .USE
-	${INSTALL} ${INSTALL_FLAGS_${.TARGET:T}:U${INSTALL_FLAGS}} \
-	    ${.ALLSRC} ${.TARGET}
+${group}NAME.${script} ?= ${${group}NAME_${script:T}:U${script:${SCRIPTSNAME_MOD}}}
+.if ${${group}NAME.${script}:T} != ${script:T}
+STAGE_AS_SETS += ${group}
+STAGE_AS_${script} = ${${group}NAME.${script:T}}
+stage_as.${group}: ${script}
 
-.for s in ${SCRIPTS}
-.if !defined(BUILD) && !make(all) && !make(${s})
-${DESTDIR}${SCRIPTSDIR_$s:U${SCRIPTSDIR}}/${SCRIPTSNAME_$s:U${s:${SCRIPTSNAME_MOD}}}:	.MADE
-.endif
-${DESTDIR}${SCRIPTSDIR_$s:U${SCRIPTSDIR}}/${SCRIPTSNAME_$s:U${s:${SCRIPTSNAME_MOD}}}:	${s} __SCRIPTINSTALL_USE
-.endfor
-.endif
+installscripts: installscripts.${group}.${script:T}
+installscripts.${group}.${script:T}: ${script} script_mkdirs
+	${INSTALL} ${SCRIPTS_COPY} ${${group}_INSTALL_OWN.${script:T}} \
+	-m ${SCRIPTSMODE} ${.ALLSRC:Nscript_mkdirs} ${DESTDIR}${${group}DIR}/${${group}NAME.${script:T}}
 
+.else
+STAGE_SETS += ${group}
+stage_files.${group}: ${script}
+installscripts.${group}: ${script}
+installscripts: installscripts.${group}
 .endif
 
-.if !target(scriptsinstall)
-scriptsinstall::
-.endif
+.endfor				# script
 
+installscripts.${group}: script_mkdirs
+	${INSTALL} ${SCRIPTS_COPY} ${${group}_INSTALL_OWN} -m ${SCRIPTSMODE} \
+	${.ALLSRC:Nscript_mkdirs:O:u} ${DESTDIR}${${group}DIR}
+
+.endif				# !empty
+.endfor				# group
+
+script_mkdirs:
+	@for d in ${script_mkdir_list:O:u}; do \
+		test -d ${DESTDIR}$$d || \
+		${INSTALL} -d ${SCRIPTS_INSTALL_OWN} -m 775 ${DESTDIR}$$d; \
+	done
+
+
+beforeinstall:
+installscripts:
+realinstall:	installscripts
+.ORDER: beforeinstall installscripts
+

Index: vendor/NetBSD/bmake/dist/mk/stage-install.sh
===================================================================
--- vendor/NetBSD/bmake/dist/mk/stage-install.sh	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/mk/stage-install.sh	2018-06-27 00:17:22 UTC (rev 11138)

Property changes on: vendor/NetBSD/bmake/dist/mk/stage-install.sh
___________________________________________________________________
Deleted: svn:executable
Modified: vendor/NetBSD/bmake/dist/mk/subdir.mk
===================================================================
--- vendor/NetBSD/bmake/dist/mk/subdir.mk	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/mk/subdir.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,4 +1,4 @@
-#	$Id: subdir.mk,v 1.14 2012/11/12 04:34:33 sjg Exp $
+#	$Id: subdir.mk,v 1.16 2017/02/08 22:16:59 sjg Exp $
 #	skip missing directories...
 
 #	$NetBSD: bsd.subdir.mk,v 1.11 1996/04/04 02:05:06 jtc Exp $
@@ -9,9 +9,7 @@
 # keep everyone happy
 _SUBDIRUSE:
 .elif !commands(_SUBDIRUSE) && !defined(NO_SUBDIR) && !defined(NOSUBDIR)
-.if exists(${.CURDIR}/Makefile.inc)
-.include "Makefile.inc"
-.endif
+.-include <${.CURDIR}/Makefile.inc>
 .if !target(.MAIN)
 .MAIN: all
 .endif
@@ -47,13 +45,18 @@
 	done
 
 ${SUBDIR}::
-	@set -e; if test -d ${.CURDIR}/${.TARGET}.${MACHINE}; then \
-		_newdir_=${.TARGET}.${MACHINE}; \
+	@set -e; _r=${.CURDIR}/; \
+	if test -z "${.TARGET:M/*}"; then \
+		if test -d ${.CURDIR}/${.TARGET}.${MACHINE}; then \
+			_newdir_=${.TARGET}.${MACHINE}; \
+		else \
+			_newdir_=${.TARGET}; \
+		fi; \
 	else \
-		_newdir_=${.TARGET}; \
+		_r= _newdir_=${.TARGET}; \
 	fi; \
 	${ECHO_DIR} "===> $${_newdir_}"; \
-	cd ${.CURDIR}/$${_newdir_}; \
+	cd $${_r}$${_newdir_}; \
 	${.MAKE} _THISDIR_="$${_newdir_}" all
 .endif
 

Modified: vendor/NetBSD/bmake/dist/mk/sys/AIX.mk
===================================================================
--- vendor/NetBSD/bmake/dist/mk/sys/AIX.mk	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/mk/sys/AIX.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -9,7 +9,7 @@
 
 NOPIC=no	# no shared libs?
 
-.SUFFIXES: .out .a .ln .o .c .cc .C .F .f .r .y .l .s .S .cl .p .h .sh .m4
+.SUFFIXES: .out .a .ln .o .c ${CXX_SUFFIXES} .F .f .r .y .l .s .S .cl .p .h .sh .m4
 
 .LIBS:		.a
 
@@ -67,8 +67,6 @@
 LINT=		lint
 LINTFLAGS=	-chapbx
 
-MAKE=		bmake
-
 PC=		pc
 PFLAGS=
 COMPILE.p=	${PC} ${PFLAGS} ${CPPFLAGS} -c
@@ -91,24 +89,15 @@
 	rm -f $*.o
 
 # C++
-.cc:
+${CXX_SUFFIXES}:
 	${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
-.cc.o:
+${CXX_SUFFIXES:%=%.o}:
 	${COMPILE.cc} ${.IMPSRC}
-.cc.a:
+${CXX_SUFFIXES:%=%.a}:
 	${COMPILE.cc} ${.IMPSRC}
 	${AR} ${ARFLAGS} $@ $*.o
 	rm -f $*.o
 
-.C:
-	${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
-.C.o:
-	${COMPILE.cc} ${.IMPSRC}
-.C.a:
-	${COMPILE.cc} ${.IMPSRC}
-	${AR} ${ARFLAGS} $@ $*.o
-	rm -f $*.o
-
 # Fortran/Ratfor
 .f:
 	${LINK.f} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}

Modified: vendor/NetBSD/bmake/dist/mk/sys/Darwin.mk
===================================================================
--- vendor/NetBSD/bmake/dist/mk/sys/Darwin.mk	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/mk/sys/Darwin.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -4,7 +4,7 @@
 OS=		Darwin
 unix?=		We run ${OS}.
 
-.SUFFIXES: .out .a .ln .o .s .S .c .cc .cpp .cxx .C .F .f .r .y .l .cl .p .h
+.SUFFIXES: .out .a .ln .o .s .S .c ${CXX_SUFFIXES} .F .f .r .y .l .cl .p .h
 .SUFFIXES: .sh .m4 .dylib
 
 .LIBS:		.a .dylib
@@ -84,8 +84,6 @@
 
 LORDER?=	lorder
 
-MAKE?=		bmake
-
 NM?=		nm
 
 PC?=		pc
@@ -114,24 +112,15 @@
 	rm -f $*.o
 
 # C++
-.cc:
+${CXX_SUFFIXES}:
 	${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
-.cc.o:
+${CXX_SUFFIXES:%=%.o}:
 	${COMPILE.cc} ${.IMPSRC}
-.cc.a:
+${CXX_SUFFIXES:%=%.a}:
 	${COMPILE.cc} ${.IMPSRC}
 	${AR} ${ARFLAGS} $@ $*.o
 	rm -f $*.o
 
-.C:
-	${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
-.C.o:
-	${COMPILE.cc} ${.IMPSRC}
-.C.a:
-	${COMPILE.cc} ${.IMPSRC}
-	${AR} ${ARFLAGS} $@ $*.o
-	rm -f $*.o
-
 # Fortran/Ratfor
 .f:
 	${LINK.f} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}

Modified: vendor/NetBSD/bmake/dist/mk/sys/Generic.mk
===================================================================
--- vendor/NetBSD/bmake/dist/mk/sys/Generic.mk	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/mk/sys/Generic.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,8 +1,8 @@
-#	$Id: Generic.mk,v 1.11 2010/09/24 05:59:53 sjg Exp $
+#	$Id: Generic.mk,v 1.13 2017/05/05 18:02:16 sjg Exp $
 #
 
 # some reasonable defaults
-.SUFFIXES: .out .a .ln .o .s .S .c .cc .cpp .cxx .C .F .f .r .y .l .cl .p .h
+.SUFFIXES: .out .a .ln .o .s .S .c ${CXX_SUFFIXES} .F .f .r .y .l .cl .p .h
 .SUFFIXES: .sh .m4
 
 .LIBS:		.a
@@ -80,8 +80,6 @@
 LINT?=		lint
 LINTFLAGS?=	-chapbxzF
 
-MAKE?=		${.MAKE}
-
 NM?=		nm
 
 PC?=		pc
@@ -110,11 +108,11 @@
 	${LINT} ${LINTFLAGS} ${CPPFLAGS:M-[IDU]*} -i ${.IMPSRC}
 
 # C++
-.cc .cpp .cxx .C:
+${CXX_SUFFIXES}:
 	${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
-.cc.o .cpp.o .cxx.o .C.o:
+${CXX_SUFFIXES:%=%.o}:
 	${COMPILE.cc} ${.IMPSRC}
-.cc.a .cpp.a .cxx.a .C.a:
+${CXX_SUFFIXES:%=%.a}:
 	${COMPILE.cc} ${.IMPSRC}
 	${AR} ${ARFLAGS} $@ $*.o
 	rm -f $*.o

Modified: vendor/NetBSD/bmake/dist/mk/sys/HP-UX.mk
===================================================================
--- vendor/NetBSD/bmake/dist/mk/sys/HP-UX.mk	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/mk/sys/HP-UX.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,4 +1,4 @@
-#	$Id: HP-UX.mk,v 1.9 2003/09/30 16:42:23 sjg Exp $
+#	$Id: HP-UX.mk,v 1.11 2017/05/05 18:02:16 sjg Exp $
 #	$NetBSD: sys.mk,v 1.19.2.1 1994/07/26 19:58:31 cgd Exp $
 #	@(#)sys.mk	5.11 (Berkeley) 3/13/91
 
@@ -14,7 +14,7 @@
 OSMAJOR?=10
 __HPUX_VERSION?=${OSMAJOR}
 
-.SUFFIXES: .out .a .ln .o .c .cc .C .F .f .r .y .l .s .S .cl .p .h .sh .m4
+.SUFFIXES: .out .a .ln .o .c ${CXX_SUFFIXES} .F .f .r .y .l .s .S .cl .p .h .sh .m4
 
 LIBMODE= 755
 LIBCRT0=	/lib/crt0.o
@@ -101,8 +101,6 @@
 LINT=		lint
 LINTFLAGS=	-chapbx
 
-MAKE=		bmake
-
 PC=		pc
 PFLAGS=
 COMPILE.p=	${PC} ${PFLAGS} ${CPPFLAGS} -c
@@ -131,24 +129,15 @@
 	rm -f $*.o
 
 # C++
-.cc:
+${CXX_SUFFIXES}:
 	${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
-.cc.o:
+${CXX_SUFFIXES:%=%.o}:
 	${COMPILE.cc} ${.IMPSRC}
-.cc.a:
+${CXX_SUFFIXES:%=%.a}:
 	${COMPILE.cc} ${.IMPSRC}
 	${AR} ${ARFLAGS} $@ $*.o
 	rm -f $*.o
 
-.C:
-	${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
-.C.o:
-	${COMPILE.cc} ${.IMPSRC}
-.C.a:
-	${COMPILE.cc} ${.IMPSRC}
-	${AR} ${ARFLAGS} $@ $*.o
-	rm -f $*.o
-
 # Fortran/Ratfor
 .f:
 	${LINK.f} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}

Modified: vendor/NetBSD/bmake/dist/mk/sys/IRIX.mk
===================================================================
--- vendor/NetBSD/bmake/dist/mk/sys/IRIX.mk	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/mk/sys/IRIX.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -10,7 +10,7 @@
 unix?=		We run ${OS}.
 .endif
 
-.SUFFIXES: .out .a .ln .o .s .S .c .cc .cpp .cxx .C .F .f .r .y .l .cl .p .h
+.SUFFIXES: .out .a .ln .o .s .S .c ${CXX_SUFFIXES} .F .f .r .y .l .cl .p .h
 .SUFFIXES: .sh .m4
 
 .LIBS:		.a
@@ -70,8 +70,6 @@
 
 LORDER?=	lorder
 
-MAKE?=		make
-
 NM?=		nm
 
 PC?=		pc
@@ -102,11 +100,11 @@
 	${LINT} ${LINTFLAGS} ${CPPFLAGS:M-[IDU]*} -i ${.IMPSRC}
 
 # C++
-.cc .cpp .cxx .C:
+${CXX_SUFFIXES}:
 	${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
-.cc.o .cpp.o .cxx.o .C.o:
+${CXX_SUFFIXES:%=%.o}:
 	${COMPILE.cc} ${.IMPSRC}
-.cc.a .cpp.a .cxx.a .C.a:
+${CXX_SUFFIXES:%=%.a}:
 	${COMPILE.cc} ${.IMPSRC}
 	${AR} ${ARFLAGS} $@ $*.o
 	rm -f $*.o

Modified: vendor/NetBSD/bmake/dist/mk/sys/Linux.mk
===================================================================
--- vendor/NetBSD/bmake/dist/mk/sys/Linux.mk	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/mk/sys/Linux.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,4 +1,4 @@
-#	$Id: Linux.mk,v 1.7 2011/03/02 05:05:21 sjg Exp $
+#	$Id: Linux.mk,v 1.9 2017/05/05 18:02:16 sjg Exp $
 #	$NetBSD: sys.mk,v 1.19.2.1 1994/07/26 19:58:31 cgd Exp $
 #	@(#)sys.mk	5.11 (Berkeley) 3/13/91
 
@@ -12,7 +12,7 @@
 
 NEED_SOLINKS=yes
 
-.SUFFIXES: .out .a .ln .o .c .cc .C .F .f .r .y .l .s .S .cl .p .h .sh .m4
+.SUFFIXES: .out .a .ln .o .c ${CXX_SUFFIXES} .F .f .r .y .l .s .S .cl .p .h .sh .m4
 
 .LIBS:		.a
 
@@ -70,8 +70,6 @@
 LINT=		lint
 LINTFLAGS=	-chapbx
 
-MAKE=		bmake
-
 PC=		pc
 PFLAGS=
 COMPILE.p=	${PC} ${PFLAGS} ${CPPFLAGS} -c
@@ -94,24 +92,15 @@
 	rm -f $*.o
 
 # C++
-.cc:
+${CXX_SUFFIXES}:
 	${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
-.cc.o:
+${CXX_SUFFIXES:%=%.o}:
 	${COMPILE.cc} ${.IMPSRC}
-.cc.a:
+${CXX_SUFFIXES:%=%.a}:
 	${COMPILE.cc} ${.IMPSRC}
 	${AR} ${ARFLAGS} $@ $*.o
 	rm -f $*.o
 
-.C:
-	${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
-.C.o:
-	${COMPILE.cc} ${.IMPSRC}
-.C.a:
-	${COMPILE.cc} ${.IMPSRC}
-	${AR} ${ARFLAGS} $@ $*.o
-	rm -f $*.o
-
 # Fortran/Ratfor
 .f:
 	${LINK.f} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}

Modified: vendor/NetBSD/bmake/dist/mk/sys/NetBSD.mk
===================================================================
--- vendor/NetBSD/bmake/dist/mk/sys/NetBSD.mk	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/mk/sys/NetBSD.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -19,7 +19,7 @@
 .endif
 .endif
 
-.SUFFIXES: .out .a .ln .o .s .S .c .cc .cpp .cxx .C .F .f .r .y .l .cl .p .h
+.SUFFIXES: .out .a .ln .o .s .S .c ${CXX_SUFFIXES} .F .f .r .y .l .cl .p .h
 .SUFFIXES: .sh .m4
 
 .LIBS:		.a
@@ -105,8 +105,6 @@
 
 LORDER?=	lorder
 
-MAKE?=		make
-
 NM?=		nm
 
 PC?=		pc
@@ -137,11 +135,11 @@
 	${LINT} ${LINTFLAGS} ${CPPFLAGS:M-[IDU]*} -i ${.IMPSRC}
 
 # C++
-.cc .cpp .cxx .C:
+${CXX_SUFFIXES}:
 	${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
-.cc.o .cpp.o .cxx.o .C.o:
+${CXX_SUFFIXES:%=%.o}:
 	${COMPILE.cc} ${.IMPSRC}
-.cc.a .cpp.a .cxx.a .C.a:
+${CXX_SUFFIXES:%=%.a}:
 	${COMPILE.cc} ${.IMPSRC}
 	${AR} ${ARFLAGS} $@ $*.o
 	rm -f $*.o

Modified: vendor/NetBSD/bmake/dist/mk/sys/OSF1.mk
===================================================================
--- vendor/NetBSD/bmake/dist/mk/sys/OSF1.mk	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/mk/sys/OSF1.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,4 +1,4 @@
-#	$Id: OSF1.mk,v 1.6 2003/09/30 16:42:23 sjg Exp $
+#	$Id: OSF1.mk,v 1.8 2017/05/05 18:02:16 sjg Exp $
 #	$NetBSD: sys.mk,v 1.19.2.1 1994/07/26 19:58:31 cgd Exp $
 #	@(#)sys.mk	5.11 (Berkeley) 3/13/91
 
@@ -11,7 +11,7 @@
 
 PATH=/usr/sbin:/usr/bin:/usr/ucb:/opt/gnu/bin:/usr/ccs/bin
 
-.SUFFIXES: .out .a .ln .o .c .cc .C .F .f .r .y .l .s .S .cl .p .h .sh .m4
+.SUFFIXES: .out .a .ln .o .c ${CXX_SUFFIXES} .F .f .r .y .l .s .S .cl .p .h .sh .m4
 
 .LIBS:		.a
 
@@ -77,8 +77,6 @@
 LINT=		lint
 LINTFLAGS=	-chapbx
 
-MAKE=		bmake
-
 PC=		pc
 PFLAGS=
 COMPILE.p=	${PC} ${PFLAGS} ${CPPFLAGS} -c
@@ -105,24 +103,15 @@
 	rm -f $*.o
 
 # C++
-.cc:
+${CXX_SUFFIXES}:
 	${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
-.cc.o:
+${CXX_SUFFIXES:%=%.o}:
 	${COMPILE.cc} ${.IMPSRC}
-.cc.a:
+${CXX_SUFFIXES:%=%.a}:
 	${COMPILE.cc} ${.IMPSRC}
 	${AR} ${ARFLAGS} $@ $*.o
 	rm -f $*.o
 
-.C:
-	${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
-.C.o:
-	${COMPILE.cc} ${.IMPSRC}
-.C.a:
-	${COMPILE.cc} ${.IMPSRC}
-	${AR} ${ARFLAGS} $@ $*.o
-	rm -f $*.o
-
 # Fortran/Ratfor
 .f:
 	${LINK.f} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}

Modified: vendor/NetBSD/bmake/dist/mk/sys/OpenBSD.mk
===================================================================
--- vendor/NetBSD/bmake/dist/mk/sys/OpenBSD.mk	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/mk/sys/OpenBSD.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -4,7 +4,7 @@
 OS=		OpenBSD
 unix?=		We run ${OS}.
 
-.SUFFIXES: .out .a .ln .o .s .S .c .cc .cpp .cxx .C .F .f .r .y .l .cl .p .h
+.SUFFIXES: .out .a .ln .o .s .S .c ${CXX_SUFFIXES} .F .f .r .y .l .cl .p .h
 .SUFFIXES: .sh .m4
 
 .LIBS:		.a
@@ -80,8 +80,6 @@
 
 LORDER?=	lorder
 
-MAKE?=		make
-
 NM?=		nm
 
 PC?=		pc
@@ -112,11 +110,11 @@
 	${LINT} ${LINTFLAGS} ${CPPFLAGS:M-[IDU]*} -i ${.IMPSRC}
 
 # C++
-.cc .cpp .cxx .C:
+${CXX_SUFFIXES}:
 	${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
-.cc.o .cpp.o .cxx.o .C.o:
+${CXX_SUFFIXES:%=%.o}:
 	${COMPILE.cc} ${.IMPSRC}
-.cc.a .cpp.a .cxx.a .C.a:
+${CXX_SUFFIXES:%=%.a}:
 	${COMPILE.cc} ${.IMPSRC}
 	${AR} ${ARFLAGS} $@ $*.o
 	rm -f $*.o

Modified: vendor/NetBSD/bmake/dist/mk/sys/SunOS.mk
===================================================================
--- vendor/NetBSD/bmake/dist/mk/sys/SunOS.mk	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/mk/sys/SunOS.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,4 +1,4 @@
-#	$Id: SunOS.mk,v 1.6 2014/04/05 22:56:54 sjg Exp $
+#	$Id: SunOS.mk,v 1.8 2017/05/05 18:02:17 sjg Exp $
 
 .if ${.PARSEFILE} == "sys.mk"
 .include <host-target.mk>
@@ -41,7 +41,7 @@
 
 # the rest is common
 
-.SUFFIXES: .out .a .ln .o .c .cc .C .F .f .r .y .l .s .S .cl .p .h .sh .m4
+.SUFFIXES: .out .a .ln .o .c ${CXX_SUFFIXES} .F .f .r .y .l .s .S .cl .p .h .sh .m4
 
 .LIBS:		.a
 
@@ -98,8 +98,6 @@
 LINT=		lint
 LINTFLAGS=	-chapbx
 
-MAKE=		bmake
-
 PC=		pc
 PFLAGS=
 COMPILE.p=	${PC} ${PFLAGS} ${CPPFLAGS} -c
@@ -126,24 +124,15 @@
 	rm -f $*.o
 
 # C++
-.cc:
+${CXX_SUFFIXES}:
 	${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
-.cc.o:
+${CXX_SUFFIXES:%=%.o}:
 	${COMPILE.cc} ${.IMPSRC}
-.cc.a:
+${CXX_SUFFIXES:%=%.a}:
 	${COMPILE.cc} ${.IMPSRC}
 	${AR} ${ARFLAGS} $@ $*.o
 	rm -f $*.o
 
-.C:
-	${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
-.C.o:
-	${COMPILE.cc} ${.IMPSRC}
-.C.a:
-	${COMPILE.cc} ${.IMPSRC}
-	${AR} ${ARFLAGS} $@ $*.o
-	rm -f $*.o
-
 # Fortran/Ratfor
 .f:
 	${LINK.f} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}

Modified: vendor/NetBSD/bmake/dist/mk/sys/UnixWare.mk
===================================================================
--- vendor/NetBSD/bmake/dist/mk/sys/UnixWare.mk	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/mk/sys/UnixWare.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,4 +1,4 @@
-#	$Id: UnixWare.mk,v 1.1 2005/10/09 22:56:40 sjg Exp $
+#	$Id: UnixWare.mk,v 1.3 2017/05/05 18:02:17 sjg Exp $
 #	based on "Id: SunOS.5.sys.mk,v 1.6 2003/09/30 16:42:23 sjg Exp "
 #	$NetBSD: sys.mk,v 1.19.2.1 1994/07/26 19:58:31 cgd Exp $
 #	@(#)sys.mk	5.11 (Berkeley) 3/13/91
@@ -12,7 +12,7 @@
 
 PATH=/usr/sbin:/usr/bin:/usr/ccs/bin:/usr/ccs/lib:/usr/ucb:/usr/local/bin
 
-.SUFFIXES: .out .a .ln .o .c .cc .C .F .f .r .y .l .s .S .cl .p .h .sh .m4
+.SUFFIXES: .out .a .ln .o .c ${CXX_SUFFIXES} .F .f .r .y .l .s .S .cl .p .h .sh .m4
 
 .LIBS:		.a
 
@@ -114,8 +114,6 @@
 
 LORDER?=	lorder
 
-MAKE?=		bmake
-
 NM?=		nm
 
 PC?=		pc # XXX: UDK probably does not have pc
@@ -148,24 +146,15 @@
 	rm -f $*.o
 
 # C++
-.cc:
+${CXX_SUFFIXES}:
 	${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
-.cc.o:
+${CXX_SUFFIXES:%=%.o}:
 	${COMPILE.cc} ${.IMPSRC}
-.cc.a:
+${CXX_SUFFIXES:%=%.a}:
 	${COMPILE.cc} ${.IMPSRC}
 	${AR} ${ARFLAGS} $@ $*.o
 	rm -f $*.o
 
-.C:
-	${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
-.C.o:
-	${COMPILE.cc} ${.IMPSRC}
-.C.a:
-	${COMPILE.cc} ${.IMPSRC}
-	${AR} ${ARFLAGS} $@ $*.o
-	rm -f $*.o
-
 # Fortran/Ratfor
 .f:
 	${LINK.f} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}

Modified: vendor/NetBSD/bmake/dist/mk/sys.clean-env.mk
===================================================================
--- vendor/NetBSD/bmake/dist/mk/sys.clean-env.mk	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/mk/sys.clean-env.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,4 +1,4 @@
-# $Id: sys.clean-env.mk,v 1.20 2012/11/12 06:56:04 sjg Exp $
+# $Id: sys.clean-env.mk,v 1.21 2016/02/18 21:16:40 sjg Exp $
 #
 #	@(#) Copyright (c) 2009, Simon J. Gerraty
 #
@@ -94,6 +94,7 @@
 # MAKEOBJDIR='${.CURDIR:S,${SRCTOP},${OBJTOP},}'
 _srctop := ${SRCTOP:U${SB_SRC:U${SB}/src}}
 _objroot := ${OBJROOT:U${SB_OBJROOT:U${SB}/${SB_OBJPREFIX}}}
+.if ${MAKE_VERSION} < 20160218
 _objtop := ${OBJTOP:U${_objroot}${MACHINE}}
 # Take care of ${MACHINE}
 .if ${MACHINE} == "host" || ${OBJTOP} == ${HOST_OBJTOP:Uno}
@@ -113,7 +114,17 @@
 .for v in ${_tricky_env_vars}
 $v := ${$v}
 .endfor
+.else
+# we cannot use the '$$' trick, anymore
+# but we can export a literal (unexpanded) value
+SRCTOP := ${_srctop}
+OBJROOT := ${_objroot}
+OBJTOP = ${OBJROOT}${MACHINE}
+MAKEOBJDIR = ${.CURDIR:S,${SRCTOP},${OBJTOP},}
+.export-literal SRCTOP OBJROOT ${_tricky_env_vars}
+.endif
 #.info ${_tricky_env_vars:@v@${.newline}$v=${$v}@}
-
+#showenv:
+#	@env | egrep 'OBJ|SRC'
 .endif				# MAKEOBJDIR
 .endif				# level 0

Added: vendor/NetBSD/bmake/dist/mk/sys.debug.mk
===================================================================
--- vendor/NetBSD/bmake/dist/mk/sys.debug.mk	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/mk/sys.debug.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,33 @@
+# $Id: sys.debug.mk,v 1.1 2016/10/01 19:11:55 sjg Exp $
+#
+#	@(#) Copyright (c) 2009, Simon J. Gerraty
+#
+#	This file is provided in the hope that it will
+#	be of use.  There is absolutely NO WARRANTY.
+#	Permission to copy, redistribute or otherwise
+#	use this file is hereby granted provided that 
+#	the above copyright notice and this notice are
+#	left intact. 
+#      
+#	Please send copies of changes and bug-fixes to:
+#	sjg at crufty.net
+#
+
+# Sometimes we want to turn on debugging in just one or two places
+# if .CURDIR is matched by any entry in DEBUG_MAKE_SYS_DIRS we
+# will apply DEBUG_MAKE_FLAGS now.
+# if an entry in DEBUG_MAKE_DIRS matches, we at the end of sys.mk
+# eg.  DEBUG_MAKE_FLAGS=-dv DEBUG_MAKE_SYS_DIRS="*lib/sjg"
+# use DEBUG_MAKE_FLAGS0 to apply only to .MAKE.LEVEL 0
+#
+.if ${.MAKE.LEVEL:U1} == 0
+# we use indirection, to simplify the tests below, and incase
+# DEBUG_* were given on our command line.
+_DEBUG_MAKE_FLAGS = ${DEBUG_MAKE_FLAGS0}
+_DEBUG_MAKE_SYS_DIRS = ${DEBUG_MAKE_SYS_DIRS0:U${DEBUG_MAKE_SYS_DIRS}}
+_DEBUG_MAKE_DIRS = ${DEBUG_MAKE_DIRS0:U${DEBUG_MAKE_DIRS}}
+.else
+_DEBUG_MAKE_FLAGS = ${DEBUG_MAKE_FLAGS}
+_DEBUG_MAKE_SYS_DIRS = ${DEBUG_MAKE_SYS_DIRS}
+_DEBUG_MAKE_DIRS = ${DEBUG_MAKE_DIRS}
+.endif

Modified: vendor/NetBSD/bmake/dist/mk/sys.dependfile.mk
===================================================================
--- vendor/NetBSD/bmake/dist/mk/sys.dependfile.mk	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/mk/sys.dependfile.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,4 +1,4 @@
-# $Id: sys.dependfile.mk,v 1.5 2013/03/08 00:59:21 sjg Exp $
+# $Id: sys.dependfile.mk,v 1.8 2016/03/11 01:34:13 sjg Exp $
 #
 #	@(#) Copyright (c) 2012, Simon J. Gerraty
 #
@@ -25,6 +25,12 @@
 # All depend file names should start with this
 .MAKE.DEPENDFILE_PREFIX ?= Makefile.depend
 
+.if !empty(.MAKE.DEPENDFILE) && \
+	${.MAKE.DEPENDFILE:M${.MAKE.DEPENDFILE_PREFIX}*} == ""
+# let us do our thing below...
+.undef .MAKE.DEPENDFILE
+.endif
+
 # The order of preference: we will use the first one of these we find.
 # It usually makes sense to order from most specific to least.
 .MAKE.DEPENDFILE_PREFERENCE ?= \
@@ -42,8 +48,10 @@
 # MACHINE specific depend files are supported, but *not* default.
 # If any already exist, we should follow suit.
 _aml = ${ALL_MACHINE_LIST:Uarm amd64 i386 powerpc:N${MACHINE}} ${MACHINE}
-# MACHINE must be the last entry in _aml ;-)
+# make sure we restore MACHINE
+_m := ${MACHINE}
 _e := ${_aml:@MACHINE@${.MAKE.DEPENDFILE_PREFERENCE:@m@${exists($m):?$m:}@}@}
+MACHINE := ${_m}
 .if !empty(_e)
 .MAKE.DEPENDFILE ?= ${.MAKE.DEPENDFILE_PREFERENCE:M*${MACHINE}:[1]}
 .endif

Modified: vendor/NetBSD/bmake/dist/mk/sys.mk
===================================================================
--- vendor/NetBSD/bmake/dist/mk/sys.mk	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/mk/sys.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,4 +1,4 @@
-# $Id: sys.mk,v 1.36 2014/05/11 00:30:19 sjg Exp $
+# $Id: sys.mk,v 1.45 2017/02/05 01:26:13 sjg Exp $
 #
 #	@(#) Copyright (c) 2003-2009, Simon J. Gerraty
 #
@@ -15,39 +15,9 @@
 
 # Avoid putting anything platform specific in here.
 
-# We use the following paradigm for preventing multiple inclusion.
-# It relies on the fact that conditionals and dependencies are resolved 
-# at the time they are read.
-#
-# _this ?= ${.PARSEFILE}
-# .if !target(__${_this}__)
-# __${_this}__:
-#
-.if ${MAKE_VERSION:U0} > 20100408
-_this = ${.PARSEDIR:tA}/${.PARSEFILE}
-.else
-_this = ${.PARSEDIR}/${.PARSEFILE}
-.endif
+# _DEBUG_MAKE_FLAGS etc.
+.include <sys.debug.mk>
 
-# Sometimes we want to turn on debugging in just one or two places
-# if .CURDIR is matched by any entry in DEBUG_MAKE_SYS_DIRS we
-# will apply DEBUG_MAKE_FLAGS now.
-# if an entry in DEBUG_MAKE_DIRS matches, we at the end of sys.mk
-# eg.  DEBUG_MAKE_FLAGS=-dv DEBUG_MAKE_SYS_DIRS="*lib/sjg"
-# use DEBUG_MAKE_FLAGS0 to apply only to .MAKE.LEVEL 0
-#
-.if ${.MAKE.LEVEL:U1} == 0
-# we use indirection, to simplify the tests below, and incase
-# DEBUG_* were given on our command line.
-_DEBUG_MAKE_FLAGS = ${DEBUG_MAKE_FLAGS0}
-_DEBUG_MAKE_SYS_DIRS = ${DEBUG_MAKE_SYS_DIRS0:U${DEBUG_MAKE_SYS_DIRS}}
-_DEBUG_MAKE_DIRS = ${DEBUG_MAKE_DIRS0:U${DEBUG_MAKE_DIRS}}
-.else
-_DEBUG_MAKE_FLAGS = ${DEBUG_MAKE_FLAGS}
-_DEBUG_MAKE_SYS_DIRS = ${DEBUG_MAKE_SYS_DIRS}
-_DEBUG_MAKE_DIRS = ${DEBUG_MAKE_DIRS}
-.endif
-
 .if !empty(_DEBUG_MAKE_FLAGS)
 .if ${_DEBUG_MAKE_SYS_DIRS:Uno:@x@${.CURDIR:M$x}@} != ""
 .MAKEFLAGS: ${_DEBUG_MAKE_FLAGS}
@@ -54,44 +24,9 @@
 .endif
 .endif
 
-# if this is an ancient version of bmake
-MAKE_VERSION ?= 0
-.if ${MAKE_VERSION:M*make-*}
-# turn it into what we want - just the date
-MAKE_VERSION := ${MAKE_VERSION:[1]:C,.*-,,}
-.endif
+# useful modifiers
+.include <sys.vars.mk>
 
-# some useful modifiers
-
-# A useful trick for testing multiple :M's against something
-# :L says to use the variable's name as its value - ie. literal
-# got = ${clean* destroy:${M_ListToMatch:S,V,.TARGETS,}}
-M_ListToMatch = L:@m@$${V:M$$m}@
-# match against our initial targets (see above)
-M_L_TARGETS = ${M_ListToMatch:S,V,_TARGETS,}
-
-# turn a list into a set of :N modifiers
-# NskipFoo = ${Foo:${M_ListToSkip}}
-M_ListToSkip= O:u:ts::S,:,:N,g:S,^,N,
-
-# type should be a builtin in any sh since about 1980,
-# AUTOCONF := ${autoconf:L:${M_whence}}
-M_type = @x@(type $$x 2> /dev/null); echo;@:sh:[0]:N* found*:[@]:C,[()],,g
-M_whence = ${M_type}:M/*:[1]
-
-# convert a path to a valid shell variable
-M_P2V = tu:C,[./-],_,g
-
-# convert path to absolute
-.if ${MAKE_VERSION:U0} > 20100408
-M_tA = tA
-.else
-M_tA = C,.*,('cd' & \&\& 'pwd') 2> /dev/null || echo &,:sh
-.endif
-
-# absoulte path to what we are reading.
-_PARSEDIR = ${.PARSEDIR:${M_tA}}
-
 # we expect a recent bmake
 .if !defined(_TARGETS)
 # some things we do only once
@@ -102,6 +37,13 @@
 # we need HOST_TARGET etc below.
 .include <host-target.mk>
 
+# early customizations
+.-include <local.sys.env.mk>
+
+# Popular suffixes for C++
+CXX_SUFFIXES += .cc .cpp .cxx .C
+CXX_SUFFIXES := ${CXX_SUFFIXES:O:u}
+
 # find the OS specifics
 .if defined(SYS_OS_MK)
 .include <${SYS_OS_MK}>
@@ -126,11 +68,30 @@
 .export SYS_OS_MK
 .endif
 
-# allow customization without editing.
-.-include <local.sys.mk>
+# some options we need to know early
+OPTIONS_DEFAULT_NO += \
+	DIRDEPS_BUILD \
+	DIRDEPS_CACHE
 
+OPTIONS_DEFAULT_DEPENDENT += \
+	AUTO_OBJ/DIRDEPS_BUILD \
+	META_MODE/DIRDEPS_BUILD \
+	STAGING/DIRDEPS_BUILD \
+
+.-include <options.mk>
+
+.if ${MK_DIRDEPS_BUILD:Uno} == "yes"
+MK_META_MODE = yes
+.-include <meta.sys.mk>
+.elif ${MK_META_MODE:Uno} == "yes"
+.MAKE.MODE = meta verbose
+.endif
+# make sure we have a harmless value
+.MAKE.MODE ?= normal
+
 # if you want objdirs make them automatic
-.if ${MKOBJDIRS:Uno} == "auto"
+# and do it early before we compute .PATH
+.if ${MK_AUTO_OBJ:Uno} == "yes" || ${MKOBJDIRS:Uno} == "auto"
 .include <auto.obj.mk>
 .endif
 
@@ -175,20 +136,11 @@
 .c.cpp-out:
 	@${COMPILE.c:N-c} -E ${.IMPSRC} | grep -v '^[ 	]*$$'
 
-.cc.cpp-out:
+${CXX_SUFFIXES:%=%.cpp-out}:
 	@${COMPILE.cc:N-c} -E ${.IMPSRC} | grep -v '^[ 	]*$$'
 
-# we don't include own.mk but user can expect -DWITH_META_MODE to work
-.if defined(WITHOUT_META_MODE)
-USE_META= no
-.elif defined(WITH_META_MODE)
-USE_META= yes
-.endif
-.if ${USE_META:Uno} == "yes"
-.-include <meta.sys.mk>
-.endif
-# make sure we have a harmless value
-.MAKE.MODE ?= normal
+# late customizations
+.-include <local.sys.mk>
 
 # if .CURDIR is matched by any entry in DEBUG_MAKE_DIRS we
 # will apply DEBUG_MAKE_FLAGS, now.

Added: vendor/NetBSD/bmake/dist/mk/sys.vars.mk
===================================================================
--- vendor/NetBSD/bmake/dist/mk/sys.vars.mk	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/mk/sys.vars.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,80 @@
+# $Id: sys.vars.mk,v 1.2 2017/01/31 07:44:45 sjg Exp $
+#
+#	@(#) Copyright (c) 2003-2009, Simon J. Gerraty
+#
+#	This file is provided in the hope that it will
+#	be of use.  There is absolutely NO WARRANTY.
+#	Permission to copy, redistribute or otherwise
+#	use this file is hereby granted provided that 
+#	the above copyright notice and this notice are
+#	left intact. 
+#      
+#	Please send copies of changes and bug-fixes to:
+#	sjg at crufty.net
+#
+
+# We use the following paradigm for preventing multiple inclusion.
+# It relies on the fact that conditionals and dependencies are resolved 
+# at the time they are read.
+#
+# _this ?= ${.PARSEFILE}
+# .if !target(__${_this}__)
+# __${_this}__:
+#
+.if ${MAKE_VERSION:U0} > 20100408
+_this = ${.PARSEDIR:tA}/${.PARSEFILE}
+.else
+_this = ${.PARSEDIR}/${.PARSEFILE}
+.endif
+
+# if this is an ancient version of bmake
+MAKE_VERSION ?= 0
+.if ${MAKE_VERSION:M*make-*}
+# turn it into what we want - just the date
+MAKE_VERSION := ${MAKE_VERSION:[1]:C,.*-,,}
+.endif
+
+# some useful modifiers
+
+# A useful trick for testing multiple :M's against something
+# :L says to use the variable's name as its value - ie. literal
+# got = ${clean* destroy:${M_ListToMatch:S,V,.TARGETS,}}
+M_ListToMatch = L:@m@$${V:M$$m}@
+# match against our initial targets (see above)
+M_L_TARGETS = ${M_ListToMatch:S,V,_TARGETS,}
+
+# turn a list into a set of :N modifiers
+# NskipFoo = ${Foo:${M_ListToSkip}}
+M_ListToSkip= O:u:ts::S,:,:N,g:S,^,N,
+
+# type should be a builtin in any sh since about 1980,
+# but sadly there are exceptions!
+.if ${.MAKE.OS:Unknown:NBSD/OS} == ""
+_type_sh = which
+.endif
+
+# AUTOCONF := ${autoconf:L:${M_whence}}
+M_type = @x@(${_type_sh:Utype} $$x) 2> /dev/null; echo;@:sh:[0]:N* found*:[@]:C,[()],,g
+M_whence = ${M_type}:M/*:[1]
+
+# convert a path to a valid shell variable
+M_P2V = tu:C,[./-],_,g
+
+# convert path to absolute
+.if ${MAKE_VERSION:U0} > 20100408
+M_tA = tA
+.else
+M_tA = C,.*,('cd' & \&\& 'pwd') 2> /dev/null || echo &,:sh
+.endif
+
+.if ${MAKE_VERSION:U0} >= 20170130
+# M_cmpv allows comparing dotted versions like 3.1.2
+# ${3.1.2:L:${M_cmpv}} -> 3001002
+# we use big jumps to handle 3 digits per dot:
+# ${123.456.789:L:${M_cmpv}} -> 123456789
+M_cmpv.units = 1 1000 1000000
+M_cmpv = S,., ,g:_:range:@i at + $${_:[-$$i]} \* $${M_cmpv.units:[$$i]}@:S,^,expr 0 ,1:sh
+.endif
+
+# absoulte path to what we are reading.
+_PARSEDIR = ${.PARSEDIR:${M_tA}}

Modified: vendor/NetBSD/bmake/dist/mk/warnings.mk
===================================================================
--- vendor/NetBSD/bmake/dist/mk/warnings.mk	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/mk/warnings.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,5 +1,5 @@
 # RCSid:
-#	$Id: warnings.mk,v 1.8 2014/04/02 19:20:23 sjg Exp $
+#	$Id: warnings.mk,v 1.14 2016/04/05 15:58:37 sjg Exp $
 #
 #	@(#) Copyright (c) 2002, Simon J. Gerraty
 #
@@ -15,9 +15,11 @@
 #
 
 .ifndef _w_cflags
+# make sure we get the behavior we expect
+.MAKE.SAVE_DOLLARS = no
 
 # Any number of warnings sets can be added.
-.-include "warnings-sets.mk"
+.-include <warnings-sets.mk>
 
 # Modest defaults - put more elaborate sets in warnings-sets.mk
 # -Wunused  etc are here so you can set
@@ -48,6 +50,11 @@
 DEFAULT_WARNINGS_SET?= MIN
 WARNINGS_SET?= ${DEFAULT_WARNINGS_SET}
 
+# There is always someone who wants more...
+.if !empty(WARNINGS_XTRAS)
+${WARNINGS_SET}_WARNINGS += ${WARNINGS_XTRAS}
+.endif
+
 # If you add sets, besure to list them (you don't have to touch this list).
 ALL_WARNINGS_SETS+= MIN LOW MEDIUM HIGH EXTRA
 
@@ -70,7 +77,7 @@
 # Without -O or if we've set -O0 somewhere - to make debugging more effective,
 # we need to turn off -Wuninitialized as otherwise we get a warning that
 # -Werror turns into an error.  To be safe, set W_uninitialized blank.
-_w_cflags:= ${CFLAGS} ${CPPFLAGS}
+_w_cflags= ${CFLAGS} ${CFLAGS_LAST} ${CPPFLAGS}
 .if ${_w_cflags:M-O*} == "" || ${_w_cflags:M-O0} != ""
 W_uninitialized=
 .endif
@@ -116,6 +123,7 @@
 
 # it is rather silly that g++ blows up on some warning flags
 NO_CXX_WARNINGS+= \
+	implicit \
 	missing-declarations \
 	missing-prototypes \
 	nested-externs \

Added: vendor/NetBSD/bmake/dist/mk/whats.mk
===================================================================
--- vendor/NetBSD/bmake/dist/mk/whats.mk	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/mk/whats.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,63 @@
+# $Id: whats.mk,v 1.1 2014/08/30 22:40:47 sjg Exp $
+#
+#	@(#) Copyright (c) 2014, Simon J. Gerraty
+#
+#	This file is provided in the hope that it will
+#	be of use.  There is absolutely NO WARRANTY.
+#	Permission to copy, redistribute or otherwise
+#	use this file is hereby granted provided that 
+#	the above copyright notice and this notice are
+#	left intact. 
+#      
+#	Please send copies of changes and bug-fixes to:
+#	sjg at crufty.net
+#
+
+.if ${MK_WHATSTRING:Uno} != "no"
+what_build_exts?= o
+# it can be useful to embed a what(1) string in binaries 
+# so that the build location can be seen from a core file.
+.if defined(PROG) && ${.MAKE.MAKEFILES:M*prog.mk} != ""
+what_thing?= ${PROGNAME:U${PROG}}
+what_build_thing?= ${PROG}
+.elif defined(LIB) && ${.MAKE.MAKEFILES:M*lib.mk} != ""
+# probably only makes sense for shared libs
+# and the plumbing needed varies depending on *lib.mk
+what_thing?= lib${LIB}
+.if !empty(SOBJS)
+_soe:= ${SOBJS:E:[1]}
+what_build_exts= ${_soe}
+SOBJS+= ${what_uuid}.${_soe}
+.endif
+.elif defined(KMOD) && ${.MAKE.MAKEFILES:M*kmod.mk} != ""
+what_thing?= ${KMOD}
+what_build_thing?= ${KMOD}.ko
+.endif
+
+.if !empty(what_thing)
+# a unique name that won't conflict with anything
+what_uuid = what_${.CURDIR:T:hash}
+
+.if !empty(what_build_thing)
+${what_build_thing}: ${what_build_exts:@e@${what_uuid}.$e@}
+.endif
+OBJS+= ${what_uuid}.o
+CLEANFILES+= ${what_uuid}.c
+
+# we do not need to capture this
+SUPPRESS_DEPEND+= *${what_uuid}.c
+
+SB?= ${SRCTOP:H}
+SB_LOCATION?= ${HOST}:${SB}
+what_location:= ${.OBJDIR:S,${SB},${SB_LOCATION},}
+
+# this works with clang and gcc
+_what_t= const char __attribute__ ((section(".data")))
+_what1:= @(\#)${what_thing:tu} built ${%Y%m%d:L:localtime} by ${USER}
+_what2:= @(\#)${what_location}
+
+${what_uuid}.c:
+	echo '${_what_t} ${what_uuid}1[] = "${_what1}";' > $@ ${.OODATE:MNO_META_CMP}
+	echo '${_what_t} ${what_uuid}2[] = "${_what2}";' >> $@
+.endif
+.endif

Modified: vendor/NetBSD/bmake/dist/nonints.h
===================================================================
--- vendor/NetBSD/bmake/dist/nonints.h	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/nonints.h	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,4 +1,4 @@
-/*	$NetBSD: nonints.h,v 1.65 2012/08/30 21:17:05 sjg Exp $	*/
+/*	$NetBSD: nonints.h,v 1.74 2016/09/05 00:40:29 sevan Exp $	*/
 
 /*-
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -91,7 +91,7 @@
 
 /* cond.c */
 struct If;
-int Cond_EvalExpression(const struct If *, char *, Boolean *, int);
+int Cond_EvalExpression(const struct If *, char *, Boolean *, int, Boolean);
 int Cond_Eval(char *);
 void Cond_restore_depth(unsigned int);
 unsigned int Cond_save_depth(void);
@@ -109,7 +109,6 @@
 /* main.c */
 void Main_ParseArgLine(const char *);
 void MakeMode(const char *);
-int main(int, char **);
 char *Cmd_Exec(const char *, const char **);
 void Error(const char *, ...) MAKE_ATTR_PRINTFLIKE(1, 2);
 void Fatal(const char *, ...) MAKE_ATTR_PRINTFLIKE(1, 2) MAKE_ATTR_DEAD;
@@ -120,7 +119,9 @@
 int eunlink(const char *);
 void execError(const char *, const char *);
 char *getTmpdir(void);
+Boolean s2Boolean(const char *, Boolean);
 Boolean getBoolean(const char *, Boolean);
+char *cached_realpath(const char *, char *);
 
 /* parse.c */
 void Parse_Error(int, const char *, ...) MAKE_ATTR_PRINTFLIKE(2, 3);
@@ -142,6 +143,11 @@
 char *Str_SYSVMatch(const char *, const char *, int *len);
 void Str_SYSVSubst(Buffer *, char *, char *, int);
 
+#ifndef HAVE_STRLCPY
+/* strlcpy.c */
+size_t strlcpy(char *, const char *, size_t);
+#endif
+
 /* suff.c */
 void Suff_ClearSuffixes(void);
 Boolean Suff_IsTransform(char *);
@@ -184,8 +190,8 @@
 void Var_Append(const char *, const char *, GNode *);
 Boolean Var_Exists(const char *, GNode *);
 char *Var_Value(const char *, GNode *, char **);
-char *Var_Parse(const char *, GNode *, Boolean, int *, void **);
-char *Var_Subst(const char *, const char *, GNode *, Boolean);
+char *Var_Parse(const char *, GNode *, int, int *, void **);
+char *Var_Subst(const char *, const char *, GNode *, int);
 char *Var_GetTail(const char *);
 char *Var_GetHead(const char *);
 void Var_Init(void);

Modified: vendor/NetBSD/bmake/dist/os.sh
===================================================================
--- vendor/NetBSD/bmake/dist/os.sh	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/os.sh	2018-06-27 00:17:22 UTC (rev 11138)
@@ -17,7 +17,7 @@
 #	Simon J. Gerraty <sjg at crufty.net>
 
 # RCSid:
-#	$Id: os.sh,v 1.46 2014/05/19 16:38:09 sjg Exp $
+#	$Id: os.sh,v 1.53 2017/01/11 20:01:09 sjg Exp $
 #
 #	@(#) Copyright (c) 1994 Simon J. Gerraty
 #
@@ -44,7 +44,7 @@
 # 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";;
+unknown|*[!A-Za-z0-9_-]*) MACHINE_ARCH="$MACHINE";;
 esac
         
 # we need this here, and it is not always available...
@@ -56,10 +56,10 @@
 	case "$1" in
 	/*)	test $t $1 && echo $1;;
 	*)
-        	# some shells cannot correctly handle `IFS`
-        	# in conjunction with the for loop.
-        	_dirs=`IFS=:; echo ${2:-$PATH}`
-        	for d in $_dirs
+		# some shells cannot correctly handle `IFS`
+		# in conjunction with the for loop.
+		_dirs=`IFS=:; echo ${2:-$PATH}`
+		for d in $_dirs
 		do
 			test $t $d/$1 && { echo $d/$1; break; }
 		done
@@ -70,11 +70,11 @@
 # tr is insanely non-portable wrt char classes, so we need to
 # spell out the alphabet. sed y/// would work too.
 toUpper() {
-        ${TR:-tr} abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
+	${TR:-tr} abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
 }
 
 toLower() {
-        ${TR:-tr} ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
+	${TR:-tr} ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
 }
 
 K=
@@ -91,7 +91,7 @@
 	export CHOWN
 	
 	# Great! Solaris keeps moving arch(1)
-        # should just bite the bullet and use uname -p
+	# should just bite the bullet and use uname -p
 	arch=`Which arch /usr/bin:/usr/ucb`
 	
 	MAILER=/usr/ucb/Mail
@@ -105,8 +105,8 @@
 		MACHINE=$MACHINE_ARCH
 		;;
 	4*)
-                MACHINE_ARCH=`arch`
-                ;;
+		MACHINE_ARCH=`arch`
+		;;
 	5*)
 		K=-k
 		LOCAL_FS=ufs
@@ -116,8 +116,8 @@
 		# overwriting an existing file!!!!! We want one that works!
 		test -x /usr/xpg4/bin/ln && LN=${LN:-/usr/xpg4/bin/ln}
 		# wonderful, 5.8's tr again require's []'s
-                # but /usr/xpg4/bin/tr causes problems if LC_COLLATE is set!
-                # use toUpper/toLower instead.
+		# but /usr/xpg4/bin/tr causes problems if LC_COLLATE is set!
+		# use toUpper/toLower instead.
 		;;
 	esac
 	case "$OS/$MACHINE_ARCH" in
@@ -137,11 +137,14 @@
 	# NetBSD at least has good backward compatibility
 	# so NetBSD/i386 is good enough
 	case $OS in
-	NetBSD) SHARE_ARCH=$OS/${MACHINE_ARCH:-$MACHINE};;
+	NetBSD)
+		HOST_ARCH=$MACHINE
+		SHARE_ARCH=$OS/$HOST_ARCH
+		;;
 	OpenBSD)
-	        arch=`Which arch /usr/bin:/usr/ucb:$PATH`
-                MACHINE_ARCH=`$arch -s`
-                ;;
+		arch=`Which arch /usr/bin:/usr/ucb:$PATH`
+		MACHINE_ARCH=`$arch -s`
+		;;
 	esac
 	NAWK=awk
 	export NAWK
@@ -203,28 +206,45 @@
 
 TMP_DIRS=${TMP_DIRS:-"/tmp /var/tmp"}
 MACHINE_ARCH=${MACHINE_ARCH:-$MACHINE}
+case "$MACHINE_ARCH" in
+x86*64|amd64) MACHINE32_ARCH=i386;;
+*64) MACHINE32_ARCH=`echo $MACHINE_ARCH | sed 's,64,32,'`;;
+*) MACHINE32_ARCH=$MACHINE_ARCH;;
+esac
+HOST_ARCH=${HOST_ARCH:-$MACHINE_ARCH}
+HOST_ARCH32=${HOST_ARCH32:-$MACHINE32_ARCH}
 # we mount server:/share/arch/$SHARE_ARCH as /usr/local
-SHARE_ARCH=${SHARE_ARCH:-$OS/$OSMAJOR.X/$MACHINE_ARCH}
+SHARE_ARCH_DEFAULT=$OS/$OSMAJOR.X/$HOST_ARCH
+SHARE_ARCH=${SHARE_ARCH:-$SHARE_ARCH_DEFAULT}
 LN=${LN:-ln}
 TR=${TR:-tr}
 
 # Some people like have /share/$HOST_TARGET/bin etc.
-HOST_TARGET=`echo ${OS}${OSMAJOR}-${MACHINE_ARCH} | toLower`
-export HOST_TARGET
+HOST_TARGET=`echo ${OS}${OSMAJOR}-$HOST_ARCH | tr -d / | toLower`
+HOST_TARGET32=`echo ${OS}${OSMAJOR}-$HOST_ARCH32 | tr -d / | toLower`
+export HOST_TARGET HOST_TARGET32
 
 case `echo -n .` in -n*) N=; C="\c";; *) N=-n; C=;; esac
 
-export HOSTNAME HOST        
+Echo() {
+	case "$1" in
+	-n) _n=$N _c=$C; shift;;
+	*) _n= _c=;;
+	esac
+	echo $_n "$@" $_c
+}
+
+export HOSTNAME HOST	    
 export OS MACHINE MACHINE_ARCH OSREL OSMAJOR LOCAL_FS TMP_DIRS MAILER N C K PS_AXC
 export LN SHARE_ARCH TR
 
 case /$0 in
 */os.sh)
-        for v in $*
+	for v in $*
 	do
-                eval vv=\$$v
-                echo "$v='$vv'"
+		eval vv=\$$v
+		echo "$v='$vv'"
 	done
-        ;;
+	;;
 esac
 

Modified: vendor/NetBSD/bmake/dist/parse.c
===================================================================
--- vendor/NetBSD/bmake/dist/parse.c	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/parse.c	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.194 2014/02/15 00:17:17 christos Exp $	*/
+/*	$NetBSD: parse.c,v 1.225 2017/04/17 13:29:07 maya Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: parse.c,v 1.194 2014/02/15 00:17:17 christos Exp $";
+static char rcsid[] = "$NetBSD: parse.c,v 1.225 2017/04/17 13:29:07 maya Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
@@ -76,7 +76,7 @@
 #if 0
 static char sccsid[] = "@(#)parse.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: parse.c,v 1.194 2014/02/15 00:17:17 christos Exp $");
+__RCSID("$NetBSD: parse.c,v 1.225 2017/04/17 13:29:07 maya Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -128,7 +128,6 @@
 #include <assert.h>
 #include <ctype.h>
 #include <errno.h>
-#include <fcntl.h>
 #include <stdarg.h>
 #include <stdio.h>
 
@@ -139,6 +138,10 @@
 #include "buf.h"
 #include "pathnames.h"
 
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
+
 #ifdef HAVE_MMAP
 #include <sys/mman.h>
 
@@ -161,6 +164,7 @@
     int             lineno;         /* current line number in file */
     int             first_lineno;   /* line number of start of text */
     int             cond_depth;     /* 'if' nesting when file opened */
+    Boolean         depending;      /* state of doing_depend on EOF */
     char            *P_str;         /* point to base of string buffer */
     char            *P_ptr;         /* point to next char of string buffer */
     char            *P_end;         /* point to the end of string buffer */
@@ -184,6 +188,7 @@
 typedef enum {
     Begin,  	    /* .BEGIN */
     Default,	    /* .DEFAULT */
+    DeleteOnError,  /* .DELETE_ON_ERROR */
     End,    	    /* .END */
     dotError,	    /* .ERROR */
     Ignore,	    /* .IGNORE */
@@ -301,6 +306,7 @@
 } parseKeywords[] = {
 { ".BEGIN", 	  Begin,    	0 },
 { ".DEFAULT",	  Default,  	0 },
+{ ".DELETE_ON_ERROR", DeleteOnError, 0 },
 { ".END",   	  End,	    	0 },
 { ".ERROR",   	  dotError,    	0 },
 { ".EXEC",	  Attribute,   	OP_EXEC },
@@ -508,7 +514,11 @@
 #ifdef HAVE_MMAP
 	if (load_getsize(fd, &lf->len) == SUCCESS) {
 		/* found a size, try mmap */
+#ifdef _SC_PAGESIZE
 		pagesize = sysconf(_SC_PAGESIZE);
+#else
+		pagesize = 0;
+#endif
 		if (pagesize <= 0) {
 			pagesize = 0x1000;
 		}
@@ -533,7 +543,7 @@
 		if (lf->buf != MAP_FAILED) {
 			/* succeeded */
 			if (lf->len == lf->maplen && lf->buf[lf->len - 1] != '\n') {
-				char *b = malloc(lf->len + 1);
+				char *b = bmake_malloc(lf->len + 1);
 				b[lf->len] = '\n';
 				memcpy(b, lf->buf, lf->len++);
 				munmap(lf->buf, lf->maplen);
@@ -554,9 +564,15 @@
 	while (1) {
 		assert(bufpos <= lf->len);
 		if (bufpos == lf->len) {
+			if (lf->len > SIZE_MAX/2) {
+				errno = EFBIG;
+				Error("%s: file too large", path);
+				exit(1);
+			}
 			lf->len *= 2;
 			lf->buf = bmake_realloc(lf->buf, lf->len);
 		}
+		assert(bufpos < lf->len);
 		result = read(fd, lf->buf + bufpos, lf->len - bufpos);
 		if (result < 0) {
 			Error("%s: read error: %s", path, strerror(errno));
@@ -572,7 +588,11 @@
 
 	/* truncate malloc region to actual length (maybe not useful) */
 	if (lf->len > 0) {
+		/* as for mmap case, ensure trailing \n */
+		if (lf->buf[lf->len - 1] != '\n')
+			lf->len++;
 		lf->buf = bmake_realloc(lf->buf, lf->len);
+		lf->buf[lf->len - 1] = '\n';
 	}
 
 #ifdef HAVE_MMAP
@@ -805,14 +825,14 @@
 	return FALSE;
     }
 
-    while (isalpha((u_char)*line))
+    while (isalpha((unsigned char)*line))
 	line++;
-    if (!isspace((u_char)*line))
+    if (!isspace((unsigned char)*line))
 	return FALSE;			/* not for us */
-    while (isspace((u_char)*line))
+    while (isspace((unsigned char)*line))
 	line++;
 
-    line = Var_Subst(NULL, line, VAR_CMD, 0);
+    line = Var_Subst(NULL, line, VAR_CMD, VARF_WANTRES);
     Parse_Error(mtype, "%s", line);
     free(line);
 
@@ -1089,15 +1109,15 @@
  *-----------------------------------------------------------------------
  */
 static int
-ParseFindMain(void *gnp, void *dummy)
+ParseFindMain(void *gnp, void *dummy MAKE_ATTR_UNUSED)
 {
     GNode   	  *gn = (GNode *)gnp;
     if ((gn->type & OP_NOTARGET) == 0) {
 	mainNode = gn;
 	Targ_SetMain(gn);
-	return (dummy ? 1 : 1);
+	return 1;
     } else {
-	return (dummy ? 0 : 0);
+	return 0;
     }
 }
 
@@ -1135,10 +1155,10 @@
  *-----------------------------------------------------------------------
  */
 static int
-ParseClearPath(void *path, void *dummy)
+ParseClearPath(void *path, void *dummy MAKE_ATTR_UNUSED)
 {
     Dir_ClearPath((Lst) path);
-    return(dummy ? 0 : 0);
+    return 0;
 }
 
 /*-
@@ -1203,7 +1223,17 @@
 
     curTargs = Lst_Init(FALSE);
 
+    /*
+     * First, grind through the targets.
+     */
+
     do {
+	/*
+	 * Here LINE points to the beginning of the next word, and
+	 * LSTART points to the actual beginning of the line.
+	 */
+
+	/* Find the end of the next word. */
 	for (cp = line; *cp && (ParseIsEscaped(lstart, cp) ||
 		     !(isspace((unsigned char)*cp) ||
 			 *cp == '!' || *cp == ':' || *cp == LPAREN));
@@ -1219,13 +1249,17 @@
 		int 	length;
 		void    *freeIt;
 
-		(void)Var_Parse(cp, VAR_CMD, TRUE, &length, &freeIt);
-		if (freeIt)
-		    free(freeIt);
+		(void)Var_Parse(cp, VAR_CMD, VARF_UNDEFERR|VARF_WANTRES,
+				&length, &freeIt);
+		free(freeIt);
 		cp += length-1;
 	    }
 	}
 
+	/*
+	 * If the word is followed by a left parenthesis, it's the
+	 * name of an object file inside an archive (ar file).
+	 */
 	if (!ParseIsEscaped(lstart, cp) && *cp == LPAREN) {
 	    /*
 	     * Archives must be handled specially to make sure the OP_ARCHV
@@ -1242,13 +1276,17 @@
 			     "Error in archive specification: \"%s\"", line);
 		goto out;
 	    } else {
+		/* Done with this word; on to the next. */
+		cp = line;
 		continue;
 	    }
 	}
-	savec = *cp;
 
 	if (!*cp) {
 	    /*
+	     * We got to the end of the line while we were still
+	     * looking at targets.
+	     *
 	     * Ending a dependency line without an operator is a Bozo
 	     * no-no.  As a heuristic, this is also often triggered by
 	     * undetected conflicts from cvs/rcs merges.
@@ -1263,10 +1301,13 @@
 				     : "Need an operator");
 	    goto out;
 	}
+
+	/* Insert a null terminator. */
+	savec = *cp;
 	*cp = '\0';
 
 	/*
-	 * Have a word in line. See if it's a special target and set
+	 * Got the word. See if it's a special target and if so set
 	 * specType to match it.
 	 */
 	if (*line == '.' && isupper ((unsigned char)line[1])) {
@@ -1309,6 +1350,7 @@
 		 *	.BEGIN
 		 *	.END
 		 *	.ERROR
+		 *	.DELETE_ON_ERROR
 		 *	.INTERRUPT  	Are not to be considered the
 		 *			main target.
 		 *  	.NOTPARALLEL	Make only one target at a time.
@@ -1344,6 +1386,9 @@
 		    (void)Lst_AtEnd(targets, gn);
 		    DEFAULT = gn;
 		    break;
+		case DeleteOnError:
+		    deleteOnError = TRUE;
+		    break;
 		case NotParallel:
 		    maxJobs = 1;
 		    break;
@@ -1405,6 +1450,8 @@
 		(void)Lst_AtEnd(curTargs, line);
 	    }
 
+	    /* Apply the targets. */
+
 	    while(!Lst_IsEmpty(curTargs)) {
 		char	*targName = (char *)Lst_DeQueue(curTargs);
 
@@ -1422,7 +1469,9 @@
 	    Parse_Error(PARSE_WARNING, "Extra target (%s) ignored", line);
 	}
 
+	/* Don't need the inserted null terminator any more. */
 	*cp = savec;
+
 	/*
 	 * If it is a special type and not .PATH, it's the only target we
 	 * allow on this line...
@@ -1498,12 +1547,21 @@
 	goto out;
     }
 
-    cp++;			/* Advance beyond operator */
+    /* Advance beyond the operator */
+    cp++;
 
+    /*
+     * Apply the operator to the target. This is how we remember which
+     * operator a target was defined with. It fails if the operator
+     * used isn't consistent across all references.
+     */
     Lst_ForEach(targets, ParseDoOp, &op);
 
     /*
-     * Get to the first source
+     * Onward to the sources.
+     *
+     * LINE will now point to the first source word, if any, or the
+     * end of the string if not.
      */
     while (*cp && isspace ((unsigned char)*cp)) {
 	cp++;
@@ -1559,7 +1617,8 @@
 	    goto out;
 	}
 	*line = '\0';
-    } else if ((specType == NotParallel) || (specType == SingleShell)) {
+    } else if ((specType == NotParallel) || (specType == SingleShell) ||
+	    (specType == DeleteOnError)) {
 	*line = '\0';
     }
 
@@ -1620,7 +1679,7 @@
 		    Suff_SetNull(line);
 		    break;
 		case ExObjdir:
-		    Main_SetObjdir(line);
+		    Main_SetObjdir("%s", line);
 		    break;
 		default:
 		    break;
@@ -1636,10 +1695,12 @@
 	}
 	if (paths) {
 	    Lst_Destroy(paths, NULL);
+	    paths = NULL;
 	}
 	if (specType == ExPath)
 	    Dir_SetPATH();
     } else {
+	assert(paths == NULL);
 	while (*line) {
 	    /*
 	     * The targets take real sources, so we must beware of archive
@@ -1698,6 +1759,7 @@
     }
 
 out:
+    assert(paths == NULL);
     if (curTargs)
 	    Lst_Destroy(curTargs, NULL);
 }
@@ -1820,7 +1882,7 @@
      * XXX Rather than counting () and {} we should look for $ and
      * then expand the variable.
      */
-    for (depth = 0, cp = line + 1; depth != 0 || *cp != '='; cp++) {
+    for (depth = 0, cp = line + 1; depth > 0 || *cp != '='; cp++) {
 	if (*cp == '(' || *cp == '{') {
 	    depth++;
 	    continue;
@@ -1911,7 +1973,7 @@
 	if (!Var_Exists(line, ctxt))
 	    Var_Set(line, "", ctxt, 0);
 
-	cp = Var_Subst(NULL, cp, ctxt, FALSE);
+	cp = Var_Subst(NULL, cp, ctxt, VARF_WANTRES|VARF_ASSIGN);
 	oldVars = oldOldVars;
 	freeCp = TRUE;
 
@@ -1926,7 +1988,7 @@
 	     * expansion on the whole thing. The resulting string will need
 	     * freeing when we're done, so set freeCmd to TRUE.
 	     */
-	    cp = Var_Subst(NULL, cp, VAR_CMD, TRUE);
+	    cp = Var_Subst(NULL, cp, VAR_CMD, VARF_UNDEFERR|VARF_WANTRES);
 	    freeCp = TRUE;
 	}
 
@@ -1962,6 +2024,40 @@
 }
 
 
+/*
+ * ParseMaybeSubMake --
+ * 	Scan the command string to see if it a possible submake node
+ * Input:
+ *	cmd		the command to scan
+ * Results:
+ *	TRUE if the command is possibly a submake, FALSE if not.
+ */
+static Boolean
+ParseMaybeSubMake(const char *cmd)
+{
+    size_t i;
+    static struct {
+	const char *name;
+	size_t len;
+    } vals[] = {
+#define MKV(A)	{	A, sizeof(A) - 1	}
+	MKV("${MAKE}"),
+	MKV("${.MAKE}"),
+	MKV("$(MAKE)"),
+	MKV("$(.MAKE)"),
+	MKV("make"),
+    };
+    for (i = 0; i < sizeof(vals)/sizeof(vals[0]); i++) {
+	char *ptr;
+	if ((ptr = strstr(cmd, vals[i].name)) == NULL)
+	    continue;
+	if ((ptr == cmd || !isalnum((unsigned char)ptr[-1]))
+	    && !isalnum((unsigned char)ptr[vals[i].len]))
+	    return TRUE;
+    }
+    return FALSE;
+}
+
 /*-
  * ParseAddCmd  --
  *	Lst_ForEach function to add a command line to all targets
@@ -1974,7 +2070,9 @@
  *	Always 0
  *
  * Side Effects:
- *	A new element is added to the commands list of the node.
+ *	A new element is added to the commands list of the node,
+ *	and the node can be marked as a submake node if the command is
+ *	determined to be that.
  */
 static int
 ParseAddCmd(void *gnp, void *cmd)
@@ -1988,6 +2086,8 @@
     /* if target already supplied, ignore commands */
     if (!(gn->type & OP_HAS_COMMANDS)) {
 	(void)Lst_AtEnd(gn->commands, cmd);
+	if (ParseMaybeSubMake(cmd))
+	    gn->type |= OP_SUBMAKE;
 	ParseMark(gn);
     } else {
 #ifdef notyet
@@ -2080,7 +2180,7 @@
  */
 
 static void
-Parse_include_file(char *file, Boolean isSystem, int silent)
+Parse_include_file(char *file, Boolean isSystem, Boolean depinc, int silent)
 {
     struct loadedfile *lf;
     char          *fullname;	/* full pathname of file */
@@ -2180,6 +2280,8 @@
     /* Start reading from this file next */
     Parse_SetInput(fullname, 0, -1, loadedfile_nextbuf, lf);
     curFile->lf = lf;
+    if (depinc)
+	doing_depend = depinc;		/* only turn it on */
 }
 
 static void
@@ -2227,9 +2329,9 @@
      * Substitute for any variables in the file name before trying to
      * find the thing.
      */
-    file = Var_Subst(NULL, file, VAR_CMD, FALSE);
+    file = Var_Subst(NULL, file, VAR_CMD, VARF_WANTRES);
 
-    Parse_include_file(file, endc == '>', silent);
+    Parse_include_file(file, endc == '>', (*line == 'd'), silent);
     free(file);
 }
 
@@ -2264,10 +2366,8 @@
 	fprintf(debug_file, "%s: ${.INCLUDEDFROMDIR} = `%s' "
 	    "${.INCLUDEDFROMFILE} = `%s'\n", __func__, pd, pf);
 
-    if (fp)
-	free(fp);
-    if (dp)
-	free(dp);
+    free(fp);
+    free(dp);
 }
 /*-
  *---------------------------------------------------------------------
@@ -2319,15 +2419,19 @@
 ParseTrackInput(const char *name)
 {
     char *old;
+    char *ep;
     char *fp = NULL;
     size_t name_len = strlen(name);
     
     old = Var_Value(MAKE_MAKEFILES, VAR_GLOBAL, &fp);
     if (old) {
+	ep = old + strlen(old) - name_len;
 	/* does it contain name? */
 	for (; old != NULL; old = strchr(old, ' ')) {
 	    if (*old == ' ')
 		old++;
+	    if (old >= ep)
+		break;			/* cannot contain name */
 	    if (memcmp(old, name, name_len) == 0
 		    && (old[name_len] == 0 || old[name_len] == ' '))
 		goto cleanup;
@@ -2393,6 +2497,7 @@
     curFile->nextbuf = nextbuf;
     curFile->nextbuf_arg = arg;
     curFile->lf = NULL;
+    curFile->depending = doing_depend;	/* restore this on EOF */
 
     assert(nextbuf != NULL);
 
@@ -2453,12 +2558,12 @@
      * Substitute for any variables in the file name before trying to
      * find the thing.
      */
-    all_files = Var_Subst(NULL, file, VAR_CMD, FALSE);
+    all_files = Var_Subst(NULL, file, VAR_CMD, VARF_WANTRES);
 
     if (*file == '\0') {
 	Parse_Error(PARSE_FATAL,
 		     "Filename missing from \"include\"");
-	return;
+	goto out;
     }
 
     for (file = all_files; !done; file = cp + 1) {
@@ -2471,8 +2576,9 @@
 	else
 	    done = 1;
 
-	Parse_include_file(file, FALSE, silent);
+	Parse_include_file(file, FALSE, FALSE, silent);
     }
+out:
     free(all_files);
 }
 #endif
@@ -2521,8 +2627,9 @@
     /*
      * Expand the value before putting it in the environment.
      */
-    value = Var_Subst(NULL, value, VAR_CMD, FALSE);
+    value = Var_Subst(NULL, value, VAR_CMD, VARF_WANTRES);
     setenv(variable, value, 1);
+    free(value);
 }
 #endif
 
@@ -2549,6 +2656,7 @@
 
     assert(curFile->nextbuf != NULL);
 
+    doing_depend = curFile->depending;	/* restore this */
     /* get next input buffer, if any */
     ptr = curFile->nextbuf(curFile->nextbuf_arg, &len);
     curFile->P_ptr = ptr;
@@ -2911,7 +3019,7 @@
 		    continue;
 		}
 		if (strncmp(cp, "include", 7) == 0 ||
-			((cp[0] == 's' || cp[0] == '-') &&
+			((cp[0] == 'd' || cp[0] == 's' || cp[0] == '-') &&
 			    strncmp(&cp[1], "include", 7) == 0)) {
 		    ParseDoInclude(cp);
 		    continue;
@@ -3070,7 +3178,7 @@
 	     * variables expanded before being parsed. Tell the variable
 	     * module to complain if some variable is undefined...
 	     */
-	    line = Var_Subst(NULL, line, VAR_CMD, TRUE);
+	    line = Var_Subst(NULL, line, VAR_CMD, VARF_UNDEFERR|VARF_WANTRES);
 
 	    /*
 	     * Need a non-circular list for the target nodes

Modified: vendor/NetBSD/bmake/dist/sprite.h
===================================================================
--- vendor/NetBSD/bmake/dist/sprite.h	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/sprite.h	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,4 +1,4 @@
-/*	$NetBSD: sprite.h,v 1.11 2009/01/23 21:26:30 dsl Exp $	*/
+/*	$NetBSD: sprite.h,v 1.14 2017/05/31 22:02:06 maya Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -78,8 +78,8 @@
  * Common constants and type declarations for Sprite.
  */
 
-#ifndef _SPRITE
-#define _SPRITE
+#ifndef MAKE_SPRITE_H
+#define MAKE_SPRITE_H
 
 
 /*
@@ -113,4 +113,4 @@
 #define	SUCCESS			0x00000000
 #define	FAILURE			0x00000001
 
-#endif /* _SPRITE */
+#endif /* MAKE_SPRITE_H */

Modified: vendor/NetBSD/bmake/dist/str.c
===================================================================
--- vendor/NetBSD/bmake/dist/str.c	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/str.c	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,4 +1,4 @@
-/*	$NetBSD: str.c,v 1.35 2014/02/12 01:35:56 sjg Exp $	*/
+/*	$NetBSD: str.c,v 1.38 2017/04/21 22:15:44 sjg Exp $	*/
 
 /*-
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: str.c,v 1.35 2014/02/12 01:35:56 sjg Exp $";
+static char rcsid[] = "$NetBSD: str.c,v 1.38 2017/04/21 22:15:44 sjg Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
@@ -76,7 +76,7 @@
 #if 0
 static char     sccsid[] = "@(#)str.c	5.8 (Berkeley) 6/1/90";
 #else
-__RCSID("$NetBSD: str.c,v 1.35 2014/02/12 01:35:56 sjg Exp $");
+__RCSID("$NetBSD: str.c,v 1.38 2017/04/21 22:15:44 sjg Exp $");
 #endif
 #endif				/* not lint */
 #endif
@@ -102,7 +102,7 @@
 	len2 = strlen(s2);
 
 	/* allocate length plus separator plus EOS */
-	result = bmake_malloc((u_int)(len1 + len2 + 2));
+	result = bmake_malloc((unsigned int)(len1 + len2 + 2));
 
 	/* copy first string into place */
 	memcpy(result, s1, len1);
@@ -373,16 +373,26 @@
 		 * by a range (two characters separated by "-").
 		 */
 		if (*pattern == '[') {
+			int nomatch;
+
 			++pattern;
+			if (*pattern == '^') {
+				++pattern;
+				nomatch = 1;
+			} else
+				nomatch = 0;
 			for (;;) {
-				if ((*pattern == ']') || (*pattern == 0))
+				if ((*pattern == ']') || (*pattern == 0)) {
+					if (nomatch)
+						break;
 					return(0);
+				}
 				if (*pattern == *string)
 					break;
 				if (pattern[1] == '-') {
 					c2 = pattern[2];
 					if (c2 == 0)
-						return(0);
+						return(nomatch);
 					if ((*pattern <= *string) &&
 					    (c2 >= *string))
 						break;
@@ -393,6 +403,8 @@
 				}
 				++pattern;
 			}
+			if (nomatch && (*pattern != ']') && (*pattern != 0))
+				return 0;
 			while ((*pattern != ']') && (*pattern != 0))
 				++pattern;
 			goto thisCharOK;

Modified: vendor/NetBSD/bmake/dist/suff.c
===================================================================
--- vendor/NetBSD/bmake/dist/suff.c	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/suff.c	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,4 +1,4 @@
-/*	$NetBSD: suff.c,v 1.70 2013/05/18 13:13:34 sjg Exp $	*/
+/*	$NetBSD: suff.c,v 1.86 2017/04/16 20:38:18 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: suff.c,v 1.70 2013/05/18 13:13:34 sjg Exp $";
+static char rcsid[] = "$NetBSD: suff.c,v 1.86 2017/04/16 20:38:18 riastradh Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
@@ -76,7 +76,7 @@
 #if 0
 static char sccsid[] = "@(#)suff.c	8.4 (Berkeley) 3/21/94";
 #else
-__RCSID("$NetBSD: suff.c,v 1.70 2013/05/18 13:13:34 sjg Exp $");
+__RCSID("$NetBSD: suff.c,v 1.86 2017/04/16 20:38:18 riastradh Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -135,6 +135,7 @@
  *				order to find the node.
  */
 
+#include    	  <assert.h>
 #include    	  <stdio.h>
 #include	  "make.h"
 #include	  "hash.h"
@@ -553,7 +554,20 @@
 #endif
     sufflist = Lst_Init(FALSE);
     sNum = 0;
-    suffNull = emptySuff;
+    if (suffNull)
+	SuffFree(suffNull);
+    emptySuff = suffNull = bmake_malloc(sizeof(Suff));
+
+    suffNull->name =   	    bmake_strdup("");
+    suffNull->nameLen =     0;
+    suffNull->searchPath =  Lst_Init(FALSE);
+    Dir_Concat(suffNull->searchPath, dirSearchPath);
+    suffNull->children =    Lst_Init(FALSE);
+    suffNull->parents =	    Lst_Init(FALSE);
+    suffNull->ref =	    Lst_Init(FALSE);
+    suffNull->sNum =   	    sNum++;
+    suffNull->flags =  	    SUFF_NULL;
+    suffNull->refCount =    1;
 }
 
 /*-
@@ -749,7 +763,7 @@
  *-----------------------------------------------------------------------
  */
 int
-Suff_EndTransform(void *gnp, void *dummy)
+Suff_EndTransform(void *gnp, void *dummy MAKE_ATTR_UNUSED)
 {
     GNode *gn = (GNode *)gnp;
 
@@ -796,7 +810,7 @@
 	fprintf(debug_file, "transformation %s complete\n", gn->name);
     }
 
-    return(dummy ? 0 : 0);
+    return 0;
 }
 
 /*-
@@ -1202,7 +1216,7 @@
 #ifdef DEBUG_SRC
 	s2->cp = Lst_Init(FALSE);
 	Lst_AtEnd(targ->cp, s2);
-	fprintf(debug_file, "1 add %x %x to %x:", targ, s2, ls->l);
+	fprintf(debug_file, "1 add %p %p to %p:", targ, s2, ls->l);
 	Lst_ForEach(ls->l, PrintAddr, NULL);
 	fprintf(debug_file, "\n");
 #endif
@@ -1220,7 +1234,7 @@
 #ifdef DEBUG_SRC
     s2->cp = Lst_Init(FALSE);
     Lst_AtEnd(targ->cp, s2);
-    fprintf(debug_file, "2 add %x %x to %x:", targ, s2, ls->l);
+    fprintf(debug_file, "2 add %p %p to %p:", targ, s2, ls->l);
     Lst_ForEach(ls->l, PrintAddr, NULL);
     fprintf(debug_file, "\n");
 #endif
@@ -1292,14 +1306,14 @@
 		free(s->pref);
 	    else {
 #ifdef DEBUG_SRC
-		LstNode ln = Lst_Member(s->parent->cp, s);
-		if (ln != NULL)
-		    Lst_Remove(s->parent->cp, ln);
+		LstNode ln2 = Lst_Member(s->parent->cp, s);
+		if (ln2 != NULL)
+		    Lst_Remove(s->parent->cp, ln2);
 #endif
 		--s->parent->children;
 	    }
 #ifdef DEBUG_SRC
-	    fprintf(debug_file, "free: [l=%x] p=%x %d\n", l, s, s->children);
+	    fprintf(debug_file, "free: [l=%p] p=%p %d\n", l, s, s->children);
 	    Lst_Destroy(s->cp, NULL);
 #endif
 	    Lst_Remove(l, ln);
@@ -1310,7 +1324,7 @@
 	}
 #ifdef DEBUG_SRC
 	else {
-	    fprintf(debug_file, "keep: [l=%x] p=%x %d: ", l, s, s->children);
+	    fprintf(debug_file, "keep: [l=%p] p=%p %d: ", l, s, s->children);
 	    Lst_ForEach(s->cp, PrintAddr, NULL);
 	    fprintf(debug_file, "\n");
 	}
@@ -1359,7 +1373,7 @@
 	 */
 	if (Targ_FindNode(s->file, TARG_NOCREATE) != NULL) {
 #ifdef DEBUG_SRC
-	    fprintf(debug_file, "remove %x from %x\n", s, srcs);
+	    fprintf(debug_file, "remove %p from %p\n", s, srcs);
 #endif
 	    rs = s;
 	    break;
@@ -1368,7 +1382,7 @@
 	if ((ptr = Dir_FindFile(s->file, s->suff->searchPath)) != NULL) {
 	    rs = s;
 #ifdef DEBUG_SRC
-	    fprintf(debug_file, "remove %x from %x\n", s, srcs);
+	    fprintf(debug_file, "remove %p from %p\n", s, srcs);
 #endif
 	    free(ptr);
 	    break;
@@ -1484,7 +1498,7 @@
     targ->children += 1;
 #ifdef DEBUG_SRC
     ret->cp = Lst_Init(FALSE);
-    fprintf(debug_file, "3 add %x %x\n", targ, ret);
+    fprintf(debug_file, "3 add %p %p\n", targ, ret);
     Lst_AtEnd(targ->cp, ret);
 #endif
     Lst_AtEnd(slst, ret);
@@ -1543,7 +1557,7 @@
     if (DEBUG(SUFF)) {
 	fprintf(debug_file, "Expanding \"%s\"...", cgn->name);
     }
-    cp = Var_Subst(NULL, cgn->name, pgn, TRUE);
+    cp = Var_Subst(NULL, cgn->name, pgn, VARF_UNDEFERR|VARF_WANTRES);
 
     if (cp != NULL) {
 	Lst	    members = Lst_Init(FALSE);
@@ -1596,14 +1610,14 @@
 		    int 	len;
 		    void	*freeIt;
 
-		    junk = Var_Parse(cp, pgn, TRUE, &len, &freeIt);
+		    junk = Var_Parse(cp, pgn, VARF_UNDEFERR|VARF_WANTRES,
+			&len, &freeIt);
 		    if (junk != var_Error) {
 			cp += len - 1;
 		    }
 
-		    if (freeIt)
-			free(freeIt);
-		} else if (*cp == '\\' && *cp != '\0') {
+		    free(freeIt);
+		} else if (*cp == '\\' && cp[1] != '\0') {
 		    /*
 		     * Escaped something -- skip over it
 		     */
@@ -1881,6 +1895,7 @@
 	TARGET,	    	    /* Must be first */
 	PREFIX,	    	    /* Must be second */
     };
+    LstNode 	ln, nln;    /* Next suffix node to check */
     int	    	i;  	    /* Index into copy and vals */
     Suff    	*ms;	    /* Suffix descriptor for member */
     char    	*name;	    /* Start of member's name */
@@ -1892,6 +1907,13 @@
     eoarch = strchr(gn->name, '(');
     eoname = strchr(eoarch, ')');
 
+    /*
+     * Caller guarantees the format `libname(member)', via
+     * Arch_ParseArchive.
+     */
+    assert(eoarch != NULL);
+    assert(eoname != NULL);
+
     *eoname = '\0';	  /* Nuke parentheses during suffix search */
     *eoarch = '\0';	  /* So a suffix can be found */
 
@@ -1920,8 +1942,7 @@
     for (i = (sizeof(copy)/sizeof(copy[0]))-1; i >= 0; i--) {
 	char *p1;
 	Var_Set(copy[i], Var_Value(copy[i], mem, &p1), gn, 0);
-	if (p1)
-	    free(p1);
+	free(p1);
 
     }
 
@@ -1943,6 +1964,20 @@
     Var_Set(MEMBER, name, gn, 0);
     Var_Set(ARCHIVE, gn->name, gn, 0);
 
+    /*
+     * Set $@ for compatibility with other makes
+     */
+    Var_Set(TARGET, gn->name, gn, 0);
+
+    /*
+     * Now we've got the important local variables set, expand any sources
+     * that still contain variables or wildcards in their names.
+     */
+    for (ln = Lst_First(gn->children); ln != NULL; ln = nln) {
+	nln = Lst_Succ(ln);
+	SuffExpandChildren(ln, gn);
+    }
+
     if (ms != NULL) {
 	/*
 	 * Member has a known suffix, so look for a transformation rule from
@@ -1950,7 +1985,6 @@
 	 * through the entire list, we just look at suffixes to which the
 	 * member's suffix may be transformed...
 	 */
-	LstNode		ln;
 	SuffixCmpData	sd;		/* Search string data */
 
 	/*
@@ -1990,9 +2024,10 @@
 
     /*
      * Flag the member as such so we remember to look in the archive for
-     * its modification time.
+     * its modification time. The OP_JOIN | OP_MADE is needed because this
+     * target should never get made.
      */
-    mem->type |= OP_MEMBER;
+    mem->type |= OP_MEMBER | OP_JOIN | OP_MADE;
 }
 
 /*-
@@ -2524,7 +2559,6 @@
 void
 Suff_Init(void)
 {
-    sufflist = Lst_Init(FALSE);
 #ifdef CLEANUP
     suffClean = Lst_Init(FALSE);
 #endif
@@ -2531,25 +2565,12 @@
     srclist = Lst_Init(FALSE);
     transforms = Lst_Init(FALSE);
 
-    sNum = 0;
     /*
      * Create null suffix for single-suffix rules (POSIX). The thing doesn't
      * actually go on the suffix list or everyone will think that's its
      * suffix.
      */
-    emptySuff = suffNull = bmake_malloc(sizeof(Suff));
-
-    suffNull->name =   	    bmake_strdup("");
-    suffNull->nameLen =     0;
-    suffNull->searchPath =  Lst_Init(FALSE);
-    Dir_Concat(suffNull->searchPath, dirSearchPath);
-    suffNull->children =    Lst_Init(FALSE);
-    suffNull->parents =	    Lst_Init(FALSE);
-    suffNull->ref =	    Lst_Init(FALSE);
-    suffNull->sNum =   	    sNum++;
-    suffNull->flags =  	    SUFF_NULL;
-    suffNull->refCount =    1;
-
+    Suff_ClearSuffixes();
 }
 
 
@@ -2582,14 +2603,15 @@
 
 /********************* DEBUGGING FUNCTIONS **********************/
 
-static int SuffPrintName(void *s, void *dummy)
+static int SuffPrintName(void *s, void *dummy MAKE_ATTR_UNUSED)
 {
+
     fprintf(debug_file, "%s ", ((Suff *)s)->name);
-    return (dummy ? 0 : 0);
+    return 0;
 }
 
 static int
-SuffPrintSuff(void *sp, void *dummy)
+SuffPrintSuff(void *sp, void *dummy MAKE_ATTR_UNUSED)
 {
     Suff    *s = (Suff *)sp;
     int	    flags;
@@ -2627,11 +2649,11 @@
     fprintf(debug_file, "#\tSearch Path: ");
     Dir_PrintPath(s->searchPath);
     fputc('\n', debug_file);
-    return (dummy ? 0 : 0);
+    return 0;
 }
 
 static int
-SuffPrintTrans(void *tp, void *dummy)
+SuffPrintTrans(void *tp, void *dummy MAKE_ATTR_UNUSED)
 {
     GNode   *t = (GNode *)tp;
 
@@ -2640,7 +2662,7 @@
     fputc('\n', debug_file);
     Lst_ForEach(t->commands, Targ_PrintCmd, NULL);
     fputc('\n', debug_file);
-    return(dummy ? 0 : 0);
+    return 0;
 }
 
 void

Modified: vendor/NetBSD/bmake/dist/targ.c
===================================================================
--- vendor/NetBSD/bmake/dist/targ.c	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/targ.c	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,4 +1,4 @@
-/*	$NetBSD: targ.c,v 1.57 2012/06/12 19:21:51 joerg Exp $	*/
+/*	$NetBSD: targ.c,v 1.62 2017/04/16 19:53:58 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: targ.c,v 1.57 2012/06/12 19:21:51 joerg Exp $";
+static char rcsid[] = "$NetBSD: targ.c,v 1.62 2017/04/16 19:53:58 riastradh Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
@@ -76,7 +76,7 @@
 #if 0
 static char sccsid[] = "@(#)targ.c	8.2 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: targ.c,v 1.57 2012/06/12 19:21:51 joerg Exp $");
+__RCSID("$NetBSD: targ.c,v 1.62 2017/04/16 19:53:58 riastradh Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -292,10 +292,8 @@
 
 
     free(gn->name);
-    if (gn->uname)
-	free(gn->uname);
-    if (gn->path)
-	free(gn->path);
+    free(gn->uname);
+    free(gn->path);
     /* gn->fname points to name allocated when file was opened, don't free */
 
     Lst_Destroy(gn->iParents, NULL);
@@ -523,10 +521,10 @@
 
 
 int
-Targ_PrintCmd(void *cmd, void *dummy)
+Targ_PrintCmd(void *cmd, void *dummy MAKE_ATTR_UNUSED)
 {
     fprintf(debug_file, "\t%s\n", (char *)cmd);
-    return (dummy ? 0 : 0);
+    return 0;
 }
 
 /*-

Modified: vendor/NetBSD/bmake/dist/unit-tests/Makefile.in
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/Makefile.in	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/unit-tests/Makefile.in	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,17 +1,18 @@
-# $Id: Makefile.in,v 1.44 2013/08/28 22:09:29 sjg Exp $
+# $Id: Makefile.in,v 1.48 2015/12/07 04:06:29 sjg Exp $
 #
-# $NetBSD: Makefile,v 1.38 2013/08/28 21:56:50 sjg Exp $
+# $NetBSD: Makefile,v 1.52 2015/05/05 21:51:09 sjg Exp $
 #
 # Unit tests for make(1)
 # The main targets are:
 # 
 # all:	run all the tests
-# test:	run 'all', capture output and compare to expected results
+# test:	run 'all', and compare to expected results
 # accept: move generated output to expected results
 #
 # Adding a test case.  
 # Each feature should get its own set of tests in its own suitably
-# named makefile which should be added to SUBFILES to hook it in.
+# named makefile (*.mk), with its own set of expected results (*.exp),
+# and it should be added to the TESTNAMES list.
 # 
 
 srcdir= @srcdir@
@@ -19,12 +20,14 @@
 .MAIN: all
 
 UNIT_TESTS:= ${srcdir}
+.PATH: ${UNIT_TESTS}
 
-# Simple sub-makefiles - we run them as a black box
-# keep the list sorted.
-SUBFILES= \
+# Each test is in a sub-makefile.
+# Keep the list sorted.
+TESTNAMES= \
 	comment \
 	cond1 \
+	cond2 \
 	error \
 	export \
 	export-all \
@@ -42,7 +45,6 @@
 	modts \
 	modword \
 	order \
-	phony-end \
 	posix \
 	qequals \
 	sunshcmd \
@@ -50,24 +52,37 @@
 	ternary \
 	unexport \
 	unexport-env \
-	varcmd
+	varcmd \
+	varmisc \
+	varshell
 
-all: ${SUBFILES}
+# these tests were broken by referting POSIX chanegs
+STRICT_POSIX_TESTS = \
+	escape \
+	impsrc \
+	phony-end \
+	posix1 \
+	suffixes
 
+# Override make flags for certain tests
 flags.doterror=
 flags.order=-j1
 
-# the tests are actually done with sub-makes.
-.PHONY: ${SUBFILES}
-.PRECIOUS: ${SUBFILES}
-${SUBFILES}:
-	-@${.MAKE} ${flags.$@:U-k} -f ${UNIT_TESTS}/$@
+OUTFILES= ${TESTNAMES:S/$/.out/}
 
+all: ${OUTFILES}
+
+CLEANFILES += *.rawout *.out *.status *.tmp *.core *.tmp
+CLEANFILES += obj*.[och] lib*.a		# posix1.mk
+CLEANFILES += issue* .[ab]*		# suffixes.mk
+CLEANRECURSIVE += dir dummy		# posix1.mk
+
 clean:
-	rm -f *.out *.fail *.core
+	rm -f ${CLEANFILES}
+.if !empty(CLEANRECURSIVE)
+	rm -rf ${CLEANRECURSIVE}
+.endif
 
-.-include <obj.mk>
-
 TEST_MAKE?= ${.MAKE}
 TOOL_SED?= sed
 TOOL_TR?= tr
@@ -81,22 +96,56 @@
 .export LANG LC_ALL
 .endif
 
-# The driver.
+# some tests need extra post-processing
+SED_CMDS.varshell = -e 's,^[a-z]*sh: ,,' \
+	-e '/command/s,No such.*,not found,'
+
+# the tests are actually done with sub-makes.
+.SUFFIXES: .mk .rawout .out
+.mk.rawout:
+	@echo ${TEST_MAKE} ${flags.${.TARGET:R}:U-k} -f ${.IMPSRC}
+	- at cd ${.OBJDIR} && \
+	{ ${TEST_MAKE} ${flags.${.TARGET:R}:U-k} -f ${.IMPSRC} \
+	  2>&1 ; echo $$? >${.TARGET:R}.status ; } > ${.TARGET}.tmp
+	@mv ${.TARGET}.tmp ${.TARGET}
+
 # We always pretend .MAKE was called 'make' 
 # and strip ${.CURDIR}/ from the output
 # and replace anything after 'stopped in' with unit-tests
 # so the results can be compared.
-test:
-	@echo "${TEST_MAKE} -f ${MAKEFILE} > ${.TARGET}.out 2>&1"
-	@cd ${.OBJDIR} && ${TEST_MAKE} -f ${MAKEFILE} 2>&1 | \
-	${TOOL_TR} -d '\015' | \
-	${TOOL_SED} -e 's,^${TEST_MAKE:T:C/\./\\\./g}[^:]*:,make:,' \
-	-e '/stopped/s, /.*, unit-tests,' \
-	-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; }
-	${TOOL_DIFF} ${DIFF_FLAGS} ${UNIT_TESTS}/${.TARGET}.exp ${.TARGET}.out
+.rawout.out:
+	@echo postprocess ${.TARGET}
+	@${TOOL_SED} -e 's,^${TEST_MAKE:T:C/\./\\\./g}[][0-9]*:,make:,' \
+	  -e 's,${TEST_MAKE:C/\./\\\./g},make,' \
+	  -e '/stopped/s, /.*, unit-tests,' \
+	  -e 's,${.CURDIR:C/\./\\\./g}/,,g' \
+	  -e 's,${UNIT_TESTS:C/\./\\\./g}/,,g' ${SED_CMDS.${.TARGET:T:R}} \
+	  < ${.IMPSRC} > ${.TARGET}.tmp
+	@echo "exit status `cat ${.TARGET:R}.status`" >> ${.TARGET}.tmp
+	@mv ${.TARGET}.tmp ${.TARGET}
 
+# Compare all output files
+test:	${OUTFILES} .PHONY
+	@failed= ; \
+	for test in ${TESTNAMES}; do \
+	  ${TOOL_DIFF} ${DIFF_FLAGS} ${UNIT_TESTS}/$${test}.exp $${test}.out \
+	  || failed="$${failed}$${failed:+ }$${test}" ; \
+	done ; \
+	if [ -n "$${failed}" ]; then \
+	  echo "Failed tests: $${failed}" ; false ; \
+	else \
+	  echo "All tests passed" ; \
+	fi
+
 accept:
-	mv test.out ${srcdir}/test.exp
+	@for test in ${TESTNAMES}; do \
+	  cmp -s ${UNIT_TESTS}/$${test}.exp $${test}.out \
+	  || { echo "Replacing $${test}.exp" ; \
+	       cp $${test}.out ${UNIT_TESTS}/$${test}.exp ; } \
+	done
 
+.if exists(${TEST_MAKE})
+${TESTNAMES:S/$/.rawout/}: ${TEST_MAKE}
+.endif
+
+.-include <obj.mk>

Deleted: vendor/NetBSD/bmake/dist/unit-tests/comment
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/comment	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/unit-tests/comment	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,31 +0,0 @@
-# This is a comment
-.if ${MACHINE_ARCH} == something
-FOO=bar
-.endif
-
-#\
-	Multiline comment
-
-BAR=# defined
-FOOBAR= # defined 
-
-# This is an escaped comment \
-that keeps going until the end of this line
-
-# Another escaped comment \
-that \
-goes \
-on
-
-# This is NOT an escaped comment due to the double backslashes \\
-all: hi foo bar
-	@echo comment testing done
-
-hi:
-	@echo comment testing start
-
-foo:
-	@echo this is $@
-
-bar:
-	@echo This is how a comment looks: '# comment'

Added: vendor/NetBSD/bmake/dist/unit-tests/comment.exp
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/comment.exp	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/comment.exp	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,5 @@
+comment testing start
+this is foo
+This is how a comment looks: # comment
+comment testing done
+exit status 0

Added: vendor/NetBSD/bmake/dist/unit-tests/comment.mk
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/comment.mk	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/comment.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,31 @@
+# This is a comment
+.if ${MACHINE_ARCH} == something
+FOO=bar
+.endif
+
+#\
+	Multiline comment
+
+BAR=# defined
+FOOBAR= # defined 
+
+# This is an escaped comment \
+that keeps going until the end of this line
+
+# Another escaped comment \
+that \
+goes \
+on
+
+# This is NOT an escaped comment due to the double backslashes \\
+all: hi foo bar
+	@echo comment testing done
+
+hi:
+	@echo comment testing start
+
+foo:
+	@echo this is $@
+
+bar:
+	@echo This is how a comment looks: '# comment'

Deleted: vendor/NetBSD/bmake/dist/unit-tests/cond1
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/cond1	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/unit-tests/cond1	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,109 +0,0 @@
-# $Id: cond1,v 1.1.1.3 2011/03/06 00:04:58 sjg Exp $
-
-# hard code these!
-TEST_UNAME_S= NetBSD
-TEST_UNAME_M= sparc
-TEST_MACHINE= i386
-
-.if ${TEST_UNAME_S}
-Ok=var,
-.endif
-.if ("${TEST_UNAME_S}")
-Ok+=(\"var\"),
-.endif
-.if (${TEST_UNAME_M} != ${TEST_MACHINE})
-Ok+=(var != var),
-.endif
-.if ${TEST_UNAME_M} != ${TEST_MACHINE}
-Ok+= var != var,
-.endif
-.if !((${TEST_UNAME_M} != ${TEST_MACHINE}) && defined(X))
-Ok+= !((var != var) && defined(name)),
-.endif
-# from bsd.obj.mk
-MKOBJ?=no
-.if ${MKOBJ} == "no"
-o= no
-Ok+= var == "quoted",
-.else
-.if defined(notMAKEOBJDIRPREFIX) || defined(norMAKEOBJDIR)
-.if defined(notMAKEOBJDIRPREFIX)
-o=${MAKEOBJDIRPREFIX}${__curdir}
-.else
-o= ${MAKEOBJDIR}
-.endif
-.endif
-o= o
-.endif
-
-# repeat the above to check we get the same result
-.if ${MKOBJ} == "no"
-o2= no
-.else
-.if defined(notMAKEOBJDIRPREFIX) || defined(norMAKEOBJDIR)
-.if defined(notMAKEOBJDIRPREFIX)
-o2=${MAKEOBJDIRPREFIX}${__curdir}
-.else
-o2= ${MAKEOBJDIR}
-.endif
-.endif
-o2= o
-.endif
-
-PRIMES=2 3 5 7 11
-NUMBERS=1 2 3 4 5
-
-n=2
-.if ${PRIMES:M$n} == ""
-X=not
-.else
-X=
-.endif
-
-.if ${MACHINE_ARCH} == no-such
-A=one
-.else
-.if ${MACHINE_ARCH} == not-this
-.if ${MACHINE_ARCH} == something-else
-A=unlikely
-.else
-A=no
-.endif
-.endif
-A=other
-# We expect an extra else warning - we're not skipping here
-.else
-A=this should be an error
-.endif
-
-.if $X != ""
-.if $X == not
-B=one
-.else
-B=other
-# We expect an extra else warning - we are skipping here
-.else
-B=this should be an error
-.endif
-.else
-B=unknown
-.endif
-
-.if "quoted" == quoted
-C=clever
-.else
-C=dim
-.endif
-
-.if defined(nosuch) && ${nosuch:Mx} != ""
-# this should not happen
-.info nosuch is x
-.endif
-
-all:
-	@echo "$n is $X prime"
-	@echo "A='$A' B='$B' C='$C' o='$o,${o2}'"
-	@echo "Passed:${.newline} ${Ok:S/,/${.newline}/}"
-	@echo "${NUMBERS:@n@$n is ${("${PRIMES:M$n}" == ""):?not:} prime${.newline}@}"
-	@echo "${"${DoNotQuoteHere:U0}" > 0:?OK:No}"
-	@echo "${${NoSuchNumber:U42} > 0:?OK:No}"

Added: vendor/NetBSD/bmake/dist/unit-tests/cond1.exp
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/cond1.exp	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/cond1.exp	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,23 @@
+make: "cond1.mk" line 75: warning: extra else
+make: "cond1.mk" line 85: warning: extra else
+2 is  prime
+A='other' B='unknown' C='clever' o='no,no'
+Passed:
+ var
+ ("var")
+ (var != var)
+ var != var
+ !((var != var) && defined(name))
+ var == quoted
+
+1 is not prime
+2 is  prime
+3 is  prime
+4 is not prime
+5 is  prime
+
+make: warning: String comparison operator should be either == or !=
+make: Bad conditional expression `"0" > 0' in "0" > 0?OK:No
+
+OK
+exit status 0

Added: vendor/NetBSD/bmake/dist/unit-tests/cond1.mk
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/cond1.mk	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/cond1.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,109 @@
+# $Id: cond1.mk,v 1.1.1.1 2014/08/30 18:57:18 sjg Exp $
+
+# hard code these!
+TEST_UNAME_S= NetBSD
+TEST_UNAME_M= sparc
+TEST_MACHINE= i386
+
+.if ${TEST_UNAME_S}
+Ok=var,
+.endif
+.if ("${TEST_UNAME_S}")
+Ok+=(\"var\"),
+.endif
+.if (${TEST_UNAME_M} != ${TEST_MACHINE})
+Ok+=(var != var),
+.endif
+.if ${TEST_UNAME_M} != ${TEST_MACHINE}
+Ok+= var != var,
+.endif
+.if !((${TEST_UNAME_M} != ${TEST_MACHINE}) && defined(X))
+Ok+= !((var != var) && defined(name)),
+.endif
+# from bsd.obj.mk
+MKOBJ?=no
+.if ${MKOBJ} == "no"
+o= no
+Ok+= var == "quoted",
+.else
+.if defined(notMAKEOBJDIRPREFIX) || defined(norMAKEOBJDIR)
+.if defined(notMAKEOBJDIRPREFIX)
+o=${MAKEOBJDIRPREFIX}${__curdir}
+.else
+o= ${MAKEOBJDIR}
+.endif
+.endif
+o= o
+.endif
+
+# repeat the above to check we get the same result
+.if ${MKOBJ} == "no"
+o2= no
+.else
+.if defined(notMAKEOBJDIRPREFIX) || defined(norMAKEOBJDIR)
+.if defined(notMAKEOBJDIRPREFIX)
+o2=${MAKEOBJDIRPREFIX}${__curdir}
+.else
+o2= ${MAKEOBJDIR}
+.endif
+.endif
+o2= o
+.endif
+
+PRIMES=2 3 5 7 11
+NUMBERS=1 2 3 4 5
+
+n=2
+.if ${PRIMES:M$n} == ""
+X=not
+.else
+X=
+.endif
+
+.if ${MACHINE_ARCH} == no-such
+A=one
+.else
+.if ${MACHINE_ARCH} == not-this
+.if ${MACHINE_ARCH} == something-else
+A=unlikely
+.else
+A=no
+.endif
+.endif
+A=other
+# We expect an extra else warning - we're not skipping here
+.else
+A=this should be an error
+.endif
+
+.if $X != ""
+.if $X == not
+B=one
+.else
+B=other
+# We expect an extra else warning - we are skipping here
+.else
+B=this should be an error
+.endif
+.else
+B=unknown
+.endif
+
+.if "quoted" == quoted
+C=clever
+.else
+C=dim
+.endif
+
+.if defined(nosuch) && ${nosuch:Mx} != ""
+# this should not happen
+.info nosuch is x
+.endif
+
+all:
+	@echo "$n is $X prime"
+	@echo "A='$A' B='$B' C='$C' o='$o,${o2}'"
+	@echo "Passed:${.newline} ${Ok:S/,/${.newline}/}"
+	@echo "${NUMBERS:@n@$n is ${("${PRIMES:M$n}" == ""):?not:} prime${.newline}@}"
+	@echo "${"${DoNotQuoteHere:U0}" > 0:?OK:No}"
+	@echo "${${NoSuchNumber:U42} > 0:?OK:No}"

Added: vendor/NetBSD/bmake/dist/unit-tests/cond2.exp
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/cond2.exp	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/cond2.exp	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,7 @@
+make: Bad conditional expression ` == "empty"' in  == "empty"?oops:ok
+make: "cond2.mk" line 13: Malformed conditional ({TEST_TYPO} == "Ok")
+TEST_NOT_SET is empty or not defined
+make: "cond2.mk" line 20: Malformed conditional (${TEST_NOT_SET} == "empty")
+make: Fatal errors encountered -- cannot continue
+make: stopped in unit-tests
+exit status 1

Added: vendor/NetBSD/bmake/dist/unit-tests/cond2.mk
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/cond2.mk	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/cond2.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,29 @@
+# $Id: cond2.mk,v 1.1.1.2 2015/12/02 00:34:27 sjg Exp $
+
+TEST_UNAME_S= NetBSD
+
+# this should be ok
+X:= ${${TEST_UNAME_S} == "NetBSD":?Ok:fail}
+.if $X == "Ok"
+Y= good
+.endif
+# expect: Bad conditional expression ` == "empty"' in  == "empty"?oops:ok
+X:= ${${TEST_NOT_SET} == "empty":?oops:ok}
+# expect: Malformed conditional ({TEST_TYPO} == "Ok")
+.if {TEST_TYPO} == "Ok"
+Y= oops
+.endif
+.if empty(TEST_NOT_SET)
+Y!= echo TEST_NOT_SET is empty or not defined >&2; echo
+.endif
+# expect: Malformed conditional (${TEST_NOT_SET} == "empty")
+.if ${TEST_NOT_SET} == "empty"
+Y= oops
+.endif
+
+.if defined(.NDEF) && ${.NDEF} > 0
+Z= yes
+.endif
+
+all:
+	@echo $@

Deleted: vendor/NetBSD/bmake/dist/unit-tests/doterror
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/doterror	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/unit-tests/doterror	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,20 +0,0 @@
-# $Id: doterror,v 1.1.1.1 2010/04/08 17:43:00 sjg Exp $
-
-
-.BEGIN:
-	@echo At first, I am
-
-.END:
-	@echo not reached
-
-.ERROR:
-	@echo "$@: Looks like '${.ERROR_TARGET}' is upset."
-
-all:	happy sad
-
-happy:
-	@echo $@
-
-sad:
-	@echo and now: $@; exit 1
-

Added: vendor/NetBSD/bmake/dist/unit-tests/doterror.exp
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/doterror.exp	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/doterror.exp	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,9 @@
+At first, I am
+happy
+and now: sad
+*** Error code 1
+
+Stop.
+make: stopped in unit-tests
+.ERROR: Looks like 'sad' is upset.
+exit status 1

Added: vendor/NetBSD/bmake/dist/unit-tests/doterror.mk
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/doterror.mk	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/doterror.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,20 @@
+# $Id: doterror.mk,v 1.1.1.1 2014/08/30 18:57:18 sjg Exp $
+
+
+.BEGIN:
+	@echo At first, I am
+
+.END:
+	@echo not reached
+
+.ERROR:
+	@echo "$@: Looks like '${.ERROR_TARGET}' is upset."
+
+all:	happy sad
+
+happy:
+	@echo $@
+
+sad:
+	@echo and now: $@; exit 1
+

Deleted: vendor/NetBSD/bmake/dist/unit-tests/dotwait
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/dotwait	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/unit-tests/dotwait	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,61 +0,0 @@
-# $NetBSD: dotwait,v 1.1 2006/02/26 22:45:46 apb Exp $
-
-THISMAKEFILE:= ${.PARSEDIR}/${.PARSEFILE}
-
-TESTS= simple recursive shared cycle
-PAUSE= sleep 1
-
-# Use a .for loop rather than dependencies here, to ensure
-# that the tests are run one by one, with parallelism
-# only within tests.
-# Ignore "--- target ---" lines printed by parallel make.
-all:
-.for t in ${TESTS}
-	@${.MAKE} -f ${THISMAKEFILE} -j4 $t | grep -v "^--- "
-.endfor
-
-#
-# Within each test, the names of the sub-targets follow these
-# conventions:
-# * If it's expected that two or more targets may be made in parallel,
-#   then the target names will differ only in an alphabetic component
-#   such as ".a" or ".b".
-# * If it's expected that two or more targets should be made in sequence
-#   then the target names will differ in numeric components, such that
-#   lexical ordering of the target names matches the expected order
-#   in which the targets should be made.
-#
-# Targets may echo ${PARALLEL_TARG} to print a modified version
-# of their own name, in which alphabetic components like ".a" or ".b"
-# are converted to ".*".  Two targets that are expected to
-# be made in parallel will thus print the same strings, so that the
-# output is independent of the order in which these targets are made.
-#
-PARALLEL_TARG= ${.TARGET:C/\.[a-z]/.*/g:Q}
-.DEFAULT:
-	@echo ${PARALLEL_TARG}; ${PAUSE}; echo ${PARALLEL_TARG}
-_ECHOUSE: .USE
-	@echo ${PARALLEL_TARG}; ${PAUSE}; echo ${PARALLEL_TARG}
-
-# simple: no recursion, no cycles
-simple: simple.1 .WAIT simple.2
-
-# recursive: all children of the left hand side of the .WAIT
-# must be made before any child of the right hand side.
-recursive: recursive.1.99 .WAIT recursive.2.99
-recursive.1.99: recursive.1.1.a recursive.1.1.b _ECHOUSE
-recursive.2.99: recursive.2.1.a recursive.2.1.b _ECHOUSE
-
-# shared: both shared.1.99 and shared.2.99 depend on shared.0.
-# shared.0 must be made first, even though it is a child of
-# the right hand side of the .WAIT.
-shared: shared.1.99 .WAIT shared.2.99
-shared.1.99: shared.0 _ECHOUSE
-shared.2.99: shared.2.1 shared.0 _ECHOUSE
-
-# cycle: the cyclic dependency must not cause infinite recursion
-# leading to stack overflow and a crash.
-cycle: cycle.1.99 .WAIT cycle.2.99
-cycle.2.99: cycle.2.98 _ECHOUSE
-cycle.2.98: cycle.2.97 _ECHOUSE
-cycle.2.97: cycle.2.99 _ECHOUSE

Added: vendor/NetBSD/bmake/dist/unit-tests/dotwait.exp
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/dotwait.exp	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/dotwait.exp	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,30 @@
+simple.1
+simple.1
+simple.2
+simple.2
+recursive.1.1.*
+recursive.1.1.*
+recursive.1.1.*
+recursive.1.1.*
+recursive.1.99
+recursive.1.99
+recursive.2.1.*
+recursive.2.1.*
+recursive.2.1.*
+recursive.2.1.*
+recursive.2.99
+recursive.2.99
+shared.0
+shared.0
+shared.1.99
+shared.1.99
+shared.2.1
+shared.2.1
+shared.2.99
+shared.2.99
+make: Graph cycles through `cycle.2.99'
+make: Graph cycles through `cycle.2.98'
+make: Graph cycles through `cycle.2.97'
+cycle.1.99
+cycle.1.99
+exit status 0

Added: vendor/NetBSD/bmake/dist/unit-tests/dotwait.mk
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/dotwait.mk	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/dotwait.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,61 @@
+# $NetBSD: dotwait.mk,v 1.1 2014/08/21 13:44:51 apb Exp $
+
+THISMAKEFILE:= ${.PARSEDIR}/${.PARSEFILE}
+
+TESTS= simple recursive shared cycle
+PAUSE= sleep 1
+
+# Use a .for loop rather than dependencies here, to ensure
+# that the tests are run one by one, with parallelism
+# only within tests.
+# Ignore "--- target ---" lines printed by parallel make.
+all:
+.for t in ${TESTS}
+	@${.MAKE} -f ${THISMAKEFILE} -j4 $t | grep -v "^--- "
+.endfor
+
+#
+# Within each test, the names of the sub-targets follow these
+# conventions:
+# * If it's expected that two or more targets may be made in parallel,
+#   then the target names will differ only in an alphabetic component
+#   such as ".a" or ".b".
+# * If it's expected that two or more targets should be made in sequence
+#   then the target names will differ in numeric components, such that
+#   lexical ordering of the target names matches the expected order
+#   in which the targets should be made.
+#
+# Targets may echo ${PARALLEL_TARG} to print a modified version
+# of their own name, in which alphabetic components like ".a" or ".b"
+# are converted to ".*".  Two targets that are expected to
+# be made in parallel will thus print the same strings, so that the
+# output is independent of the order in which these targets are made.
+#
+PARALLEL_TARG= ${.TARGET:C/\.[a-z]/.*/g:Q}
+.DEFAULT:
+	@echo ${PARALLEL_TARG}; ${PAUSE}; echo ${PARALLEL_TARG}
+_ECHOUSE: .USE
+	@echo ${PARALLEL_TARG}; ${PAUSE}; echo ${PARALLEL_TARG}
+
+# simple: no recursion, no cycles
+simple: simple.1 .WAIT simple.2
+
+# recursive: all children of the left hand side of the .WAIT
+# must be made before any child of the right hand side.
+recursive: recursive.1.99 .WAIT recursive.2.99
+recursive.1.99: recursive.1.1.a recursive.1.1.b _ECHOUSE
+recursive.2.99: recursive.2.1.a recursive.2.1.b _ECHOUSE
+
+# shared: both shared.1.99 and shared.2.99 depend on shared.0.
+# shared.0 must be made first, even though it is a child of
+# the right hand side of the .WAIT.
+shared: shared.1.99 .WAIT shared.2.99
+shared.1.99: shared.0 _ECHOUSE
+shared.2.99: shared.2.1 shared.0 _ECHOUSE
+
+# cycle: the cyclic dependency must not cause infinite recursion
+# leading to stack overflow and a crash.
+cycle: cycle.1.99 .WAIT cycle.2.99
+cycle.2.99: cycle.2.98 _ECHOUSE
+cycle.2.98: cycle.2.97 _ECHOUSE
+cycle.2.97: cycle.2.99 _ECHOUSE

Deleted: vendor/NetBSD/bmake/dist/unit-tests/error
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/error	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/unit-tests/error	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,10 +0,0 @@
-# $Id: error,v 1.1.1.2 2010/05/24 23:36:03 sjg Exp $
-
-.info just FYI
-.warning this could be serious
-.error this is fatal
-
-all:
-
-.info.html:
-	@echo this should be ignored

Added: vendor/NetBSD/bmake/dist/unit-tests/error.exp
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/error.exp	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/error.exp	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,4 @@
+make: "error.mk" line 3: just FYI
+make: "error.mk" line 4: warning: this could be serious
+make: "error.mk" line 5: this is fatal
+exit status 1

Added: vendor/NetBSD/bmake/dist/unit-tests/error.mk
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/error.mk	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/error.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,10 @@
+# $Id: error.mk,v 1.1.1.1 2014/08/30 18:57:18 sjg Exp $
+
+.info just FYI
+.warning this could be serious
+.error this is fatal
+
+all:
+
+.info.html:
+	@echo this should be ignored

Added: vendor/NetBSD/bmake/dist/unit-tests/escape.exp
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/escape.exp	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/escape.exp	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,104 @@
+var-1bs
+printf "%s=:%s:\n" VAR1BS 111\\111;   printf "%s=:%s:\n" VAR1BSa 111\\aaa;   printf "%s=:%s:\n" VAR1BSA 111\\aaa;   printf "%s=:%s:\n" VAR1BSda 111\\\$\{a\};   printf "%s=:%s:\n" VAR1BSdA 111\\\$\{A\};   printf "%s=:%s:\n" VAR1BSc 111\#\ backslash\ escapes\ comment\ char,\ so\ this\ is\ part\ of\ the\ value;   printf "%s=:%s:\n" VAR1BSsc 111\\\ ; 
+VAR1BS=:111\111:
+VAR1BSa=:111\aaa:
+VAR1BSA=:111\aaa:
+VAR1BSda=:111\${a}:
+VAR1BSdA=:111\${A}:
+VAR1BSc=:111# backslash escapes comment char, so this is part of the value:
+VAR1BSsc=:111\ :
+var-2bs
+printf "%s=:%s:\n" VAR2BS 222\\\\222;   printf "%s=:%s:\n" VAR2BSa 222\\\\aaa;   printf "%s=:%s:\n" VAR2BSA 222\\\\aaa;   printf "%s=:%s:\n" VAR2BSda 222\\\\\$\{a\};   printf "%s=:%s:\n" VAR2BSdA 222\\\\\$\{A\};   printf "%s=:%s:\n" VAR2BSc 222\\\\;   printf "%s=:%s:\n" VAR2BSsc 222\\\\; 
+VAR2BS=:222\\222:
+VAR2BSa=:222\\aaa:
+VAR2BSA=:222\\aaa:
+VAR2BSda=:222\\${a}:
+VAR2BSdA=:222\\${A}:
+VAR2BSc=:222\\:
+VAR2BSsc=:222\\:
+var-1bsnl
+printf "%s=:%s:\n" VAR1BSNL 111\ 111;   printf "%s=:%s:\n" VAR1BSNLa 111\ aaa;   printf "%s=:%s:\n" VAR1BSNLA 111\ aaa;   printf "%s=:%s:\n" VAR1BSNLda 111\ \$\{a\};   printf "%s=:%s:\n" VAR1BSNLdA 111\ \$\{A\};   printf "%s=:%s:\n" VAR1BSNLc 111;   printf "%s=:%s:\n" VAR1BSNLsc 111; 
+VAR1BSNL=:111 111:
+VAR1BSNLa=:111 aaa:
+VAR1BSNLA=:111 aaa:
+VAR1BSNLda=:111 ${a}:
+VAR1BSNLdA=:111 ${A}:
+VAR1BSNLc=:111:
+VAR1BSNLsc=:111:
+var-2bsnl
+printf "%s=:%s:\n" VAR2BSNL 222\\\\;   printf "%s=:%s:\n" VAR2BSNLa 222\\\\;   printf "%s=:%s:\n" VAR2BSNLA 222\\\\;   printf "%s=:%s:\n" VAR2BSNLda 222\\\\;   printf "%s=:%s:\n" VAR2BSNLdA 222\\\\;   printf "%s=:%s:\n" VAR2BSNLc 222\\\\;   printf "%s=:%s:\n" VAR2BSNLsc 222\\\\; 
+VAR2BSNL=:222\\:
+VAR2BSNLa=:222\\:
+VAR2BSNLA=:222\\:
+VAR2BSNLda=:222\\:
+VAR2BSNLdA=:222\\:
+VAR2BSNLc=:222\\:
+VAR2BSNLsc=:222\\:
+var-3bsnl
+printf "%s=:%s:\n" VAR3BSNL 333\\\\\ 333=;   printf "%s=:%s:\n" VAR3BSNLa 333\\\\\ aaa=;   printf "%s=:%s:\n" VAR3BSNLA 333\\\\\ aaa=;   printf "%s=:%s:\n" VAR3BSNLda 333\\\\\ \$\{a\}=;   printf "%s=:%s:\n" VAR3BSNLdA 333\\\\\ \$\{A\}=;   printf "%s=:%s:\n" VAR3BSNLc 333\\\\;   printf "%s=:%s:\n" VAR3BSNLsc 333\\\\; 
+VAR3BSNL=:333\\ 333=:
+VAR3BSNLa=:333\\ aaa=:
+VAR3BSNLA=:333\\ aaa=:
+VAR3BSNLda=:333\\ ${a}=:
+VAR3BSNLdA=:333\\ ${A}=:
+VAR3BSNLc=:333\\:
+VAR3BSNLsc=:333\\:
+var-1bsnl-space
+printf "%s=:%s:\n" VAR1BSNL00 first\ line;   printf "%s=:%s:\n" VAR1BSNL0 first\ line\ no\ space\ on\ second\ line;   printf "%s=:%s:\n" VAR1BSNLs first\ line\ one\ space\ on\ second\ line;   printf "%s=:%s:\n" VAR1BSNLss first\ line\ two\ spaces\ on\ second\ line;   printf "%s=:%s:\n" VAR1BSNLt first\ line\ one\ tab\ on\ second\ line;   printf "%s=:%s:\n" VAR1BSNLtt first\ line\ two\ tabs\ on\ second\ line;   printf "%s=:%s:\n" VAR1BSNLxx first\ line\ many\ spaces\ and\ tabs\ \[\ \ \	\ \]\ on\ second\ line; 
+VAR1BSNL00=:first line:
+VAR1BSNL0=:first line no space on second line:
+VAR1BSNLs=:first line one space on second line:
+VAR1BSNLss=:first line two spaces on second line:
+VAR1BSNLt=:first line one tab on second line:
+VAR1BSNLtt=:first line two tabs on second line:
+VAR1BSNLxx=:first line many spaces and tabs [  	 ] on second line:
+cmd-1bsnl
+echo :'first line\
+#second line without space\
+third line':
+:first line\
+#second line without space\
+third line:
+echo :'first line\
+     second line spaces should be retained':
+:first line\
+     second line spaces should be retained:
+echo :'first line\
+second line tab should be elided':
+:first line\
+second line tab should be elided:
+echo :'first line\
+	only one tab should be elided, second tab remains'
+:first line\
+	only one tab should be elided, second tab remains
+cmd-1bsnl-eof
+echo :'command ending with backslash-newline'; \
+
+:command ending with backslash-newline
+cmd-2bsnl
+echo take one\\
+take one\
+echo take two\\
+take two\
+echo take three\\
+take three\
+cmd-3bsnl
+echo :'first line\\\
+#second line without space\\\
+third line':
+:first line\\\
+#second line without space\\\
+third line:
+echo :'first line\\\
+     second line spaces should be retained':
+:first line\\\
+     second line spaces should be retained:
+echo :'first line\\\
+second line tab should be elided':
+:first line\\\
+second line tab should be elided:
+echo :'first line\\\
+	only one tab should be elided, second tab remains'
+:first line\\\
+	only one tab should be elided, second tab remains
+exit status 0

Added: vendor/NetBSD/bmake/dist/unit-tests/escape.mk
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/escape.mk	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/escape.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,246 @@
+# $Id: escape.mk,v 1.1.1.2 2014/11/06 01:40:37 sjg Exp $
+#
+# Test backslash escaping.
+
+# Extracts from the POSIX 2008 specification
+# <http://pubs.opengroup.org/onlinepubs/9699919799/utilities/make.html>:
+#
+#     Comments start with a <number-sign> ( '#' ) and continue until an
+#     unescaped <newline> is reached.
+#
+#     When an escaped <newline> (one preceded by a <backslash>) is found
+#     anywhere in the makefile except in a command line, an include
+#     line, or a line immediately preceding an include line, it shall
+#     be replaced, along with any leading white space on the following
+#     line, with a single <space>.
+#
+#     When an escaped <newline> is found in a command line in a
+#     makefile, the command line shall contain the <backslash>, the
+#     <newline>, and the next line, except that the first character of
+#     the next line shall not be included if it is a <tab>.
+#
+#     When an escaped <newline> is found in an include line or in a
+#     line immediately preceding an include line, the behavior is
+#     unspecified.
+#
+# Notice that the behaviour of <backslash><backslash> or
+# <backslash><anything other than newline> is not mentioned.  I think
+# this implies that <backslash> should be taken literally everywhere
+# except before <newline>.
+#
+# Our practice, despite what POSIX might say, is that "\#"
+# in a variable assignment stores "#" as part of the value.
+# The "\" is not taken literally, and the "#" does not begin a comment.
+#
+# Also, our practice is that an even number of backslashes before a
+# newline in a variable assignment simply stores the backslashes as part
+# of the value, and treats the newline as though it was not escaped.
+# Similarly, ann even number of backslashes before a newline in a
+# command simply uses the backslashes as part of the command test, but
+# does not escape the newline.  This is compatible with GNU make.
+
+all: .PHONY
+# We will add dependencies like "all: yet-another-test" later.
+
+# Some variables to be expanded in tests
+#
+a = aaa
+A = ${a}
+
+# Backslash at end of line in a comment\
+should continue the comment. \
+# This is also tested in comment.mk.
+
+__printvars: .USE .MADE
+	@echo ${.TARGET}
+	${.ALLSRC:@v@ printf "%s=:%s:\n" ${v:Q} ${${v}:Q}; @}
+
+# Embedded backslash in variable should be taken literally.
+#
+VAR1BS = 111\111
+VAR1BSa = 111\${a}
+VAR1BSA = 111\${A}
+VAR1BSda = 111\$${a}
+VAR1BSdA = 111\$${A}
+VAR1BSc = 111\# backslash escapes comment char, so this is part of the value
+VAR1BSsc = 111\ # This is a comment.  Value ends with <backslash><space>
+
+all: var-1bs
+var-1bs: .PHONY __printvars VAR1BS VAR1BSa VAR1BSA VAR1BSda VAR1BSdA \
+	VAR1BSc VAR1BSsc
+
+# Double backslash in variable should be taken as two literal backslashes.
+#
+VAR2BS = 222\\222
+VAR2BSa = 222\\${a}
+VAR2BSA = 222\\${A}
+VAR2BSda = 222\\$${a}
+VAR2BSdA = 222\\$${A}
+VAR2BSc = 222\\# backslash does not escape comment char, so this is a comment
+VAR2BSsc = 222\\ # This is a comment.  Value ends with <backslash><backslash>
+
+all: var-2bs
+var-2bs: .PHONY __printvars VAR2BS VAR2BSa VAR2BSA VAR2BSda VAR2BSdA \
+	VAR2BSc VAR2BSsc
+
+# Backslash-newline in a variable setting is replaced by a single space.
+#
+VAR1BSNL = 111\
+111
+VAR1BSNLa = 111\
+${a}
+VAR1BSNLA = 111\
+${A}
+VAR1BSNLda = 111\
+$${a}
+VAR1BSNLdA = 111\
+$${A}
+VAR1BSNLc = 111\
+# this should be processed as a comment
+VAR1BSNLsc = 111\
+ # this should be processed as a comment
+
+all: var-1bsnl
+var-1bsnl:	.PHONY
+var-1bsnl: .PHONY __printvars \
+	VAR1BSNL VAR1BSNLa VAR1BSNLA VAR1BSNLda VAR1BSNLdA \
+	VAR1BSNLc VAR1BSNLsc
+
+# Double-backslash-newline in a variable setting.
+# Both backslashes should be taken literally, and the newline is NOT escaped.
+#
+# The second lines below each end with '=' so that they will not
+# generate syntax errors regardless of whether or not they are
+# treated as part of the value.
+#
+VAR2BSNL = 222\\
+222=
+VAR2BSNLa = 222\\
+${a}=
+VAR2BSNLA = 222\\
+${A}=
+VAR2BSNLda = 222\\
+$${a}=
+VAR2BSNLdA = 222\\
+$${A}=
+VAR2BSNLc = 222\\
+# this should be processed as a comment
+VAR2BSNLsc = 222\\
+ # this should be processed as a comment
+
+all: var-2bsnl
+var-2bsnl: .PHONY __printvars \
+	VAR2BSNL VAR2BSNLa VAR2BSNLA VAR2BSNLda VAR2BSNLdA \
+	VAR2BSNLc VAR2BSNLsc
+
+# Triple-backslash-newline in a variable setting.
+# First two should be taken literally, and last should escape the newline.
+#
+# The second lines below each end with '=' so that they will not
+# generate syntax errors regardless of whether or not they are
+# treated as part of the value.
+#
+VAR3BSNL = 333\\\
+333=
+VAR3BSNLa = 333\\\
+${a}=
+VAR3BSNLA = 333\\\
+${A}=
+VAR3BSNLda = 333\\\
+$${a}=
+VAR3BSNLdA = 333\\\
+$${A}=
+VAR3BSNLc = 333\\\
+# this should be processed as a comment
+VAR3BSNLsc = 333\\\
+ # this should be processed as a comment
+
+all: var-3bsnl
+var-3bsnl: .PHONY __printvars \
+	VAR3BSNL VAR3BSNLa VAR3BSNLA VAR3BSNLda VAR3BSNLdA \
+	VAR3BSNLc VAR3BSNLsc
+
+# Backslash-newline in a variable setting, plus any amount of white space
+# on the next line, is replaced by a single space.
+#
+VAR1BSNL00= first line\
+
+# above line is entirely empty, and this is a comment
+VAR1BSNL0= first line\
+no space on second line
+VAR1BSNLs= first line\
+ one space on second line
+VAR1BSNLss= first line\
+  two spaces on second line
+VAR1BSNLt= first line\
+	one tab on second line
+VAR1BSNLtt= first line\
+		two tabs on second line
+VAR1BSNLxx= first line\
+  	 	 	 many spaces and tabs [  	 ] on second line
+
+all: var-1bsnl-space
+var-1bsnl-space: .PHONY __printvars \
+	VAR1BSNL00 VAR1BSNL0 VAR1BSNLs VAR1BSNLss VAR1BSNLt VAR1BSNLtt \
+	VAR1BSNLxx
+
+# Backslash-newline in a command is retained.
+#
+# The "#" in "# second line without space" makes it a comment instead
+# of a syntax error if the preceding line is parsed incorretly.
+# The ":" in "third line':" makes it look like the start of a
+# target instead of a syntax error if the first line is parsed incorrectly.
+#
+all: cmd-1bsnl
+cmd-1bsnl: .PHONY
+	@echo ${.TARGET}
+	echo :'first line\
+#second line without space\
+third line':
+	echo :'first line\
+     second line spaces should be retained':
+	echo :'first line\
+	second line tab should be elided':
+	echo :'first line\
+		only one tab should be elided, second tab remains'
+
+# When backslash-newline appears at the end of a command script,
+# both the backslash and the newline should be passed to the shell.
+# The shell should elide the backslash-newline.
+#
+all: cmd-1bsnl-eof
+cmd-1bsnl-eof:
+	@echo ${.TARGET}
+	echo :'command ending with backslash-newline'; \
+
+# above line must be blank
+
+# Double-backslash-newline in a command.
+# Both backslashes are retained, but the newline is not escaped.
+# XXX: This may differ from POSIX, but matches gmake.
+#
+# When make passes two backslashes to the shell, the shell will pass one
+# backslash to the echo commant.
+#
+all: cmd-2bsnl
+cmd-2bsnl: .PHONY
+	@echo ${.TARGET}
+	echo take one\\
+# this should be a comment
+	echo take two\\
+	echo take three\\
+
+# Triple-backslash-newline in a command is retained.
+#
+all: cmd-3bsnl
+cmd-3bsnl: .PHONY
+	@echo ${.TARGET}
+	echo :'first line\\\
+#second line without space\\\
+third line':
+	echo :'first line\\\
+     second line spaces should be retained':
+	echo :'first line\\\
+	second line tab should be elided':
+	echo :'first line\\\
+		only one tab should be elided, second tab remains'

Deleted: vendor/NetBSD/bmake/dist/unit-tests/export
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/export	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/unit-tests/export	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,22 +0,0 @@
-# $Id: export,v 1.1.1.1 2007/10/08 20:30:12 sjg Exp $
-
-UT_TEST=export
-UT_FOO=foo${BAR}
-UT_FU=fubar
-UT_ZOO=hoopie
-UT_NO=all
-# belive it or not, we expect this one to come out with $UT_FU unexpanded.
-UT_DOLLAR= This is $$UT_FU
-
-.export UT_FU UT_FOO
-.export UT_DOLLAR
-# this one will be ignored
-.export .MAKE.PID
-
-BAR=bar is ${UT_FU}
-
-.MAKE.EXPORTED+= UT_ZOO UT_TEST
-
-all:
-	@env | grep '^UT_' | sort
-

Deleted: vendor/NetBSD/bmake/dist/unit-tests/export-all
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/export-all	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/unit-tests/export-all	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,23 +0,0 @@
-# $Id: export-all,v 1.1.1.2 2010/04/21 04:26:14 sjg Exp $
-
-UT_OK=good
-UT_F=fine
-
-# the old way to do :tA
-M_tAbad = C,.*,cd & \&\& 'pwd',:sh
-# the new
-M_tA = tA
-
-here := ${.PARSEDIR}
-
-# this will cause trouble (recursing if we let it)
-UT_BADDIR = ${${here}/../${here:T}:L:${M_tAbad}:T}
-# this will be ok
-UT_OKDIR = ${${here}/../${here:T}:L:${M_tA}:T}
-
-.export
-
-.include "export"
-
-UT_TEST=export-all
-UT_ALL=even this gets exported

Added: vendor/NetBSD/bmake/dist/unit-tests/export-all.exp
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/export-all.exp	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/export-all.exp	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,12 @@
+UT_ALL=even this gets exported
+UT_BADDIR=unit-tests
+UT_DOLLAR=This is $UT_FU
+UT_F=fine
+UT_FOO=foobar is fubar
+UT_FU=fubar
+UT_NO=all
+UT_OK=good
+UT_OKDIR=unit-tests
+UT_TEST=export-all
+UT_ZOO=hoopie
+exit status 0

Added: vendor/NetBSD/bmake/dist/unit-tests/export-all.mk
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/export-all.mk	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/export-all.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,23 @@
+# $Id: export-all.mk,v 1.1.1.2 2015/04/10 20:43:38 sjg Exp $
+
+UT_OK=good
+UT_F=fine
+
+# the old way to do :tA
+M_tAbad = C,.*,cd & \&\& 'pwd',:sh
+# the new
+M_tA = tA
+
+here := ${.PARSEDIR}
+
+# this will cause trouble (recursing if we let it)
+UT_BADDIR = ${${here}/../${here:T}:L:${M_tAbad}:T}
+# this will be ok
+UT_OKDIR = ${${here}/../${here:T}:L:${M_tA}:T}
+
+.export
+
+.include "export.mk"
+
+UT_TEST=export-all
+UT_ALL=even this gets exported

Deleted: vendor/NetBSD/bmake/dist/unit-tests/export-env
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/export-env	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/unit-tests/export-env	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,24 +0,0 @@
-# $Id: export-env,v 1.1.1.1 2013/03/23 02:26:59 sjg Exp $
-
-# our normal .export, subsequent changes affect the environment
-UT_TEST=this
-.export UT_TEST
-UT_TEST:= ${.PARSEFILE}
-
-# not so with .export-env
-UT_ENV=exported
-.export-env UT_ENV
-UT_ENV=not-exported
-
-# gmake style export goes further; affects nothing but the environment
-UT_EXP=before-export
-export UT_EXP=exported
-UT_EXP=not-exported
-
-all:
-	@echo make:; ${UT_TEST UT_ENV UT_EXP:L:@v at echo $v=${$v};@}
-	@echo env:; ${UT_TEST UT_ENV UT_EXP:L:@v at echo $v=$${$v};@}
-
-
-
-

Added: vendor/NetBSD/bmake/dist/unit-tests/export-env.exp
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/export-env.exp	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/export-env.exp	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,11 @@
+make:
+UT_TEST=export-env.mk
+UT_ENV=not-exported
+UT_EXP=not-exported
+UT_LIT=literal export-env.mk
+env:
+UT_TEST=export-env.mk
+UT_ENV=exported
+UT_EXP=exported
+UT_LIT=literal ${UT_TEST}
+exit status 0

Added: vendor/NetBSD/bmake/dist/unit-tests/export-env.mk
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/export-env.mk	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/export-env.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,27 @@
+# $Id: export-env.mk,v 1.1.1.2 2016/02/18 20:35:24 sjg Exp $
+
+# our normal .export, subsequent changes affect the environment
+UT_TEST=this
+.export UT_TEST
+UT_TEST:= ${.PARSEFILE}
+
+# not so with .export-env
+UT_ENV=exported
+.export-env UT_ENV
+UT_ENV=not-exported
+
+# gmake style export goes further; affects nothing but the environment
+UT_EXP=before-export
+export UT_EXP=exported
+UT_EXP=not-exported
+
+UT_LIT= literal ${UT_TEST}
+.export-literal UT_LIT
+
+all:
+	@echo make:; ${UT_TEST UT_ENV UT_EXP UT_LIT:L:@v at echo $v=${$v};@}
+	@echo env:; ${UT_TEST UT_ENV UT_EXP UT_LIT:L:@v at echo $v=$${$v};@}
+
+
+
+

Added: vendor/NetBSD/bmake/dist/unit-tests/export.exp
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/export.exp	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/export.exp	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,6 @@
+UT_DOLLAR=This is $UT_FU
+UT_FOO=foobar is fubar
+UT_FU=fubar
+UT_TEST=export
+UT_ZOO=hoopie
+exit status 0

Added: vendor/NetBSD/bmake/dist/unit-tests/export.mk
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/export.mk	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/export.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,22 @@
+# $Id: export.mk,v 1.1.1.1 2014/08/30 18:57:18 sjg Exp $
+
+UT_TEST=export
+UT_FOO=foo${BAR}
+UT_FU=fubar
+UT_ZOO=hoopie
+UT_NO=all
+# belive it or not, we expect this one to come out with $UT_FU unexpanded.
+UT_DOLLAR= This is $$UT_FU
+
+.export UT_FU UT_FOO
+.export UT_DOLLAR
+# this one will be ignored
+.export .MAKE.PID
+
+BAR=bar is ${UT_FU}
+
+.MAKE.EXPORTED+= UT_ZOO UT_TEST
+
+all:
+	@env | grep '^UT_' | sort
+

Deleted: vendor/NetBSD/bmake/dist/unit-tests/forloop
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/forloop	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/unit-tests/forloop	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,45 +0,0 @@
-# $Id: forloop,v 1.1.1.1 2012/06/19 23:30:49 sjg Exp $
-
-all: for-loop
-
-LIST = one "two and three" four "five"
-
-.if make(for-fail)
-for-fail:
-
-XTRA_LIST = xtra
-.else
-
-.for x in ${LIST}
-X!= echo 'x=$x' >&2; echo
-.endfor
-
-CFL = -I/this -I"This or that" -Ithat "-DTHIS=\"this and that\""
-cfl=
-.for x in ${CFL}
-X!= echo 'x=$x' >&2; echo
-.if empty(cfl)
-cfl= $x
-.else
-cfl+= $x
-.endif
-.endfor
-X!= echo 'cfl=${cfl}' >&2; echo
-
-.if ${cfl} != ${CFL}
-.error ${.newline}'${cfl}' != ${.newline}'${CFL}'
-.endif
-
-.for a b in ${EMPTY}
-X!= echo 'a=$a b=$b' >&2; echo
-.endfor
-.endif
-
-.for a b in ${LIST} ${LIST:tu} ${XTRA_LIST}
-X!= echo 'a=$a b=$b' >&2; echo
-.endfor
-
-for-loop:
-	@echo We expect an error next:
-	@(cd ${.CURDIR} && ${.MAKE} -f ${MAKEFILE} for-fail) && \
-	{ echo "Oops that should have failed!"; exit 1; } || echo OK

Added: vendor/NetBSD/bmake/dist/unit-tests/forloop.exp
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/forloop.exp	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/forloop.exp	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,19 @@
+x=one
+x="two and three"
+x=four
+x="five"
+x=-I/this
+x=-I"This or that"
+x=-Ithat
+x="-DTHIS=\"this and that\""
+cfl=-I/this -I"This or that" -Ithat "-DTHIS=\"this and that\""
+a=one b="two and three"
+a=four b="five"
+a=ONE b="TWO AND THREE"
+a=FOUR b="FIVE"
+We expect an error next:
+make: "forloop.mk" line 38: Wrong number of words (9) in .for substitution list with 2 vars
+make: Fatal errors encountered -- cannot continue
+make: stopped in unit-tests
+OK
+exit status 0

Added: vendor/NetBSD/bmake/dist/unit-tests/forloop.mk
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/forloop.mk	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/forloop.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,45 @@
+# $Id: forloop.mk,v 1.1.1.1 2014/08/30 18:57:18 sjg Exp $
+
+all: for-loop
+
+LIST = one "two and three" four "five"
+
+.if make(for-fail)
+for-fail:
+
+XTRA_LIST = xtra
+.else
+
+.for x in ${LIST}
+X!= echo 'x=$x' >&2; echo
+.endfor
+
+CFL = -I/this -I"This or that" -Ithat "-DTHIS=\"this and that\""
+cfl=
+.for x in ${CFL}
+X!= echo 'x=$x' >&2; echo
+.if empty(cfl)
+cfl= $x
+.else
+cfl+= $x
+.endif
+.endfor
+X!= echo 'cfl=${cfl}' >&2; echo
+
+.if ${cfl} != ${CFL}
+.error ${.newline}'${cfl}' != ${.newline}'${CFL}'
+.endif
+
+.for a b in ${EMPTY}
+X!= echo 'a=$a b=$b' >&2; echo
+.endfor
+.endif
+
+.for a b in ${LIST} ${LIST:tu} ${XTRA_LIST}
+X!= echo 'a=$a b=$b' >&2; echo
+.endfor
+
+for-loop:
+	@echo We expect an error next:
+	@(cd ${.CURDIR} && ${.MAKE} -f ${MAKEFILE} for-fail) && \
+	{ echo "Oops that should have failed!"; exit 1; } || echo OK

Deleted: vendor/NetBSD/bmake/dist/unit-tests/forsubst
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/forsubst	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/unit-tests/forsubst	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,10 +0,0 @@
-# $Id: forsubst,v 1.1.1.1 2009/10/07 18:53:35 sjg Exp $
-
-all: for-subst
-
-here := ${.PARSEDIR}
-# this should not run foul of the parser
-.for file in ${.PARSEFILE}
-for-subst:	  ${file:S;^;${here}/;g}
-	@echo ".for with :S;... OK"
-.endfor

Added: vendor/NetBSD/bmake/dist/unit-tests/forsubst.exp
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/forsubst.exp	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/forsubst.exp	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,2 @@
+.for with :S;... OK
+exit status 0

Added: vendor/NetBSD/bmake/dist/unit-tests/forsubst.mk
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/forsubst.mk	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/forsubst.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,10 @@
+# $Id: forsubst.mk,v 1.1.1.1 2014/08/30 18:57:18 sjg Exp $
+
+all: for-subst
+
+here := ${.PARSEDIR}
+# this should not run foul of the parser
+.for file in ${.PARSEFILE}
+for-subst:	  ${file:S;^;${here}/;g}
+	@echo ".for with :S;... OK"
+.endfor

Deleted: vendor/NetBSD/bmake/dist/unit-tests/hash
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/hash	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/unit-tests/hash	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,18 +0,0 @@
-STR1=
-STR2=	a
-STR3=	ab
-STR4=	abc
-STR5=	abcd
-STR6=	abcde
-STR7=	abcdef
-STR8=	abcdefghijklmnopqrstuvwxyz
-
-all:
-	@echo ${STR1:hash}
-	@echo ${STR2:hash}
-	@echo ${STR3:hash}
-	@echo ${STR4:hash}
-	@echo ${STR5:hash}
-	@echo ${STR6:hash}
-	@echo ${STR7:hash}
-	@echo ${STR8:hash}

Added: vendor/NetBSD/bmake/dist/unit-tests/hash.exp
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/hash.exp	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/hash.exp	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,9 @@
+b2af338b
+3360ac65
+7747f046
+9ca87054
+880fe816
+208fcbd3
+d5d376eb
+de41416c
+exit status 0

Added: vendor/NetBSD/bmake/dist/unit-tests/hash.mk
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/hash.mk	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/hash.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,18 @@
+STR1=
+STR2=	a
+STR3=	ab
+STR4=	abc
+STR5=	abcd
+STR6=	abcde
+STR7=	abcdef
+STR8=	abcdefghijklmnopqrstuvwxyz
+
+all:
+	@echo ${STR1:hash}
+	@echo ${STR2:hash}
+	@echo ${STR3:hash}
+	@echo ${STR4:hash}
+	@echo ${STR5:hash}
+	@echo ${STR6:hash}
+	@echo ${STR7:hash}
+	@echo ${STR8:hash}

Added: vendor/NetBSD/bmake/dist/unit-tests/impsrc.exp
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/impsrc.exp	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/impsrc.exp	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,13 @@
+expected: source4
+actual:   source4
+expected: target1.x
+actual:   target1.x
+expected: target1.y
+actual:   target1.y
+expected: source1
+actual:   source1
+expected: source2
+actual:   source2
+expected: source1
+actual:   source1
+exit status 0

Added: vendor/NetBSD/bmake/dist/unit-tests/impsrc.mk
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/impsrc.mk	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/impsrc.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,43 @@
+# $NetBSD: impsrc.mk,v 1.2 2014/08/30 22:21:07 sjg Exp $
+
+# Does ${.IMPSRC} work properly?
+# It should be set, in order of precedence, to ${.TARGET} of:
+#  1) the implied source of a transformation rule,
+#  2) the first prerequisite from the dependency line of an explicit rule, or
+#  3) the first prerequisite of an explicit rule.
+#
+
+all: target1.z target2 target3 target4
+
+.SUFFIXES: .x .y .z
+
+.x.y: source1
+	@echo 'expected: target1.x'
+	@echo 'actual:   $<'
+
+.y.z: source2
+	@echo 'expected: target1.y'
+	@echo 'actual:   $<'
+
+target1.y: source3
+
+target1.x: source4
+	@echo 'expected: source4'
+	@echo 'actual:   $<'
+
+target2: source1 source2
+	@echo 'expected: source1'
+	@echo 'actual:   $<'
+
+target3: source1
+target3: source2 source3
+	@echo 'expected: source2'
+	@echo 'actual:   $<'
+
+target4: source1
+target4:
+	@echo 'expected: source1'
+	@echo 'actual:   $<'
+
+source1 source2 source3 source4:
+

Deleted: vendor/NetBSD/bmake/dist/unit-tests/misc
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/misc	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/unit-tests/misc	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,16 +0,0 @@
-# $Id: misc,v 1.1.1.1 2011/03/06 00:04:58 sjg Exp $
-
-.if !exists(${.CURDIR}/)
-.warning ${.CURDIR}/ doesn't exist ?
-.endif
-
-.if !exists(${.CURDIR}/.)
-.warning ${.CURDIR}/. doesn't exist ?
-.endif
-
-.if !exists(${.CURDIR}/..)
-.warning ${.CURDIR}/.. doesn't exist ?
-.endif
-
-all:
-	@: all is well

Added: vendor/NetBSD/bmake/dist/unit-tests/misc.exp
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/misc.exp	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/misc.exp	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1 @@
+exit status 0

Added: vendor/NetBSD/bmake/dist/unit-tests/misc.mk
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/misc.mk	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/misc.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,16 @@
+# $Id: misc.mk,v 1.1.1.1 2014/08/30 18:57:18 sjg Exp $
+
+.if !exists(${.CURDIR}/)
+.warning ${.CURDIR}/ doesn't exist ?
+.endif
+
+.if !exists(${.CURDIR}/.)
+.warning ${.CURDIR}/. doesn't exist ?
+.endif
+
+.if !exists(${.CURDIR}/..)
+.warning ${.CURDIR}/.. doesn't exist ?
+.endif
+
+all:
+	@: all is well

Deleted: vendor/NetBSD/bmake/dist/unit-tests/moderrs
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/moderrs	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/unit-tests/moderrs	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,31 +0,0 @@
-# $Id: moderrs,v 1.2 2006/05/11 18:53:39 sjg Exp $
-#
-# various modifier error tests
-
-VAR=TheVariable
-# incase we have to change it ;-)
-MOD_UNKN=Z
-MOD_TERM=S,V,v
-MOD_S:= ${MOD_TERM},
-
-all:	modunkn modunknV varterm vartermV modtermV
-
-modunkn:
-	@echo "Expect: Unknown modifier 'Z'"
-	@echo "VAR:Z=${VAR:Z}"
-
-modunknV:
-	@echo "Expect: Unknown modifier 'Z'"
-	@echo "VAR:${MOD_UNKN}=${VAR:${MOD_UNKN}}"
-
-varterm:
-	@echo "Expect: Unclosed variable specification for VAR"
-	@echo VAR:S,V,v,=${VAR:S,V,v,
-
-vartermV:
-	@echo "Expect: Unclosed variable specification for VAR"
-	@echo VAR:${MOD_TERM},=${VAR:${MOD_S}
-
-modtermV:
-	@echo "Expect: Unclosed substitution for VAR (, missing)"
-	- at echo "VAR:${MOD_TERM}=${VAR:${MOD_TERM}}"

Added: vendor/NetBSD/bmake/dist/unit-tests/moderrs.exp
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/moderrs.exp	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/moderrs.exp	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,16 @@
+Expect: Unknown modifier 'Z'
+make: Unknown modifier 'Z'
+VAR:Z=
+Expect: Unknown modifier 'Z'
+make: Unknown modifier 'Z'
+VAR:Z=
+Expect: Unclosed variable specification for VAR
+make: Unclosed variable specification (expecting '}') for "VAR" (value "Thevariable") modifier S
+VAR:S,V,v,=Thevariable
+Expect: Unclosed variable specification for VAR
+make: Unclosed variable specification after complex modifier (expecting '}') for VAR
+VAR:S,V,v,=Thevariable
+Expect: Unclosed substitution for VAR (, missing)
+make: Unclosed substitution for VAR (, missing)
+VAR:S,V,v=
+exit status 0

Added: vendor/NetBSD/bmake/dist/unit-tests/moderrs.mk
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/moderrs.mk	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/moderrs.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,31 @@
+# $Id: moderrs.mk,v 1.1.1.1 2014/08/30 18:57:18 sjg Exp $
+#
+# various modifier error tests
+
+VAR=TheVariable
+# incase we have to change it ;-)
+MOD_UNKN=Z
+MOD_TERM=S,V,v
+MOD_S:= ${MOD_TERM},
+
+all:	modunkn modunknV varterm vartermV modtermV
+
+modunkn:
+	@echo "Expect: Unknown modifier 'Z'"
+	@echo "VAR:Z=${VAR:Z}"
+
+modunknV:
+	@echo "Expect: Unknown modifier 'Z'"
+	@echo "VAR:${MOD_UNKN}=${VAR:${MOD_UNKN}}"
+
+varterm:
+	@echo "Expect: Unclosed variable specification for VAR"
+	@echo VAR:S,V,v,=${VAR:S,V,v,
+
+vartermV:
+	@echo "Expect: Unclosed variable specification for VAR"
+	@echo VAR:${MOD_TERM},=${VAR:${MOD_S}
+
+modtermV:
+	@echo "Expect: Unclosed substitution for VAR (, missing)"
+	- at echo "VAR:${MOD_TERM}=${VAR:${MOD_TERM}}"

Deleted: vendor/NetBSD/bmake/dist/unit-tests/modmatch
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/modmatch	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/unit-tests/modmatch	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,25 +0,0 @@
-
-X=a b c d e
-
-.for x in $X
-LIB${x:tu}=/tmp/lib$x.a
-.endfor
-
-X_LIBS= ${LIBA} ${LIBD} ${LIBE}
-
-LIB?=a
-
-var = head
-res = no
-.if !empty(var:M${:Uhead\:tail:C/:.*//})
-res = OK
-.endif
-
-all:
-	@for x in $X; do ${.MAKE} -f ${MAKEFILE} show LIB=$$x; done
-	@echo "Mscanner=${res}"
-
-show:
-	@echo 'LIB=${LIB} X_LIBS:M$${LIB$${LIB:tu}} is "${X_LIBS:M${LIB${LIB:tu}}}"'
-	@echo 'LIB=${LIB} X_LIBS:M*/lib$${LIB}.a is "${X_LIBS:M*/lib${LIB}.a}"'
-	@echo 'LIB=${LIB} X_LIBS:M*/lib$${LIB}.a:tu is "${X_LIBS:M*/lib${LIB}.a:tu}"'

Added: vendor/NetBSD/bmake/dist/unit-tests/modmatch.exp
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/modmatch.exp	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/modmatch.exp	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,20 @@
+LIB=a X_LIBS:M${LIB${LIB:tu}} is "/tmp/liba.a"
+LIB=a X_LIBS:M*/lib${LIB}.a is "/tmp/liba.a"
+LIB=a X_LIBS:M*/lib${LIB}.a:tu is "/TMP/LIBA.A"
+LIB=b X_LIBS:M${LIB${LIB:tu}} is ""
+LIB=b X_LIBS:M*/lib${LIB}.a is ""
+LIB=b X_LIBS:M*/lib${LIB}.a:tu is ""
+LIB=c X_LIBS:M${LIB${LIB:tu}} is ""
+LIB=c X_LIBS:M*/lib${LIB}.a is ""
+LIB=c X_LIBS:M*/lib${LIB}.a:tu is ""
+LIB=d X_LIBS:M${LIB${LIB:tu}} is "/tmp/libd.a"
+LIB=d X_LIBS:M*/lib${LIB}.a is "/tmp/libd.a"
+LIB=d X_LIBS:M*/lib${LIB}.a:tu is "/TMP/LIBD.A"
+LIB=e X_LIBS:M${LIB${LIB:tu}} is "/tmp/libe.a"
+LIB=e X_LIBS:M*/lib${LIB}.a is "/tmp/libe.a"
+LIB=e X_LIBS:M*/lib${LIB}.a:tu is "/TMP/LIBE.A"
+Mscanner=OK
+Upper=One Two Three Four
+Lower=five six seven
+nose=One Three five
+exit status 0

Added: vendor/NetBSD/bmake/dist/unit-tests/modmatch.mk
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/modmatch.mk	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/modmatch.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,34 @@
+
+X=a b c d e
+
+.for x in $X
+LIB${x:tu}=/tmp/lib$x.a
+.endfor
+
+X_LIBS= ${LIBA} ${LIBD} ${LIBE}
+
+LIB?=a
+
+var = head
+res = no
+.if !empty(var:M${:Uhead\:tail:C/:.*//})
+res = OK
+.endif
+
+all:	show-libs check-cclass
+
+show-libs:
+	@for x in $X; do ${.MAKE} -f ${MAKEFILE} show LIB=$$x; done
+	@echo "Mscanner=${res}"
+
+show:
+	@echo 'LIB=${LIB} X_LIBS:M$${LIB$${LIB:tu}} is "${X_LIBS:M${LIB${LIB:tu}}}"'
+	@echo 'LIB=${LIB} X_LIBS:M*/lib$${LIB}.a is "${X_LIBS:M*/lib${LIB}.a}"'
+	@echo 'LIB=${LIB} X_LIBS:M*/lib$${LIB}.a:tu is "${X_LIBS:M*/lib${LIB}.a:tu}"'
+
+LIST= One Two Three Four five six seven
+
+check-cclass:
+	@echo Upper=${LIST:M[A-Z]*}
+	@echo Lower=${LIST:M[^A-Z]*}
+	@echo nose=${LIST:M[^s]*[ex]}

Deleted: vendor/NetBSD/bmake/dist/unit-tests/modmisc
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/modmisc	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/unit-tests/modmisc	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,38 +0,0 @@
-# $Id: modmisc,v 1.1.1.5 2011/04/11 15:10:32 sjg Exp $
-#
-# miscellaneous modifier tests
-
-# do not put any dirs in this list which exist on some
-# but not all target systems - an exists() check is below.
-path=:/bin:/tmp::/:.:/no/such/dir:.
-# strip cwd from path.
-MOD_NODOT=S/:/ /g:N.:ts:
-# and decorate, note that $'s need to be doubled. Also note that 
-# the modifier_variable can be used with other modifiers.
-MOD_NODOTX=S/:/ /g:N.:@d@'$$d'@
-# another mod - pretend it is more interesting
-MOD_HOMES=S,/home/,/homes/,
-MOD_OPT=@d@$${exists($$d):?$$d:$${d:S,/usr,/opt,}}@
-MOD_SEP=S,:, ,g
-
-all:	modvar modvarloop modsysv
-
-modsysv:
-	@echo "The answer is ${libfoo.a:L:libfoo.a=42}"
-
-modvar:
-	@echo "path='${path}'"
-	@echo "path='${path:${MOD_NODOT}}'"
-	@echo "path='${path:S,home,homes,:${MOD_NODOT}}'"
-	@echo "path=${path:${MOD_NODOTX}:ts:}"
-	@echo "path=${path:${MOD_HOMES}:${MOD_NODOTX}:ts:}"
-
-.for d in ${path:${MOD_SEP}:N.} /usr/xbin
-path_$d?= ${d:${MOD_OPT}:${MOD_HOMES}}/
-paths+= ${d:${MOD_OPT}:${MOD_HOMES}}
-.endfor
-
-modvarloop:
-	@echo "path_/usr/xbin=${path_/usr/xbin}"
-	@echo "paths=${paths}"
-	@echo "PATHS=${paths:tu}"

Added: vendor/NetBSD/bmake/dist/unit-tests/modmisc.exp
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/modmisc.exp	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/modmisc.exp	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,10 @@
+path=':/bin:/tmp::/:.:/no/such/dir:.'
+path='/bin:/tmp:/:/no/such/dir'
+path='/bin:/tmp:/:/no/such/dir'
+path='/bin':'/tmp':'/':'/no/such/dir'
+path='/bin':'/tmp':'/':'/no/such/dir'
+path_/usr/xbin=/opt/xbin/
+paths=/bin /tmp / /no/such/dir /opt/xbin
+PATHS=/BIN /TMP / /NO/SUCH/DIR /OPT/XBIN
+The answer is 42
+exit status 0

Added: vendor/NetBSD/bmake/dist/unit-tests/modmisc.mk
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/modmisc.mk	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/modmisc.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,38 @@
+# $Id: modmisc.mk,v 1.1.1.1 2014/08/30 18:57:18 sjg Exp $
+#
+# miscellaneous modifier tests
+
+# do not put any dirs in this list which exist on some
+# but not all target systems - an exists() check is below.
+path=:/bin:/tmp::/:.:/no/such/dir:.
+# strip cwd from path.
+MOD_NODOT=S/:/ /g:N.:ts:
+# and decorate, note that $'s need to be doubled. Also note that 
+# the modifier_variable can be used with other modifiers.
+MOD_NODOTX=S/:/ /g:N.:@d@'$$d'@
+# another mod - pretend it is more interesting
+MOD_HOMES=S,/home/,/homes/,
+MOD_OPT=@d@$${exists($$d):?$$d:$${d:S,/usr,/opt,}}@
+MOD_SEP=S,:, ,g
+
+all:	modvar modvarloop modsysv
+
+modsysv:
+	@echo "The answer is ${libfoo.a:L:libfoo.a=42}"
+
+modvar:
+	@echo "path='${path}'"
+	@echo "path='${path:${MOD_NODOT}}'"
+	@echo "path='${path:S,home,homes,:${MOD_NODOT}}'"
+	@echo "path=${path:${MOD_NODOTX}:ts:}"
+	@echo "path=${path:${MOD_HOMES}:${MOD_NODOTX}:ts:}"
+
+.for d in ${path:${MOD_SEP}:N.} /usr/xbin
+path_$d?= ${d:${MOD_OPT}:${MOD_HOMES}}/
+paths+= ${d:${MOD_OPT}:${MOD_HOMES}}
+.endfor
+
+modvarloop:
+	@echo "path_/usr/xbin=${path_/usr/xbin}"
+	@echo "paths=${paths}"
+	@echo "PATHS=${paths:tu}"

Deleted: vendor/NetBSD/bmake/dist/unit-tests/modorder
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/modorder	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/unit-tests/modorder	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,22 +0,0 @@
-# $NetBSD: modorder,v 1.2 2007/10/05 15:27:46 sjg Exp $
-
-LIST=		one two three four five six seven eight nine ten
-LISTX=		${LIST:Ox}
-LISTSX:=	${LIST:Ox}
-TEST_RESULT= && echo Ok || echo Failed
-
-# unit-tests have to produce the same results on each run
-# so we cannot actually include :Ox output.
-all:
-	@echo "LIST      = ${LIST}"
-	@echo "LIST:O    = ${LIST:O}"
-	# Note that 1 in every 10! trials two independently generated
-	# randomized orderings will be the same.  The test framework doesn't
-	# support checking probabilistic output, so we accept that the test
-	# will incorrectly fail with probability 2.8E-7.
-	@echo "LIST:Ox   = `test '${LIST:Ox}' != '${LIST:Ox}' ${TEST_RESULT}`"
-	@echo "LIST:O:Ox = `test '${LIST:O:Ox}' != '${LIST:O:Ox}' ${TEST_RESULT}`"
-	@echo "LISTX     = `test '${LISTX}' != '${LISTX}' ${TEST_RESULT}`"
-	@echo "LISTSX    = `test '${LISTSX}' = '${LISTSX}' ${TEST_RESULT}`"
-	@echo "BADMOD 1  = ${LIST:OX}"
-	@echo "BADMOD 2  = ${LIST:OxXX}"

Added: vendor/NetBSD/bmake/dist/unit-tests/modorder.exp
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/modorder.exp	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/modorder.exp	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,11 @@
+LIST      = one two three four five six seven eight nine ten
+LIST:O    = eight five four nine one seven six ten three two
+LIST:Ox   = Ok
+LIST:O:Ox = Ok
+LISTX     = Ok
+LISTSX    = Ok
+make: Bad modifier `:OX' for LIST
+BADMOD 1  = }
+make: Bad modifier `:OxXX' for LIST
+BADMOD 2  = XX}
+exit status 0

Added: vendor/NetBSD/bmake/dist/unit-tests/modorder.mk
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/modorder.mk	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/modorder.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,22 @@
+# $NetBSD: modorder.mk,v 1.1 2014/08/21 13:44:51 apb Exp $
+
+LIST=		one two three four five six seven eight nine ten
+LISTX=		${LIST:Ox}
+LISTSX:=	${LIST:Ox}
+TEST_RESULT= && echo Ok || echo Failed
+
+# unit-tests have to produce the same results on each run
+# so we cannot actually include :Ox output.
+all:
+	@echo "LIST      = ${LIST}"
+	@echo "LIST:O    = ${LIST:O}"
+	# Note that 1 in every 10! trials two independently generated
+	# randomized orderings will be the same.  The test framework doesn't
+	# support checking probabilistic output, so we accept that the test
+	# will incorrectly fail with probability 2.8E-7.
+	@echo "LIST:Ox   = `test '${LIST:Ox}' != '${LIST:Ox}' ${TEST_RESULT}`"
+	@echo "LIST:O:Ox = `test '${LIST:O:Ox}' != '${LIST:O:Ox}' ${TEST_RESULT}`"
+	@echo "LISTX     = `test '${LISTX}' != '${LISTX}' ${TEST_RESULT}`"
+	@echo "LISTSX    = `test '${LISTSX}' = '${LISTSX}' ${TEST_RESULT}`"
+	@echo "BADMOD 1  = ${LIST:OX}"
+	@echo "BADMOD 2  = ${LIST:OxXX}"

Deleted: vendor/NetBSD/bmake/dist/unit-tests/modts
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/modts	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/unit-tests/modts	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,43 +0,0 @@
-
-LIST= one two three
-LIST+= four five six
-
-FU_mod-ts = a / b / cool
-
-AAA= a a a
-B.aaa= Baaa
-
-all:   mod-ts
-
-# Use print or printf iff they are builtin.
-# XXX note that this causes problems, when make decides 
-# there is no need to use a shell, so avoid where possible.
-.if ${type print 2> /dev/null || echo:L:sh:Mbuiltin} != ""
-PRINT= print -r --
-.elif ${type printf 2> /dev/null || echo:L:sh:Mbuiltin} != ""
-PRINT= printf '%s\n'
-.else
-PRINT= echo
-.endif
-
-mod-ts:
-	@echo 'LIST="${LIST}"'
-	@echo 'LIST:ts,="${LIST:ts,}"'
-	@echo 'LIST:ts/:tu="${LIST:ts/:tu}"'
-	@echo 'LIST:ts::tu="${LIST:ts::tu}"'
-	@echo 'LIST:ts:tu="${LIST:ts:tu}"'
-	@echo 'LIST:tu:ts/="${LIST:tu:ts/}"'
-	@echo 'LIST:ts:="${LIST:ts:}"'
-	@echo 'LIST:ts="${LIST:ts}"'
-	@echo 'LIST:ts:S/two/2/="${LIST:ts:S/two/2/}"'
-	@echo 'LIST:S/two/2/:ts="${LIST:S/two/2/:ts}"'
-	@echo 'LIST:ts/:S/two/2/="${LIST:ts/:S/two/2/}"'
-	@echo "Pretend the '/' in '/n' etc. below are back-slashes."
-	@${PRINT} 'LIST:ts/n="${LIST:ts\n}"'
-	@${PRINT} 'LIST:ts/t="${LIST:ts\t}"'
-	@${PRINT} 'LIST:ts/012:tu="${LIST:ts\012:tu}"'
-	@${PRINT} 'LIST:tx="${LIST:tx}"'
-	@${PRINT} 'LIST:ts/x:tu="${LIST:ts\x:tu}"'
-	@${PRINT} 'FU_$@="${FU_${@:ts}:ts}"'
-	@${PRINT} 'FU_$@:ts:T="${FU_${@:ts}:ts:T}" == cool?'
-	@${PRINT} 'B.$${AAA:ts}="${B.${AAA:ts}}" == Baaa?'

Added: vendor/NetBSD/bmake/dist/unit-tests/modts.exp
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/modts.exp	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/modts.exp	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,39 @@
+LIST="one two three four five six"
+LIST:ts,="one,two,three,four,five,six"
+LIST:ts/:tu="ONE/TWO/THREE/FOUR/FIVE/SIX"
+LIST:ts::tu="ONE:TWO:THREE:FOUR:FIVE:SIX"
+LIST:ts:tu="ONETWOTHREEFOURFIVESIX"
+LIST:tu:ts/="ONE/TWO/THREE/FOUR/FIVE/SIX"
+LIST:ts:="one:two:three:four:five:six"
+LIST:ts="onetwothreefourfivesix"
+LIST:ts:S/two/2/="one2threefourfivesix"
+LIST:S/two/2/:ts="one2threefourfivesix"
+LIST:ts/:S/two/2/="one/2/three/four/five/six"
+Pretend the '/' in '/n' etc. below are back-slashes.
+LIST:ts/n="one
+two
+three
+four
+five
+six"
+LIST:ts/t="one	two	three	four	five	six"
+LIST:ts/012:tu="ONE
+TWO
+THREE
+FOUR
+FIVE
+SIX"
+LIST:ts/xa:tu="ONE
+TWO
+THREE
+FOUR
+FIVE
+SIX"
+make: Bad modifier `:tx' for LIST
+LIST:tx="}"
+make: Bad modifier `:ts\X' for LIST
+LIST:ts/x:tu="\X:tu}"
+FU_mod-ts="a/b/cool"
+FU_mod-ts:ts:T="cool" == cool?
+B.${AAA:ts}="Baaa" == Baaa?
+exit status 0

Added: vendor/NetBSD/bmake/dist/unit-tests/modts.mk
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/modts.mk	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/modts.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,44 @@
+
+LIST= one two three
+LIST+= four five six
+
+FU_mod-ts = a / b / cool
+
+AAA= a a a
+B.aaa= Baaa
+
+all:   mod-ts
+
+# Use print or printf iff they are builtin.
+# XXX note that this causes problems, when make decides 
+# there is no need to use a shell, so avoid where possible.
+.if ${(type print) 2> /dev/null || echo:L:sh:Mbuiltin} != ""
+PRINT= print -r --
+.elif ${(type printf) 2> /dev/null || echo:L:sh:Mbuiltin} != ""
+PRINT= printf '%s\n'
+.else
+PRINT= echo
+.endif
+
+mod-ts:
+	@echo 'LIST="${LIST}"'
+	@echo 'LIST:ts,="${LIST:ts,}"'
+	@echo 'LIST:ts/:tu="${LIST:ts/:tu}"'
+	@echo 'LIST:ts::tu="${LIST:ts::tu}"'
+	@echo 'LIST:ts:tu="${LIST:ts:tu}"'
+	@echo 'LIST:tu:ts/="${LIST:tu:ts/}"'
+	@echo 'LIST:ts:="${LIST:ts:}"'
+	@echo 'LIST:ts="${LIST:ts}"'
+	@echo 'LIST:ts:S/two/2/="${LIST:ts:S/two/2/}"'
+	@echo 'LIST:S/two/2/:ts="${LIST:S/two/2/:ts}"'
+	@echo 'LIST:ts/:S/two/2/="${LIST:ts/:S/two/2/}"'
+	@echo "Pretend the '/' in '/n' etc. below are back-slashes."
+	@${PRINT} 'LIST:ts/n="${LIST:ts\n}"'
+	@${PRINT} 'LIST:ts/t="${LIST:ts\t}"'
+	@${PRINT} 'LIST:ts/012:tu="${LIST:ts\012:tu}"'
+	@${PRINT} 'LIST:ts/xa:tu="${LIST:ts\xa:tu}"'
+	@${PRINT} 'LIST:tx="${LIST:tx}"'
+	@${PRINT} 'LIST:ts/x:tu="${LIST:ts\X:tu}"'
+	@${PRINT} 'FU_$@="${FU_${@:ts}:ts}"'
+	@${PRINT} 'FU_$@:ts:T="${FU_${@:ts}:ts:T}" == cool?'
+	@${PRINT} 'B.$${AAA:ts}="${B.${AAA:ts}}" == Baaa?'

Deleted: vendor/NetBSD/bmake/dist/unit-tests/modword
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/modword	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/unit-tests/modword	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,151 +0,0 @@
-# $Id: modword,v 1.1.1.1 2003/09/28 17:01:48 sjg Exp $
-#
-# Test behaviour of new :[] modifier
-
-all: mod-squarebrackets mod-S-W mod-C-W mod-tW-tw
-
-LIST= one two three
-LIST+= four five six
-LONGLIST= 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
-
-EMPTY= # the space should be ignored
-ESCAPEDSPACE=\ # escaped space before the '#'
-REALLYSPACE:=${EMPTY:C/^/ /W}
-HASH= \#
-AT= @
-STAR= *
-ZERO= 0
-ONE= 1
-MINUSONE= -1
-
-mod-squarebrackets: mod-squarebrackets-0-star-at \
-	mod-squarebrackets-hash \
-	mod-squarebrackets-n \
-	mod-squarebrackets-start-end \
-	mod-squarebrackets-nested
-
-mod-squarebrackets-0-star-at:
-	@echo 'LIST:[]="${LIST:[]}" is an error'
-	@echo 'LIST:[0]="${LIST:[0]}"'
-	@echo 'LIST:[0x0]="${LIST:[0x0]}"'
-	@echo 'LIST:[000]="${LIST:[000]}"'
-	@echo 'LIST:[*]="${LIST:[*]}"'
-	@echo 'LIST:[@]="${LIST:[@]}"'
-	@echo 'LIST:[0]:C/ /,/="${LIST:[0]:C/ /,/}"'
-	@echo 'LIST:[0]:C/ /,/g="${LIST:[0]:C/ /,/g}"'
-	@echo 'LIST:[0]:C/ /,/1g="${LIST:[0]:C/ /,/1g}"'
-	@echo 'LIST:[*]:C/ /,/="${LIST:[*]:C/ /,/}"'
-	@echo 'LIST:[*]:C/ /,/g="${LIST:[*]:C/ /,/g}"'
-	@echo 'LIST:[*]:C/ /,/1g="${LIST:[*]:C/ /,/1g}"'
-	@echo 'LIST:[@]:C/ /,/="${LIST:[@]:C/ /,/}"'
-	@echo 'LIST:[@]:C/ /,/g="${LIST:[@]:C/ /,/g}"'
-	@echo 'LIST:[@]:C/ /,/1g="${LIST:[@]:C/ /,/1g}"'
-	@echo 'LIST:[@]:[0]:C/ /,/="${LIST:[@]:[0]:C/ /,/}"'
-	@echo 'LIST:[0]:[@]:C/ /,/="${LIST:[0]:[@]:C/ /,/}"'
-	@echo 'LIST:[@]:[*]:C/ /,/="${LIST:[@]:[*]:C/ /,/}"'
-	@echo 'LIST:[*]:[@]:C/ /,/="${LIST:[*]:[@]:C/ /,/}"'
-
-mod-squarebrackets-hash:
-	@echo 'EMPTY="${EMPTY}"'
-	@echo 'EMPTY:[#]="${EMPTY:[#]}" == 1 ?'
-	@echo 'ESCAPEDSPACE="${ESCAPEDSPACE}"'
-	@echo 'ESCAPEDSPACE:[#]="${ESCAPEDSPACE:[#]}" == 1 ?'
-	@echo 'REALLYSPACE="${REALLYSPACE}"'
-	@echo 'REALLYSPACE:[#]="${REALLYSPACE:[#]}" == 1 ?'
-	@echo 'LIST:[#]="${LIST:[#]}"'
-	@echo 'LIST:[0]:[#]="${LIST:[0]:[#]}" == 1 ?'
-	@echo 'LIST:[*]:[#]="${LIST:[*]:[#]}" == 1 ?'
-	@echo 'LIST:[@]:[#]="${LIST:[@]:[#]}"'
-	@echo 'LIST:[1]:[#]="${LIST:[1]:[#]}"'
-	@echo 'LIST:[1..3]:[#]="${LIST:[1..3]:[#]}"'
-
-mod-squarebrackets-n:
-	@echo 'EMPTY:[1]="${EMPTY:[1]}"'
-	@echo 'ESCAPEDSPACE="${ESCAPEDSPACE}"'
-	@echo 'ESCAPEDSPACE:[1]="${ESCAPEDSPACE:[1]}"'
-	@echo 'REALLYSPACE="${REALLYSPACE}"'
-	@echo 'REALLYSPACE:[1]="${REALLYSPACE:[1]}" == "" ?'
-	@echo 'REALLYSPACE:[*]:[1]="${REALLYSPACE:[*]:[1]}" == " " ?'
-	@echo 'LIST:[1]="${LIST:[1]}"'
-	@echo 'LIST:[1.]="${LIST:[1.]}" is an error'
-	@echo 'LIST:[1].="${LIST:[1].}" is an error'
-	@echo 'LIST:[2]="${LIST:[2]}"'
-	@echo 'LIST:[6]="${LIST:[6]}"'
-	@echo 'LIST:[7]="${LIST:[7]}"'
-	@echo 'LIST:[999]="${LIST:[999]}"'
-	@echo 'LIST:[-]="${LIST:[-]}" is an error'
-	@echo 'LIST:[--]="${LIST:[--]}" is an error'
-	@echo 'LIST:[-1]="${LIST:[-1]}"'
-	@echo 'LIST:[-2]="${LIST:[-2]}"'
-	@echo 'LIST:[-6]="${LIST:[-6]}"'
-	@echo 'LIST:[-7]="${LIST:[-7]}"'
-	@echo 'LIST:[-999]="${LIST:[-999]}"'
-	@echo 'LONGLIST:[17]="${LONGLIST:[17]}"'
-	@echo 'LONGLIST:[0x11]="${LONGLIST:[0x11]}"'
-	@echo 'LONGLIST:[021]="${LONGLIST:[021]}"'
-	@echo 'LIST:[0]:[1]="${LIST:[0]:[1]}"'
-	@echo 'LIST:[*]:[1]="${LIST:[*]:[1]}"'
-	@echo 'LIST:[@]:[1]="${LIST:[@]:[1]}"'
-	@echo 'LIST:[0]:[2]="${LIST:[0]:[2]}"'
-	@echo 'LIST:[*]:[2]="${LIST:[*]:[2]}"'
-	@echo 'LIST:[@]:[2]="${LIST:[@]:[2]}"'
-	@echo 'LIST:[*]:C/ /,/:[2]="${LIST:[*]:C/ /,/:[2]}"'
-	@echo 'LIST:[*]:C/ /,/:[*]:[2]="${LIST:[*]:C/ /,/:[*]:[2]}"'
-	@echo 'LIST:[*]:C/ /,/:[@]:[2]="${LIST:[*]:C/ /,/:[@]:[2]}"'
-
-mod-squarebrackets-start-end:
-	@echo 'LIST:[1.]="${LIST:[1.]}" is an error'
-	@echo 'LIST:[1..]="${LIST:[1..]}" is an error'
-	@echo 'LIST:[1..1]="${LIST:[1..1]}"'
-	@echo 'LIST:[1..1.]="${LIST:[1..1.]}" is an error'
-	@echo 'LIST:[1..2]="${LIST:[1..2]}"'
-	@echo 'LIST:[2..1]="${LIST:[2..1]}"'
-	@echo 'LIST:[3..-2]="${LIST:[3..-2]}"'
-	@echo 'LIST:[-4..4]="${LIST:[-4..4]}"'
-	@echo 'LIST:[0..1]="${LIST:[0..1]}" is an error'
-	@echo 'LIST:[-1..0]="${LIST:[-1..0]}" is an error'
-	@echo 'LIST:[-1..1]="${LIST:[-1..1]}"'
-	@echo 'LIST:[0..0]="${LIST:[0..0]}"'
-	@echo 'LIST:[3..99]="${LIST:[3..99]}"'
-	@echo 'LIST:[-3..-99]="${LIST:[-3..-99]}"'
-	@echo 'LIST:[-99..-3]="${LIST:[-99..-3]}"'
-
-mod-squarebrackets-nested:
-	@echo 'HASH="${HASH}" == "#" ?'
-	@echo 'LIST:[$${HASH}]="${LIST:[${HASH}]}"'
-	@echo 'LIST:[$${ZERO}]="${LIST:[${ZERO}]}"'
-	@echo 'LIST:[$${ZERO}x$${ONE}]="${LIST:[${ZERO}x${ONE}]}"'
-	@echo 'LIST:[$${ONE}]="${LIST:[${ONE}]}"'
-	@echo 'LIST:[$${MINUSONE}]="${LIST:[${MINUSONE}]}"'
-	@echo 'LIST:[$${STAR}]="${LIST:[${STAR}]}"'
-	@echo 'LIST:[$${AT}]="${LIST:[${AT}]}"'
-	@echo 'LIST:[$${EMPTY}]="${LIST:[${EMPTY}]}" is an error'
-	@echo 'LIST:[$${LONGLIST:[21]:S/2//}]="${LIST:[${LONGLIST:[21]:S/2//}]}"'
-	@echo 'LIST:[$${LIST:[#]}]="${LIST:[${LIST:[#]}]}"'
-	@echo 'LIST:[$${LIST:[$${HASH}]}]="${LIST:[${LIST:[${HASH}]}]}"'
-
-mod-C-W:
-	@echo 'LIST:C/ /,/="${LIST:C/ /,/}"'
-	@echo 'LIST:C/ /,/W="${LIST:C/ /,/W}"'
-	@echo 'LIST:C/ /,/gW="${LIST:C/ /,/gW}"'
-	@echo 'EMPTY:C/^/,/="${EMPTY:C/^/,/}"'
-	@echo 'EMPTY:C/^/,/W="${EMPTY:C/^/,/W}"'
-
-mod-S-W:
-	@echo 'LIST:S/ /,/="${LIST:S/ /,/}"'
-	@echo 'LIST:S/ /,/W="${LIST:S/ /,/W}"'
-	@echo 'LIST:S/ /,/gW="${LIST:S/ /,/gW}"'
-	@echo 'EMPTY:S/^/,/="${EMPTY:S/^/,/}"'
-	@echo 'EMPTY:S/^/,/W="${EMPTY:S/^/,/W}"'
-
-mod-tW-tw:
-	@echo 'LIST:tW="${LIST:tW}"'
-	@echo 'LIST:tw="${LIST:tw}"'
-	@echo 'LIST:tW:C/ /,/="${LIST:tW:C/ /,/}"'
-	@echo 'LIST:tW:C/ /,/g="${LIST:tW:C/ /,/g}"'
-	@echo 'LIST:tW:C/ /,/1g="${LIST:tW:C/ /,/1g}"'
-	@echo 'LIST:tw:C/ /,/="${LIST:tw:C/ /,/}"'
-	@echo 'LIST:tw:C/ /,/g="${LIST:tw:C/ /,/g}"'
-	@echo 'LIST:tw:C/ /,/1g="${LIST:tw:C/ /,/1g}"'
-	@echo 'LIST:tw:tW:C/ /,/="${LIST:tw:tW:C/ /,/}"'
-	@echo 'LIST:tW:tw:C/ /,/="${LIST:tW:tw:C/ /,/}"'

Added: vendor/NetBSD/bmake/dist/unit-tests/modword.exp
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/modword.exp	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/modword.exp	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,122 @@
+make: Bad modifier `:[]' for LIST
+LIST:[]="" is an error
+LIST:[0]="one two three four five six"
+LIST:[0x0]="one two three four five six"
+LIST:[000]="one two three four five six"
+LIST:[*]="one two three four five six"
+LIST:[@]="one two three four five six"
+LIST:[0]:C/ /,/="one,two three four five six"
+LIST:[0]:C/ /,/g="one,two,three,four,five,six"
+LIST:[0]:C/ /,/1g="one,two,three,four,five,six"
+LIST:[*]:C/ /,/="one,two three four five six"
+LIST:[*]:C/ /,/g="one,two,three,four,five,six"
+LIST:[*]:C/ /,/1g="one,two,three,four,five,six"
+LIST:[@]:C/ /,/="one two three four five six"
+LIST:[@]:C/ /,/g="one two three four five six"
+LIST:[@]:C/ /,/1g="one two three four five six"
+LIST:[@]:[0]:C/ /,/="one,two three four five six"
+LIST:[0]:[@]:C/ /,/="one two three four five six"
+LIST:[@]:[*]:C/ /,/="one,two three four five six"
+LIST:[*]:[@]:C/ /,/="one two three four five six"
+EMPTY=""
+EMPTY:[#]="1" == 1 ?
+ESCAPEDSPACE="\ "
+ESCAPEDSPACE:[#]="1" == 1 ?
+REALLYSPACE=" "
+REALLYSPACE:[#]="1" == 1 ?
+LIST:[#]="6"
+LIST:[0]:[#]="1" == 1 ?
+LIST:[*]:[#]="1" == 1 ?
+LIST:[@]:[#]="6"
+LIST:[1]:[#]="1"
+LIST:[1..3]:[#]="3"
+EMPTY:[1]=""
+ESCAPEDSPACE="\ "
+ESCAPEDSPACE:[1]="\ "
+REALLYSPACE=" "
+REALLYSPACE:[1]="" == "" ?
+REALLYSPACE:[*]:[1]=" " == " " ?
+LIST:[1]="one"
+make: Bad modifier `:[1.]' for LIST
+LIST:[1.]="" is an error
+make: Bad modifier `:[1].' for LIST
+LIST:[1].="}" is an error
+LIST:[2]="two"
+LIST:[6]="six"
+LIST:[7]=""
+LIST:[999]=""
+make: Bad modifier `:[-]' for LIST
+LIST:[-]="" is an error
+make: Bad modifier `:[--]' for LIST
+LIST:[--]="" is an error
+LIST:[-1]="six"
+LIST:[-2]="five"
+LIST:[-6]="one"
+LIST:[-7]=""
+LIST:[-999]=""
+LONGLIST:[17]="17"
+LONGLIST:[0x11]="17"
+LONGLIST:[021]="17"
+LIST:[0]:[1]="one two three four five six"
+LIST:[*]:[1]="one two three four five six"
+LIST:[@]:[1]="one"
+LIST:[0]:[2]=""
+LIST:[*]:[2]=""
+LIST:[@]:[2]="two"
+LIST:[*]:C/ /,/:[2]=""
+LIST:[*]:C/ /,/:[*]:[2]=""
+LIST:[*]:C/ /,/:[@]:[2]="three"
+make: Bad modifier `:[1.]' for LIST
+LIST:[1.]="" is an error
+make: Bad modifier `:[1..]' for LIST
+LIST:[1..]="" is an error
+LIST:[1..1]="one"
+make: Bad modifier `:[1..1.]' for LIST
+LIST:[1..1.]="" is an error
+LIST:[1..2]="one two"
+LIST:[2..1]="two one"
+LIST:[3..-2]="three four five"
+LIST:[-4..4]="three four"
+make: Bad modifier `:[0..1]' for LIST
+LIST:[0..1]="" is an error
+make: Bad modifier `:[-1..0]' for LIST
+LIST:[-1..0]="" is an error
+LIST:[-1..1]="six five four three two one"
+LIST:[0..0]="one two three four five six"
+LIST:[3..99]="three four five six"
+LIST:[-3..-99]="four three two one"
+LIST:[-99..-3]="one two three four"
+HASH="#" == "#" ?
+LIST:[${HASH}]="6"
+LIST:[${ZERO}]="one two three four five six"
+LIST:[${ZERO}x${ONE}]="one"
+LIST:[${ONE}]="one"
+LIST:[${MINUSONE}]="six"
+LIST:[${STAR}]="one two three four five six"
+LIST:[${AT}]="one two three four five six"
+make: Bad modifier `:[${EMPTY' for LIST
+LIST:[${EMPTY}]="" is an error
+LIST:[${LONGLIST:[21]:S/2//}]="one"
+LIST:[${LIST:[#]}]="six"
+LIST:[${LIST:[${HASH}]}]="six"
+LIST:S/ /,/="one two three four five six"
+LIST:S/ /,/W="one,two three four five six"
+LIST:S/ /,/gW="one,two,three,four,five,six"
+EMPTY:S/^/,/=","
+EMPTY:S/^/,/W=","
+LIST:C/ /,/="one two three four five six"
+LIST:C/ /,/W="one,two three four five six"
+LIST:C/ /,/gW="one,two,three,four,five,six"
+EMPTY:C/^/,/=","
+EMPTY:C/^/,/W=","
+LIST:tW="one two three four five six"
+LIST:tw="one two three four five six"
+LIST:tW:C/ /,/="one,two three four five six"
+LIST:tW:C/ /,/g="one,two,three,four,five,six"
+LIST:tW:C/ /,/1g="one,two,three,four,five,six"
+LIST:tw:C/ /,/="one two three four five six"
+LIST:tw:C/ /,/g="one two three four five six"
+LIST:tw:C/ /,/1g="one two three four five six"
+LIST:tw:tW:C/ /,/="one,two three four five six"
+LIST:tW:tw:C/ /,/="one two three four five six"
+exit status 0

Added: vendor/NetBSD/bmake/dist/unit-tests/modword.mk
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/modword.mk	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/modword.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,151 @@
+# $Id: modword.mk,v 1.1.1.1 2014/08/30 18:57:18 sjg Exp $
+#
+# Test behaviour of new :[] modifier
+
+all: mod-squarebrackets mod-S-W mod-C-W mod-tW-tw
+
+LIST= one two three
+LIST+= four five six
+LONGLIST= 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
+
+EMPTY= # the space should be ignored
+ESCAPEDSPACE=\ # escaped space before the '#'
+REALLYSPACE:=${EMPTY:C/^/ /W}
+HASH= \#
+AT= @
+STAR= *
+ZERO= 0
+ONE= 1
+MINUSONE= -1
+
+mod-squarebrackets: mod-squarebrackets-0-star-at \
+	mod-squarebrackets-hash \
+	mod-squarebrackets-n \
+	mod-squarebrackets-start-end \
+	mod-squarebrackets-nested
+
+mod-squarebrackets-0-star-at:
+	@echo 'LIST:[]="${LIST:[]}" is an error'
+	@echo 'LIST:[0]="${LIST:[0]}"'
+	@echo 'LIST:[0x0]="${LIST:[0x0]}"'
+	@echo 'LIST:[000]="${LIST:[000]}"'
+	@echo 'LIST:[*]="${LIST:[*]}"'
+	@echo 'LIST:[@]="${LIST:[@]}"'
+	@echo 'LIST:[0]:C/ /,/="${LIST:[0]:C/ /,/}"'
+	@echo 'LIST:[0]:C/ /,/g="${LIST:[0]:C/ /,/g}"'
+	@echo 'LIST:[0]:C/ /,/1g="${LIST:[0]:C/ /,/1g}"'
+	@echo 'LIST:[*]:C/ /,/="${LIST:[*]:C/ /,/}"'
+	@echo 'LIST:[*]:C/ /,/g="${LIST:[*]:C/ /,/g}"'
+	@echo 'LIST:[*]:C/ /,/1g="${LIST:[*]:C/ /,/1g}"'
+	@echo 'LIST:[@]:C/ /,/="${LIST:[@]:C/ /,/}"'
+	@echo 'LIST:[@]:C/ /,/g="${LIST:[@]:C/ /,/g}"'
+	@echo 'LIST:[@]:C/ /,/1g="${LIST:[@]:C/ /,/1g}"'
+	@echo 'LIST:[@]:[0]:C/ /,/="${LIST:[@]:[0]:C/ /,/}"'
+	@echo 'LIST:[0]:[@]:C/ /,/="${LIST:[0]:[@]:C/ /,/}"'
+	@echo 'LIST:[@]:[*]:C/ /,/="${LIST:[@]:[*]:C/ /,/}"'
+	@echo 'LIST:[*]:[@]:C/ /,/="${LIST:[*]:[@]:C/ /,/}"'
+
+mod-squarebrackets-hash:
+	@echo 'EMPTY="${EMPTY}"'
+	@echo 'EMPTY:[#]="${EMPTY:[#]}" == 1 ?'
+	@echo 'ESCAPEDSPACE="${ESCAPEDSPACE}"'
+	@echo 'ESCAPEDSPACE:[#]="${ESCAPEDSPACE:[#]}" == 1 ?'
+	@echo 'REALLYSPACE="${REALLYSPACE}"'
+	@echo 'REALLYSPACE:[#]="${REALLYSPACE:[#]}" == 1 ?'
+	@echo 'LIST:[#]="${LIST:[#]}"'
+	@echo 'LIST:[0]:[#]="${LIST:[0]:[#]}" == 1 ?'
+	@echo 'LIST:[*]:[#]="${LIST:[*]:[#]}" == 1 ?'
+	@echo 'LIST:[@]:[#]="${LIST:[@]:[#]}"'
+	@echo 'LIST:[1]:[#]="${LIST:[1]:[#]}"'
+	@echo 'LIST:[1..3]:[#]="${LIST:[1..3]:[#]}"'
+
+mod-squarebrackets-n:
+	@echo 'EMPTY:[1]="${EMPTY:[1]}"'
+	@echo 'ESCAPEDSPACE="${ESCAPEDSPACE}"'
+	@echo 'ESCAPEDSPACE:[1]="${ESCAPEDSPACE:[1]}"'
+	@echo 'REALLYSPACE="${REALLYSPACE}"'
+	@echo 'REALLYSPACE:[1]="${REALLYSPACE:[1]}" == "" ?'
+	@echo 'REALLYSPACE:[*]:[1]="${REALLYSPACE:[*]:[1]}" == " " ?'
+	@echo 'LIST:[1]="${LIST:[1]}"'
+	@echo 'LIST:[1.]="${LIST:[1.]}" is an error'
+	@echo 'LIST:[1].="${LIST:[1].}" is an error'
+	@echo 'LIST:[2]="${LIST:[2]}"'
+	@echo 'LIST:[6]="${LIST:[6]}"'
+	@echo 'LIST:[7]="${LIST:[7]}"'
+	@echo 'LIST:[999]="${LIST:[999]}"'
+	@echo 'LIST:[-]="${LIST:[-]}" is an error'
+	@echo 'LIST:[--]="${LIST:[--]}" is an error'
+	@echo 'LIST:[-1]="${LIST:[-1]}"'
+	@echo 'LIST:[-2]="${LIST:[-2]}"'
+	@echo 'LIST:[-6]="${LIST:[-6]}"'
+	@echo 'LIST:[-7]="${LIST:[-7]}"'
+	@echo 'LIST:[-999]="${LIST:[-999]}"'
+	@echo 'LONGLIST:[17]="${LONGLIST:[17]}"'
+	@echo 'LONGLIST:[0x11]="${LONGLIST:[0x11]}"'
+	@echo 'LONGLIST:[021]="${LONGLIST:[021]}"'
+	@echo 'LIST:[0]:[1]="${LIST:[0]:[1]}"'
+	@echo 'LIST:[*]:[1]="${LIST:[*]:[1]}"'
+	@echo 'LIST:[@]:[1]="${LIST:[@]:[1]}"'
+	@echo 'LIST:[0]:[2]="${LIST:[0]:[2]}"'
+	@echo 'LIST:[*]:[2]="${LIST:[*]:[2]}"'
+	@echo 'LIST:[@]:[2]="${LIST:[@]:[2]}"'
+	@echo 'LIST:[*]:C/ /,/:[2]="${LIST:[*]:C/ /,/:[2]}"'
+	@echo 'LIST:[*]:C/ /,/:[*]:[2]="${LIST:[*]:C/ /,/:[*]:[2]}"'
+	@echo 'LIST:[*]:C/ /,/:[@]:[2]="${LIST:[*]:C/ /,/:[@]:[2]}"'
+
+mod-squarebrackets-start-end:
+	@echo 'LIST:[1.]="${LIST:[1.]}" is an error'
+	@echo 'LIST:[1..]="${LIST:[1..]}" is an error'
+	@echo 'LIST:[1..1]="${LIST:[1..1]}"'
+	@echo 'LIST:[1..1.]="${LIST:[1..1.]}" is an error'
+	@echo 'LIST:[1..2]="${LIST:[1..2]}"'
+	@echo 'LIST:[2..1]="${LIST:[2..1]}"'
+	@echo 'LIST:[3..-2]="${LIST:[3..-2]}"'
+	@echo 'LIST:[-4..4]="${LIST:[-4..4]}"'
+	@echo 'LIST:[0..1]="${LIST:[0..1]}" is an error'
+	@echo 'LIST:[-1..0]="${LIST:[-1..0]}" is an error'
+	@echo 'LIST:[-1..1]="${LIST:[-1..1]}"'
+	@echo 'LIST:[0..0]="${LIST:[0..0]}"'
+	@echo 'LIST:[3..99]="${LIST:[3..99]}"'
+	@echo 'LIST:[-3..-99]="${LIST:[-3..-99]}"'
+	@echo 'LIST:[-99..-3]="${LIST:[-99..-3]}"'
+
+mod-squarebrackets-nested:
+	@echo 'HASH="${HASH}" == "#" ?'
+	@echo 'LIST:[$${HASH}]="${LIST:[${HASH}]}"'
+	@echo 'LIST:[$${ZERO}]="${LIST:[${ZERO}]}"'
+	@echo 'LIST:[$${ZERO}x$${ONE}]="${LIST:[${ZERO}x${ONE}]}"'
+	@echo 'LIST:[$${ONE}]="${LIST:[${ONE}]}"'
+	@echo 'LIST:[$${MINUSONE}]="${LIST:[${MINUSONE}]}"'
+	@echo 'LIST:[$${STAR}]="${LIST:[${STAR}]}"'
+	@echo 'LIST:[$${AT}]="${LIST:[${AT}]}"'
+	@echo 'LIST:[$${EMPTY}]="${LIST:[${EMPTY}]}" is an error'
+	@echo 'LIST:[$${LONGLIST:[21]:S/2//}]="${LIST:[${LONGLIST:[21]:S/2//}]}"'
+	@echo 'LIST:[$${LIST:[#]}]="${LIST:[${LIST:[#]}]}"'
+	@echo 'LIST:[$${LIST:[$${HASH}]}]="${LIST:[${LIST:[${HASH}]}]}"'
+
+mod-C-W:
+	@echo 'LIST:C/ /,/="${LIST:C/ /,/}"'
+	@echo 'LIST:C/ /,/W="${LIST:C/ /,/W}"'
+	@echo 'LIST:C/ /,/gW="${LIST:C/ /,/gW}"'
+	@echo 'EMPTY:C/^/,/="${EMPTY:C/^/,/}"'
+	@echo 'EMPTY:C/^/,/W="${EMPTY:C/^/,/W}"'
+
+mod-S-W:
+	@echo 'LIST:S/ /,/="${LIST:S/ /,/}"'
+	@echo 'LIST:S/ /,/W="${LIST:S/ /,/W}"'
+	@echo 'LIST:S/ /,/gW="${LIST:S/ /,/gW}"'
+	@echo 'EMPTY:S/^/,/="${EMPTY:S/^/,/}"'
+	@echo 'EMPTY:S/^/,/W="${EMPTY:S/^/,/W}"'
+
+mod-tW-tw:
+	@echo 'LIST:tW="${LIST:tW}"'
+	@echo 'LIST:tw="${LIST:tw}"'
+	@echo 'LIST:tW:C/ /,/="${LIST:tW:C/ /,/}"'
+	@echo 'LIST:tW:C/ /,/g="${LIST:tW:C/ /,/g}"'
+	@echo 'LIST:tW:C/ /,/1g="${LIST:tW:C/ /,/1g}"'
+	@echo 'LIST:tw:C/ /,/="${LIST:tw:C/ /,/}"'
+	@echo 'LIST:tw:C/ /,/g="${LIST:tw:C/ /,/g}"'
+	@echo 'LIST:tw:C/ /,/1g="${LIST:tw:C/ /,/1g}"'
+	@echo 'LIST:tw:tW:C/ /,/="${LIST:tw:tW:C/ /,/}"'
+	@echo 'LIST:tW:tw:C/ /,/="${LIST:tW:tw:C/ /,/}"'

Deleted: vendor/NetBSD/bmake/dist/unit-tests/order
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/order	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/unit-tests/order	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,20 +0,0 @@
-# $NetBSD: order,v 1.1 2012/11/09 19:08:28 sjg Exp $
-
-# Test that .ORDER is handled correctly.
-# The explicit dependency the.o: the.h will make us examine the.h
-# the .ORDER will prevent us building it immediately,
-# we should then examine the.c rather than stop.
-
-all: the.o
-
-.ORDER: the.c the.h
-
-the.c the.h:
-	@echo Making $@
-
-.SUFFIXES: .o .c
-
-.c.o:
-	@echo Making $@ from $?
-
-the.o: the.h

Added: vendor/NetBSD/bmake/dist/unit-tests/order.exp
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/order.exp	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/order.exp	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,4 @@
+Making the.c
+Making the.h
+Making the.o from the.h the.c
+exit status 0

Added: vendor/NetBSD/bmake/dist/unit-tests/order.mk
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/order.mk	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/order.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,20 @@
+# $NetBSD: order.mk,v 1.1 2014/08/21 13:44:51 apb Exp $
+
+# Test that .ORDER is handled correctly.
+# The explicit dependency the.o: the.h will make us examine the.h
+# the .ORDER will prevent us building it immediately,
+# we should then examine the.c rather than stop.
+
+all: the.o
+
+.ORDER: the.c the.h
+
+the.c the.h:
+	@echo Making $@
+
+.SUFFIXES: .o .c
+
+.c.o:
+	@echo Making $@ from $?
+
+the.o: the.h

Deleted: vendor/NetBSD/bmake/dist/unit-tests/phony-end
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/phony-end	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/unit-tests/phony-end	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,9 +0,0 @@
-# $Id: phony-end,v 1.1.1.1 2011/10/01 17:19:39 sjg Exp $
-
-all ok also.ok bug phony:
-	@echo '${.TARGET .PREFIX .IMPSRC:L:@v@$v="${$v}"@}'
-
-.END:	ok also.ok bug
-
-phony bug:	.PHONY
-all: phony

Added: vendor/NetBSD/bmake/dist/unit-tests/phony-end.exp
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/phony-end.exp	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/phony-end.exp	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,6 @@
+.TARGET="phony" .PREFIX="phony" .IMPSRC=""
+.TARGET="all" .PREFIX="all" .IMPSRC="phony"
+.TARGET="ok" .PREFIX="ok" .IMPSRC=""
+.TARGET="also.ok" .PREFIX="also.ok" .IMPSRC=""
+.TARGET="bug" .PREFIX="bug" .IMPSRC=""
+exit status 0

Added: vendor/NetBSD/bmake/dist/unit-tests/phony-end.mk
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/phony-end.mk	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/phony-end.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,9 @@
+# $Id: phony-end.mk,v 1.1.1.1 2014/08/30 18:57:18 sjg Exp $
+
+all ok also.ok bug phony:
+	@echo '${.TARGET .PREFIX .IMPSRC:L:@v@$v="${$v}"@}'
+
+.END:	ok also.ok bug
+
+phony bug:	.PHONY
+all: phony

Deleted: vendor/NetBSD/bmake/dist/unit-tests/posix
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/posix	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/unit-tests/posix	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,24 +0,0 @@
-# $Id: posix,v 1.1.1.1 2004/05/08 16:45:39 sjg Exp $
-
-all:	x plus subs err
-
-x:
-	@echo "Posix says we should execute the command as if run by system(3)"
-	@echo "Expect 'Hello,' and 'World!'"
-	@echo Hello,; false; echo "World!"
-
-plus:
-	@echo a command
-	+ at echo "a command prefixed by '+' executes even with -n"
-	@echo another command
-
-subs:
-	@echo make -n
-	@${.MAKE} -f ${MAKEFILE} -n plus
-	@echo make -n -j1
-	@${.MAKE} -f ${MAKEFILE} -n -j1 plus
-
-err:
-	@(echo Now we expect an error...; exit 1)
-	@echo "Oops! you shouldn't see this!"
-

Added: vendor/NetBSD/bmake/dist/unit-tests/posix.exp
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/posix.exp	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/posix.exp	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,23 @@
+Posix says we should execute the command as if run by system(3)
+Expect 'Hello,' and 'World!'
+Hello,
+World!
+a command
+a command prefixed by '+' executes even with -n
+another command
+make -n
+echo a command
+echo "a command prefixed by '+' executes even with -n"
+a command prefixed by '+' executes even with -n
+echo another command
+make -n -j1
+{ echo a command 
+} || exit $?
+echo "a command prefixed by '+' executes even with -n"
+a command prefixed by '+' executes even with -n
+{ echo another command 
+} || exit $?
+Now we expect an error...
+*** Error code 1 (continuing)
+`all' not remade because of errors.
+exit status 0

Added: vendor/NetBSD/bmake/dist/unit-tests/posix.mk
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/posix.mk	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/posix.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,24 @@
+# $Id: posix.mk,v 1.1.1.1 2014/08/30 18:57:18 sjg Exp $
+
+all:	x plus subs err
+
+x:
+	@echo "Posix says we should execute the command as if run by system(3)"
+	@echo "Expect 'Hello,' and 'World!'"
+	@echo Hello,; false; echo "World!"
+
+plus:
+	@echo a command
+	+ at echo "a command prefixed by '+' executes even with -n"
+	@echo another command
+
+subs:
+	@echo make -n
+	@${.MAKE} -f ${MAKEFILE} -n plus
+	@echo make -n -j1
+	@${.MAKE} -f ${MAKEFILE} -n -j1 plus
+
+err:
+	@(echo Now we expect an error...; exit 1)
+	@echo "Oops! you shouldn't see this!"
+

Added: vendor/NetBSD/bmake/dist/unit-tests/posix1.exp
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/posix1.exp	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/posix1.exp	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,185 @@
+${VAR} = "foo  bar baz"
+a
+b
+c
+foo baR baz,  bar baz, foo bar baz, fooadd baradd bazadd
+mkdir -p 'dir'
+touch 'dir/obj_1.h'
+mkdir -p 'dir'
+printf '#include "obj_1.h"\nconst char* obj_1 = "dir/obj_1.c";\n' \
+    >'dir/obj_1.c'
+Local variables
+ ${@}="dir/obj_1.o" ${<}="dir/obj_1.c"
+ ${*}="dir/obj_1" ${?}="dir/obj_1.h dir/obj_1.c"
+ ${%}=""
+
+Directory and filename parts of local variables
+ ${@D}="dir" ${@F}="obj_1.o"
+ ${<D}="dir" ${<F}="obj_1.c"
+ ${*D}="dir" ${*F}="obj_1"
+ ${?D}="dir dir" ${?F}="obj_1.h obj_1.c"
+ ${%D}="" ${%F}=""
+
+Local variable substitutions
+ ${@:.o=}="dir/obj_1" ${<:.c=.C}="dir/obj_1.C"
+ ${*:=.h}="dir/obj_1.h" ${?:.h=.H}="dir/obj_1.H dir/obj_1.c"
+ ${%:=}=""
+
+Target with suffix transformations
+ ${@D:=append}="dirappend"
+ ${@F:.o=.O}="obj_1.O"
+ 
+ Implied source with suffix transformations
+ ${<D:r=rr}="dirr"
+ ${<F:.c=.C}="obj_1.C"
+ 
+ Suffixless target with suffix transformations
+ ${*D:.=dot}="dir"
+ ${*F:.a=}="obj_1"
+ 
+ Out-of-date dependencies with suffix transformations
+ ${?D:ir=}="d d"
+ ${?F:.h=.H}="obj_1.H obj_1.c"
+ 
+ Member with suffix transformations
+ ${%D:.=}=""
+ ${%F:${VAR2}=${VAR}}=""
+
+cc -c -o 'dir/obj_1.o' 'dir/obj_1.c'
+mkdir -p '.'
+touch 'dummy'
+Local variables
+ ${@}="lib.a" ${<}="dir/obj_1.o"
+ ${*}="obj1" ${?}="dir/obj_1.o dummy"
+ ${%}="obj1.o"
+
+Directory and filename parts of local variables
+ ${@D}="." ${@F}="lib.a"
+ ${<D}="dir" ${<F}="obj_1.o"
+ ${*D}="." ${*F}="obj1"
+ ${?D}="dir ." ${?F}="obj_1.o dummy"
+ ${%D}="." ${%F}="obj1.o"
+
+Local variable substitutions
+ ${@:.o=}="lib.a" ${<:.c=.C}="dir/obj_1.o"
+ ${*:=.h}="obj1.h" ${?:.h=.H}="dir/obj_1.o dummy"
+ ${%:=}="obj1.o"
+
+Target with suffix transformations
+ ${@D:=append}=".append"
+ ${@F:.o=.O}="lib.a"
+ 
+ Implied source with suffix transformations
+ ${<D:r=rr}="dirr"
+ ${<F:.c=.C}="obj_1.o"
+ 
+ Suffixless target with suffix transformations
+ ${*D:.=dot}="dot"
+ ${*F:.a=}="obj1"
+ 
+ Out-of-date dependencies with suffix transformations
+ ${?D:ir=}="d ."
+ ${?F:.h=.H}="obj_1.o dummy"
+ 
+ Member with suffix transformations
+ ${%D:.=}=""
+ ${%F:${VAR2}=${VAR}}="obj1foo  bar baz"
+
+cp 'dir/obj_1.o' 'obj1.o'
+ar -rcv 'lib.a' 'obj1.o'
+a - obj1.o
+rm -f 'obj1.o'
+mkdir -p '.'
+printf '#include "obj_2.h"\nconst char* obj_2 = "obj_2.c";\n' \
+    >'obj_2.c'
+mkdir -p '.'
+touch 'obj_2.h'
+Local variables
+ ${@}="obj2.o" ${<}="obj_2.c"
+ ${*}="obj2" ${?}="obj_2.c obj_2.h dir/obj_1.h"
+ ${%}=""
+
+Directory and filename parts of local variables
+ ${@D}="." ${@F}="obj2.o"
+ ${<D}="." ${<F}="obj_2.c"
+ ${*D}="." ${*F}="obj2"
+ ${?D}=". . dir" ${?F}="obj_2.c obj_2.h obj_1.h"
+ ${%D}="" ${%F}=""
+
+Local variable substitutions
+ ${@:.o=}="obj2" ${<:.c=.C}="obj_2.C"
+ ${*:=.h}="obj2.h" ${?:.h=.H}="obj_2.c obj_2.H dir/obj_1.H"
+ ${%:=}=""
+
+Target with suffix transformations
+ ${@D:=append}=".append"
+ ${@F:.o=.O}="obj2.O"
+ 
+ Implied source with suffix transformations
+ ${<D:r=rr}="."
+ ${<F:.c=.C}="obj_2.C"
+ 
+ Suffixless target with suffix transformations
+ ${*D:.=dot}="dot"
+ ${*F:.a=}="obj2"
+ 
+ Out-of-date dependencies with suffix transformations
+ ${?D:ir=}=". . d"
+ ${?F:.h=.H}="obj_2.c obj_2.H obj_1.H"
+ 
+ Member with suffix transformations
+ ${%D:.=}=""
+ ${%F:${VAR2}=${VAR}}=""
+
+cc -c -o 'obj2.o' 'obj_2.c'
+ar -rcv 'lib.a' 'obj2.o'
+a - obj2.o
+mkdir -p '.'
+touch 'obj3.h'
+mkdir -p 'dir'
+touch 'dir/dummy'
+mkdir -p '.'
+printf '#include "obj3.h"\nconst char* obj3 = "obj3.c";\n' \
+    >'obj3.c'
+Local variables
+ ${@}="lib.a" ${<}="obj3.c"
+ ${*}="obj3" ${?}="obj3.h dir/dummy obj3.c"
+ ${%}="obj3.o"
+
+Directory and filename parts of local variables
+ ${@D}="." ${@F}="lib.a"
+ ${<D}="." ${<F}="obj3.c"
+ ${*D}="." ${*F}="obj3"
+ ${?D}=". dir ." ${?F}="obj3.h dummy obj3.c"
+ ${%D}="." ${%F}="obj3.o"
+
+Local variable substitutions
+ ${@:.o=}="lib.a" ${<:.c=.C}="obj3.C"
+ ${*:=.h}="obj3.h" ${?:.h=.H}="obj3.H dir/dummy obj3.c"
+ ${%:=}="obj3.o"
+
+Target with suffix transformations
+ ${@D:=append}=".append"
+ ${@F:.o=.O}="lib.a"
+ 
+ Implied source with suffix transformations
+ ${<D:r=rr}="."
+ ${<F:.c=.C}="obj3.C"
+ 
+ Suffixless target with suffix transformations
+ ${*D:.=dot}="dot"
+ ${*F:.a=}="obj3"
+ 
+ Out-of-date dependencies with suffix transformations
+ ${?D:ir=}=". d ."
+ ${?F:.h=.H}="obj3.H dummy obj3.c"
+ 
+ Member with suffix transformations
+ ${%D:.=}=""
+ ${%F:${VAR2}=${VAR}}="obj3foo  bar baz"
+
+cc -c -o 'obj3.o' 'obj3.c'
+ar -rcv 'lib.a' 'obj3.o'
+a - obj3.o
+rm -f 'obj3.o'
+exit status 0

Added: vendor/NetBSD/bmake/dist/unit-tests/posix1.mk
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/posix1.mk	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/posix1.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,184 @@
+# $NetBSD: posix1.mk,v 1.3 2014/08/30 22:21:08 sjg Exp $
+
+# Keep the default suffixes from interfering, just in case.
+.SUFFIXES:
+
+all:	line-continuations suffix-substitution localvars
+
+# we need to clean for repeatable results
+.BEGIN: clean
+clean:
+	@rm -f lib.a dir/* dummy obj*
+
+#
+# Line continuations
+#
+
+# Escaped newlines and leading whitespace from the next line are replaced
+# with single space, except in commands, where the escape and the newline
+# are retained, but a single leading tab (if any) from the next line is
+# removed. (PR 49085)
+# Expect:
+# ${VAR} = "foo  bar baz"
+# a
+# b
+# c
+VAR = foo\
+\
+	  bar\
+ baz
+
+line-continuations:
+	@echo '$${VAR} = "${VAR}"'
+	@echo 'aXbXc' | sed -e 's/X/\
+	/g'
+
+
+#
+# Suffix substitution
+#
+
+# The only variable modifier accepted by POSIX.
+# ${VAR:s1=s2}: replace s1, if found, with s2 at end of each word in
+# ${VAR}.  s1 and s2 may contain macro expansions.
+# Expect: foo baR baz, bar baz, foo bar baz, fooadd baradd bazadd
+suffix-substitution:
+	@echo '${VAR:r=R}, ${VAR:foo=}, ${VAR:not_there=wrong}, ${VAR:=add}'
+
+
+#
+# Local variables: regular forms, D/F forms and suffix substitution.
+#
+
+# In the past substitutions did not work with the D/F forms and those
+# forms were not available for $?.  (PR 49085)
+
+ARFLAGS = -rcv
+
+localvars: lib.a
+
+# $@ = target or archive name	$< = implied source
+# $* = target without suffix 	$? = sources newer than target
+# $% = archive member name
+LOCALS = \
+	"Local variables\n\
+	\$${@}=\"${@}\" \$${<}=\"${<}\"\n\
+	\$${*}=\"${*}\" \$${?}=\"${?}\"\n\
+	\$${%%}=\"${%}\"\n\n"
+
+# $XD = directory part of X	$XF = file part of X
+# X is one of the local variables.
+LOCAL_ALTERNATIVES = \
+	"Directory and filename parts of local variables\n\
+	\$${@D}=\"${@D}\" \$${@F}=\"${@F}\"\n\
+	\$${<D}=\"${<D}\" \$${<F}=\"${<F}\"\n\
+	\$${*D}=\"${*D}\" \$${*F}=\"${*F}\"\n\
+	\$${?D}=\"${?D}\" \$${?F}=\"${?F}\"\n\
+	\$${%%D}=\"${%D}\" \$${%%F}=\"${%F}\"\n\n"
+
+# Do all kinds of meaningless substitutions on local variables to see
+# if they work.  Add, remove and replace things.
+VAR2 = .o
+VAR3 = foo
+LOCAL_SUBSTITUTIONS = \
+	"Local variable substitutions\n\
+	\$${@:.o=}=\"${@:.o=}\" \$${<:.c=.C}=\"${<:.c=.C}\"\n\
+	\$${*:=.h}=\"${*:=.h}\" \$${?:.h=.H}=\"${?:.h=.H}\"\n\
+	\$${%%:=}=\"${%:=}\"\n\n"
+
+LOCAL_ALTERNATIVE_SUBSTITUTIONS = \
+	"Target with suffix transformations\n\
+	\$${@D:=append}=\"${@D:=append}\"\n\
+	\$${@F:.o=.O}=\"${@F:.o=.O}\"\n\
+	\n\
+	Implied source with suffix transformations\n\
+	\$${<D:r=rr}=\"${<D:r=rr}\"\n\
+	\$${<F:.c=.C}=\"${<F:.c=.C}\"\n\
+	\n\
+	Suffixless target with suffix transformations\n\
+	\$${*D:.=dot}=\"${*D:.=dot}\"\n\
+	\$${*F:.a=}=\"${*F:.a=}\"\n\
+	\n\
+	Out-of-date dependencies with suffix transformations\n\
+	\$${?D:ir=}=\"${?D:ir=}\"\n\
+	\$${?F:.h=.H}=\"${?F:.h=.H}\"\n\
+	\n\
+	Member with suffix transformations\n\
+	\$${%%D:.=}=\"${%D:.=}\"\n\
+	\$${%%F:\$${VAR2}=\$${VAR}}=\"${%F:${VAR2}=${VAR}}\"\n\n"
+
+.SUFFIXES: .c .o .a
+
+# The system makefiles make the .c.a rule .PRECIOUS with a special source,
+# but such a thing is not POSIX compatible.  It's also somewhat useless
+# in a test makefile.
+.c.a:
+	@printf ${LOCALS}
+	@printf ${LOCAL_ALTERNATIVES}
+	@printf ${LOCAL_SUBSTITUTIONS}
+	@printf ${LOCAL_ALTERNATIVE_SUBSTITUTIONS}
+	cc -c -o '${%}' '${<}'
+	ar ${ARFLAGS} '${@}' '${%}'
+	rm -f '${%}'
+
+.c.o:
+	@printf ${LOCALS}
+	@printf ${LOCAL_ALTERNATIVES}
+	@printf ${LOCAL_SUBSTITUTIONS}
+	@printf ${LOCAL_ALTERNATIVE_SUBSTITUTIONS}
+	cc -c -o '${@}' '${<}'
+
+# Some of these rules are padded with useless extra dependencies just so
+# that ${?} has more than one file.
+
+lib.a: lib.a(obj1.o) lib.a(obj2.o) lib.a(obj3.o)
+	@ar -s '${@}'
+
+# Explicit rule where the dependency is an inferred file.  The dependency
+# object's name differs from the member's because there was a bug which
+# forced a dependency on member even when no such dependency was specified
+# (PR 49086).
+lib.a(obj1.o): dir/obj_1.o dummy
+	@printf ${LOCALS}
+	@printf ${LOCAL_ALTERNATIVES}
+	@printf ${LOCAL_SUBSTITUTIONS}
+	@printf ${LOCAL_ALTERNATIVE_SUBSTITUTIONS}
+	cp 'dir/obj_1.o' '$%'
+	ar ${ARFLAGS} '${@}' '$%'
+	rm -f '$%'
+
+# Excplicit rule where the dependency also has an explicit rule.
+lib.a(obj2.o): obj2.o
+	ar ${ARFLAGS} '${@}' '${%}'
+
+# Use .c.a inference with an extra dependency.
+lib.a(obj3.o): obj3.h dir/dummy
+
+# Use .c.o inference with an extra dependency.
+dir/obj_1.o: dir/obj_1.h
+
+# According to POSIX, $* is only required for inference rules and $<'s
+# value is unspecified outside of inference rules.  Strictly speaking
+# we shouldn't be expanding them here but who cares.  At least we get
+# to check that the program does nothing stupid (like crash) with them.
+# The C file is named differently from the object file because there
+# was a bug which forced dependencies based on inference rules on all
+# applicable targets (PR 49086).
+obj2.o: obj_2.c obj_2.h dir/obj_1.h
+	@printf ${LOCALS}
+	@printf ${LOCAL_ALTERNATIVES}
+	@printf ${LOCAL_SUBSTITUTIONS}
+	@printf ${LOCAL_ALTERNATIVE_SUBSTITUTIONS}
+	cc -c -o '${@}' 'obj_2.c'
+
+# Hey, this is make, we can make our own test data setup!  obj1.c
+# and obj2.c are not used, so they should not get created.  They're here
+# as a bait for a regression into the forced dependencies discussed earlier.
+obj1.c dir/obj_1.c obj2.c obj_2.c obj3.c:
+	mkdir -p '${@D}'
+	printf '#include "${@F:.c=.h}"\nconst char* ${@F:.c=} = "${@}";\n' \
+	    >'${@}'
+
+dir/obj_1.h obj_2.h obj3.h dummy dir/dummy:
+	mkdir -p '${@D}'
+	touch '${@}'

Deleted: vendor/NetBSD/bmake/dist/unit-tests/qequals
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/qequals	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/unit-tests/qequals	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,8 +0,0 @@
-# $Id: qequals,v 1.1.1.1 2008/03/31 00:13:05 sjg Exp $
-
-M= i386
-V.i386= OK
-V.$M ?= bug
-
-all:
-	@echo 'V.$M ?= ${V.$M}'

Added: vendor/NetBSD/bmake/dist/unit-tests/qequals.exp
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/qequals.exp	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/qequals.exp	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,2 @@
+V.i386 ?= OK
+exit status 0

Added: vendor/NetBSD/bmake/dist/unit-tests/qequals.mk
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/qequals.mk	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/qequals.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,8 @@
+# $Id: qequals.mk,v 1.1.1.1 2014/08/30 18:57:18 sjg Exp $
+
+M= i386
+V.i386= OK
+V.$M ?= bug
+
+all:
+	@echo 'V.$M ?= ${V.$M}'

Added: vendor/NetBSD/bmake/dist/unit-tests/suffixes.exp
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/suffixes.exp	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/suffixes.exp	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,35 @@
+make: don't know how to make issue3 (continuing)
+There should be no text after the colon: 
+touch .a
+There should be no text after the colon: 
+touch .a.b
+There should be no text after the colon: 
+touch .b.a
+touch issue5a.c
+first set
+cp issue5a.c issue5a.d
+touch issue5b.d
+first set
+cp issue5b.d issue5b.c
+touch issue5c.d
+first set
+cp issue5c.d issue5c
+touch issue5d.d
+first set
+cp issue5d.d issue5d.e
+touch issue5e.e
+first set
+cp issue5e.e issue5e.d
+make: don't know how to make issue6.f (continuing)
+touch issue10.d
+first set
+cp issue10.d issue10.e
+touch issue11.h
+touch issue11.first
+.ALLSRC: issue11.h issue11.first
+cp issue11.h issue11.i
+touch issue11.second
+.ALLSRC: issue11.i issue11.second
+cp issue11.i issue11.j
+`all' not remade because of errors.
+exit status 0

Added: vendor/NetBSD/bmake/dist/unit-tests/suffixes.mk
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/suffixes.mk	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/suffixes.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,89 @@
+# $NetBSD: suffixes.mk,v 1.3 2014/08/30 22:21:08 sjg Exp $
+
+# Issues from PR 49086
+
+# Issue 3: single suffix rules remain active after .SUFFIXES is cleared
+#
+# There's a rule for issue3.a, but .a is no longer a known suffix when
+# targets are being made, so issue3 should not get made.
+all: issue3
+
+# Issue 4: suffix rules do not become regular rules when .SUFFIXES is cleared
+#
+# When the rules were encountered, .a and .b were known suffices, but later
+# on they were forgotten.  These should get created as regular targets.
+all: .a .a.b .b.a
+
+# Issue 5: adding more suffixes does not make existing rules into suffix rules
+#
+# When the targets .c.d, .d.c, .d, .d.e, and .e.d were encountered, only .a,
+# .b and .c were known suffixes, so all of them were regular rules.  Later
+# rest of the suffixes were made known, so they should all be suffix
+# transformation rules.
+all: issue5a.d issue5b.c issue5c issue5d.e issue5e.d
+
+# Issue 6: transformation search can end up in an infinite loop
+#
+# There is no file or target from which issue6.f could be made from so
+# this should fail.  The bug was that because rules .e.f, .d.e and .e.d
+# exist, make would try to make .f from .e and then infinitely try
+# to do .e from .d and vice versa.
+all: issue6.f
+
+# Issue 10: explicit dependencies affect transformation rule selection
+#
+# If issue10.e is wanted and both issue10.d and issue10.f are available,
+# make should choose the .d.e rule, because .d is before .f in .SUFFIXES.
+# The bug was that if issue10.d had an explicit dependency on issue10.f,
+# it would choose .f.e instead.
+all: issue10.e
+
+# Issue 11: sources from transformation rules are expanded incorrectly
+#
+# issue11.j should depend on issue11.i and issue11.second and issue11.i
+# should depend on issue11.h and issue11.first.  The bug was that
+# the dynamic sources were expanded before ${.PREFIX} and ${.TARGET} were
+# available, so they would have expanded to a null string.
+all: issue11.j
+
+# we need to clean for repeatable results
+.BEGIN: clean
+clean:
+	@rm -f issue* .[ab]*
+
+.SUFFIXES: .a .b .c
+
+.a .a.b .b.a:
+	@echo 'There should be no text after the colon: ${.IMPSRC}'
+	touch ${.TARGET}
+
+.c.d .d.c .d .d.e .e.d:
+	@echo 'first set'
+	cp ${.IMPSRC} ${.TARGET}
+
+.SUFFIXES:
+.SUFFIXES: .c .d .e .f .g
+
+.e .e.f .f.e:
+	@echo 'second set'
+	cp ${.IMPSRC} ${.TARGET}
+
+issue3.a:
+	@echo 'There is a bug if you see this.'
+	touch ${.TARGET}
+
+issue5a.c issue5b.d issue5c.d issue5d.d issue5e.e issue10.d issue10.f:
+	touch ${.TARGET}
+
+.SUFFIXES: .h .i .j
+
+.h.i: ${.PREFIX}.first
+	@echo '.ALLSRC: ${.ALLSRC}'
+	cp ${.IMPSRC} ${.TARGET}
+
+.i.j: ${.PREFIX}.second
+	@echo '.ALLSRC: ${.ALLSRC}'
+	cp ${.IMPSRC} ${.TARGET}
+
+issue11.h issue11.first issue11.second:
+	touch ${.TARGET}

Deleted: vendor/NetBSD/bmake/dist/unit-tests/sunshcmd
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/sunshcmd	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/unit-tests/sunshcmd	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,10 +0,0 @@
-BYECMD		= echo bye
-LATERCMD	= echo later
-TEST1 :sh	= echo hello
-TEST2 :sh	= ${BYECMD}
-TEST3		= ${LATERCMD:sh}
-
-all:
-	@echo "TEST1=${TEST1}"
-	@echo "TEST2=${TEST2}"
-	@echo "TEST3=${TEST3}"

Added: vendor/NetBSD/bmake/dist/unit-tests/sunshcmd.exp
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/sunshcmd.exp	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/sunshcmd.exp	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,4 @@
+TEST1=hello
+TEST2=bye
+TEST3=later
+exit status 0

Added: vendor/NetBSD/bmake/dist/unit-tests/sunshcmd.mk
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/sunshcmd.mk	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/sunshcmd.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,10 @@
+BYECMD		= echo bye
+LATERCMD	= echo later
+TEST1 :sh	= echo hello
+TEST2 :sh	= ${BYECMD}
+TEST3		= ${LATERCMD:sh}
+
+all:
+	@echo "TEST1=${TEST1}"
+	@echo "TEST2=${TEST2}"
+	@echo "TEST3=${TEST3}"

Deleted: vendor/NetBSD/bmake/dist/unit-tests/sysv
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/sysv	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/unit-tests/sysv	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,26 +0,0 @@
-# $Id: sysv,v 1.1.1.2 2011/06/05 04:23:49 sjg Exp $
-
-FOO ?=
-FOOBAR = $(FOO:=bar)
-
-_this := ${.PARSEDIR}/${.PARSEFILE}
-
-B = /b
-S = /
-FUN = ${B}${S}fun
-SUN = the Sun
-
-# we expect nothing when FOO is empty
-all: foo fun
-
-foo:
-	@echo FOOBAR = $(FOOBAR)
-.if empty(FOO)
-	@FOO="foo fu" ${.MAKE} -f ${_this} foo
-.endif
-
-fun:
-	@echo ${FUN:T}
-	@echo ${FUN:${B}${S}fun=fun}
-	@echo ${FUN:${B}${S}%=%}
-	@echo ${In:L:%=% ${SUN}}

Added: vendor/NetBSD/bmake/dist/unit-tests/sysv.exp
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/sysv.exp	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/sysv.exp	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,7 @@
+FOOBAR =
+FOOBAR = foobar fubar
+fun
+fun
+fun
+In the Sun
+exit status 0

Added: vendor/NetBSD/bmake/dist/unit-tests/sysv.mk
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/sysv.mk	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/sysv.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,26 @@
+# $Id: sysv.mk,v 1.2 2014/08/30 22:25:14 sjg Exp $
+
+FOO ?=
+FOOBAR = ${FOO:=bar}
+
+_this := ${.PARSEDIR}/${.PARSEFILE}
+
+B = /b
+S = /
+FUN = ${B}${S}fun
+SUN = the Sun
+
+# we expect nothing when FOO is empty
+all: foo fun
+
+foo:
+	@echo FOOBAR = ${FOOBAR}
+.if empty(FOO)
+	@FOO="foo fu" ${.MAKE} -f ${_this} foo
+.endif
+
+fun:
+	@echo ${FUN:T}
+	@echo ${FUN:${B}${S}fun=fun}
+	@echo ${FUN:${B}${S}%=%}
+	@echo ${In:L:%=% ${SUN}}

Deleted: vendor/NetBSD/bmake/dist/unit-tests/ternary
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/ternary	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/unit-tests/ternary	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,8 +0,0 @@
-
-all:
-	@for x in "" A= A=42; do ${.MAKE} -f ${MAKEFILE} show $$x; done
-
-show:
-	@echo "The answer is ${A:?known:unknown}"
-	@echo "The answer is ${A:?$A:unknown}"
-	@echo "The answer is ${empty(A):?empty:$A}"

Added: vendor/NetBSD/bmake/dist/unit-tests/ternary.exp
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/ternary.exp	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/ternary.exp	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,10 @@
+The answer is unknown
+The answer is unknown
+The answer is empty
+The answer is known
+The answer is 
+The answer is empty
+The answer is known
+The answer is 42
+The answer is 42
+exit status 0

Added: vendor/NetBSD/bmake/dist/unit-tests/ternary.mk
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/ternary.mk	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/ternary.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,8 @@
+
+all:
+	@for x in "" A= A=42; do ${.MAKE} -f ${MAKEFILE} show $$x; done
+
+show:
+	@echo "The answer is ${A:?known:unknown}"
+	@echo "The answer is ${A:?$A:unknown}"
+	@echo "The answer is ${empty(A):?empty:$A}"

Deleted: vendor/NetBSD/bmake/dist/unit-tests/test.exp
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/test.exp	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/unit-tests/test.exp	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,383 +0,0 @@
-comment testing start
-this is foo
-This is how a comment looks: # comment
-comment testing done
-make: "cond1" line 75: warning: extra else
-make: "cond1" line 85: warning: extra else
-2 is  prime
-A='other' B='unknown' C='clever' o='no,no'
-Passed:
- var
- ("var")
- (var != var)
- var != var
- !((var != var) && defined(name))
- var == quoted
-
-1 is not prime
-2 is  prime
-3 is  prime
-4 is not prime
-5 is  prime
-
-make: warning: String comparison operator should be either == or !=
-make: Bad conditional expression `"0" > 0' in "0" > 0?OK:No
-
-OK
-make: "error" line 3: just FYI
-make: "error" line 4: warning: this could be serious
-make: "error" line 5: this is fatal
-UT_DOLLAR=This is $UT_FU
-UT_FOO=foobar is fubar
-UT_FU=fubar
-UT_TEST=export
-UT_ZOO=hoopie
-UT_ALL=even this gets exported
-UT_BADDIR=unit-tests
-UT_DOLLAR=This is $UT_FU
-UT_F=fine
-UT_FOO=foobar is fubar
-UT_FU=fubar
-UT_NO=all
-UT_OK=good
-UT_OKDIR=unit-tests
-UT_TEST=export-all
-UT_ZOO=hoopie
-make:
-UT_TEST=export-env
-UT_ENV=not-exported
-UT_EXP=not-exported
-env:
-UT_TEST=export-env
-UT_ENV=exported
-UT_EXP=exported
-At first, I am
-happy
-and now: sad
-.ERROR: Looks like 'sad' is upset.
-*** Error code 1
-
-Stop.
-make: stopped in unit-tests
-simple.1
-simple.1
-simple.2
-simple.2
-recursive.1.1.*
-recursive.1.1.*
-recursive.1.1.*
-recursive.1.1.*
-recursive.1.99
-recursive.1.99
-recursive.2.1.*
-recursive.2.1.*
-recursive.2.1.*
-recursive.2.1.*
-recursive.2.99
-recursive.2.99
-shared.0
-shared.0
-shared.1.99
-shared.1.99
-shared.2.1
-shared.2.1
-shared.2.99
-shared.2.99
-make: Graph cycles through `cycle.2.99'
-make: Graph cycles through `cycle.2.98'
-make: Graph cycles through `cycle.2.97'
-cycle.1.99
-cycle.1.99
-x=one
-x="two and three"
-x=four
-x="five"
-x=-I/this
-x=-I"This or that"
-x=-Ithat
-x="-DTHIS=\"this and that\""
-cfl=-I/this -I"This or that" -Ithat "-DTHIS=\"this and that\""
-a=one b="two and three"
-a=four b="five"
-a=ONE b="TWO AND THREE"
-a=FOUR b="FIVE"
-We expect an error next:
-make: "forloop" line 38: Wrong number of words (9) in .for substitution list with 2 vars
-make: Fatal errors encountered -- cannot continue
-make: stopped in unit-tests
-OK
-.for with :S;... OK
-b2af338b
-3360ac65
-7747f046
-9ca87054
-880fe816
-208fcbd3
-d5d376eb
-de41416c
-Expect: Unknown modifier 'Z'
-make: Unknown modifier 'Z'
-VAR:Z=
-Expect: Unknown modifier 'Z'
-make: Unknown modifier 'Z'
-VAR:Z=
-Expect: Unclosed variable specification for VAR
-make: Unclosed variable specification (expecting '}') for "VAR" (value "Thevariable") modifier S
-VAR:S,V,v,=Thevariable
-Expect: Unclosed variable specification for VAR
-make: Unclosed variable specification after complex modifier (expecting '}') for VAR
-VAR:S,V,v,=Thevariable
-Expect: Unclosed substitution for VAR (, missing)
-make: Unclosed substitution for VAR (, missing)
-VAR:S,V,v=
-LIB=a X_LIBS:M${LIB${LIB:tu}} is "/tmp/liba.a"
-LIB=a X_LIBS:M*/lib${LIB}.a is "/tmp/liba.a"
-LIB=a X_LIBS:M*/lib${LIB}.a:tu is "/TMP/LIBA.A"
-LIB=b X_LIBS:M${LIB${LIB:tu}} is ""
-LIB=b X_LIBS:M*/lib${LIB}.a is ""
-LIB=b X_LIBS:M*/lib${LIB}.a:tu is ""
-LIB=c X_LIBS:M${LIB${LIB:tu}} is ""
-LIB=c X_LIBS:M*/lib${LIB}.a is ""
-LIB=c X_LIBS:M*/lib${LIB}.a:tu is ""
-LIB=d X_LIBS:M${LIB${LIB:tu}} is "/tmp/libd.a"
-LIB=d X_LIBS:M*/lib${LIB}.a is "/tmp/libd.a"
-LIB=d X_LIBS:M*/lib${LIB}.a:tu is "/TMP/LIBD.A"
-LIB=e X_LIBS:M${LIB${LIB:tu}} is "/tmp/libe.a"
-LIB=e X_LIBS:M*/lib${LIB}.a is "/tmp/libe.a"
-LIB=e X_LIBS:M*/lib${LIB}.a:tu is "/TMP/LIBE.A"
-Mscanner=OK
-path=':/bin:/tmp::/:.:/no/such/dir:.'
-path='/bin:/tmp:/:/no/such/dir'
-path='/bin:/tmp:/:/no/such/dir'
-path='/bin':'/tmp':'/':'/no/such/dir'
-path='/bin':'/tmp':'/':'/no/such/dir'
-path_/usr/xbin=/opt/xbin/
-paths=/bin /tmp / /no/such/dir /opt/xbin
-PATHS=/BIN /TMP / /NO/SUCH/DIR /OPT/XBIN
-The answer is 42
-LIST      = one two three four five six seven eight nine ten
-LIST:O    = eight five four nine one seven six ten three two
-LIST:Ox   = Ok
-LIST:O:Ox = Ok
-LISTX     = Ok
-LISTSX    = Ok
-make: Bad modifier `:OX' for LIST
-BADMOD 1  = }
-make: Bad modifier `:OxXX' for LIST
-BADMOD 2  = XX}
-LIST="one two three four five six"
-LIST:ts,="one,two,three,four,five,six"
-LIST:ts/:tu="ONE/TWO/THREE/FOUR/FIVE/SIX"
-LIST:ts::tu="ONE:TWO:THREE:FOUR:FIVE:SIX"
-LIST:ts:tu="ONETWOTHREEFOURFIVESIX"
-LIST:tu:ts/="ONE/TWO/THREE/FOUR/FIVE/SIX"
-LIST:ts:="one:two:three:four:five:six"
-LIST:ts="onetwothreefourfivesix"
-LIST:ts:S/two/2/="one2threefourfivesix"
-LIST:S/two/2/:ts="one2threefourfivesix"
-LIST:ts/:S/two/2/="one/2/three/four/five/six"
-Pretend the '/' in '/n' etc. below are back-slashes.
-LIST:ts/n="one
-two
-three
-four
-five
-six"
-LIST:ts/t="one	two	three	four	five	six"
-LIST:ts/012:tu="ONE
-TWO
-THREE
-FOUR
-FIVE
-SIX"
-make: Bad modifier `:tx' for LIST
-LIST:tx="}"
-make: Bad modifier `:ts\x' for LIST
-LIST:ts/x:tu="\x:tu}"
-FU_mod-ts="a/b/cool"
-FU_mod-ts:ts:T="cool" == cool?
-B.${AAA:ts}="Baaa" == Baaa?
-make: Bad modifier `:[]' for LIST
-LIST:[]="" is an error
-LIST:[0]="one two three four five six"
-LIST:[0x0]="one two three four five six"
-LIST:[000]="one two three four five six"
-LIST:[*]="one two three four five six"
-LIST:[@]="one two three four five six"
-LIST:[0]:C/ /,/="one,two three four five six"
-LIST:[0]:C/ /,/g="one,two,three,four,five,six"
-LIST:[0]:C/ /,/1g="one,two,three,four,five,six"
-LIST:[*]:C/ /,/="one,two three four five six"
-LIST:[*]:C/ /,/g="one,two,three,four,five,six"
-LIST:[*]:C/ /,/1g="one,two,three,four,five,six"
-LIST:[@]:C/ /,/="one two three four five six"
-LIST:[@]:C/ /,/g="one two three four five six"
-LIST:[@]:C/ /,/1g="one two three four five six"
-LIST:[@]:[0]:C/ /,/="one,two three four five six"
-LIST:[0]:[@]:C/ /,/="one two three four five six"
-LIST:[@]:[*]:C/ /,/="one,two three four five six"
-LIST:[*]:[@]:C/ /,/="one two three four five six"
-EMPTY=""
-EMPTY:[#]="1" == 1 ?
-ESCAPEDSPACE="\ "
-ESCAPEDSPACE:[#]="1" == 1 ?
-REALLYSPACE=" "
-REALLYSPACE:[#]="1" == 1 ?
-LIST:[#]="6"
-LIST:[0]:[#]="1" == 1 ?
-LIST:[*]:[#]="1" == 1 ?
-LIST:[@]:[#]="6"
-LIST:[1]:[#]="1"
-LIST:[1..3]:[#]="3"
-EMPTY:[1]=""
-ESCAPEDSPACE="\ "
-ESCAPEDSPACE:[1]="\ "
-REALLYSPACE=" "
-REALLYSPACE:[1]="" == "" ?
-REALLYSPACE:[*]:[1]=" " == " " ?
-LIST:[1]="one"
-make: Bad modifier `:[1.]' for LIST
-LIST:[1.]="" is an error
-make: Bad modifier `:[1].' for LIST
-LIST:[1].="}" is an error
-LIST:[2]="two"
-LIST:[6]="six"
-LIST:[7]=""
-LIST:[999]=""
-make: Bad modifier `:[-]' for LIST
-LIST:[-]="" is an error
-make: Bad modifier `:[--]' for LIST
-LIST:[--]="" is an error
-LIST:[-1]="six"
-LIST:[-2]="five"
-LIST:[-6]="one"
-LIST:[-7]=""
-LIST:[-999]=""
-LONGLIST:[17]="17"
-LONGLIST:[0x11]="17"
-LONGLIST:[021]="17"
-LIST:[0]:[1]="one two three four five six"
-LIST:[*]:[1]="one two three four five six"
-LIST:[@]:[1]="one"
-LIST:[0]:[2]=""
-LIST:[*]:[2]=""
-LIST:[@]:[2]="two"
-LIST:[*]:C/ /,/:[2]=""
-LIST:[*]:C/ /,/:[*]:[2]=""
-LIST:[*]:C/ /,/:[@]:[2]="three"
-make: Bad modifier `:[1.]' for LIST
-LIST:[1.]="" is an error
-make: Bad modifier `:[1..]' for LIST
-LIST:[1..]="" is an error
-LIST:[1..1]="one"
-make: Bad modifier `:[1..1.]' for LIST
-LIST:[1..1.]="" is an error
-LIST:[1..2]="one two"
-LIST:[2..1]="two one"
-LIST:[3..-2]="three four five"
-LIST:[-4..4]="three four"
-make: Bad modifier `:[0..1]' for LIST
-LIST:[0..1]="" is an error
-make: Bad modifier `:[-1..0]' for LIST
-LIST:[-1..0]="" is an error
-LIST:[-1..1]="six five four three two one"
-LIST:[0..0]="one two three four five six"
-LIST:[3..99]="three four five six"
-LIST:[-3..-99]="four three two one"
-LIST:[-99..-3]="one two three four"
-HASH="#" == "#" ?
-LIST:[${HASH}]="6"
-LIST:[${ZERO}]="one two three four five six"
-LIST:[${ZERO}x${ONE}]="one"
-LIST:[${ONE}]="one"
-LIST:[${MINUSONE}]="six"
-LIST:[${STAR}]="one two three four five six"
-LIST:[${AT}]="one two three four five six"
-make: Bad modifier `:[${EMPTY' for LIST
-LIST:[${EMPTY}]="" is an error
-LIST:[${LONGLIST:[21]:S/2//}]="one"
-LIST:[${LIST:[#]}]="six"
-LIST:[${LIST:[${HASH}]}]="six"
-LIST:S/ /,/="one two three four five six"
-LIST:S/ /,/W="one,two three four five six"
-LIST:S/ /,/gW="one,two,three,four,five,six"
-EMPTY:S/^/,/=","
-EMPTY:S/^/,/W=","
-LIST:C/ /,/="one two three four five six"
-LIST:C/ /,/W="one,two three four five six"
-LIST:C/ /,/gW="one,two,three,four,five,six"
-EMPTY:C/^/,/=","
-EMPTY:C/^/,/W=","
-LIST:tW="one two three four five six"
-LIST:tw="one two three four five six"
-LIST:tW:C/ /,/="one,two three four five six"
-LIST:tW:C/ /,/g="one,two,three,four,five,six"
-LIST:tW:C/ /,/1g="one,two,three,four,five,six"
-LIST:tw:C/ /,/="one two three four five six"
-LIST:tw:C/ /,/g="one two three four five six"
-LIST:tw:C/ /,/1g="one two three four five six"
-LIST:tw:tW:C/ /,/="one,two three four five six"
-LIST:tW:tw:C/ /,/="one two three four five six"
-Making the.c
-Making the.h
-Making the.o from the.h the.c
-.TARGET="phony" .PREFIX="phony" .IMPSRC=""
-.TARGET="all" .PREFIX="all" .IMPSRC=""
-.TARGET="ok" .PREFIX="ok" .IMPSRC=""
-.TARGET="also.ok" .PREFIX="also.ok" .IMPSRC=""
-.TARGET="bug" .PREFIX="bug" .IMPSRC=""
-Posix says we should execute the command as if run by system(3)
-Expect 'Hello,' and 'World!'
-Hello,
-World!
-a command
-a command prefixed by '+' executes even with -n
-another command
-make -n
-echo a command
-echo "a command prefixed by '+' executes even with -n"
-a command prefixed by '+' executes even with -n
-echo another command
-make -n -j1
-{ echo a command 
-} || exit $?
-echo "a command prefixed by '+' executes even with -n"
-a command prefixed by '+' executes even with -n
-{ echo another command 
-} || exit $?
-Now we expect an error...
-*** Error code 1 (continuing)
-`all' not remade because of errors.
-V.i386 ?= OK
-TEST1=hello
-TEST2=bye
-TEST3=later
-FOOBAR =
-FOOBAR = foobar fubar
-fun
-fun
-fun
-In the Sun
-The answer is unknown
-The answer is unknown
-The answer is empty
-The answer is known
-The answer is 
-The answer is empty
-The answer is known
-The answer is 42
-The answer is 42
-UT_DOLLAR=This is $UT_FU
-UT_FU=fubar
-UT_TEST=unexport
-UT_TEST=unexport-env
-default FU=<v>fu</v> FOO=<v>foo</v> VAR=<v></v>
-two FU=<v>bar</v> FOO=<v>goo</v> VAR=<v></v>
-three FU=<v>bar</v> FOO=<v>goo</v> VAR=<v></v>
-four FU=<v>bar</v> FOO=<v>goo</v> VAR=<v>Internal</v>
-five FU=<v>bar</v> FOO=<v>goo</v> VAR=<v>Internal</v>
-five v=is x k=is x
-six v=is y k=is y
-show-v v=override k=override
-*** Error code 1 (ignored)
-*** Error code 1 (ignored)

Deleted: vendor/NetBSD/bmake/dist/unit-tests/unexport
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/unexport	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/unit-tests/unexport	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,8 +0,0 @@
-# $Id: unexport,v 1.1.1.1 2009/11/19 00:31:11 sjg Exp $
-
-# pick up a bunch of exported vars
-.include "export"
-
-.unexport UT_ZOO UT_FOO
-
-UT_TEST = unexport

Deleted: vendor/NetBSD/bmake/dist/unit-tests/unexport-env
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/unexport-env	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/unit-tests/unexport-env	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,14 +0,0 @@
-# $Id: unexport-env,v 1.1.1.1 2009/11/19 00:31:11 sjg Exp $
-
-# pick up a bunch of exported vars
-.include "export"
-
-# an example of setting up a minimal environment.
-PATH = /bin:/usr/bin:/sbin:/usr/sbin
-
-# now clobber the environment to just PATH and UT_TEST
-UT_TEST = unexport-env
-
-# this removes everything
-.unexport-env
-.export PATH UT_TEST

Added: vendor/NetBSD/bmake/dist/unit-tests/unexport-env.exp
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/unexport-env.exp	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/unexport-env.exp	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,2 @@
+UT_TEST=unexport-env
+exit status 0

Added: vendor/NetBSD/bmake/dist/unit-tests/unexport-env.mk
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/unexport-env.mk	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/unexport-env.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,14 @@
+# $Id: unexport-env.mk,v 1.1.1.1 2014/08/30 18:57:18 sjg Exp $
+
+# pick up a bunch of exported vars
+.include "export.mk"
+
+# an example of setting up a minimal environment.
+PATH = /bin:/usr/bin:/sbin:/usr/sbin
+
+# now clobber the environment to just PATH and UT_TEST
+UT_TEST = unexport-env
+
+# this removes everything
+.unexport-env
+.export PATH UT_TEST

Added: vendor/NetBSD/bmake/dist/unit-tests/unexport.exp
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/unexport.exp	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/unexport.exp	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,4 @@
+UT_DOLLAR=This is $UT_FU
+UT_FU=fubar
+UT_TEST=unexport
+exit status 0

Added: vendor/NetBSD/bmake/dist/unit-tests/unexport.mk
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/unexport.mk	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/unexport.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,8 @@
+# $Id: unexport.mk,v 1.1.1.1 2014/08/30 18:57:18 sjg Exp $
+
+# pick up a bunch of exported vars
+.include "export.mk"
+
+.unexport UT_ZOO UT_FOO
+
+UT_TEST = unexport

Deleted: vendor/NetBSD/bmake/dist/unit-tests/varcmd
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/varcmd	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/unit-tests/varcmd	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,49 +0,0 @@
-# $Id: varcmd,v 1.3 2008/05/15 04:30:47 sjg Exp $
-#
-# Test behaviour of recursive make and vars set on command line.
-
-FU=fu
-FOO?=foo
-.if !empty(.TARGETS)
-TAG=${.TARGETS}
-.endif
-TAG?=default
-
-all:	one
-
-show:
-	@echo "${TAG} FU=<v>${FU}</v> FOO=<v>${FOO}</v> VAR=<v>${VAR}</v>"
-
-one:	show
-	@${.MAKE} -f ${MAKEFILE} FU=bar FOO=goo two
-
-two:	show
-	@${.MAKE} -f ${MAKEFILE} three
-
-three:	show
-	@${.MAKE} -f ${MAKEFILE} four
-
-
-.ifmake four
-VAR=Internal
-.MAKEOVERRIDES+= VAR
-.endif
-
-four:	show
-	@${.MAKE} -f ${MAKEFILE} five
-
-M = x
-V.y = is y
-V.x = is x
-V := ${V.$M}
-K := ${V}
-
-show-v:
-	@echo '${TAG} v=${V} k=${K}'
-
-five:	show show-v
-	@${.MAKE} -f ${MAKEFILE} M=y six
-
-six:	show-v
-	@${.MAKE} -f ${MAKEFILE} V=override show-v
-

Added: vendor/NetBSD/bmake/dist/unit-tests/varcmd.exp
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/varcmd.exp	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/varcmd.exp	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,9 @@
+default FU=<v>fu</v> FOO=<v>foo</v> VAR=<v></v>
+two FU=<v>bar</v> FOO=<v>goo</v> VAR=<v></v>
+three FU=<v>bar</v> FOO=<v>goo</v> VAR=<v></v>
+four FU=<v>bar</v> FOO=<v>goo</v> VAR=<v>Internal</v>
+five FU=<v>bar</v> FOO=<v>goo</v> VAR=<v>Internal</v>
+five v=is x k=is x
+six v=is y k=is y
+show-v v=override k=override
+exit status 0

Added: vendor/NetBSD/bmake/dist/unit-tests/varcmd.mk
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/varcmd.mk	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/varcmd.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,49 @@
+# $Id: varcmd.mk,v 1.1.1.1 2014/08/30 18:57:18 sjg Exp $
+#
+# Test behaviour of recursive make and vars set on command line.
+
+FU=fu
+FOO?=foo
+.if !empty(.TARGETS)
+TAG=${.TARGETS}
+.endif
+TAG?=default
+
+all:	one
+
+show:
+	@echo "${TAG} FU=<v>${FU}</v> FOO=<v>${FOO}</v> VAR=<v>${VAR}</v>"
+
+one:	show
+	@${.MAKE} -f ${MAKEFILE} FU=bar FOO=goo two
+
+two:	show
+	@${.MAKE} -f ${MAKEFILE} three
+
+three:	show
+	@${.MAKE} -f ${MAKEFILE} four
+
+
+.ifmake four
+VAR=Internal
+.MAKEOVERRIDES+= VAR
+.endif
+
+four:	show
+	@${.MAKE} -f ${MAKEFILE} five
+
+M = x
+V.y = is y
+V.x = is x
+V := ${V.$M}
+K := ${V}
+
+show-v:
+	@echo '${TAG} v=${V} k=${K}'
+
+five:	show show-v
+	@${.MAKE} -f ${MAKEFILE} M=y six
+
+six:	show-v
+	@${.MAKE} -f ${MAKEFILE} V=override show-v
+

Added: vendor/NetBSD/bmake/dist/unit-tests/varmisc.exp
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/varmisc.exp	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/varmisc.exp	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,25 @@
+
+:D expanded when var set
+true
+TRUE
+:U expanded when var undef
+true
+TRUE
+:D skipped if var undef
+
+:U skipped when var set
+is set
+:? only lhs when value true
+true
+TRUE
+:? only rhs when value false
+false
+FALSE
+do not evaluate or expand :? if discarding
+is set
+year=2016 month=04 day=01
+date=20160401
+Version=123.456.789 == 123456789
+Literal=3.4.5 == 3004005
+We have target specific vars
+exit status 0

Added: vendor/NetBSD/bmake/dist/unit-tests/varmisc.mk
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/varmisc.mk	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/varmisc.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,62 @@
+# $Id: varmisc.mk,v 1.9 2017/02/01 18:44:54 sjg Exp $
+#
+# Miscellaneous variable tests.
+
+all: unmatched_var_paren D_true U_true D_false U_false Q_lhs Q_rhs NQ_none \
+	strftime cmpv
+
+unmatched_var_paren:
+	@echo ${foo::=foo-text}
+
+True = ${echo true >&2:L:sh}TRUE
+False= ${echo false >&2:L:sh}FALSE
+
+VSET= is set
+.undef UNDEF
+
+U_false:
+	@echo :U skipped when var set
+	@echo ${VSET:U${False}}
+
+D_false:
+	@echo :D skipped if var undef
+	@echo ${UNDEF:D${False}}
+
+U_true:
+	@echo :U expanded when var undef
+	@echo ${UNDEF:U${True}}
+
+D_true:
+	@echo :D expanded when var set
+	@echo ${VSET:D${True}}
+
+Q_lhs:
+	@echo :? only lhs when value true
+	@echo ${1:L:?${True}:${False}}
+
+Q_rhs:
+	@echo :? only rhs when value false
+	@echo ${0:L:?${True}:${False}}
+
+NQ_none:
+	@echo do not evaluate or expand :? if discarding
+	@echo ${VSET:U${1:L:?${True}:${False}}}
+
+April1= 1459494000
+
+# slightly contorted syntax to use utc via variable
+strftime:
+	@echo ${year=%Y month=%m day=%d:L:gmtime=1459494000}
+	@echo date=${%Y%m%d:L:${gmtime=${April1}:L}}
+
+# big jumps to handle 3 digits per step
+M_cmpv.units = 1 1000 1000000
+M_cmpv = S,., ,g:_:range:@i at + $${_:[-$$i]} \* $${M_cmpv.units:[$$i]}@:S,^,expr 0 ,1:sh
+
+Version = 123.456.789
+cmpv.only = target specific vars
+
+cmpv:
+	@echo Version=${Version} == ${Version:${M_cmpv}}
+	@echo Literal=3.4.5 == ${3.4.5:L:${M_cmpv}}
+	@echo We have ${${.TARGET:T}.only}

Added: vendor/NetBSD/bmake/dist/unit-tests/varshell.exp
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/varshell.exp	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/varshell.exp	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,10 @@
+make: "varshell.mk" line 5: warning: "/bin/no/such/command 2> /dev/null" returned non-zero status
+make: "varshell.mk" line 8: warning: "false" returned non-zero status
+make: "varshell.mk" line 9: warning: "echo "output before the error"; false" returned non-zero status
+EXEC_FAILED=''
+TERMINATED_BY_SIGNAL=''
+ERROR_NO_OUTPUT=''
+ERROR_WITH_OUTPUT='output before the error'
+NO_ERROR_NO_OUTPUT=''
+NO_ERROR_WITH_OUTPUT='this is good'
+exit status 0

Added: vendor/NetBSD/bmake/dist/unit-tests/varshell.mk
===================================================================
--- vendor/NetBSD/bmake/dist/unit-tests/varshell.mk	                        (rev 0)
+++ vendor/NetBSD/bmake/dist/unit-tests/varshell.mk	2018-06-27 00:17:22 UTC (rev 11138)
@@ -0,0 +1,19 @@
+# $Id: varshell.mk,v 1.4 2015/04/20 03:16:39 sjg Exp $
+#
+# Test VAR != shell command
+
+EXEC_FAILED		!= /bin/no/such/command 2> /dev/null
+# SunOS cannot handle this one
+#TERMINATED_BY_SIGNAL	!= kill -14 $$$$
+ERROR_NO_OUTPUT		!= false
+ERROR_WITH_OUTPUT	!= echo "output before the error"; false
+NO_ERROR_NO_OUTPUT	!= true
+NO_ERROR_WITH_OUTPUT	!= echo "this is good"
+
+allvars= EXEC_FAILED TERMINATED_BY_SIGNAL ERROR_NO_OUTPUT ERROR_WITH_OUTPUT \
+	NO_ERROR_NO_OUTPUT NO_ERROR_WITH_OUTPUT
+
+all:
+.for v in ${allvars}
+	@echo ${v}=\'${${v}}\'
+.endfor

Modified: vendor/NetBSD/bmake/dist/var.c
===================================================================
--- vendor/NetBSD/bmake/dist/var.c	2018-06-27 00:14:22 UTC (rev 11137)
+++ vendor/NetBSD/bmake/dist/var.c	2018-06-27 00:17:22 UTC (rev 11138)
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.186 2014/06/20 06:13:45 sjg Exp $	*/
+/*	$NetBSD: var.c,v 1.215 2017/04/16 21:39:49 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.186 2014/06/20 06:13:45 sjg Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.215 2017/04/16 21:39:49 riastradh Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
@@ -76,7 +76,7 @@
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.186 2014/06/20 06:13:45 sjg Exp $");
+__RCSID("$NetBSD: var.c,v 1.215 2017/04/16 21:39:49 riastradh Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -129,7 +129,6 @@
 #include    <regex.h>
 #endif
 #include    <ctype.h>
-#include    <inttypes.h>
 #include    <stdlib.h>
 #include    <limits.h>
 #include    <time.h>
@@ -138,6 +137,7 @@
 #include    "buf.h"
 #include    "dir.h"
 #include    "job.h"
+#include    "metachar.h"
 
 extern int makelevel;
 /*
@@ -154,13 +154,23 @@
 char 	var_Error[] = "";
 
 /*
- * Similar to var_Error, but returned when the 'errnum' flag for Var_Parse is
- * set false. Why not just use a constant? Well, gcc likes to condense
- * identical string instances...
+ * Similar to var_Error, but returned when the 'VARF_UNDEFERR' flag for
+ * Var_Parse is not set. Why not just use a constant? Well, gcc likes
+ * to condense identical string instances...
  */
 static char	varNoError[] = "";
 
 /*
+ * Traditionally we consume $$ during := like any other expansion.
+ * Other make's do not.
+ * This knob allows controlling the behavior.
+ * FALSE for old behavior.
+ * TRUE for new compatible.
+ */
+#define SAVE_DOLLARS ".MAKE.SAVE_DOLLARS"
+static Boolean save_dollars = FALSE;
+
+/*
  * Internally, variables are contained in four different contexts.
  *	1) the environment. They may not be changed. If an environment
  *	    variable is appended-to, the result is placed in the global
@@ -216,7 +226,11 @@
  * We pass this to Var_Export when doing the initial export
  * or after updating an exported var.
  */
-#define VAR_EXPORT_PARENT 1
+#define VAR_EXPORT_PARENT	1
+/*
+ * We pass this to Var_Export1 to tell it to leave the value alone.
+ */
+#define VAR_EXPORT_LITERAL	2
 
 /* Var*Pattern flags */
 #define VAR_SUB_GLOBAL	0x01	/* Apply substitution globally */
@@ -516,7 +530,7 @@
     h = Hash_CreateEntry(&ctxt->context, name, NULL);
     Hash_SetValue(h, v);
     v->name = h->name;
-    if (DEBUG(VAR)) {
+    if (DEBUG(VAR) && (ctxt->flags & INTERNAL) == 0) {
 	fprintf(debug_file, "%s:%s = %s\n", ctxt->name, name, val);
     }
 }
@@ -541,7 +555,7 @@
     char *cp;
     
     if (strchr(name, '$')) {
-	cp = Var_Subst(NULL, name, VAR_GLOBAL, 0);
+	cp = Var_Subst(NULL, name, VAR_GLOBAL, VARF_WANTRES);
     } else {
 	cp = (char *)name;
     }
@@ -580,12 +594,13 @@
  * We only manipulate flags of vars if 'parent' is set.
  */
 static int
-Var_Export1(const char *name, int parent)
+Var_Export1(const char *name, int flags)
 {
     char tmp[BUFSIZ];
     Var *v;
     char *val = NULL;
     int n;
+    int parent = (flags & VAR_EXPORT_PARENT);
 
     if (*name == '.')
 	return 0;			/* skip internals */
@@ -613,7 +628,7 @@
 	return 0;			/* nothing to do */
     }
     val = Buf_GetAll(&v->val, NULL);
-    if (strchr(val, '$')) {
+    if ((flags & VAR_EXPORT_LITERAL) == 0 && strchr(val, '$')) {
 	if (parent) {
 	    /*
 	     * Flag this as something we need to re-export.
@@ -632,7 +647,7 @@
 	}
 	n = snprintf(tmp, sizeof(tmp), "${%s}", name);
 	if (n < (int)sizeof(tmp)) {
-	    val = Var_Subst(NULL, tmp, VAR_GLOBAL, 0);
+	    val = Var_Subst(NULL, tmp, VAR_GLOBAL, VARF_WANTRES);
 	    setenv(name, val, 1);
 	    free(val);
 	}
@@ -700,14 +715,16 @@
 	int ac;
 	int i;
 
-	val = Var_Subst(NULL, tmp, VAR_GLOBAL, 0);
-	av = brk_string(val, &ac, FALSE, &as);
-	for (i = 0; i < ac; i++) {
-	    Var_Export1(av[i], 0);
+	val = Var_Subst(NULL, tmp, VAR_GLOBAL, VARF_WANTRES);
+	if (*val) {
+	    av = brk_string(val, &ac, FALSE, &as);
+	    for (i = 0; i < ac; i++) {
+		Var_Export1(av[i], 0);
+	    }
+	    free(as);
+	    free(av);
 	}
 	free(val);
-	free(as);
-	free(av);
     }
 }
 
@@ -723,7 +740,7 @@
     char *val;
     char **av;
     char *as;
-    int track;
+    int flags;
     int ac;
     int i;
 
@@ -732,42 +749,47 @@
 	return;
     }
 
+    flags = 0;
     if (strncmp(str, "-env", 4) == 0) {
-	track = 0;
 	str += 4;
+    } else if (strncmp(str, "-literal", 8) == 0) {
+	str += 8;
+	flags |= VAR_EXPORT_LITERAL;
     } else {
-	track = VAR_EXPORT_PARENT;
+	flags |= VAR_EXPORT_PARENT;
     }
-    val = Var_Subst(NULL, str, VAR_GLOBAL, 0);
-    av = brk_string(val, &ac, FALSE, &as);
-    for (i = 0; i < ac; i++) {
-	name = av[i];
-	if (!name[1]) {
-	    /*
-	     * A single char.
-	     * If it is one of the vars that should only appear in
-	     * local context, skip it, else we can get Var_Subst
-	     * into a loop.
-	     */
-	    switch (name[0]) {
-	    case '@':
-	    case '%':
-	    case '*':
-	    case '!':
-		continue;
+    val = Var_Subst(NULL, str, VAR_GLOBAL, VARF_WANTRES);
+    if (*val) {
+	av = brk_string(val, &ac, FALSE, &as);
+	for (i = 0; i < ac; i++) {
+	    name = av[i];
+	    if (!name[1]) {
+		/*
+		 * A single char.
+		 * If it is one of the vars that should only appear in
+		 * local context, skip it, else we can get Var_Subst
+		 * into a loop.
+		 */
+		switch (name[0]) {
+		case '@':
+		case '%':
+		case '*':
+		case '!':
+		    continue;
+		}
 	    }
-	}
-	if (Var_Export1(name, track)) {
-	    if (VAR_EXPORTED_ALL != var_exportedVars)
-		var_exportedVars = VAR_EXPORTED_YES;
-	    if (isExport && track) {
-		Var_Append(MAKE_EXPORTED, name, VAR_GLOBAL);
+	    if (Var_Export1(name, flags)) {
+		if (VAR_EXPORTED_ALL != var_exportedVars)
+		    var_exportedVars = VAR_EXPORTED_YES;
+		if (isExport && (flags & VAR_EXPORT_PARENT)) {
+		    Var_Append(MAKE_EXPORTED, name, VAR_GLOBAL);
+		}
 	    }
 	}
+	free(as);
+	free(av);
     }
     free(val);
-    free(as);
-    free(av);
 }
 
 
@@ -826,7 +848,7 @@
 	/* Using .MAKE.EXPORTED */
 	n = snprintf(tmp, sizeof(tmp), "${" MAKE_EXPORTED ":O:u}");
 	if (n < (int)sizeof(tmp)) {
-	    vlist = Var_Subst(NULL, tmp, VAR_GLOBAL, 0);
+	    vlist = Var_Subst(NULL, tmp, VAR_GLOBAL, VARF_WANTRES);
 	}
     }
     if (vlist) {
@@ -856,7 +878,7 @@
 		n = snprintf(tmp, sizeof(tmp),
 			     "${" MAKE_EXPORTED ":N%s}", v->name);
 		if (n < (int)sizeof(tmp)) {
-		    cp = Var_Subst(NULL, tmp, VAR_GLOBAL, 0);
+		    cp = Var_Subst(NULL, tmp, VAR_GLOBAL, VARF_WANTRES);
 		    Var_Set(MAKE_EXPORTED, cp, VAR_GLOBAL, 0);
 		    free(cp);
 		}
@@ -911,7 +933,7 @@
      * point in searching them all just to save a bit of memory...
      */
     if (strchr(name, '$') != NULL) {
-	expanded_name = Var_Subst(NULL, name, ctxt, 0);
+	expanded_name = Var_Subst(NULL, name, ctxt, VARF_WANTRES);
 	if (expanded_name[0] == 0) {
 	    if (DEBUG(VAR)) {
 		fprintf(debug_file, "Var_Set(\"%s\", \"%s\", ...) "
@@ -979,10 +1001,13 @@
 
 	Var_Append(MAKEOVERRIDES, name, VAR_GLOBAL);
     }
-	
+    if (*name == '.') {
+	if (strcmp(name, SAVE_DOLLARS) == 0)
+	    save_dollars = s2Boolean(val, save_dollars);
+    }
+
  out:
-    if (expanded_name != NULL)
-	free(expanded_name);
+    free(expanded_name);
     if (v != NULL)
 	VarFreeEnv(v, TRUE);
 }
@@ -1022,7 +1047,7 @@
     char *expanded_name = NULL;
 
     if (strchr(name, '$') != NULL) {
-	expanded_name = Var_Subst(NULL, name, ctxt, 0);
+	expanded_name = Var_Subst(NULL, name, ctxt, VARF_WANTRES);
 	if (expanded_name[0] == 0) {
 	    if (DEBUG(VAR)) {
 		fprintf(debug_file, "Var_Append(\"%s\", \"%s\", ...) "
@@ -1060,8 +1085,7 @@
 	    Hash_SetValue(h, v);
 	}
     }
-    if (expanded_name != NULL)
-	free(expanded_name);
+    free(expanded_name);
 }
 
 /*-
@@ -1088,12 +1112,10 @@
     char          *cp;
 
     if ((cp = strchr(name, '$')) != NULL) {
-	cp = Var_Subst(NULL, name, ctxt, FALSE);
+	cp = Var_Subst(NULL, name, ctxt, VARF_WANTRES);
     }
     v = VarFind(cp ? cp : name, ctxt, FIND_CMD|FIND_GLOBAL|FIND_ENV);
-    if (cp != NULL) {
-	free(cp);
-    }
+    free(cp);
     if (v == NULL) {
 	return(FALSE);
     } else {
@@ -1159,7 +1181,7 @@
 static Boolean
 VarHead(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate,
 	char *word, Boolean addSpace, Buffer *buf,
-	void *dummy)
+	void *dummy MAKE_ATTR_UNUSED)
 {
     char *slash;
 
@@ -1180,7 +1202,7 @@
 	    Buf_AddByte(buf, vpstate->varSpace);
 	Buf_AddByte(buf, '.');
     }
-    return(dummy ? TRUE : TRUE);
+    return TRUE;
 }
 
 /*-
@@ -1207,7 +1229,7 @@
 static Boolean
 VarTail(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate,
 	char *word, Boolean addSpace, Buffer *buf,
-	void *dummy)
+	void *dummy MAKE_ATTR_UNUSED)
 {
     char *slash;
 
@@ -1223,7 +1245,7 @@
     } else {
 	Buf_AddBytes(buf, strlen(word), word);
     }
-    return (dummy ? TRUE : TRUE);
+    return TRUE;
 }
 
 /*-
@@ -1249,7 +1271,7 @@
 static Boolean
 VarSuffix(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate,
 	  char *word, Boolean addSpace, Buffer *buf,
-	  void *dummy)
+	  void *dummy MAKE_ATTR_UNUSED)
 {
     char *dot;
 
@@ -1263,7 +1285,7 @@
 	dot[-1] = '.';
 	addSpace = TRUE;
     }
-    return (dummy ? addSpace : addSpace);
+    return addSpace;
 }
 
 /*-
@@ -1290,7 +1312,7 @@
 static Boolean
 VarRoot(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate,
 	char *word, Boolean addSpace, Buffer *buf,
-	void *dummy)
+	void *dummy MAKE_ATTR_UNUSED)
 {
     char *dot;
 
@@ -1306,7 +1328,7 @@
     } else {
 	Buf_AddBytes(buf, strlen(word), word);
     }
-    return (dummy ? TRUE : TRUE);
+    return TRUE;
 }
 
 /*-
@@ -1388,7 +1410,7 @@
     addSpace = TRUE;
 
     if ((ptr = Str_SYSVMatch(word, pat->lhs, &len)) != NULL) {
-        varexp = Var_Subst(NULL, pat->rhs, ctx, 0);
+        varexp = Var_Subst(NULL, pat->rhs, ctx, VARF_WANTRES);
 	Str_SYSVSubst(buf, varexp, ptr, len);
 	free(varexp);
     } else {
@@ -1628,14 +1650,14 @@
  *-----------------------------------------------------------------------
  */
 static void
-VarREError(int errnum, regex_t *pat, const char *str)
+VarREError(int reerr, regex_t *pat, const char *str)
 {
     char *errbuf;
     int errlen;
 
-    errlen = regerror(errnum, pat, 0, 0);
+    errlen = regerror(reerr, pat, 0, 0);
     errbuf = bmake_malloc(errlen);
-    regerror(errnum, pat, errbuf, errlen);
+    regerror(reerr, pat, errbuf, errlen);
     Error("%s: %s", str, errbuf);
     free(errbuf);
 }
@@ -1808,14 +1830,14 @@
 
     if (word && *word) {
         Var_Set(loop->tvar, word, loop->ctxt, VAR_NO_EXPORT);
-        s = Var_Subst(NULL, loop->str, loop->ctxt, loop->errnum);
+        s = Var_Subst(NULL, loop->str, loop->ctxt, loop->errnum | VARF_WANTRES);
         if (s != NULL && *s != '\0') {
             if (addSpace && *s != '\n')
                 Buf_AddByte(buf, ' ');
             Buf_AddBytes(buf, (slen = strlen(s)), s);
             addSpace = (slen > 0 && s[slen - 1] != '\n');
-            free(s);
         }
+	free(s);
     }
     return addSpace;
 }
@@ -1928,7 +1950,7 @@
 	    Buf_AddByte(buf, vpstate->varSpace);
 	}
 	addSpace = TRUE;
-	rp = realpath(word, rbuf);
+	rp = cached_realpath(word, rbuf);
 	if (rp && *rp == '/' && stat(rp, &st) == 0)
 		word = rp;
 	
@@ -2117,7 +2139,52 @@
     return Buf_Destroy(&buf, FALSE);
 }
 
+/*-
+ *-----------------------------------------------------------------------
+ * VarRange --
+ *	Return an integer sequence
+ *
+ * Input:
+ *	str		String whose words provide default range
+ *	ac		range length, if 0 use str words
+ *
+ * Side Effects:
+ *	None.
+ *
+ *-----------------------------------------------------------------------
+ */
+static char *
+VarRange(const char *str, int ac)
+{
+    Buffer	  buf;		    /* Buffer for new string */
+    char	  tmp[32];	    /* each element */
+    char 	**av;		    /* List of words to affect */
+    char 	 *as;		    /* Word list memory */
+    int 	  i, n;
 
+    Buf_Init(&buf, 0);
+    if (ac > 0) {
+	as = NULL;
+	av = NULL;
+    } else {
+	av = brk_string(str, &ac, FALSE, &as);
+    }
+    for (i = 0; i < ac; i++) {
+	n = snprintf(tmp, sizeof(tmp), "%d", 1 + i);
+	if (n >= (int)sizeof(tmp))
+	    break;
+	Buf_AddBytes(&buf, n, tmp);
+	if (i != ac - 1)
+	    Buf_AddByte(&buf, ' ');
+    }
+
+    free(as);
+    free(av);
+
+    return Buf_Destroy(&buf, FALSE);
+}
+
+
 /*-
  *-----------------------------------------------------------------------
  * VarGetPattern --
@@ -2142,7 +2209,7 @@
  */
 static char *
 VarGetPattern(GNode *ctxt, Var_Parse_State *vpstate MAKE_ATTR_UNUSED,
-	      int errnum, const char **tstr, int delim, int *flags,
+	      int flags, const char **tstr, int delim, int *vflags,
 	      int *length, VarPattern *pattern)
 {
     const char *cp;
@@ -2149,6 +2216,7 @@
     char *rstr;
     Buffer buf;
     int junk;
+    int errnum = flags & VARF_UNDEFERR;
 
     Buf_Init(&buf, 0);
     if (length == NULL)
@@ -2170,7 +2238,7 @@
 	    cp++;
 	} else if (*cp == '$') {
 	    if (cp[1] == delim) {
-		if (flags == NULL)
+		if (vflags == NULL)
 		    Buf_AddByte(&buf, *cp);
 		else
 		    /*
@@ -2177,9 +2245,9 @@
 		     * Unescaped $ at end of pattern => anchor
 		     * pattern at end.
 		     */
-		    *flags |= VAR_MATCH_END;
+		    *vflags |= VAR_MATCH_END;
 	    } else {
-		if (flags == NULL || (*flags & VAR_NOSUBST) == 0) {
+		if (vflags == NULL || (*vflags & VAR_NOSUBST) == 0) {
 		    char   *cp2;
 		    int     len;
 		    void   *freeIt;
@@ -2189,10 +2257,10 @@
 		     * delimiter, assume it's a variable
 		     * substitution and recurse.
 		     */
-		    cp2 = Var_Parse(cp, ctxt, errnum, &len, &freeIt);
+		    cp2 = Var_Parse(cp, ctxt, errnum | VARF_WANTRES, &len,
+			&freeIt);
 		    Buf_AddBytes(&buf, strlen(cp2), cp2);
-		    if (freeIt)
-			free(freeIt);
+		    free(freeIt);
 		    cp += len - 1;
 		} else {
 		    const char *cp2 = &cp[1];
@@ -2245,7 +2313,7 @@
 /*-
  *-----------------------------------------------------------------------
  * VarQuote --
- *	Quote shell meta-characters in the string
+ *	Quote shell meta-characters and space characters in the string
  *
  * Results:
  *	The quoted string
@@ -2260,10 +2328,8 @@
 {
 
     Buffer  	  buf;
-    /* This should cover most shells :-( */
-    static const char meta[] = "\n \t'`\";&<>()|*?{}[]\\$!#^~";
     const char	*newline;
-    size_t len, nlen;
+    size_t nlen;
 
     if ((newline = Shell_GetNewline()) == NULL)
 	    newline = "\\\n";
@@ -2270,19 +2336,17 @@
     nlen = strlen(newline);
 
     Buf_Init(&buf, 0);
-    while (*str != '\0') {
-	if ((len = strcspn(str, meta)) != 0) {
-	    Buf_AddBytes(&buf, len, str);
-	    str += len;
-	} else if (*str == '\n') {
+
+    for (; *str != '\0'; str++) {
+	if (*str == '\n') {
 	    Buf_AddBytes(&buf, nlen, newline);
-	    ++str;
-	} else {
+	    continue;
+	}
+	if (isspace((unsigned char)*str) || ismeta((unsigned char)*str))
 	    Buf_AddByte(&buf, '\\');
-	    Buf_AddByte(&buf, *str);
-	    ++str;
-	}
+	Buf_AddByte(&buf, *str);
     }
+
     str = Buf_Destroy(&buf, FALSE);
     if (DEBUG(VAR))
 	fprintf(debug_file, "QuoteMeta: [%s]\n", str);
@@ -2313,7 +2377,7 @@
     Buffer         buf;
     size_t         len, len2;
     unsigned char  *ustr = (unsigned char *)str;
-    uint32_t       h, k, c1, c2;
+    unsigned int   h, k, c1, c2;
 
     h  = 0x971e137bU;
     c1 = 0x95543787U;
@@ -2361,12 +2425,12 @@
 }
 
 static char *
-VarStrftime(const char *fmt, int zulu)
+VarStrftime(const char *fmt, int zulu, time_t utc)
 {
     char buf[BUFSIZ];
-    time_t utc;
 
-    time(&utc);
+    if (!utc)
+	time(&utc);
     if (!*fmt)
 	fmt = "%c";
     strftime(buf, sizeof(buf), fmt, zulu ? gmtime(&utc) : localtime(&utc));
@@ -2463,11 +2527,14 @@
 /* we now have some modifiers with long names */
 #define STRMOD_MATCH(s, want, n) \
     (strncmp(s, want, n) == 0 && (s[n] == endc || s[n] == ':'))
+#define STRMOD_MATCHX(s, want, n) \
+    (strncmp(s, want, n) == 0 && (s[n] == endc || s[n] == ':' || s[n] == '='))
+#define CHARMOD_MATCH(c) (c == endc || c == ':')
 
 static char *
 ApplyModifiers(char *nstr, const char *tstr,
 	       int startc, int endc,
-	       Var *v, GNode *ctxt, Boolean errnum,
+	       Var *v, GNode *ctxt, int flags,
 	       int *lengthPtr, void **freePtr)
 {
     const char 	   *start;
@@ -2474,6 +2541,7 @@
     const char     *cp;    	/* Secondary pointer into str (place marker
 				 * for tstr) */
     char	   *newStr;	/* New value to return */
+    char	   *ep;
     char	    termc;	/* Character which terminated scan */
     int             cnt;	/* Used to count brace pairs when variable in
 				 * in parens or braces */
@@ -2480,6 +2548,7 @@
     char	delim;
     int		modifier;	/* that we are processing */
     Var_Parse_State parsestate; /* Flags passed to helper functions */
+    time_t	utc;		/* for VarStrftime */
 
     delim = '\0';
     parsestate.oneBigWord = FALSE;
@@ -2498,7 +2567,7 @@
 	    int rlen;
 	    int c;
 
-	    rval = Var_Parse(tstr, ctxt, errnum, &rlen, &freeIt);
+	    rval = Var_Parse(tstr, ctxt, flags, &rlen, &freeIt);
 
 	    /*
 	     * If we have not parsed up to endc or ':',
@@ -2508,8 +2577,7 @@
 		(c = tstr[rlen]) != '\0' &&
 		c != ':' &&
 		c != endc) {
-		if (freeIt)
-		    free(freeIt);
+		free(freeIt);
 		goto apply_mods;
 	    }
 
@@ -2524,18 +2592,15 @@
 		int used;
 
 		nstr = ApplyModifiers(nstr, rval,
-				      0, 0,
-				      v, ctxt, errnum, &used, freePtr);
+				      0, 0, v, ctxt, flags, &used, freePtr);
 		if (nstr == var_Error
-		    || (nstr == varNoError && errnum == 0)
+		    || (nstr == varNoError && (flags & VARF_UNDEFERR) == 0)
 		    || strlen(rval) != (size_t) used) {
-		    if (freeIt)
-			free(freeIt);
+		    free(freeIt);
 		    goto out;		/* error already reported */
 		}
 	    }
-	    if (freeIt)
-		free(freeIt);
+	    free(freeIt);
 	    if (*tstr == ':')
 		tstr++;
 	    else if (!*tstr && endc) {
@@ -2564,6 +2629,7 @@
 		    char *sv_name;
 		    VarPattern	pattern;
 		    int	how;
+		    int vflags;
 
 		    if (v->name[0] == 0)
 			goto bad_modifier;
@@ -2599,8 +2665,9 @@
 		    delim = startc == PROPEN ? PRCLOSE : BRCLOSE;
 		    pattern.flags = 0;
 
-		    pattern.rhs = VarGetPattern(ctxt, &parsestate, errnum,
-						&cp, delim, NULL,
+		    vflags = (flags & VARF_WANTRES) ? 0 : VAR_NOSUBST;
+		    pattern.rhs = VarGetPattern(ctxt, &parsestate, flags,
+						&cp, delim, &vflags,
 						&pattern.rightLen,
 						NULL);
 		    if (v->flags & VAR_JUNK) {
@@ -2614,26 +2681,27 @@
 		    termc = *--cp;
 		    delim = '\0';
 
-		    switch (how) {
-		    case '+':
-			Var_Append(v->name, pattern.rhs, v_ctxt);
-			break;
-		    case '!':
-			newStr = Cmd_Exec(pattern.rhs, &emsg);
-			if (emsg)
-			    Error(emsg, nstr);
-			else
-			    Var_Set(v->name, newStr,  v_ctxt, 0);
-			if (newStr)
+		    if (flags & VARF_WANTRES) {
+			switch (how) {
+			case '+':
+			    Var_Append(v->name, pattern.rhs, v_ctxt);
+			    break;
+			case '!':
+			    newStr = Cmd_Exec(pattern.rhs, &emsg);
+			    if (emsg)
+				Error(emsg, nstr);
+			    else
+				Var_Set(v->name, newStr,  v_ctxt, 0);
 			    free(newStr);
-			break;
-		    case '?':
-			if ((v->flags & VAR_JUNK) == 0)
 			    break;
-			/* FALLTHROUGH */
-		    default:
-			Var_Set(v->name, pattern.rhs, v_ctxt, 0);
-			break;
+			case '?':
+			    if ((v->flags & VAR_JUNK) == 0)
+				break;
+			    /* FALLTHROUGH */
+			default:
+			    Var_Set(v->name, pattern.rhs, v_ctxt, 0);
+			    break;
+			}
 		    }
 		    free(UNCONST(pattern.rhs));
 		    newStr = varNoError;
@@ -2644,19 +2712,19 @@
 	case '@':
 	    {
 		VarLoop_t	loop;
-		int flags = VAR_NOSUBST;
+		int vflags = VAR_NOSUBST;
 
 		cp = ++tstr;
 		delim = '@';
-		if ((loop.tvar = VarGetPattern(ctxt, &parsestate, errnum,
+		if ((loop.tvar = VarGetPattern(ctxt, &parsestate, flags,
 					       &cp, delim,
-					       &flags, &loop.tvarLen,
+					       &vflags, &loop.tvarLen,
 					       NULL)) == NULL)
 		    goto cleanup;
 
-		if ((loop.str = VarGetPattern(ctxt, &parsestate, errnum,
+		if ((loop.str = VarGetPattern(ctxt, &parsestate, flags,
 					      &cp, delim,
-					      &flags, &loop.strLen,
+					      &vflags, &loop.strLen,
 					      NULL)) == NULL)
 		    goto cleanup;
 
@@ -2663,20 +2731,54 @@
 		termc = *cp;
 		delim = '\0';
 
-		loop.errnum = errnum;
+		loop.errnum = flags & VARF_UNDEFERR;
 		loop.ctxt = ctxt;
 		newStr = VarModify(ctxt, &parsestate, nstr, VarLoopExpand,
 				   &loop);
+		Var_Delete(loop.tvar, ctxt);
 		free(loop.tvar);
 		free(loop.str);
 		break;
 	    }
+	case '_':			/* remember current value */
+	    cp = tstr + 1;	/* make sure it is set */
+	    if (STRMOD_MATCHX(tstr, "_", 1)) {
+		if (tstr[1] == '=') {
+		    char *np;
+		    int n;
+
+		    cp++;
+		    n = strcspn(cp, ":)}");
+		    np = bmake_strndup(cp, n+1);
+		    np[n] = '\0';
+		    cp = tstr + 2 + n;
+		    Var_Set(np, nstr, ctxt, 0);
+		    free(np);
+		} else {
+		    Var_Set("_", nstr, ctxt, 0);
+		}
+		newStr = nstr;
+		termc = *cp;
+		break;
+	    }
+	    goto default_case;
 	case 'D':
 	case 'U':
 	    {
 		Buffer  buf;    	/* Buffer for patterns */
-		int	    wantit;	/* want data in buffer */
+		int	nflags;
 
+		if (flags & VARF_WANTRES) {
+		    int wantres;
+		    if (*tstr == 'U')
+			wantres = ((v->flags & VAR_JUNK) != 0);
+		    else
+			wantres = ((v->flags & VAR_JUNK) == 0);
+		    nflags = flags & ~VARF_WANTRES;
+		    if (wantres)
+			nflags |= VARF_WANTRES;
+		} else
+		    nflags = flags;
 		/*
 		 * Pass through tstr looking for 1) escaped delimiters,
 		 * '$'s and backslashes (place the escaped character in
@@ -2705,10 +2807,9 @@
 			    int	    len;
 			    void    *freeIt;
 
-			    cp2 = Var_Parse(cp, ctxt, errnum, &len, &freeIt);
+			    cp2 = Var_Parse(cp, ctxt, nflags, &len, &freeIt);
 			    Buf_AddBytes(&buf, strlen(cp2), cp2);
-			    if (freeIt)
-				free(freeIt);
+			    free(freeIt);
 			    cp += len - 1;
 			} else {
 			    Buf_AddByte(&buf, *cp);
@@ -2717,13 +2818,9 @@
 
 		termc = *cp;
 
-		if (*tstr == 'U')
-		    wantit = ((v->flags & VAR_JUNK) != 0);
-		else
-		    wantit = ((v->flags & VAR_JUNK) == 0);
 		if ((v->flags & VAR_JUNK) != 0)
 		    v->flags |= VAR_KEEP;
-		if (wantit) {
+		if (nflags & VARF_WANTRES) {
 		    newStr = Buf_Destroy(&buf, FALSE);
 		} else {
 		    newStr = nstr;
@@ -2768,14 +2865,17 @@
 		pattern.flags = 0;
 
 		delim = '!';
-
+		emsg = NULL;
 		cp = ++tstr;
-		if ((pattern.rhs = VarGetPattern(ctxt, &parsestate, errnum,
+		if ((pattern.rhs = VarGetPattern(ctxt, &parsestate, flags,
 						 &cp, delim,
 						 NULL, &pattern.rightLen,
 						 NULL)) == NULL)
 		    goto cleanup;
-		newStr = Cmd_Exec(pattern.rhs, &emsg);
+		if (flags & VARF_WANTRES)
+		    newStr = Cmd_Exec(pattern.rhs, &emsg);
+		else
+		    newStr = varNoError;
 		free(UNCONST(pattern.rhs));
 		if (emsg)
 		    Error(emsg, nstr);
@@ -2800,7 +2900,7 @@
 		cp = tstr+1; /* point to char after '[' */
 		delim = ']'; /* look for closing ']' */
 		estr = VarGetPattern(ctxt, &parsestate,
-				     errnum, &cp, delim,
+				     flags, &cp, delim,
 				     NULL, NULL, NULL);
 		if (estr == NULL)
 		    goto cleanup; /* report missing ']' */
@@ -2867,8 +2967,6 @@
 		     * integer for :[N], or two integers
 		     * separated by ".." for :[start..end].
 		     */
-		    char *ep;
-
 		    VarSelectWords_t seldata = { 0, 0 };
 
 		    seldata.start = strtol(estr, &ep, 0);
@@ -2927,9 +3025,15 @@
 	    }
 	case 'g':
 	    cp = tstr + 1;	/* make sure it is set */
-	    if (STRMOD_MATCH(tstr, "gmtime", 6)) {
-		newStr = VarStrftime(nstr, 1);
-		cp = tstr + 6;
+	    if (STRMOD_MATCHX(tstr, "gmtime", 6)) {
+		if (tstr[6] == '=') {
+		    utc = strtoul(&tstr[7], &ep, 10);
+		    cp = ep;
+		} else {
+		    utc = 0;
+		    cp = tstr + 6;
+		}
+		newStr = VarStrftime(nstr, 1, utc);
 		termc = *cp;
 	    } else {
 		goto default_case;
@@ -2947,9 +3051,15 @@
 	    break;
 	case 'l':
 	    cp = tstr + 1;	/* make sure it is set */
-	    if (STRMOD_MATCH(tstr, "localtime", 9)) {
-		newStr = VarStrftime(nstr, 0);
-		cp = tstr + 9;
+	    if (STRMOD_MATCHX(tstr, "localtime", 9)) {
+		if (tstr[9] == '=') {
+		    utc = strtoul(&tstr[10], &ep, 10);
+		    cp = ep;
+		} else {
+		    utc = 0;
+		    cp = tstr + 9;
+		}
+		newStr = VarStrftime(nstr, 0, utc);
 		termc = *cp;
 	    } else {
 		goto default_case;
@@ -2977,6 +3087,9 @@
 			    parsestate.varSpace = 0; /* no separator */
 			    cp = tstr + 2;
 			} else if (tstr[2] == '\\') {
+			    const char *xp = &tstr[3];
+			    int base = 8; /* assume octal */
+
 			    switch (tstr[3]) {
 			    case 'n':
 				parsestate.varSpace = '\n';
@@ -2986,12 +3099,19 @@
 				parsestate.varSpace = '\t';
 				cp = tstr + 4;
 				break;
+			    case 'x':
+				base = 16;
+				xp++;
+				goto get_numeric;
+			    case '0':
+				base = 0;
+				goto get_numeric;
 			    default:
 				if (isdigit((unsigned char)tstr[3])) {
-				    char *ep;
 
+				get_numeric:
 				    parsestate.varSpace =
-					strtoul(&tstr[3], &ep, 0);
+					strtoul(xp, &ep, base);
 				    if (*ep != ':' && *ep != endc)
 					goto bad_modifier;
 				    cp = ep;
@@ -3151,7 +3271,7 @@
 		     * expand it.
 		     */
 		    cp2 = pattern;
-		    pattern = Var_Subst(NULL, cp2, ctxt, errnum);
+		    pattern = Var_Subst(NULL, cp2, ctxt, flags | VARF_WANTRES);
 		    free(cp2);
 		}
 		if (DEBUG(VAR))
@@ -3187,7 +3307,7 @@
 		}
 
 		cp = tstr;
-		if ((pattern.lhs = VarGetPattern(ctxt, &parsestate, errnum,
+		if ((pattern.lhs = VarGetPattern(ctxt, &parsestate, flags,
 						 &cp, delim,
 						 &pattern.flags,
 						 &pattern.leftLen,
@@ -3194,7 +3314,7 @@
 						 NULL)) == NULL)
 		    goto cleanup;
 
-		if ((pattern.rhs = VarGetPattern(ctxt, &parsestate, errnum,
+		if ((pattern.rhs = VarGetPattern(ctxt, &parsestate, flags,
 						 &cp, delim, NULL,
 						 &pattern.rightLen,
 						 &pattern)) == NULL)
@@ -3237,15 +3357,32 @@
 	    {
 		VarPattern 	pattern;
 		Boolean	value;
-
+		int cond_rc;
+		int lhs_flags, rhs_flags;
+		
 		/* find ':', and then substitute accordingly */
-
+		if (flags & VARF_WANTRES) {
+		    cond_rc = Cond_EvalExpression(NULL, v->name, &value, 0, FALSE);
+		    if (cond_rc == COND_INVALID) {
+			lhs_flags = rhs_flags = VAR_NOSUBST;
+		    } else if (value) {
+			lhs_flags = 0;
+			rhs_flags = VAR_NOSUBST;
+		    } else {
+			lhs_flags = VAR_NOSUBST;
+			rhs_flags = 0;
+		    }
+		} else {
+		    /* we are just consuming and discarding */
+		    cond_rc = value = 0;
+		    lhs_flags = rhs_flags = VAR_NOSUBST;
+		}
 		pattern.flags = 0;
 
 		cp = ++tstr;
 		delim = ':';
-		if ((pattern.lhs = VarGetPattern(ctxt, &parsestate, errnum,
-						 &cp, delim, NULL,
+		if ((pattern.lhs = VarGetPattern(ctxt, &parsestate, flags,
+						 &cp, delim, &lhs_flags,
 						 &pattern.leftLen,
 						 NULL)) == NULL)
 		    goto cleanup;
@@ -3252,8 +3389,8 @@
 
 		/* BROPEN or PROPEN */
 		delim = endc;
-		if ((pattern.rhs = VarGetPattern(ctxt, &parsestate, errnum,
-						 &cp, delim, NULL,
+		if ((pattern.rhs = VarGetPattern(ctxt, &parsestate, flags,
+						 &cp, delim, &rhs_flags,
 						 &pattern.rightLen,
 						 NULL)) == NULL)
 		    goto cleanup;
@@ -3260,8 +3397,7 @@
 
 		termc = *--cp;
 		delim = '\0';
-		if (Cond_EvalExpression(NULL, v->name, &value, 0)
-		    == COND_INVALID) {
+		if (cond_rc == COND_INVALID) {
 		    Error("Bad conditional expression `%s' in %s?%s:%s",
 			  v->name, v->name, pattern.lhs, pattern.rhs);
 		    goto cleanup;
@@ -3294,12 +3430,12 @@
 
 		cp = tstr;
 
-		if ((re = VarGetPattern(ctxt, &parsestate, errnum, &cp, delim,
+		if ((re = VarGetPattern(ctxt, &parsestate, flags, &cp, delim,
 					NULL, NULL, NULL)) == NULL)
 		    goto cleanup;
 
 		if ((pattern.replace = VarGetPattern(ctxt, &parsestate,
-						     errnum, &cp, delim, NULL,
+						     flags, &cp, delim, NULL,
 						     NULL, NULL)) == NULL){
 		    free(re);
 		    goto cleanup;
@@ -3392,6 +3528,23 @@
 		break;
 	    }
 	    goto default_case;
+	case 'r':
+	    cp = tstr + 1;	/* make sure it is set */
+	    if (STRMOD_MATCHX(tstr, "range", 5)) {
+		int n;
+		
+		if (tstr[5] == '=') {
+		    n = strtoul(&tstr[6], &ep, 10);
+		    cp = ep;
+		} else {
+		    n = 0;
+		    cp = tstr + 5;
+		}
+		newStr = VarRange(nstr, n);
+		termc = *cp;
+		break;
+	    }
+	    goto default_case;
 	case 'O':
 	    {
 		char otype;
@@ -3423,9 +3576,12 @@
 	case 's':
 	    if (tstr[1] == 'h' && (tstr[2] == endc || tstr[2] == ':')) {
 		const char *emsg;
-		newStr = Cmd_Exec(nstr, &emsg);
-		if (emsg)
-		    Error(emsg, nstr);
+		if (flags & VARF_WANTRES) {
+		    newStr = Cmd_Exec(nstr, &emsg);
+		    if (emsg)
+			Error(emsg, nstr);
+		} else
+		    newStr = varNoError;
 		cp = tstr + 2;
 		termc = *cp;
 		break;
@@ -3473,12 +3629,12 @@
 		delim='=';
 		cp = tstr;
 		if ((pattern.lhs = VarGetPattern(ctxt, &parsestate,
-						 errnum, &cp, delim, &pattern.flags,
+						 flags, &cp, delim, &pattern.flags,
 						 &pattern.leftLen, NULL)) == NULL)
 		    goto cleanup;
 		delim = endc;
 		if ((pattern.rhs = VarGetPattern(ctxt, &parsestate,
-						 errnum, &cp, delim, NULL, &pattern.rightLen,
+						 flags, &cp, delim, NULL, &pattern.rightLen,
 						 &pattern)) == NULL)
 		    goto cleanup;
 
@@ -3546,10 +3702,8 @@
     if (delim != '\0')
 	Error("Unclosed substitution for %s (%c missing)",
 	      v->name, delim);
-    if (*freePtr) {
-	free(*freePtr);
-	*freePtr = NULL;
-    }
+    free(*freePtr);
+    *freePtr = NULL;
     return (var_Error);
 }
 
@@ -3563,7 +3717,9 @@
  * Input:
  *	str		The string to parse
  *	ctxt		The context for the variable
- *	errnum		TRUE if undefined variables are an error
+ *	flags		VARF_UNDEFERR	if undefineds are an error
+ *			VARF_WANTRES	if we actually want the result
+ *			VARF_ASSIGN	if we are in a := assignment
  *	lengthPtr	OUT: The length of the specification
  *	freePtr		OUT: Non-NULL if caller should free *freePtr
  *
@@ -3582,8 +3738,8 @@
  */
 /* coverity[+alloc : arg-*4] */
 char *
-Var_Parse(const char *str, GNode *ctxt, Boolean errnum, int *lengthPtr,
-	  void **freePtr)
+Var_Parse(const char *str, GNode *ctxt, int flags,
+	  int *lengthPtr, void **freePtr)
 {
     const char	   *tstr;    	/* Pointer into str */
     Var		   *v;		/* Variable in invocation */
@@ -3599,14 +3755,13 @@
 				 * expanding it in a non-local context. This
 				 * is done to support dynamic sources. The
 				 * result is just the invocation, unaltered */
-    Var_Parse_State parsestate; /* Flags passed to helper functions */
+    const char     *extramodifiers; /* extra modifiers to apply first */
     char	  name[2];
 
     *freePtr = NULL;
+    extramodifiers = NULL;
     dynamic = FALSE;
     start = str;
-    parsestate.oneBigWord = FALSE;
-    parsestate.varSpace = ' ';	/* word separator */
 
     startc = str[1];
     if (startc != PROPEN && startc != BROPEN) {
@@ -3642,17 +3797,17 @@
 		    case '@':
 			return UNCONST("$(.TARGET)");
 		    case '%':
-			return UNCONST("$(.ARCHIVE)");
+			return UNCONST("$(.MEMBER)");
 		    case '*':
 			return UNCONST("$(.PREFIX)");
 		    case '!':
-			return UNCONST("$(.MEMBER)");
+			return UNCONST("$(.ARCHIVE)");
 		}
 	    }
 	    /*
 	     * Error
 	     */
-	    return (errnum ? var_Error : varNoError);
+	    return (flags & VARF_UNDEFERR) ? var_Error : varNoError;
 	} else {
 	    haveModifier = FALSE;
 	    tstr = &str[1];
@@ -3689,12 +3844,11 @@
 	    if (*tstr == '$') {
 		int rlen;
 		void *freeIt;
-		char *rval = Var_Parse(tstr, ctxt, errnum, &rlen, &freeIt);
+		char *rval = Var_Parse(tstr, ctxt, flags,  &rlen, &freeIt);
 		if (rval != NULL) {
 		    Buf_AddBytes(&buf, strlen(rval), rval);
 		}
-		if (freeIt)
-		    free(freeIt);
+		free(freeIt);
 		tstr += rlen - 1;
 	    }
 	    else
@@ -3734,7 +3888,7 @@
 	 */
 	if ((v == NULL) && (ctxt != VAR_CMD) && (ctxt != VAR_GLOBAL) &&
 		(vlen == 2) && (str[1] == 'F' || str[1] == 'D') &&
-		strchr("@%*!<>", str[0]) != NULL) {
+		strchr("@%?*!<>", str[0]) != NULL) {
 	    /*
 	     * Well, it's local -- go look for it.
 	     */
@@ -3743,29 +3897,12 @@
 	    v = VarFind(name, ctxt, 0);
 
 	    if (v != NULL) {
-		/*
-		 * No need for nested expansion or anything, as we're
-		 * the only one who sets these things and we sure don't
-		 * but nested invocations in them...
-		 */
-		nstr = Buf_GetAll(&v->val, NULL);
-
 		if (str[1] == 'D') {
-		    nstr = VarModify(ctxt, &parsestate, nstr, VarHead,
-				    NULL);
-		} else {
-		    nstr = VarModify(ctxt, &parsestate, nstr, VarTail,
-				    NULL);
+			extramodifiers = "H:";
 		}
-		/*
-		 * Resulting string is dynamically allocated, so
-		 * tell caller to free it.
-		 */
-		*freePtr = nstr;
-		*lengthPtr = tstr-start+1;
-		Buf_Destroy(&buf, TRUE);
-		VarFreeEnv(v, TRUE);
-		return nstr;
+		else { /* F */
+			extramodifiers = "T:";
+		}
 	    }
 	}
 
@@ -3820,7 +3957,7 @@
 		    return(pstr);
 		} else {
 		    Buf_Destroy(&buf, TRUE);
-		    return (errnum ? var_Error : varNoError);
+		    return (flags & VARF_UNDEFERR) ? var_Error : varNoError;
 		}
 	    } else {
 		/*
@@ -3854,22 +3991,33 @@
      */
     nstr = Buf_GetAll(&v->val, NULL);
     if (strchr(nstr, '$') != NULL) {
-	nstr = Var_Subst(NULL, nstr, ctxt, errnum);
+	nstr = Var_Subst(NULL, nstr, ctxt, flags);
 	*freePtr = nstr;
     }
 
     v->flags &= ~VAR_IN_USE;
 
-    if ((nstr != NULL) && haveModifier) {
+    if ((nstr != NULL) && (haveModifier || extramodifiers != NULL)) {
+	void *extraFree;
 	int used;
-	/*
-	 * Skip initial colon.
-	 */
-	tstr++;
 
-	nstr = ApplyModifiers(nstr, tstr, startc, endc,
-			      v, ctxt, errnum, &used, freePtr);
-	tstr += used;
+	extraFree = NULL;
+	if (extramodifiers != NULL) {
+		nstr = ApplyModifiers(nstr, extramodifiers, '(', ')',
+				      v, ctxt, flags, &used, &extraFree);
+	}
+
+	if (haveModifier) {
+		/* Skip initial colon. */
+		tstr++;
+
+		nstr = ApplyModifiers(nstr, tstr, startc, endc,
+				      v, ctxt, flags, &used, freePtr);
+		tstr += used;
+		free(extraFree);
+	} else {
+		*freePtr = extraFree;
+	}
     }
     if (*tstr) {
 	*lengthPtr = tstr - start + 1;
@@ -3905,7 +4053,7 @@
 		nstr = bmake_strndup(start, *lengthPtr);
 		*freePtr = nstr;
 	    } else {
-		nstr = errnum ? var_Error : varNoError;
+		nstr = (flags & VARF_UNDEFERR) ? var_Error : varNoError;
 	    }
 	}
 	if (nstr != Buf_GetAll(&v->val, NULL))
@@ -3920,7 +4068,7 @@
  *-----------------------------------------------------------------------
  * Var_Subst  --
  *	Substitute for all variables in the given string in the given context
- *	If undefErr is TRUE, Parse_Error will be called when an undefined
+ *	If flags & VARF_UNDEFERR, Parse_Error will be called when an undefined
  *	variable is encountered.
  *
  * Input:
@@ -3927,7 +4075,9 @@
  *	var		Named variable || NULL for all
  *	str		the string which to substitute
  *	ctxt		the context wherein to find variables
- *	undefErr	TRUE if undefineds are an error
+ *	flags		VARF_UNDEFERR	if undefineds are an error
+ *			VARF_WANTRES	if we actually want the result
+ *			VARF_ASSIGN	if we are in a := assignment
  *
  * Results:
  *	The resulting string.
@@ -3937,7 +4087,7 @@
  *-----------------------------------------------------------------------
  */
 char *
-Var_Subst(const char *var, const char *str, GNode *ctxt, Boolean undefErr)
+Var_Subst(const char *var, const char *str, GNode *ctxt, int flags)
 {
     Buffer  	  buf;		    /* Buffer for forming things */
     char    	  *val;		    /* Value to substitute for a variable */
@@ -3961,6 +4111,8 @@
 	     * In such a case, we skip over the escape character and store the
 	     * dollar sign into the buffer directly.
 	     */
+	    if (save_dollars && (flags & VARF_ASSIGN))
+		Buf_AddByte(&buf, *str);
 	    str++;
 	    Buf_AddByte(&buf, *str);
 	    str++;
@@ -4035,7 +4187,7 @@
 		    continue;
 	    }
 
-	    val = Var_Parse(str, ctxt, undefErr, &length, &freeIt);
+	    val = Var_Parse(str, ctxt, flags, &length, &freeIt);
 
 	    /*
 	     * When we come down here, val should either point to the
@@ -4052,7 +4204,7 @@
 		 */
 		if (oldVars) {
 		    str += length;
-		} else if (undefErr || val == var_Error) {
+		} else if ((flags & VARF_UNDEFERR) || val == var_Error) {
 		    /*
 		     * If variable is undefined, complain and skip the
 		     * variable. The complaint will stop us from doing anything
@@ -4083,10 +4235,8 @@
 		Buf_AddBytes(&buf, length, val);
 		trailingBslash = length > 0 && val[length - 1] == '\\';
 	    }
-	    if (freeIt) {
-		free(freeIt);
-		freeIt = NULL;
-	    }
+	    free(freeIt);
+	    freeIt = NULL;
 	}
     }
 



More information about the Midnightbsd-cvs mailing list