Updating usr.bin/make
Change-Id: I66b137a0368cf99267cd47a9625da8a12d8a1df7
This commit is contained in:
		
							parent
							
								
									71c7dcb9ce
								
							
						
					
					
						commit
						2bc7c627ac
					
				@ -121,7 +121,7 @@
 | 
			
		||||
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
 | 
			
		||||
 | 
			
		||||
@ -25,13 +25,7 @@ COPTS.meta.c += -DHAVE_FILEMON_H -I${FILEMON_H:H}
 | 
			
		||||
.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
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,4 @@
 | 
			
		||||
/*	$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
 | 
			
		||||
@ -69,14 +69,14 @@
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#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
 | 
			
		||||
@ -1029,7 +1029,7 @@ Arch_Touch(GNode *gn)
 | 
			
		||||
 */
 | 
			
		||||
void
 | 
			
		||||
#if !defined(RANLIBMAG)
 | 
			
		||||
Arch_TouchLib(GNode *gn __unused)
 | 
			
		||||
Arch_TouchLib(GNode *gn MAKE_ATTR_UNUSED)
 | 
			
		||||
#else
 | 
			
		||||
Arch_TouchLib(GNode *gn)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,4 @@
 | 
			
		||||
/*	$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.
 | 
			
		||||
@ -70,14 +70,14 @@
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#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
 | 
			
		||||
@ -248,3 +248,44 @@ Buf_Destroy(Buffer *buf, Boolean freeData)
 | 
			
		||||
 | 
			
		||||
    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);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,4 @@
 | 
			
		||||
/*	$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.
 | 
			
		||||
@ -114,5 +114,6 @@ Byte *Buf_GetAll(Buffer *, int *);
 | 
			
		||||
void Buf_Empty(Buffer *);
 | 
			
		||||
void Buf_Init(Buffer *, int);
 | 
			
		||||
Byte *Buf_Destroy(Buffer *, Boolean);
 | 
			
		||||
Byte *Buf_DestroyCompact(Buffer *);
 | 
			
		||||
 | 
			
		||||
#endif /* _BUF_H */
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,4 @@
 | 
			
		||||
/*	$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.
 | 
			
		||||
@ -70,14 +70,14 @@
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#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
 | 
			
		||||
@ -121,7 +121,7 @@ static char 	    meta[256];
 | 
			
		||||
 | 
			
		||||
static GNode	    *curTarg = NULL;
 | 
			
		||||
static GNode	    *ENDNode;
 | 
			
		||||
static void CompatInterrupt(int) __dead;
 | 
			
		||||
static void CompatInterrupt(int);
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
Compat_Init(void)
 | 
			
		||||
@ -180,7 +180,10 @@ CompatInterrupt(int signo)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
    exit(signo);
 | 
			
		||||
    if (signo == SIGQUIT)
 | 
			
		||||
	_exit(signo);
 | 
			
		||||
    bmake_signal(signo, SIG_DFL);
 | 
			
		||||
    kill(myPid, signo);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*-
 | 
			
		||||
@ -241,7 +244,6 @@ CompatRunCommand(void *cmdp, void *gnp)
 | 
			
		||||
 | 
			
		||||
    if (*cmdStart == '\0') {
 | 
			
		||||
	free(cmdStart);
 | 
			
		||||
	Error("%s expands to empty string", cmd);
 | 
			
		||||
	return(0);
 | 
			
		||||
    }
 | 
			
		||||
    cmd = cmdStart;
 | 
			
		||||
@ -276,6 +278,12 @@ CompatRunCommand(void *cmdp, void *gnp)
 | 
			
		||||
    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
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,4 @@
 | 
			
		||||
/*	$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.
 | 
			
		||||
@ -70,14 +70,14 @@
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#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
 | 
			
		||||
@ -327,7 +327,7 @@ CondGetArg(char **linePtr, char **argPtr, const char *func)
 | 
			
		||||
 *-----------------------------------------------------------------------
 | 
			
		||||
 */
 | 
			
		||||
static Boolean
 | 
			
		||||
CondDoDefined(int argLen __unused, const char *arg)
 | 
			
		||||
CondDoDefined(int argLen MAKE_ATTR_UNUSED, const char *arg)
 | 
			
		||||
{
 | 
			
		||||
    char    *p1;
 | 
			
		||||
    Boolean result;
 | 
			
		||||
@ -376,7 +376,7 @@ CondStrMatch(const void *string, const void *pattern)
 | 
			
		||||
 *-----------------------------------------------------------------------
 | 
			
		||||
 */
 | 
			
		||||
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;
 | 
			
		||||
}
 | 
			
		||||
@ -395,7 +395,7 @@ CondDoMake(int argLen __unused, const char *arg)
 | 
			
		||||
 *-----------------------------------------------------------------------
 | 
			
		||||
 */
 | 
			
		||||
static Boolean
 | 
			
		||||
CondDoExists(int argLen __unused, const char *arg)
 | 
			
		||||
CondDoExists(int argLen MAKE_ATTR_UNUSED, const char *arg)
 | 
			
		||||
{
 | 
			
		||||
    Boolean result;
 | 
			
		||||
    char    *path;
 | 
			
		||||
@ -428,7 +428,7 @@ CondDoExists(int argLen __unused, const char *arg)
 | 
			
		||||
 *-----------------------------------------------------------------------
 | 
			
		||||
 */
 | 
			
		||||
static Boolean
 | 
			
		||||
CondDoTarget(int argLen __unused, const char *arg)
 | 
			
		||||
CondDoTarget(int argLen MAKE_ATTR_UNUSED, const char *arg)
 | 
			
		||||
{
 | 
			
		||||
    GNode   *gn;
 | 
			
		||||
 | 
			
		||||
@ -452,7 +452,7 @@ CondDoTarget(int argLen __unused, const char *arg)
 | 
			
		||||
 *-----------------------------------------------------------------------
 | 
			
		||||
 */
 | 
			
		||||
static Boolean
 | 
			
		||||
CondDoCommands(int argLen __unused, const char *arg)
 | 
			
		||||
CondDoCommands(int argLen MAKE_ATTR_UNUSED, const char *arg)
 | 
			
		||||
{
 | 
			
		||||
    GNode   *gn;
 | 
			
		||||
 | 
			
		||||
@ -790,7 +790,7 @@ done:
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
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
 | 
			
		||||
@ -831,7 +831,7 @@ get_mpt_arg(char **linePtr, char **argPtr, const char *func __unused)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static Boolean
 | 
			
		||||
CondDoEmpty(int arglen, const char *arg __unused)
 | 
			
		||||
CondDoEmpty(int arglen, const char *arg MAKE_ATTR_UNUSED)
 | 
			
		||||
{
 | 
			
		||||
    return arglen == 1;
 | 
			
		||||
}
 | 
			
		||||
@ -1227,7 +1227,7 @@ do_Cond_EvalExpression(Boolean *value)
 | 
			
		||||
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 */
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,4 @@
 | 
			
		||||
/*	$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.
 | 
			
		||||
@ -70,14 +70,14 @@
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#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
 | 
			
		||||
@ -860,8 +860,8 @@ Dir_Expand(const char *word, Lst path, Lst expansions)
 | 
			
		||||
 *-----------------------------------------------------------------------
 | 
			
		||||
 */
 | 
			
		||||
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 */
 | 
			
		||||
 | 
			
		||||
@ -1004,7 +1004,7 @@ DirLookupAbs(Path *p, const char *name, const char *cp)
 | 
			
		||||
 *-----------------------------------------------------------------------
 | 
			
		||||
 */
 | 
			
		||||
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) {
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,4 @@
 | 
			
		||||
/*	$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.
 | 
			
		||||
@ -30,14 +30,14 @@
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#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
 | 
			
		||||
@ -151,6 +151,8 @@ For_Eval(char *line)
 | 
			
		||||
    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++)
 | 
			
		||||
@ -216,35 +218,56 @@ For_Eval(char *line)
 | 
			
		||||
     */
 | 
			
		||||
    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);
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,4 @@
 | 
			
		||||
/*	$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.
 | 
			
		||||
@ -70,14 +70,14 @@
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#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
 | 
			
		||||
@ -352,7 +352,7 @@ static int JobStart(GNode *, int);
 | 
			
		||||
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 *);
 | 
			
		||||
@ -475,7 +475,7 @@ JobCondPassSig(int signo)
 | 
			
		||||
 *-----------------------------------------------------------------------
 | 
			
		||||
 */
 | 
			
		||||
static void
 | 
			
		||||
JobChildSig(int signo __unused)
 | 
			
		||||
JobChildSig(int signo MAKE_ATTR_UNUSED)
 | 
			
		||||
{
 | 
			
		||||
    write(childExitJob.outPipe, CHILD_EXIT, 1);
 | 
			
		||||
}
 | 
			
		||||
@ -498,7 +498,7 @@ JobChildSig(int signo __unused)
 | 
			
		||||
 *-----------------------------------------------------------------------
 | 
			
		||||
 */
 | 
			
		||||
static void
 | 
			
		||||
JobContinueSig(int signo __unused)
 | 
			
		||||
JobContinueSig(int signo MAKE_ATTR_UNUSED)
 | 
			
		||||
{
 | 
			
		||||
    /*
 | 
			
		||||
     * Defer sending to SIGCONT to our stopped children until we return
 | 
			
		||||
@ -523,14 +523,14 @@ JobContinueSig(int signo __unused)
 | 
			
		||||
 *
 | 
			
		||||
 *-----------------------------------------------------------------------
 | 
			
		||||
 */
 | 
			
		||||
__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 */
 | 
			
		||||
@ -2423,7 +2423,7 @@ Job_ParseShell(char *line)
 | 
			
		||||
	 * 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");
 | 
			
		||||
@ -2438,6 +2438,12 @@ Job_ParseShell(char *line)
 | 
			
		||||
	    }
 | 
			
		||||
	    commandShell = sh;
 | 
			
		||||
	    shellName = newShell.name;
 | 
			
		||||
	    if (shellPath) {
 | 
			
		||||
		/* Shell_Init has already been called!  Do it again. */
 | 
			
		||||
		free(UNCONST(shellPath));
 | 
			
		||||
		shellPath = NULL;
 | 
			
		||||
		Shell_Init();
 | 
			
		||||
	    }
 | 
			
		||||
	}
 | 
			
		||||
    } else {
 | 
			
		||||
	/*
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,4 @@
 | 
			
		||||
/*	$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
 | 
			
		||||
@ -69,7 +69,7 @@
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#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
 | 
			
		||||
@ -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.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
 | 
			
		||||
@ -159,6 +159,7 @@ int			maxJobs;	/* -j argument */
 | 
			
		||||
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 */
 | 
			
		||||
@ -178,7 +179,7 @@ static const char *	tracefile;
 | 
			
		||||
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 */
 | 
			
		||||
@ -260,6 +261,9 @@ parse_debug_options(const char *argvalue)
 | 
			
		||||
		case 't':
 | 
			
		||||
			debug |= DEBUG_TARG;
 | 
			
		||||
			break;
 | 
			
		||||
		case 'V':
 | 
			
		||||
			debugVflag = TRUE;
 | 
			
		||||
			break;
 | 
			
		||||
		case 'v':
 | 
			
		||||
			debug |= DEBUG_VAR;
 | 
			
		||||
			break;
 | 
			
		||||
@ -269,9 +273,10 @@ parse_debug_options(const char *argvalue)
 | 
			
		||||
		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;
 | 
			
		||||
@ -706,7 +711,7 @@ str2Lst_Append(Lst lp, char *str, const char *sep)
 | 
			
		||||
#ifdef SIGINFO
 | 
			
		||||
/*ARGSUSED*/
 | 
			
		||||
static void
 | 
			
		||||
siginfo(int signo __unused)
 | 
			
		||||
siginfo(int signo MAKE_ATTR_UNUSED)
 | 
			
		||||
{
 | 
			
		||||
	char dir[MAXPATHLEN];
 | 
			
		||||
	char str[2 * MAXPATHLEN];
 | 
			
		||||
@ -876,6 +881,7 @@ main(int argc, char **argv)
 | 
			
		||||
	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 */
 | 
			
		||||
@ -1213,7 +1219,12 @@ main(int argc, char **argv)
 | 
			
		||||
	/* 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);
 | 
			
		||||
@ -1221,6 +1232,13 @@ main(int argc, char **argv)
 | 
			
		||||
			
 | 
			
		||||
			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);
 | 
			
		||||
			}
 | 
			
		||||
@ -1300,7 +1318,7 @@ main(int argc, char **argv)
 | 
			
		||||
 *	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;
 | 
			
		||||
@ -2018,3 +2036,49 @@ mkTempFile(const char *pattern, char **fnamep)
 | 
			
		||||
    }
 | 
			
		||||
    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);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,4 @@
 | 
			
		||||
.\"	$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.
 | 
			
		||||
@ -29,7 +29,7 @@
 | 
			
		||||
.\"
 | 
			
		||||
.\"	from: @(#)make.1	8.4 (Berkeley) 3/19/94
 | 
			
		||||
.\"
 | 
			
		||||
.Dd March 31, 2012
 | 
			
		||||
.Dd October 8, 2012
 | 
			
		||||
.Dt MAKE 1
 | 
			
		||||
.Os
 | 
			
		||||
.Sh NAME
 | 
			
		||||
@ -203,6 +203,10 @@ Print debugging information about makefile parsing.
 | 
			
		||||
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
 | 
			
		||||
@ -675,6 +679,10 @@ and cannot be confused with the special target with the same name.
 | 
			
		||||
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 .
 | 
			
		||||
@ -2034,6 +2042,13 @@ or
 | 
			
		||||
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
 | 
			
		||||
@ -2044,7 +2059,7 @@ command appeared in
 | 
			
		||||
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 .
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,4 @@
 | 
			
		||||
/*	$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
 | 
			
		||||
@ -69,14 +69,14 @@
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#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
 | 
			
		||||
@ -139,7 +139,7 @@ static int MakeCheckOrder(void *, void *);
 | 
			
		||||
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;
 | 
			
		||||
@ -221,7 +221,7 @@ Make_OODate(GNode *gn)
 | 
			
		||||
     * 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));
 | 
			
		||||
@ -867,7 +867,7 @@ Make_Update(GNode *cgn)
 | 
			
		||||
 *-----------------------------------------------------------------------
 | 
			
		||||
 */
 | 
			
		||||
static int
 | 
			
		||||
MakeUnmark(void *cgnp, void *pgnp __unused)
 | 
			
		||||
MakeUnmark(void *cgnp, void *pgnp MAKE_ATTR_UNUSED)
 | 
			
		||||
{
 | 
			
		||||
    GNode	*cgn = (GNode *)cgnp;
 | 
			
		||||
 | 
			
		||||
@ -1005,7 +1005,7 @@ Make_DoAllVar(GNode *gn)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
static int
 | 
			
		||||
MakeCheckOrder(void *v_bn, void *ignore __unused)
 | 
			
		||||
MakeCheckOrder(void *v_bn, void *ignore MAKE_ATTR_UNUSED)
 | 
			
		||||
{
 | 
			
		||||
    GNode *bn = v_bn;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,4 @@
 | 
			
		||||
/*	$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
 | 
			
		||||
@ -93,26 +93,33 @@
 | 
			
		||||
# 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 */
 | 
			
		||||
#endif
 | 
			
		||||
#define	MAKE_ATTR_UNUSED	/* delete */
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if !defined(__dead)
 | 
			
		||||
#define __dead
 | 
			
		||||
#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 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"
 | 
			
		||||
@ -401,6 +408,7 @@ extern Lst	defIncPath;	/* The default include path. */
 | 
			
		||||
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().
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,4 @@
 | 
			
		||||
/*	$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.
 | 
			
		||||
@ -28,7 +28,7 @@
 | 
			
		||||
 | 
			
		||||
#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>
 | 
			
		||||
@ -36,9 +36,11 @@ __RCSID("$NetBSD: make_malloc.c,v 1.6 2010/12/25 20:35:25 dholland Exp $");
 | 
			
		||||
#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.
 | 
			
		||||
@ -46,8 +48,6 @@ __RCSID("$NetBSD: make_malloc.c,v 1.6 2010/12/25 20:35:25 dholland Exp $");
 | 
			
		||||
static void
 | 
			
		||||
enomem(void)
 | 
			
		||||
{
 | 
			
		||||
	extern char *progname;
 | 
			
		||||
 | 
			
		||||
	(void)fprintf(stderr, "%s: %s.\n", progname, strerror(ENOMEM));
 | 
			
		||||
	exit(2);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,4 @@
 | 
			
		||||
/*      $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.
 | 
			
		||||
@ -68,6 +68,7 @@ static Boolean metaSilent = FALSE;	/* if we have a .meta be SILENT */
 | 
			
		||||
 | 
			
		||||
extern Boolean forceJobs;
 | 
			
		||||
extern Boolean comatMake;
 | 
			
		||||
extern char    **environ;
 | 
			
		||||
 | 
			
		||||
#define	MAKE_META_PREFIX	".MAKE.META.PREFIX"
 | 
			
		||||
 | 
			
		||||
@ -388,7 +389,6 @@ printCMD(void *cmdp, void *mfpp)
 | 
			
		||||
static FILE *
 | 
			
		||||
meta_create(BuildMon *pbm, GNode *gn)
 | 
			
		||||
{
 | 
			
		||||
    extern char **environ;
 | 
			
		||||
    meta_file_t mf;
 | 
			
		||||
    char buf[MAXPATHLEN];
 | 
			
		||||
    char objdir[MAXPATHLEN];
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,4 @@
 | 
			
		||||
/*	$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
 | 
			
		||||
@ -72,11 +72,6 @@
 | 
			
		||||
 *	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 *);
 | 
			
		||||
@ -114,21 +109,19 @@ void Main_ParseArgLine(const char *);
 | 
			
		||||
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 *);
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,4 @@
 | 
			
		||||
/*	$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
 | 
			
		||||
@ -69,14 +69,14 @@
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#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
 | 
			
		||||
@ -344,9 +344,9 @@ static const struct {
 | 
			
		||||
 | 
			
		||||
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 *);
 | 
			
		||||
@ -430,6 +430,7 @@ loadedfile_nextbuf(void *x, size_t *len)
 | 
			
		||||
	return lf->buf;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#ifndef __minix
 | 
			
		||||
/*
 | 
			
		||||
 * Try to get the size of a file.
 | 
			
		||||
 */
 | 
			
		||||
@ -462,6 +463,7 @@ load_getsize(int fd, size_t *ret)
 | 
			
		||||
	*ret = (size_t) st.st_size;
 | 
			
		||||
	return SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
#endif /* ndef __minix */
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Read in a file.
 | 
			
		||||
@ -477,7 +479,9 @@ static struct loadedfile *
 | 
			
		||||
loadfile(const char *path, int fd)
 | 
			
		||||
{
 | 
			
		||||
	struct loadedfile *lf;
 | 
			
		||||
#ifndef __minix
 | 
			
		||||
	long pagesize;
 | 
			
		||||
#endif
 | 
			
		||||
	ssize_t result;
 | 
			
		||||
	size_t bufpos;
 | 
			
		||||
 | 
			
		||||
@ -536,6 +540,7 @@ loadfile(const char *path, int fd)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	/* cannot mmap; load the traditional way */
 | 
			
		||||
 | 
			
		||||
	lf->maplen = 0;
 | 
			
		||||
@ -567,7 +572,9 @@ loadfile(const char *path, int fd)
 | 
			
		||||
		lf->buf = bmake_realloc(lf->buf, lf->len);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
#ifndef __minix
 | 
			
		||||
done:
 | 
			
		||||
#endif /* !defined(__minix) */
 | 
			
		||||
	if (path != NULL) {
 | 
			
		||||
		close(fd);
 | 
			
		||||
	}
 | 
			
		||||
@ -2408,7 +2415,7 @@ ParseTraditionalInclude(char *line)
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef SYSVINCLUDE
 | 
			
		||||
#ifdef GMAKEEXPORT
 | 
			
		||||
/*-
 | 
			
		||||
 *---------------------------------------------------------------------
 | 
			
		||||
 * ParseGmakeExport  --
 | 
			
		||||
@ -2430,7 +2437,7 @@ ParseGmakeExport(char *line)
 | 
			
		||||
    char	  *value;
 | 
			
		||||
 | 
			
		||||
    if (DEBUG(PARSE)) {
 | 
			
		||||
	    fprintf(debug_file, "ParseTraditionalInclude: %s\n", variable);
 | 
			
		||||
	    fprintf(debug_file, "ParseGmakeExport: %s\n", variable);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /*
 | 
			
		||||
@ -2444,13 +2451,12 @@ ParseGmakeExport(char *line)
 | 
			
		||||
 | 
			
		||||
    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);
 | 
			
		||||
@ -2911,7 +2917,7 @@ Parse_File(const char *name, int fd)
 | 
			
		||||
		isspace((unsigned char) line[6]) &&
 | 
			
		||||
		strchr(line, ':') == NULL) {
 | 
			
		||||
		/*
 | 
			
		||||
		 * It's an Gmake"export".
 | 
			
		||||
		 * It's a Gmake "export".
 | 
			
		||||
		 */
 | 
			
		||||
		ParseGmakeExport(line);
 | 
			
		||||
		continue;
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,4 @@
 | 
			
		||||
/*	$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
 | 
			
		||||
@ -69,14 +69,14 @@
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#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
 | 
			
		||||
@ -512,7 +512,7 @@ Targ_SetMain(GNode *gn)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int
 | 
			
		||||
TargPrintName(void *gnp, void *pflags __unused)
 | 
			
		||||
TargPrintName(void *gnp, void *pflags MAKE_ATTR_UNUSED)
 | 
			
		||||
{
 | 
			
		||||
    GNode *gn = (GNode *)gnp;
 | 
			
		||||
 | 
			
		||||
@ -717,7 +717,7 @@ Targ_PrintNode(void *gnp, void *passp)
 | 
			
		||||
 *-----------------------------------------------------------------------
 | 
			
		||||
 */
 | 
			
		||||
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))
 | 
			
		||||
@ -790,7 +790,7 @@ Targ_PrintGraph(int pass)
 | 
			
		||||
 *-----------------------------------------------------------------------
 | 
			
		||||
 */
 | 
			
		||||
static int
 | 
			
		||||
TargPropagateNode(void *gnp, void *junk __unused)
 | 
			
		||||
TargPropagateNode(void *gnp, void *junk MAKE_ATTR_UNUSED)
 | 
			
		||||
{
 | 
			
		||||
    GNode	  *gn = (GNode *)gnp;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,4 @@
 | 
			
		||||
# $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:
 | 
			
		||||
@ -26,6 +26,7 @@ SUBFILES= \
 | 
			
		||||
	export-all \
 | 
			
		||||
	doterror \
 | 
			
		||||
	dotwait \
 | 
			
		||||
	forloop \
 | 
			
		||||
	forsubst \
 | 
			
		||||
	hash \
 | 
			
		||||
	misc \
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										45
									
								
								usr.bin/make/unit-tests/forloop
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								usr.bin/make/unit-tests/forloop
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,45 @@
 | 
			
		||||
# $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
 | 
			
		||||
@ -80,6 +80,24 @@ make: Graph cycles through `cycle.2.98'
 | 
			
		||||
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
 | 
			
		||||
 | 
			
		||||
@ -1,15 +1,15 @@
 | 
			
		||||
/*	$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
 | 
			
		||||
 | 
			
		||||
@ -48,11 +48,12 @@ findenv(const char *name, int *offset)
 | 
			
		||||
	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;
 | 
			
		||||
		}
 | 
			
		||||
@ -61,6 +62,14 @@ findenv(const char *name, int *offset)
 | 
			
		||||
	return NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
char *
 | 
			
		||||
getenv(const char *name)
 | 
			
		||||
{
 | 
			
		||||
    int offset;
 | 
			
		||||
 | 
			
		||||
    return(findenv(name, &offset));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
unsetenv(const char *name)
 | 
			
		||||
{
 | 
			
		||||
@ -83,7 +92,6 @@ 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;
 | 
			
		||||
@ -106,20 +114,20 @@ setenv(const char *name, const char *value, int rewrite)
 | 
			
		||||
			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 */
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,4 @@
 | 
			
		||||
/*	$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
 | 
			
		||||
@ -69,14 +69,14 @@
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#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
 | 
			
		||||
@ -139,6 +139,12 @@ __RCSID("$NetBSD: var.c,v 1.167 2011/06/03 21:10:42 sjg Exp $");
 | 
			
		||||
#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
 | 
			
		||||
@ -742,6 +748,8 @@ Var_Export(char *str, int isExport)
 | 
			
		||||
/*
 | 
			
		||||
 * This is called when .unexport[-env] is seen.
 | 
			
		||||
 */
 | 
			
		||||
extern char **environ;
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
Var_UnExport(char *str)
 | 
			
		||||
{
 | 
			
		||||
@ -760,25 +768,23 @@ 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);
 | 
			
		||||
@ -1133,7 +1139,7 @@ Var_Value(const char *name, GNode *ctxt, char **frp)
 | 
			
		||||
 *-----------------------------------------------------------------------
 | 
			
		||||
 */
 | 
			
		||||
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)
 | 
			
		||||
{
 | 
			
		||||
@ -1181,7 +1187,7 @@ VarHead(GNode *ctx __unused, Var_Parse_State *vpstate,
 | 
			
		||||
 *-----------------------------------------------------------------------
 | 
			
		||||
 */
 | 
			
		||||
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)
 | 
			
		||||
{
 | 
			
		||||
@ -1223,7 +1229,7 @@ VarTail(GNode *ctx __unused, Var_Parse_State *vpstate,
 | 
			
		||||
 *-----------------------------------------------------------------------
 | 
			
		||||
 */
 | 
			
		||||
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)
 | 
			
		||||
{
 | 
			
		||||
@ -1264,7 +1270,7 @@ VarSuffix(GNode *ctx __unused, Var_Parse_State *vpstate,
 | 
			
		||||
 *-----------------------------------------------------------------------
 | 
			
		||||
 */
 | 
			
		||||
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)
 | 
			
		||||
{
 | 
			
		||||
@ -1308,7 +1314,7 @@ VarRoot(GNode *ctx __unused, Var_Parse_State *vpstate,
 | 
			
		||||
 *-----------------------------------------------------------------------
 | 
			
		||||
 */
 | 
			
		||||
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)
 | 
			
		||||
{
 | 
			
		||||
@ -1399,7 +1405,7 @@ VarSYSVMatch(GNode *ctx, Var_Parse_State *vpstate,
 | 
			
		||||
 *-----------------------------------------------------------------------
 | 
			
		||||
 */
 | 
			
		||||
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)
 | 
			
		||||
{
 | 
			
		||||
@ -1436,7 +1442,7 @@ VarNoMatch(GNode *ctx __unused, Var_Parse_State *vpstate,
 | 
			
		||||
 *-----------------------------------------------------------------------
 | 
			
		||||
 */
 | 
			
		||||
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)
 | 
			
		||||
{
 | 
			
		||||
@ -1632,7 +1638,8 @@ VarREError(int errnum, regex_t *pat, const char *str)
 | 
			
		||||
 *-----------------------------------------------------------------------
 | 
			
		||||
 */
 | 
			
		||||
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)
 | 
			
		||||
{
 | 
			
		||||
@ -1772,7 +1779,8 @@ VarRESubstitute(GNode *ctx __unused, Var_Parse_State *vpstate __unused,
 | 
			
		||||
 *-----------------------------------------------------------------------
 | 
			
		||||
 */
 | 
			
		||||
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)
 | 
			
		||||
{
 | 
			
		||||
@ -1815,7 +1823,7 @@ VarLoopExpand(GNode *ctx __unused, Var_Parse_State *vpstate __unused,
 | 
			
		||||
 *-----------------------------------------------------------------------
 | 
			
		||||
 */
 | 
			
		||||
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 */
 | 
			
		||||
@ -1890,9 +1898,9 @@ VarSelectWords(GNode *ctx __unused, Var_Parse_State *vpstate,
 | 
			
		||||
 *	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];
 | 
			
		||||
@ -2115,7 +2123,7 @@ VarUniq(const char *str)
 | 
			
		||||
 *-----------------------------------------------------------------------
 | 
			
		||||
 */
 | 
			
		||||
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)
 | 
			
		||||
{
 | 
			
		||||
@ -4075,7 +4083,7 @@ Var_Subst(const char *var, const char *str, GNode *ctxt, Boolean undefErr)
 | 
			
		||||
	}
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return Buf_Destroy(&buf, FALSE);
 | 
			
		||||
    return Buf_DestroyCompact(&buf);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*-
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user