2012/02/10 16:16:12,usr.bin/login
2012/10/17 12:00:00,usr.bin/lorder
2012/10/17 12:00:00,usr.bin/m4
-2012/03/31 00:12:24,usr.bin/make
+2012/10/17 12:00:00,usr.bin/make
2012/10/17 12:00:00,usr.bin/Makefile
2012/10/17 12:00:00,usr.bin/Makefile.inc
2010/07/07 21:24:34,usr.bin/man
.endif
.if defined(__MINIX)
-CPPFLAGS+= -DHAVE_SETENV -DHAVE_STRERROR -DHAVE_STRDUP \
- -DHAVE_STRFTIME -DHAVE_VSNPRINTF -DUSE_SELECT
-
CPPFLAGS+= -DMAKE_MACHINE=\"${MACHINE}\" -DMAKE_MACHINE_ARCH=\"${MACHINE_ARCH}\"
-
-# LSC Until it compiles cleanly...
-NOGCCERROR:=yes
.endif #defined(__MINIX)
.PATH: ${.CURDIR}/lst.lib
-/* $NetBSD: arch.c,v 1.62 2010/11/27 16:00:09 christos Exp $ */
+/* $NetBSD: arch.c,v 1.63 2012/06/12 19:21:50 joerg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: arch.c,v 1.62 2010/11/27 16:00:09 christos Exp $";
+static char rcsid[] = "$NetBSD: arch.c,v 1.63 2012/06/12 19:21:50 joerg 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.62 2010/11/27 16:00:09 christos Exp $");
+__RCSID("$NetBSD: arch.c,v 1.63 2012/06/12 19:21:50 joerg Exp $");
#endif
#endif /* not lint */
#endif
*/
void
#if !defined(RANLIBMAG)
-Arch_TouchLib(GNode *gn __unused)
+Arch_TouchLib(GNode *gn MAKE_ATTR_UNUSED)
#else
Arch_TouchLib(GNode *gn)
#endif
-/* $NetBSD: buf.c,v 1.24 2009/01/17 13:29:37 dsl Exp $ */
+/* $NetBSD: buf.c,v 1.25 2012/04/24 20:26:58 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: buf.c,v 1.24 2009/01/17 13:29:37 dsl Exp $";
+static char rcsid[] = "$NetBSD: buf.c,v 1.25 2012/04/24 20:26:58 sjg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)buf.c 8.1 (Berkeley) 6/6/93";
#else
-__RCSID("$NetBSD: buf.c,v 1.24 2009/01/17 13:29:37 dsl Exp $");
+__RCSID("$NetBSD: buf.c,v 1.25 2012/04/24 20:26:58 sjg Exp $");
#endif
#endif /* not lint */
#endif
return data;
}
+
+
+/*-
+ *-----------------------------------------------------------------------
+ * Buf_DestroyCompact --
+ * Nuke a buffer and return its data.
+ *
+ * Input:
+ * buf Buffer to destroy
+ *
+ * Results:
+ * Data buffer
+ *
+ * Side Effects:
+ * If the buffer size is much greater than its content,
+ * a new buffer will be allocated and the old one freed.
+ *
+ *-----------------------------------------------------------------------
+ */
+#ifndef BUF_COMPACT_LIMIT
+# define BUF_COMPACT_LIMIT 128 /* worthwhile saving */
+#endif
+
+Byte *
+Buf_DestroyCompact(Buffer *buf)
+{
+#if BUF_COMPACT_LIMIT > 0
+ Byte *data;
+
+ if (buf->size - buf->count >= BUF_COMPACT_LIMIT) {
+ /* We trust realloc to be smart */
+ data = bmake_realloc(buf->buffer, buf->count + 1);
+ if (data) {
+ data[buf->count] = 0;
+ Buf_Destroy(buf, FALSE);
+ return data;
+ }
+ }
+#endif
+ return Buf_Destroy(buf, FALSE);
+}
-/* $NetBSD: buf.h,v 1.16 2009/01/17 13:55:42 dsl Exp $ */
+/* $NetBSD: buf.h,v 1.17 2012/04/24 20:26:58 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
void Buf_Empty(Buffer *);
void Buf_Init(Buffer *, int);
Byte *Buf_Destroy(Buffer *, Boolean);
+Byte *Buf_DestroyCompact(Buffer *);
#endif /* _BUF_H */
-/* $NetBSD: compat.c,v 1.84 2011/09/16 15:38:03 joerg Exp $ */
+/* $NetBSD: compat.c,v 1.90 2012/10/07 19:17:31 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: compat.c,v 1.84 2011/09/16 15:38:03 joerg Exp $";
+static char rcsid[] = "$NetBSD: compat.c,v 1.90 2012/10/07 19:17:31 sjg 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.84 2011/09/16 15:38:03 joerg Exp $");
+__RCSID("$NetBSD: compat.c,v 1.90 2012/10/07 19:17:31 sjg Exp $");
#endif
#endif /* not lint */
#endif
static GNode *curTarg = NULL;
static GNode *ENDNode;
-static void CompatInterrupt(int) __dead;
+static void CompatInterrupt(int);
static void
Compat_Init(void)
}
}
- exit(signo);
+ if (signo == SIGQUIT)
+ _exit(signo);
+ bmake_signal(signo, SIG_DFL);
+ kill(myPid, signo);
}
\f
/*-
if (*cmdStart == '\0') {
free(cmdStart);
- Error("%s expands to empty string", cmd);
return(0);
}
cmd = cmdStart;
while (isspace((unsigned char)*cmd))
cmd++;
+ /*
+ * If we did not end up with a command, just skip it.
+ */
+ if (!*cmd)
+ return (0);
+
#if !defined(MAKE_NATIVE)
/*
* In a non-native build, the host environment might be weird enough
-/* $NetBSD: cond.c,v 1.62 2011/03/29 17:19:22 sjg Exp $ */
+/* $NetBSD: cond.c,v 1.64 2012/06/12 19:21:50 joerg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: cond.c,v 1.62 2011/03/29 17:19:22 sjg Exp $";
+static char rcsid[] = "$NetBSD: cond.c,v 1.64 2012/06/12 19:21:50 joerg 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.62 2011/03/29 17:19:22 sjg Exp $");
+__RCSID("$NetBSD: cond.c,v 1.64 2012/06/12 19:21:50 joerg Exp $");
#endif
#endif /* not lint */
#endif
*-----------------------------------------------------------------------
*/
static Boolean
-CondDoDefined(int argLen __unused, const char *arg)
+CondDoDefined(int argLen MAKE_ATTR_UNUSED, const char *arg)
{
char *p1;
Boolean result;
*-----------------------------------------------------------------------
*/
static Boolean
-CondDoMake(int argLen __unused, const char *arg)
+CondDoMake(int argLen MAKE_ATTR_UNUSED, const char *arg)
{
return Lst_Find(create, arg, CondStrMatch) != NULL;
}
*-----------------------------------------------------------------------
*/
static Boolean
-CondDoExists(int argLen __unused, const char *arg)
+CondDoExists(int argLen MAKE_ATTR_UNUSED, const char *arg)
{
Boolean result;
char *path;
*-----------------------------------------------------------------------
*/
static Boolean
-CondDoTarget(int argLen __unused, const char *arg)
+CondDoTarget(int argLen MAKE_ATTR_UNUSED, const char *arg)
{
GNode *gn;
*-----------------------------------------------------------------------
*/
static Boolean
-CondDoCommands(int argLen __unused, const char *arg)
+CondDoCommands(int argLen MAKE_ATTR_UNUSED, const char *arg)
{
GNode *gn;
}
static int
-get_mpt_arg(char **linePtr, char **argPtr, const char *func __unused)
+get_mpt_arg(char **linePtr, char **argPtr, const char *func MAKE_ATTR_UNUSED)
{
/*
* Use Var_Parse to parse the spec in parens and return
}
static Boolean
-CondDoEmpty(int arglen, const char *arg __unused)
+CondDoEmpty(int arglen, const char *arg MAKE_ATTR_UNUSED)
{
return arglen == 1;
}
int
Cond_Eval(char *line)
{
- #define MAXIF 64 /* maximum depth of .if'ing */
+ #define MAXIF 128 /* maximum depth of .if'ing */
enum if_states {
IF_ACTIVE, /* .if or .elif part active */
ELSE_ACTIVE, /* .else part active */
-/* $NetBSD: dir.c,v 1.64 2012/04/07 18:29:08 christos Exp $ */
+/* $NetBSD: dir.c,v 1.65 2012/06/12 19:21:50 joerg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: dir.c,v 1.64 2012/04/07 18:29:08 christos Exp $";
+static char rcsid[] = "$NetBSD: dir.c,v 1.65 2012/06/12 19:21:50 joerg 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.64 2012/04/07 18:29:08 christos Exp $");
+__RCSID("$NetBSD: dir.c,v 1.65 2012/06/12 19:21:50 joerg Exp $");
#endif
#endif /* not lint */
#endif
*-----------------------------------------------------------------------
*/
static char *
-DirLookup(Path *p, const char *name __unused, const char *cp,
- Boolean hasSlash __unused)
+DirLookup(Path *p, const char *name MAKE_ATTR_UNUSED, const char *cp,
+ Boolean hasSlash MAKE_ATTR_UNUSED)
{
char *file; /* the current filename to check */
*-----------------------------------------------------------------------
*/
static char *
-DirFindDot(Boolean hasSlash __unused, const char *name, const char *cp)
+DirFindDot(Boolean hasSlash MAKE_ATTR_UNUSED, const char *name, const char *cp)
{
if (Hash_FindEntry(&dot->files, cp) != NULL) {
-/* $NetBSD: for.c,v 1.48 2010/12/25 04:57:07 dholland Exp $ */
+/* $NetBSD: for.c,v 1.49 2012/06/03 04:29:40 sjg Exp $ */
/*
* Copyright (c) 1992, The Regents of the University of California.
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: for.c,v 1.48 2010/12/25 04:57:07 dholland Exp $";
+static char rcsid[] = "$NetBSD: for.c,v 1.49 2012/06/03 04:29:40 sjg 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.48 2010/12/25 04:57:07 dholland Exp $");
+__RCSID("$NetBSD: for.c,v 1.49 2012/06/03 04:29:40 sjg Exp $");
#endif
#endif /* not lint */
#endif
int len;
int escapes;
unsigned char ch;
+ char **words, *word_buf;
+ int n, nwords;
/* Skip the '.' and any following whitespace */
for (ptr++; *ptr && isspace((unsigned char) *ptr); ptr++)
*/
sub = Var_Subst(NULL, ptr, VAR_GLOBAL, FALSE);
- for (ptr = sub;; ptr += len) {
- while (*ptr && isspace((unsigned char)*ptr))
- ptr++;
- if (*ptr == 0)
- break;
- escapes = 0;
- for (len = 0; (ch = ptr[len]) != 0 && !isspace(ch); len++) {
- if (ch == ':' || ch == '$' || ch == '\\')
- escapes |= FOR_SUB_ESCAPE_CHAR;
- else if (ch == ')')
- escapes |= FOR_SUB_ESCAPE_PAREN;
- else if (ch == /*{*/ '}')
- escapes |= FOR_SUB_ESCAPE_BRACE;
- }
- strlist_add_str(&new_for->items, make_str(ptr, len), escapes);
- }
+ /*
+ * Split into words allowing for quoted strings.
+ */
+ words = brk_string(sub, &nwords, FALSE, &word_buf);
free(sub);
+
+ if (words != NULL) {
+ for (n = 0; n < nwords; n++) {
+ ptr = words[n];
+ if (!*ptr)
+ continue;
+ escapes = 0;
+ while ((ch = *ptr++)) {
+ switch(ch) {
+ case ':':
+ case '$':
+ case '\\':
+ escapes |= FOR_SUB_ESCAPE_CHAR;
+ break;
+ case ')':
+ escapes |= FOR_SUB_ESCAPE_PAREN;
+ break;
+ case /*{*/ '}':
+ escapes |= FOR_SUB_ESCAPE_BRACE;
+ break;
+ }
+ }
+ /*
+ * We have to dup words[n] to maintain the semantics of
+ * strlist.
+ */
+ strlist_add_str(&new_for->items, bmake_strdup(words[n]), escapes);
+ }
- if (strlist_num(&new_for->items) % strlist_num(&new_for->vars)) {
- Parse_Error(PARSE_FATAL,
- "Wrong number of words (%d) in .for substitution list"
- " with %d vars",
- strlist_num(&new_for->items), strlist_num(&new_for->vars));
- /*
- * Return 'success' so that the body of the .for loop is accumulated.
- * Remove all items so that the loop doesn't iterate.
- */
- strlist_clean(&new_for->items);
+ free(words);
+ free(word_buf);
+
+ if ((len = strlist_num(&new_for->items)) > 0 &&
+ len % (n = strlist_num(&new_for->vars))) {
+ Parse_Error(PARSE_FATAL,
+ "Wrong number of words (%d) in .for substitution list"
+ " with %d vars", len, n);
+ /*
+ * Return 'success' so that the body of the .for loop is
+ * accumulated.
+ * Remove all items so that the loop doesn't iterate.
+ */
+ strlist_clean(&new_for->items);
+ }
}
Buf_Init(&new_for->buf, 0);
-/* $NetBSD: job.c,v 1.161 2012/04/07 18:29:08 christos Exp $ */
+/* $NetBSD: job.c,v 1.163 2012/07/03 21:03:40 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: job.c,v 1.161 2012/04/07 18:29:08 christos Exp $";
+static char rcsid[] = "$NetBSD: job.c,v 1.163 2012/07/03 21:03:40 sjg 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.161 2012/04/07 18:29:08 christos Exp $");
+__RCSID("$NetBSD: job.c,v 1.163 2012/07/03 21:03:40 sjg Exp $");
#endif
#endif /* not lint */
#endif
static char *JobOutput(Job *, char *, char *, int);
static void JobDoOutput(Job *, Boolean);
static Shell *JobMatchShell(const char *);
-static void JobInterrupt(int, int) __dead;
+static void JobInterrupt(int, int) MAKE_ATTR_DEAD;
static void JobRestartJobs(void);
static void JobTokenAdd(void);
static void JobSigLock(sigset_t *);
*-----------------------------------------------------------------------
*/
static void
-JobChildSig(int signo __unused)
+JobChildSig(int signo MAKE_ATTR_UNUSED)
{
write(childExitJob.outPipe, CHILD_EXIT, 1);
}
*-----------------------------------------------------------------------
*/
static void
-JobContinueSig(int signo __unused)
+JobContinueSig(int signo MAKE_ATTR_UNUSED)
{
/*
* Defer sending to SIGCONT to our stopped children until we return
*
*-----------------------------------------------------------------------
*/
-__dead static void
+MAKE_ATTR_DEAD static void
JobPassSig_int(int signo)
{
/* Run .INTERRUPT target then exit */
JobInterrupt(TRUE, signo);
}
-__dead static void
+MAKE_ATTR_DEAD static void
JobPassSig_term(int signo)
{
/* Dont run .INTERRUPT target then exit */
* If no path was given, the user wants one of the pre-defined shells,
* yes? So we find the one s/he wants with the help of JobMatchShell
* and set things up the right way. shellPath will be set up by
- * Job_Init.
+ * Shell_Init.
*/
if (newShell.name == NULL) {
Parse_Error(PARSE_FATAL, "Neither path nor name specified");
}
commandShell = sh;
shellName = newShell.name;
+ if (shellPath) {
+ /* Shell_Init has already been called! Do it again. */
+ free(UNCONST(shellPath));
+ shellPath = NULL;
+ Shell_Init();
+ }
}
} else {
/*
-/* $NetBSD: main.c,v 1.198 2011/09/16 15:38:04 joerg Exp $ */
+/* $NetBSD: main.c,v 1.203 2012/08/31 07:00:36 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: main.c,v 1.198 2011/09/16 15:38:04 joerg Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.203 2012/08/31 07:00:36 sjg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: main.c,v 1.198 2011/09/16 15:38:04 joerg Exp $");
+__RCSID("$NetBSD: main.c,v 1.203 2012/08/31 07:00:36 sjg Exp $");
#endif
#endif /* not lint */
#endif
static int maxJobTokens; /* -j argument */
Boolean compatMake; /* -B argument */
int debug; /* -d argument */
+Boolean debugVflag; /* -dV */
Boolean noExecute; /* -n flag */
Boolean noRecursiveExecute; /* -N flag */
Boolean keepgoing; /* -k flag */
static char * Check_Cwd_av(int, char **, int);
static void MainParseArgs(int, char **);
static int ReadMakefile(const void *, const void *);
-static void usage(void) __dead;
+static void usage(void) MAKE_ATTR_DEAD;
static Boolean ignorePWD; /* if we use -C, PWD is meaningless */
static char objdir[MAXPATHLEN + 1]; /* where we chdir'ed to */
case 't':
debug |= DEBUG_TARG;
break;
+ case 'V':
+ debugVflag = TRUE;
+ break;
case 'v':
debug |= DEBUG_VAR;
break;
case 'F':
if (debug_file != stdout && debug_file != stderr)
fclose(debug_file);
- if (*++modules == '+')
+ if (*++modules == '+') {
+ modules++;
mode = "a";
- else
+ } else
mode = "w";
if (strcmp(modules, "stdout") == 0) {
debug_file = stdout;
#ifdef SIGINFO
/*ARGSUSED*/
static void
-siginfo(int signo __unused)
+siginfo(int signo MAKE_ATTR_UNUSED)
{
char dir[MAXPATHLEN];
char str[2 * MAXPATHLEN];
create = Lst_Init(FALSE);
makefiles = Lst_Init(FALSE);
printVars = FALSE;
+ debugVflag = FALSE;
variables = Lst_Init(FALSE);
beSilent = FALSE; /* Print commands as executed */
ignoreErrors = FALSE; /* Pay attention to non-zero returns */
/* print the values of any variables requested by the user */
if (printVars) {
LstNode ln;
+ Boolean expandVars;
+ if (debugVflag)
+ expandVars = FALSE;
+ else
+ expandVars = getBoolean(".MAKE.EXPAND_VARIABLES", FALSE);
for (ln = Lst_First(variables); ln != NULL;
ln = Lst_Succ(ln)) {
char *var = (char *)Lst_Datum(ln);
if (strchr(var, '$')) {
value = p1 = Var_Subst(NULL, var, VAR_GLOBAL, 0);
+ } else if (expandVars) {
+ char tmp[128];
+
+ if (snprintf(tmp, sizeof(tmp), "${%s}", var) >= (int)(sizeof(tmp)))
+ Fatal("%s: variable name too big: %s",
+ progname, var);
+ value = p1 = Var_Subst(NULL, tmp, VAR_GLOBAL, 0);
} else {
value = Var_Value(var, VAR_GLOBAL, &p1);
}
* lots
*/
static int
-ReadMakefile(const void *p, const void *q __unused)
+ReadMakefile(const void *p, const void *q MAKE_ATTR_UNUSED)
{
const char *fname = p; /* makefile to read */
int fd;
}
return fd;
}
+
+
+/*
+ * Return a Boolean based on setting of a knob.
+ *
+ * If the knob is not set, the supplied default is the return value.
+ * If set, anything that looks or smells like "No", "False", "Off", "0" etc,
+ * is FALSE, otherwise TRUE.
+ */
+Boolean
+getBoolean(const char *name, Boolean bf)
+{
+ char tmp[64];
+ char *cp;
+
+ if (snprintf(tmp, sizeof(tmp), "${%s:tl}", name) < (int)(sizeof(tmp))) {
+ cp = Var_Subst(NULL, tmp, VAR_GLOBAL, 0);
+
+ if (cp) {
+ switch(*cp) {
+ case '\0': /* not set - the default wins */
+ break;
+ case '0':
+ case 'f':
+ case 'n':
+ bf = FALSE;
+ break;
+ case 'o':
+ switch (cp[1]) {
+ case 'f':
+ bf = FALSE;
+ break;
+ default:
+ bf = TRUE;
+ break;
+ }
+ break;
+ default:
+ bf = TRUE;
+ break;
+ }
+ free(cp);
+ }
+ }
+ return (bf);
+}
-.\" $NetBSD: make.1,v 1.202 2012/04/08 22:00:39 wiz Exp $
+.\" $NetBSD: make.1,v 1.209 2012/10/08 15:09:48 christos Exp $
.\"
.\" Copyright (c) 1990, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" from: @(#)make.1 8.4 (Berkeley) 3/19/94
.\"
-.Dd March 31, 2012
+.Dd October 8, 2012
.Dt MAKE 1
.Os
.Sh NAME
Print debugging information about suffix-transformation rules.
.It Ar t
Print debugging information about target list maintenance.
+.It Ar V
+Force the
+.Fl V
+option to print raw values of variables.
.It Ar v
Print debugging information about variable assignment.
.It Ar x
Names the makefile (default
.Ql Pa .depend )
from which generated dependencies are read.
+.It Va .MAKE.EXPAND_VARIABLES
+A boolean that controls the default behavior of the
+.Fl V
+option.
.It Va .MAKE.EXPORTED
The list of variables exported by
.Nm .
To be compatible with Makefiles that do this, one can use
.Fl B
to disable this behavior.
+.Pp
+In compatibility mode, each command is run in a separate process.
+If the command contains any shell meta characters
+.Pq Ql #=|^(){};&<>*?[]:$`\e\en
+it will be passed to the shell, otherwise
+.Nm
+will attempt direct execution.
.Sh SEE ALSO
.Xr mkdep 1
.Sh HISTORY
This
.Nm
implementation is based on Adam De Boor's pmake program which was written
-for Sprint at Berkeley.
+for Sprite at Berkeley.
It was designed to be a parallel distributed make running jobs on different
machines using a daemon called
.Dq customs .
-/* $NetBSD: make.c,v 1.85 2012/04/07 18:29:08 christos Exp $ */
+/* $NetBSD: make.c,v 1.87 2012/06/12 19:21:51 joerg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: make.c,v 1.85 2012/04/07 18:29:08 christos Exp $";
+static char rcsid[] = "$NetBSD: make.c,v 1.87 2012/06/12 19:21:51 joerg 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.85 2012/04/07 18:29:08 christos Exp $");
+__RCSID("$NetBSD: make.c,v 1.87 2012/06/12 19:21:51 joerg Exp $");
#endif
#endif /* not lint */
#endif
static int MakeBuildChild(void *, void *);
static int MakeBuildParent(void *, void *);
-__dead static void
+MAKE_ATTR_DEAD static void
make_abort(GNode *gn, int line)
{
static int two = 2;
* doesn't depend on their modification time...
*/
if ((gn->type & (OP_JOIN|OP_USE|OP_USEBEFORE|OP_EXEC)) == 0) {
- (void)Dir_MTime(gn, 0);
+ (void)Dir_MTime(gn, 1);
if (DEBUG(MAKE)) {
if (gn->mtime != 0) {
fprintf(debug_file, "modified %s...", Targ_FmtTime(gn->mtime));
*-----------------------------------------------------------------------
*/
static int
-MakeUnmark(void *cgnp, void *pgnp __unused)
+MakeUnmark(void *cgnp, void *pgnp MAKE_ATTR_UNUSED)
{
GNode *cgn = (GNode *)cgnp;
*/
static int
-MakeCheckOrder(void *v_bn, void *ignore __unused)
+MakeCheckOrder(void *v_bn, void *ignore MAKE_ATTR_UNUSED)
{
GNode *bn = v_bn;
-/* $NetBSD: make.h,v 1.87 2011/09/16 15:38:04 joerg Exp $ */
+/* $NetBSD: make.h,v 1.89 2012/06/12 19:21:51 joerg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
# include <sys/cdefs.h>
#endif
-#if !defined(__GNUC_PREREQ__)
#if defined(__GNUC__)
-#define __GNUC_PREREQ__(x, y) \
+#define MAKE_GNUC_PREREQ(x, y) \
((__GNUC__ == (x) && __GNUC_MINOR__ >= (y)) || \
(__GNUC__ > (x)))
#else /* defined(__GNUC__) */
-#define __GNUC_PREREQ__(x, y) 0
+#define MAKE_GNUC_PREREQx, y) 0
#endif /* defined(__GNUC__) */
-#endif /* !defined(__GNUC_PREREQ__) */
-#if !defined(__unused)
-#if __GNUC_PREREQ__(2, 7)
-#define __unused __attribute__((__unused__))
+#if MAKE_GNUC_PREREQ(2, 7)
+#define MAKE_ATTR_UNUSED __attribute__((__unused__))
#else
-#define __unused /* delete */
+#define MAKE_ATTR_UNUSED /* delete */
#endif
+
+#if MAKE_GNUC_PREREQ(2, 5)
+#define MAKE_ATTR_DEAD __attribute__((__noreturn__))
+#elif defined(__GNUC__)
+#define MAKE_ATTR_DEAD __volatile
+#else
+#define MAKE_ATTR_DEAD /* delete */
#endif
-#if !defined(__dead)
-#define __dead
+#if MAKE_GNUC_PREREQ(2, 7)
+#define MAKE_ATTR_PRINTFLIKE(fmtarg, firstvararg) \
+ __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
+#else
+#define MAKE_ATTR_PRINTFLIKE(fmtarg, firstvararg) /* delete */
#endif
#include "sprite.h"
extern char curdir[]; /* Startup directory */
extern char *progname; /* The program name */
extern char *makeDependfile; /* .depend */
+extern char **savedEnv; /* if we replaced environ this will be non-NULL */
/*
* We cannot vfork() in a child of vfork().
-/* $NetBSD: make_malloc.c,v 1.6 2010/12/25 20:35:25 dholland Exp $ */
+/* $NetBSD: make_malloc.c,v 1.10 2012/06/20 17:46:28 sjg Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
#ifdef MAKE_NATIVE
#include <sys/cdefs.h>
-__RCSID("$NetBSD: make_malloc.c,v 1.6 2010/12/25 20:35:25 dholland Exp $");
+__RCSID("$NetBSD: make_malloc.c,v 1.10 2012/06/20 17:46:28 sjg Exp $");
#endif
#include <stdio.h>
#include <string.h>
#include <errno.h>
-#include "make_malloc.h"
+#include "make.h"
#ifndef USE_EMALLOC
+static void enomem(void) MAKE_ATTR_DEAD;
+
/*
* enomem --
* die when out of memory.
static void
enomem(void)
{
- extern char *progname;
-
(void)fprintf(stderr, "%s: %s.\n", progname, strerror(ENOMEM));
exit(2);
}
-/* $NetBSD: meta.c,v 1.24 2011/09/21 14:30:47 christos Exp $ */
+/* $NetBSD: meta.c,v 1.25 2012/06/27 17:22:58 sjg Exp $ */
/*
* Implement 'meta' mode.
extern Boolean forceJobs;
extern Boolean comatMake;
+extern char **environ;
#define MAKE_META_PREFIX ".MAKE.META.PREFIX"
static FILE *
meta_create(BuildMon *pbm, GNode *gn)
{
- extern char **environ;
meta_file_t mf;
char buf[MAXPATHLEN];
char objdir[MAXPATHLEN];
-/* $NetBSD: nonints.h,v 1.63 2011/09/16 15:38:04 joerg Exp $ */
+/* $NetBSD: nonints.h,v 1.65 2012/08/30 21:17:05 sjg Exp $ */
/*-
* Copyright (c) 1988, 1989, 1990, 1993
* from: @(#)nonints.h 8.3 (Berkeley) 3/19/94
*/
-#ifndef MAKE_NATIVE
-#undef __attribute__
-#define __attribute__(x)
-#endif
-
/* arch.c */
ReturnStatus Arch_ParseArchive(char **, Lst, GNode *);
void Arch_Touch(GNode *);
void MakeMode(const char *);
int main(int, char **);
char *Cmd_Exec(const char *, const char **);
-void Error(const char *, ...) __attribute__((__format__(__printf__, 1, 2)));
-void Fatal(const char *, ...)
- __attribute__((__format__(__printf__, 1, 2),__noreturn__));
-void Punt(const char *, ...)
- __attribute__((__format__(__printf__, 1, 2),__noreturn__));
-void DieHorribly(void) __attribute__((__noreturn__));
+void Error(const char *, ...) MAKE_ATTR_PRINTFLIKE(1, 2);
+void Fatal(const char *, ...) MAKE_ATTR_PRINTFLIKE(1, 2) MAKE_ATTR_DEAD;
+void Punt(const char *, ...) MAKE_ATTR_PRINTFLIKE(1, 2) MAKE_ATTR_DEAD;
+void DieHorribly(void) MAKE_ATTR_DEAD;
int PrintAddr(void *, void *);
-void Finish(int) __dead;
+void Finish(int) MAKE_ATTR_DEAD;
int eunlink(const char *);
void execError(const char *, const char *);
char *getTmpdir(void);
+Boolean getBoolean(const char *, Boolean);
/* parse.c */
-void Parse_Error(int, const char *, ...)
- __attribute__((__format__(__printf__, 2, 3)));
+void Parse_Error(int, const char *, ...) MAKE_ATTR_PRINTFLIKE(2, 3);
Boolean Parse_AnyExport(void);
Boolean Parse_IsVar(char *);
void Parse_DoVar(char *, GNode *);
-/* $NetBSD: parse.c,v 1.182 2012/03/31 00:12:24 christos Exp $ */
+/* $NetBSD: parse.c,v 1.185 2012/06/12 19:21:51 joerg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: parse.c,v 1.182 2012/03/31 00:12:24 christos Exp $";
+static char rcsid[] = "$NetBSD: parse.c,v 1.185 2012/06/12 19:21:51 joerg 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.182 2012/03/31 00:12:24 christos Exp $");
+__RCSID("$NetBSD: parse.c,v 1.185 2012/06/12 19:21:51 joerg Exp $");
#endif
#endif /* not lint */
#endif
static int ParseIsEscaped(const char *, const char *);
static void ParseErrorInternal(const char *, size_t, int, const char *, ...)
- __attribute__((__format__(__printf__, 4, 5)));
+ MAKE_ATTR_PRINTFLIKE(4,5);
static void ParseVErrorInternal(FILE *, const char *, size_t, int, const char *, va_list)
- __attribute__((__format__(__printf__, 5, 0)));
+ MAKE_ATTR_PRINTFLIKE(5, 0);
static int ParseFindKeyword(const char *);
static int ParseLinkSrc(void *, void *);
static int ParseDoOp(void *, void *);
return lf->buf;
}
+#ifndef __minix
/*
* Try to get the size of a file.
*/
*ret = (size_t) st.st_size;
return SUCCESS;
}
+#endif /* ndef __minix */
/*
* Read in a file.
loadfile(const char *path, int fd)
{
struct loadedfile *lf;
+#ifndef __minix
long pagesize;
+#endif
ssize_t result;
size_t bufpos;
}
}
#endif
+
/* cannot mmap; load the traditional way */
lf->maplen = 0;
lf->buf = bmake_realloc(lf->buf, lf->len);
}
+#ifndef __minix
done:
+#endif /* !defined(__minix) */
if (path != NULL) {
close(fd);
}
}
#endif
-#ifdef SYSVINCLUDE
+#ifdef GMAKEEXPORT
/*-
*---------------------------------------------------------------------
* ParseGmakeExport --
char *value;
if (DEBUG(PARSE)) {
- fprintf(debug_file, "ParseTraditionalInclude: %s\n", variable);
+ fprintf(debug_file, "ParseGmakeExport: %s\n", variable);
}
/*
if (*value != '=') {
Parse_Error(PARSE_FATAL,
- "Variable/Value missing from \"include\"");
+ "Variable/Value missing from \"export\"");
return;
}
/*
- * Substitute for any variables in the file name before trying to
- * find the thing.
+ * Expand the value before putting it in the environment.
*/
value = Var_Subst(NULL, value, VAR_CMD, FALSE);
setenv(variable, value, 1);
isspace((unsigned char) line[6]) &&
strchr(line, ':') == NULL) {
/*
- * It's an Gmake"export".
+ * It's a Gmake "export".
*/
ParseGmakeExport(line);
continue;
-/* $NetBSD: targ.c,v 1.56 2010/11/25 21:31:09 christos Exp $ */
+/* $NetBSD: targ.c,v 1.57 2012/06/12 19:21:51 joerg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: targ.c,v 1.56 2010/11/25 21:31:09 christos Exp $";
+static char rcsid[] = "$NetBSD: targ.c,v 1.57 2012/06/12 19:21:51 joerg 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.56 2010/11/25 21:31:09 christos Exp $");
+__RCSID("$NetBSD: targ.c,v 1.57 2012/06/12 19:21:51 joerg Exp $");
#endif
#endif /* not lint */
#endif
}
static int
-TargPrintName(void *gnp, void *pflags __unused)
+TargPrintName(void *gnp, void *pflags MAKE_ATTR_UNUSED)
{
GNode *gn = (GNode *)gnp;
*-----------------------------------------------------------------------
*/
static int
-TargPrintOnlySrc(void *gnp, void *dummy __unused)
+TargPrintOnlySrc(void *gnp, void *dummy MAKE_ATTR_UNUSED)
{
GNode *gn = (GNode *)gnp;
if (!OP_NOP(gn->type))
*-----------------------------------------------------------------------
*/
static int
-TargPropagateNode(void *gnp, void *junk __unused)
+TargPropagateNode(void *gnp, void *junk MAKE_ATTR_UNUSED)
{
GNode *gn = (GNode *)gnp;
-# $NetBSD: Makefile,v 1.33 2011/09/29 23:38:04 sjg Exp $
+# $NetBSD: Makefile,v 1.34 2012/06/19 23:25:53 sjg Exp $
#
# Unit tests for make(1)
# The main targets are:
export-all \
doterror \
dotwait \
+ forloop \
forsubst \
hash \
misc \
--- /dev/null
+# $Id: forloop,v 1.1 2012/06/19 23:25:53 sjg Exp $
+
+all: for-loop
+
+LIST = one "two and three" four "five"
+
+.if make(for-fail)
+for-fail:
+
+XTRA_LIST = xtra
+.else
+
+.for x in ${LIST}
+X!= echo 'x=$x' >&2; echo
+.endfor
+
+CFL = -I/this -I"This or that" -Ithat "-DTHIS=\"this and that\""
+cfl=
+.for x in ${CFL}
+X!= echo 'x=$x' >&2; echo
+.if empty(cfl)
+cfl= $x
+.else
+cfl+= $x
+.endif
+.endfor
+X!= echo 'cfl=${cfl}' >&2; echo
+
+.if ${cfl} != ${CFL}
+.error ${.newline}'${cfl}' != ${.newline}'${CFL}'
+.endif
+
+.for a b in ${EMPTY}
+X!= echo 'a=$a b=$b' >&2; echo
+.endfor
+.endif
+
+.for a b in ${LIST} ${LIST:tu} ${XTRA_LIST}
+X!= echo 'a=$a b=$b' >&2; echo
+.endfor
+
+for-loop:
+ @echo We expect an error next:
+ @(cd ${.CURDIR} && ${.MAKE} -f ${MAKEFILE} for-fail) && \
+ { echo "Oops that should have failed!"; exit 1; } || echo OK
make: Graph cycles through `cycle.2.97'
cycle.1.99
cycle.1.99
+x=one
+x="two and three"
+x=four
+x="five"
+x=-I/this
+x=-I"This or that"
+x=-Ithat
+x="-DTHIS=\"this and that\""
+cfl=-I/this -I"This or that" -Ithat "-DTHIS=\"this and that\""
+a=one b="two and three"
+a=four b="five"
+a=ONE b="TWO AND THREE"
+a=FOUR b="FIVE"
+We expect an error next:
+make: "forloop" line 38: Wrong number of words (9) in .for substitution list with 2 vars
+make: Fatal errors encountered -- cannot continue
+make: stopped in unit-tests
+OK
.for with :S;... OK
b2af338b
3360ac65
-/* $NetBSD: util.c,v 1.51 2011/04/02 07:58:30 mbalmer Exp $ */
+/* $NetBSD: util.c,v 1.53 2012/06/04 22:45:05 sjg Exp $ */
/*
* Missing stuff from OS's
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: util.c,v 1.51 2011/04/02 07:58:30 mbalmer Exp $";
+static char rcsid[] = "$NetBSD: util.c,v 1.53 2012/06/04 22:45:05 sjg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: util.c,v 1.51 2011/04/02 07:58:30 mbalmer Exp $");
+__RCSID("$NetBSD: util.c,v 1.53 2012/06/04 22:45:05 sjg Exp $");
#endif
#endif
size_t i, len;
char *p, *q;
+ len = strlen(name);
for (i = 0; (q = environ[i]); i++) {
p = strchr(q, '=');
- if (p == NULL)
+ if (p == NULL || p - q != len)
continue;
- if (strncmp(name, q, len = p - q) == 0) {
+ if (strncmp(name, q, len) == 0) {
*offset = i;
return q + len + 1;
}
return NULL;
}
+char *
+getenv(const char *name)
+{
+ int offset;
+
+ return(findenv(name, &offset));
+}
+
int
unsetenv(const char *name)
{
int
setenv(const char *name, const char *value, int rewrite)
{
- static char **saveenv; /* copy of previously allocated space */
char *c, **newenv;
const char *cc;
size_t l_value, size;
goto copy;
} else { /* create new slot */
size = sizeof(char *) * (offset + 2);
- if (saveenv == environ) { /* just increase size */
- if ((newenv = realloc(saveenv, size)) == NULL)
+ if (savedEnv == environ) { /* just increase size */
+ if ((newenv = realloc(savedEnv, size)) == NULL)
return -1;
- saveenv = newenv;
+ savedEnv = newenv;
} else { /* get new space */
/*
* We don't free here because we don't know if
* the first allocation is valid on all OS's
*/
- if ((saveenv = malloc(size)) == NULL)
+ if ((savedEnv = malloc(size)) == NULL)
return -1;
- (void)memcpy(saveenv, environ, size - sizeof(char *));
+ (void)memcpy(savedEnv, environ, size - sizeof(char *));
}
- environ = saveenv;
+ environ = savedEnv;
environ[offset + 1] = NULL;
}
for (cc = name; *cc && *cc != '='; ++cc) /* no `=' in name */
-/* $NetBSD: var.c,v 1.167 2011/06/03 21:10:42 sjg Exp $ */
+/* $NetBSD: var.c,v 1.171 2012/06/12 19:21:51 joerg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.167 2011/06/03 21:10:42 sjg Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.171 2012/06/12 19:21:51 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.167 2011/06/03 21:10:42 sjg Exp $");
+__RCSID("$NetBSD: var.c,v 1.171 2012/06/12 19:21:51 joerg Exp $");
#endif
#endif /* not lint */
#endif
#include "dir.h"
#include "job.h"
+/*
+ * This lets us tell if we have replaced the original environ
+ * (which we cannot free).
+ */
+char **savedEnv = NULL;
+
/*
* This is a harmless return value for Var_Parse that can be used by Var_Subst
* to determine if there was an error in parsing -- easier than returning
/*
* This is called when .unexport[-env] is seen.
*/
+extern char **environ;
+
void
Var_UnExport(char *str)
{
str += 8;
unexport_env = (strncmp(str, "-env", 4) == 0);
if (unexport_env) {
- extern char **environ;
- static char **savenv;
char **newenv;
cp = getenv(MAKE_LEVEL); /* we should preserve this */
- if (environ == savenv) {
+ if (environ == savedEnv) {
/* we have been here before! */
newenv = bmake_realloc(environ, 2 * sizeof(char *));
} else {
- if (savenv) {
- free(savenv);
- savenv = NULL;
+ if (savedEnv) {
+ free(savedEnv);
+ savedEnv = NULL;
}
newenv = bmake_malloc(2 * sizeof(char *));
}
if (!newenv)
return;
/* Note: we cannot safely free() the original environ. */
- environ = savenv = newenv;
+ environ = savedEnv = newenv;
newenv[0] = NULL;
newenv[1] = NULL;
setenv(MAKE_LEVEL, cp, 1);
*-----------------------------------------------------------------------
*/
static Boolean
-VarHead(GNode *ctx __unused, Var_Parse_State *vpstate,
+VarHead(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate,
char *word, Boolean addSpace, Buffer *buf,
void *dummy)
{
*-----------------------------------------------------------------------
*/
static Boolean
-VarTail(GNode *ctx __unused, Var_Parse_State *vpstate,
+VarTail(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate,
char *word, Boolean addSpace, Buffer *buf,
void *dummy)
{
*-----------------------------------------------------------------------
*/
static Boolean
-VarSuffix(GNode *ctx __unused, Var_Parse_State *vpstate,
+VarSuffix(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate,
char *word, Boolean addSpace, Buffer *buf,
void *dummy)
{
*-----------------------------------------------------------------------
*/
static Boolean
-VarRoot(GNode *ctx __unused, Var_Parse_State *vpstate,
+VarRoot(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate,
char *word, Boolean addSpace, Buffer *buf,
void *dummy)
{
*-----------------------------------------------------------------------
*/
static Boolean
-VarMatch(GNode *ctx __unused, Var_Parse_State *vpstate,
+VarMatch(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate,
char *word, Boolean addSpace, Buffer *buf,
void *pattern)
{
*-----------------------------------------------------------------------
*/
static Boolean
-VarNoMatch(GNode *ctx __unused, Var_Parse_State *vpstate,
+VarNoMatch(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate,
char *word, Boolean addSpace, Buffer *buf,
void *pattern)
{
*-----------------------------------------------------------------------
*/
static Boolean
-VarSubstitute(GNode *ctx __unused, Var_Parse_State *vpstate,
+VarSubstitute(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate,
char *word, Boolean addSpace, Buffer *buf,
void *patternp)
{
*-----------------------------------------------------------------------
*/
static Boolean
-VarRESubstitute(GNode *ctx __unused, Var_Parse_State *vpstate __unused,
+VarRESubstitute(GNode *ctx MAKE_ATTR_UNUSED,
+ Var_Parse_State *vpstate MAKE_ATTR_UNUSED,
char *word, Boolean addSpace, Buffer *buf,
void *patternp)
{
*-----------------------------------------------------------------------
*/
static Boolean
-VarLoopExpand(GNode *ctx __unused, Var_Parse_State *vpstate __unused,
+VarLoopExpand(GNode *ctx MAKE_ATTR_UNUSED,
+ Var_Parse_State *vpstate MAKE_ATTR_UNUSED,
char *word, Boolean addSpace, Buffer *buf,
void *loopp)
{
*-----------------------------------------------------------------------
*/
static char *
-VarSelectWords(GNode *ctx __unused, Var_Parse_State *vpstate,
+VarSelectWords(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate,
const char *str, VarSelectWords_t *seldata)
{
Buffer buf; /* Buffer for the new string */
* if successful.
*/
static Boolean
-VarRealpath(GNode *ctx __unused, Var_Parse_State *vpstate,
+VarRealpath(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate,
char *word, Boolean addSpace, Buffer *buf,
- void *patternp __unused)
+ void *patternp MAKE_ATTR_UNUSED)
{
struct stat st;
char rbuf[MAXPATHLEN];
*-----------------------------------------------------------------------
*/
static char *
-VarGetPattern(GNode *ctxt, Var_Parse_State *vpstate __unused,
+VarGetPattern(GNode *ctxt, Var_Parse_State *vpstate MAKE_ATTR_UNUSED,
int errnum, const char **tstr, int delim, int *flags,
int *length, VarPattern *pattern)
{
}
}
- return Buf_Destroy(&buf, FALSE);
+ return Buf_DestroyCompact(&buf);
}
/*-