summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbsiegert <bsiegert>2011-06-18 22:39:46 +0000
committerbsiegert <bsiegert>2011-06-18 22:39:46 +0000
commite865351dcbe0fae6911188cc45cfd1423d1e94d0 (patch)
tree7efffdb9e58d8d71fb1b244b02f3a3b2a4b96fef
parent5b0755894302cf2a97e8fe6e07591dc29cad7904 (diff)
downloadpkgsrc-e865351dcbe0fae6911188cc45cfd1423d1e94d0.tar.gz
Merge bmake-20110606, regenerate catman page
-rw-r--r--devel/bmake/files/ChangeLog170
-rw-r--r--devel/bmake/files/FILES8
-rw-r--r--devel/bmake/files/Makefile.in16
-rw-r--r--devel/bmake/files/arch.c15
-rw-r--r--devel/bmake/files/bmake.1122
-rw-r--r--devel/bmake/files/bmake.cat1461
-rwxr-xr-xdevel/bmake/files/boot-strap20
-rw-r--r--devel/bmake/files/compat.c51
-rw-r--r--devel/bmake/files/cond.c28
-rw-r--r--devel/bmake/files/config.h.in33
-rwxr-xr-xdevel/bmake/files/configure78
-rw-r--r--devel/bmake/files/configure.in53
-rw-r--r--devel/bmake/files/dir.c41
-rw-r--r--devel/bmake/files/for.c9
-rw-r--r--devel/bmake/files/job.c32
-rw-r--r--devel/bmake/files/job.h11
-rwxr-xr-xdevel/bmake/files/machine.sh6
-rw-r--r--devel/bmake/files/main.c61
-rw-r--r--devel/bmake/files/make-bootstrap.sh.in24
-rw-r--r--devel/bmake/files/make.c45
-rw-r--r--devel/bmake/files/make.h12
-rw-r--r--devel/bmake/files/nonints.h5
-rw-r--r--devel/bmake/files/parse.c522
-rw-r--r--devel/bmake/files/sigcompat.c36
-rw-r--r--devel/bmake/files/targ.c11
-rw-r--r--devel/bmake/files/unit-tests/Makefile.in14
-rw-r--r--devel/bmake/files/unit-tests/cond17
-rw-r--r--devel/bmake/files/unit-tests/test.exp15
-rw-r--r--devel/bmake/files/util.c97
-rw-r--r--devel/bmake/files/var.c168
30 files changed, 1674 insertions, 497 deletions
diff --git a/devel/bmake/files/ChangeLog b/devel/bmake/files/ChangeLog
index 19052c5561f..b24761aa3d3 100644
--- a/devel/bmake/files/ChangeLog
+++ b/devel/bmake/files/ChangeLog
@@ -1,3 +1,173 @@
+2011-06-07 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * Merge with NetBSD make, pick up
+ o unit-tests/modts now works on MirBSD
+
+2011-06-04 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * Makefile.in (MAKE_VERSION): bump version to 20110606
+ Merge with NetBSD make, pick up
+ o ApplyModifiers: when we parse a variable which is not
+ the entire modifier string, or not followed by ':', do not
+ consider it as containing modifiers.
+ o loadfile: ensure newline at end of mapped file.
+
+2011-05-05 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * Makefile.in (MAKE_VERSION): bump version to 20110505
+ Merge with NetBSD make, pick up
+ o .MAKE.META.BAILIWICK - list of prefixes which define the scope
+ of make's control. In meta mode, any generated file within
+ said bailiwick, which is found to be missing, causes current
+ target to be out-of-date.
+
+2011-04-11 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * Makefile.in (MAKE_VERSION): bump version to 20110411
+ Merge with NetBSD make, pick up
+ o when long modifiers fail to match, check sysV style.
+ - add a test case
+
+2011-04-10 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * Makefile.in (MAKE_VERSION): bump version to 20110410
+ Merge with NetBSD make, pick up
+ o :hash - cheap 32bit hash of value
+ o :localtime, :gmtime - use value as format string for strftime.
+
+2011-03-30 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * Makefile.in (MAKE_VERSION): bump version to 20110330
+ mostly because its a cooler version.
+ Merge with NetBSD make, pick up
+ o NetBSD tags for meta.[ch]
+ o job.c call meta_job_finish() after meta_job_error().
+ o meta_job_error() should call meta_job_finish() to ensure
+ .meta file is closed, and safe to copy - if .ERROR target wants.
+ meta_job_finish() is safe to call repeatedly.
+
+2011-03-29 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * unit-tests/modts: use printf if it is a builtin,
+ to save us from MirBSD
+
+ * Makefile.in (MAKE_VERSION): bump version to 20110329
+ Merge with NetBSD make, pick up
+ o fix for use after free() in CondDoExists().
+ o meta_oodate() report extra commands and return earlier.
+
+2011-03-27 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * Makefile.in (MAKE_VERSION): bump version to 20110327
+ Merge with NetBSD make, pick up
+ o meta.c, if .MAKE.MODE contains curdirOk=yes
+ allow creating .meta files in .CURDIR
+ * boot-strap (TOOL_DIFF): aparently at least on linux distro
+ formats the output of 'type' differently - so eat any "()"
+
+2011-03-06 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * Makefile.in (MAKE_VERSION): bump version to 20110306
+ Merge with NetBSD make, pick up
+ o meta.c, only do getcwd() once
+
+2011-03-05 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * Makefile.in (MAKE_VERSION): bump version to 20110305
+ Merge with NetBSD make, pick up
+ o correct sysV substitution handling of empty lhs and variable
+ o correct exists() check for dir with trailing /
+ o correct handling of modifiers for non-existant variables
+ during evaluation of conditionals.
+ o ensure MAP_FILE is defined.
+ o meta.c use curdir[] now exported by main.c
+
+2011-02-25 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * Makefile.in (MAKE_VERSION): bump version to 20110225
+ Merge with NetBSD make, pick up
+ o fix for incorrect .PARSEDIR when .OBJDIR is re-computed after
+ makefiles have been read.
+ o fix example of :? modifier in man page.
+
+2011-02-13 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * Makefile.in (MAKE_VERSION): bump version to 20110214
+ Merge with NetBSD make, pick up
+ o meta.c handle realpath() failing when generating meta file
+ name.
+
+ * sigcompat.c: convert to ansi so we can use higher warning levels.
+
+
+2011-02-07 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * Makefile.in (MAKE_VERSION): bump version to 20110207
+ Merge with NetBSD make, pick up
+ o fix for bug in meta mode.
+
+2011-01-03 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * parse.c: SunOS 5.8 at least does not have MAP_FILE
+
+2011-01-01 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * Makefile.in (MAKE_VERSION): bump version to 20110101
+ Merge with NetBSD make, pick up
+ o use mmap(2) if available, for reading makefiles
+
+2010-12-15 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * Makefile.in (MAKE_VERSION): bump version to 20101215
+ Merge with NetBSD make, pick up
+ o ensure meta_job_error() does not report a previous .meta file
+ as being culprit.
+
+2010-12-10 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * Makefile.in (MAKE_VERSION): bump version to 20101210
+ Merge with NetBSD make, pick up
+ o meta_oodate: track cwd per process, and only consider target
+ out-of-date if missing file is outside make's CWD.
+ Ignore files in /tmp/ etc.
+ o to ensure unit-tests results match, need to control LC_ALL
+ as well as LANG.
+ o fix for parsing bug in var.c
+
+2010-11-26 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * Makefile.in (MAKE_VERSION): bump version to 20101126
+ Merge with NetBSD make, pick up
+ o if stale dependency is an IMPSRC, search via .PATH
+ o meta_oodate: if a referenced file is missing, target is
+ out-of-date.
+ o meta_oodate: if a target uses .OODATE in its commands,
+ it (.OODATE) needs to be recomputed.
+ o keep a pointer to youngest child node, rather than just its
+ mtime.
+
+2010-11-02 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * Makefile.in (MAKE_VERSION): bump version to 20101101
+
+2010-10-16 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * machine.sh: like os.sh,
+ allow for uname -p producing useless drivel
+
+2010-09-13 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * boot-strap: document configure knobs for meta and filemon.
+
+ * Makefile.in (MAKE_VERSION): bump version to 20100911
+ Merge with NetBSD make, pick up
+ o meta.c - meta mode
+
+ * make-bootstrap.sh.in: handle meta.c
+ * configure.in: add knobs for use_meta and filemon_h
+ also, look for dirname, str[e]sep and strlcpy
+ * util.c: add simple err[x] and warn[x]
+
2010-08-08 Simon J. Gerraty <sjg@bad.crufty.net>
* boot-strap (TOOL_DIFF): set this to ensure tests use
diff --git a/devel/bmake/files/FILES b/devel/bmake/files/FILES
index ed3a3dc8836..24e1359bece 100644
--- a/devel/bmake/files/FILES
+++ b/devel/bmake/files/FILES
@@ -30,9 +30,14 @@ hash.h
install-sh
job.c
job.h
+meta.c
+meta.h
+dirname.c
realpath.c
+strlcpy.c
strlist.c
strlist.h
+stresep.c
trace.c
trace.h
lst.h
@@ -96,6 +101,8 @@ unit-tests/error
unit-tests/export
unit-tests/export-all
unit-tests/forsubst
+unit-tests/hash
+unit-tests/misc
unit-tests/moderrs
unit-tests/modmatch
unit-tests/modmisc
@@ -104,6 +111,7 @@ unit-tests/modts
unit-tests/modword
unit-tests/posix
unit-tests/qequals
+unit-tests/sysv
unit-tests/ternary
unit-tests/test.exp
unit-tests/unexport
diff --git a/devel/bmake/files/Makefile.in b/devel/bmake/files/Makefile.in
index d9267ba7835..ed1d0526e88 100644
--- a/devel/bmake/files/Makefile.in
+++ b/devel/bmake/files/Makefile.in
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile.in,v 1.19 2011/01/23 19:07:25 agc Exp $
+# $NetBSD: Makefile.in,v 1.20 2011/06/18 22:39:46 bsiegert Exp $
# @(#)Makefile 5.2 (Berkeley) 12/28/90
-# $Id: Makefile.in,v 1.19 2011/01/23 19:07:25 agc Exp $
+# $Id: Makefile.in,v 1.20 2011/06/18 22:39:46 bsiegert Exp $
PROG= bmake
SRCS= arch.c buf.c compat.c cond.c dir.c for.c hash.c job.c main.c \
@@ -21,7 +21,7 @@ srcdir= @srcdir@
CC?= @CC@
# Base version on src date
-MAKE_VERSION= 20100808
+MAKE_VERSION= 20110606
MACHINE=@machine@
MACHINE_ARCH=@machine_arch@
DEFAULT_SYS_PATH = @default_sys_path@
@@ -40,6 +40,16 @@ LDADD= @LIBS@
SRCS+= ${LIBOBJS:T:.o=.c}
.endif
+USE_META ?= @use_meta@
+.if ${USE_META:tl} != "no"
+SRCS+= meta.c
+CPPFLAGS+= -DUSE_META
+FILEMON_H ?= @filemon_h@
+.if exists(${FILEMON_H}) && ${FILEMON_H:T} == "filemon.h"
+COPTS.meta.c += -DHAVE_FILEMON_H -I${FILEMON_H:H}
+.endif
+.endif
+
.PATH: ${srcdir}
.PATH: ${srcdir}/lst.lib
diff --git a/devel/bmake/files/arch.c b/devel/bmake/files/arch.c
index aca4f4473b9..d2492039660 100644
--- a/devel/bmake/files/arch.c
+++ b/devel/bmake/files/arch.c
@@ -1,4 +1,4 @@
-/* $NetBSD: arch.c,v 1.5 2010/04/20 13:37:49 joerg Exp $ */
+/* $NetBSD: arch.c,v 1.6 2011/06/18 22:39:46 bsiegert Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: arch.c,v 1.5 2010/04/20 13:37:49 joerg Exp $";
+static char rcsid[] = "$NetBSD: arch.c,v 1.6 2011/06/18 22:39:46 bsiegert 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.5 2010/04/20 13:37:49 joerg Exp $");
+__RCSID("$NetBSD: arch.c,v 1.6 2011/06/18 22:39:46 bsiegert Exp $");
#endif
#endif /* not lint */
#endif
@@ -1260,7 +1260,7 @@ Arch_FindLib(GNode *gn, Lst path)
* A library will be considered out-of-date for any of these reasons,
* given that it is a target on a dependency line somewhere:
* Its modification time is less than that of one of its
- * sources (gn->mtime < gn->cmtime).
+ * sources (gn->mtime < gn->cmgn->mtime).
* Its modification time is greater than the time at which the
* make began (i.e. it's been modified in the course
* of the make, probably by archiving).
@@ -1293,8 +1293,9 @@ Arch_LibOODate(GNode *gn)
oodate = TRUE;
} else if (OP_NOP(gn->type) && Lst_IsEmpty(gn->children)) {
oodate = FALSE;
- } else if ((!Lst_IsEmpty(gn->children) && gn->cmtime == 0) ||
- (gn->mtime > now) || (gn->mtime < gn->cmtime)) {
+ } else if ((!Lst_IsEmpty(gn->children) && gn->cmgn == NULL) ||
+ (gn->mtime > now) ||
+ (gn->cmgn != NULL && gn->mtime < gn->cmgn->mtime)) {
oodate = TRUE;
} else {
#ifdef RANLIBMAG
@@ -1309,7 +1310,7 @@ Arch_LibOODate(GNode *gn)
if (DEBUG(ARCH) || DEBUG(MAKE)) {
fprintf(debug_file, "%s modified %s...", RANLIBMAG, Targ_FmtTime(modTimeTOC));
}
- oodate = (gn->cmtime > modTimeTOC);
+ oodate = (gn->cmgn == NULL || gn->cmgn->mtime > modTimeTOC);
} else {
/*
* A library w/o a table of contents is out-of-date
diff --git a/devel/bmake/files/bmake.1 b/devel/bmake/files/bmake.1
index 33840f33230..0fd6a4252da 100644
--- a/devel/bmake/files/bmake.1
+++ b/devel/bmake/files/bmake.1
@@ -1,4 +1,4 @@
-.\" $NetBSD: bmake.1,v 1.8 2010/09/07 14:41:39 joerg Exp $
+.\" $NetBSD: bmake.1,v 1.9 2011/06/18 22:39:46 bsiegert 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 30, 2010
+.Dd May 29, 2011
.Dt BMAKE 1
.Os
.Sh NAME
@@ -194,6 +194,8 @@ Print commands in Makefiles regardless of whether or not they are prefixed by
.Ql @
or other "quiet" flags.
Also known as "loud" behavior.
+.It Ar M
+Print debugging information about "meta" mode decisions about targets.
.It Ar m
Print debugging information about making targets, including modification
dates.
@@ -266,6 +268,8 @@ cooperate to avoid overloading the system.
Specify the maximum number of jobs that
.Nm
may have running at any one time.
+The value is saved in
+.Va .MAKE.JOBS .
Turns compatibility mode off, unless the
.Ar B
flag is also specified.
@@ -759,9 +763,65 @@ Processed after reading all makefiles.
Can affect the mode that
.Nm
runs in.
-Currently just
-.Ql Pa compat
-mode.
+It can contain a number of keywords:
+.Bl -hang -width ignore-cmd
+.It Pa compat
+Like
+.Fl B ,
+puts
+.Nm
+into "compat" mode.
+.It Pa meta
+Puts
+.Nm
+into "meta" mode, where meta files are created for each target
+to capture the command run, the output generated and if
+.Xr filemon 4
+is available, the system calls which are of interest to
+.Nm .
+The captured output can be very useful when diagnosing errors.
+.It Pa curdirOk= Ar bf
+Normally
+.Nm
+will not create .meta files in
+.Ql Va .CURDIR .
+This can be overridden by setting
+.Va bf
+to a value which represents True.
+.It Pa verbose
+If in "meta" mode, print a clue about the target being built.
+This is useful if the build is otherwise running silently.
+The message printed the value of:
+.Va .MAKE.META.PREFIX .
+.It Pa ignore-cmd
+Some makefiles have commands which are simply not stable.
+This keyword causes them to be ignored for
+determining whether a target is out of date in "meta" mode.
+See also
+.Ic .NOMETA_CMP .
+.El
+.It Va .MAKE.META.BAILIWICK
+In "meta" mode, provides a list of prefixes which
+match the directories controlled by
+.Nm .
+If a file that was generated outside of
+.Va .OBJDIR
+but within said bailiwick is missing,
+the current target is considered out-of-date.
+.It Va .MAKE.META.CREATED
+In "meta" mode, this variable contains a list of all the meta files
+updated.
+If not empty, it can be used to trigger processing of
+.Va .MAKE.META.FILES .
+.It Va .MAKE.META.FILES
+In "meta" mode, this variable contains a list of all the meta files
+used (updated or not).
+This list can be used to process the meta files to extract dependency
+information.
+.It Va .MAKE.META.PREFIX
+Defines the message printed for each meta file updated in "meta verbose" mode.
+The default value is:
+.Dl Building ${.TARGET:H:tA}/${.TARGET:T}
.It Va .MAKEOVERRIDES
This variable is used to record the names of variables assigned to
on the command line, so that they may be exported as part of
@@ -990,6 +1050,18 @@ safely through recursive invocations of
.Nm .
.It Cm \&:R
Replaces each word in the variable with everything but its suffix.
+.It Cm \&:gmtime
+The value is a format string for
+.Xr strftime 3 ,
+using the current
+.Xr gmtime 3 .
+.It Cm \&:hash
+Compute a 32bit hash of the value and encode it as hex digits.
+.It Cm \&:localtime
+The value is a format string for
+.Xr strftime 3 ,
+using the current
+.Xr localtime 3 .
.It Cm \&:tA
Attempt to convert variable to an absolute path using
.Xr realpath 3 ,
@@ -1129,7 +1201,7 @@ A common error is trying to use expressions like
.Dl ${NUMBERS:M42:?match:no}
which actually tests defined(NUMBERS),
to determine is any words match "42" you need to use something like:
-.Dl ${${NUMBERS:M42} != "":?match:no} .
+.Dl ${"${NUMBERS:M42}" != \&"\&":?match:no} .
.It Ar :old_string=new_string
This is the
.At V
@@ -1612,6 +1684,27 @@ or
options were specified.
Normally used to mark recursive
.Nm Ns 's .
+.It Ic .META
+Create a meta file for the target, even if it is flagged as
+.Ic .PHONY ,
+.Ic .MAKE ,
+or
+.Ic .SPECIAL .
+Usage in conjunction with
+.Ic .MAKE
+is the most likely case.
+.It Ic .NOMETA
+Do not create a meta file for the target.
+Meta files are also not created for
+.Ic .PHONY ,
+.Ic .MAKE ,
+or
+.Ic .SPECIAL
+targets.
+.It Ic .NOMETA_CMP
+Ignore differences in commands when deciding if target is out of date.
+This is useful if the command contains a value which always changes.
+If the number of commands change, though, the target will still be out of date.
.It Ic .NOPATH
Do not search for the target in the directories specified by
.Ic .PATH .
@@ -1774,7 +1867,7 @@ could be built, unless
is built by another part of the dependency graph,
the following is a dependency loop:
.Bd -literal
-\&.ORDER: a b
+\&.ORDER: b a
b: a
.Ed
.Pp
@@ -1926,6 +2019,21 @@ The way that .for loop variables are substituted changed after
so that they still appear to be variable expansions.
In particular this stops them being treated as syntax, and removes some
obscure problems using them in .if statements.
+.Pp
+Unlike other
+.Nm
+programs, this implementation by default executes all commands for a given
+target using a single shell invocation.
+This is done for both efficiency and to simplify error handling in remote
+command invocations.
+Typically this is transparent to the user, unless the target commands change
+the current working directory using
+.Dq cd
+or
+.Dq chdir .
+To be compatible with Makefiles that do this, one can use
+.Fl B
+to disable this behavior.
.Sh SEE ALSO
.Xr mkdep 1
.Sh HISTORY
diff --git a/devel/bmake/files/bmake.cat1 b/devel/bmake/files/bmake.cat1
index 986206322ab..254d55017d1 100644
--- a/devel/bmake/files/bmake.cat1
+++ b/devel/bmake/files/bmake.cat1
@@ -1,4 +1,4 @@
-BMAKE(1) NetBSD General Commands Manual BMAKE(1)
+BMAKE(1) BSD General Commands Manual BMAKE(1)
NNAAMMEE
bbmmaakkee -- maintain program dependencies
@@ -10,11 +10,11 @@ SSYYNNOOPPSSIISS
[_t_a_r_g_e_t _._._.]
DDEESSCCRRIIPPTTIIOONN
- bbmmaakkee is a program designed to simplify the maintenance of other
- programs. Its input is a list of specifications as to the files upon
- which programs and other files depend. If no --ff _m_a_k_e_f_i_l_e makefile option
- is given, bbmmaakkee will try to open `_m_a_k_e_f_i_l_e' then `_M_a_k_e_f_i_l_e' in order to
- find the specifications. If the file `_._d_e_p_e_n_d' exists, it is read (see
+ bbmmaakkee is a program designed to simplify the maintenance of other pro-
+ grams. Its input is a list of specifications as to the files upon which
+ programs and other files depend. If no --ff _m_a_k_e_f_i_l_e makefile option is
+ given, bbmmaakkee will try to open `_m_a_k_e_f_i_l_e' then `_M_a_k_e_f_i_l_e' in order to find
+ the specifications. If the file `_._d_e_p_e_n_d' exists, it is read (see
mkdep(1)).
This manual page is intended as a reference document only. For a more
@@ -31,10 +31,10 @@ DDEESSCCRRIIPPTTIIOONN
dependency line in sequence.
--CC _d_i_r_e_c_t_o_r_y
- Change to _d_i_r_e_c_t_o_r_y before reading the makefiles or doing
- anything else. If multiple --CC options are specified, each is
- interpreted relative to the previous one: --CC _/ --CC _e_t_c is
- equivalent to --CC _/_e_t_c.
+ Change to _d_i_r_e_c_t_o_r_y before reading the makefiles or doing any-
+ thing else. If multiple --CC options are specified, each is inter-
+ preted relative to the previous one: --CC _/ --CC _e_t_c is equivalent to
+ --CC _/_e_t_c.
--DD _v_a_r_i_a_b_l_e
Define _v_a_r_i_a_b_l_e to be 1, in the global context.
@@ -47,8 +47,8 @@ DDEESSCCRRIIPPTTIIOONN
information is printed to standard error, but this can be changed
using the _F debugging flag. The debugging output is always
unbuffered; in addition, if debugging is enabled but debugging
- output is not directed to standard output, then the standard
- output is line buffered. _F_l_a_g_s is one or more of the following:
+ output is not directed to standard output, then the standard out-
+ put is line buffered. _F_l_a_g_s is one or more of the following:
_A Print all possible debugging information; equivalent to
specifying all of the debugging flags.
@@ -56,8 +56,8 @@ DDEESSCCRRIIPPTTIIOONN
_a Print debugging information about archive searching and
caching.
- _C Print debugging information about current working
- directory.
+ _C Print debugging information about current working direc-
+ tory.
_c Print debugging information about conditional evaluation.
@@ -96,25 +96,27 @@ DDEESSCCRRIIPPTTIIOONN
they are prefixed by `@' or other "quiet" flags. Also
known as "loud" behavior.
- _m Print debugging information about making targets,
- including modification dates.
+ _M Print debugging information about "meta" mode decisions
+ about targets.
+
+ _m Print debugging information about making targets, includ-
+ ing modification dates.
_n Don't delete the temporary command scripts created when
running commands. These temporary scripts are created in
- the directory referred to by the TMPDIR environment
- variable, or in _/_t_m_p if TMPDIR is unset or set to the
- empty string. The temporary scripts are created by
- mkstemp(3), and have names of the form _m_a_k_e_X_X_X_X_X_X. _N_O_T_E:
- This can create many files in TMPDIR or _/_t_m_p, so use with
- care.
+ the directory referred to by the TMPDIR environment vari-
+ able, or in _/_t_m_p if TMPDIR is unset or set to the empty
+ string. The temporary scripts are created by mkstemp(3),
+ and have names of the form _m_a_k_e_X_X_X_X_X_X. _N_O_T_E: This can
+ create many files in TMPDIR or _/_t_m_p, so use with care.
_p Print debugging information about makefile parsing.
_s Print debugging information about suffix-transformation
rules.
- _t Print debugging information about target list
- maintenance.
+ _t Print debugging information about target list mainte-
+ nance.
_v Print debugging information about variable assignment.
@@ -134,9 +136,8 @@ DDEESSCCRRIIPPTTIIOONN
makefiles. The system makefile directory (or directories, see
the --mm option) is automatically included as part of this list.
- --ii Ignore non-zero exit of shell commands in the makefile.
- Equivalent to specifying `--' before each command line in the
- makefile.
+ --ii Ignore non-zero exit of shell commands in the makefile. Equiva-
+ lent to specifying `--' before each command line in the makefile.
--JJ _p_r_i_v_a_t_e
This option should _n_o_t be specified by the user.
@@ -147,15 +148,15 @@ DDEESSCCRRIIPPTTIIOONN
--jj _m_a_x___j_o_b_s
Specify the maximum number of jobs that bbmmaakkee may have running at
- any one time. Turns compatibility mode off, unless the _B flag is
- also specified. When compatibility mode is off, all commands
- associated with a target are executed in a single shell
- invocation as opposed to the traditional one shell invocation per
- line. This can break traditional scripts which change
- directories on each command invocation and then expect to start
- with a fresh environment on the next line. It is more efficient
- to correct the scripts rather than turn backwards compatibility
- on.
+ any one time. The value is saved in _._M_A_K_E_._J_O_B_S. Turns compati-
+ bility mode off, unless the _B flag is also specified. When com-
+ patibility mode is off, all commands associated with a target are
+ executed in a single shell invocation as opposed to the tradi-
+ tional one shell invocation per line. This can break traditional
+ scripts which change directories on each command invocation and
+ then expect to start with a fresh environment on the next line.
+ It is more efficient to correct the scripts rather than turn
+ backwards compatibility on.
--kk Continue processing after errors are encountered, but only on
those targets that do not depend on the target whose creation
@@ -165,9 +166,9 @@ DDEESSCCRRIIPPTTIIOONN
Specify a directory in which to search for sys.mk and makefiles
included via the <_f_i_l_e>-style include statement. The --mm option
can be used multiple times to form a search path. This path will
- override the default system include path: /usr/share/mk.
- Furthermore the system include path will be appended to the
- search path used for "_f_i_l_e"-style include statements (see the --II
+ override the default system include path: /usr/share/mk. Fur-
+ thermore the system include path will be appended to the search
+ path used for "_f_i_l_e"-style include statements (see the --II
option).
If a file or directory name in the --mm argument (or the
@@ -182,8 +183,8 @@ DDEESSCCRRIIPPTTIIOONN
(e.g., by using ".../mk/sys.mk" as an argument).
--nn Display the commands that would have been executed, but do not
- actually execute them unless the target depends on the .MAKE
- special source (see below).
+ actually execute them unless the target depends on the .MAKE spe-
+ cial source (see below).
--NN Display the commands which would have been executed, but do not
actually execute any of them; useful for debugging top-level
@@ -202,12 +203,12 @@ DDEESSCCRRIIPPTTIIOONN
for each job started and completed.
--tt Rather than re-building a target as specified in the makefile,
- create it or update its modification time to make it appear
- up-to-date.
+ create it or update its modification time to make it appear up-
+ to-date.
--VV _v_a_r_i_a_b_l_e
- Print bbmmaakkee's idea of the value of _v_a_r_i_a_b_l_e, in the global
- context. Do not build any targets. Multiple instances of this
+ Print bbmmaakkee's idea of the value of _v_a_r_i_a_b_l_e, in the global con-
+ text. Do not build any targets. Multiple instances of this
option may be specified; the variables will be printed one per
line, with a blank line for each null or undefined variable. If
_v_a_r_i_a_b_l_e contains a `$' then the value will be expanded before
@@ -215,18 +216,18 @@ DDEESSCCRRIIPPTTIIOONN
--WW Treat any warnings during makefile parsing as errors.
- --XX Don't export variables passed on the command line to the
- environment individually. Variables passed on the command line
- are still exported via the _M_A_K_E_F_L_A_G_S environment variable. This
+ --XX Don't export variables passed on the command line to the environ-
+ ment individually. Variables passed on the command line are
+ still exported via the _M_A_K_E_F_L_A_G_S environment variable. This
option may be useful on systems which have a small limit on the
size of command arguments.
_v_a_r_i_a_b_l_e_=_v_a_l_u_e
Set the value of the variable _v_a_r_i_a_b_l_e to _v_a_l_u_e. Normally, all
values passed on the command line are also exported to sub-makes
- in the environment. The --XX flag disables this behavior.
- Variable assignments should follow options for POSIX
- compatibility but no ordering is enforced.
+ in the environment. The --XX flag disables this behavior. Vari-
+ able assignments should follow options for POSIX compatibility
+ but no ordering is enforced.
There are seven different types of lines in a makefile: file dependency
specifications, shell commands, variable assignments, include statements,
@@ -240,8 +241,8 @@ FFIILLEE DDEEPPEENNDDEENNCCYY SSPPEECCIIFFIICCAATTIIOO
Dependency lines consist of one or more targets, an operator, and zero or
more sources. This creates a relationship where the targets ``depend''
on the sources and are usually created from them. The exact relationship
- between the target and the source is determined by the operator that
- separates them. The three operators are as follows:
+ between the target and the source is determined by the operator that sep-
+ arates them. The three operators are as follows:
:: A target is considered out-of-date if its modification time is less
than those of any of its sources. Sources for a target accumulate
@@ -249,12 +250,12 @@ FFIILLEE DDEEPPEENNDDEENNCCYY SSPPEECCIIFFIICCAATTIIOO
removed if bbmmaakkee is interrupted.
!! Targets are always re-created, but not until all sources have been
- examined and re-created as necessary. Sources for a target
- accumulate over dependency lines when this operator is used. The
- target is removed if bbmmaakkee is interrupted.
+ examined and re-created as necessary. Sources for a target accumu-
+ late over dependency lines when this operator is used. The target
+ is removed if bbmmaakkee is interrupted.
- :::: If no sources are specified, the target is always re-created.
- Otherwise, a target is considered out-of-date if any of its sources
+ :::: If no sources are specified, the target is always re-created. Oth-
+ erwise, a target is considered out-of-date if any of its sources
has been modified more recently than the target. Sources for a
target do not accumulate over dependency lines when this operator
is used. The target will not be removed if bbmmaakkee is interrupted.
@@ -267,8 +268,8 @@ FFIILLEE DDEEPPEENNDDEENNCCYY SSPPEECCIIFFIICCAATTIIOO
done in the shell.
SSHHEELLLL CCOOMMMMAANNDDSS
- Each target may have associated with it a series of shell commands,
- normally used to create the target. Each of the commands in this script
+ Each target may have associated with it a series of shell commands, nor-
+ mally used to create the target. Each of the commands in this script
_m_u_s_t be preceded by a tab. While any target may appear on a dependency
line, only one of these dependencies may be followed by a creation
script, unless the `::::' operator is used.
@@ -282,25 +283,25 @@ SSHHEELLLL CCOOMMMMAANNDDSS
line to be ignored.
VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNTTSS
- Variables in make are much like variables in the shell, and, by
- tradition, consist of all upper-case letters.
+ Variables in make are much like variables in the shell, and, by tradi-
+ tion, consist of all upper-case letters.
VVaarriiaabbllee aassssiiggnnmmeenntt mmooddiiffiieerrss
The five operators that can be used to assign values to variables are as
follows:
- == Assign the value to the variable. Any previous value is
- overridden.
+ == Assign the value to the variable. Any previous value is overrid-
+ den.
++== Append the value to the current value of the variable.
??== Assign the value to the variable if it is not already defined.
::== Assign with expansion, i.e. expand the value before assigning it
- to the variable. Normally, expansion is not done until the
- variable is referenced. _N_O_T_E: References to undefined variables
- are _n_o_t expanded. This can cause problems when variable
- modifiers are used.
+ to the variable. Normally, expansion is not done until the vari-
+ able is referenced. _N_O_T_E: References to undefined variables are
+ _n_o_t expanded. This can cause problems when variable modifiers
+ are used.
!!== Expand the value and pass it to the shell for execution and
assign the result to the variable. Any newlines in the result
@@ -312,13 +313,13 @@ VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNTTSS
Variables are expanded by surrounding the variable name with either curly
braces (`{}') or parentheses (`()') and preceding it with a dollar sign
- (`$'). If the variable name contains only a single letter, the
- surrounding braces or parentheses are not required. This shorter form is
- not recommended.
+ (`$'). If the variable name contains only a single letter, the surround-
+ ing braces or parentheses are not required. This shorter form is not
+ recommended.
If the variable name contains a dollar, then the name itself is expanded
- first. This allows almost arbitrary variable names, however names
- containing dollar, braces, parenthesis, or whitespace are really best
+ first. This allows almost arbitrary variable names, however names con-
+ taining dollar, braces, parenthesis, or whitespace are really best
avoided!
If the result of expanding a variable contains a dollar sign (`$') the
@@ -333,8 +334,8 @@ VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNTTSS
executed.
3. ``.for'' loop index variables are expanded on each loop iteration.
- Note that other variables are not expanded inside loops so the
- following example code:
+ Note that other variables are not expanded inside loops so the fol-
+ lowing example code:
.for i in 1 2 3
@@ -357,8 +358,8 @@ VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNTTSS
after the loop completes ${j} contains ``3''.
VVaarriiaabbllee ccllaasssseess
- The four different classes of variables (in order of increasing
- precedence) are:
+ The four different classes of variables (in order of increasing prece-
+ dence) are:
Environment variables
Variables defined as part of bbmmaakkee's environment.
@@ -395,8 +396,8 @@ VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNTTSS
_._T_A_R_G_E_T The name of the target; also known as `_@'.
The shorter forms `_@', `_?', `_<', `_>', and `_*' are permitted for
- backward compatibility with historical makefiles and are not
- recommended. The six variables `_@_F', `_@_D', `_<_F', `_<_D', `_*_F', and
+ backward compatibility with historical makefiles and are not rec-
+ ommended. The six variables `_@_F', `_@_D', `_<_F', `_<_D', `_*_F', and
`_*_D' are permitted for compatibility with AT&T System V UNIX
makefiles and are not recommended.
@@ -412,8 +413,8 @@ VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNTTSS
dollar sign.
_._A_L_L_T_A_R_G_E_T_S The list of all targets encountered in the Makefile. If
- evaluated during Makefile parsing, lists only those
- targets encountered thus far.
+ evaluated during Makefile parsing, lists only those tar-
+ gets encountered thus far.
_._C_U_R_D_I_R A path to the directory where bbmmaakkee was executed. Refer
to the description of `PWD' for more details.
@@ -426,8 +427,8 @@ VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNTTSS
the same name.
_._M_A_K_E_._D_E_P_E_N_D_F_I_L_E
- Names the makefile (default `_._d_e_p_e_n_d') from which
- generated dependencies are read.
+ Names the makefile (default `_._d_e_p_e_n_d') from which gener-
+ ated dependencies are read.
_._M_A_K_E_._E_X_P_O_R_T_E_D The list of variables exported by bbmmaakkee.
@@ -439,15 +440,15 @@ VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNTTSS
which can be controlled via _._M_A_K_E_._J_O_B_._P_R_E_F_I_X.
For example:
.MAKE.JOB.PREFIX=${.newline}---${.MAKE:T}[${.MAKE.PID}]
- would produce tokens like `---make[1234] target ---'
- making it easier to track the degree of parallelism being
+ would produce tokens like `---make[1234] target ---' mak-
+ ing it easier to track the degree of parallelism being
achieved.
MAKEFLAGS The environment variable `MAKEFLAGS' may contain anything
that may be specified on bbmmaakkee's command line. Anything
specified on bbmmaakkee's command line is appended to the
- `MAKEFLAGS' variable which is then entered into the
- environment for all programs which bbmmaakkee executes.
+ `MAKEFLAGS' variable which is then entered into the envi-
+ ronment for all programs which bbmmaakkee executes.
_._M_A_K_E_._L_E_V_E_L The recursion depth of bbmmaakkee. The initial instance of
bbmmaakkee will be 0, and an incremented value is put into the
@@ -466,7 +467,56 @@ VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNTTSS
once, regardless of the number of times read.
_._M_A_K_E_._M_O_D_E Processed after reading all makefiles. Can affect the
- mode that bbmmaakkee runs in. Currently just `_c_o_m_p_a_t' mode.
+ mode that bbmmaakkee runs in. It can contain a number of key-
+ words:
+
+ _c_o_m_p_a_t Like --BB, puts bbmmaakkee into "compat" mode.
+
+ _m_e_t_a Puts bbmmaakkee into "meta" mode, where meta files
+ are created for each target to capture the
+ command run, the output generated and if
+ filemon(4) is available, the system calls
+ which are of interest to bbmmaakkee. The captured
+ output can be very useful when diagnosing
+ errors.
+
+ _c_u_r_d_i_r_O_k_= _b_f Normally bbmmaakkee will not create .meta files
+ in `_._C_U_R_D_I_R'. This can be overridden by set-
+ ting _b_f to a value which represents True.
+
+ _v_e_r_b_o_s_e If in "meta" mode, print a clue about the
+ target being built. This is useful if the
+ build is otherwise running silently. The
+ message printed the value of:
+ _._M_A_K_E_._M_E_T_A_._P_R_E_F_I_X.
+
+ _i_g_n_o_r_e_-_c_m_d Some makefiles have commands which are simply
+ not stable. This keyword causes them to be
+ ignored for determining whether a target is
+ out of date in "meta" mode. See also
+ ..NNOOMMEETTAA__CCMMPP.
+
+ _._M_A_K_E_._M_E_T_A_._B_A_I_L_I_W_I_C_K
+ In "meta" mode, provides a list of prefixes which match
+ the directories controlled by bbmmaakkee. If a file that was
+ generated outside of _._O_B_J_D_I_R but within said bailiwick is
+ missing, the current target is considered out-of-date.
+
+ _._M_A_K_E_._M_E_T_A_._C_R_E_A_T_E_D
+ In "meta" mode, this variable contains a list of all the
+ meta files updated. If not empty, it can be used to
+ trigger processing of _._M_A_K_E_._M_E_T_A_._F_I_L_E_S.
+
+ _._M_A_K_E_._M_E_T_A_._F_I_L_E_S
+ In "meta" mode, this variable contains a list of all the
+ meta files used (updated or not). This list can be used
+ to process the meta files to extract dependency informa-
+ tion.
+
+ _._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:
+ Building ${.TARGET:H:tA}/${.TARGET:T}
_._M_A_K_E_O_V_E_R_R_I_D_E_S This variable is used to record the names of variables
assigned to on the command line, so that they may be
@@ -483,8 +533,8 @@ VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNTTSS
_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
- variables named in `_M_A_K_E___P_R_I_N_T___V_A_R___O_N___E_R_R_O_R'.
+ 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'.
_._n_e_w_l_i_n_e This variable is simply assigned a newline character as
its value. This allows expansions using the ::@@ modifier
@@ -494,13 +544,13 @@ VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNTTSS
${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'${.newline}@}.
_._O_B_J_D_I_R A path to the directory where the targets are built. Its
- value is determined by trying to chdir(2) to the
- following directories in order and using the first match:
+ value is determined by trying to chdir(2) to the follow-
+ ing directories in order and using the first match:
1. ${MAKEOBJDIRPREFIX}${.CURDIR}
- (Only if `MAKEOBJDIRPREFIX' is set in the
- environment or on the command line.)
+ (Only if `MAKEOBJDIRPREFIX' is set in the environ-
+ ment or on the command line.)
2. ${MAKEOBJDIR}
@@ -523,8 +573,8 @@ VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNTTSS
`_._O_B_J_D_I_R' may be modified in the makefile as a global
variable. In all cases, bbmmaakkee will chdir(2) to `_._O_B_J_D_I_R'
- and set `PWD' to that directory before executing any
- targets.
+ and set `PWD' to that directory before executing any tar-
+ gets.
_._P_A_R_S_E_D_I_R A path to the directory of the current `_M_a_k_e_f_i_l_e' being
parsed.
@@ -535,8 +585,8 @@ VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNTTSS
_._P_A_T_H A variable that represents the list of directories that
bbmmaakkee will search for files. The search list should be
- updated using the target `_._P_A_T_H' rather than the
- variable.
+ updated using the target `_._P_A_T_H' rather than the vari-
+ able.
PWD Alternate path to the current directory. bbmmaakkee normally
sets `_._C_U_R_D_I_R' to the canonical path given by getcwd(3).
@@ -557,8 +607,8 @@ VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNTTSS
VVaarriiaabbllee mmooddiiffiieerrss
Variable expansion may be modified to select or modify each word of the
- variable (where a ``word'' is white-space delimited sequence of
- characters). The general format of a variable expansion is as follows:
+ variable (where a ``word'' is white-space delimited sequence of charac-
+ ters). The general format of a variable expansion is as follows:
${variable[:modifier[:...]]}
@@ -579,8 +629,8 @@ VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNTTSS
::EE Replaces each word in the variable with its suffix.
- ::HH Replaces each word in the variable with everything but the last
- component.
+ ::HH Replaces each word in the variable with everything but the last com-
+ ponent.
::MM_p_a_t_t_e_r_n
Select only those words that match _p_a_t_t_e_r_n. The standard shell
@@ -619,16 +669,27 @@ 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).
+
+ ::hhaasshh
+ Compute a 32bit 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).
+
::ttAA Attempt to convert variable to an absolute path using realpath(3),
if that fails, the value is unchanged.
::ttll Converts variable to lower-case letters.
::ttss_c
- Words in the variable are normally separated by a space on
- expansion. This modifier sets the separator to the character _c. If
- _c is omitted, then no separator is used. The common escapes
- (including octal numeric codes), work as expected.
+ Words in the variable are normally separated by a space on expan-
+ sion. This modifier sets the separator to the character _c. If _c is
+ omitted, then no separator is used. The common escapes (including
+ octal numeric codes), work as expected.
::ttuu Converts variable to upper-case letters.
@@ -644,8 +705,8 @@ VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNTTSS
slash of the pattern, all occurrences in each word are replaced. If
a `1' is appended to the last slash of the pattern, only the first
word is affected. If a `W' is appended to the last slash of the
- pattern, then the value is treated as a single word (possibly
- containing embedded white space). If _o_l_d___s_t_r_i_n_g begins with a caret
+ pattern, then the value is treated as a single word (possibly con-
+ taining embedded white space). If _o_l_d___s_t_r_i_n_g begins with a caret
(`^'), _o_l_d___s_t_r_i_n_g is anchored at the beginning of each word. If
_o_l_d___s_t_r_i_n_g ends with a dollar sign (`$'), it is anchored at the end
of each word. Inside _n_e_w___s_t_r_i_n_g, an ampersand (`&') is replaced by
@@ -656,31 +717,31 @@ VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNTTSS
Variable expansion occurs in the normal fashion inside both
_o_l_d___s_t_r_i_n_g and _n_e_w___s_t_r_i_n_g with the single exception that a backslash
- is used to prevent the expansion of a dollar sign (`$'), not a
- preceding dollar sign as is usual.
+ is used to prevent the expansion of a dollar sign (`$'), not a pre-
+ ceding dollar sign as is usual.
::CC/_p_a_t_t_e_r_n/_r_e_p_l_a_c_e_m_e_n_t/[11ggWW]
The ::CC modifier is just like the ::SS modifier except that the old and
- new strings, instead of being simple strings, are a regular
- expression (see regex(3)) string _p_a_t_t_e_r_n and an ed(1)-style string
+ new strings, instead of being simple strings, are a regular expres-
+ sion (see regex(3)) string _p_a_t_t_e_r_n and an ed(1)-style string
_r_e_p_l_a_c_e_m_e_n_t. Normally, the first occurrence of the pattern _p_a_t_t_e_r_n
in each word of the value is substituted with _r_e_p_l_a_c_e_m_e_n_t. The `1'
modifier causes the substitution to apply to at most one word; the
`g' modifier causes the substitution to apply to as many instances
of the search pattern _p_a_t_t_e_r_n as occur in the word or words it is
- found in; the `W' modifier causes the value to be treated as a
- single word (possibly containing embedded white space). Note that
- `1' and `g' are orthogonal; the former specifies whether multiple
- words are potentially affected, the latter whether multiple
- substitutions can potentially occur within each affected word.
+ found in; the `W' modifier causes the value to be treated as a sin-
+ gle word (possibly containing embedded white space). Note that `1'
+ and `g' are orthogonal; the former specifies whether multiple words
+ are potentially affected, the latter whether multiple substitutions
+ can potentially occur within each affected word.
::TT Replaces each word in the variable with its last component.
::uu Remove adjacent duplicate words (like uniq(1)).
::??_t_r_u_e___s_t_r_i_n_g::_f_a_l_s_e___s_t_r_i_n_g
- If the variable name (not its value), when parsed as a .if
- conditional expression, evaluates to true, return as its value the
+ If the variable name (not its value), when parsed as a .if condi-
+ tional expression, evaluates to true, return as its value the
_t_r_u_e___s_t_r_i_n_g, otherwise return the _f_a_l_s_e___s_t_r_i_n_g. Since the variable
name is used as the expression, :? must be the first modifier after
the variable name itself - which will, of course, usually contain
@@ -689,7 +750,7 @@ VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNTTSS
${NUMBERS:M42:?match:no}
which actually tests defined(NUMBERS), to determine is any words
match "42" you need to use something like:
- ${${NUMBERS:M42} != :?match:no}.
+ ${"${NUMBERS:M42}" != "":?match:no}.
_:_o_l_d___s_t_r_i_n_g_=_n_e_w___s_t_r_i_n_g
This is the AT&T System V UNIX style variable substitution. It must
@@ -701,15 +762,15 @@ VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNTTSS
Variable expansion occurs in the normal fashion inside both
_o_l_d___s_t_r_i_n_g and _n_e_w___s_t_r_i_n_g with the single exception that a backslash
- is used to prevent the expansion of a dollar sign (`$'), not a
- preceding dollar sign as is usual.
+ is used to prevent the expansion of a dollar sign (`$'), not a pre-
+ ceding dollar sign as is usual.
::@@_t_e_m_p@@_s_t_r_i_n_g@@
- This is the loop expansion mechanism from the OSF Development
- Environment (ODE) make. Unlike ..ffoorr loops expansion occurs at the
- time of reference. Assign _t_e_m_p to each word in the variable and
- evaluate _s_t_r_i_n_g. The ODE convention is that _t_e_m_p should start and
- end with a period. For example.
+ This is the loop expansion mechanism from the OSF Development Envi-
+ ronment (ODE) make. Unlike ..ffoorr loops expansion occurs at the time
+ of reference. Assign _t_e_m_p to each word in the variable and evaluate
+ _s_t_r_i_n_g. The ODE convention is that _t_e_m_p should start and end with a
+ period. For example.
${LINKS:@.LINK.@${LN} ${TARGET} ${.LINK.}@}
::UU_n_e_w_v_a_l
@@ -758,9 +819,8 @@ VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNTTSS
Assign the output of _c_m_d to the variable.
::[[_r_a_n_g_e]]
- Selects one or more words from the value, or performs other
- operations related to the way in which the value is divided into
- words.
+ Selects one or more words from the value, or performs other opera-
+ tions related to the way in which the value is divided into words.
Ordinarily, a value is treated as a sequence of words delimited by
white space. Some modifiers suppress this behaviour, causing a
@@ -779,8 +839,8 @@ VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNTTSS
_s_t_a_r_t...._e_n_d
Selects all words from _s_t_a_r_t to _e_n_d, inclusive. For example,
`::[[22....--11]]' selects all words from the second word to the last
- word. If _s_t_a_r_t is greater than _e_n_d, then the words are
- output in reverse order. For example, `::[[--11....11]]' selects all
+ word. If _s_t_a_r_t is greater than _e_n_d, then the words are out-
+ put in reverse order. For example, `::[[--11....11]]' selects all
the words from last to first.
** Causes subsequent modifiers to treat the value as a single
@@ -799,9 +859,9 @@ IINNCCLLUUDDEE SSTTAATTEEMMEENNTTSS,, CCOONNDDIITTIIOO
Makefile inclusion, conditional structures and for loops reminiscent of
the C programming language are provided in bbmmaakkee. All such structures
are identified by a line beginning with a single dot (`.') character.
- Files are included with either ..iinncclluuddee <_f_i_l_e> or ..iinncclluuddee "_f_i_l_e".
- Variables between the angle brackets or double quotes are expanded to
- form the file name. If angle brackets are used, the included makefile is
+ Files are included with either ..iinncclluuddee <_f_i_l_e> or ..iinncclluuddee "_f_i_l_e". Vari-
+ ables between the angle brackets or double quotes are expanded to form
+ the file name. If angle brackets are used, the included makefile is
expected to be in the system makefile directory. If double quotes are
used, the including makefile's directory and any directories specified
using the --II option are searched before the system makefile directory.
@@ -827,9 +887,8 @@ IINNCCLLUUDDEE SSTTAATTEEMMEENNTTSS,, CCOONNDDIITTIIOO
..eexxppoorrtt--eennvv _v_a_r_i_a_b_l_e _._._.
The same as `.export', except that the variable is not appended
- to _._M_A_K_E_._E_X_P_O_R_T_E_D. This allows exporting a value to the
- environment which is different from that used by bbmmaakkee
- internally.
+ to _._M_A_K_E_._E_X_P_O_R_T_E_D. This allows exporting a value to the environ-
+ ment which is different from that used by bbmmaakkee internally.
..iinnffoo _m_e_s_s_a_g_e
The message is printed along with the name of the makefile and
@@ -845,13 +904,12 @@ IINNCCLLUUDDEE SSTTAATTEEMMEENNTTSS,, CCOONNDDIITTIIOO
all globals are unexported, and _._M_A_K_E_._E_X_P_O_R_T_E_D deleted.
..uunneexxppoorrtt--eennvv
- Unexport all globals previously exported and clear the
- environment inherited from the parent. This operation will cause
- a memory leak of the original environment, so should be used
- sparingly. Testing for _._M_A_K_E_._L_E_V_E_L being 0, would make sense.
- Also note that any variables which originated in the parent
- environment should be explicitly preserved if desired. For
- example:
+ Unexport all globals previously exported and clear the environ-
+ ment inherited from the parent. This operation will cause a mem-
+ ory leak of the original environment, so should be used spar-
+ ingly. Testing for _._M_A_K_E_._L_E_V_E_L being 0, would make sense. Also
+ note that any variables which originated in the parent environ-
+ ment should be explicitly preserved if desired. For example:
.if ${.MAKE.LEVEL} == 0
PATH := ${PATH}
@@ -940,13 +998,13 @@ IINNCCLLUUDDEE SSTTAATTEEMMEENNTTSS,, CCOONNDDIITTIIOO
_E_x_p_r_e_s_s_i_o_n may also be an arithmetic or string comparison. Variable
expansion is performed on both sides of the comparison, after which the
integral values are compared. A value is interpreted as hexadecimal if
- it is preceded by 0x, otherwise it is decimal; octal numbers are not
- supported. The standard C relational operators are all supported. If
- after variable expansion, either the left or right hand side of a `====' or
- `!!==' operator is not an integral value, then string comparison is
- performed between the expanded variables. If no relational operator is
- given, it is assumed that the expanded variable is being compared against
- 0 or an empty string in the case of a string comparison.
+ it is preceded by 0x, otherwise it is decimal; octal numbers are not sup-
+ ported. The standard C relational operators are all supported. If after
+ variable expansion, either the left or right hand side of a `====' or `!!=='
+ operator is not an integral value, then string comparison is performed
+ between the expanded variables. If no relational operator is given, it
+ is assumed that the expanded variable is being compared against 0 or an
+ empty string in the case of a string comparison.
When bbmmaakkee is evaluating one of these conditional expressions, and it
encounters a (white-space separated) word it doesn't recognize, either
@@ -955,8 +1013,8 @@ IINNCCLLUUDDEE SSTTAATTEEMMEENNTTSS,, CCOONNDDIITTIIOO
the ``defined'' expression is applied. Similarly, if the form is
`..iiffmmaakkee' or `..iiffnnmmaakkee, tthhee' ``make'' expression is applied.
- If the conditional evaluates to true the parsing of the makefile
- continues as before. If it evaluates to false, the following lines are
+ If the conditional evaluates to true the parsing of the makefile contin-
+ ues as before. If it evaluates to false, the following lines are
skipped. In both cases this continues until a `..eellssee' or `..eennddiiff' is
found.
@@ -975,15 +1033,15 @@ IINNCCLLUUDDEE SSTTAATTEEMMEENNTTSS,, CCOONNDDIITTIIOO
must be a multiple of three.
CCOOMMMMEENNTTSS
- Comments begin with a hash (`#') character, anywhere but in a shell
- command line, and continue to the end of an unescaped new line.
+ Comments begin with a hash (`#') character, anywhere but in a shell com-
+ mand line, and continue to the end of an unescaped new line.
SSPPEECCIIAALL SSOOUURRCCEESS ((AATTTTRRIIBBUUTTEESS))
- ..EEXXEECC Target is never out of date, but always execute commands
- anyway.
+ ..EEXXEECC Target is never out of date, but always execute commands any-
+ way.
- ..IIGGNNOORREE Ignore any errors from the commands associated with this
- target, exactly as if they all were preceded by a dash (`-').
+ ..IIGGNNOORREE Ignore any errors from the commands associated with this tar-
+ get, exactly as if they all were preceded by a dash (`-').
..MMAADDEE Mark all sources of this target as being up-to-date.
@@ -991,6 +1049,19 @@ SSPPEECCIIAALL SSOOUURRCCEESS ((AATTTTRRIIBBUUTTEESS))
or --tt options were specified. Normally used to mark recursive
bbmmaakkee's.
+ ..MMEETTAA Create a meta file for the target, even if it is flagged as
+ ..PPHHOONNYY, ..MMAAKKEE, or ..SSPPEECCIIAALL. Usage in conjunction with ..MMAAKKEE is
+ the most likely case.
+
+ ..NNOOMMEETTAA Do not create a meta file for the target. Meta files are also
+ not created for ..PPHHOONNYY, ..MMAAKKEE, or ..SSPPEECCIIAALL targets.
+
+ ..NNOOMMEETTAA__CCMMPP
+ Ignore differences in commands when deciding if target is out
+ of date. This is useful if the command contains a value which
+ always changes. If the number of commands change, though, the
+ target will still be out of date.
+
..NNOOPPAATTHH Do not search for the target in the directories specified by
..PPAATTHH.
@@ -999,9 +1070,9 @@ SSPPEECCIIAALL SSOOUURRCCEESS ((AATTTTRRIIBBUUTTEESS))
source prevents this target from being selected.
..OOPPTTIIOONNAALL
- If a target is marked with this attribute and bbmmaakkee can't
- figure out how to create it, it will ignore this fact and
- assume the file isn't needed or already exists.
+ If a target is marked with this attribute and bbmmaakkee can't fig-
+ ure out how to create it, it will ignore this fact and assume
+ the file isn't needed or already exists.
..PPHHOONNYY The target does not correspond to an actual file; it is always
considered to be out of date, and will not be created with the
@@ -1019,8 +1090,8 @@ SSPPEECCIIAALL SSOOUURRCCEESS ((AATTTTRRIIBBUUTTEESS))
..SSIILLEENNTT Do not echo any of the commands associated with this target,
exactly as if they all were preceded by an at sign (`@').
- ..UUSSEE Turn the target into bbmmaakkee's version of a macro. When the
- target is used as a source for another target, the other target
+ ..UUSSEE Turn the target into bbmmaakkee's version of a macro. When the tar-
+ get is used as a source for another target, the other target
acquires the commands, sources, and attributes (except for
..UUSSEE) of the source. If the target already has commands, the
..UUSSEE target's commands are appended to them.
@@ -1033,8 +1104,8 @@ SSPPEECCIIAALL SSOOUURRCCEESS ((AATTTTRRIIBBUUTTEESS))
it are made before the sources that succeed it in the line.
Since the dependents of files are not made until the file
itself could be made, this also stops the dependents being
- built unless they are needed for another branch of the
- dependency tree. So given:
+ built unless they are needed for another branch of the depen-
+ dency tree. So given:
x: a .WAIT b
echo x
@@ -1058,10 +1129,10 @@ SSPPEECCIIAALL TTAARRGGEETTSS
..DDEEFFAAUULLTT
This is sort of a ..UUSSEE rule for any target (that was used only
- as a source) that bbmmaakkee can't figure out any other way to
- create. Only the shell script is used. The ..IIMMPPSSRRCC variable of
- a target that inherits ..DDEEFFAAUULLTT's commands is set to the
- target's own name.
+ as a source) that bbmmaakkee can't figure out any other way to cre-
+ ate. Only the shell script is used. The ..IIMMPPSSRRCC variable of a
+ target that inherits ..DDEEFFAAUULLTT's commands is set to the target's
+ own name.
..EENNDD Any command lines attached to this target are executed after
everything else is done.
@@ -1096,22 +1167,22 @@ SSPPEECCIIAALL TTAARRGGEETTSS
variants.
..OORRDDEERR The named targets are made in sequence. This ordering does not
- add targets to the list of targets to be made. Since the
- dependents of a target do not get built until the target itself
- could be built, unless `a' is built by another part of the
- dependency graph, the following is a dependency loop:
+ add targets to the list of targets to be made. Since the depen-
+ dents of a target do not get built until the target itself could
+ be built, unless `a' is built by another part of the dependency
+ graph, the following is a dependency loop:
- .ORDER: a b
+ .ORDER: b a
b: a
The ordering imposed by ..OORRDDEERR is only relevant for parallel
makes.
..PPAATTHH The sources are directories which are to be searched for files
- not found in the current directory. If no sources are
- specified, any previously specified directories are deleted. If
- the source is the special ..DDOOTTLLAASSTT target, then the current
- working directory is searched last.
+ not found in the current directory. If no sources are speci-
+ fied, any previously specified directories are deleted. If the
+ source is the special ..DDOOTTLLAASSTT target, then the current working
+ directory is searched last.
..PPHHOONNYY Apply the ..PPHHOONNYY attribute to any specified sources.
@@ -1136,16 +1207,16 @@ SSPPEECCIIAALL TTAARRGGEETTSS
_e_c_h_o The command to turn on echoing of commands executed.
- _q_u_i_e_t The command to turn off echoing of commands
- executed.
+ _q_u_i_e_t The command to turn off echoing of commands exe-
+ cuted.
- _f_i_l_t_e_r The output to filter after issuing the _q_u_i_e_t
- command. It is typically identical to _q_u_i_e_t.
+ _f_i_l_t_e_r The output to filter after issuing the _q_u_i_e_t com-
+ mand. It is typically identical to _q_u_i_e_t.
_e_r_r_F_l_a_g The flag to pass the shell to enable error checking.
- _e_c_h_o_F_l_a_g The flag to pass the shell to enable command
- echoing.
+ _e_c_h_o_F_l_a_g The flag to pass the shell to enable command echo-
+ ing.
_n_e_w_l_i_n_e The string literal to pass the shell that results in
a single newline character when used outside of any
@@ -1178,8 +1249,8 @@ EENNVVIIRROONNMMEENNTT
PWD, and TMPDIR.
MAKEOBJDIRPREFIX and MAKEOBJDIR may only be set in the environment or on
- the command line to bbmmaakkee and not as makefile variables; see the
- description of `_._O_B_J_D_I_R' for more details.
+ the command line to bbmmaakkee and not as makefile variables; see the descrip-
+ tion of `_._O_B_J_D_I_R' for more details.
FFIILLEESS
.depend list of dependencies
@@ -1194,14 +1265,22 @@ CCOOMMPPAATTIIBBIILLIITTYY
not.
The way that parallel makes are scheduled changed in NetBSD 4.0 so that
- .ORDER and .WAIT apply recursively to the dependant nodes. The
- algorithms used may change again in the future.
+ .ORDER and .WAIT apply recursively to the dependant nodes. The algo-
+ rithms used may change again in the future.
The way that .for loop variables are substituted changed after NetBSD 5.0
so that they still appear to be variable expansions. In particular this
stops them being treated as syntax, and removes some obscure problems
using them in .if statements.
+ Unlike other bbmmaakkee programs, this implementation by default executes all
+ commands for a given target using a single shell invocation. This is
+ done for both efficiency and to simplify error handling in remote command
+ invocations. Typically this is transparent to the user, unless the tar-
+ get commands change the current working directory using ``cd'' or
+ ``chdir''. To be compatible with Makefiles that do this, one can use --BB
+ to disable this behavior.
+
SSEEEE AALLSSOO
mkdep(1)
@@ -1219,4 +1298,4 @@ BBUUGGSS
There is no way of escaping a space character in a filename.
-NetBSD 5.0 June 30, 2010 NetBSD 5.0
+BSD May 29, 2011 BSD
diff --git a/devel/bmake/files/boot-strap b/devel/bmake/files/boot-strap
index b1e160081b9..e5f60a6b651 100755
--- a/devel/bmake/files/boot-strap
+++ b/devel/bmake/files/boot-strap
@@ -34,6 +34,16 @@
#
# Possibly useful configure_args:
#
+# --without-meta
+# disable use of meta mode.
+#
+# --without-filemon
+# disable use of filemon(9) which is currently only
+# available for NetBSD and FreeBSD.
+#
+# --with-filemon="path/to/filemon.h"
+# enables use of filemon(9) by meta mode.
+#
# --with-machine="machine"
# set "machine" to override that determined by
# machine.sh
@@ -53,7 +63,7 @@
# Simon J. Gerraty <sjg@crufty.net>
# RCSid:
-# $Id: boot-strap,v 1.9 2010/09/07 14:28:00 joerg Exp $
+# $Id: boot-strap,v 1.10 2011/06/18 22:39:46 bsiegert Exp $
#
# @(#) Copyright (c) 2001 Simon J. Gerraty
#
@@ -263,6 +273,12 @@ ShareDir() {
echo $1/share
}
+# make it easy to force prefix to use $HOST_TARGET
+: looking at "$prefix"
+case "$prefix" in
+*/host?target) prefix=`echo "$prefix" | sed "s,host.target,${HOST_TARGET},"`;;
+esac
+
share_dir="${share_dir:-`ShareDir $prefix`}"
AddConfigure --prefix= "$prefix"
@@ -294,7 +310,7 @@ if [ -s "${mksrc:-/dev/null}/install-mk" ]; then
esac
fi
# make sure test below uses the same diff that configure did
-TOOL_DIFF=`type diff | sed 's,^[^/][^/]*,,;q'`
+TOOL_DIFF=`type diff | sed 's,[()],,g;s,^[^/][^/]*,,;q'`
export MAKESYSPATH TOOL_DIFF
if [ "$mksrc" ]; then
$objdir/bmake test || exit 1
diff --git a/devel/bmake/files/compat.c b/devel/bmake/files/compat.c
index f2e46be124c..779f491838c 100644
--- a/devel/bmake/files/compat.c
+++ b/devel/bmake/files/compat.c
@@ -1,4 +1,4 @@
-/* $NetBSD: compat.c,v 1.8 2010/09/07 14:28:00 joerg Exp $ */
+/* $NetBSD: compat.c,v 1.9 2011/06/18 22:39:46 bsiegert 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.8 2010/09/07 14:28:00 joerg Exp $";
+static char rcsid[] = "$NetBSD: compat.c,v 1.9 2011/06/18 22:39:46 bsiegert 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.8 2010/09/07 14:28:00 joerg Exp $");
+__RCSID("$NetBSD: compat.c,v 1.9 2011/06/18 22:39:46 bsiegert Exp $");
#endif
#endif /* not lint */
#endif
@@ -355,6 +355,12 @@ again:
local = TRUE;
+#ifdef USE_META
+ if (useMeta) {
+ meta_compat_start();
+ }
+#endif
+
/*
* Fork and execute the single command. If the fork fails, we abort.
*/
@@ -365,6 +371,11 @@ again:
if (cpid == 0) {
Check_Cwd(av);
Var_ExportVars();
+#ifdef USE_META
+ if (useMeta) {
+ meta_compat_child();
+ }
+#endif
if (local)
(void)execvp(av[0], (char *const *)UNCONST(av));
else
@@ -378,6 +389,12 @@ again:
free(bp);
Lst_Replace(cmdNode, NULL);
+#ifdef USE_META
+ if (useMeta) {
+ meta_compat_parent();
+ }
+#endif
+
/*
* The child is off and running. Now all we can do is wait...
*/
@@ -396,6 +413,11 @@ again:
status = WSTOPSIG(reason); /* stopped */
} else if (WIFEXITED(reason)) {
status = WEXITSTATUS(reason); /* exited */
+#if defined(USE_META) && defined(USE_FILEMON_ONCE)
+ if (useMeta) {
+ meta_cmd_finish(NULL);
+ }
+#endif
if (status != 0) {
if (DEBUG(ERROR)) {
fprintf(debug_file, "\n*** Failed target: %s\n*** Failed command: ",
@@ -422,6 +444,11 @@ again:
if (!WIFEXITED(reason) || (status != 0)) {
if (errCheck) {
+#ifdef USE_META
+ if (useMeta) {
+ meta_job_error(NULL, gn, 0, status);
+ }
+#endif
gn->made = ERROR;
if (keepgoing) {
/*
@@ -503,10 +530,10 @@ Compat_Make(void *gnp, void *pgnp)
}
/*
- * All the children were made ok. Now cmtime contains the modification
- * time of the newest child, we need to find out if we exist and when
- * we were modified last. The criteria for datedness are defined by the
- * Make_OODate function.
+ * All the children were made ok. Now cmgn->mtime contains the
+ * modification time of the newest child, we need to find out if we
+ * exist and when we were modified last. The criteria for datedness
+ * are defined by the Make_OODate function.
*/
if (DEBUG(MAKE)) {
fprintf(debug_file, "Examining %s...", gn->name);
@@ -554,6 +581,11 @@ Compat_Make(void *gnp, void *pgnp)
*/
if (!touchFlag || (gn->type & OP_MAKE)) {
curTarg = gn;
+#ifdef USE_META
+ if (useMeta && !NoExecute(gn)) {
+ meta_job_start(NULL, gn);
+ }
+#endif
Lst_ForEach(gn->commands, CompatRunCommand, gn);
curTarg = NULL;
} else {
@@ -562,6 +594,11 @@ Compat_Make(void *gnp, void *pgnp)
} else {
gn->made = ERROR;
}
+#ifdef USE_META
+ if (useMeta && !NoExecute(gn)) {
+ meta_job_finish(NULL);
+ }
+#endif
if (gn->made != ERROR) {
/*
diff --git a/devel/bmake/files/cond.c b/devel/bmake/files/cond.c
index 8b7ece30822..3346771f698 100644
--- a/devel/bmake/files/cond.c
+++ b/devel/bmake/files/cond.c
@@ -1,4 +1,4 @@
-/* $NetBSD: cond.c,v 1.6 2010/04/20 13:37:49 joerg Exp $ */
+/* $NetBSD: cond.c,v 1.7 2011/06/18 22:39:46 bsiegert 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.6 2010/04/20 13:37:49 joerg Exp $";
+static char rcsid[] = "$NetBSD: cond.c,v 1.7 2011/06/18 22:39:46 bsiegert 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.6 2010/04/20 13:37:49 joerg Exp $");
+__RCSID("$NetBSD: cond.c,v 1.7 2011/06/18 22:39:46 bsiegert Exp $");
#endif
#endif /* not lint */
#endif
@@ -327,7 +327,7 @@ CondGetArg(char **linePtr, char **argPtr, const char *func)
*-----------------------------------------------------------------------
*/
static Boolean
-CondDoDefined(int argLen, const char *arg)
+CondDoDefined(int argLen __unused, const char *arg)
{
char *p1;
Boolean result;
@@ -376,7 +376,7 @@ CondStrMatch(const void *string, const void *pattern)
*-----------------------------------------------------------------------
*/
static Boolean
-CondDoMake(int argLen, const char *arg)
+CondDoMake(int argLen __unused, const char *arg)
{
return Lst_Find(create, arg, CondStrMatch) != NULL;
}
@@ -395,22 +395,22 @@ CondDoMake(int argLen, const char *arg)
*-----------------------------------------------------------------------
*/
static Boolean
-CondDoExists(int argLen, const char *arg)
+CondDoExists(int argLen __unused, const char *arg)
{
Boolean result;
char *path;
path = Dir_FindFile(arg, dirSearchPath);
+ if (DEBUG(COND)) {
+ fprintf(debug_file, "exists(%s) result is \"%s\"\n",
+ arg, path ? path : "");
+ }
if (path != NULL) {
result = TRUE;
free(path);
} else {
result = FALSE;
}
- if (DEBUG(COND)) {
- fprintf(debug_file, "exists(%s) result is \"%s\"\n",
- arg, path ? path : "");
- }
return (result);
}
@@ -428,7 +428,7 @@ CondDoExists(int argLen, const char *arg)
*-----------------------------------------------------------------------
*/
static Boolean
-CondDoTarget(int argLen, const char *arg)
+CondDoTarget(int argLen __unused, const char *arg)
{
GNode *gn;
@@ -452,7 +452,7 @@ CondDoTarget(int argLen, const char *arg)
*-----------------------------------------------------------------------
*/
static Boolean
-CondDoCommands(int argLen, const char *arg)
+CondDoCommands(int argLen __unused, const char *arg)
{
GNode *gn;
@@ -790,7 +790,7 @@ done:
}
static int
-get_mpt_arg(char **linePtr, char **argPtr, const char *func)
+get_mpt_arg(char **linePtr, char **argPtr, const char *func __unused)
{
/*
* Use Var_Parse to parse the spec in parens and return
@@ -831,7 +831,7 @@ get_mpt_arg(char **linePtr, char **argPtr, const char *func)
}
static Boolean
-CondDoEmpty(int arglen, const char *arg)
+CondDoEmpty(int arglen, const char *arg __unused)
{
return arglen == 1;
}
diff --git a/devel/bmake/files/config.h.in b/devel/bmake/files/config.h.in
index f0a3152c092..2c7e4eb297c 100644
--- a/devel/bmake/files/config.h.in
+++ b/devel/bmake/files/config.h.in
@@ -20,9 +20,21 @@
*/
#undef HAVE_DIRENT_H
+/* Define to 1 if you have the `dirname' function. */
+#undef HAVE_DIRNAME
+
/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
#undef HAVE_DOPRNT
+/* Define to 1 if you have the `err' function. */
+#undef HAVE_ERR
+
+/* Define to 1 if you have the `errx' function. */
+#undef HAVE_ERRX
+
+/* Define to 1 if you have the <err.h> header file. */
+#undef HAVE_ERR_H
+
/* Define to 1 if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H
@@ -50,6 +62,9 @@
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
+/* Define to 1 if you have the `mmap' function. */
+#undef HAVE_MMAP
+
/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
#undef HAVE_NDIR_H
@@ -92,6 +107,9 @@
/* Define to 1 if you have the `strerror' function. */
#undef HAVE_STRERROR
+/* Define to 1 if you have the `stresep' function. */
+#undef HAVE_STRESEP
+
/* Define to 1 if you have the `strftime' function. */
#undef HAVE_STRFTIME
@@ -101,6 +119,12 @@
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
+/* Define to 1 if you have the `strlcpy' function. */
+#undef HAVE_STRLCPY
+
+/* Define to 1 if you have the `strsep' function. */
+#undef HAVE_STRSEP
+
/* Define to 1 if you have the `strtod' function. */
#undef HAVE_STRTOD
@@ -118,6 +142,9 @@
*/
#undef HAVE_SYS_DIR_H
+/* Define to 1 if you have the <sys/mman.h> header file. */
+#undef HAVE_SYS_MMAN_H
+
/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
*/
#undef HAVE_SYS_NDIR_H
@@ -173,6 +200,12 @@
/* Define to 1 if you have the `waitpid' function. */
#undef HAVE_WAITPID
+/* Define to 1 if you have the `warn' function. */
+#undef HAVE_WARN
+
+/* Define to 1 if you have the `warnx' function. */
+#undef HAVE_WARNX
+
/* Define to 1 if `fork' works. */
#undef HAVE_WORKING_FORK
diff --git a/devel/bmake/files/configure b/devel/bmake/files/configure
index ebf085d5920..9a0d5fe4206 100755
--- a/devel/bmake/files/configure
+++ b/devel/bmake/files/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.64 for bmake 20100414.
+# Generated by GNU Autoconf 2.64 for bmake 2010505.
#
# Report bugs to <sjg@NetBSD.org>.
#
@@ -549,8 +549,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='bmake'
PACKAGE_TARNAME='bmake'
-PACKAGE_VERSION='20100414'
-PACKAGE_STRING='bmake 20100414'
+PACKAGE_VERSION='2010505'
+PACKAGE_STRING='bmake 2010505'
PACKAGE_BUGREPORT='sjg@NetBSD.org'
PACKAGE_URL=''
@@ -591,6 +591,8 @@ ac_includes_default="\
#endif"
ac_subst_vars='LTLIBOBJS
+filemon_h
+use_meta
diff_u
GCC
INSTALL
@@ -656,6 +658,8 @@ ac_subst_files=''
ac_user_opts='
enable_option_checking
with_defshell
+with_meta
+with_filemon
with_machine
with_force_machine
with_force_machine_arch
@@ -1216,7 +1220,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures bmake 20100414 to adapt to many kinds of systems.
+\`configure' configures bmake 2010505 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1277,7 +1281,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of bmake 20100414:";;
+ short | recursive ) echo "Configuration of bmake 2010505:";;
esac
cat <<\_ACEOF
@@ -1293,6 +1297,8 @@ Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--with-defshell=SHELL use SHELL by default - must be sh compatible, use sh or ksh to pick the internal definitions
+ --without-meta dissable use of meta-mode
+ --with-filemon=path/filemon.h indicate path to filemon.h for meta-mode
--with-machine=MACHINE explicitly set MACHINE
--with-force-machine=MACHINE set FORCE_MACHINE
--with-force-machine-arch=MACHINE set FORCE_MACHINE_ARCH
@@ -1380,7 +1386,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-bmake configure 20100414
+bmake configure 2010505
generated by GNU Autoconf 2.64
Copyright (C) 2009 Free Software Foundation, Inc.
@@ -1901,7 +1907,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by bmake $as_me 20100414, which was
+It was created by bmake $as_me 2010505, which was
generated by GNU Autoconf 2.64. Invocation command line was
$ $0 $@
@@ -2267,6 +2273,47 @@ no) ;;
esac
fi
+use_meta=yes
+
+# Check whether --with-meta was given.
+if test "${with_meta+set}" = set; then :
+ withval=$with_meta; case "${withval}" in
+yes|no) use_meta=${withval};;
+*) as_fn_error "bad value ${withval} given for meta" "$LINENO" 5 ;;
+esac
+fi
+
+
+# Check whether --with-filemon was given.
+if test "${with_filemon+set}" = set; then :
+ withval=$with_filemon; case "/${withval}" in
+/no|*/filemon.h) filemon_h="${withval}";;
+*/filemon*) filemon_h="${withval}/filemon.h";;
+*) as_fn_error "bad value ${withval} given for filemon" "$LINENO" 5 ;;
+esac
+else
+
+OS=`uname -s`
+for d in "$srcdir/filemon" "$srcdir/../filemon"
+do
+ for x in "/$OS" ""
+ do
+ filemon_h="$d$x/filemon.h"
+ test -s "$filemon_h" && break
+ done
+ test -s "$filemon_h" && break
+done
+test -s "${filemon_h:-/dev/null}" || filemon_h=no
+
+fi
+
+case "$use_meta" in
+yes)
+ case "$filemon_h" in
+ *.h) echo "Using: filemon=$filemon_h" >&6;;
+ esac
+ ;;
+esac
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -4508,11 +4555,13 @@ fi
for ac_header in \
ar.h \
+ err.h \
fcntl.h \
paths.h \
poll.h \
ranlib.h \
string.h \
+ sys/mman.h \
sys/select.h \
sys/socket.h \
sys/time.h \
@@ -5360,11 +5409,14 @@ $as_echo "#define HAVE_WAIT3 1" >>confdefs.h
fi
for ac_func in \
+ err \
+ errx \
getcwd \
getenv \
getopt \
getwd \
killpg \
+ mmap \
putenv \
select \
setenv \
@@ -5373,6 +5425,7 @@ for ac_func in \
snprintf \
strerror \
strftime \
+ strsep \
strtod \
strtol \
unsetenv \
@@ -5380,6 +5433,8 @@ for ac_func in \
wait3 \
wait4 \
waitpid \
+ warn \
+ warnx \
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
@@ -5397,6 +5452,9 @@ done
for ac_func in \
getenv \
realpath \
+ dirname \
+ stresep \
+ strlcpy \
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
@@ -5793,6 +5851,8 @@ fi
+
+
ac_config_files="$ac_config_files Makefile make-bootstrap.sh unit-tests/Makefile"
cat >confcache <<\_ACEOF
@@ -6301,7 +6361,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by bmake $as_me 20100414, which was
+This file was extended by bmake $as_me 2010505, which was
generated by GNU Autoconf 2.64. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -6361,7 +6421,7 @@ Report bugs to <sjg@NetBSD.org>."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_version="\\
-bmake config.status 20100414
+bmake config.status 2010505
configured by $0, generated by GNU Autoconf 2.64,
with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
diff --git a/devel/bmake/files/configure.in b/devel/bmake/files/configure.in
index 9e438f7e7d2..50001c07e76 100644
--- a/devel/bmake/files/configure.in
+++ b/devel/bmake/files/configure.in
@@ -1,10 +1,10 @@
dnl
dnl RCSid:
-dnl $Id: configure.in,v 1.10 2010/04/20 13:37:49 joerg Exp $
+dnl $Id: configure.in,v 1.11 2011/06/18 22:39:46 bsiegert Exp $
dnl
dnl Process this file with autoconf to produce a configure script
dnl
-AC_INIT([bmake], [20100414], [sjg@NetBSD.org])
+AC_INIT([bmake], [2010505], [sjg@NetBSD.org])
AC_CONFIG_HEADER(config.h)
dnl
@@ -22,6 +22,42 @@ no) ;;
;;
esac])
dnl
+use_meta=yes
+AC_ARG_WITH(meta,
+[ --without-meta dissable use of meta-mode],
+[case "${withval}" in
+yes|no) use_meta=${withval};;
+*) AC_MSG_ERROR(bad value ${withval} given for meta) ;;
+esac])
+dnl
+AC_ARG_WITH(filemon,
+[ --with-filemon=path/filemon.h indicate path to filemon.h for meta-mode],
+[ case "/${withval}" in
+/no|*/filemon.h) filemon_h="${withval}";;
+*/filemon*) filemon_h="${withval}/filemon.h";;
+*) AC_MSG_ERROR(bad value ${withval} given for filemon) ;;
+esac],
+[
+OS=`uname -s`
+for d in "$srcdir/filemon" "$srcdir/../filemon"
+do
+ for x in "/$OS" ""
+ do
+ filemon_h="$d$x/filemon.h"
+ test -s "$filemon_h" && break
+ done
+ test -s "$filemon_h" && break
+done
+test -s "${filemon_h:-/dev/null}" || filemon_h=no
+])
+dnl echo "Note: use_meta=$use_meta filemon_h=$filemon_h" >&6
+case "$use_meta" in
+yes)
+ case "$filemon_h" in
+ *.h) echo "Using: filemon=$filemon_h" >&6;;
+ esac
+ ;;
+esac
dnl
dnl Check for OS problems
dnl Solaris's signal.h only privides sigset_t etc if one of
@@ -47,11 +83,13 @@ AC_HEADER_DIRENT
dnl Keep this list sorted
AC_CHECK_HEADERS( \
ar.h \
+ err.h \
fcntl.h \
paths.h \
poll.h \
ranlib.h \
string.h \
+ sys/mman.h \
sys/select.h \
sys/socket.h \
sys/time.h \
@@ -94,11 +132,14 @@ AC_FUNC_VPRINTF
AC_FUNC_WAIT3
dnl Keep this list sorted
AC_CHECK_FUNCS( \
+ err \
+ errx \
getcwd \
getenv \
getopt \
getwd \
killpg \
+ mmap \
putenv \
select \
setenv \
@@ -107,6 +148,7 @@ AC_CHECK_FUNCS( \
snprintf \
strerror \
strftime \
+ strsep \
strtod \
strtol \
unsetenv \
@@ -114,12 +156,17 @@ AC_CHECK_FUNCS( \
wait3 \
wait4 \
waitpid \
+ warn \
+ warnx \
)
dnl functions which we may need to provide
AC_REPLACE_FUNCS( \
getenv \
realpath \
+ dirname \
+ stresep \
+ strlcpy \
)
AC_CHECK_LIB([util], [emalloc],
@@ -298,6 +345,8 @@ AC_SUBST(default_sys_path)
AC_SUBST(INSTALL)
AC_SUBST(GCC)
AC_SUBST(diff_u)
+AC_SUBST(use_meta)
+AC_SUBST(filemon_h)
AC_OUTPUT(Makefile make-bootstrap.sh unit-tests/Makefile)
cat <<EOF
diff --git a/devel/bmake/files/dir.c b/devel/bmake/files/dir.c
index 086c24ca1f9..0deee9f97b7 100644
--- a/devel/bmake/files/dir.c
+++ b/devel/bmake/files/dir.c
@@ -1,4 +1,4 @@
-/* $NetBSD: dir.c,v 1.4 2009/09/18 21:27:25 joerg Exp $ */
+/* $NetBSD: dir.c,v 1.5 2011/06/18 22:39:46 bsiegert 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.4 2009/09/18 21:27:25 joerg Exp $";
+static char rcsid[] = "$NetBSD: dir.c,v 1.5 2011/06/18 22:39:46 bsiegert 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.4 2009/09/18 21:27:25 joerg Exp $");
+__RCSID("$NetBSD: dir.c,v 1.5 2011/06/18 22:39:46 bsiegert Exp $");
#endif
#endif /* not lint */
#endif
@@ -1061,6 +1061,7 @@ Dir_FindFile(const char *name, Lst path)
Boolean hasSlash; /* true if 'name' contains a / */
struct stat stb; /* Buffer for stat, if necessary */
Hash_Entry *entry; /* Entry for mtimes table */
+ const char *trailing_dot = ".";
/*
* Find the final component of the name and note whether it has a
@@ -1165,6 +1166,11 @@ Dir_FindFile(const char *name, Lst path)
return NULL;
}
+ if (*cp == '\0') {
+ /* we were given a trailing "/" */
+ cp = trailing_dot;
+ }
+
if (name[0] != '/') {
Boolean checkedDot = FALSE;
@@ -1272,6 +1278,10 @@ Dir_FindFile(const char *name, Lst path)
* b/c we added it here. This is not good...
*/
#ifdef notdef
+ if (cp == traling_dot) {
+ cp = strrchr(name, '/');
+ cp += 1;
+ }
cp[-1] = '\0';
(void)Dir_AddDir(path, name);
cp[-1] = '/';
@@ -1434,6 +1444,31 @@ Dir_MTime(GNode *gn)
fullName = NULL;
else {
fullName = Dir_FindFile(gn->name, Suff_FindPath(gn));
+ if (fullName == NULL && gn->flags & FROM_DEPEND &&
+ !Lst_IsEmpty(gn->iParents)) {
+ char *cp;
+
+ cp = strrchr(gn->name, '/');
+ if (cp) {
+ /*
+ * This is an implied source, and it may have moved,
+ * see if we can find it via the current .PATH
+ */
+ cp++;
+
+ fullName = Dir_FindFile(cp, Suff_FindPath(gn));
+ if (fullName) {
+ /*
+ * Put the found file in gn->path
+ * so that we give that to the compiler.
+ */
+ gn->path = bmake_strdup(fullName);
+ fprintf(stdout,
+ "%s: ignoring stale %s for %s, found %s\n",
+ progname, makeDependfile, gn->name, fullName);
+ }
+ }
+ }
if (DEBUG(DIR))
fprintf(debug_file, "Found '%s' as '%s'\n",
gn->name, fullName ? fullName : "(not found)" );
diff --git a/devel/bmake/files/for.c b/devel/bmake/files/for.c
index 11256a7f4b4..ec0ef6a17f3 100644
--- a/devel/bmake/files/for.c
+++ b/devel/bmake/files/for.c
@@ -1,4 +1,4 @@
-/* $NetBSD: for.c,v 1.5 2010/04/20 13:37:49 joerg Exp $ */
+/* $NetBSD: for.c,v 1.6 2011/06/18 22:39:46 bsiegert 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.5 2010/04/20 13:37:49 joerg Exp $";
+static char rcsid[] = "$NetBSD: for.c,v 1.6 2011/06/18 22:39:46 bsiegert 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.5 2010/04/20 13:37:49 joerg Exp $");
+__RCSID("$NetBSD: for.c,v 1.6 2011/06/18 22:39:46 bsiegert Exp $");
#endif
#endif /* not lint */
#endif
@@ -366,7 +366,7 @@ for_substitute(Buffer *cmds, strlist_t *items, unsigned int item_no, char ech)
}
static char *
-For_Iterate(void *v_arg)
+For_Iterate(void *v_arg, size_t *ret_len)
{
For *arg = v_arg;
int i, len;
@@ -451,6 +451,7 @@ For_Iterate(void *v_arg)
arg->sub_next += strlist_num(&arg->vars);
arg->parse_buf = cp;
+ *ret_len = strlen(cp);
return cp;
}
diff --git a/devel/bmake/files/job.c b/devel/bmake/files/job.c
index ea4fa7e1e9b..5582d8ea90e 100644
--- a/devel/bmake/files/job.c
+++ b/devel/bmake/files/job.c
@@ -1,4 +1,4 @@
-/* $NetBSD: job.c,v 1.11 2010/09/07 14:28:00 joerg Exp $ */
+/* $NetBSD: job.c,v 1.12 2011/06/18 22:39:46 bsiegert 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.11 2010/09/07 14:28:00 joerg Exp $";
+static char rcsid[] = "$NetBSD: job.c,v 1.12 2011/06/18 22:39:46 bsiegert 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.11 2010/09/07 14:28:00 joerg Exp $");
+__RCSID("$NetBSD: job.c,v 1.12 2011/06/18 22:39:46 bsiegert Exp $");
#endif
#endif /* not lint */
#endif
@@ -1030,6 +1030,11 @@ JobFinish (Job *job, WAIT_T status)
MESSAGE(stdout, job->node);
lastNode = job->node;
}
+#ifdef USE_META
+ if (useMeta) {
+ meta_job_error(job, job->node, job->flags, WEXITSTATUS(status));
+ }
+#endif
(void)printf("*** [%s] Error code %d%s\n",
job->node->name,
WEXITSTATUS(status),
@@ -1058,6 +1063,12 @@ JobFinish (Job *job, WAIT_T status)
(void)fflush(stdout);
}
+#ifdef USE_META
+ if (useMeta) {
+ meta_job_finish(job);
+ }
+#endif
+
return_job_token = FALSE;
Trace_Log(JOBEND, job);
@@ -1325,6 +1336,11 @@ JobExec(Job *job, char **argv)
/* Child */
sigset_t tmask;
+#ifdef USE_META
+ if (useMeta) {
+ meta_job_child(job);
+ }
+#endif
/*
* Reset all signal handlers; this is necessary because we also
* need to unblock signals before we exec(2).
@@ -1588,6 +1604,11 @@ JobStart(GNode *gn, int flags)
*/
noExec = FALSE;
+#ifdef USE_META
+ if (useMeta) {
+ meta_job_start(job, gn);
+ }
+#endif
/*
* We can do all the commands at once. hooray for sanity
*/
@@ -1860,6 +1881,11 @@ end_loop:
MESSAGE(stdout, job->node);
lastNode = job->node;
}
+#ifdef USE_META
+ if (useMeta) {
+ meta_job_output(job, cp, gotNL ? "\n" : "");
+ }
+#endif
(void)fprintf(stdout, "%s%s", cp, gotNL ? "\n" : "");
(void)fflush(stdout);
}
diff --git a/devel/bmake/files/job.h b/devel/bmake/files/job.h
index 4ff63c0bbd9..3fb4e3919e8 100644
--- a/devel/bmake/files/job.h
+++ b/devel/bmake/files/job.h
@@ -1,4 +1,4 @@
-/* $NetBSD: job.h,v 1.6 2009/09/18 21:27:25 joerg Exp $ */
+/* $NetBSD: job.h,v 1.7 2011/06/18 22:39:46 bsiegert Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -135,6 +135,11 @@ emul_poll(struct pollfd *fd, int nfd, int timeout);
*/
struct pollfd;
+
+#ifdef USE_META
+# include "meta.h"
+#endif
+
#define JOB_BUFSIZE 1024
typedef struct Job {
int pid; /* The child's process ID */
@@ -165,6 +170,10 @@ typedef struct Job {
/* Buffer for storing the output of the
* job, line by line */
int curPos; /* Current position in op_outBuf */
+
+#ifdef USE_META
+ struct BuildMon bm;
+#endif
} Job;
#define inPipe jobPipe[0]
diff --git a/devel/bmake/files/machine.sh b/devel/bmake/files/machine.sh
index 00cdfb5b68c..7c42667b0f0 100755
--- a/devel/bmake/files/machine.sh
+++ b/devel/bmake/files/machine.sh
@@ -2,7 +2,7 @@
# derrived from /etc/rc_d/os.sh
# RCSid:
-# $Id: machine.sh,v 1.3 2011/01/23 19:07:25 agc Exp $
+# $Id: machine.sh,v 1.4 2011/06/18 22:39:46 bsiegert Exp $
#
# @(#) Copyright (c) 1994-2002 Simon J. Gerraty
#
@@ -23,8 +23,10 @@ OSMAJOR=`IFS=.; set $OSREL; echo $1`
machine=`uname -p 2>/dev/null || uname -m`
MACHINE=
+# there is at least one case of `uname -p` outputting
+# a bunch of usless drivel
case "$machine" in
-unknown)
+unknown|*[!A-Za-z0-9_-]*)
machine=`uname -m`
;;
esac
diff --git a/devel/bmake/files/main.c b/devel/bmake/files/main.c
index d13e8c5fbcb..77f6be89c5f 100644
--- a/devel/bmake/files/main.c
+++ b/devel/bmake/files/main.c
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.10 2010/09/07 14:28:00 joerg Exp $ */
+/* $NetBSD: main.c,v 1.11 2011/06/18 22:39:46 bsiegert Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: main.c,v 1.10 2010/09/07 14:28:00 joerg Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.11 2011/06/18 22:39:46 bsiegert 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.10 2010/09/07 14:28:00 joerg Exp $");
+__RCSID("$NetBSD: main.c,v 1.11 2011/06/18 22:39:46 bsiegert Exp $");
#endif
#endif /* not lint */
#endif
@@ -183,8 +183,8 @@ static int ReadMakefile(const void *, const void *);
static void usage(void);
static Boolean ignorePWD; /* if we use -C, PWD is meaningless */
-static char curdir[MAXPATHLEN + 1]; /* startup directory */
static char objdir[MAXPATHLEN + 1]; /* where we chdir'ed to */
+char curdir[MAXPATHLEN + 1]; /* Startup directory */
char *progname; /* the program name */
char *makeDependfile;
pid_t myPid;
@@ -253,6 +253,9 @@ parse_debug_options(const char *argvalue)
case 'l':
debug |= DEBUG_LOUD;
break;
+ case 'M':
+ debug |= DEBUG_META;
+ break;
case 'm':
debug |= DEBUG_MAKE;
break;
@@ -713,7 +716,7 @@ ReadAllMakefiles(const void *p, const void *q)
return (ReadMakefile(p, q) == 0);
}
-static int
+int
str2Lst_Append(Lst lp, char *str, const char *sep)
{
char *cp;
@@ -732,7 +735,7 @@ str2Lst_Append(Lst lp, char *str, const char *sep)
#ifdef SIGINFO
/*ARGSUSED*/
static void
-siginfo(int signo)
+siginfo(int signo __unused)
{
char dir[MAXPATHLEN];
char str[2 * MAXPATHLEN];
@@ -761,6 +764,10 @@ MakeMode(const char *mode)
compatMake = TRUE;
forceJobs = FALSE;
}
+#if USE_META
+ if (strstr(mode, "meta"))
+ meta_init(mode);
+#endif
}
if (mp)
free(mp);
@@ -792,9 +799,9 @@ main(int argc, char **argv)
char *p1, *path, *pwd;
char mdpath[MAXPATHLEN];
#ifdef FORCE_MACHINE
- char *machine = FORCE_MACHINE;
+ const char *machine = FORCE_MACHINE;
#else
- char *machine = getenv("MACHINE");
+ const char *machine = getenv("MACHINE");
#endif
const char *machine_arch = getenv("MACHINE_ARCH");
char *syspath = getenv("MAKESYSPATH");
@@ -990,7 +997,8 @@ main(int argc, char **argv)
* We take care of PWD for the automounter below...
*/
if (getcwd(curdir, MAXPATHLEN) == NULL) {
- (void)fprintf(stderr, "%s: %s.\n", progname, strerror(errno));
+ (void)fprintf(stderr, "%s: getcwd: %s.\n",
+ progname, strerror(errno));
exit(2);
}
@@ -1336,7 +1344,7 @@ ReadMakefile(const void *p, const void *q __unused)
char *name, *path = bmake_malloc(len);
if (!strcmp(fname, "-")) {
- Parse_File("(stdin)", dup(fileno(stdin)));
+ Parse_File(NULL /*stdin*/, -1);
Var_Set("MAKEFILE", "", VAR_GLOBAL, 0);
} else {
/* if we've chdir'd, rebuild the path name */
@@ -2013,20 +2021,10 @@ Main_ExportMAKEFLAGS(Boolean first)
}
}
-/*
- * Create and open a temp file using "pattern".
- * If "fnamep" is provided set it to a copy of the filename created.
- * Otherwise unlink the file once open.
- */
-int
-mkTempFile(const char *pattern, char **fnamep)
+char *
+getTmpdir(void)
{
static char *tmpdir = NULL;
- char tfile[MAXPATHLEN];
- int fd;
-
- if (!pattern)
- pattern = TMPPAT;
if (!tmpdir) {
struct stat st;
@@ -2041,6 +2039,25 @@ mkTempFile(const char *pattern, char **fnamep)
tmpdir = bmake_strdup(_PATH_TMP);
}
}
+ return tmpdir;
+}
+
+/*
+ * Create and open a temp file using "pattern".
+ * If "fnamep" is provided set it to a copy of the filename created.
+ * Otherwise unlink the file once open.
+ */
+int
+mkTempFile(const char *pattern, char **fnamep)
+{
+ static char *tmpdir = NULL;
+ char tfile[MAXPATHLEN];
+ int fd;
+
+ if (!pattern)
+ pattern = TMPPAT;
+ if (!tmpdir)
+ tmpdir = getTmpdir();
if (pattern[0] == '/') {
snprintf(tfile, sizeof(tfile), "%s", pattern);
} else {
diff --git a/devel/bmake/files/make-bootstrap.sh.in b/devel/bmake/files/make-bootstrap.sh.in
index 9e63185ee6a..d9ed15490fa 100644
--- a/devel/bmake/files/make-bootstrap.sh.in
+++ b/devel/bmake/files/make-bootstrap.sh.in
@@ -6,13 +6,19 @@ srcdir=@srcdir@
DEFAULT_SYS_PATH="@default_sys_path@"
+case "@use_meta@" in
+yes) XDEFS="-DUSE_META ${XDEFS}";;
+esac
+
CC="@CC@"
-CFLAGS="@CFLAGS@ -I. -I${srcdir} @DEFS@ @CPPFLAGS@ -DMAKE_NATIVE ${XDEFS} \
- -D_PATH_DEFSYSPATH=\"${DEFAULT_SYS_PATH}\""
+CFLAGS="@CFLAGS@ -I. -I${srcdir} @DEFS@ @CPPFLAGS@ -DMAKE_NATIVE ${XDEFS}"
MAKE_VERSION=`sed -n '/^MAKE_VERSION=/s,.*=[^0-9]*,,p' Makefile`
-MDEFS="-D@force_machine@MACHINE=\"@machine@\" -DMACHINE_ARCH=\"@machine_arch@\" -DMAKE_VERSION=\"$MAKE_VERSION\""
+MDEFS="-DMAKE_VERSION=\"$MAKE_VERSION\" \
+-D@force_machine@MACHINE=\"@machine@\" -DMACHINE_ARCH=\"@machine_arch@\" \
+-D_PATH_DEFSYSPATH=\"${DEFAULT_SYS_PATH}\""
+
LDFLAGS="@LDFLAGS@"
LIBS="@LIBS@"
@@ -35,7 +41,7 @@ do_compile() {
do_compile2 "$obj" "$d/$src" "$@" || exit 1
return
done
- echo "Unknown object file '$1'" >&2
+ echo "Unknown object file '$obj'" >&2
exit 1
}
@@ -65,4 +71,14 @@ do
do_compile "$o"
done
+case "@use_meta@" in
+yes)
+ case "@filemon_h@" in
+ */filemon.h) FDEFS="-DHAVE_FILEMON_H -I`dirname @filemon_h@`";;
+ esac
+ do_compile meta.o ${FDEFS}
+ BASE_OBJECTS="meta.o ${BASE_OBJECTS}"
+ ;;
+esac
+
do_link bmake main.o ${BASE_OBJECTS} ${LST_OBJECTS} ${LIB_OBJECTS}
diff --git a/devel/bmake/files/make.c b/devel/bmake/files/make.c
index c851a1d69c7..0d891a0d241 100644
--- a/devel/bmake/files/make.c
+++ b/devel/bmake/files/make.c
@@ -1,4 +1,4 @@
-/* $NetBSD: make.c,v 1.4 2010/04/20 13:37:49 joerg Exp $ */
+/* $NetBSD: make.c,v 1.5 2011/06/18 22:39:46 bsiegert Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: make.c,v 1.4 2010/04/20 13:37:49 joerg Exp $";
+static char rcsid[] = "$NetBSD: make.c,v 1.5 2011/06/18 22:39:46 bsiegert 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.4 2010/04/20 13:37:49 joerg Exp $");
+__RCSID("$NetBSD: make.c,v 1.5 2011/06/18 22:39:46 bsiegert Exp $");
#endif
#endif /* not lint */
#endif
@@ -94,12 +94,12 @@ __RCSID("$NetBSD: make.c,v 1.4 2010/04/20 13:37:49 joerg Exp $");
*
* Make_Update Update all parents of a given child. Performs
* various bookkeeping chores like the updating
- * of the cmtime field of the parent, filling
+ * of the cmgn field of the parent, filling
* of the IMPSRC context variable, etc. It will
* place the parent on the toBeMade queue if it
* should be.
*
- * Make_TimeStamp Function to set the parent's cmtime field
+ * Make_TimeStamp Function to set the parent's cmgn field
* based on a child's modification time.
*
* Make_DoAllVar Set up the various local variables for a
@@ -154,7 +154,7 @@ make_abort(GNode *gn, int line)
/*-
*-----------------------------------------------------------------------
* Make_TimeStamp --
- * Set the cmtime field of a parent node based on the mtime stamp in its
+ * Set the cmgn field of a parent node based on the mtime stamp in its
* child. Called from MakeOODate via Lst_ForEach.
*
* Input:
@@ -165,15 +165,15 @@ make_abort(GNode *gn, int line)
* Always returns 0.
*
* Side Effects:
- * The cmtime of the parent node will be changed if the mtime
+ * The cmgn of the parent node will be changed if the mtime
* field of the child is greater than it.
*-----------------------------------------------------------------------
*/
int
Make_TimeStamp(GNode *pgn, GNode *cgn)
{
- if (cgn->mtime > pgn->cmtime) {
- pgn->cmtime = cgn->mtime;
+ if (pgn->cmgn == NULL || cgn->mtime > pgn->cmgn->mtime) {
+ pgn->cmgn = cgn;
}
return (0);
}
@@ -207,7 +207,7 @@ MakeTimeStamp(void *pgn, void *cgn)
* TRUE if the node is out of date. FALSE otherwise.
*
* Side Effects:
- * The mtime field of the node and the cmtime field of its parents
+ * The mtime field of the node and the cmgn field of its parents
* will/may be changed.
*-----------------------------------------------------------------------
*/
@@ -265,7 +265,7 @@ Make_OODate(GNode *gn)
* or non-existent.
*/
oodate = (gn->mtime == 0 || Arch_LibOODate(gn) ||
- (gn->cmtime == 0 && (gn->type & OP_DOUBLEDEP)));
+ (gn->cmgn == NULL && (gn->type & OP_DOUBLEDEP)));
} else if (gn->type & OP_JOIN) {
/*
* A target with the .JOIN attribute is only considered
@@ -293,21 +293,22 @@ Make_OODate(GNode *gn)
}
}
oodate = TRUE;
- } else if (gn->mtime < gn->cmtime ||
- (gn->cmtime == 0 &&
+ } else if ((gn->cmgn != NULL && gn->mtime < gn->cmgn->mtime) ||
+ (gn->cmgn == NULL &&
((gn->mtime == 0 && !(gn->type & OP_OPTIONAL))
|| gn->type & OP_DOUBLEDEP)))
{
/*
* A node whose modification time is less than that of its
- * youngest child or that has no children (cmtime == 0) and
+ * youngest child or that has no children (cmgn == NULL) and
* either doesn't exist (mtime == 0) and it isn't optional
* or was the object of a * :: operator is out-of-date.
* Why? Because that's the way Make does it.
*/
if (DEBUG(MAKE)) {
- if (gn->mtime < gn->cmtime) {
- fprintf(debug_file, "modified before source...");
+ if (gn->cmgn != NULL && gn->mtime < gn->cmgn->mtime) {
+ fprintf(debug_file, "modified before source %s...",
+ gn->cmgn->path);
} else if (gn->mtime == 0) {
fprintf(debug_file, "non-existent and no sources...");
} else {
@@ -330,6 +331,12 @@ Make_OODate(GNode *gn)
oodate = (gn->flags & FORCE) ? TRUE : FALSE;
}
+#ifdef USE_META
+ if (useMeta) {
+ oodate = meta_oodate(gn, oodate);
+ }
+#endif
+
/*
* If the target isn't out-of-date, the parents need to know its
* modification time. Note that targets that appear to be out-of-date
@@ -389,7 +396,7 @@ MakeAddChild(void *gnp, void *lp)
* Always returns 0
*
* Side Effects:
- * The path and mtime of the node and the cmtime of the parent are
+ * The path and mtime of the node and the cmgn of the parent are
* updated; the unmade children count of the parent is decremented.
*-----------------------------------------------------------------------
*/
@@ -657,12 +664,12 @@ Make_Recheck(GNode *gn)
* the toBeMade queue if this field becomes 0.
*
* If the child was made, the parent's flag CHILDMADE field will be
- * set true and its cmtime set to now.
+ * set true.
*
* If the child is not up-to-date and still does not exist,
* set the FORCE flag on the parents.
*
- * If the child wasn't made, the cmtime field of the parent will be
+ * If the child wasn't made, the cmgn field of the parent will be
* altered if the child's mtime is big enough.
*
* Finally, if the child is the implied source for the parent, the
diff --git a/devel/bmake/files/make.h b/devel/bmake/files/make.h
index f2878037a9a..aede918a4d8 100644
--- a/devel/bmake/files/make.h
+++ b/devel/bmake/files/make.h
@@ -1,4 +1,4 @@
-/* $NetBSD: make.h,v 1.5 2010/04/24 21:10:29 joerg Exp $ */
+/* $NetBSD: make.h,v 1.6 2011/06/18 22:39:46 bsiegert Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -203,8 +203,7 @@ typedef struct GNode {
int unmade; /* The number of unmade children */
time_t mtime; /* Its modification time */
- time_t cmtime; /* The modification time of its youngest
- * child */
+ struct GNode *cmgn; /* The youngest child */
Lst iParents; /* Links to parents for which this is an
* implied source, if any */
@@ -276,6 +275,9 @@ typedef struct GNode {
#define OP_PHONY 0x00010000 /* Not a file target; run always */
#define OP_NOPATH 0x00020000 /* Don't search for file in the path */
#define OP_WAIT 0x00040000 /* .WAIT phony node */
+#define OP_NOMETA 0x00080000 /* .NOMETA do not create a .meta file */
+#define OP_META 0x00100000 /* .META we _do_ want a .meta file */
+#define OP_NOMETA_CMP 0x00200000 /* Do not compare commands in .meta file */
/* Attributes applied by PMake */
#define OP_TRANSFORM 0x80000000 /* The node is a transformation rule */
#define OP_MEMBER 0x40000000 /* Target is a member of an archive */
@@ -408,6 +410,7 @@ extern Boolean oldVars; /* Do old-style variable substitution */
extern Lst sysIncPath; /* The system include path. */
extern Lst defIncPath; /* The default include path. */
+extern char curdir[]; /* Startup directory */
extern char *progname; /* The program name */
extern char *makeDependfile; /* .depend */
@@ -449,6 +452,8 @@ extern int debug;
#define DEBUG_SHELL 0x00800
#define DEBUG_ERROR 0x01000
#define DEBUG_LOUD 0x02000
+#define DEBUG_META 0x04000
+
#define DEBUG_GRAPH3 0x10000
#define DEBUG_SCRIPT 0x20000
#define DEBUG_PARSE 0x40000
@@ -474,6 +479,7 @@ void PrintOnError(GNode *, const char *);
void Main_ExportMAKEFLAGS(Boolean);
Boolean Main_SetObjdir(const char *);
int mkTempFile(const char *, char **);
+int str2Lst_Append(Lst, char *, const char *);
#ifdef __GNUC__
#define UNCONST(ptr) ({ \
diff --git a/devel/bmake/files/nonints.h b/devel/bmake/files/nonints.h
index 2d4a7bd2a80..d34c6a22707 100644
--- a/devel/bmake/files/nonints.h
+++ b/devel/bmake/files/nonints.h
@@ -1,4 +1,4 @@
-/* $NetBSD: nonints.h,v 1.6 2010/09/07 14:28:00 joerg Exp $ */
+/* $NetBSD: nonints.h,v 1.7 2011/06/18 22:39:46 bsiegert Exp $ */
/*-
* Copyright (c) 1988, 1989, 1990, 1993
@@ -126,6 +126,7 @@ int PrintAddr(void *, void *);
void Finish(int);
int eunlink(const char *);
void execError(const char *, const char *);
+char *getTmpdir(void);
/* parse.c */
void Parse_Error(int, const char *, ...)
@@ -137,7 +138,7 @@ void Parse_AddIncludeDir(char *);
void Parse_File(const char *, int);
void Parse_Init(void);
void Parse_End(void);
-void Parse_SetInput(const char *, int, int, char *(*)(void *), void *);
+void Parse_SetInput(const char *, int, int, char *(*)(void *, size_t *), void *);
Lst Parse_MainName(void);
/* str.c */
diff --git a/devel/bmake/files/parse.c b/devel/bmake/files/parse.c
index d20ad586392..6fcbf9fe7d9 100644
--- a/devel/bmake/files/parse.c
+++ b/devel/bmake/files/parse.c
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.8 2010/09/07 14:28:00 joerg Exp $ */
+/* $NetBSD: parse.c,v 1.9 2011/06/18 22:39:46 bsiegert Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: parse.c,v 1.8 2010/09/07 14:28:00 joerg Exp $";
+static char rcsid[] = "$NetBSD: parse.c,v 1.9 2011/06/18 22:39:46 bsiegert 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.8 2010/09/07 14:28:00 joerg Exp $");
+__RCSID("$NetBSD: parse.c,v 1.9 2011/06/18 22:39:46 bsiegert Exp $");
#endif
#endif /* not lint */
#endif
@@ -123,12 +123,22 @@ __RCSID("$NetBSD: parse.c,v 1.8 2010/09/07 14:28:00 joerg Exp $");
* Parse_MainName Returns a Lst of the main target to create.
*/
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <stdarg.h>
#include <stdio.h>
+#ifndef MAP_FILE
+#define MAP_FILE 0
+#endif
+#ifndef MAP_COPY
+#define MAP_COPY MAP_PRIVATE
+#endif
+
#include "make.h"
#include "hash.h"
#include "dir.h"
@@ -136,56 +146,47 @@ __RCSID("$NetBSD: parse.c,v 1.8 2010/09/07 14:28:00 joerg Exp $");
#include "buf.h"
#include "pathnames.h"
-/*
- * These values are returned by ParseEOF to tell Parse_File whether to
- * CONTINUE parsing, i.e. it had only reached the end of an include file,
- * or if it's DONE.
- */
-#define CONTINUE 1
-#define DONE 0
-static Lst targets; /* targets we're working on */
-#ifdef CLEANUP
-static Lst targCmds; /* command lines for targets */
+#ifdef HAVE_MMAP
+#include <sys/mman.h>
+
+#ifndef MAP_COPY
+#define MAP_COPY MAP_PRIVATE
#endif
-static Boolean inLine; /* true if currently in a dependency
- * line or its commands */
-static int fatals = 0;
+#ifndef MAP_FILE
+#define MAP_FILE 0
+#endif
+#endif
+
+////////////////////////////////////////////////////////////
+// types and constants
-static GNode *mainNode; /* The main target to create. This is the
- * first target on the first dependency
- * line in the first makefile */
+/*
+ * Structure for a file being read ("included file")
+ */
typedef struct IFile {
const char *fname; /* name of file */
int lineno; /* current line number in file */
int first_lineno; /* line number of start of text */
- int fd; /* the open file */
int cond_depth; /* 'if' nesting when file opened */
char *P_str; /* point to base of string buffer */
char *P_ptr; /* point to next char of string buffer */
char *P_end; /* point to the end of string buffer */
- int P_buflen; /* current size of file buffer */
- char *(*nextbuf)(void *); /* Function to get more data */
+ char *(*nextbuf)(void *, size_t *); /* Function to get more data */
void *nextbuf_arg; /* Opaque arg for nextbuf() */
+ struct loadedfile *lf; /* loadedfile object, if any */
} IFile;
-#define IFILE_BUFLEN 0x8000
-static IFile *curFile;
-
/*
- * Definitions for handling #include specifications
+ * These values are returned by ParseEOF to tell Parse_File whether to
+ * CONTINUE parsing, i.e. it had only reached the end of an include file,
+ * or if it's DONE.
*/
+#define CONTINUE 1
+#define DONE 0
-static Lst includes; /* stack of IFiles generated by .includes */
-Lst parseIncPath; /* list of directories for "..." includes */
-Lst sysIncPath; /* list of directories for <...> includes */
-Lst defIncPath; /* default directories for <...> includes */
-
-/*-
- * specType contains the SPECial TYPE of the current target. It is
- * Not if the target is unspecial. If it *is* special, however, the children
- * are linked as children of the parent but not vice versa. This variable is
- * set in ParseDoDependency
+/*
+ * Tokens for target attributes
*/
typedef enum {
Begin, /* .BEGIN */
@@ -196,10 +197,13 @@ typedef enum {
Includes, /* .INCLUDES */
Interrupt, /* .INTERRUPT */
Libs, /* .LIBS */
+ Meta, /* .META */
MFlags, /* .MFLAGS or .MAKEFLAGS */
Main, /* .MAIN and we don't have anything user-specified to
* make */
NoExport, /* .NOEXPORT */
+ NoMeta, /* .NOMETA */
+ NoMetaCmp, /* .NOMETA_CMP */
NoPath, /* .NOPATH */
Not, /* Not special */
NotParallel, /* .NOTPARALLEL */
@@ -221,16 +225,74 @@ typedef enum {
Attribute /* Generic attribute */
} ParseSpecial;
+/*
+ * Other tokens
+ */
+#define LPAREN '('
+#define RPAREN ')'
+
+
+////////////////////////////////////////////////////////////
+// result data
+
+/*
+ * The main target to create. This is the first target on the first
+ * dependency line in the first makefile.
+ */
+static GNode *mainNode;
+
+////////////////////////////////////////////////////////////
+// eval state
+
+/* targets we're working on */
+static Lst targets;
+
+#ifdef CLEANUP
+/* command lines for targets */
+static Lst targCmds;
+#endif
+
+/*
+ * specType contains the SPECial TYPE of the current target. It is
+ * Not if the target is unspecial. If it *is* special, however, the children
+ * are linked as children of the parent but not vice versa. This variable is
+ * set in ParseDoDependency
+ */
static ParseSpecial specType;
-#define LPAREN '('
-#define RPAREN ')'
/*
* Predecessor node for handling .ORDER. Initialized to NULL when .ORDER
* seen, then set to each successive source on the line.
*/
static GNode *predecessor;
+////////////////////////////////////////////////////////////
+// parser state
+
+/* true if currently in a dependency line or its commands */
+static Boolean inLine;
+
+/* number of fatal errors */
+static int fatals = 0;
+
+/*
+ * Variables for doing includes
+ */
+
+/* current file being read */
+static IFile *curFile;
+
+/* stack of IFiles generated by .includes */
+static Lst includes;
+
+/* include paths (lists of directories) */
+Lst parseIncPath; /* dirs for "..." includes */
+Lst sysIncPath; /* dirs for <...> includes */
+Lst defIncPath; /* default for sysIncPath */
+
+////////////////////////////////////////////////////////////
+// parser tables
+
/*
* The parseKeywords table is searched using binary search when deciding
* if a target or source is special. The 'spec' field is the ParseSpecial
@@ -238,7 +300,7 @@ static GNode *predecessor;
* the 'op' field is the operator to apply to the list of targets if the
* keyword is used as a source ("0" if the keyword isn't special as a source)
*/
-static struct {
+static const struct {
const char *name; /* Name of keyword */
ParseSpecial spec; /* Type when used as a target */
int op; /* Operator when used as a source */
@@ -258,7 +320,10 @@ static struct {
{ ".MAIN", Main, 0 },
{ ".MAKE", Attribute, OP_MAKE },
{ ".MAKEFLAGS", MFlags, 0 },
+{ ".META", Meta, OP_META },
{ ".MFLAGS", MFlags, 0 },
+{ ".NOMETA", NoMeta, OP_NOMETA },
+{ ".NOMETA_CMP", NoMetaCmp, OP_NOMETA_CMP },
{ ".NOPATH", NoPath, OP_NOPATH },
{ ".NOTMAIN", Attribute, OP_NOTMAIN },
{ ".NOTPARALLEL", NotParallel, 0 },
@@ -284,6 +349,9 @@ static struct {
{ ".WAIT", Wait, 0 },
};
+////////////////////////////////////////////////////////////
+// local functions
+
static int ParseIsEscaped(const char *, const char *);
static void ParseErrorInternal(const char *, size_t, int, const char *, ...)
__attribute__((__format__(__printf__, 4, 5)));
@@ -309,8 +377,216 @@ static char *ParseReadLine(void);
static void ParseFinishLine(void);
static void ParseMark(GNode *);
-extern int maxJobs;
+////////////////////////////////////////////////////////////
+// file loader
+struct loadedfile {
+ const char *path; /* name, for error reports */
+ char *buf; /* contents buffer */
+ size_t len; /* length of contents */
+ size_t maplen; /* length of mmap area, or 0 */
+ Boolean used; /* XXX: have we used the data yet */
+};
+
+/*
+ * Constructor/destructor for loadedfile
+ */
+static struct loadedfile *
+loadedfile_create(const char *path)
+{
+ struct loadedfile *lf;
+
+ lf = bmake_malloc(sizeof(*lf));
+ lf->path = (path == NULL ? "(stdin)" : path);
+ lf->buf = NULL;
+ lf->len = 0;
+ lf->maplen = 0;
+ lf->used = FALSE;
+ return lf;
+}
+
+static void
+loadedfile_destroy(struct loadedfile *lf)
+{
+ if (lf->buf != NULL) {
+ if (lf->maplen > 0) {
+#ifdef HAVE_MMAP
+ munmap(lf->buf, lf->maplen);
+#endif
+ } else {
+ free(lf->buf);
+ }
+ }
+ free(lf);
+}
+
+/*
+ * nextbuf() operation for loadedfile, as needed by the weird and twisted
+ * logic below. Once that's cleaned up, we can get rid of lf->used...
+ */
+static char *
+loadedfile_nextbuf(void *x, size_t *len)
+{
+ struct loadedfile *lf = x;
+
+ if (lf->used) {
+ return NULL;
+ }
+ lf->used = TRUE;
+ *len = lf->len;
+ return lf->buf;
+}
+
+/*
+ * Try to get the size of a file.
+ */
+static ReturnStatus
+load_getsize(int fd, size_t *ret)
+{
+ struct stat st;
+
+ if (fstat(fd, &st) < 0) {
+ return FAILURE;
+ }
+
+ if (!S_ISREG(st.st_mode)) {
+ return FAILURE;
+ }
+
+ /*
+ * st_size is an off_t, which is 64 bits signed; *ret is
+ * size_t, which might be 32 bits unsigned or 64 bits
+ * unsigned. Rather than being elaborate, just punt on
+ * files that are more than 2^31 bytes. We should never
+ * see a makefile that size in practice...
+ *
+ * While we're at it reject negative sizes too, just in case.
+ */
+ if (st.st_size < 0 || st.st_size > 0x7fffffff) {
+ return FAILURE;
+ }
+
+ *ret = (size_t) st.st_size;
+ return SUCCESS;
+}
+
+/*
+ * Read in a file.
+ *
+ * Until the path search logic can be moved under here instead of
+ * being in the caller in another source file, we need to have the fd
+ * passed in already open. Bleh.
+ *
+ * If the path is NULL use stdin and (to insure against fd leaks)
+ * assert that the caller passed in -1.
+ */
+static struct loadedfile *
+loadfile(const char *path, int fd)
+{
+ struct loadedfile *lf;
+#ifdef HAVE_MMAP
+ long pagesize;
+#endif
+ ssize_t result;
+ size_t bufpos;
+
+ lf = loadedfile_create(path);
+
+ if (path == NULL) {
+ assert(fd == -1);
+ fd = STDIN_FILENO;
+ } else {
+#if 0 /* notyet */
+ fd = open(path, O_RDONLY);
+ if (fd < 0) {
+ ...
+ Error("%s: %s", path, strerror(errno));
+ exit(1);
+ }
+#endif
+ }
+
+#ifdef HAVE_MMAP
+ if (load_getsize(fd, &lf->len) == SUCCESS) {
+ /* found a size, try mmap */
+ pagesize = sysconf(_SC_PAGESIZE);
+ if (pagesize <= 0) {
+ pagesize = 0x1000;
+ }
+ /* round size up to a page */
+ lf->maplen = pagesize * ((lf->len + pagesize - 1)/pagesize);
+
+ /*
+ * XXX hack for dealing with empty files; remove when
+ * we're no longer limited by interfacing to the old
+ * logic elsewhere in this file.
+ */
+ if (lf->maplen == 0) {
+ lf->maplen = pagesize;
+ }
+
+ /*
+ * FUTURE: remove PROT_WRITE when the parser no longer
+ * needs to scribble on the input.
+ */
+ lf->buf = mmap(NULL, lf->maplen, PROT_READ|PROT_WRITE,
+ MAP_FILE|MAP_COPY, fd, 0);
+ if (lf->buf != MAP_FAILED) {
+ /* succeeded */
+ if (lf->len == lf->maplen && lf->buf[lf->len - 1] != '\n') {
+ char *b = malloc(lf->len + 1);
+ b[lf->len] = '\n';
+ memcpy(b, lf->buf, lf->len++);
+ munmap(lf->buf, lf->maplen);
+ lf->maplen = 0;
+ lf->buf = b;
+ }
+ goto done;
+ }
+ }
+#endif
+ /* cannot mmap; load the traditional way */
+
+ lf->maplen = 0;
+ lf->len = 1024;
+ lf->buf = bmake_malloc(lf->len);
+
+ bufpos = 0;
+ while (1) {
+ assert(bufpos <= lf->len);
+ if (bufpos == lf->len) {
+ lf->len *= 2;
+ lf->buf = bmake_realloc(lf->buf, lf->len);
+ }
+ result = read(fd, lf->buf + bufpos, lf->len - bufpos);
+ if (result < 0) {
+ Error("%s: read error: %s", path, strerror(errno));
+ exit(1);
+ }
+ if (result == 0) {
+ break;
+ }
+ bufpos += result;
+ }
+ assert(bufpos <= lf->len);
+ lf->len = bufpos;
+
+ /* truncate malloc region to actual length (maybe not useful) */
+ if (lf->len > 0) {
+ lf->buf = bmake_realloc(lf->buf, lf->len);
+ }
+
+#ifdef HAVE_MMAP
+done:
+#endif
+ if (path != NULL) {
+ close(fd);
+ }
+ return lf;
+}
+
+////////////////////////////////////////////////////////////
+// old code
/*-
*----------------------------------------------------------------------
@@ -404,7 +680,7 @@ ParseVErrorInternal(FILE *f, const char *cfname, size_t clineno, int type,
const char *dir;
/*
- * Nothing is more anoying than not knowing
+ * Nothing is more annoying than not knowing
* which Makefile is the culprit.
*/
dir = Var_Value(".PARSEDIR", VAR_GLOBAL, &cp);
@@ -1786,6 +2062,7 @@ Parse_AddIncludeDir(char *dir)
static void
Parse_include_file(char *file, Boolean isSystem, int silent)
{
+ struct loadedfile *lf;
char *fullname; /* full pathname of file */
char *newName;
char *prefEnd, *incdir;
@@ -1876,8 +2153,12 @@ Parse_include_file(char *file, Boolean isSystem, int silent)
return;
}
+ /* load it */
+ lf = loadfile(fullname, fd);
+
/* Start reading from this file next */
- Parse_SetInput(fullname, 0, fd, NULL, NULL);
+ Parse_SetInput(fullname, 0, -1, loadedfile_nextbuf, lf);
+ curFile->lf = lf;
}
static void
@@ -1955,7 +2236,7 @@ ParseSetParseFile(const char *filename)
slash = strrchr(filename, '/');
if (slash == NULL) {
- Var_Set(".PARSEDIR", ".", VAR_GLOBAL, 0);
+ Var_Set(".PARSEDIR", curdir, VAR_GLOBAL, 0);
Var_Set(".PARSEFILE", filename, VAR_GLOBAL, 0);
} else {
len = slash - filename;
@@ -2014,9 +2295,11 @@ ParseTrackInput(const char *name)
*---------------------------------------------------------------------
*/
void
-Parse_SetInput(const char *name, int line, int fd, char *(*nextbuf)(void *), void *arg)
+Parse_SetInput(const char *name, int line, int fd,
+ char *(*nextbuf)(void *, size_t *), void *arg)
{
char *buf;
+ size_t len;
if (name == NULL)
name = curFile->fname;
@@ -2047,33 +2330,22 @@ Parse_SetInput(const char *name, int line, int fd, char *(*nextbuf)(void *), voi
curFile->fname = name;
curFile->lineno = line;
curFile->first_lineno = line;
- curFile->fd = fd;
curFile->nextbuf = nextbuf;
curFile->nextbuf_arg = arg;
+ curFile->lf = NULL;
- if (nextbuf == NULL) {
- /*
- * Allocate a 32k data buffer (as stdio seems to).
- * Set pointers so that first ParseReadc has to do a file read.
- */
- buf = bmake_malloc(IFILE_BUFLEN);
- buf[0] = 0;
- curFile->P_str = buf;
- curFile->P_ptr = buf;
- curFile->P_end = buf;
- curFile->P_buflen = IFILE_BUFLEN;
- } else {
- /* Get first block of input data */
- buf = curFile->nextbuf(curFile->nextbuf_arg);
- if (buf == NULL) {
- /* Was all a waste of time ... */
- free(curFile);
- return;
- }
- curFile->P_str = buf;
- curFile->P_ptr = buf;
- curFile->P_end = NULL;
+ assert(nextbuf != NULL);
+
+ /* Get first block of input data */
+ buf = curFile->nextbuf(curFile->nextbuf_arg, &len);
+ if (buf == NULL) {
+ /* Was all a waste of time ... */
+ free(curFile);
+ return;
}
+ curFile->P_str = buf;
+ curFile->P_ptr = buf;
+ curFile->P_end = buf+len;
curFile->cond_depth = Cond_save_depth();
ParseSetParseFile(name);
@@ -2162,26 +2434,31 @@ static int
ParseEOF(void)
{
char *ptr;
-
- if (curFile->nextbuf != NULL) {
- /* eg .for loop data, get next iteration */
- ptr = curFile->nextbuf(curFile->nextbuf_arg);
- curFile->P_ptr = ptr;
- curFile->P_str = ptr;
- curFile->lineno = curFile->first_lineno;
- if (ptr != NULL) {
- /* Iterate again */
- return CONTINUE;
- }
+ size_t len;
+
+ assert(curFile->nextbuf != NULL);
+
+ /* get next input buffer, if any */
+ ptr = curFile->nextbuf(curFile->nextbuf_arg, &len);
+ curFile->P_ptr = ptr;
+ curFile->P_str = ptr;
+ curFile->P_end = ptr + len;
+ curFile->lineno = curFile->first_lineno;
+ if (ptr != NULL) {
+ /* Iterate again */
+ return CONTINUE;
}
/* Ensure the makefile (or loop) didn't have mismatched conditionals */
Cond_restore_depth(curFile->cond_depth);
+ if (curFile->lf != NULL) {
+ loadedfile_destroy(curFile->lf);
+ curFile->lf = NULL;
+ }
+
/* Dispose of curFile info */
/* Leak curFile->fname because all the gnodes have pointers to it */
- if (curFile->fd != -1)
- close(curFile->fd);
free(curFile->P_str);
free(curFile);
@@ -2195,8 +2472,8 @@ ParseEOF(void)
}
if (DEBUG(PARSE))
- fprintf(debug_file, "ParseEOF: returning to file %s, line %d, fd %d\n",
- curFile->fname, curFile->lineno, curFile->fd);
+ fprintf(debug_file, "ParseEOF: returning to file %s, line %d\n",
+ curFile->fname, curFile->lineno);
/* Restore the PARSEDIR/PARSEFILE variables */
ParseSetParseFile(curFile->fname);
@@ -2217,7 +2494,6 @@ ParseGetLine(int flags, int *length)
char *escaped;
char *comment;
char *tp;
- int len, dist;
/* Loop through blank lines and comment lines */
for (;;) {
@@ -2228,67 +2504,25 @@ ParseGetLine(int flags, int *length)
escaped = NULL;
comment = NULL;
for (;;) {
+ if (cf->P_end != NULL && ptr == cf->P_end) {
+ /* end of buffer */
+ ch = 0;
+ break;
+ }
ch = *ptr;
if (ch == 0 || (ch == '\\' && ptr[1] == 0)) {
if (cf->P_end == NULL)
/* End of string (aka for loop) data */
break;
- /* End of data read from file, read more data */
- if (ptr != cf->P_end && (ch != '\\' || ptr + 1 != cf->P_end)) {
- Parse_Error(PARSE_FATAL, "Zero byte read from file");
- return NULL;
- }
- /* Move existing data to (near) start of file buffer */
- len = cf->P_end - cf->P_ptr;
- tp = cf->P_str + 32;
- memmove(tp, cf->P_ptr, len);
- dist = cf->P_ptr - tp;
- /* Update all pointers to reflect moved data */
- ptr -= dist;
- line -= dist;
- line_end -= dist;
- if (escaped)
- escaped -= dist;
- if (comment)
- comment -= dist;
- cf->P_ptr = tp;
- tp += len;
- cf->P_end = tp;
- /* Try to read more data from file into buffer space */
- len = cf->P_str + cf->P_buflen - tp - 32;
- if (len <= 0) {
- /* We need a bigger buffer to hold this line */
- tp = bmake_realloc(cf->P_str, cf->P_buflen + IFILE_BUFLEN);
- cf->P_ptr = cf->P_ptr - cf->P_str + tp;
- cf->P_end = cf->P_end - cf->P_str + tp;
- ptr = ptr - cf->P_str + tp;
- line = line - cf->P_str + tp;
- line_end = line_end - cf->P_str + tp;
- if (escaped)
- escaped = escaped - cf->P_str + tp;
- if (comment)
- comment = comment - cf->P_str + tp;
- cf->P_str = tp;
- tp = cf->P_end;
- len += IFILE_BUFLEN;
- cf->P_buflen += IFILE_BUFLEN;
- }
- len = read(cf->fd, tp, len);
- if (len <= 0) {
- if (len < 0) {
- Parse_Error(PARSE_FATAL, "Makefile read error: %s",
- strerror(errno));
- return NULL;
- }
- /* End of file */
+ if (cf->nextbuf != NULL) {
+ /*
+ * End of this buffer; return EOF and outer logic
+ * will get the next one. (eww)
+ */
break;
}
- /* 0 terminate the data, and update end pointer */
- tp += len;
- cf->P_end = tp;
- *tp = 0;
- /* Process newly read characters */
- continue;
+ Parse_Error(PARSE_FATAL, "Zero byte read from file");
+ return NULL;
}
if (ch == '\\') {
@@ -2459,7 +2693,7 @@ ParseReadLine(void)
line = ParseGetLine(PARSE_RAW, &lineLength);
if (line == NULL) {
Parse_Error(PARSE_FATAL,
- "Unexpected end of file in for loop.\n");
+ "Unexpected end of file in for loop.");
break;
}
} while (For_Accum(line));
@@ -2522,11 +2756,19 @@ Parse_File(const char *name, int fd)
{
char *cp; /* pointer into the line */
char *line; /* the line we're working on */
+ struct loadedfile *lf;
+
+ lf = loadfile(name, fd);
inLine = FALSE;
fatals = 0;
- Parse_SetInput(name, 0, fd, NULL, NULL);
+ if (name == NULL) {
+ name = "(stdin)";
+ }
+
+ Parse_SetInput(name, 0, -1, loadedfile_nextbuf, lf);
+ curFile->lf = lf;
do {
for (; (line = ParseReadLine()) != NULL; ) {
@@ -2719,7 +2961,7 @@ Parse_File(const char *name, int fd)
if (fatals) {
(void)fflush(stdout);
(void)fprintf(stderr,
- "%s: Fatal errors encountered -- cannot continue\n",
+ "%s: Fatal errors encountered -- cannot continue",
progname);
PrintOnError(NULL, NULL);
exit(1);
diff --git a/devel/bmake/files/sigcompat.c b/devel/bmake/files/sigcompat.c
index 13be76ddc47..837b9c401cc 100644
--- a/devel/bmake/files/sigcompat.c
+++ b/devel/bmake/files/sigcompat.c
@@ -104,7 +104,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
/*static char *sccsid = "from: @(#)sigcompat.c 5.3 (Berkeley) 2/24/91";*/
-static char *rcsid = "$Id: sigcompat.c,v 1.4 2009/09/18 21:27:25 joerg Exp $";
+static char *rcsid = "$Id: sigcompat.c,v 1.5 2011/06/18 22:39:46 bsiegert Exp $";
#endif /* LIBC_SCCS and not lint */
#undef signal
@@ -163,9 +163,7 @@ static char *rcsid = "$Id: sigcompat.c,v 1.4 2009/09/18 21:27:25 joerg Exp $";
#endif
int _signalFlags = SIGNAL_FLAGS;
-SIG_HDLR(*signal(sig, handler)) __P((int))
- int sig;
- SIG_HDLR(*handler) __P((int));
+SIG_HDLR(*signal(int sig, SIG_HDLR(*handler)(int)))(int)
{
_DBUG(static int depth_signal = 0);
struct sigaction act, oact;
@@ -183,11 +181,9 @@ SIG_HDLR(*signal(sig, handler)) __P((int))
return (oact.sa_handler);
}
#else
-SIG_HDLR(*signal(sig, handler)) __P((int))
- int sig;
- SIG_HDLR(*handler) __P((int));
+SIG_HDLR(*signal(int sig, SIG_HDLR(*handler)(int)))(int)
{
- extern SIG_HDLR(*Signal __P((int, void (*) __P((int))))) __P((int));
+ extern SIG_HDLR(*Signal(int, void (*)(int)))(int);
_DBUG(static int depth_signal = 0);
SIG_HDLR(*old) __P((int));
@@ -210,8 +206,7 @@ SIG_HDLR(*signal(sig, handler)) __P((int))
# define m2ss(ss, m) *ss = (sigset_t) *(m)
#else
static MASK_T
-ss2m(ss)
- sigset_t *ss;
+ss2m(sigset_t *ss)
{
MASK_T ma[(sizeof(sigset_t) / sizeof(MASK_T)) + 1];
@@ -220,9 +215,7 @@ ss2m(ss)
}
static void
-m2ss(ss, m)
- sigset_t *ss;
- MASK_T *m;
+m2ss(sigset_t *ss, MASK_T *m)
{
if (sizeof(sigset_t) > sizeof(MASK_T))
memset((char *) ss, 0, sizeof(sigset_t));
@@ -233,8 +226,7 @@ m2ss(ss, m)
#if !defined(HAVE_SIGSETMASK) || defined(FORCE_POSIX_SIGNALS)
MASK_T
-sigsetmask(mask)
- MASK_T mask;
+sigsetmask(MASK_T mask)
{
_DBUG(static int depth_sigsetmask = 0);
sigset_t m, omask;
@@ -253,8 +245,7 @@ sigsetmask(mask)
MASK_T
-sigblock(mask)
- MASK_T mask;
+sigblock(MASK_T mask)
{
_DBUG(static int depth_sigblock = 0);
sigset_t m, omask;
@@ -274,8 +265,7 @@ sigblock(mask)
#undef sigpause /* Linux at least */
PAUSE_MASK_T
-sigpause(mask)
- PAUSE_MASK_T mask;
+sigpause(PAUSE_MASK_T mask)
{
_DBUG(static int depth_sigpause = 0);
sigset_t m;
@@ -292,9 +282,7 @@ sigpause(mask)
#if defined(HAVE_SIGVEC) && defined(FORCE_POSIX_SIGNALS)
int
-sigvec(signo, sv, osv)
- int signo;
- struct sigvec *sv, *osv;
+sigvec(int signo, struct sigvec *sv, struct sigvec *osv)
{
_DBUG(static int depth_sigvec = 0);
int ret;
@@ -321,9 +309,7 @@ sigvec(signo, sv, osv)
# endif
int
-main(argc, argv)
- int argc;
- char **argv;
+main(int argc, char *argv[])
{
MASK_T old = 0;
diff --git a/devel/bmake/files/targ.c b/devel/bmake/files/targ.c
index 1a264b069ec..d8973cd4e8d 100644
--- a/devel/bmake/files/targ.c
+++ b/devel/bmake/files/targ.c
@@ -1,4 +1,4 @@
-/* $NetBSD: targ.c,v 1.4 2009/09/18 21:27:25 joerg Exp $ */
+/* $NetBSD: targ.c,v 1.5 2011/06/18 22:39:46 bsiegert Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: targ.c,v 1.4 2009/09/18 21:27:25 joerg Exp $";
+static char rcsid[] = "$NetBSD: targ.c,v 1.5 2011/06/18 22:39:46 bsiegert 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.4 2009/09/18 21:27:25 joerg Exp $");
+__RCSID("$NetBSD: targ.c,v 1.5 2011/06/18 22:39:46 bsiegert Exp $");
#endif
#endif /* not lint */
#endif
@@ -248,8 +248,9 @@ Targ_NewGN(const char *name)
gn->centurion = NULL;
gn->made = UNMADE;
gn->flags = 0;
- gn->checked = 0;
- gn->mtime = gn->cmtime = 0;
+ gn->checked = 0;
+ gn->mtime = 0;
+ gn->cmgn = NULL;
gn->iParents = Lst_Init(FALSE);
gn->cohorts = Lst_Init(FALSE);
gn->parents = Lst_Init(FALSE);
diff --git a/devel/bmake/files/unit-tests/Makefile.in b/devel/bmake/files/unit-tests/Makefile.in
index 362289e0c0e..f6c58ee93c6 100644
--- a/devel/bmake/files/unit-tests/Makefile.in
+++ b/devel/bmake/files/unit-tests/Makefile.in
@@ -1,6 +1,6 @@
-# $Id: Makefile.in,v 1.7 2010/09/07 14:28:01 joerg Exp $
+# $Id: Makefile.in,v 1.8 2011/06/18 22:39:46 bsiegert Exp $
#
-# $NetBSD: Makefile.in,v 1.7 2010/09/07 14:28:01 joerg Exp $
+# $NetBSD: Makefile.in,v 1.8 2011/06/18 22:39:46 bsiegert Exp $
#
# Unit tests for make(1)
# The main targets are:
@@ -31,6 +31,8 @@ SUBFILES= \
doterror \
dotwait \
forsubst \
+ hash \
+ misc \
moderrs \
modmatch \
modmisc \
@@ -39,6 +41,7 @@ SUBFILES= \
modword \
posix \
qequals \
+ sysv \
ternary \
unexport \
unexport-env \
@@ -66,12 +69,9 @@ TOOL_DIFF?= diff
DIFF_FLAGS?= @diff_u@
# ensure consistent results from sort(1)
+LC_ALL= C
LANG= C
-.export LANG
-
-# ensure consistent results from sort(1)
-LANG= C
-.export LANG
+.export LANG LC_ALL
# The driver.
# We always pretend .MAKE was called 'make'
diff --git a/devel/bmake/files/unit-tests/cond1 b/devel/bmake/files/unit-tests/cond1
index 34b20100d30..f485ef5c259 100644
--- a/devel/bmake/files/unit-tests/cond1
+++ b/devel/bmake/files/unit-tests/cond1
@@ -1,4 +1,4 @@
-# $Id: cond1,v 1.3 2008/11/11 14:37:06 joerg Exp $
+# $Id: cond1,v 1.4 2011/06/18 22:39:46 bsiegert Exp $
# hard code these!
TEST_UNAME_S= NetBSD
@@ -95,6 +95,11 @@ C=clever
C=dim
.endif
+.if defined(nosuch) && ${nosuch:Mx} != ""
+# this should not happen
+.info nosuch is x
+.endif
+
all:
@echo "$n is $X prime"
@echo "A='$A' B='$B' C='$C' o='$o,${o2}'"
diff --git a/devel/bmake/files/unit-tests/test.exp b/devel/bmake/files/unit-tests/test.exp
index 347bb9f2409..cc49d4b454d 100644
--- a/devel/bmake/files/unit-tests/test.exp
+++ b/devel/bmake/files/unit-tests/test.exp
@@ -81,6 +81,14 @@ make: Graph cycles through `cycle.2.97'
cycle.1.99
cycle.1.99
.for with :S;... OK
+b2af338b
+3360ac65
+7747f046
+9ca87054
+880fe816
+208fcbd3
+d5d376eb
+de41416c
Expect: Unknown modifier 'Z'
make: Unknown modifier 'Z'
VAR:Z=
@@ -120,6 +128,7 @@ path='/bin':'/tmp':'/':'/no/such/dir'
path_/usr/xbin=/opt/xbin/
paths=/bin /tmp / /no/such/dir /opt/xbin
PATHS=/BIN /TMP / /NO/SUCH/DIR /OPT/XBIN
+The answer is 42
LIST = one two three four five six seven eight nine ten
LIST:O = eight five four nine one seven six ten three two
LIST:Ox = Ok
@@ -306,6 +315,12 @@ Now we expect an error...
*** Error code 1 (continuing)
`all' not remade because of errors.
V.i386 ?= OK
+FOOBAR =
+FOOBAR = foobar fubar
+fun
+fun
+fun
+In the Sun
The answer is unknown
The answer is unknown
The answer is empty
diff --git a/devel/bmake/files/util.c b/devel/bmake/files/util.c
index 4617a1118ab..6b298c6abc6 100644
--- a/devel/bmake/files/util.c
+++ b/devel/bmake/files/util.c
@@ -1,18 +1,18 @@
-/* $NetBSD: util.c,v 1.9 2010/12/21 22:57:44 seanb Exp $ */
+/* $NetBSD: util.c,v 1.10 2011/06/18 22:39:46 bsiegert Exp $ */
/*
* Missing stuff from OS's
*
- * $Id: util.c,v 1.9 2010/12/21 22:57:44 seanb Exp $
+ * $Id: util.c,v 1.10 2011/06/18 22:39:46 bsiegert Exp $
*/
#include "make.h"
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: util.c,v 1.9 2010/12/21 22:57:44 seanb Exp $";
+static char rcsid[] = "$NetBSD: util.c,v 1.10 2011/06/18 22:39:46 bsiegert Exp $";
#else
#ifndef lint
-__RCSID("$NetBSD: util.c,v 1.9 2010/12/21 22:57:44 seanb Exp $");
+__RCSID("$NetBSD: util.c,v 1.10 2011/06/18 22:39:46 bsiegert Exp $");
#endif
#endif
@@ -47,7 +47,7 @@ findenv(const char *name, int *offset)
char *p, *q;
for (i = 0; (q = environ[i]); i++) {
- char *p = strchr(q, '=');
+ p = strchr(q, '=');
if (p == NULL)
continue;
if (strncmp(name, q, len = p - q) == 0) {
@@ -529,3 +529,90 @@ killpg(int pid, int sig)
}
#endif
#endif
+
+#if !defined(HAVE_WARNX)
+static void
+vwarnx(const char *fmt, va_list args)
+{
+ fprintf(stderr, "%s: ", progname);
+ if ((fmt)) {
+ vfprintf(stderr, fmt, args);
+ fprintf(stderr, ": ");
+ }
+}
+#endif
+
+#if !defined(HAVE_WARN)
+static void
+vwarn(const char *fmt, va_list args)
+{
+ vwarnx(fmt, args);
+ fprintf(stderr, "%s\n", strerror(errno));
+}
+#endif
+
+#if !defined(HAVE_ERR)
+static void
+verr(int eval, const char *fmt, va_list args)
+{
+ vwarn(fmt, args);
+ exit(eval);
+}
+#endif
+
+#if !defined(HAVE_ERRX)
+static void
+verrx(int eval, const char *fmt, va_list args)
+{
+ vwarnx(fmt, args);
+ exit(eval);
+}
+#endif
+
+#if !defined(HAVE_ERR)
+void
+err(int eval, const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ verr(eval, fmt, ap);
+ va_end(ap);
+}
+#endif
+
+#if !defined(HAVE_ERRX)
+void
+errx(int eval, const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ verrx(eval, fmt, ap);
+ va_end(ap);
+}
+#endif
+
+#if !defined(HAVE_WARN)
+void
+warn(const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ vwarn(fmt, ap);
+ va_end(ap);
+}
+#endif
+
+#if !defined(HAVE_WARNX)
+void
+warnx(const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ vwarnx(fmt, ap);
+ va_end(ap);
+}
+#endif
diff --git a/devel/bmake/files/var.c b/devel/bmake/files/var.c
index 1a020c2c43c..4185877dfc2 100644
--- a/devel/bmake/files/var.c
+++ b/devel/bmake/files/var.c
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.8 2010/09/07 14:28:01 joerg Exp $ */
+/* $NetBSD: var.c,v 1.9 2011/06/18 22:39:46 bsiegert Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.8 2010/09/07 14:28:01 joerg Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.9 2011/06/18 22:39:46 bsiegert 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.8 2010/09/07 14:28:01 joerg Exp $");
+__RCSID("$NetBSD: var.c,v 1.9 2011/06/18 22:39:46 bsiegert Exp $");
#endif
#endif /* not lint */
#endif
@@ -129,8 +129,10 @@ __RCSID("$NetBSD: var.c,v 1.8 2010/09/07 14:28:01 joerg Exp $");
#include <regex.h>
#endif
#include <ctype.h>
+#include <inttypes.h>
#include <stdlib.h>
#include <limits.h>
+#include <time.h>
#include "make.h"
#include "buf.h"
@@ -302,6 +304,7 @@ static char *VarGetPattern(GNode *, Var_Parse_State *,
VarPattern *);
static char *VarQuote(char *);
static char *VarChangeCase(char *, int);
+static char *VarHash(char *);
static char *VarModify(GNode *, Var_Parse_State *,
const char *,
Boolean (*)(GNode *, Var_Parse_State *, char *, Boolean, Buffer *, void *),
@@ -379,6 +382,12 @@ VarFind(const char *name, GNode *ctxt, int flags)
name = TARGET;
break;
}
+#ifdef notyet
+ /* for compatibility with gmake */
+ if (name[0] == '^' && name[1] == '\0')
+ name = ALLSRC;
+#endif
+
/*
* First look for the variable in the given context. If it's not there,
* look for it in VAR_CMD, VAR_GLOBAL and the environment, in that order,
@@ -2256,6 +2265,79 @@ VarQuote(char *str)
/*-
*-----------------------------------------------------------------------
+ * VarHash --
+ * Hash the string using the MurmurHash3 algorithm.
+ * Output is computed using 32bit Little Endian arithmetic.
+ *
+ * Input:
+ * str String to modify
+ *
+ * Results:
+ * Hash value of str, encoded as 8 hex digits.
+ *
+ * Side Effects:
+ * None.
+ *
+ *-----------------------------------------------------------------------
+ */
+static char *
+VarHash(char *str)
+{
+ static const char hexdigits[16] = "0123456789abcdef";
+ Buffer buf;
+ size_t len, len2;
+ unsigned char *ustr = (unsigned char *)str;
+ uint32_t h, k, c1, c2;
+ int done;
+
+ done = 1;
+ h = 0x971e137bU;
+ c1 = 0x95543787U;
+ c2 = 0x2ad7eb25U;
+ len2 = strlen(str);
+
+ for (len = len2; len; ) {
+ k = 0;
+ switch (len) {
+ default:
+ k = (ustr[3] << 24) | (ustr[2] << 16) | (ustr[1] << 8) | ustr[0];
+ len -= 4;
+ ustr += 4;
+ break;
+ case 3:
+ k |= (ustr[2] << 16);
+ case 2:
+ k |= (ustr[1] << 8);
+ case 1:
+ k |= ustr[0];
+ len = 0;
+ }
+ c1 = c1 * 5 + 0x7b7d159cU;
+ c2 = c2 * 5 + 0x6bce6396U;
+ k *= c1;
+ k = (k << 11) ^ (k >> 21);
+ k *= c2;
+ h = (h << 13) ^ (h >> 19);
+ h = h * 5 + 0x52dce729U;
+ h ^= k;
+ } while (!done);
+ h ^= len2;
+ h *= 0x85ebca6b;
+ h ^= h >> 13;
+ h *= 0xc2b2ae35;
+ h ^= h >> 16;
+
+ Buf_Init(&buf, 0);
+ for (len = 0; len < 8; ++len) {
+ Buf_AddByte(&buf, hexdigits[h & 15]);
+ h >>= 4;
+ }
+
+ return Buf_Destroy(&buf, FALSE);
+}
+
+/*-
+ *-----------------------------------------------------------------------
* VarChangeCase --
* Change the string to all uppercase or all lowercase
*
@@ -2285,6 +2367,21 @@ VarChangeCase(char *str, int upper)
return Buf_Destroy(&buf, FALSE);
}
+static char *
+VarStrftime(const char *fmt, int zulu)
+{
+ char buf[BUFSIZ];
+ time_t utc;
+
+ time(&utc);
+ if (!*fmt)
+ fmt = "%c";
+ strftime(buf, sizeof(buf), fmt, zulu ? gmtime(&utc) : localtime(&utc));
+
+ buf[sizeof(buf) - 1] = '\0';
+ return bmake_strdup(buf);
+}
+
/*
* Now we need to apply any modifiers the user wants applied.
* These are:
@@ -2370,6 +2467,10 @@ VarChangeCase(char *str, int upper)
* variable.
*/
+/* we now have some modifiers with long names */
+#define STRMOD_MATCH(s, want, n) \
+ (strncmp(s, want, n) == 0 && (s[n] == endc || s[n] == ':'))
+
static char *
ApplyModifiers(char *nstr, const char *tstr,
int startc, int endc,
@@ -2397,14 +2498,28 @@ ApplyModifiers(char *nstr, const char *tstr,
if (*tstr == '$') {
/*
- * We have some complex modifiers in a variable.
+ * We may have some complex modifiers in a variable.
*/
void *freeIt;
char *rval;
int rlen;
+ int c;
rval = Var_Parse(tstr, ctxt, errnum, &rlen, &freeIt);
+ /*
+ * If we have not parsed up to endc or ':',
+ * we are not interested.
+ */
+ if (rval != NULL && *rval &&
+ (c = tstr[rlen]) != '\0' &&
+ c != ':' &&
+ c != endc) {
+ if (freeIt)
+ free(freeIt);
+ goto apply_mods;
+ }
+
if (DEBUG(VAR)) {
fprintf(debug_file, "Got '%s' from '%.*s'%.*s\n",
rval, rlen, tstr, rlen, tstr + rlen);
@@ -2436,6 +2551,7 @@ ApplyModifiers(char *nstr, const char *tstr,
}
continue;
}
+ apply_mods:
if (DEBUG(VAR)) {
fprintf(debug_file, "Applying :%c to \"%s\"\n", *tstr, nstr);
}
@@ -2486,7 +2602,7 @@ ApplyModifiers(char *nstr, const char *tstr,
cp = ++tstr;
break;
}
- delim = BRCLOSE;
+ delim = startc == PROPEN ? PRCLOSE : BRCLOSE;
pattern.flags = 0;
pattern.rhs = VarGetPattern(ctxt, &parsestate, errnum,
@@ -2815,6 +2931,36 @@ 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;
+ termc = *cp;
+ } else {
+ goto default_case;
+ }
+ break;
+ case 'h':
+ cp = tstr + 1; /* make sure it is set */
+ if (STRMOD_MATCH(tstr, "hash", 4)) {
+ newStr = VarHash(nstr);
+ cp = tstr + 4;
+ termc = *cp;
+ } else {
+ goto default_case;
+ }
+ break;
+ case 'l':
+ cp = tstr + 1; /* make sure it is set */
+ if (STRMOD_MATCH(tstr, "localtime", 9)) {
+ newStr = VarStrftime(nstr, 0);
+ cp = tstr + 9;
+ termc = *cp;
+ } else {
+ goto default_case;
+ }
+ break;
case 't':
{
cp = tstr + 1; /* make sure it is set */
@@ -3340,9 +3486,13 @@ ApplyModifiers(char *nstr, const char *tstr,
*/
termc = *--cp;
delim = '\0';
- newStr = VarModify(ctxt, &parsestate, nstr,
- VarSYSVMatch,
- &pattern);
+ if (pattern.leftLen == 0 && *nstr == '\0') {
+ newStr = nstr; /* special case */
+ } else {
+ newStr = VarModify(ctxt, &parsestate, nstr,
+ VarSYSVMatch,
+ &pattern);
+ }
free(UNCONST(pattern.lhs));
free(UNCONST(pattern.rhs));
} else
@@ -3740,7 +3890,7 @@ Var_Parse(const char *str, GNode *ctxt, Boolean errnum, int *lengthPtr,
nstr = bmake_strndup(start, *lengthPtr);
*freePtr = nstr;
} else {
- nstr = var_Error;
+ nstr = errnum ? var_Error : varNoError;
}
}
if (nstr != Buf_GetAll(&v->val, NULL))