summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsjg <sjg@FreeBSD.org>2017-06-13 00:22:15 +0000
committersjg <sjg@FreeBSD.org>2017-06-13 00:22:15 +0000
commit288f3738be6e27e220023bc4b7657fe85362d81d (patch)
tree40cf6f102891991aa2f8a183d5abb857ef42e453
parent1017c991b1cd2684dcf01ef4801db4bfe18320b4 (diff)
downloadFreeBSD-src-288f3738be6e27e220023bc4b7657fe85362d81d.zip
FreeBSD-src-288f3738be6e27e220023bc4b7657fe85362d81d.tar.gz
Update bmake to 20170510
Approved by: re@
-rw-r--r--contrib/bmake/ChangeLog166
-rw-r--r--contrib/bmake/Makefile9
-rw-r--r--contrib/bmake/PSD.doc/tutorial.ms15
-rw-r--r--contrib/bmake/arch.c35
-rw-r--r--contrib/bmake/bmake.170
-rw-r--r--contrib/bmake/bmake.cat156
-rw-r--r--contrib/bmake/compat.c51
-rw-r--r--contrib/bmake/cond.c10
-rw-r--r--contrib/bmake/dir.c52
-rw-r--r--contrib/bmake/for.c8
-rw-r--r--contrib/bmake/job.c81
-rw-r--r--contrib/bmake/main.c181
-rw-r--r--contrib/bmake/make.168
-rw-r--r--contrib/bmake/make.c8
-rw-r--r--contrib/bmake/make.h5
-rw-r--r--contrib/bmake/make_malloc.c8
-rw-r--r--contrib/bmake/meta.c170
-rw-r--r--contrib/bmake/mk/ChangeLog183
-rw-r--r--contrib/bmake/mk/FILES3
-rw-r--r--contrib/bmake/mk/auto.obj.mk9
-rw-r--r--contrib/bmake/mk/dirdeps.mk178
-rw-r--r--contrib/bmake/mk/doc.mk4
-rw-r--r--contrib/bmake/mk/dpadd.mk6
-rw-r--r--contrib/bmake/mk/files.mk83
-rw-r--r--contrib/bmake/mk/final.mk12
-rw-r--r--contrib/bmake/mk/gendirdeps.mk5
-rw-r--r--contrib/bmake/mk/inc.mk72
-rw-r--r--contrib/bmake/mk/init.mk16
-rw-r--r--contrib/bmake/mk/install-mk6
-rw-r--r--contrib/bmake/mk/lib.mk98
-rw-r--r--contrib/bmake/mk/meta.stage.mk67
-rw-r--r--contrib/bmake/mk/meta.sys.mk24
-rwxr-xr-xcontrib/bmake/mk/meta2deps.py160
-rwxr-xr-xcontrib/bmake/mk/meta2deps.sh8
-rwxr-xr-xcontrib/bmake/mk/mkopt.sh4
-rw-r--r--contrib/bmake/mk/own.mk27
-rw-r--r--contrib/bmake/mk/prog.mk27
-rw-r--r--contrib/bmake/mk/scripts.mk101
-rw-r--r--contrib/bmake/mk/subdir.mk15
-rw-r--r--contrib/bmake/mk/sys.debug.mk33
-rw-r--r--contrib/bmake/mk/sys.mk83
-rw-r--r--contrib/bmake/mk/sys.vars.mk80
-rw-r--r--contrib/bmake/mk/sys/AIX.mk2
-rw-r--r--contrib/bmake/mk/sys/Darwin.mk2
-rw-r--r--contrib/bmake/mk/sys/Generic.mk4
-rw-r--r--contrib/bmake/mk/sys/HP-UX.mk4
-rw-r--r--contrib/bmake/mk/sys/IRIX.mk2
-rw-r--r--contrib/bmake/mk/sys/Linux.mk4
-rw-r--r--contrib/bmake/mk/sys/NetBSD.mk2
-rw-r--r--contrib/bmake/mk/sys/OSF1.mk4
-rw-r--r--contrib/bmake/mk/sys/OpenBSD.mk2
-rw-r--r--contrib/bmake/mk/sys/SunOS.mk4
-rw-r--r--contrib/bmake/mk/sys/UnixWare.mk4
-rw-r--r--contrib/bmake/nonints.h3
-rwxr-xr-xcontrib/bmake/os.sh16
-rw-r--r--contrib/bmake/parse.c52
-rw-r--r--contrib/bmake/str.c22
-rw-r--r--contrib/bmake/suff.c53
-rw-r--r--contrib/bmake/targ.c10
-rw-r--r--contrib/bmake/unit-tests/modmatch.exp3
-rw-r--r--contrib/bmake/unit-tests/modmatch.mk11
-rw-r--r--contrib/bmake/unit-tests/varmisc.exp5
-rw-r--r--contrib/bmake/unit-tests/varmisc.mk24
-rw-r--r--contrib/bmake/var.c146
-rw-r--r--usr.bin/bmake/Makefile9
65 files changed, 2049 insertions, 636 deletions
diff --git a/contrib/bmake/ChangeLog b/contrib/bmake/ChangeLog
index deee9bf..37d3e6e 100644
--- a/contrib/bmake/ChangeLog
+++ b/contrib/bmake/ChangeLog
@@ -1,3 +1,169 @@
+2017-05-10 Simon J. Gerraty <sjg@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@bad.crufty.net>
+
+ * Makefile (_MAKE_VERSION): 20170505
+ see mk/ChangeLog
+
+2017-05-05 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * parse.c: not everyone has stdint.h
+
+2017-05-01 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * Makefile (_MAKE_VERSION): 20170501
+ see mk/ChangeLog
+
+2017-04-21 Simon J. Gerraty <sjg@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@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@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@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@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@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@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@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@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@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@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@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@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@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@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@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@bad.crufty.net>
+
+ * Makefile MAN: tweak .Dt to match ${PROG}
+
+2016-08-18 Simon J. Gerraty <sjg@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@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@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@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@bad.crufty.net>
* Makefile (_MAKE_VERSION): 20160606
diff --git a/contrib/bmake/Makefile b/contrib/bmake/Makefile
index 9c63e4f..1ded36d 100644
--- a/contrib/bmake/Makefile
+++ b/contrib/bmake/Makefile
@@ -1,7 +1,7 @@
-# $Id: Makefile,v 1.67 2016/06/07 00:46:12 sjg Exp $
+# $Id: Makefile,v 1.92 2017/05/10 22:29:04 sjg Exp $
# Base version on src date
-_MAKE_VERSION= 20160606
+_MAKE_VERSION= 20170510
PROG= bmake
@@ -156,7 +156,10 @@ my.history: ${MAKEFILE}
.NOPATH: ${MAN}
${MAN}: make.1 my.history
@echo making $@
- @sed -e 's/^.Nx/NetBSD/' -e '/^.Nm/s/make/${PROG}/' \
+ @sed \
+ -e '/^.Dt/s/MAKE/${PROG:tu}/' \
+ -e 's/^.Nx/NetBSD/' \
+ -e '/^.Nm/s/make/${PROG}/' \
-e '/^.Sh HISTORY/rmy.history' \
-e '/^.Sh HISTORY/,$$s,^.Nm,make,' ${srcdir}/make.1 > $@
diff --git a/contrib/bmake/PSD.doc/tutorial.ms b/contrib/bmake/PSD.doc/tutorial.ms
index d5c8a7d..814a09a 100644
--- a/contrib/bmake/PSD.doc/tutorial.ms
+++ b/contrib/bmake/PSD.doc/tutorial.ms
@@ -1,4 +1,4 @@
-.\" $NetBSD: tutorial.ms,v 1.12 2014/09/30 21:33:14 christos Exp $
+.\" $NetBSD: tutorial.ms,v 1.13 2017/03/01 13:05:11 kre Exp $
.\" Copyright (c) 1988, 1989, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -117,6 +117,15 @@
.de No
.br
.ne 0.5i
+.ie n \{\
+.nr g3 \w'NOTE '
+.po -\\n(g3u
+.br
+NOTE
+.br
+.po +\\n(g3u
+.\}
+.el \{\
.po -0.5i
.br
.mk
@@ -148,12 +157,14 @@
.rt
.ft \\n(g3
.ps \\n(g4
+.\}
..
.de Bp
.ie !\\n(.$ .IP \(bu 2
.el .IP "\&" 2
..
-.po +.3i
+.ie n .po +\w'NOTE 'u
+.el .po +.3i
.TL
PMake \*- A Tutorial
.AU
diff --git a/contrib/bmake/arch.c b/contrib/bmake/arch.c
index 1b5bab7..12c518a 100644
--- a/contrib/bmake/arch.c
+++ b/contrib/bmake/arch.c
@@ -1,4 +1,4 @@
-/* $NetBSD: arch.c,v 1.69 2016/04/06 09:57:00 gson Exp $ */
+/* $NetBSD: arch.c,v 1.70 2017/04/16 20:49:09 riastradh Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: arch.c,v 1.69 2016/04/06 09:57:00 gson Exp $";
+static char rcsid[] = "$NetBSD: arch.c,v 1.70 2017/04/16 20:49:09 riastradh Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)arch.c 8.2 (Berkeley) 1/2/94";
#else
-__RCSID("$NetBSD: arch.c,v 1.69 2016/04/06 09:57:00 gson Exp $");
+__RCSID("$NetBSD: arch.c,v 1.70 2017/04/16 20:49:09 riastradh Exp $");
#endif
#endif /* not lint */
#endif
@@ -726,7 +726,8 @@ ArchStatMember(char *archive, char *member, Boolean hash)
if (fread(memName, elen, 1, arch) != 1)
goto badarch;
memName[elen] = '\0';
- fseek(arch, -elen, SEEK_CUR);
+ if (fseek(arch, -elen, SEEK_CUR) != 0)
+ goto badarch;
if (DEBUG(ARCH) || DEBUG(MAKE)) {
fprintf(debug_file, "ArchStat: Extended format entry for %s\n", memName);
}
@@ -737,7 +738,8 @@ ArchStatMember(char *archive, char *member, Boolean hash)
Hash_SetValue(he, bmake_malloc(sizeof(struct ar_hdr)));
memcpy(Hash_GetValue(he), &arh, sizeof(struct ar_hdr));
}
- fseek(arch, (size + 1) & ~1, SEEK_CUR);
+ if (fseek(arch, (size + 1) & ~1, SEEK_CUR) != 0)
+ goto badarch;
}
fclose(arch);
@@ -956,7 +958,10 @@ ArchFindMember(char *archive, char *member, struct ar_hdr *arhPtr,
* the file at the actual member, rather than its header, but
* not here...
*/
- fseek(arch, -sizeof(struct ar_hdr), SEEK_CUR);
+ if (fseek(arch, -sizeof(struct ar_hdr), SEEK_CUR) != 0) {
+ fclose(arch);
+ return NULL;
+ }
return (arch);
}
} else
@@ -986,10 +991,17 @@ ArchFindMember(char *archive, char *member, struct ar_hdr *arhPtr,
}
if (strncmp(ename, member, len) == 0) {
/* Found as extended name */
- fseek(arch, -sizeof(struct ar_hdr) - elen, SEEK_CUR);
+ if (fseek(arch, -sizeof(struct ar_hdr) - elen,
+ SEEK_CUR) != 0) {
+ fclose(arch);
+ return NULL;
+ }
return (arch);
}
- fseek(arch, -elen, SEEK_CUR);
+ if (fseek(arch, -elen, SEEK_CUR) != 0) {
+ fclose(arch);
+ return NULL;
+ }
goto skip;
} else
#endif
@@ -1002,9 +1014,12 @@ skip:
* extract the size of the file from the 'size' field of the
* header and round it up during the seek.
*/
- arhPtr->ar_size[sizeof(arhPtr->AR_SIZE)-1] = '\0';
+ arhPtr->AR_SIZE[sizeof(arhPtr->AR_SIZE)-1] = '\0';
size = (int)strtol(arhPtr->AR_SIZE, NULL, 10);
- fseek(arch, (size + 1) & ~1, SEEK_CUR);
+ if (fseek(arch, (size + 1) & ~1, SEEK_CUR) != 0) {
+ fclose(arch);
+ return NULL;
+ }
}
}
diff --git a/contrib/bmake/bmake.1 b/contrib/bmake/bmake.1
index 93cf7ac..3bad1e7 100644
--- a/contrib/bmake/bmake.1
+++ b/contrib/bmake/bmake.1
@@ -1,4 +1,4 @@
-.\" $NetBSD: make.1,v 1.259 2016/06/03 07:07:37 wiz Exp $
+.\" $NetBSD: make.1,v 1.266 2017/02/01 18:39:27 sjg Exp $
.\"
.\" Copyright (c) 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -29,8 +29,8 @@
.\"
.\" from: @(#)make.1 8.4 (Berkeley) 3/19/94
.\"
-.Dd June 2, 2016
-.Dt MAKE 1
+.Dd February 1, 2017
+.Dt BMAKE 1
.Os
.Sh NAME
.Nm bmake
@@ -927,6 +927,9 @@ The default list includes:
.It Va .MAKE.META.IGNORE_PATTERNS
Provides a list of patterns to match against pathnames.
Ignore any that match.
+.It Va .MAKE.META.IGNORE_FILTER
+Provides a list of variable modifiers to apply to each pathname.
+Ignore if the expansion is an empty string.
.It Va .MAKE.META.PREFIX
Defines the message printed for each meta file updated in "meta verbose" mode.
The default value is:
@@ -974,7 +977,19 @@ per normal evaluation rules.
.It Va MAKE_PRINT_VAR_ON_ERROR
When
.Nm
-stops due to an error, it prints its name and the value of
+stops due to an error, it sets
+.Ql Va .ERROR_TARGET
+to the name of the target that failed,
+.Ql Va .ERROR_CMD
+to the commands of the failed target,
+and in "meta" mode, it also sets
+.Ql Va .ERROR_CWD
+to the
+.Xr getcwd 3 ,
+and
+.Ql Va .ERROR_META_FILE
+to the path of the meta file (if any) describing the failed target.
+It then prints its name and the value of
.Ql Va .CURDIR
as well as the value of any variables named in
.Ql Va MAKE_PRINT_VAR_ON_ERROR .
@@ -1190,18 +1205,28 @@ safely through recursive invocations of
.Nm .
.It Cm \&:R
Replaces each word in the variable with everything but its suffix.
-.It Cm \&:gmtime
+.It Cm \&:range[=count]
+The value is an integer sequence representing the words of the original
+value, or the supplied
+.Va count .
+.It Cm \&:gmtime[=utc]
The value is a format string for
.Xr strftime 3 ,
-using the current
+using
.Xr gmtime 3 .
+If a
+.Va utc
+value is not provided or is 0, the current time is used.
.It Cm \&:hash
Compute a 32-bit hash of the value and encode it as hex digits.
-.It Cm \&:localtime
+.It Cm \&:localtime[=utc]
The value is a format string for
.Xr strftime 3 ,
-using the current
+using
.Xr localtime 3 .
+If a
+.Va utc
+value is not provided or is 0, the current time is used.
.It Cm \&:tA
Attempt to convert variable to an absolute path using
.Xr realpath 3 ,
@@ -1401,6 +1426,27 @@ For example.
.Pp
However a single character variable is often more readable:
.Dl ${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'${.newline}@}
+.It Cm \&:_[=var]
+Save the current variable value in
+.Ql $_
+or the named
+.Va var
+for later reference.
+Example usage:
+.Bd -literal -offset indent
+M_cmpv.units = 1 1000 1000000
+M_cmpv = S,., ,g:_:range:@i@+ $${_:[-$$i]} \&\\
+\\* $${M_cmpv.units:[$$i]}@:S,^,expr 0 ,1:sh
+
+.Dv .if ${VERSION:${M_cmpv}} < ${3.1.12:L:${M_cmpv}}
+
+.Ed
+Here
+.Ql $_
+is used to save the result of the
+.Ql :S
+modifier which is later referenced using the index values from
+.Ql :range .
.It Cm \&:U Ns Ar newval
If the variable is undefined
.Ar newval
@@ -1996,6 +2042,14 @@ variable of a target that inherits
.Ic .DEFAULT Ns 's
commands is set
to the target's own name.
+.It Ic .DELETE_ON_ERROR
+If this target is present in the makefile, it globally causes make to
+delete targets whose commands fail.
+(By default, only targets whose commands are interrupted during
+execution are deleted.
+This is the historical behavior.)
+This setting can be used to help prevent half-finished or malformed
+targets from being left around and corrupting future rebuilds.
.It Ic .END
Any command lines attached to this target are executed after everything
else is done.
diff --git a/contrib/bmake/bmake.cat1 b/contrib/bmake/bmake.cat1
index 51e02f4..bd98e5b 100644
--- a/contrib/bmake/bmake.cat1
+++ b/contrib/bmake/bmake.cat1
@@ -1,4 +1,4 @@
-MAKE(1) NetBSD General Commands Manual MAKE(1)
+BMAKE(1) NetBSD General Commands Manual BMAKE(1)
NNAAMMEE
bbmmaakkee -- maintain program dependencies
@@ -604,6 +604,10 @@ VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNTTSS
Provides a list of patterns to match against pathnames.
Ignore any that match.
+ _._M_A_K_E_._M_E_T_A_._I_G_N_O_R_E___F_I_L_T_E_R
+ Provides a list of variable modifiers to apply to each
+ pathname. Ignore if the expansion is an empty string.
+
_._M_A_K_E_._M_E_T_A_._P_R_E_F_I_X
Defines the message printed for each meta file updated in
"meta verbose" mode. The default value is:
@@ -635,9 +639,14 @@ VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNTTSS
becomes `$' per normal evaluation rules.
_M_A_K_E___P_R_I_N_T___V_A_R___O_N___E_R_R_O_R
- When bbmmaakkee stops due to an error, it prints its name and
- the value of `_._C_U_R_D_I_R' as well as the value of any vari-
- ables named in `_M_A_K_E___P_R_I_N_T___V_A_R___O_N___E_R_R_O_R'.
+ When bbmmaakkee stops due to an error, it sets `_._E_R_R_O_R___T_A_R_G_E_T'
+ to the name of the target that failed, `_._E_R_R_O_R___C_M_D' to
+ the commands of the failed target, and in "meta" mode, it
+ also sets `_._E_R_R_O_R___C_W_D' to the getcwd(3), and
+ `_._E_R_R_O_R___M_E_T_A___F_I_L_E' to the path of the meta file (if any)
+ describing the failed target. It then prints its name
+ and the value of `_._C_U_R_D_I_R' as well as the value of any
+ variables named in `_M_A_K_E___P_R_I_N_T___V_A_R___O_N___E_R_R_O_R'.
_._n_e_w_l_i_n_e This variable is simply assigned a newline character as
its value. This allows expansions using the ::@@ modifier
@@ -780,16 +789,20 @@ VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNTTSS
::RR Replaces each word in the variable with everything but its suffix.
- ::ggmmttiimmee
- The value is a format string for strftime(3), using the current
- gmtime(3).
+ ::rraannggee[[==ccoouunntt]]
+ The value is an integer sequence representing the words of the orig-
+ inal value, or the supplied _c_o_u_n_t.
+
+ ::ggmmttiimmee[[==uuttcc]]
+ The value is a format string for strftime(3), using gmtime(3). If a
+ _u_t_c value is not provided or is 0, the current time is used.
::hhaasshh
Compute a 32-bit hash of the value and encode it as hex digits.
- ::llooccaallttiimmee
- The value is a format string for strftime(3), using the current
- localtime(3).
+ ::llooccaallttiimmee[[==uuttcc]]
+ The value is a format string for strftime(3), using localtime(3).
+ If a _u_t_c value is not provided or is 0, the current time is used.
::ttAA Attempt to convert variable to an absolute path using realpath(3),
if that fails, the value is unchanged.
@@ -890,6 +903,19 @@ VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNTTSS
However a single character variable is often more readable:
${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'${.newline}@}
+ ::__[[==vvaarr]]
+ Save the current variable value in `$_' or the named _v_a_r for later
+ reference. Example usage:
+
+ M_cmpv.units = 1 1000 1000000
+ M_cmpv = S,., ,g:_:range:@i@+ $${_:[-$$i]} \
+ \* $${M_cmpv.units:[$$i]}@:S,^,expr 0 ,1:sh
+
+ .if ${VERSION:${M_cmpv}} < ${3.1.12:L:${M_cmpv}}
+
+ Here `$_' is used to save the result of the `:S' modifier which is
+ later referenced using the index values from `:range'.
+
::UU_n_e_w_v_a_l
If the variable is undefined _n_e_w_v_a_l is the value. If the variable
is defined, the existing value is returned. This is another ODE
@@ -1276,6 +1302,14 @@ SSPPEECCIIAALL TTAARRGGEETTSS
target that inherits ..DDEEFFAAUULLTT's commands is set to the target's
own name.
+ ..DDEELLEETTEE__OONN__EERRRROORR
+ If this target is present in the makefile, it globally causes
+ make to delete targets whose commands fail. (By default, only
+ targets whose commands are interrupted during execution are
+ deleted. This is the historical behavior.) This setting can be
+ used to help prevent half-finished or malformed targets from
+ being left around and corrupting future rebuilds.
+
..EENNDD Any command lines attached to this target are executed after
everything else is done.
@@ -1489,4 +1523,4 @@ BBUUGGSS
There is no way of escaping a space character in a filename.
-NetBSD 5.1 June 2, 2016 NetBSD 5.1
+NetBSD 7.1_RC1 February 1, 2017 NetBSD 7.1_RC1
diff --git a/contrib/bmake/compat.c b/contrib/bmake/compat.c
index 87e1261..3e16fff 100644
--- a/contrib/bmake/compat.c
+++ b/contrib/bmake/compat.c
@@ -1,4 +1,4 @@
-/* $NetBSD: compat.c,v 1.105 2016/05/12 20:28:34 sjg Exp $ */
+/* $NetBSD: compat.c,v 1.106 2016/08/26 23:28:39 dholland Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: compat.c,v 1.105 2016/05/12 20:28:34 sjg Exp $";
+static char rcsid[] = "$NetBSD: compat.c,v 1.106 2016/08/26 23:28:39 dholland Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)compat.c 8.2 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: compat.c,v 1.105 2016/05/12 20:28:34 sjg Exp $");
+__RCSID("$NetBSD: compat.c,v 1.106 2016/08/26 23:28:39 dholland Exp $");
#endif
#endif /* not lint */
#endif
@@ -119,6 +119,25 @@ static GNode *curTarg = NULL;
static GNode *ENDNode;
static void CompatInterrupt(int);
+/*
+ * CompatDeleteTarget -- delete a failed, interrupted, or otherwise
+ * duffed target if not inhibited by .PRECIOUS.
+ */
+static void
+CompatDeleteTarget(GNode *gn)
+{
+ if ((gn != NULL) && !Targ_Precious (gn)) {
+ char *p1;
+ char *file = Var_Value(TARGET, gn, &p1);
+
+ if (!noExecute && eunlink(file) != -1) {
+ Error("*** %s removed", file);
+ }
+
+ free(p1);
+ }
+}
+
/*-
*-----------------------------------------------------------------------
* CompatInterrupt --
@@ -132,6 +151,9 @@ static void CompatInterrupt(int);
* The target is removed and the process exits. If .INTERRUPT exists,
* its commands are run first WITH INTERRUPTS IGNORED..
*
+ * XXX: is .PRECIOUS supposed to inhibit .INTERRUPT? I doubt it, but I've
+ * left the logic alone for now. - dholland 20160826
+ *
*-----------------------------------------------------------------------
*/
static void
@@ -139,16 +161,9 @@ CompatInterrupt(int signo)
{
GNode *gn;
- if ((curTarg != NULL) && !Targ_Precious (curTarg)) {
- char *p1;
- char *file = Var_Value(TARGET, curTarg, &p1);
-
- if (!noExecute && eunlink(file) != -1) {
- Error("*** %s removed", file);
- }
-
- free(p1);
+ CompatDeleteTarget(curTarg);
+ if ((curTarg != NULL) && !Targ_Precious (curTarg)) {
/*
* Run .INTERRUPT only if hit with interrupt signal
*/
@@ -158,7 +173,6 @@ CompatInterrupt(int signo)
Compat_Make(gn, gn);
}
}
-
}
if (signo == SIGQUIT)
_exit(signo);
@@ -447,6 +461,11 @@ again:
* continue.
*/
printf(" (continuing)\n");
+ } else {
+ printf("\n");
+ }
+ if (deleteOnError) {
+ CompatDeleteTarget(gn);
}
} else {
/*
@@ -607,7 +626,7 @@ Compat_Make(void *gnp, void *pgnp)
} else if (keepgoing) {
pgn->flags &= ~REMAKE;
} else {
- PrintOnError(gn, "\n\nStop.");
+ PrintOnError(gn, "\nStop.");
exit(1);
}
} else if (gn->made == ERROR) {
@@ -698,7 +717,7 @@ Compat_Run(Lst targs)
if (gn != NULL) {
Compat_Make(gn, gn);
if (gn->made == ERROR) {
- PrintOnError(gn, "\n\nStop.");
+ PrintOnError(gn, "\nStop.");
exit(1);
}
}
@@ -739,7 +758,7 @@ Compat_Run(Lst targs)
if (errors == 0) {
Compat_Make(ENDNode, ENDNode);
if (gn->made == ERROR) {
- PrintOnError(gn, "\n\nStop.");
+ PrintOnError(gn, "\nStop.");
exit(1);
}
}
diff --git a/contrib/bmake/cond.c b/contrib/bmake/cond.c
index cf0107b..7c9c96a 100644
--- a/contrib/bmake/cond.c
+++ b/contrib/bmake/cond.c
@@ -1,4 +1,4 @@
-/* $NetBSD: cond.c,v 1.74 2016/02/18 18:29:14 christos Exp $ */
+/* $NetBSD: cond.c,v 1.75 2017/04/16 20:59:04 riastradh Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: cond.c,v 1.74 2016/02/18 18:29:14 christos Exp $";
+static char rcsid[] = "$NetBSD: cond.c,v 1.75 2017/04/16 20:59:04 riastradh Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)cond.c 8.2 (Berkeley) 1/2/94";
#else
-__RCSID("$NetBSD: cond.c,v 1.74 2016/02/18 18:29:14 christos Exp $");
+__RCSID("$NetBSD: cond.c,v 1.75 2017/04/16 20:59:04 riastradh Exp $");
#endif
#endif /* not lint */
#endif
@@ -91,6 +91,7 @@ __RCSID("$NetBSD: cond.c,v 1.74 2016/02/18 18:29:14 christos Exp $");
*
*/
+#include <assert.h>
#include <ctype.h>
#include <errno.h> /* For strtoul() error checking */
@@ -1174,8 +1175,9 @@ Cond_EvalExpression(const struct If *info, char *line, Boolean *value, int eprin
break;
dflt_info = info;
}
+ assert(info != NULL);
- if_info = info != NULL ? info : ifs + 4;
+ if_info = info;
condExpr = line;
condPushBack = TOK_NONE;
diff --git a/contrib/bmake/dir.c b/contrib/bmake/dir.c
index 4667e3c..8331999 100644
--- a/contrib/bmake/dir.c
+++ b/contrib/bmake/dir.c
@@ -1,4 +1,4 @@
-/* $NetBSD: dir.c,v 1.68 2016/06/07 00:40:00 sjg Exp $ */
+/* $NetBSD: dir.c,v 1.71 2017/04/16 21:14:47 riastradh Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: dir.c,v 1.68 2016/06/07 00:40:00 sjg Exp $";
+static char rcsid[] = "$NetBSD: dir.c,v 1.71 2017/04/16 21:14:47 riastradh Exp $";
#else
#include <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.68 2016/06/07 00:40:00 sjg Exp $");
+__RCSID("$NetBSD: dir.c,v 1.71 2017/04/16 21:14:47 riastradh Exp $");
#endif
#endif /* not lint */
#endif
@@ -346,11 +346,13 @@ cached_lstat(const char *pathname, void *st)
void
Dir_Init(const char *cdname)
{
- dirSearchPath = Lst_Init(FALSE);
- openDirectories = Lst_Init(FALSE);
- Hash_InitTable(&mtimes, 0);
- Hash_InitTable(&lmtimes, 0);
-
+ if (!cdname) {
+ dirSearchPath = Lst_Init(FALSE);
+ openDirectories = Lst_Init(FALSE);
+ Hash_InitTable(&mtimes, 0);
+ Hash_InitTable(&lmtimes, 0);
+ return;
+ }
Dir_InitCur(cdname);
dotLast = bmake_malloc(sizeof(Path));
@@ -801,11 +803,11 @@ DirExpandInt(const char *word, Lst path, Lst expansions)
*-----------------------------------------------------------------------
*/
static int
-DirPrintWord(void *word, void *dummy)
+DirPrintWord(void *word, void *dummy MAKE_ATTR_UNUSED)
{
fprintf(debug_file, "%s ", (char *)word);
- return(dummy ? 0 : 0);
+ return 0;
}
/*-
@@ -1313,8 +1315,14 @@ Dir_FindFile(const char *name, Lst path)
fprintf(debug_file, " Trying exact path matches...\n");
}
- if (!hasLastDot && cur && (file = DirLookupAbs(cur, name, cp)) != NULL)
- return *file?file:NULL;
+ if (!hasLastDot && cur && ((file = DirLookupAbs(cur, name, cp))
+ != NULL)) {
+ if (file[0] == '\0') {
+ free(file);
+ return NULL;
+ }
+ return file;
+ }
(void)Lst_Open(path);
while ((ln = Lst_Next(path)) != NULL) {
@@ -1323,13 +1331,23 @@ Dir_FindFile(const char *name, Lst path)
continue;
if ((file = DirLookupAbs(p, name, cp)) != NULL) {
Lst_Close(path);
- return *file?file:NULL;
+ if (file[0] == '\0') {
+ free(file);
+ return NULL;
+ }
+ return file;
}
}
Lst_Close(path);
- if (hasLastDot && cur && (file = DirLookupAbs(cur, name, cp)) != NULL)
- return *file?file:NULL;
+ if (hasLastDot && cur && ((file = DirLookupAbs(cur, name, cp))
+ != NULL)) {
+ if (file[0] == '\0') {
+ free(file);
+ return NULL;
+ }
+ return file;
+ }
}
/*
@@ -1849,10 +1867,10 @@ Dir_PrintDirectories(void)
}
static int
-DirPrintDir(void *p, void *dummy)
+DirPrintDir(void *p, void *dummy MAKE_ATTR_UNUSED)
{
fprintf(debug_file, "%s ", ((Path *)p)->name);
- return (dummy ? 0 : 0);
+ return 0;
}
void
diff --git a/contrib/bmake/for.c b/contrib/bmake/for.c
index ec00a45..fffedda 100644
--- a/contrib/bmake/for.c
+++ b/contrib/bmake/for.c
@@ -1,4 +1,4 @@
-/* $NetBSD: for.c,v 1.52 2016/02/18 18:29:14 christos Exp $ */
+/* $NetBSD: for.c,v 1.53 2017/04/16 21:04:44 riastradh Exp $ */
/*
* Copyright (c) 1992, The Regents of the University of California.
@@ -30,14 +30,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: for.c,v 1.52 2016/02/18 18:29:14 christos Exp $";
+static char rcsid[] = "$NetBSD: for.c,v 1.53 2017/04/16 21:04:44 riastradh Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)for.c 8.1 (Berkeley) 6/6/93";
#else
-__RCSID("$NetBSD: for.c,v 1.52 2016/02/18 18:29:14 christos Exp $");
+__RCSID("$NetBSD: for.c,v 1.53 2017/04/16 21:04:44 riastradh Exp $");
#endif
#endif /* not lint */
#endif
@@ -427,7 +427,7 @@ For_Iterate(void *v_arg, size_t *ret_len)
for (cp = cmd_cp; (cp = strchr(cp, '$')) != NULL;) {
char ech;
ch = *++cp;
- if ((ch == '(' && (ech = ')')) || (ch == '{' && (ech = '}'))) {
+ if ((ch == '(' && (ech = ')', 1)) || (ch == '{' && (ech = '}', 1))) {
cp++;
/* Check variable name against the .for loop variables */
STRLIST_FOREACH(var, &arg->vars, i) {
diff --git a/contrib/bmake/job.c b/contrib/bmake/job.c
index 340d3b6..f52a626 100644
--- a/contrib/bmake/job.c
+++ b/contrib/bmake/job.c
@@ -1,4 +1,4 @@
-/* $NetBSD: job.c,v 1.187 2016/05/12 20:28:34 sjg Exp $ */
+/* $NetBSD: job.c,v 1.190 2017/04/16 21:23:43 riastradh Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: job.c,v 1.187 2016/05/12 20:28:34 sjg Exp $";
+static char rcsid[] = "$NetBSD: job.c,v 1.190 2017/04/16 21:23:43 riastradh Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)job.c 8.2 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: job.c,v 1.187 2016/05/12 20:28:34 sjg Exp $");
+__RCSID("$NetBSD: job.c,v 1.190 2017/04/16 21:23:43 riastradh Exp $");
#endif
#endif /* not lint */
#endif
@@ -389,7 +389,10 @@ static void JobSigLock(sigset_t *);
static void JobSigUnlock(sigset_t *);
static void JobSigReset(void);
-const char *malloc_options="A";
+#if !defined(MALLOC_OPTIONS)
+# define MALLOC_OPTIONS "A"
+#endif
+const char *malloc_options= MALLOC_OPTIONS;
static void
job_table_dump(const char *where)
@@ -404,6 +407,21 @@ job_table_dump(const char *where)
}
/*
+ * Delete the target of a failed, interrupted, or otherwise
+ * unsuccessful job unless inhibited by .PRECIOUS.
+ */
+static void
+JobDeleteTarget(GNode *gn)
+{
+ if ((gn->type & (OP_JOIN|OP_PHONY)) == 0 && !Targ_Precious(gn)) {
+ char *file = (gn->path == NULL ? gn->name : gn->path);
+ if (!noExecute && eunlink(file) != -1) {
+ Error("*** %s removed", file);
+ }
+ }
+}
+
+/*
* JobSigLock/JobSigUnlock
*
* Signal lock routines to get exclusive access. Currently used to
@@ -425,7 +443,7 @@ static void JobSigUnlock(sigset_t *omaskp)
static void
JobCreatePipe(Job *job, int minfd)
{
- int i, fd;
+ int i, fd, flags;
if (pipe(job->jobPipe) == -1)
Punt("Cannot create pipe: %s", strerror(errno));
@@ -440,8 +458,10 @@ JobCreatePipe(Job *job, int minfd)
}
/* Set close-on-exec flag for both */
- (void)fcntl(job->jobPipe[0], F_SETFD, FD_CLOEXEC);
- (void)fcntl(job->jobPipe[1], F_SETFD, FD_CLOEXEC);
+ if (fcntl(job->jobPipe[0], F_SETFD, FD_CLOEXEC) == -1)
+ Punt("Cannot set close-on-exec: %s", strerror(errno));
+ if (fcntl(job->jobPipe[1], F_SETFD, FD_CLOEXEC) == -1)
+ Punt("Cannot set close-on-exec: %s", strerror(errno));
/*
* We mark the input side of the pipe non-blocking; we poll(2) the
@@ -449,8 +469,12 @@ JobCreatePipe(Job *job, int minfd)
* race for the token when a new one becomes available, so the read
* from the pipe should not block.
*/
- fcntl(job->jobPipe[0], F_SETFL,
- fcntl(job->jobPipe[0], F_GETFL, 0) | O_NONBLOCK);
+ flags = fcntl(job->jobPipe[0], F_GETFL, 0);
+ if (flags == -1)
+ Punt("Cannot get flags: %s", strerror(errno));
+ flags |= O_NONBLOCK;
+ if (fcntl(job->jobPipe[0], F_SETFL, flags) == -1)
+ Punt("Cannot set flags: %s", strerror(errno));
}
/*-
@@ -752,6 +776,7 @@ JobPrintCommand(void *cmdp, void *jobp)
* but this one needs to be - use compat mode just for it.
*/
CompatRunCommand(cmdp, job->node);
+ free(cmdStart);
return 0;
}
break;
@@ -1049,6 +1074,9 @@ JobFinish (Job *job, WAIT_T status)
if (job->flags & JOB_IGNERR) {
WAIT_STATUS(status) = 0;
} else {
+ if (deleteOnError) {
+ JobDeleteTarget(job->node);
+ }
PrintOnError(job->node, NULL);
}
} else if (DEBUG(JOB)) {
@@ -1066,6 +1094,9 @@ JobFinish (Job *job, WAIT_T status)
}
(void)printf("*** [%s] Signal %d\n",
job->node->name, WTERMSIG(status));
+ if (deleteOnError) {
+ JobDeleteTarget(job->node);
+ }
}
(void)fflush(stdout);
}
@@ -1374,16 +1405,28 @@ JobExec(Job *job, char **argv)
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 (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);
+ }
}
/*
@@ -1400,7 +1443,10 @@ JobExec(Job *job, char **argv)
* 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);
@@ -2601,12 +2647,7 @@ JobInterrupt(int runINTERRUPT, int signo)
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,
diff --git a/contrib/bmake/main.c b/contrib/bmake/main.c
index 20aa9c9..9c52fd2 100644
--- a/contrib/bmake/main.c
+++ b/contrib/bmake/main.c
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.247 2016/06/05 01:39:17 christos Exp $ */
+/* $NetBSD: main.c,v 1.265 2017/05/10 22:26:14 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: main.c,v 1.247 2016/06/05 01:39:17 christos Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.265 2017/05/10 22:26:14 sjg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
@@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\
#if 0
static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: main.c,v 1.247 2016/06/05 01:39:17 christos Exp $");
+__RCSID("$NetBSD: main.c,v 1.265 2017/05/10 22:26:14 sjg Exp $");
#endif
#endif /* not lint */
#endif
@@ -155,6 +155,7 @@ Lst create; /* Targets to be made */
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 */
@@ -186,6 +187,7 @@ static const char * tracefile;
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 +337,7 @@ parse_debug_options(const char *argvalue)
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 +368,32 @@ debug_setbuf:
}
}
+/*
+ * 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,6 +416,7 @@ MainParseArgs(int argc, char **argv)
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 */
@@ -456,6 +485,12 @@ rearg:
(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':
@@ -711,22 +746,22 @@ Main_ParseArgLine(const char *line)
}
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, VARF_WANTRES);
- }
+ 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 */
@@ -739,16 +774,38 @@ Main_SetObjdir(const char *path)
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;
}
}
- 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.
@@ -979,6 +1036,7 @@ main(int argc, char **argv)
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 */
@@ -1053,6 +1111,8 @@ main(int argc, char **argv)
#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
@@ -1128,28 +1188,19 @@ main(int argc, char **argv)
* 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);
/*
* Initialize archive, target and suffix modules in preparation for
@@ -1303,8 +1354,9 @@ main(int argc, char **argv)
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
@@ -1883,31 +1935,60 @@ usage(void)
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)
{
- static GNode *cache;
+ GNode *cache;
char *rp, *cp;
if (!pathname || !pathname[0])
return NULL;
- if (!cache) {
- cache = Targ_NewGN("Realpath");
-#ifndef DEBUG_REALPATH_CACHE
- cache->flags = INTERNAL;
-#endif
- }
+ cache = get_cached_realpaths();
- rp = Var_Value(pathname, cache, &cp);
- if (rp) {
+ if ((rp = Var_Value(pathname, cache, &cp)) != NULL) {
/* a hit */
strlcpy(resolved, rp, MAXPATHLEN);
- } else if ((rp = realpath(pathname, resolved))) {
+ } else if ((rp = realpath(pathname, resolved)) != NULL) {
Var_Set(pathname, rp, cache, 0);
}
free(cp);
@@ -1922,6 +2003,14 @@ PrintAddr(void *a, void *b)
}
+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)
@@ -1942,6 +2031,8 @@ PrintOnError(GNode *gn, const char *s)
* 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);
diff --git a/contrib/bmake/make.1 b/contrib/bmake/make.1
index d542615..807c6fe 100644
--- a/contrib/bmake/make.1
+++ b/contrib/bmake/make.1
@@ -1,4 +1,4 @@
-.\" $NetBSD: make.1,v 1.259 2016/06/03 07:07:37 wiz Exp $
+.\" $NetBSD: make.1,v 1.266 2017/02/01 18:39:27 sjg Exp $
.\"
.\" Copyright (c) 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -29,7 +29,7 @@
.\"
.\" from: @(#)make.1 8.4 (Berkeley) 3/19/94
.\"
-.Dd June 2, 2016
+.Dd February 1, 2017
.Dt MAKE 1
.Os
.Sh NAME
@@ -938,6 +938,9 @@ The default list includes:
.It Va .MAKE.META.IGNORE_PATTERNS
Provides a list of patterns to match against pathnames.
Ignore any that match.
+.It Va .MAKE.META.IGNORE_FILTER
+Provides a list of variable modifiers to apply to each pathname.
+Ignore if the expansion is an empty string.
.It Va .MAKE.META.PREFIX
Defines the message printed for each meta file updated in "meta verbose" mode.
The default value is:
@@ -985,7 +988,19 @@ per normal evaluation rules.
.It Va MAKE_PRINT_VAR_ON_ERROR
When
.Nm
-stops due to an error, it prints its name and the value of
+stops due to an error, it sets
+.Ql Va .ERROR_TARGET
+to the name of the target that failed,
+.Ql Va .ERROR_CMD
+to the commands of the failed target,
+and in "meta" mode, it also sets
+.Ql Va .ERROR_CWD
+to the
+.Xr getcwd 3 ,
+and
+.Ql Va .ERROR_META_FILE
+to the path of the meta file (if any) describing the failed target.
+It then prints its name and the value of
.Ql Va .CURDIR
as well as the value of any variables named in
.Ql Va MAKE_PRINT_VAR_ON_ERROR .
@@ -1201,18 +1216,28 @@ safely through recursive invocations of
.Nm .
.It Cm \&:R
Replaces each word in the variable with everything but its suffix.
-.It Cm \&:gmtime
+.It Cm \&:range[=count]
+The value is an integer sequence representing the words of the original
+value, or the supplied
+.Va count .
+.It Cm \&:gmtime[=utc]
The value is a format string for
.Xr strftime 3 ,
-using the current
+using
.Xr gmtime 3 .
+If a
+.Va utc
+value is not provided or is 0, the current time is used.
.It Cm \&:hash
Compute a 32-bit hash of the value and encode it as hex digits.
-.It Cm \&:localtime
+.It Cm \&:localtime[=utc]
The value is a format string for
.Xr strftime 3 ,
-using the current
+using
.Xr localtime 3 .
+If a
+.Va utc
+value is not provided or is 0, the current time is used.
.It Cm \&:tA
Attempt to convert variable to an absolute path using
.Xr realpath 3 ,
@@ -1412,6 +1437,27 @@ For example.
.Pp
However a single character variable is often more readable:
.Dl ${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'${.newline}@}
+.It Cm \&:_[=var]
+Save the current variable value in
+.Ql $_
+or the named
+.Va var
+for later reference.
+Example usage:
+.Bd -literal -offset indent
+M_cmpv.units = 1 1000 1000000
+M_cmpv = S,., ,g:_:range:@i@+ $${_:[-$$i]} \&\\
+\\* $${M_cmpv.units:[$$i]}@:S,^,expr 0 ,1:sh
+
+.Dv .if ${VERSION:${M_cmpv}} < ${3.1.12:L:${M_cmpv}}
+
+.Ed
+Here
+.Ql $_
+is used to save the result of the
+.Ql :S
+modifier which is later referenced using the index values from
+.Ql :range .
.It Cm \&:U Ns Ar newval
If the variable is undefined
.Ar newval
@@ -2007,6 +2053,14 @@ variable of a target that inherits
.Ic .DEFAULT Ns 's
commands is set
to the target's own name.
+.It Ic .DELETE_ON_ERROR
+If this target is present in the makefile, it globally causes make to
+delete targets whose commands fail.
+(By default, only targets whose commands are interrupted during
+execution are deleted.
+This is the historical behavior.)
+This setting can be used to help prevent half-finished or malformed
+targets from being left around and corrupting future rebuilds.
.It Ic .END
Any command lines attached to this target are executed after everything
else is done.
diff --git a/contrib/bmake/make.c b/contrib/bmake/make.c
index 5ea04fc..8947582 100644
--- a/contrib/bmake/make.c
+++ b/contrib/bmake/make.c
@@ -1,4 +1,4 @@
-/* $NetBSD: make.c,v 1.95 2016/02/18 18:29:14 christos Exp $ */
+/* $NetBSD: make.c,v 1.96 2016/11/10 23:41:58 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: make.c,v 1.95 2016/02/18 18:29:14 christos 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
#if 0
static char sccsid[] = "@(#)make.c 8.1 (Berkeley) 6/6/93";
#else
-__RCSID("$NetBSD: make.c,v 1.95 2016/02/18 18:29:14 christos 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 @@ Make_OODate(GNode *gn)
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 {
diff --git a/contrib/bmake/make.h b/contrib/bmake/make.h
index 0fe12ab..d029db6 100644
--- a/contrib/bmake/make.h
+++ b/contrib/bmake/make.h
@@ -1,4 +1,4 @@
-/* $NetBSD: make.h,v 1.100 2016/06/07 00:40:00 sjg Exp $ */
+/* $NetBSD: make.h,v 1.102 2016/12/07 15:00:46 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -389,6 +389,7 @@ extern Boolean beSilent; /* True if should print no commands */
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 */
@@ -503,7 +504,7 @@ char * Check_Cwd_Cmd(const char *);
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 *);
diff --git a/contrib/bmake/make_malloc.c b/contrib/bmake/make_malloc.c
index b8ac23f..035d519 100644
--- a/contrib/bmake/make_malloc.c
+++ b/contrib/bmake/make_malloc.c
@@ -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 @@ __RCSID("$NetBSD: make_malloc.c,v 1.10 2012/06/20 17:46:28 sjg Exp $");
#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));
diff --git a/contrib/bmake/meta.c b/contrib/bmake/meta.c
index 13b955d..33c2dd8 100644
--- a/contrib/bmake/meta.c
+++ b/contrib/bmake/meta.c
@@ -1,4 +1,4 @@
-/* $NetBSD: meta.c,v 1.61 2016/06/07 00:40:00 sjg Exp $ */
+/* $NetBSD: meta.c,v 1.67 2016/08/17 15:52:42 sjg Exp $ */
/*
* Implement 'meta' mode.
@@ -69,6 +69,9 @@ static char *metaIgnorePathsStr; /* string storage for the list */
#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;
@@ -79,6 +82,7 @@ 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 */
@@ -237,7 +241,7 @@ eat_dots(char *buf, size_t bufsz, int dots)
}
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 *cwd)
@@ -392,7 +396,7 @@ printCMD(void *cmdp, void *mfpp)
* Do we need/want a .meta file ?
*/
static Boolean
-meta_needed(GNode *gn, const char *dname, const char *tname,
+meta_needed(GNode *gn, const char *dname,
char *objdir, int verbose)
{
struct stat fs;
@@ -472,7 +476,7 @@ meta_create(BuildMon *pbm, GNode *gn)
tname = Var_Value(TARGET, gn, &p[i++]);
/* if this succeeds objdir is realpath of dname */
- if (!meta_needed(gn, dname, tname, objdir, TRUE))
+ if (!meta_needed(gn, dname, objdir, TRUE))
goto out;
dname = objdir;
@@ -498,7 +502,7 @@ meta_create(BuildMon *pbm, GNode *gn)
/* Don't create meta data. */
goto out;
- fname = meta_name(gn, pbm->meta_fname, sizeof(pbm->meta_fname),
+ fname = meta_name(pbm->meta_fname, sizeof(pbm->meta_fname),
dname, tname, objdir);
#ifdef DEBUG_META_MODE
@@ -645,6 +649,11 @@ meta_mode_init(const char *make_mode)
metaIgnorePatterns = TRUE;
free(cp);
}
+ cp = NULL;
+ if (Var_Value(MAKE_META_IGNORE_FILTER, VAR_GLOBAL, &cp)) {
+ metaIgnoreFilter = TRUE;
+ free(cp);
+ }
}
/*
@@ -869,6 +878,7 @@ fgetLine(char **bufp, size_t *szp, int o, FILE *fp)
return 0;
}
+/* Lst_ForEach wants 1 to stop search */
static int
prefix_match(void *p, void *q)
{
@@ -879,6 +889,32 @@ prefix_match(void *p, void *q)
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)
{
@@ -889,6 +925,67 @@ string_match(const void *p, const void *q)
}
+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;
+
+ snprintf(fname, sizeof(fname),
+ "${%s:@m@${%s:L:M$m}@}",
+ MAKE_META_IGNORE_PATTERNS, p);
+ pm = Var_Subst(NULL, fname, 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 its meta data file is more recent.
@@ -952,7 +1049,7 @@ meta_oodate(GNode *gn, Boolean oodate)
tname = Var_Value(TARGET, gn, &pa[i++]);
/* if this succeeds fname3 is realpath of dname */
- if (!meta_needed(gn, dname, tname, fname3, FALSE))
+ if (!meta_needed(gn, dname, fname3, FALSE))
goto oodate_out;
dname = fname3;
@@ -966,7 +1063,7 @@ meta_oodate(GNode *gn, Boolean oodate)
*/
Make_DoAllVar(gn);
- meta_name(gn, fname, sizeof(fname), dname, tname, dname);
+ meta_name(fname, sizeof(fname), dname, tname, dname);
#ifdef DEBUG_META_MODE
if (DEBUG(META))
@@ -1170,12 +1267,19 @@ meta_oodate(GNode *gn, Boolean oodate)
/* 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') {
@@ -1240,8 +1344,10 @@ meta_oodate(GNode *gn, Boolean oodate)
if ((link_src != NULL && cached_lstat(p, &fs) < 0) ||
(link_src == NULL && cached_stat(p, &fs) < 0)) {
- if (Lst_Find(missingFiles, p, string_match) == NULL)
+ if (!meta_ignore(gn, p)) {
+ if (Lst_Find(missingFiles, p, string_match) == NULL)
Lst_AtEnd(missingFiles, bmake_strdup(p));
+ }
}
break;
check_link_src:
@@ -1259,37 +1365,9 @@ meta_oodate(GNode *gn, Boolean oodate)
* be part of the dependencies because
* they are _expected_ to change.
*/
- if (*p == '/') {
- cached_realpath(p, fname1); /* clean it up */
- if (Lst_ForEach(metaIgnorePaths, prefix_match, fname1)) {
-#ifdef DEBUG_META_MODE
- if (DEBUG(META))
- fprintf(debug_file, "meta_oodate: ignoring path: %s\n",
- p);
-#endif
- break;
- }
- }
-
- if (metaIgnorePatterns) {
- char *pm;
-
- snprintf(fname1, sizeof(fname1),
- "${%s:@m@${%s:L:M$m}@}",
- MAKE_META_IGNORE_PATTERNS, p);
- pm = Var_Subst(NULL, fname1, 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);
- break;
- }
- free(pm);
- }
-
+ if (meta_ignore(gn, p))
+ break;
+
/*
* The rest of the record is the file name.
* Check if it's not an absolute path.
@@ -1547,7 +1625,7 @@ meta_compat_parent(void)
while (fgets(buf, sizeof(buf), fp)) {
meta_job_output(NULL, buf, "");
printf("%s", buf);
- (void)fflush(stdout);
+ fflush(stdout);
}
fclose(fp);
}
diff --git a/contrib/bmake/mk/ChangeLog b/contrib/bmake/mk/ChangeLog
index de94df7..8e42c8c 100644
--- a/contrib/bmake/mk/ChangeLog
+++ b/contrib/bmake/mk/ChangeLog
@@ -1,3 +1,186 @@
+2017-05-08 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * install-mk (MK_VERSION): 20170505
+
+ * meta2deps.py: fix botched indenation.
+
+2017-05-05 Simon J. Gerraty <sjg@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@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@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@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@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@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@bad.crufty.net>
+
+ * auto.obj.mk: handle the case of __objdir=obj or obj.${MACHINE} etc.
+
+2017-03-18 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * mkopt.sh: treat WITH_*=NO like no; ie. WITHOUT_*
+
+2017-03-01 Simon J. Gerraty <sjg@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@bad.crufty.net>
+
+ * prog.mk (install_links): depends on realinstall
+
+2017-02-12 Simon J. Gerraty <sjg@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@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@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@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@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@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@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@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@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@bad.crufty.net>
+
+ * meta.sys.mk (META_COOKIE_TOUCH): use ${.OBJDIR}/${.TARGET:T} as default
+
+2016-08-15 Simon J. Gerraty <sjg@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@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@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@bad.crufty.net>
+
+ * dirdeps.mk (DIRDEPS_CACHE): no dirname.
+
2016-06-02 Simon J. Gerraty <sjg@bad.crufty.net>
* install-mk (MK_VERSION): 20160602
diff --git a/contrib/bmake/mk/FILES b/contrib/bmake/mk/FILES
index 0a72c67..acce4c0 100644
--- a/contrib/bmake/mk/FILES
+++ b/contrib/bmake/mk/FILES
@@ -9,6 +9,7 @@ cython.mk
dep.mk
doc.mk
dpadd.mk
+files.mk
final.mk
host-target.mk
host.libnames.mk
@@ -38,7 +39,9 @@ stage-install.sh
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
diff --git a/contrib/bmake/mk/auto.obj.mk b/contrib/bmake/mk/auto.obj.mk
index 2395f64..b4ea4d5 100644
--- a/contrib/bmake/mk/auto.obj.mk
+++ b/contrib/bmake/mk/auto.obj.mk
@@ -1,4 +1,4 @@
-# $Id: auto.obj.mk,v 1.12 2015/12/16 01:57:06 sjg Exp $
+# $Id: auto.obj.mk,v 1.14 2017/04/18 23:53:18 sjg Exp $
#
# @(#) Copyright (c) 2004, Simon J. Gerraty
#
@@ -41,6 +41,10 @@ MKOBJDIRS= auto
# Use __objdir here so it is easier to tweak without impacting
# the logic.
.if !empty(MAKEOBJDIRPREFIX)
+.if ${.CURDIR:M${MAKEOBJDIRPREFIX}/*} != ""
+# we are already in obj tree!
+__objdir?= ${.CURDIR}
+.endif
__objdir?= ${MAKEOBJDIRPREFIX}${.CURDIR}
.endif
__objdir?= ${MAKEOBJDIR:Uobj}
@@ -57,7 +61,10 @@ __objdir_made != echo ${__objdir}/; umask ${OBJDIR_UMASK:U002}; \
# This causes make to use the specified directory as .OBJDIR
.OBJDIR: ${__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
diff --git a/contrib/bmake/mk/dirdeps.mk b/contrib/bmake/mk/dirdeps.mk
index 0e57841..a0a40e5 100644
--- a/contrib/bmake/mk/dirdeps.mk
+++ b/contrib/bmake/mk/dirdeps.mk
@@ -1,4 +1,4 @@
-# $Id: dirdeps.mk,v 1.67 2016/04/18 21:50:47 sjg Exp $
+# $Id: dirdeps.mk,v 1.88 2017/04/24 20:34:59 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,18 +113,54 @@
# # 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 !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)
+# 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
#
@@ -144,15 +183,6 @@ MK_DIRDEPS_CACHE = no
# make sure we get the behavior we expect
.MAKE.SAVE_DOLLARS = no
-# 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
-
# make sure these are empty to start with
_DEP_TARGET_SPEC =
@@ -175,9 +205,15 @@ DEP_$v ?= ${$v}
# 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
@@ -223,6 +259,10 @@ N_notmachine := ${.MAKE.DEPENDFILE_PREFERENCE:E:N*${MACHINE}*:${M_ListToSkip}}
.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
@@ -287,6 +327,18 @@ _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.
@@ -305,8 +357,10 @@ SKIP_DIR.host += ${SKIP_HOSTDIR}
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}}
@@ -344,7 +398,7 @@ _DIRDEP_USE: .USE .MAKE
.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
@@ -353,7 +407,7 @@ _machine_list != 'ls' -1 ${_CURDIR}/${.MAKE.DEPENDFILE_PREFIX}.* 2> /dev/null; e
.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)
@@ -362,30 +416,35 @@ _only_machines := ${TARGET_MACHINE:U${ALL_MACHINE_LIST:U${DEP_MACHINE}}}
.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
-# 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 !defined(NO_DIRDEPS) && !defined(NO_DIRDEPS_BELOW)
.if ${MK_DIRDEPS_CACHE} == "yes"
-# this is where we will cache all our work
-DIRDEPS_CACHE?= ${_OBJDIR}/dirdeps.cache${.TARGETS:Nall:O:u:ts-:S,/,_,g:S,^,.,:N.}
# just ensure this exists
build-dirdeps:
@@ -397,6 +456,9 @@ M_oneperline = @x@\\${.newline} $$x@
# 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}"
@@ -417,6 +479,7 @@ ${DIRDEPS_CACHE}: .META .NOMETA_CMP
} > ${.TARGET}.new
+@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 \
@@ -486,8 +549,10 @@ _machines := ${_machines:O:u}
_dm := ${DEP_MACHINE}
# apply the same filtering that we do when qualifying DIRDEPS.
# M_dep_qual_fixes expects .${MACHINE}* so add (and remove) '.'
-_machines := ${_machines:@DEP_MACHINE@${DEP_TARGET_SPEC}@:S,^,.,:${M_dep_qual_fixes:ts:}:O:u:S,^.,,}
+# 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
@@ -519,7 +584,7 @@ _build_dirs += ${_machines:N${DEP_TARGET_SPEC}:@m@${_CURDIR}.$m@}
# 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
@@ -557,11 +622,11 @@ _build_dirs += \
# qualify everything now
_build_dirs := ${_build_dirs:${M_dep_qual_fixes:ts:}:O:u}
+.endif # empty DIRDEPS
+
_build_all_dirs += ${_build_dirs}
_build_all_dirs := ${_build_all_dirs:O:u}
-.endif # empty DIRDEPS
-
# 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.
@@ -618,6 +683,19 @@ _dirdeps_checked.$d:
.endif
# 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.
@@ -628,10 +706,6 @@ _qm := ${_m:C;(\.depend)$;\1.${d:E};:${M_dep_qual_fixes:ts:}}
.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/,.*//}
# set this "just in case"
# we can skip :tA since we computed the path above
DEP_RELDIR := ${_m:H:S,${SRCTOP}/,,}
@@ -669,7 +743,10 @@ _DEP_RELDIR := ${RELDIR}
make(bootstrap-recurse) || \
make(bootstrap-empty))
-.if exists(${.CURDIR}/${.MAKE.DEPENDFILE:T})
+# if we are bootstrapping create the default
+_want = ${.CURDIR}/${.MAKE.DEPENDFILE_DEFAULT:T}
+
+.if exists(${_want})
# stop here
${.TARGETS:Mboot*}:
.elif !make(bootstrap-empty)
@@ -679,12 +756,19 @@ _src != cd ${.CURDIR} && for m in ${.MAKE.DEPENDFILE_PREFERENCE:T:S,${MACHINE},*
.error cannot find any of ${.MAKE.DEPENDFILE_PREFERENCE:T}${.newline}Use: bootstrap-empty
.endif
-_src?= ${.MAKE.DEPENDFILE:T}
+_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}/${.MAKE.DEPENDFILE:T} from ${_src:T}
- (cd ${.CURDIR} && sed 's,${_src:E},${MACHINE},g' ${_src} > ${.MAKE.DEPENDFILE:T})
+ @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
@@ -704,8 +788,8 @@ bootstrap-recurse: .NOTMAIN .MAKE
# create an empty Makefile.depend* to get the ball rolling.
bootstrap-empty: .NOTMAIN .NOMETA
- @echo Creating empty ${RELDIR}/${.MAKE.DEPENDFILE:T}; \
+ @echo Creating empty ${RELDIR}/${_want:T}; \
echo You need to build ${RELDIR} to correctly populate it.
- @{ echo DIRDEPS=; echo ".include <dirdeps.mk>"; } > ${.CURDIR}/${.MAKE.DEPENDFILE:T}
+ @{ echo DIRDEPS=; echo ".include <dirdeps.mk>"; } > ${_want}
.endif
diff --git a/contrib/bmake/mk/doc.mk b/contrib/bmake/mk/doc.mk
index d1385e9..0ff8890 100644
--- a/contrib/bmake/mk/doc.mk
+++ b/contrib/bmake/mk/doc.mk
@@ -1,4 +1,4 @@
-# $Id: doc.mk,v 1.5 2015/09/08 06:15:31 sjg Exp $
+# $Id: doc.mk,v 1.6 2017/05/01 21:24:10 sjg Exp $
.if !target(__${.PARSEFILE}__)
__${.PARSEFILE}__:
@@ -59,7 +59,7 @@ spell: ${SRCS}
.include <own.mk>
.if !empty(DOCOWN)
-DOC_INSTALL_OWN?= -o ${DOCOWN} -g ${DOGGRP}
+DOC_INSTALL_OWN?= -o ${DOCOWN} -g ${DOCGRP}
.endif
.endif
diff --git a/contrib/bmake/mk/dpadd.mk b/contrib/bmake/mk/dpadd.mk
index c789acf..650d61b 100644
--- a/contrib/bmake/mk/dpadd.mk
+++ b/contrib/bmake/mk/dpadd.mk
@@ -1,4 +1,4 @@
-# $Id: dpadd.mk,v 1.22 2016/05/31 23:30:59 sjg Exp $
+# $Id: dpadd.mk,v 1.23 2017/02/13 16:46:01 sjg Exp $
#
# @(#) Copyright (c) 2004, Simon J. Gerraty
#
@@ -49,11 +49,11 @@ CXXFLAGS_LAST += ${CXXFLAGS_DEBUG_XTRA}
# DPLIBS helps us ensure we keep DPADD and LDADD in sync
DPLIBS+= ${DPLIBS_LAST}
DPADD+= ${DPLIBS:N-*}
-.for __lib in ${DPLIBS:T:R}
+.for __lib in ${DPLIBS}
.if "${_lib:M-*}" != ""
LDADD += ${__lib}
.else
-LDADD += ${LDADD_${__lib}:U${__lib:T:R:S/lib/-l/:C/\.so.*//}}
+LDADD += ${LDADD_${__lib:T:R}:U${__lib:T:R:S/lib/-l/:C/\.so.*//}}
.endif
.endfor
diff --git a/contrib/bmake/mk/files.mk b/contrib/bmake/mk/files.mk
new file mode 100644
index 0000000..fa16b11
--- /dev/null
+++ b/contrib/bmake/mk/files.mk
@@ -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@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
diff --git a/contrib/bmake/mk/final.mk b/contrib/bmake/mk/final.mk
index 235d36d..df1c81b 100644
--- a/contrib/bmake/mk/final.mk
+++ b/contrib/bmake/mk/final.mk
@@ -1,4 +1,4 @@
-# $Id: final.mk,v 1.6 2016/04/05 15:58:37 sjg Exp $
+# $Id: final.mk,v 1.8 2017/05/07 20:30:08 sjg Exp $
.if !target(__${.PARSEFILE}__)
__${.PARSEFILE}__:
@@ -6,9 +6,17 @@ __${.PARSEFILE}__:
# provide a hook for folk who want to do scary stuff
.-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
diff --git a/contrib/bmake/mk/gendirdeps.mk b/contrib/bmake/mk/gendirdeps.mk
index 68f32be..9ac7dcd 100644
--- a/contrib/bmake/mk/gendirdeps.mk
+++ b/contrib/bmake/mk/gendirdeps.mk
@@ -1,4 +1,4 @@
-# $Id: gendirdeps.mk,v 1.32 2016/04/05 15:58: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.
@@ -146,6 +146,9 @@ M2D_OBJROOTS += ${OBJTOP} ${_OBJROOT} ${_objroot}
.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
diff --git a/contrib/bmake/mk/inc.mk b/contrib/bmake/mk/inc.mk
index 5d57f52..74626d3 100644
--- a/contrib/bmake/mk/inc.mk
+++ b/contrib/bmake/mk/inc.mk
@@ -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 @@ INCMODE ?= 444
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
diff --git a/contrib/bmake/mk/init.mk b/contrib/bmake/mk/init.mk
index cb5ab82..81b76d5 100644
--- a/contrib/bmake/mk/init.mk
+++ b/contrib/bmake/mk/init.mk
@@ -1,4 +1,4 @@
-# $Id: init.mk,v 1.12 2016/04/05 15:58:37 sjg Exp $
+# $Id: init.mk,v 1.15 2017/05/07 20:27:54 sjg Exp $
#
# @(#) Copyright (c) 2002, Simon J. Gerraty
#
@@ -50,8 +50,20 @@ PROFFLAGS?= -DGPROF -DPROF
_SKIP_BUILD = not building at level 0
.endif
-.if !empty(_SKIP_BUILD)
+.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
diff --git a/contrib/bmake/mk/install-mk b/contrib/bmake/mk/install-mk
index 74b0939..50da97c 100644
--- a/contrib/bmake/mk/install-mk
+++ b/contrib/bmake/mk/install-mk
@@ -55,7 +55,7 @@
# Simon J. Gerraty <sjg@crufty.net>
# RCSid:
-# $Id: install-mk,v 1.128 2016/06/03 17:22:32 sjg Exp $
+# $Id: install-mk,v 1.145 2017/05/09 04:05:32 sjg Exp $
#
# @(#) Copyright (c) 1994 Simon J. Gerraty
#
@@ -70,7 +70,7 @@
# sjg@crufty.net
#
-MK_VERSION=20160602
+MK_VERSION=20170505
OWNER=
GROUP=
MODE=444
@@ -176,7 +176,7 @@ $SKIP_MKFILES Do chmod $BINMODE $mk_scripts
[ "$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
diff --git a/contrib/bmake/mk/lib.mk b/contrib/bmake/mk/lib.mk
index 2361266..0cc1466 100644
--- a/contrib/bmake/mk/lib.mk
+++ b/contrib/bmake/mk/lib.mk
@@ -1,4 +1,4 @@
-# $Id: lib.mk,v 1.53 2016/03/22 20:45:14 sjg Exp $
+# $Id: lib.mk,v 1.61 2017/05/06 17:30:09 sjg Exp $
.if !target(__${.PARSEFILE}__)
__${.PARSEFILE}__:
@@ -9,44 +9,35 @@ __${.PARSEFILE}__:
NEED_SOLINKS?= yes
.endif
-.if exists(${.CURDIR}/shlib_version)
-SHLIB_MAJOR != . ${.CURDIR}/shlib_version ; echo $$major
-SHLIB_MINOR != . ${.CURDIR}/shlib_version ; echo $$minor
-.endif
-
-print-shlib-major:
-.if defined(SHLIB_MAJOR) && ${MK_PIC} != "no"
- @echo ${SHLIB_MAJOR}
-.else
- @false
+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-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}
+.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
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 @@ CFLAGS+= ${COPTS}
# 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,14 +153,14 @@ LD_shared=-b
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 '*'
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,9 +241,9 @@ AR_cq ?= cq
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_DIRDEPS_BUILD} == "yes" && ${SRCS:Uno:[\#]} > 42
OPTIMIZE_OBJECT_META_FILES ?= yes
@@ -287,7 +278,7 @@ ${CXX_SUFFIXES:%=%.o}:
${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:
@@ -302,7 +293,7 @@ ${CXX_SUFFIXES:%=%.po}:
@${LD} ${LD_X} ${LD_r} ${.TARGET}.o -o ${.TARGET}
@rm -f ${.TARGET}.o
-.S.So .s.So:
+.S${PICO} .s${PICO}:
@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}
@@ -310,23 +301,23 @@ ${CXX_SUFFIXES:%=%.po}:
.endif
.if (${LD_x} == "")
-.c.So:
+.c${PICO}:
${COMPILE.c} ${PICFLAG} ${CC_PIC} ${.IMPSRC} -o ${.TARGET}
-${CXX_SUFFIXES:%=%.So}:
+${CXX_SUFFIXES:%=%${PICO}}:
${COMPILE.cc} ${PICFLAG} ${CC_PIC} ${.IMPSRC} -o ${.TARGET}
.S.po .s.po:
${COMPILE.S} ${PROFFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}
.else
-.c.So:
+.c${PICO}:
@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}
@rm -f ${.TARGET}.o
-${CXX_SUFFIXES:%=%.So}:
+${CXX_SUFFIXES:%=%${PICO}}:
@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}
@@ -384,19 +375,18 @@ _LIBS+=llib-l${LIB}.ln
.include <dpadd.mk>
.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:
+.if empty(LIB)
+_LIBS=
.endif
+
+.if !defined(_SKIP_BUILD)
+realbuild: ${_LIBS}
.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}
@@ -441,7 +431,7 @@ lib${LIB}_p.a:: ${POBJS}
@${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
@@ -502,7 +492,7 @@ cleandir: _SUBDIRUSE clean
.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,7 +508,7 @@ LIB_INSTALL_OWN ?= -o ${LIBOWN} -g ${LIBGRP}
.include <links.mk>
-.if !target(realinstall)
+.if !target(realinstall) && !empty(LIB)
realinstall: libinstall
.endif
.if !target(libinstall)
@@ -561,12 +551,19 @@ libinstall:
.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 +596,10 @@ realinstall: beforeinstall
.endfor
@touch ${.TARGET}
+.if !empty(LIB)
+STAGE_LIBDIR?= ${STAGE_OBJTOP}${LIBDIR}
+stage_libs: ${_LIBS}
+.endif
+
.include <final.mk>
.endif
diff --git a/contrib/bmake/mk/meta.stage.mk b/contrib/bmake/mk/meta.stage.mk
index 11eb5c3..7383aad 100644
--- a/contrib/bmake/mk/meta.stage.mk
+++ b/contrib/bmake/mk/meta.stage.mk
@@ -1,6 +1,6 @@
-# $Id: meta.stage.mk,v 1.45 2016/05/26 03:59:09 sjg Exp $
+# $Id: meta.stage.mk,v 1.49 2017/04/01 02:10:34 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@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
@@ -58,7 +60,7 @@ GENDIRDEPS_FILTER += Nnot-empty-is-important \
LN_CP_SCRIPT = LnCp() { \
rm -f $$2 2> /dev/null; \
- { [ -z "$$mode" ] && 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
@@ -127,26 +129,17 @@ STAGE_AS_SCRIPT = ${STAGE_DIRDEP_SCRIPT}; StageAs() { \
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 ${.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}}
-.if !empty(STAGE_INCSDIR)
-STAGE_TARGETS += stage_incs
-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
-
-.if !empty(STAGE_LIBDIR)
-STAGE_TARGETS += stage_libs
-
-STAGE_LIBS ?= ${.ALLSRC:N.dirdep:Nstage_*}
stage_libs: .dirdep
@${STAGE_FILE_SCRIPT}; StageFiles ${STAGE_LIBDIR:${STAGE_DIR_FILTER}} ${STAGE_LIBS}
@@ -159,6 +152,18 @@ stage_libs: .dirdep
.endif
.endif
@touch $@
+
+.endif # first time
+
+
+.if !empty(STAGE_INCSDIR)
+STAGE_TARGETS += stage_incs
+STAGE_INCS ?= ${.ALLSRC:N.dirdep:Nstage_*}
+.endif
+
+.if !empty(STAGE_LIBDIR)
+STAGE_TARGETS += stage_libs
+STAGE_LIBS ?= ${.ALLSRC:N.dirdep:Nstage_*}
.endif
.if !empty(STAGE_DIR)
@@ -184,6 +189,8 @@ STAGE_LINKS_DIR.$s ?= ${STAGE_OBJTOP}
STAGE_SYMLINKS_DIR.$s ?= ${STAGE_OBJTOP}
STAGE_TARGETS += stage_files
+.if !target(.stage_files.$s)
+.stage_files.$s:
.if $s != "_default"
stage_files: stage_files.$s
stage_files.$s: .dirdep
@@ -192,8 +199,11 @@ 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
STAGE_TARGETS += stage_links
+.if !target(.stage_links.$s)
+.stage_links.$s:
.if $s != "_default"
stage_links: stage_links.$s
stage_links.$s: .dirdep
@@ -202,8 +212,11 @@ stage_links: .dirdep
.endif
@${STAGE_LINKS_SCRIPT}; StageLinks ${STAGE_LINKS_DIR.$s:U${STAGE_DIR.$s}:${STAGE_DIR_FILTER}} ${STAGE_LINKS.$s}
@touch $@
+.endif
STAGE_TARGETS += stage_symlinks
+.if !target(.stage_symlinks.$s)
+.stage_symlinks.$s:
.if $s != "_default"
stage_symlinks: stage_symlinks.$s
stage_symlinks.$s: .dirdep
@@ -212,6 +225,7 @@ stage_symlinks: .dirdep
.endif
@${STAGE_LINKS_SCRIPT}; StageLinks -s ${STAGE_SYMLINKS_DIR.$s:U${STAGE_DIR.$s}:${STAGE_DIR_FILTER}} ${STAGE_SYMLINKS.$s}
@touch $@
+.endif
.endfor
.endif
@@ -219,24 +233,44 @@ stage_symlinks: .dirdep
.if !empty(STAGE_AS_SETS)
CLEANFILES += ${STAGE_AS_SETS:@s@stage*$s@}
-STAGE_TARGETS += stage_as
+STAGE_TARGETS += stage_as stage_as_and_symlink
# 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:Nstage_*}
+STAGE_AS_AND_SYMLINK.$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:tA}:U${STAGE_AS_${f:T}:U${f:T}}}@}
@touch $@
+.endif
+
+.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
.endfor
.endif
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}
@@ -292,3 +326,4 @@ stale_staged: staging .NOMETA
.endif
.endif
.endif
+.endif
diff --git a/contrib/bmake/mk/meta.sys.mk b/contrib/bmake/mk/meta.sys.mk
index dde2c48..747d85e 100644
--- a/contrib/bmake/mk/meta.sys.mk
+++ b/contrib/bmake/mk/meta.sys.mk
@@ -1,4 +1,4 @@
-# $Id: meta.sys.mk,v 1.28 2016/04/05 15:58:37 sjg Exp $
+# $Id: meta.sys.mk,v 1.31 2016/09/10 00:44:46 sjg Exp $
#
# @(#) Copyright (c) 2010, Simon J. Gerraty
@@ -25,6 +25,10 @@
# 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}
@@ -98,9 +102,6 @@ _metaError: .NOMETA .NOTMAIN
.endif
-META_COOKIE_TOUCH=
-# some targets need to be .PHONY in non-meta mode
-META_NOPHONY= .PHONY
# Are we, after all, in meta mode?
.if ${.MAKE.MODE:Uno:Mmeta*} != ""
MKDEP_MK = meta.autodep.mk
@@ -117,8 +118,17 @@ MKDEP_MK = meta.autodep.mk
# we can afford to use cookies to prevent some targets
# re-running needlessly
-META_COOKIE_TOUCH= touch ${COOKIE.${.TARGET}:U${.OBJDIR}/${.TARGET}}
+META_COOKIE_TOUCH?= touch ${COOKIE.${.TARGET}:U${.OBJDIR}/${.TARGET:T}}
META_NOPHONY=
+
+# 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
@@ -149,5 +159,9 @@ BUILD_AT_LEVEL0 ?= no
.endif
.endif
+.else
+META_COOKIE_TOUCH=
+# some targets need to be .PHONY in non-meta mode
+META_NOPHONY= .PHONY
.endif
.endif
diff --git a/contrib/bmake/mk/meta2deps.py b/contrib/bmake/mk/meta2deps.py
index 6361493..22eef5f 100755
--- a/contrib/bmake/mk/meta2deps.py
+++ b/contrib/bmake/mk/meta2deps.py
@@ -37,7 +37,7 @@ We only pay attention to a subset of the information in the
"""
RCSid:
- $Id: meta2deps.py,v 1.19 2016/04/02 20:45:40 sjg Exp $
+ $Id: meta2deps.py,v 1.26 2017/05/09 04:04:16 sjg Exp $
Copyright (c) 2011-2013, Juniper Networks, Inc.
All rights reserved.
@@ -103,20 +103,36 @@ def resolve(path, cwd, last_dir=None, debug=0, debug_out=sys.stderr):
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 == '..':
+ p.pop()
+ continue
+ 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.find('./') > 0 or
- path.endswith('/..') or
- os.path.islink(path)):
- return os.path.realpath(path)
+ path.find('./') > 0 or
+ path.endswith('/..')):
+ path = cleanpath(path)
return path
def sort_unique(list, cmp=None, key=None, reverse=False):
@@ -126,6 +142,7 @@ def sort_unique(list, cmp=None, key=None, reverse=False):
for e in list:
if e == le:
continue
+ le = e
nl.append(e)
return nl
@@ -153,38 +170,38 @@ class MetaFile:
"""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'
- EXCLUDES
- A list of paths to ignore.
- ccache(1) can otherwise be trouble.
+ EXCLUDES
+ A list of paths to ignore.
+ ccache(1) can otherwise be trouble.
- debug desired debug level
+ debug desired debug level
debug_out open file to send debug output to (sys.stderr)
@@ -228,8 +245,9 @@ class MetaFile:
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)
@@ -292,6 +310,9 @@ class MetaFile:
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."""
@@ -359,28 +380,28 @@ class MetaFile:
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"
- F "pid" "child"
- R "pid" "path"
- W "pid" "path"
- X "pid" "status"
- D "pid" "path"
- L "pid" "src" "target"
- M "pid" "old" "new"
- S "pid" "path"
- # Bye bye
-
- We go to some effort to avoid processing a dependency more than once.
- Of the above record types only C,E,F,L,R,V and W are of interest.
+ # 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"
+ D "pid" "path"
+ L "pid" "src" "target"
+ M "pid" "old" "new"
+ S "pid" "path"
+ # Bye bye
+
+ We go to some effort to avoid processing a dependency more than once.
+ Of the above record types only C,E,F,L,R,V and W are of interest.
"""
version = 0 # unknown
@@ -430,7 +451,6 @@ class MetaFile:
pid = int(w[1])
if pid != last_pid:
if last_pid:
- pid_cwd[last_pid] = cwd
pid_last_dir[last_pid] = self.last_dir
cwd = getv(pid_cwd, pid, self.cwd)
self.last_dir = getv(pid_last_dir, pid, self.cwd)
@@ -447,7 +467,8 @@ class MetaFile:
cwd = abspath(w[2], cwd, None, self.debug, self.debug_out)
if cwd.endswith('/.'):
cwd = cwd[0:-2]
- self.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
@@ -470,6 +491,21 @@ class MetaFile:
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
+ path = '/'.join([dir,base])
+ 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
+
def parse_path(self, path, cwd, op=None, w=[]):
"""look at a path for the op specified"""
@@ -498,7 +534,8 @@ class MetaFile:
# 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)
- if rdir == dir or rdir.find('./') > 0:
+ rdir = os.path.realpath(dir)
+ if rdir == dir:
rdir = None
# now put path back together
path = '/'.join([dir,base])
@@ -520,17 +557,9 @@ class MetaFile:
# finally, we get down to it
if dir == self.cwd or dir == self.curdir:
return
- 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')
+ if self.is_src(base, dir, rdir):
self.seenit(w[2])
- self.seenit(dir)
- if rdir and not rdir.startswith(srctop):
- dir = rdir # for below
- rdir = None
- else:
+ if not rdir:
return
objroot = None
@@ -544,6 +573,9 @@ class MetaFile:
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])
diff --git a/contrib/bmake/mk/meta2deps.sh b/contrib/bmake/mk/meta2deps.sh
index a9ea075..7caf690 100755
--- a/contrib/bmake/mk/meta2deps.sh
+++ b/contrib/bmake/mk/meta2deps.sh
@@ -77,7 +77,7 @@
# RCSid:
-# $Id: meta2deps.sh,v 1.10 2016/03/02 18:53:36 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.
@@ -255,7 +255,7 @@ meta2deps() {
*)
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
@@ -271,9 +271,11 @@ meta2deps() {
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%/*}
diff --git a/contrib/bmake/mk/mkopt.sh b/contrib/bmake/mk/mkopt.sh
index c3a39c5..ad58479 100755
--- a/contrib/bmake/mk/mkopt.sh
+++ b/contrib/bmake/mk/mkopt.sh
@@ -1,5 +1,5 @@
:
-# $Id: mkopt.sh,v 1.10 2015/06/07 17:29:08 sjg Exp $
+# $Id: mkopt.sh,v 1.11 2017/03/18 21:36:42 sjg Exp $
#
# @(#) Copyright (c) 2014, Simon J. Gerraty
#
@@ -40,7 +40,7 @@ _mk_opt() {
eval "_mov=\$$_mo _wov=\$$_wo _wiv=\$$_wi"
case "$_wiv" in
- no) _wov=no;;
+ [Nn][Oo]) _wov=no;;
esac
_v=${_mov:-${_wov:+no}}
_v=${_v:-${_wiv:+yes}}
diff --git a/contrib/bmake/mk/own.mk b/contrib/bmake/mk/own.mk
index b9e4f99..1d087ac 100644
--- a/contrib/bmake/mk/own.mk
+++ b/contrib/bmake/mk/own.mk
@@ -1,4 +1,4 @@
-# $Id: own.mk,v 1.32 2016/05/18 20:54:29 sjg Exp $
+# $Id: own.mk,v 1.35 2017/05/03 18:09:44 sjg Exp $
.if !target(__${.PARSEFILE}__)
__${.PARSEFILE}__:
@@ -117,6 +117,7 @@ OPTIONS_DEFAULT_DEPENDENT+= \
PICINSTALL/LINKLIB \
PICLIB/PIC \
PROFILE/LINKLIB \
+ STAGING_PROG/STAGING \
.include <options.mk>
@@ -128,7 +129,7 @@ _uid!= id -u
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 SHARE
$xOWN= ${USER}
$xGRP= ${USERGRP}
$x_INSTALL_OWN=
@@ -145,6 +146,9 @@ BINMODE?= 555
NONBINMODE?= 444
DIRMODE?= 755
+INCLUDEDIR?= ${prefix}/include
+INCDIR?= ${INCLUDEDIR}
+
# Define MANZ to have the man pages compressed (gzip)
#MANZ= 1
@@ -184,6 +188,10 @@ KMODGRP?= ${BINGRP}
KMODOWN?= ${BINOWN}
KMODMODE?= ${NONBINMODE}
+SHAREGRP?= ${BINGRP}
+SHAREOWN?= ${BINOWN}
+SHAREMODE?= ${NONBINMODE}
+
COPY?= -c
STRIP_FLAG?= -s
@@ -244,4 +252,19 @@ MK_MAN= no
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
diff --git a/contrib/bmake/mk/prog.mk b/contrib/bmake/mk/prog.mk
index db77da2..2d6abb3 100644
--- a/contrib/bmake/mk/prog.mk
+++ b/contrib/bmake/mk/prog.mk
@@ -1,4 +1,4 @@
-# $Id: prog.mk,v 1.26 2016/03/22 20:45:14 sjg Exp $
+# $Id: prog.mk,v 1.32 2017/05/06 17:30:09 sjg Exp $
.if !target(__${.PARSEFILE}__)
__${.PARSEFILE}__:
@@ -75,6 +75,8 @@ ${CXX_SUFFIXES:%=%.o}:
.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
@@ -126,8 +128,9 @@ MAN= ${PROG}.1
.endif # defined(PROG)
.if !defined(_SKIP_BUILD)
-all: ${PROG}
+realbuild: ${PROG}
.endif
+
all: _SUBDIRUSE
.if !target(clean)
@@ -191,6 +194,8 @@ install_links:
maninstall: afterinstall
afterinstall: realinstall
+install_links: realinstall
+proginstall: beforeinstall
realinstall: beforeinstall
.endif
@@ -206,6 +211,10 @@ lint: ${LOBJS}
.NOPATH: ${OBJS}
.endif
+.if defined(FILES) || defined(FILESGROUPS)
+.include <files.mk>
+.endif
+
.if ${MK_MAN} != "no"
.include <man.mk>
.endif
@@ -217,6 +226,20 @@ lint: ${LOBJS}
.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
diff --git a/contrib/bmake/mk/scripts.mk b/contrib/bmake/mk/scripts.mk
index efd65f9..9b6d82f 100644
--- a/contrib/bmake/mk/scripts.mk
+++ b/contrib/bmake/mk/scripts.mk
@@ -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@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}}}@}
-
-scriptsinstall:: ${script_targets}
+.if !target(buildfiles)
+.for group in ${SCRIPTSGROUPS}
+buildfiles: ${${group}}
+.endfor
+.endif
+buildfiles:
+realbuild: buildfiles
-.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
diff --git a/contrib/bmake/mk/subdir.mk b/contrib/bmake/mk/subdir.mk
index 2511d10..1d5001a 100644
--- a/contrib/bmake/mk/subdir.mk
+++ b/contrib/bmake/mk/subdir.mk
@@ -1,4 +1,4 @@
-# $Id: subdir.mk,v 1.15 2016/04/05 15:58:37 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 $
@@ -45,13 +45,18 @@ _SUBDIRUSE: .USE
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
diff --git a/contrib/bmake/mk/sys.debug.mk b/contrib/bmake/mk/sys.debug.mk
new file mode 100644
index 0000000..7debfc6
--- /dev/null
+++ b/contrib/bmake/mk/sys.debug.mk
@@ -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@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
diff --git a/contrib/bmake/mk/sys.mk b/contrib/bmake/mk/sys.mk
index 325ce82..55f615d 100644
--- a/contrib/bmake/mk/sys.mk
+++ b/contrib/bmake/mk/sys.mk
@@ -1,4 +1,4 @@
-# $Id: sys.mk,v 1.43 2016/04/05 15:58:37 sjg Exp $
+# $Id: sys.mk,v 1.45 2017/02/05 01:26:13 sjg Exp $
#
# @(#) Copyright (c) 2003-2009, Simon J. Gerraty
#
@@ -15,38 +15,8 @@
# 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
-
-# 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
+# _DEBUG_MAKE_FLAGS etc.
+.include <sys.debug.mk>
.if !empty(_DEBUG_MAKE_FLAGS)
.if ${_DEBUG_MAKE_SYS_DIRS:Uno:@x@${.CURDIR:M$x}@} != ""
@@ -54,47 +24,8 @@ _DEBUG_MAKE_DIRS = ${DEBUG_MAKE_DIRS}
.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
-
-# 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
-
-# absoulte path to what we are reading.
-_PARSEDIR = ${.PARSEDIR:${M_tA}}
+# useful modifiers
+.include <sys.vars.mk>
# we expect a recent bmake
.if !defined(_TARGETS)
@@ -140,11 +71,11 @@ SYS_OS_MK := ${_sys_mk}
# some options we need to know early
OPTIONS_DEFAULT_NO += \
DIRDEPS_BUILD \
- DIRDEPS_CACHE \
- META_MODE
+ DIRDEPS_CACHE
OPTIONS_DEFAULT_DEPENDENT += \
AUTO_OBJ/DIRDEPS_BUILD \
+ META_MODE/DIRDEPS_BUILD \
STAGING/DIRDEPS_BUILD \
.-include <options.mk>
diff --git a/contrib/bmake/mk/sys.vars.mk b/contrib/bmake/mk/sys.vars.mk
new file mode 100644
index 0000000..f2cb00e
--- /dev/null
+++ b/contrib/bmake/mk/sys.vars.mk
@@ -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@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@+ $${_:[-$$i]} \* $${M_cmpv.units:[$$i]}@:S,^,expr 0 ,1:sh
+.endif
+
+# absoulte path to what we are reading.
+_PARSEDIR = ${.PARSEDIR:${M_tA}}
diff --git a/contrib/bmake/mk/sys/AIX.mk b/contrib/bmake/mk/sys/AIX.mk
index 3109c23..895b92f 100644
--- a/contrib/bmake/mk/sys/AIX.mk
+++ b/contrib/bmake/mk/sys/AIX.mk
@@ -67,8 +67,6 @@ LDFLAGS=
LINT= lint
LINTFLAGS= -chapbx
-MAKE= bmake
-
PC= pc
PFLAGS=
COMPILE.p= ${PC} ${PFLAGS} ${CPPFLAGS} -c
diff --git a/contrib/bmake/mk/sys/Darwin.mk b/contrib/bmake/mk/sys/Darwin.mk
index 28cb414..c6beb72 100644
--- a/contrib/bmake/mk/sys/Darwin.mk
+++ b/contrib/bmake/mk/sys/Darwin.mk
@@ -84,8 +84,6 @@ LINTFLAGS?= -chapbx
LORDER?= lorder
-MAKE?= bmake
-
NM?= nm
PC?= pc
diff --git a/contrib/bmake/mk/sys/Generic.mk b/contrib/bmake/mk/sys/Generic.mk
index acf7832..9e3e6a7 100644
--- a/contrib/bmake/mk/sys/Generic.mk
+++ b/contrib/bmake/mk/sys/Generic.mk
@@ -1,4 +1,4 @@
-# $Id: Generic.mk,v 1.12 2016/03/22 20:45:14 sjg Exp $
+# $Id: Generic.mk,v 1.13 2017/05/05 18:02:16 sjg Exp $
#
# some reasonable defaults
@@ -80,8 +80,6 @@ LDFLAGS?=
LINT?= lint
LINTFLAGS?= -chapbxzF
-MAKE?= ${.MAKE}
-
NM?= nm
PC?= pc
diff --git a/contrib/bmake/mk/sys/HP-UX.mk b/contrib/bmake/mk/sys/HP-UX.mk
index 95cc595..29157b9 100644
--- a/contrib/bmake/mk/sys/HP-UX.mk
+++ b/contrib/bmake/mk/sys/HP-UX.mk
@@ -1,4 +1,4 @@
-# $Id: HP-UX.mk,v 1.10 2016/03/22 20:45:14 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
@@ -101,8 +101,6 @@ LDFLAGS=
LINT= lint
LINTFLAGS= -chapbx
-MAKE= bmake
-
PC= pc
PFLAGS=
COMPILE.p= ${PC} ${PFLAGS} ${CPPFLAGS} -c
diff --git a/contrib/bmake/mk/sys/IRIX.mk b/contrib/bmake/mk/sys/IRIX.mk
index 6909bdf..3d2236b 100644
--- a/contrib/bmake/mk/sys/IRIX.mk
+++ b/contrib/bmake/mk/sys/IRIX.mk
@@ -70,8 +70,6 @@ LINTFLAGS?= -chapbxzF
LORDER?= lorder
-MAKE?= make
-
NM?= nm
PC?= pc
diff --git a/contrib/bmake/mk/sys/Linux.mk b/contrib/bmake/mk/sys/Linux.mk
index c619412..090de3a 100644
--- a/contrib/bmake/mk/sys/Linux.mk
+++ b/contrib/bmake/mk/sys/Linux.mk
@@ -1,4 +1,4 @@
-# $Id: Linux.mk,v 1.8 2016/03/22 20:45:14 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
@@ -70,8 +70,6 @@ LDFLAGS=
LINT= lint
LINTFLAGS= -chapbx
-MAKE= bmake
-
PC= pc
PFLAGS=
COMPILE.p= ${PC} ${PFLAGS} ${CPPFLAGS} -c
diff --git a/contrib/bmake/mk/sys/NetBSD.mk b/contrib/bmake/mk/sys/NetBSD.mk
index a17a3f8..00ea9a6 100644
--- a/contrib/bmake/mk/sys/NetBSD.mk
+++ b/contrib/bmake/mk/sys/NetBSD.mk
@@ -105,8 +105,6 @@ LINTFLAGS?= -chapbxzF
LORDER?= lorder
-MAKE?= make
-
NM?= nm
PC?= pc
diff --git a/contrib/bmake/mk/sys/OSF1.mk b/contrib/bmake/mk/sys/OSF1.mk
index dfaa896..1b4515a 100644
--- a/contrib/bmake/mk/sys/OSF1.mk
+++ b/contrib/bmake/mk/sys/OSF1.mk
@@ -1,4 +1,4 @@
-# $Id: OSF1.mk,v 1.7 2016/03/22 20:45:15 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
@@ -77,8 +77,6 @@ LDFLAGS=
LINT= lint
LINTFLAGS= -chapbx
-MAKE= bmake
-
PC= pc
PFLAGS=
COMPILE.p= ${PC} ${PFLAGS} ${CPPFLAGS} -c
diff --git a/contrib/bmake/mk/sys/OpenBSD.mk b/contrib/bmake/mk/sys/OpenBSD.mk
index c8d7e3e..a570c1c 100644
--- a/contrib/bmake/mk/sys/OpenBSD.mk
+++ b/contrib/bmake/mk/sys/OpenBSD.mk
@@ -80,8 +80,6 @@ LINTFLAGS?= -chapbxzF
LORDER?= lorder
-MAKE?= make
-
NM?= nm
PC?= pc
diff --git a/contrib/bmake/mk/sys/SunOS.mk b/contrib/bmake/mk/sys/SunOS.mk
index 75d83c2..2fb5128 100644
--- a/contrib/bmake/mk/sys/SunOS.mk
+++ b/contrib/bmake/mk/sys/SunOS.mk
@@ -1,4 +1,4 @@
-# $Id: SunOS.mk,v 1.7 2016/03/22 20:45:15 sjg Exp $
+# $Id: SunOS.mk,v 1.8 2017/05/05 18:02:17 sjg Exp $
.if ${.PARSEFILE} == "sys.mk"
.include <host-target.mk>
@@ -98,8 +98,6 @@ LDFLAGS=
LINT= lint
LINTFLAGS= -chapbx
-MAKE= bmake
-
PC= pc
PFLAGS=
COMPILE.p= ${PC} ${PFLAGS} ${CPPFLAGS} -c
diff --git a/contrib/bmake/mk/sys/UnixWare.mk b/contrib/bmake/mk/sys/UnixWare.mk
index 49a52a2..d65ca01 100644
--- a/contrib/bmake/mk/sys/UnixWare.mk
+++ b/contrib/bmake/mk/sys/UnixWare.mk
@@ -1,4 +1,4 @@
-# $Id: UnixWare.mk,v 1.2 2016/03/22 20:45:15 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
@@ -114,8 +114,6 @@ LINTFLAGS?= -pF
LORDER?= lorder
-MAKE?= bmake
-
NM?= nm
PC?= pc # XXX: UDK probably does not have pc
diff --git a/contrib/bmake/nonints.h b/contrib/bmake/nonints.h
index 4756935..170ea7f 100644
--- a/contrib/bmake/nonints.h
+++ b/contrib/bmake/nonints.h
@@ -1,4 +1,4 @@
-/* $NetBSD: nonints.h,v 1.73 2016/06/03 01:21:59 sjg Exp $ */
+/* $NetBSD: nonints.h,v 1.74 2016/09/05 00:40:29 sevan Exp $ */
/*-
* Copyright (c) 1988, 1989, 1990, 1993
@@ -109,7 +109,6 @@ void JobReapChild(pid_t, WAIT_T, Boolean);
/* 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;
diff --git a/contrib/bmake/os.sh b/contrib/bmake/os.sh
index 1dd394f..8468ba1 100755
--- a/contrib/bmake/os.sh
+++ b/contrib/bmake/os.sh
@@ -17,7 +17,7 @@
# Simon J. Gerraty <sjg@crufty.net>
# RCSid:
-# $Id: os.sh,v 1.50 2015/12/17 17:06:29 sjg Exp $
+# $Id: os.sh,v 1.53 2017/01/11 20:01:09 sjg Exp $
#
# @(#) Copyright (c) 1994 Simon J. Gerraty
#
@@ -139,7 +139,7 @@ SunOS)
case $OS in
NetBSD)
HOST_ARCH=$MACHINE
- SHARE_ARCH=$OS/$HOST
+ SHARE_ARCH=$OS/$HOST_ARCH
;;
OpenBSD)
arch=`Which arch /usr/bin:/usr/ucb:$PATH`
@@ -206,15 +206,23 @@ esac
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/$HOST_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}-$HOST_ARCH | tr -d / | toLower`
-export HOST_TARGET
+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
diff --git a/contrib/bmake/parse.c b/contrib/bmake/parse.c
index 6d2cfb4..b351fe1 100644
--- a/contrib/bmake/parse.c
+++ b/contrib/bmake/parse.c
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.214 2016/04/06 09:57:00 gson Exp $ */
+/* $NetBSD: parse.c,v 1.225 2017/04/17 13:29:07 maya Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: parse.c,v 1.214 2016/04/06 09:57:00 gson 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
#if 0
static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: parse.c,v 1.214 2016/04/06 09:57:00 gson Exp $");
+__RCSID("$NetBSD: parse.c,v 1.225 2017/04/17 13:29:07 maya Exp $");
#endif
#endif /* not lint */
#endif
@@ -138,6 +138,10 @@ __RCSID("$NetBSD: parse.c,v 1.214 2016/04/06 09:57:00 gson Exp $");
#include "buf.h"
#include "pathnames.h"
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
+
#ifdef HAVE_MMAP
#include <sys/mman.h>
@@ -184,6 +188,7 @@ typedef struct IFile {
typedef enum {
Begin, /* .BEGIN */
Default, /* .DEFAULT */
+ DeleteOnError, /* .DELETE_ON_ERROR */
End, /* .END */
dotError, /* .ERROR */
Ignore, /* .IGNORE */
@@ -301,6 +306,7 @@ static const struct {
} parseKeywords[] = {
{ ".BEGIN", Begin, 0 },
{ ".DEFAULT", Default, 0 },
+{ ".DELETE_ON_ERROR", DeleteOnError, 0 },
{ ".END", End, 0 },
{ ".ERROR", dotError, 0 },
{ ".EXEC", Attribute, OP_EXEC },
@@ -537,7 +543,7 @@ loadfile(const char *path, int fd)
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);
@@ -558,9 +564,15 @@ loadfile(const char *path, int fd)
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));
@@ -576,7 +588,11 @@ loadfile(const char *path, int fd)
/* 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
@@ -1093,15 +1109,15 @@ ParseDoSrc(int tOp, const char *src)
*-----------------------------------------------------------------------
*/
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;
}
}
@@ -1139,10 +1155,10 @@ ParseAddDir(void *path, void *name)
*-----------------------------------------------------------------------
*/
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;
}
/*-
@@ -1334,6 +1350,7 @@ ParseDoDependency(char *line)
* .BEGIN
* .END
* .ERROR
+ * .DELETE_ON_ERROR
* .INTERRUPT Are not to be considered the
* main target.
* .NOTPARALLEL Make only one target at a time.
@@ -1369,6 +1386,9 @@ ParseDoDependency(char *line)
(void)Lst_AtEnd(targets, gn);
DEFAULT = gn;
break;
+ case DeleteOnError:
+ deleteOnError = TRUE;
+ break;
case NotParallel:
maxJobs = 1;
break;
@@ -1597,7 +1617,8 @@ ParseDoDependency(char *line)
goto out;
}
*line = '\0';
- } else if ((specType == NotParallel) || (specType == SingleShell)) {
+ } else if ((specType == NotParallel) || (specType == SingleShell) ||
+ (specType == DeleteOnError)) {
*line = '\0';
}
@@ -1658,7 +1679,7 @@ ParseDoDependency(char *line)
Suff_SetNull(line);
break;
case ExObjdir:
- Main_SetObjdir(line);
+ Main_SetObjdir("%s", line);
break;
default:
break;
@@ -1674,10 +1695,12 @@ ParseDoDependency(char *line)
}
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
@@ -1736,6 +1759,7 @@ ParseDoDependency(char *line)
}
out:
+ assert(paths == NULL);
if (curTargs)
Lst_Destroy(curTargs, NULL);
}
@@ -1858,7 +1882,7 @@ Parse_DoVar(char *line, GNode *ctxt)
* 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;
@@ -2539,7 +2563,7 @@ ParseTraditionalInclude(char *line)
if (*file == '\0') {
Parse_Error(PARSE_FATAL,
"Filename missing from \"include\"");
- return;
+ goto out;
}
for (file = all_files; !done; file = cp + 1) {
@@ -2554,6 +2578,7 @@ ParseTraditionalInclude(char *line)
Parse_include_file(file, FALSE, FALSE, silent);
}
+out:
free(all_files);
}
#endif
@@ -2604,6 +2629,7 @@ ParseGmakeExport(char *line)
*/
value = Var_Subst(NULL, value, VAR_CMD, VARF_WANTRES);
setenv(variable, value, 1);
+ free(value);
}
#endif
diff --git a/contrib/bmake/str.c b/contrib/bmake/str.c
index 5e4e8f6..b5255bc 100644
--- a/contrib/bmake/str.c
+++ b/contrib/bmake/str.c
@@ -1,4 +1,4 @@
-/* $NetBSD: str.c,v 1.36 2016/04/06 09:57:00 gson Exp $ */
+/* $NetBSD: str.c,v 1.38 2017/04/21 22:15:44 sjg Exp $ */
/*-
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: str.c,v 1.36 2016/04/06 09:57:00 gson 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
#if 0
static char sccsid[] = "@(#)str.c 5.8 (Berkeley) 6/1/90";
#else
-__RCSID("$NetBSD: str.c,v 1.36 2016/04/06 09:57:00 gson Exp $");
+__RCSID("$NetBSD: str.c,v 1.38 2017/04/21 22:15:44 sjg Exp $");
#endif
#endif /* not lint */
#endif
@@ -373,16 +373,26 @@ Str_Match(const char *string, const char *pattern)
* 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 @@ Str_Match(const char *string, const char *pattern)
}
++pattern;
}
+ if (nomatch && (*pattern != ']') && (*pattern != 0))
+ return 0;
while ((*pattern != ']') && (*pattern != 0))
++pattern;
goto thisCharOK;
diff --git a/contrib/bmake/suff.c b/contrib/bmake/suff.c
index 97f745b..df0306a 100644
--- a/contrib/bmake/suff.c
+++ b/contrib/bmake/suff.c
@@ -1,4 +1,4 @@
-/* $NetBSD: suff.c,v 1.81 2016/03/15 18:30:14 matthias Exp $ */
+/* $NetBSD: suff.c,v 1.86 2017/04/16 20:38:18 riastradh Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: suff.c,v 1.81 2016/03/15 18:30:14 matthias 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
#if 0
static char sccsid[] = "@(#)suff.c 8.4 (Berkeley) 3/21/94";
#else
-__RCSID("$NetBSD: suff.c,v 1.81 2016/03/15 18:30:14 matthias 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 @@ __RCSID("$NetBSD: suff.c,v 1.81 2016/03/15 18:30:14 matthias Exp $");
* order to find the node.
*/
+#include <assert.h>
#include <stdio.h>
#include "make.h"
#include "hash.h"
@@ -762,7 +763,7 @@ Suff_AddTransform(char *line)
*-----------------------------------------------------------------------
*/
int
-Suff_EndTransform(void *gnp, void *dummy)
+Suff_EndTransform(void *gnp, void *dummy MAKE_ATTR_UNUSED)
{
GNode *gn = (GNode *)gnp;
@@ -809,7 +810,7 @@ Suff_EndTransform(void *gnp, void *dummy)
fprintf(debug_file, "transformation %s complete\n", gn->name);
}
- return(dummy ? 0 : 0);
+ return 0;
}
/*-
@@ -1215,7 +1216,7 @@ SuffAddSrc(void *sp, void *lsp)
#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
@@ -1233,7 +1234,7 @@ SuffAddSrc(void *sp, void *lsp)
#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
@@ -1305,14 +1306,14 @@ SuffRemoveSrc(Lst l)
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);
@@ -1323,7 +1324,7 @@ SuffRemoveSrc(Lst l)
}
#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");
}
@@ -1372,7 +1373,7 @@ SuffFindThem(Lst srcs, Lst slst)
*/
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;
@@ -1381,7 +1382,7 @@ SuffFindThem(Lst srcs, Lst slst)
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;
@@ -1497,7 +1498,7 @@ SuffFindCmds(Src *targ, Lst slst)
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);
@@ -1616,7 +1617,7 @@ SuffExpandChildren(LstNode cln, GNode *pgn)
}
free(freeIt);
- } else if (*cp == '\\' && *cp != '\0') {
+ } else if (*cp == '\\' && cp[1] != '\0') {
/*
* Escaped something -- skip over it
*/
@@ -1906,6 +1907,13 @@ SuffFindArchiveDeps(GNode *gn, Lst slst)
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 */
@@ -2595,14 +2603,15 @@ Suff_End(void)
/********************* 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;
@@ -2640,11 +2649,11 @@ SuffPrintSuff(void *sp, void *dummy)
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;
@@ -2653,7 +2662,7 @@ SuffPrintTrans(void *tp, void *dummy)
fputc('\n', debug_file);
Lst_ForEach(t->commands, Targ_PrintCmd, NULL);
fputc('\n', debug_file);
- return(dummy ? 0 : 0);
+ return 0;
}
void
diff --git a/contrib/bmake/targ.c b/contrib/bmake/targ.c
index dd52b29..01c3d1c 100644
--- a/contrib/bmake/targ.c
+++ b/contrib/bmake/targ.c
@@ -1,4 +1,4 @@
-/* $NetBSD: targ.c,v 1.61 2016/01/17 17:45:21 christos Exp $ */
+/* $NetBSD: targ.c,v 1.62 2017/04/16 19:53:58 riastradh Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: targ.c,v 1.61 2016/01/17 17:45:21 christos 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
#if 0
static char sccsid[] = "@(#)targ.c 8.2 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: targ.c,v 1.61 2016/01/17 17:45:21 christos Exp $");
+__RCSID("$NetBSD: targ.c,v 1.62 2017/04/16 19:53:58 riastradh Exp $");
#endif
#endif /* not lint */
#endif
@@ -521,10 +521,10 @@ TargPrintName(void *gnp, void *pflags MAKE_ATTR_UNUSED)
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;
}
/*-
diff --git a/contrib/bmake/unit-tests/modmatch.exp b/contrib/bmake/unit-tests/modmatch.exp
index fcaf6c0..a7bf8b7 100644
--- a/contrib/bmake/unit-tests/modmatch.exp
+++ b/contrib/bmake/unit-tests/modmatch.exp
@@ -14,4 +14,7 @@ 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
diff --git a/contrib/bmake/unit-tests/modmatch.mk b/contrib/bmake/unit-tests/modmatch.mk
index 48a1bef..4519928 100644
--- a/contrib/bmake/unit-tests/modmatch.mk
+++ b/contrib/bmake/unit-tests/modmatch.mk
@@ -15,7 +15,9 @@ res = no
res = OK
.endif
-all:
+all: show-libs check-cclass
+
+show-libs:
@for x in $X; do ${.MAKE} -f ${MAKEFILE} show LIB=$$x; done
@echo "Mscanner=${res}"
@@ -23,3 +25,10 @@ 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]}
diff --git a/contrib/bmake/unit-tests/varmisc.exp b/contrib/bmake/unit-tests/varmisc.exp
index e2af496..ffe8f8b 100644
--- a/contrib/bmake/unit-tests/varmisc.exp
+++ b/contrib/bmake/unit-tests/varmisc.exp
@@ -17,4 +17,9 @@ 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
diff --git a/contrib/bmake/unit-tests/varmisc.mk b/contrib/bmake/unit-tests/varmisc.mk
index 14b52d2..a0b8f2d 100644
--- a/contrib/bmake/unit-tests/varmisc.mk
+++ b/contrib/bmake/unit-tests/varmisc.mk
@@ -1,8 +1,9 @@
-# $Id: varmisc.mk,v 1.5 2015/10/12 17:10:48 sjg Exp $
+# $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
+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}
@@ -40,3 +41,22 @@ Q_rhs:
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@+ $${_:[-$$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}
diff --git a/contrib/bmake/var.c b/contrib/bmake/var.c
index 81e9daf..24728e1 100644
--- a/contrib/bmake/var.c
+++ b/contrib/bmake/var.c
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.208 2016/06/03 01:21:59 sjg Exp $ */
+/* $NetBSD: var.c,v 1.215 2017/04/16 21:39:49 riastradh Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.208 2016/06/03 01:21:59 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
#if 0
static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: var.c,v 1.208 2016/06/03 01:21:59 sjg Exp $");
+__RCSID("$NetBSD: var.c,v 1.215 2017/04/16 21:39:49 riastradh Exp $");
#endif
#endif /* not lint */
#endif
@@ -1181,7 +1181,7 @@ Var_Value(const char *name, GNode *ctxt, char **frp)
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;
@@ -1202,7 +1202,7 @@ VarHead(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate,
Buf_AddByte(buf, vpstate->varSpace);
Buf_AddByte(buf, '.');
}
- return(dummy ? TRUE : TRUE);
+ return TRUE;
}
/*-
@@ -1229,7 +1229,7 @@ VarHead(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate,
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;
@@ -1245,7 +1245,7 @@ VarTail(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate,
} else {
Buf_AddBytes(buf, strlen(word), word);
}
- return (dummy ? TRUE : TRUE);
+ return TRUE;
}
/*-
@@ -1271,7 +1271,7 @@ VarTail(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate,
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;
@@ -1285,7 +1285,7 @@ VarSuffix(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate,
dot[-1] = '.';
addSpace = TRUE;
}
- return (dummy ? addSpace : addSpace);
+ return addSpace;
}
/*-
@@ -1312,7 +1312,7 @@ VarSuffix(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate,
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;
@@ -1328,7 +1328,7 @@ VarRoot(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate,
} else {
Buf_AddBytes(buf, strlen(word), word);
}
- return (dummy ? TRUE : TRUE);
+ return TRUE;
}
/*-
@@ -1836,8 +1836,8 @@ VarLoopExpand(GNode *ctx MAKE_ATTR_UNUSED,
Buf_AddByte(buf, ' ');
Buf_AddBytes(buf, (slen = strlen(s)), s);
addSpace = (slen > 0 && s[slen - 1] != '\n');
- free(s);
}
+ free(s);
}
return addSpace;
}
@@ -2139,6 +2139,51 @@ VarUniq(const char *str)
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);
+}
+
/*-
*-----------------------------------------------------------------------
@@ -2380,12 +2425,12 @@ VarHash(char *str)
}
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));
@@ -2482,6 +2527,9 @@ VarStrftime(const char *fmt, int zulu)
/* 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,
@@ -2493,12 +2541,14 @@ ApplyModifiers(char *nstr, const char *tstr,
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 */
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;
@@ -2690,6 +2740,28 @@ ApplyModifiers(char *nstr, const char *tstr,
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':
{
@@ -2895,8 +2967,6 @@ ApplyModifiers(char *nstr, const char *tstr,
* integer for :[N], or two integers
* separated by ".." for :[start..end].
*/
- char *ep;
-
VarSelectWords_t seldata = { 0, 0 };
seldata.start = strtol(estr, &ep, 0);
@@ -2955,9 +3025,15 @@ ApplyModifiers(char *nstr, const char *tstr,
}
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;
@@ -2975,9 +3051,15 @@ ApplyModifiers(char *nstr, const char *tstr,
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;
@@ -3026,7 +3108,6 @@ ApplyModifiers(char *nstr, const char *tstr,
goto get_numeric;
default:
if (isdigit((unsigned char)tstr[3])) {
- char *ep;
get_numeric:
parsestate.varSpace =
@@ -3447,6 +3528,23 @@ ApplyModifiers(char *nstr, const char *tstr,
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;
diff --git a/usr.bin/bmake/Makefile b/usr.bin/bmake/Makefile
index a748a9b..3ed2955 100644
--- a/usr.bin/bmake/Makefile
+++ b/usr.bin/bmake/Makefile
@@ -14,10 +14,10 @@ CFLAGS+= -I${.CURDIR}
CLEANDIRS+= FreeBSD
CLEANFILES+= bootstrap
-# $Id: Makefile,v 1.67 2016/06/07 00:46:12 sjg Exp $
+# $Id: Makefile,v 1.92 2017/05/10 22:29:04 sjg Exp $
# Base version on src date
-_MAKE_VERSION= 20160606
+_MAKE_VERSION= 20170510
PROG?= ${.CURDIR:T}
@@ -124,7 +124,10 @@ my.history: ${MAKEFILE}
.NOPATH: ${MAN}
${MAN}: make.1 my.history
@echo making $@
- @sed -e 's/^.Nx/NetBSD/' -e '/^.Nm/s/make/${PROG}/' \
+ @sed \
+ -e '/^.Dt/s/MAKE/${PROG:tu}/' \
+ -e 's/^.Nx/NetBSD/' \
+ -e '/^.Nm/s/make/${PROG}/' \
-e '/^.Sh HISTORY/rmy.history' \
-e '/^.Sh HISTORY/,$$s,^.Nm,make,' ${srcdir}/make.1 > $@
OpenPOWER on IntegriCloud