summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon J. Gerraty <sjg@FreeBSD.org>2018-12-06 00:13:35 +0000
committerSimon J. Gerraty <sjg@FreeBSD.org>2018-12-06 00:13:35 +0000
commit14ed4acf373acf4a08f80acf1689d5f967460af0 (patch)
treebeec9a380ea6fe2383a4876e5a908622d6e16edf
parenta5422567f996e7316e1e9471b8b993f146212fcd (diff)
downloadsrc-test2-14ed4acf373acf4a08f80acf1689d5f967460af0.tar.gz
src-test2-14ed4acf373acf4a08f80acf1689d5f967460af0.zip
Import bmake-20180919vendor/NetBSD/bmake/20180919
Notes
Notes: svn path=/vendor/NetBSD/bmake/dist/; revision=341609 svn path=/vendor/NetBSD/bmake/20180919/; revision=341610; tag=vendor/NetBSD/bmake/20180919
-rw-r--r--ChangeLog11
-rw-r--r--FILES2
-rw-r--r--Makefile.config.in8
-rw-r--r--VERSION2
-rw-r--r--bmake.111
-rw-r--r--dir.c67
-rw-r--r--make.111
-rw-r--r--mk/ChangeLog22
-rw-r--r--mk/dirdeps-options.mk13
-rw-r--r--mk/dirdeps.mk6
-rw-r--r--mk/gendirdeps.mk20
-rw-r--r--mk/install-mk4
-rw-r--r--mk/meta.autodep.mk16
-rw-r--r--mk/meta.stage.mk12
-rw-r--r--unit-tests/Makefile.in5
-rw-r--r--unit-tests/varquote.exp3
-rw-r--r--unit-tests/varquote.mk14
-rw-r--r--var.c16
18 files changed, 154 insertions, 89 deletions
diff --git a/ChangeLog b/ChangeLog
index fe6b0d949383..25edb9e496ae 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2018-09-21 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * VERSION: 20180919
+ Merge with NetBSD make, pick up
+ o var.c: add :q
+ o dir.c: cleanup caching of stats
+
+2018-09-21 Simon J Gerraty <sjg@beast.crufty.net>
+
+ * Makefile.config.in: use += where it makes sense.
+
2018-05-12 Simon J. Gerraty <sjg@bad.crufty.net>
* VERSION: 20180512
diff --git a/FILES b/FILES
index 24cd0451f077..08d9d7cf4afb 100644
--- a/FILES
+++ b/FILES
@@ -163,6 +163,8 @@ unit-tests/varcmd.exp
unit-tests/varcmd.mk
unit-tests/varmisc.exp
unit-tests/varmisc.mk
+unit-tests/varquote.exp
+unit-tests/varquote.mk
unit-tests/varshell.exp
unit-tests/varshell.mk
util.c
diff --git a/Makefile.config.in b/Makefile.config.in
index 323417bc1bcb..bc0cc9d90972 100644
--- a/Makefile.config.in
+++ b/Makefile.config.in
@@ -1,6 +1,6 @@
# things set by configure
-_MAKE_VERSION=@_MAKE_VERSION@
+_MAKE_VERSION?=@_MAKE_VERSION@
prefix?= @prefix@
srcdir= @srcdir@
@@ -11,9 +11,9 @@ DEFAULT_SYS_PATH?= @default_sys_path@
CPPFLAGS+= @CPPFLAGS@
CFLAGS+= ${CPPFLAGS} @DEFS@
-LDFLAGS= @LDFLAGS@
-LIBOBJS= @LIBOBJS@
-LDADD= @LIBS@
+LDFLAGS+= @LDFLAGS@
+LIBOBJS+= @LIBOBJS@
+LDADD+= @LIBS@
USE_META= @use_meta@
FILEMON_H?= @filemon_h@
BMAKE_PATH_MAX?= @bmake_path_max@
diff --git a/VERSION b/VERSION
index d29d946c9039..e390075f472b 100644
--- a/VERSION
+++ b/VERSION
@@ -1,2 +1,2 @@
# keep this compatible with sh and make
-_MAKE_VERSION=20180512
+_MAKE_VERSION=20180919
diff --git a/bmake.1 b/bmake.1
index 1ee14bad6717..d0a02289a6d8 100644
--- a/bmake.1
+++ b/bmake.1
@@ -1,4 +1,4 @@
-.\" $NetBSD: make.1,v 1.272 2018/04/02 04:26:17 dholland Exp $
+.\" $NetBSD: make.1,v 1.273 2018/05/27 01:14:51 christos 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 June 22, 2017
+.Dd May 26, 2018
.Dt BMAKE 1
.Os
.Sh NAME
@@ -1227,8 +1227,15 @@ due uno quattro tre
.Ed
.It Cm \&:Q
Quotes every shell meta-character in the variable, so that it can be passed
+safely to the shell.
+.It Cm \&:q
+Quotes every shell meta-character in the variable, and also doubles
+.Sq $
+characters so that it can be passed
safely through recursive invocations of
.Nm .
+This is equivalent to:
+.Sq \&:S/\e\&$/&&/g:Q .
.It Cm \&:R
Replaces each word in the variable with everything but its suffix.
.It Cm \&:range[=count]
diff --git a/dir.c b/dir.c
index 8331999802d2..0062ac04d515 100644
--- a/dir.c
+++ b/dir.c
@@ -1,4 +1,4 @@
-/* $NetBSD: dir.c,v 1.71 2017/04/16 21:14:47 riastradh Exp $ */
+/* $NetBSD: dir.c,v 1.73 2018/07/12 18:03:31 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: dir.c,v 1.71 2017/04/16 21:14:47 riastradh Exp $";
+static char rcsid[] = "$NetBSD: dir.c,v 1.73 2018/07/12 18:03:31 christos Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)dir.c 8.2 (Berkeley) 1/2/94";
#else
-__RCSID("$NetBSD: dir.c,v 1.71 2017/04/16 21:14:47 riastradh Exp $");
+__RCSID("$NetBSD: dir.c,v 1.73 2018/07/12 18:03:31 christos Exp $");
#endif
#endif /* not lint */
#endif
@@ -268,15 +268,6 @@ struct cache_st {
};
/* 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
@@ -298,6 +289,10 @@ cached_stats(Hash_Table *htp, const char *pathname, struct stat *st, int flags)
memset(st, 0, sizeof(*st));
st->st_mtime = cst->mtime;
st->st_mode = cst->mode;
+ if (DEBUG(DIR)) {
+ fprintf(debug_file, "Using cached time %s for %s\n",
+ Targ_FmtTime(st->st_mtime), pathname);
+ }
return 0;
}
@@ -315,6 +310,10 @@ cached_stats(Hash_Table *htp, const char *pathname, struct stat *st, int flags)
cst = entry->clientPtr;
cst->mtime = st->st_mtime;
cst->mode = st->st_mode;
+ if (DEBUG(DIR)) {
+ fprintf(debug_file, " Caching %s for %s\n",
+ Targ_FmtTime(st->st_mtime), pathname);
+ }
return 0;
}
@@ -995,14 +994,6 @@ DirLookupSubdir(Path *p, const char *name)
}
if (cached_stat(file, &stb) == 0) {
- /*
- * Save the modification time so if it's needed, we don't have
- * to fetch it again.
- */
- if (DEBUG(DIR)) {
- fprintf(debug_file, " Caching %s for %s\n", Targ_FmtTime(stb.st_mtime),
- file);
- }
nearmisses += 1;
return (file);
}
@@ -1134,7 +1125,6 @@ Dir_FindFile(const char *name, Lst path)
Boolean hasLastDot = FALSE; /* true we should search dot last */
Boolean hasSlash; /* true if 'name' contains a / */
struct stat stb; /* Buffer for stat, if necessary */
- Hash_Entry *entry; /* Entry for mtimes table */
const char *trailing_dot = ".";
/*
@@ -1395,24 +1385,14 @@ Dir_FindFile(const char *name, Lst path)
}
bigmisses += 1;
- entry = Hash_FindEntry(&mtimes, name);
- if (entry != NULL) {
- if (DEBUG(DIR)) {
- fprintf(debug_file, " got it (in mtime cache)\n");
- }
- return(bmake_strdup(name));
- } else if (cached_stat(name, &stb) == 0) {
- if (DEBUG(DIR)) {
- fprintf(debug_file, " Caching %s for %s\n", Targ_FmtTime(stb.st_mtime),
- name);
- }
+ if (cached_stat(name, &stb) == 0) {
return (bmake_strdup(name));
- } else {
- if (DEBUG(DIR)) {
- fprintf(debug_file, " failed. Returning NULL\n");
- }
- return NULL;
}
+
+ if (DEBUG(DIR)) {
+ fprintf(debug_file, " failed. Returning NULL\n");
+ }
+ return NULL;
#endif /* notdef */
}
@@ -1518,7 +1498,6 @@ Dir_MTime(GNode *gn, Boolean recheck)
{
char *fullName; /* the full pathname of name */
struct stat stb; /* buffer for finding the mod time */
- Hash_Entry *entry;
if (gn->type & OP_ARCHV) {
return Arch_MTime(gn);
@@ -1569,17 +1548,7 @@ Dir_MTime(GNode *gn, Boolean recheck)
fullName = bmake_strdup(gn->name);
}
- if (!recheck)
- entry = Hash_FindEntry(&mtimes, fullName);
- 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(stb.st_mtime), fullName);
- }
- } else if (cached_stats(&mtimes, fullName, &stb, recheck ? CST_UPDATE : 0) < 0) {
+ if (cached_stats(&mtimes, fullName, &stb, recheck ? CST_UPDATE : 0) < 0) {
if (gn->type & OP_MEMBER) {
if (fullName != gn->path)
free(fullName);
diff --git a/make.1 b/make.1
index a83fb588c5d2..2a2237f8eb60 100644
--- a/make.1
+++ b/make.1
@@ -1,4 +1,4 @@
-.\" $NetBSD: make.1,v 1.272 2018/04/02 04:26:17 dholland Exp $
+.\" $NetBSD: make.1,v 1.273 2018/05/27 01:14:51 christos 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 June 22, 2017
+.Dd May 26, 2018
.Dt MAKE 1
.Os
.Sh NAME
@@ -1227,8 +1227,15 @@ due uno quattro tre
.Ed
.It Cm \&:Q
Quotes every shell meta-character in the variable, so that it can be passed
+safely to the shell.
+.It Cm \&:q
+Quotes every shell meta-character in the variable, and also doubles
+.Sq $
+characters so that it can be passed
safely through recursive invocations of
.Nm .
+This is equivalent to:
+.Sq \&:S/\e\&$/&&/g:Q .
.It Cm \&:R
Replaces each word in the variable with everything but its suffix.
.It Cm \&:range[=count]
diff --git a/mk/ChangeLog b/mk/ChangeLog
index 3bc1976fcfc3..ce8ac5361a4d 100644
--- a/mk/ChangeLog
+++ b/mk/ChangeLog
@@ -1,3 +1,25 @@
+2018-09-19 Simon J Gerraty <sjg@beast.crufty.net>
+
+ * install-mk (MK_VERSION): 20180919
+
+ * dirdeps-options.mk: .undef cannot handle var that expands to
+ more than one var.
+
+2018-07-08 Simon J Gerraty <sjg@beast.crufty.net>
+
+ * meta.stage.mk: allow wildcards in STAGE_FILES.* etc.
+
+2018-06-01 Simon J Gerraty <sjg@beast.crufty.net>
+
+ * meta.autodep.mk: export META_FILES to avoid command line limit
+ * gendirdeps.mk: if we have lots of .meta files put them in
+ an @list
+
+2018-05-28 Simon J Gerraty <sjg@beast.crufty.net>
+
+ * dirdeps-options.mk: use local.dirdeps-options.mk
+ not local.dirdeps-option.mk
+
2018-04-20 Simon J Gerraty <sjg@beast.crufty.net>
* install-mk (MK_VERSION): 20180420
diff --git a/mk/dirdeps-options.mk b/mk/dirdeps-options.mk
index b6164cfa299a..4f74c02e1b8c 100644
--- a/mk/dirdeps-options.mk
+++ b/mk/dirdeps-options.mk
@@ -1,4 +1,4 @@
-# $Id: dirdeps-options.mk,v 1.5 2018/04/18 15:53:57 sjg Exp $
+# $Id: dirdeps-options.mk,v 1.9 2018/09/20 00:07:19 sjg Exp $
#
# @(#) Copyright (c) 2018, Simon J. Gerraty
#
@@ -25,7 +25,7 @@
# If a Makefile.depend.options file exists, it will be included by
# dirdeps.mk and meta.autodep.mk
#
-# We include local.dirdeps-option.mk which may also define DIRDEPS.*
+# We include local.dirdeps-options.mk which may also define DIRDEPS.*
# for options.
#
# Thus a directory, that is affected by an option FOO would have
@@ -35,7 +35,7 @@
# DIRDEPS.FOO.yes
# DIRDEPS.FOO.no
# to whatever applies for that dir, or it can rely on globals
-# set in local.dirdeps-option.mk
+# set in local.dirdeps-options.mk
# Either way, we will .undef DIRDEPS.* when done.
# This should have been set by Makefile.depend.options
@@ -43,7 +43,7 @@
DIRDEPS_OPTIONS ?=
# pickup any DIRDEPS.* we need
-.-include <local.dirdeps-option.mk>
+.-include <local.dirdeps-options.mk>
.if ${.MAKE.LEVEL} == 0
# :U below avoids potential errors when we :=
@@ -52,7 +52,10 @@ DIRDEPS += ${DIRDEPS.$o.${MK_$o:U}:U}
.endfor
DIRDEPS := ${DIRDEPS:O:u}
# avoid cross contamination
-.undef ${DIRDEPS_OPTIONS:tu:@o@DIRDEPS.$o.yes DIRDEPS.$o.no@}
+.for o in ${DIRDEPS_OPTIONS:tu}
+.undef DIRDEPS.$o.yes
+.undef DIRDEPS.$o.no
+.endfor
.else
# whether options are enabled or not,
# we want to filter out the relevant DIRDEPS.*
diff --git a/mk/dirdeps.mk b/mk/dirdeps.mk
index 5df66e58f7ff..a84e0dde44e3 100644
--- a/mk/dirdeps.mk
+++ b/mk/dirdeps.mk
@@ -1,4 +1,4 @@
-# $Id: dirdeps.mk,v 1.95 2018/04/23 17:53:56 sjg Exp $
+# $Id: dirdeps.mk,v 1.96 2018/06/20 22:26:39 sjg Exp $
# Copyright (c) 2010-2013, Juniper Networks, Inc.
# All rights reserved.
@@ -731,6 +731,8 @@ DIRDEPS =
.info loading ${_m} for ${d:E}
.endif
.include <${_m}>
+.else
+.-include <local.dirdeps-missing.mk>
.endif
.endif
.endif
@@ -746,7 +748,7 @@ DIRDEPS =
DEP_RELDIR := ${RELDIR}
_DEP_RELDIR := ${RELDIR}
# Since we are/should be included by .MAKE.DEPENDFILE
-# is is a final opportunity to add/hook global rules.
+# This is a final opportunity to add/hook global rules.
.-include <local.dirdeps-build.mk>
# pickup local dependencies
diff --git a/mk/gendirdeps.mk b/mk/gendirdeps.mk
index d8f900630ac4..e04f8390cae9 100644
--- a/mk/gendirdeps.mk
+++ b/mk/gendirdeps.mk
@@ -1,4 +1,4 @@
-# $Id: gendirdeps.mk,v 1.38 2018/03/10 00:53:52 sjg Exp $
+# $Id: gendirdeps.mk,v 1.39 2018/06/08 01:25:31 sjg Exp $
# Copyright (c) 2010-2013, Juniper Networks, Inc.
# All rights reserved.
@@ -171,11 +171,27 @@ GENDIRDEPS_SEDCMDS += \
# we canonicalize them to keep things simple
# if we are using a split-fs sandbox, it gets a little messier.
_objtop := ${_OBJTOP:tA}
+
+# some people put *.meta in META_XTRAS to make sure we get here
+_meta_files := ${META_FILES:N\*.meta:O:u}
+# assume a big list
+_meta_files_arg= @meta.list
+.if empty(_meta_files) && ${META_FILES:M\*.meta} != ""
+# XXX this should be considered a bad idea,
+# since we cannot ignore stale .meta
+x != cd ${_OBJDIR} && find . -name '*.meta' -print -o \( -type d ! -name . -prune \) | sed 's,^./,,' > meta.list; echo
+.elif ${_meta_files:[#]} > 500
+.export _meta_files
+x != echo; for m in $$_meta_files; do echo $$m; done > meta.list
+.else
+_meta_files_arg:= ${_meta_files}
+.endif
+
dir_list != cd ${_OBJDIR} && \
${META2DEPS_CMD} MACHINE=${MACHINE} \
SRCTOP=${SRCTOP} RELDIR=${RELDIR} CURDIR=${_CURDIR} \
${META2DEPS_ARGS} \
- ${META_FILES:O:u} | ${META2DEPS_FILTER} ${_skip_gendirdeps} \
+ ${_meta_files_arg} | ${META2DEPS_FILTER} ${_skip_gendirdeps} \
sed ${GENDIRDEPS_SEDCMDS}
.if ${dir_list:M*ERROR\:*} != ""
diff --git a/mk/install-mk b/mk/install-mk
index 70233fc23ed8..886c264bd808 100644
--- a/mk/install-mk
+++ b/mk/install-mk
@@ -55,7 +55,7 @@
# Simon J. Gerraty <sjg@crufty.net>
# RCSid:
-# $Id: install-mk,v 1.156 2018/04/22 04:42:47 sjg Exp $
+# $Id: install-mk,v 1.160 2018/09/20 00:07:19 sjg Exp $
#
# @(#) Copyright (c) 1994 Simon J. Gerraty
#
@@ -70,7 +70,7 @@
# sjg@crufty.net
#
-MK_VERSION=20180420
+MK_VERSION=20180919
OWNER=
GROUP=
MODE=444
diff --git a/mk/meta.autodep.mk b/mk/meta.autodep.mk
index c33c5d809447..9cb3f14ea0c6 100644
--- a/mk/meta.autodep.mk
+++ b/mk/meta.autodep.mk
@@ -1,4 +1,4 @@
-# $Id: meta.autodep.mk,v 1.48 2018/04/15 06:30:04 sjg Exp $
+# $Id: meta.autodep.mk,v 1.50 2018/06/08 01:25:31 sjg Exp $
#
# @(#) Copyright (c) 2010, Simon J. Gerraty
@@ -20,9 +20,11 @@ __${_this}__: .NOTMAIN
.-include <local.autodep.mk>
+PICO?= .pico
+
.if defined(SRCS)
# it would be nice to be able to query .SUFFIXES
-OBJ_EXTENSIONS+= .o .po .lo .So
+OBJ_EXTENSIONS+= .o .po .lo ${PICO}
# explicit dependencies help short-circuit .SUFFIX searches
SRCS_DEP_FILTER+= N*.[hly]
@@ -178,7 +180,7 @@ DEPEND_SUFFIXES += .c .h .cpp .hpp .cxx .hxx .cc .hh
@case "${.MAKE.META.FILES:T:M*.po.*}" in \
*.po.*) mv $@.${.MAKE.PID} $@;; \
*) { cat $@.${.MAKE.PID}; \
- sed 's,\.So:,.o:,;s,\.o:,.po:,' $@.${.MAKE.PID}; } | sort -u > $@; \
+ sed 's,\${PICO}:,.o:,;s,\.o:,.po:,' $@.${.MAKE.PID}; } | sort -u > $@; \
rm -f $@.${.MAKE.PID};; \
esac
.else
@@ -243,7 +245,7 @@ META_FILES = *.meta
.elif ${OPTIMIZE_OBJECT_META_FILES:Uno:tl} == "no"
META_FILES = ${.MAKE.META.FILES:T:N.depend*:O:u}
.else
-# if we have 1000's of .o.meta, .So.meta etc we need only look at one set
+# if we have 1000's of .o.meta, ${PICO}.meta etc we need only look at one set
# it is left as an exercise for the reader to work out what this does
META_FILES = ${.MAKE.META.FILES:T:N.depend*:N*o.meta:O:u} \
${.MAKE.META.FILES:T:M*.${.MAKE.META.FILES:M*o.meta:R:E:O:u:[1]}.meta:O:u}
@@ -260,6 +262,9 @@ META_FILES = ${.MAKE.META.FILES:T:N.depend*:N*o.meta:O:u} \
.if !empty(GENDIRDEPS_FILTER)
.export GENDIRDEPS_FILTER
.endif
+# export to avoid blowing command line limit
+META_FILES := ${META_XTRAS:U:O:u} ${META_FILES:U:T:O:u:${META_FILE_FILTER:ts:}}
+.export META_FILES
.endif
# we might have .../ in MAKESYSPATH
@@ -270,8 +275,7 @@ ${_DEPENDFILE}: ${_depend} ${.PARSEDIR}/gendirdeps.mk ${META2DEPS} $${.MAKE.MET
SKIP_GENDIRDEPS='${SKIP_GENDIRDEPS:O:u}' \
DPADD='${FORCE_DPADD:O:u}' ${_gendirdeps_mutex} \
MAKESYSPATH=${_makesyspath} \
- ${.MAKE} -f gendirdeps.mk RELDIR=${RELDIR} _DEPENDFILE=${_DEPENDFILE} \
- META_FILES='${META_XTRAS:O:u} ${META_FILES:T:O:u:${META_FILE_FILTER:ts:}}')
+ ${.MAKE} -f gendirdeps.mk RELDIR=${RELDIR} _DEPENDFILE=${_DEPENDFILE})
@test -s $@ && touch $@; :
.endif
diff --git a/mk/meta.stage.mk b/mk/meta.stage.mk
index 5c54f81fb378..320ffcca80a0 100644
--- a/mk/meta.stage.mk
+++ b/mk/meta.stage.mk
@@ -1,4 +1,4 @@
-# $Id: meta.stage.mk,v 1.55 2017/10/27 01:17:09 sjg Exp $
+# $Id: meta.stage.mk,v 1.56 2018/07/08 17:12:54 sjg Exp $
#
# @(#) Copyright (c) 2011-2017, Simon J. Gerraty
#
@@ -141,7 +141,7 @@ _STAGE_AS_BASENAME_USE: .USE .dirdep ${.TARGET:T}
.if !empty(STAGE_INCSDIR)
.if !empty(STAGE_INCS)
-stage_incs: ${STAGE_INCS}
+stage_incs: ${STAGE_INCS:N*\**}
.endif
.if target(stage_incs) || !empty(.ALLTARGETS:Mstage_includes)
STAGE_TARGETS += stage_incs
@@ -156,7 +156,7 @@ stage_incs: .dirdep
.if !empty(STAGE_LIBDIR)
.if !empty(STAGE_LIBS)
-stage_libs: ${STAGE_LIBS}
+stage_libs: ${STAGE_LIBS:N*\**}
.endif
.if target(stage_libs)
STAGE_TARGETS += stage_libs
@@ -191,7 +191,7 @@ CLEANFILES += ${STAGE_SETS:@s@stage*$s@}
# some makefiles need to populate multiple directories
.for s in ${STAGE_SETS:O:u}
.if !empty(STAGE_FILES.$s)
-stage_files.$s: ${STAGE_FILES.$s}
+stage_files.$s: ${STAGE_FILES.$s:N*\**}
.endif
.if target(stage_files.$s) || target(stage_files${s:S,^,.,:N._default})
STAGE_TARGETS += stage_files
@@ -262,7 +262,7 @@ CLEANFILES += ${STAGE_AS_SETS:@s@stage*$s@}
# both operations happen together
.for s in ${STAGE_AS_SETS:O:u}
.if !empty(STAGE_AS.$s)
-stage_as.$s: ${STAGE_AS.$s}
+stage_as.$s: ${STAGE_AS.$s:N*\**}
.endif
.if target(stage_as.$s)
STAGE_TARGETS += stage_as
@@ -277,7 +277,7 @@ stage_as.$s: .dirdep
.endif
.if !empty(STAGE_AS_AND_SYMLINK.$s)
-stage_as_and_symlink.$s: ${STAGE_AS_AND_SYMLINK.$s}
+stage_as_and_symlink.$s: ${STAGE_AS_AND_SYMLINK.$s:N*\**}
.endif
.if target(stage_as_and_symlink.$s)
STAGE_TARGETS += stage_as_and_symlink
diff --git a/unit-tests/Makefile.in b/unit-tests/Makefile.in
index 4ee94bd87f68..e51d25455a50 100644
--- a/unit-tests/Makefile.in
+++ b/unit-tests/Makefile.in
@@ -1,6 +1,6 @@
-# $Id: Makefile.in,v 1.48 2015/12/07 04:06:29 sjg Exp $
+# $Id: Makefile.in,v 1.49 2018/09/21 21:39:05 sjg Exp $
#
-# $NetBSD: Makefile,v 1.52 2015/05/05 21:51:09 sjg Exp $
+# $NetBSD: Makefile,v 1.53 2018/05/24 00:25:44 christos Exp $
#
# Unit tests for make(1)
# The main targets are:
@@ -54,6 +54,7 @@ TESTNAMES= \
unexport-env \
varcmd \
varmisc \
+ varquote \
varshell
# these tests were broken by referting POSIX chanegs
diff --git a/unit-tests/varquote.exp b/unit-tests/varquote.exp
new file mode 100644
index 000000000000..63107bfd34f5
--- /dev/null
+++ b/unit-tests/varquote.exp
@@ -0,0 +1,3 @@
+-fdebug-prefix-map=$NETBSDSRCDIR=/usr/src -fdebug-regex-map=/usr/src/(.*)/obj$=/usr/obj/\1
+-fdebug-prefix-map=$NETBSDSRCDIR=/usr/src -fdebug-regex-map=/usr/src/(.*)/obj$=/usr/obj/\1
+exit status 0
diff --git a/unit-tests/varquote.mk b/unit-tests/varquote.mk
new file mode 100644
index 000000000000..571f262fd91e
--- /dev/null
+++ b/unit-tests/varquote.mk
@@ -0,0 +1,14 @@
+# $NetBSD: varquote.mk,v 1.2 2018/05/27 01:14:51 christos Exp $
+#
+# Test VAR:q modifier
+
+.if !defined(REPROFLAGS)
+REPROFLAGS+= -fdebug-prefix-map=\$$NETBSDSRCDIR=/usr/src
+REPROFLAGS+= -fdebug-regex-map='/usr/src/(.*)/obj$$=/usr/obj/\1'
+all:
+ @${MAKE} -f ${MAKEFILE} REPROFLAGS=${REPROFLAGS:S/\$/&&/g:Q}
+ @${MAKE} -f ${MAKEFILE} REPROFLAGS=${REPROFLAGS:q}
+.else
+all:
+ @echo ${REPROFLAGS}
+.endif
diff --git a/var.c b/var.c
index 0e2460f131c7..b9b316939492 100644
--- a/var.c
+++ b/var.c
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.218 2018/02/18 00:52:42 sjg Exp $ */
+/* $NetBSD: var.c,v 1.220 2018/05/27 01:14:51 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.218 2018/02/18 00:52:42 sjg Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.220 2018/05/27 01:14:51 christos Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: var.c,v 1.218 2018/02/18 00:52:42 sjg Exp $");
+__RCSID("$NetBSD: var.c,v 1.220 2018/05/27 01:14:51 christos Exp $");
#endif
#endif /* not lint */
#endif
@@ -324,7 +324,7 @@ static Boolean VarLoopExpand(GNode *, Var_Parse_State *,
static char *VarGetPattern(GNode *, Var_Parse_State *,
int, const char **, int, int *, int *,
VarPattern *);
-static char *VarQuote(char *);
+static char *VarQuote(char *, Boolean);
static char *VarHash(char *);
static char *VarModify(GNode *, Var_Parse_State *,
const char *,
@@ -2315,6 +2315,7 @@ VarGetPattern(GNode *ctxt, Var_Parse_State *vpstate MAKE_ATTR_UNUSED,
*-----------------------------------------------------------------------
* VarQuote --
* Quote shell meta-characters and space characters in the string
+ * if quoteDollar is set, also quote and double any '$' characters.
*
* Results:
* The quoted string
@@ -2325,7 +2326,7 @@ VarGetPattern(GNode *ctxt, Var_Parse_State *vpstate MAKE_ATTR_UNUSED,
*-----------------------------------------------------------------------
*/
static char *
-VarQuote(char *str)
+VarQuote(char *str, Boolean quoteDollar)
{
Buffer buf;
@@ -2346,6 +2347,8 @@ VarQuote(char *str)
if (isspace((unsigned char)*str) || ismeta((unsigned char)*str))
Buf_AddByte(&buf, '\\');
Buf_AddByte(&buf, *str);
+ if (quoteDollar && *str == '$')
+ Buf_AddBytes(&buf, 2, "\\$");
}
str = Buf_Destroy(&buf, FALSE);
@@ -3485,9 +3488,10 @@ ApplyModifiers(char *nstr, const char *tstr,
break;
}
#endif
+ case 'q':
case 'Q':
if (tstr[1] == endc || tstr[1] == ':') {
- newStr = VarQuote(nstr);
+ newStr = VarQuote(nstr, modifier == 'q');
cp = tstr + 1;
termc = *cp;
break;