summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoerg <joerg@pkgsrc.org>2010-04-24 20:33:51 +0000
committerjoerg <joerg@pkgsrc.org>2010-04-24 20:33:51 +0000
commit80199590869cf77565b0b4dea7357b2043cbcd15 (patch)
treef86a3ee04f84e05b9348275194c962790f9c8f02
parent75156626a2b9871f49248f4d7653cef0267f9214 (diff)
downloadpkgsrc-80199590869cf77565b0b4dea7357b2043cbcd15.tar.gz
Import bmake-20100423:
- Fixes for vfork(), bogus $TMPDIR, .export and realpath(3) - boot-strap fixes to allow -m .../mk, no default use of /usr/share/mk on !NetBSD, honor --with-default-sys-path - Other small improvements
-rw-r--r--devel/bmake/files/ChangeLog35
-rw-r--r--devel/bmake/files/Makefile.in8
-rw-r--r--devel/bmake/files/bmake.18
-rw-r--r--devel/bmake/files/bmake.cat14
-rwxr-xr-xdevel/bmake/files/boot-strap104
-rw-r--r--devel/bmake/files/compat.c8
-rw-r--r--devel/bmake/files/job.c30
-rw-r--r--devel/bmake/files/main.c60
-rw-r--r--devel/bmake/files/make.18
-rw-r--r--devel/bmake/files/make.h10
-rw-r--r--devel/bmake/files/realpath.c6
-rw-r--r--devel/bmake/files/unit-tests/Makefile.in18
-rw-r--r--devel/bmake/files/unit-tests/export-all14
-rw-r--r--devel/bmake/files/unit-tests/modmisc6
-rw-r--r--devel/bmake/files/unit-tests/test.exp16
-rw-r--r--devel/bmake/files/var.c17
16 files changed, 271 insertions, 81 deletions
diff --git a/devel/bmake/files/ChangeLog b/devel/bmake/files/ChangeLog
index f32afd9ade0..559a28514f6 100644
--- a/devel/bmake/files/ChangeLog
+++ b/devel/bmake/files/ChangeLog
@@ -1,3 +1,38 @@
+2010-04-23 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * Makefile.in (MAKE_VERSION): bump version to 20100423
+ Merge with NetBSD make, pick up
+ o updated unit tests for Haiku (this time for sure).
+ * boot-strap: based on patch from joerg
+ honor --with-default-sys-path better.
+ * boot-strap: remove mention of --with-prefix-sys-path
+
+2010-04-22 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * Makefile.in (MAKE_VERSION): bump version to 20100422
+ * Merge with NetBSD make, pick up
+ o fix for vfork() on Darwin.
+ o fix for bogus $TMPDIR.
+ o set .MAKE.MODE=compat for -B
+ o set .MAKE.JOBS=max_jobs for -j max_jobs
+ o allow unit-tests to run without any *.mk
+ o unit-tests/modmisc be more conservative in dirs presumed to exist.
+ * boot-strap: ignore /usr/share/mk except on NetBSD.
+ * unit-tests/Makefile.in: set LANG=C when running unit-tests to
+ ensure sort(1) behaves as expected.
+
+2010-04-21 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * boot-strap: add FindHereOrAbove so we can use -m .../mk
+
+2010-04-20 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * Makefile.in (MAKE_VERSION): bump version to 20100420
+ * Merge with NetBSD make, pick up
+ o fix for variable realpath() behavior.
+ we have to stat(2) the result to be sure.
+ o fix for .export (all) when nested vars use :sh
+
2010-04-14 Simon J. Gerraty <sjg@bad.crufty.net>
* Makefile.in (MAKE_VERSION): bump version to 20100414
diff --git a/devel/bmake/files/Makefile.in b/devel/bmake/files/Makefile.in
index 2d5b6ffed51..2046469c9d9 100644
--- a/devel/bmake/files/Makefile.in
+++ b/devel/bmake/files/Makefile.in
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile.in,v 1.1.1.6 2010/04/20 13:32:18 joerg Exp $
+# $NetBSD: Makefile.in,v 1.1.1.7 2010/04/24 20:33:52 joerg Exp $
# @(#)Makefile 5.2 (Berkeley) 12/28/90
-# $Id: Makefile.in,v 1.1.1.6 2010/04/20 13:32:18 joerg Exp $
+# $Id: Makefile.in,v 1.1.1.7 2010/04/24 20:33:52 joerg 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= 20100414
+MAKE_VERSION= 20100423
MACHINE=@machine@
MACHINE_ARCH=@machine_arch@
DEFAULT_SYS_PATH = @default_sys_path@
@@ -158,4 +158,4 @@ DPADD+=${LIBUTIL}
# A simple unit-test driver to help catch regressions
accept test:
- cd ${.CURDIR}/unit-tests && ${.MAKE:S,^./,${.CURDIR}/,} TEST_MAKE=${TEST_MAKE:U${.OBJDIR}/${PROG:T}} ${.TARGET}
+ cd ${.CURDIR}/unit-tests && ${.MAKE} -r -m / TEST_MAKE=${TEST_MAKE:U${.OBJDIR}/${PROG:T}} ${.TARGET}
diff --git a/devel/bmake/files/bmake.1 b/devel/bmake/files/bmake.1
index f136fb2bfc3..3bfd6c974fd 100644
--- a/devel/bmake/files/bmake.1
+++ b/devel/bmake/files/bmake.1
@@ -1,4 +1,4 @@
-.\" $NetBSD: bmake.1,v 1.1.1.1 2010/04/20 13:32:30 joerg Exp $
+.\" $NetBSD: bmake.1,v 1.1.1.2 2010/04/24 20:33:58 joerg 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 April 14, 2010
+.Dd April 21, 2010
.Dt MAKE 1
.Os
.Sh NAME
@@ -659,6 +659,10 @@ from which generated dependencies are read.
.It Va .MAKE.EXPORTED
The list of variables exported by
.Nm .
+.It Va .MAKE.JOBS
+The argument to the
+.Fl j
+option.
.It Va .MAKE.JOB.PREFIX
If
.Nm
diff --git a/devel/bmake/files/bmake.cat1 b/devel/bmake/files/bmake.cat1
index e88631d37c2..4e7f1093254 100644
--- a/devel/bmake/files/bmake.cat1
+++ b/devel/bmake/files/bmake.cat1
@@ -401,6 +401,8 @@ VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNTTSS
_._M_A_K_E_._E_X_P_O_R_T_E_D The list of variables exported by bbmmaakkee.
+ _._M_A_K_E_._J_O_B_S The argument to the --jj option.
+
_._M_A_K_E_._J_O_B_._P_R_E_F_I_X
If bbmmaakkee is run with _j then output for each target is
prefixed with a token `--- target ---' the first part of
@@ -1164,4 +1166,4 @@ HHIISSTTOORRYY
bbmmaakkee is derived from NetBSD's make(1). It uses autoconf to facilitate
portability to other platforms.
-NetBSD 5.0_STABLE April 14, 2010 NetBSD 5.0_STABLE
+NetBSD 5.0_STABLE April 21, 2010 NetBSD 5.0_STABLE
diff --git a/devel/bmake/files/boot-strap b/devel/bmake/files/boot-strap
index b0e3188ef2b..3ab787f46f0 100755
--- a/devel/bmake/files/boot-strap
+++ b/devel/bmake/files/boot-strap
@@ -48,15 +48,12 @@
# --with-default-sys-path="syspath"
# set an explicit default "syspath" which is where bmake
# will look for sys.mk and friends.
-#
-# --with-prefix-sys-path="syspath"
-# prefix the built in default syspath with "syspath"
#
# AUTHOR:
# Simon J. Gerraty <sjg@crufty.net>
# RCSid:
-# $Id: boot-strap,v 1.1.1.6 2010/04/20 13:32:18 joerg Exp $
+# $Id: boot-strap,v 1.1.1.7 2010/04/24 20:33:52 joerg Exp $
#
# @(#) Copyright (c) 2001 Simon J. Gerraty
#
@@ -104,6 +101,7 @@ source_rc() {
}
CONFIGURE_ARGS=
+MAKESYSPATH=
# pick a useful default prefix (for me at least ;-)
for prefix in /opt/$HOST_TARGET "$HOME/$HOST_TARGET" /usr/pkg /usr/local ""
do
@@ -116,23 +114,33 @@ quiet=:
source_rc .bmake-boot-strap.rc . "$Mydir/.." "$HOME"
+get_optarg() {
+ expr "x$1" : "x[^=]*=\\(.*\\)"
+}
+
while :
do
case "$1" in
--) shift; break;;
--prefix) prefix="$2"; shift;;
- --prefix=*) prefix=`IFS="="; set -- "$1"; echo "$2"`;;
- --src=*) srcdir=`IFS="="; set -- "$1"; echo "$2"`;;
- --with-mksrc=*|--mksrc=*) mksrc=`IFS="="; set -- "$1"; echo "$2"`;;
- --share=*) share_dir=`IFS="="; set -- "$1"; echo "$2"`;;
+ --prefix=*) prefix=`get_optarg "$1"`;;
+ --src=*) srcdir=`get_optarg "$1"`;;
+ --with-mksrc=*|--mksrc=*) mksrc=`get_optarg "$1"`;;
+ --share=*) share_dir=`get_optarg "$1"`;;
--share) share_dir="$2"; shift;;
+ --with-default-sys-path=*)
+ CONFIGURE_ARGS="$1"
+ MAKESYSPATH=`get_optarg "$1"`;;
+ --with-default-sys-path)
+ CONFIGURE_ARGS="$1 $2"
+ MAKESYSPATH="$2"; shift;;
-s|--src) srcdir="$2"; shift;;
-m|--mksrc) mksrc="$2"; shift;;
-o|--objdir) objdir="$2"; shift;;
-q) quiet=;;
-c) source_rc "$2"; shift;;
--*) CONFIGURE_ARGS="$CONFIGURE_ARGS $1";;
- *=*) eval "$1"; export `IFS="="; set -- "$1"; echo "$1"`;;
+ *=*) eval "$1"; export `expr "x$1" : "x\\(.[^=]\\)=.*"`;;
*) break;;
esac
shift
@@ -164,12 +172,70 @@ GetDir() {
done
}
+FindHereOrAbove() {
+ (
+ _t=-s
+ while :
+ do
+ case "$1" in
+ -C) cd "$2"; shift; shift;;
+ -?) _t=$1; shift;;
+ *) break;;
+ esac
+ done
+ case "$1" in
+ /*) # we shouldn't be here
+ [ $_t "$1" ] && echo "$1"
+ return
+ ;;
+ .../*) want=`echo "$1" | sed 's,^.../*,,'`;;
+ *) want="$1";;
+ esac
+ here=`'pwd'`
+ while :
+ do
+ if [ $_t "./$want" ]; then
+ echo "$here/$want"
+ return
+ fi
+ cd ..
+ here=`'pwd'`
+ case "$here" in
+ /) return;;
+ esac
+ done
+ )
+}
+
+# is $1 missing from $2 (or PATH) ?
+no_path() {
+ eval "__p=\$${2:-PATH}"
+ case ":$__p:" in *:"$1":*) return 1;; *) return 0;; esac
+}
+
+# if $1 exists and is not in path, append it
+add_path () {
+ case "$1" in
+ -?) t=$1; shift;;
+ *) t=-d;;
+ esac
+ case "$2,$1" in
+ MAKESYSPATH,.../*) ;;
+ *) [ $t ${1:-.} ] || return;;
+ esac
+ no_path $* && eval ${2:-PATH}="$__p${__p:+:}$1"
+}
+
+
srcdir=`GetDir /bmake "$srcdir" "$2" "$Mydir" ./bmake* "$Mydir"/../bmake*`
[ -d "${srcdir:-/dev/null}" ] || Usage
case "$mksrc" in
none|-) # we don't want it
mksrc=
;;
+.../*) # find here or above
+ mksrc=`FindHereOrAbove -C "$Mydir" -d "$mksrc"`
+ ;;
*) # guess we want mksrc...
mksrc=`GetDir /mk "$mksrc" "$3" ./mk* "$srcdir"/mk* "$srcdir"/../mk*`
[ -d "${mksrc:-/dev/null}" ] || Usage "Use '-m none' to build without mksrc"
@@ -186,6 +252,7 @@ objdir=`'pwd'`
ShareDir() {
case "/$1" in
+ /) [ -d /share ] || return;;
*/$HOST_TARGET)
if [ -d "$1/../share" ]; then
echo `dirname "$1"`/share
@@ -200,22 +267,31 @@ share_dir="${share_dir:-`ShareDir $prefix`}"
AddConfigure --prefix= "$prefix"
case "$CONFIGURE_ARGS" in
-*--with-prefix-sys-path*) ;; # skip
-*) AddConfigure --with-default-sys-path= "$share_dir/mk";;
+*--with-*-sys-path*) ;; # skip
+*) [ "$share_dir" ] && AddConfigure --with-default-sys-path= "$share_dir/mk";;
esac
if [ "$mksrc" ]; then
AddConfigure --with-mksrc= "$mksrc"
# not all cc's support this
- export CFLAGS_MF=
+ CFLAGS_MF= CFLAGS_MD=
+ export CFLAGS_MF CFLAGS_MD
fi
$srcdir/configure $CONFIGURE_ARGS || exit 1
chmod 755 make-bootstrap.sh || exit 1
./make-bootstrap.sh || exit 1
-MAKESYSPATH="$share_dir/mk:/usr/share/mk"
+if [ -z "$MAKESYSPATH" ]; then
+ add_path "${share_dir:-...}/mk" MAKESYSPATH
+ case "$HOST_TARGET" in
+ netbsd*) add_path /usr/share/mk MAKESYSPATH;;
+ esac
+fi
if [ -s "${mksrc:-/dev/null}/install-mk" ]; then
sh "${mksrc}/install-mk" "$objdir/mk"
- MAKESYSPATH=".../mk:${MAKESYSPATH}"
+ case "$MAKESYSPATH" in
+ .../mk*) ;;
+ *) MAKESYSPATH=".../mk:${MAKESYSPATH}";;
+ esac
fi
export MAKESYSPATH
./bmake test || exit 1
diff --git a/devel/bmake/files/compat.c b/devel/bmake/files/compat.c
index a3314d1748c..b7f8e031073 100644
--- a/devel/bmake/files/compat.c
+++ b/devel/bmake/files/compat.c
@@ -1,4 +1,4 @@
-/* $NetBSD: compat.c,v 1.1.1.5 2010/04/20 13:32:19 joerg Exp $ */
+/* $NetBSD: compat.c,v 1.1.1.6 2010/04/24 20:33:52 joerg 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.1.1.5 2010/04/20 13:32:19 joerg Exp $";
+static char rcsid[] = "$NetBSD: compat.c,v 1.1.1.6 2010/04/24 20:33:52 joerg 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.1.1.5 2010/04/20 13:32:19 joerg Exp $");
+__RCSID("$NetBSD: compat.c,v 1.1.1.6 2010/04/24 20:33:52 joerg Exp $");
#endif
#endif /* not lint */
#endif
@@ -358,7 +358,7 @@ again:
/*
* Fork and execute the single command. If the fork fails, we abort.
*/
- cpid = vfork();
+ cpid = vFork();
if (cpid < 0) {
Fatal("Could not fork");
}
diff --git a/devel/bmake/files/job.c b/devel/bmake/files/job.c
index 1b0c8367be7..47be3827cee 100644
--- a/devel/bmake/files/job.c
+++ b/devel/bmake/files/job.c
@@ -1,4 +1,4 @@
-/* $NetBSD: job.c,v 1.1.1.6 2010/04/20 13:32:27 joerg Exp $ */
+/* $NetBSD: job.c,v 1.1.1.7 2010/04/24 20:33:56 joerg 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.1.1.6 2010/04/20 13:32:27 joerg Exp $";
+static char rcsid[] = "$NetBSD: job.c,v 1.1.1.7 2010/04/24 20:33:56 joerg 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.1.1.6 2010/04/20 13:32:27 joerg Exp $");
+__RCSID("$NetBSD: job.c,v 1.1.1.7 2010/04/24 20:33:56 joerg Exp $");
#endif
#endif /* not lint */
#endif
@@ -355,8 +355,6 @@ static sigset_t caught_signals; /* Set of signals we handle */
#define KILLPG(pid, sig) killpg((pid), (sig))
#endif
-static char *tmpdir; /* directory name, always ending with "/" */
-
static void JobChildSig(int);
static void JobContinueSig(int);
static Job *JobFindPid(int, int);
@@ -1315,7 +1313,7 @@ JobExec(Job *job, char **argv)
/* Pre-emptively mark job running, pid still zero though */
job->job_state = JOB_ST_RUNNING;
- cpid = vfork();
+ cpid = vFork();
if (cpid == -1)
Punt("Cannot vfork: %s", strerror(errno));
@@ -1569,11 +1567,7 @@ JobStart(GNode *gn, int flags)
}
JobSigLock(&mask);
- tfile = bmake_malloc(strlen(tmpdir) + sizeof(TMPPAT));
- strcpy(tfile, tmpdir);
- strcat(tfile, TMPPAT);
- if ((tfd = mkstemp(tfile)) == -1)
- Punt("Could not create temporary file %s", strerror(errno));
+ tfd = mkTempFile(TMPPAT, &tfile);
if (!DEBUG(SCRIPT))
(void)eunlink(tfile);
JobSigUnlock(&mask);
@@ -2136,8 +2130,6 @@ void
Job_Init(void)
{
GNode *begin; /* node for commands to do at the very start */
- const char *p;
- size_t len;
/* Allocate space for all the job info */
job_table = bmake_malloc(maxJobs * sizeof *job_table);
@@ -2150,18 +2142,6 @@ Job_Init(void)
lastNode = NULL;
- /* set tmpdir, and ensure that it ends with "/" */
- p = getenv("TMPDIR");
- if (p == NULL || *p == '\0') {
- p = _PATH_TMP;
- }
- len = strlen(p);
- tmpdir = bmake_malloc(len + 2);
- strcpy(tmpdir, p);
- if (tmpdir[len - 1] != '/') {
- strcat(tmpdir, "/");
- }
-
if (maxJobs == 1) {
/*
* If only one job can run at a time, there's no need for a banner,
diff --git a/devel/bmake/files/main.c b/devel/bmake/files/main.c
index 50496a8ebeb..bea3db15e29 100644
--- a/devel/bmake/files/main.c
+++ b/devel/bmake/files/main.c
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.1.1.6 2010/04/20 13:32:28 joerg Exp $ */
+/* $NetBSD: main.c,v 1.1.1.7 2010/04/24 20:33:57 joerg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: main.c,v 1.1.1.6 2010/04/20 13:32:28 joerg Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.1.1.7 2010/04/24 20:33:57 joerg 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.1.1.6 2010/04/20 13:32:28 joerg Exp $");
+__RCSID("$NetBSD: main.c,v 1.1.1.7 2010/04/24 20:33:57 joerg Exp $");
#endif
#endif /* not lint */
#endif
@@ -187,6 +187,7 @@ static char curdir[MAXPATHLEN + 1]; /* startup directory */
static char objdir[MAXPATHLEN + 1]; /* where we chdir'ed to */
char *progname; /* the program name */
char *makeDependfile;
+pid_t myPid;
Boolean forceJobs = FALSE;
@@ -396,6 +397,7 @@ rearg:
case 'B':
compatMake = TRUE;
Var_Append(MAKEFLAGS, "-B", VAR_GLOBAL);
+ Var_Set(MAKE_MODE, "compat", VAR_GLOBAL, 0);
break;
case 'C':
if (chdir(argvalue) == -1) {
@@ -511,6 +513,7 @@ rearg:
}
Var_Append(MAKEFLAGS, "-j", VAR_GLOBAL);
Var_Append(MAKEFLAGS, argvalue, VAR_GLOBAL);
+ Var_Set(".MAKE.JOBS", argvalue, VAR_GLOBAL, 0);
maxJobTokens = maxJobs;
break;
case 'k':
@@ -873,6 +876,8 @@ main(int argc, char **argv)
#endif
}
+ myPid = getpid(); /* remember this for vFork() */
+
/*
* Just in case MAKEOBJDIR wants us to do something tricky.
*/
@@ -932,7 +937,7 @@ main(int argc, char **argv)
p1 = argv[0];
} else {
p1 = realpath(argv[0], mdpath);
- if (!p1 || *p1 != '/') {
+ if (!p1 || *p1 != '/' || stat(p1, &sb) < 0) {
p1 = argv[0]; /* realpath failed */
}
}
@@ -954,7 +959,7 @@ main(int argc, char **argv)
ep = "0";
}
Var_Set(MAKE_LEVEL, ep, VAR_GLOBAL, 0);
- snprintf(tmp, sizeof(tmp), "%u", getpid());
+ snprintf(tmp, sizeof(tmp), "%u", myPid);
Var_Set(".MAKE.PID", tmp, VAR_GLOBAL, 0);
snprintf(tmp, sizeof(tmp), "%u", getppid());
Var_Set(".MAKE.PPID", tmp, VAR_GLOBAL, 0);
@@ -1633,7 +1638,7 @@ Cmd_Exec(const char *cmd, const char **errnum)
/*
* Fork
*/
- switch (cpid = vfork()) {
+ switch (cpid = vFork()) {
case 0:
/*
* Close input side of pipe
@@ -1996,3 +2001,46 @@ Main_ExportMAKEFLAGS(Boolean first)
#endif
}
}
+
+/*
+ * 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) {
+ struct stat st;
+
+ /*
+ * Honor $TMPDIR but only if it is valid.
+ * Ensure it ends with /.
+ */
+ tmpdir = Var_Subst(NULL, "${TMPDIR:tA:U" _PATH_TMP "}/", VAR_GLOBAL, 0);
+ if (stat(tmpdir, &st) < 0 || !S_ISDIR(st.st_mode)) {
+ free(tmpdir);
+ tmpdir = bmake_strdup(_PATH_TMP);
+ }
+ }
+ if (pattern[0] == '/') {
+ snprintf(tfile, sizeof(tfile), "%s", pattern);
+ } else {
+ snprintf(tfile, sizeof(tfile), "%s%s", tmpdir, pattern);
+ }
+ if ((fd = mkstemp(tfile)) < 0)
+ Punt("Could not create temporary file %s: %s", tfile, strerror(errno));
+ if (fnamep) {
+ *fnamep = bmake_strdup(tfile);
+ } else {
+ unlink(tfile); /* we just want the descriptor */
+ }
+ return fd;
+}
diff --git a/devel/bmake/files/make.1 b/devel/bmake/files/make.1
index a94e7160022..0e68c419c40 100644
--- a/devel/bmake/files/make.1
+++ b/devel/bmake/files/make.1
@@ -1,4 +1,4 @@
-.\" $NetBSD: make.1,v 1.1.1.6 2010/04/20 13:32:29 joerg Exp $
+.\" $NetBSD: make.1,v 1.1.1.7 2010/04/24 20:33:58 joerg 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 April 14, 2010
+.Dd April 21, 2010
.Dt MAKE 1
.Os
.Sh NAME
@@ -659,6 +659,10 @@ from which generated dependencies are read.
.It Va .MAKE.EXPORTED
The list of variables exported by
.Nm .
+.It Va .MAKE.JOBS
+The argument to the
+.Fl j
+option.
.It Va .MAKE.JOB.PREFIX
If
.Nm
diff --git a/devel/bmake/files/make.h b/devel/bmake/files/make.h
index ad85163696f..856b3dfa2a0 100644
--- a/devel/bmake/files/make.h
+++ b/devel/bmake/files/make.h
@@ -1,4 +1,4 @@
-/* $NetBSD: make.h,v 1.1.1.5 2010/04/20 13:32:32 joerg Exp $ */
+/* $NetBSD: make.h,v 1.1.1.6 2010/04/24 20:33:59 joerg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -411,6 +411,13 @@ extern Lst defIncPath; /* The default include path. */
extern char *progname; /* The program name */
extern char *makeDependfile; /* .depend */
+/*
+ * We cannot vfork() in a child of vfork().
+ * Most systems do not enforce this but some do.
+ */
+#define vFork() ((getpid() == myPid) ? vfork() : fork())
+extern pid_t myPid;
+
#define MAKEFLAGS ".MAKEFLAGS"
#define MAKEOVERRIDES ".MAKEOVERRIDES"
#define MAKE_JOB_PREFIX ".MAKE.JOB.PREFIX" /* prefix for job target output */
@@ -466,6 +473,7 @@ void Check_Cwd(const char **);
void PrintOnError(GNode *, const char *);
void Main_ExportMAKEFLAGS(Boolean);
Boolean Main_SetObjdir(const char *);
+int mkTempFile(const char *, char **);
#ifdef __GNUC__
#define UNCONST(ptr) ({ \
diff --git a/devel/bmake/files/realpath.c b/devel/bmake/files/realpath.c
index 9783fefb260..a8dc83bd914 100644
--- a/devel/bmake/files/realpath.c
+++ b/devel/bmake/files/realpath.c
@@ -1,5 +1,5 @@
-/* $Id: realpath.c,v 1.1.1.1 2010/04/20 13:32:27 joerg Exp $ */
-/* from: $NetBSD: realpath.c,v 1.1.1.1 2010/04/20 13:32:27 joerg Exp $ */
+/* $Id: realpath.c,v 1.1.1.2 2010/04/24 20:33:57 joerg Exp $ */
+/* from: $NetBSD: realpath.c,v 1.1.1.2 2010/04/24 20:33:57 joerg Exp $ */
/*
* Copyright (c) 1989, 1991, 1993, 1995
@@ -35,7 +35,7 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
-#ifndef HAVE_REALPATHx
+#ifndef HAVE_REALPATH
#include <sys/cdefs.h>
#include <sys/param.h>
diff --git a/devel/bmake/files/unit-tests/Makefile.in b/devel/bmake/files/unit-tests/Makefile.in
index ebeffb324b8..2fbea9d21da 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.1.1.6 2010/04/20 13:32:41 joerg Exp $
+# $Id: Makefile.in,v 1.1.1.7 2010/04/24 20:34:05 joerg Exp $
#
-# $NetBSD: Makefile.in,v 1.1.1.6 2010/04/20 13:32:41 joerg Exp $
+# $NetBSD: Makefile.in,v 1.1.1.7 2010/04/24 20:34:05 joerg Exp $
#
# Unit tests for make(1)
# The main targets are:
@@ -57,11 +57,19 @@ ${SUBFILES}:
clean:
rm -f *.out *.fail *.core
-.include <bsd.obj.mk>
+.-include <bsd.obj.mk>
TEST_MAKE?= ${.MAKE}
-TOOL_SED ?= sed
-TOOL_TR ?= tr
+TOOL_SED?= sed
+TOOL_TR?= tr
+
+# ensure consistent results from sort(1)
+LANG= C
+.export LANG
+
+# ensure consistent results from sort(1)
+LANG= C
+.export LANG
# The driver.
# We always pretend .MAKE was called 'make'
diff --git a/devel/bmake/files/unit-tests/export-all b/devel/bmake/files/unit-tests/export-all
index 9108dd4c33b..85224a532c0 100644
--- a/devel/bmake/files/unit-tests/export-all
+++ b/devel/bmake/files/unit-tests/export-all
@@ -1,8 +1,20 @@
-# $Id: export-all,v 1.1.1.3 2009/09/18 20:55:34 joerg Exp $
+# $Id: export-all,v 1.1.1.4 2010/04/24 20:34:05 joerg Exp $
UT_OK=good
UT_F=fine
+# the old way to do :tA
+M_tAbad = C,.*,cd & \&\& 'pwd',:sh
+# the new
+M_tA = tA
+
+here := ${.PARSEDIR}
+
+# this will cause trouble (recursing if we let it)
+UT_BADDIR = ${${here}/../${here:T}:L:${M_tAbad}:T}
+# this will be ok
+UT_OKDIR = ${${here}/../${here:T}:L:${M_tA}:T}
+
.export
.include "export"
diff --git a/devel/bmake/files/unit-tests/modmisc b/devel/bmake/files/unit-tests/modmisc
index 19b8f6005f9..375accca28d 100644
--- a/devel/bmake/files/unit-tests/modmisc
+++ b/devel/bmake/files/unit-tests/modmisc
@@ -1,8 +1,10 @@
-# $Id: modmisc,v 1.1.1.3 2009/09/18 20:55:34 joerg Exp $
+# $Id: modmisc,v 1.1.1.4 2010/04/24 20:34:05 joerg Exp $
#
# miscellaneous modifier tests
-path=:/bin:/usr/bin::/sbin:/usr/sbin:.:/home/user/bin:.
+# do not put any dirs in this list which exist on some
+# but not all target systems - an exists() check is below.
+path=:/bin:/tmp::/:.:/no/such/dir:.
# strip cwd from path.
MOD_NODOT=S/:/ /g:N.:ts:
# and decorate, note that $'s need to be doubled. Also note that
diff --git a/devel/bmake/files/unit-tests/test.exp b/devel/bmake/files/unit-tests/test.exp
index 660e28982ca..347bb9f2409 100644
--- a/devel/bmake/files/unit-tests/test.exp
+++ b/devel/bmake/files/unit-tests/test.exp
@@ -33,12 +33,14 @@ UT_FU=fubar
UT_TEST=export
UT_ZOO=hoopie
UT_ALL=even this gets exported
+UT_BADDIR=unit-tests
UT_DOLLAR=This is $UT_FU
UT_F=fine
UT_FOO=foobar is fubar
UT_FU=fubar
UT_NO=all
UT_OK=good
+UT_OKDIR=unit-tests
UT_TEST=export-all
UT_ZOO=hoopie
At first, I am
@@ -110,14 +112,14 @@ LIB=e X_LIBS:M${LIB${LIB:tu}} is "/tmp/libe.a"
LIB=e X_LIBS:M*/lib${LIB}.a is "/tmp/libe.a"
LIB=e X_LIBS:M*/lib${LIB}.a:tu is "/TMP/LIBE.A"
Mscanner=OK
-path=':/bin:/usr/bin::/sbin:/usr/sbin:.:/home/user/bin:.'
-path='/bin:/usr/bin:/sbin:/usr/sbin:/home/user/bin'
-path='/bin:/usr/bin:/sbin:/usr/sbin:/homes/user/bin'
-path='/bin':'/usr/bin':'/sbin':'/usr/sbin':'/home/user/bin'
-path='/bin':'/usr/bin':'/sbin':'/usr/sbin':'/homes/user/bin'
+path=':/bin:/tmp::/:.:/no/such/dir:.'
+path='/bin:/tmp:/:/no/such/dir'
+path='/bin:/tmp:/:/no/such/dir'
+path='/bin':'/tmp':'/':'/no/such/dir'
+path='/bin':'/tmp':'/':'/no/such/dir'
path_/usr/xbin=/opt/xbin/
-paths=/bin /usr/bin /sbin /usr/sbin /homes/user/bin /opt/xbin
-PATHS=/BIN /USR/BIN /SBIN /USR/SBIN /HOMES/USER/BIN /OPT/XBIN
+paths=/bin /tmp / /no/such/dir /opt/xbin
+PATHS=/BIN /TMP / /NO/SUCH/DIR /OPT/XBIN
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
diff --git a/devel/bmake/files/var.c b/devel/bmake/files/var.c
index f412e7bf985..edc0058b9e3 100644
--- a/devel/bmake/files/var.c
+++ b/devel/bmake/files/var.c
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.1.1.6 2010/04/20 13:32:37 joerg Exp $ */
+/* $NetBSD: var.c,v 1.1.1.7 2010/04/24 20:34:02 joerg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.1.1.6 2010/04/20 13:32:37 joerg Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.1.1.7 2010/04/24 20:34:02 joerg 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.1.1.6 2010/04/20 13:32:37 joerg Exp $");
+__RCSID("$NetBSD: var.c,v 1.1.1.7 2010/04/24 20:34:02 joerg Exp $");
#endif
#endif /* not lint */
#endif
@@ -123,6 +123,7 @@ __RCSID("$NetBSD: var.c,v 1.1.1.6 2010/04/20 13:32:37 joerg Exp $");
* XXX: There's a lot of duplication in these functions.
*/
+#include <sys/stat.h>
#ifndef NO_REGEX
#include <sys/types.h>
#include <regex.h>
@@ -590,6 +591,13 @@ Var_Export1(const char *name, int parent)
v->flags |= (VAR_EXPORTED|VAR_REEXPORT);
return 1;
}
+ if (v->flags & VAR_IN_USE) {
+ /*
+ * We recursed while exporting in a child.
+ * This isn't going to end well, just skip it.
+ */
+ return 0;
+ }
n = snprintf(tmp, sizeof(tmp), "${%s}", name);
if (n < (int)sizeof(tmp)) {
val = Var_Subst(NULL, tmp, VAR_GLOBAL, 0);
@@ -1870,6 +1878,7 @@ VarRealpath(GNode *ctx __unused, Var_Parse_State *vpstate,
char *word, Boolean addSpace, Buffer *buf,
void *patternp __unused)
{
+ struct stat st;
char rbuf[MAXPATHLEN];
char *rp;
@@ -1878,7 +1887,7 @@ VarRealpath(GNode *ctx __unused, Var_Parse_State *vpstate,
}
addSpace = TRUE;
rp = realpath(word, rbuf);
- if (rp && *rp == '/')
+ if (rp && *rp == '/' && stat(rp, &st) == 0)
word = rp;
Buf_AddBytes(buf, strlen(word), word);