Import the 20-June-2012 release of the "Portable" BSD make tool (from NetBSD).

Submitted by:	sjg@juniper.net
This commit is contained in:
David E. O'Brien 2012-06-25 22:20:51 +00:00
parent b379932fc0
commit 0fae4a3feb
22 changed files with 231 additions and 123 deletions

View File

@ -1,3 +1,24 @@
2012-06-20 Simon J. Gerraty <sjg@bad.crufty.net>
* Makefile.in (MAKE_VERSION): bump version to 20120620
Merge with NetBSD make, pick up
o make_malloc.c: avoid including make_malloc.h again
* Makefile.in: avoid bmake only syntax or protect with
.if defined(.MAKE.LEVEL)
* bsd.after-import.mk: replace .-include with .sinclude
ensure? SRCTOP gets a value
* configure.in: look for filemon.h in /usr/include/dev/filemon first.
2012-06-19 Simon J. Gerraty <sjg@bad.crufty.net>
* Makefile.in (MAKE_VERSION): bump version to 20120612
Merge with NetBSD make, pick up
o use MAKE_ATTR_* rather than those defined by cdefs.h or compiler
for greater portability.
o unit-tests/forloop: check that .for works as expected wrt
number of times and with "quoted strings".
2012-06-06 Simon J. Gerraty <sjg@bad.crufty.net>
* Makefile.in (MAKE_VERSION): bump version to 20120606

1
FILES
View File

@ -100,6 +100,7 @@ unit-tests/dotwait
unit-tests/error
unit-tests/export
unit-tests/export-all
unit-tests/forloop
unit-tests/forsubst
unit-tests/hash
unit-tests/misc

View File

@ -1,7 +1,7 @@
# $NetBSD: Makefile,v 1.56 2012/05/30 21:54:23 sjg Exp $
# @(#)Makefile 5.2 (Berkeley) 12/28/90
# $Id: Makefile.in,v 1.161 2012/06/06 20:02:32 sjg Exp $
# $Id: Makefile.in,v 1.164 2012/06/20 22:44:26 sjg Exp $
PROG= bmake
SRCS= arch.c buf.c compat.c cond.c dir.c for.c hash.c job.c main.c \
@ -21,7 +21,7 @@ srcdir= @srcdir@
CC?= @CC@
# Base version on src date
MAKE_VERSION= 20120606
MAKE_VERSION= 20120620
MACHINE=@machine@
MACHINE_ARCH=@machine_arch@
DEFAULT_SYS_PATH = @default_sys_path@
@ -40,7 +40,7 @@ SRCS+= ${LIBOBJS:T:.o=.c}
.endif
USE_META ?= @use_meta@
.if ${USE_META:tl} != "no"
.if ${USE_META} != "no"
SRCS+= meta.c
CPPFLAGS+= -DUSE_META
FILEMON_H ?= @filemon_h@
@ -83,9 +83,11 @@ SRCS+= sigcompat.c
CFLAGS+= -DSIGNAL_FLAGS=SA_RESTART
.endif
.endif
.if defined(.MAKE.LEVEL)
.if make(obj) || make(clean)
SUBDIR+= unit-tests
.endif
.endif
# many systems use gcc these days
CC_IS_GCC=@GCC@
@ -132,9 +134,11 @@ _mfromdir=${srcdir}
# sigh, FreeBSD at least includes bsd.subdir.mk via bsd.obj.mk
# so the inclusion below, results in complaints about re-defined
# targets. For NetBSD though we need to explicitly include it.
.if defined(.MAKE.LEVEL)
.if defined(SUBDIR) && !target(${SUBDIR:[1]})
.-include <bsd.subdir.mk>
.endif
.endif
CPPFLAGS+= -DMAKE_NATIVE
COPTS.var.c += -Wno-cast-qual

8
arch.c
View File

@ -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
@ -1077,7 +1077,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

View File

@ -1,4 +1,4 @@
# $Id: bsd.after-import.mk,v 1.3 2012/06/06 17:48:14 sjg Exp $
# $Id: bsd.after-import.mk,v 1.5 2012/06/20 22:45:07 sjg Exp $
# This makefile is for use when integrating bmake into a BSD build
# system. Use this makefile after importing bmake.
@ -13,12 +13,24 @@ all: ${.CURDIR}/Makefile
all: after-import
# we rely on bmake
.if !defined(.MAKE.LEVEL)
.error this makefile requires bmake
.endif
_this := ${MAKEFILE:tA}
BMAKE_SRC := ${.PARSEDIR}
# it helps to know where the top of the tree is.
.if !defined(SRCTOP)
srctop := ${.MAKE.MAKEFILES:M*src/share/mk/sys.mk:H:H:H}
.if empty(srctop)
# likely locations?
.for d in contrib/bmake external/bsd/bmake/dist
.if ${BMAKE_SRC:M*/$d} != ""
srctop := ${BMAKE_SRC:tA:S,/$d,,}
.endif
.endfor
.endif
.if !empty(srctop)
SRCTOP := ${srctop}
.endif
@ -47,6 +59,7 @@ bootstrap: ${BMAKE_SRC}/boot-strap ${MAKEFILE}
# Makefiles need a little more tweaking than say config.h
MAKEFILE_SED = sed -e '/^MACHINE/d' \
-e '/^PROG/s,bmake,${.CURDIR:T},' \
-e 's,^.-include,.sinclude,' \
-e 's,${SRCTOP},$${SRCTOP},g'
# These are the simple files we want to capture
@ -55,11 +68,13 @@ configured_files= config.h unit-tests/Makefile
after-import: bootstrap ${MAKEFILE}
.for f in ${configured_files:N*Makefile}
@echo Capturing $f
@mkdir -p ${${.CURDIR}/$f:L:H}
@cmp -s ${.CURDIR}/$f ${HOST_OS}/$f || \
cp ${HOST_OS}/$f ${.CURDIR}/$f
.endfor
.for f in ${configured_files:M*Makefile}
@echo Capturing $f
@mkdir -p ${${.CURDIR}/$f:L:H}
@${MAKEFILE_SED} ${HOST_OS}/$f > ${.CURDIR}/$f
.endfor
@ -68,6 +83,8 @@ ${.CURDIR}/Makefile: bootstrap ${MAKEFILE} .PRECIOUS
@echo Generating ${.TARGET:T}
@(echo '# This is a generated file, do NOT edit!'; \
echo '# See ${_this:S,${SRCTOP}/,,}'; \
echo '#'; echo '# $$${OS}$$'; echo; \
echo 'SRCTOP?= $${.CURDIR:${.CURDIR:S,${SRCTOP}/,,:C,[^/]+,H,g:S,/,:,g}}'; echo; \
echo; echo '# look here first for config.h'; \
echo 'CFLAGS+= -I$${.CURDIR}'; echo; \
${MAKEFILE_SED} ${HOST_OS}/Makefile; \
@ -79,7 +96,7 @@ ${.CURDIR}/Makefile: bootstrap ${MAKEFILE} .PRECIOUS
echo 'CLEANFILES+= bootstrap'; \
echo; echo 'after-import: ${_this:S,${SRCTOP},\${SRCTOP},}'; \
echo ' cd $${.CURDIR} && $${.MAKE} -f ${_this:S,${SRCTOP},\${SRCTOP},}'; \
echo; echo '.-include "Makefile.inc"'; \
echo; echo '.sinclude "Makefile.inc"'; \
echo ) > ${.TARGET:T}.new
@mv ${.TARGET:T}.new ${.TARGET}

View File

@ -1,4 +1,4 @@
/* $NetBSD: compat.c,v 1.88 2012/06/05 17:31:04 sjg Exp $ */
/* $NetBSD: compat.c,v 1.89 2012/06/10 21:44:01 wiz 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.88 2012/06/05 17:31:04 sjg Exp $";
static char rcsid[] = "$NetBSD: compat.c,v 1.89 2012/06/10 21:44:01 wiz 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.88 2012/06/05 17:31:04 sjg Exp $");
__RCSID("$NetBSD: compat.c,v 1.89 2012/06/10 21:44:01 wiz Exp $");
#endif
#endif /* not lint */
#endif
@ -124,7 +124,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)

20
cond.c
View File

@ -1,4 +1,4 @@
/* $NetBSD: cond.c,v 1.63 2012/05/21 06:30:02 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.63 2012/05/21 06:30:02 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.63 2012/05/21 06:30:02 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 @@ compare_expression(Boolean doEval)
}
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;
}

20
configure vendored
View File

@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.64 for bmake 20120606.
# Generated by GNU Autoconf 2.64 for bmake 20120620.
#
# Report bugs to <sjg@NetBSD.org>.
#
@ -549,8 +549,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='bmake'
PACKAGE_TARNAME='bmake'
PACKAGE_VERSION='20120606'
PACKAGE_STRING='bmake 20120606'
PACKAGE_VERSION='20120620'
PACKAGE_STRING='bmake 20120620'
PACKAGE_BUGREPORT='sjg@NetBSD.org'
PACKAGE_URL=''
@ -1220,7 +1220,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures bmake 20120606 to adapt to many kinds of systems.
\`configure' configures bmake 20120620 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@ -1281,7 +1281,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of bmake 20120606:";;
short | recursive ) echo "Configuration of bmake 20120620:";;
esac
cat <<\_ACEOF
@ -1386,7 +1386,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
bmake configure 20120606
bmake configure 20120620
generated by GNU Autoconf 2.64
Copyright (C) 2009 Free Software Foundation, Inc.
@ -1907,7 +1907,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by bmake $as_me 20120606, which was
It was created by bmake $as_me 20120620, which was
generated by GNU Autoconf 2.64. Invocation command line was
$ $0 $@
@ -2294,7 +2294,7 @@ esac
else
OS=`uname -s`
for d in "$srcdir/filemon" "$srcdir/../filemon" "$srcdir/../../sys/dev/filemon"
for d in "/usr/include/dev/filemon" "$prefix/include/dev/filemon" "$srcdir/filemon" "$srcdir/../filemon" "$srcdir/../../sys/dev/filemon"
do
for x in "/$OS" ""
do
@ -6369,7 +6369,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by bmake $as_me 20120606, which was
This file was extended by bmake $as_me 20120620, which was
generated by GNU Autoconf 2.64. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@ -6429,7 +6429,7 @@ Report bugs to <sjg@NetBSD.org>."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_version="\\
bmake config.status 20120606
bmake config.status 20120620
configured by $0, generated by GNU Autoconf 2.64,
with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"

View File

@ -1,10 +1,10 @@
dnl
dnl RCSid:
dnl $Id: configure.in,v 1.44 2012/06/06 17:48:14 sjg Exp $
dnl $Id: configure.in,v 1.45 2012/06/20 22:43:41 sjg Exp $
dnl
dnl Process this file with autoconf to produce a configure script
dnl
AC_INIT([bmake], [20120606], [sjg@NetBSD.org])
AC_INIT([bmake], [20120620], [sjg@NetBSD.org])
AC_CONFIG_HEADER(config.h)
dnl
@ -39,7 +39,7 @@ AC_ARG_WITH(filemon,
esac],
[
OS=`uname -s`
for d in "$srcdir/filemon" "$srcdir/../filemon" "$srcdir/../../sys/dev/filemon"
for d in "/usr/include/dev/filemon" "$prefix/include/dev/filemon" "$srcdir/filemon" "$srcdir/../filemon" "$srcdir/../../sys/dev/filemon"
do
for x in "/$OS" ""
do

12
dir.c
View File

@ -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) {

16
job.c
View File

@ -1,4 +1,4 @@
/* $NetBSD: job.c,v 1.161 2012/04/07 18:29:08 christos Exp $ */
/* $NetBSD: job.c,v 1.162 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: job.c,v 1.161 2012/04/07 18:29:08 christos Exp $";
static char rcsid[] = "$NetBSD: job.c,v 1.162 2012/06/12 19:21:50 joerg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)job.c 8.2 (Berkeley) 3/19/94";
#else
__RCSID("$NetBSD: job.c,v 1.161 2012/04/07 18:29:08 christos Exp $");
__RCSID("$NetBSD: job.c,v 1.162 2012/06/12 19:21:50 joerg Exp $");
#endif
#endif /* not lint */
#endif
@ -365,7 +365,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 *);
@ -488,7 +488,7 @@ JobCondPassSig(int signo)
*-----------------------------------------------------------------------
*/
static void
JobChildSig(int signo __unused)
JobChildSig(int signo MAKE_ATTR_UNUSED)
{
write(childExitJob.outPipe, CHILD_EXIT, 1);
}
@ -511,7 +511,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
@ -536,14 +536,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 */

12
main.c
View File

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.199 2012/04/24 20:35:04 sjg Exp $ */
/* $NetBSD: main.c,v 1.200 2012/06/12 19:21:51 joerg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -69,7 +69,7 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: main.c,v 1.199 2012/04/24 20:35:04 sjg Exp $";
static char rcsid[] = "$NetBSD: main.c,v 1.200 2012/06/12 19:21:51 joerg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\
#if 0
static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94";
#else
__RCSID("$NetBSD: main.c,v 1.199 2012/04/24 20:35:04 sjg Exp $");
__RCSID("$NetBSD: main.c,v 1.200 2012/06/12 19:21:51 joerg Exp $");
#endif
#endif /* not lint */
#endif
@ -180,7 +180,7 @@ static char * Check_Cwd_av(int, char **, int);
#endif
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 */
@ -736,7 +736,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];
@ -1340,7 +1340,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;

12
make.c
View File

@ -1,4 +1,4 @@
/* $NetBSD: make.c,v 1.86 2012/05/10 19:53:26 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.86 2012/05/10 19:53:26 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.86 2012/05/10 19:53:26 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;
@ -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;

31
make.h
View File

@ -1,4 +1,4 @@
/* $NetBSD: make.h,v 1.88 2012/06/04 20:34:20 sjg Exp $ */
/* $NetBSD: make.h,v 1.89 2012/06/12 19:21:51 joerg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -98,26 +98,33 @@
#include <unistd.h>
#include <sys/cdefs.h>
#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"

View File

@ -1,4 +1,4 @@
/* $NetBSD: make_malloc.c,v 1.7 2012/05/18 02:28:16 sjg 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.7 2012/05/18 02:28:16 sjg Exp $");
__RCSID("$NetBSD: make_malloc.c,v 1.10 2012/06/20 17:46:28 sjg Exp $");
#endif
#include <stdio.h>
@ -36,15 +36,15 @@ __RCSID("$NetBSD: make_malloc.c,v 1.7 2012/05/18 02:28:16 sjg 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.
*/
extern char *progname;
static void
enomem(void)
{

View File

@ -1,4 +1,4 @@
/* $NetBSD: nonints.h,v 1.63 2011/09/16 15:38:04 joerg Exp $ */
/* $NetBSD: nonints.h,v 1.64 2012/06/12 19:21:51 joerg 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 *);
@ -116,21 +111,18 @@ 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);
/* 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 *);

10
parse.c
View File

@ -1,4 +1,4 @@
/* $NetBSD: parse.c,v 1.184 2012/04/24 20:12:16 sjg 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.184 2012/04/24 20:12:16 sjg 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.184 2012/04/24 20:12:16 sjg Exp $");
__RCSID("$NetBSD: parse.c,v 1.185 2012/06/12 19:21:51 joerg Exp $");
#endif
#endif /* not lint */
#endif
@ -347,9 +347,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 *);

12
targ.c
View File

@ -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;

View File

@ -1,6 +1,6 @@
# $Id: Makefile.in,v 1.37 2011/10/01 20:30:30 sjg Exp $
# $Id: Makefile.in,v 1.38 2012/06/19 23:38:48 sjg Exp $
#
# $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:
@ -30,6 +30,7 @@ SUBFILES= \
export-all \
doterror \
dotwait \
forloop \
forsubst \
hash \
misc \

45
unit-tests/forloop Normal file
View File

@ -0,0 +1,45 @@
# $Id: forloop,v 1.1.1.1 2012/06/19 23:30:49 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

View File

@ -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

34
var.c
View File

@ -1,4 +1,4 @@
/* $NetBSD: var.c,v 1.170 2012/06/04 20:34:20 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.170 2012/06/04 20:34:20 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.170 2012/06/04 20:34:20 sjg Exp $");
__RCSID("$NetBSD: var.c,v 1.171 2012/06/12 19:21:51 joerg Exp $");
#endif
#endif /* not lint */
#endif
@ -1145,7 +1145,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)
{
@ -1193,7 +1193,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)
{
@ -1235,7 +1235,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)
{
@ -1276,7 +1276,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)
{
@ -1320,7 +1320,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)
{
@ -1411,7 +1411,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)
{
@ -1448,7 +1448,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)
{
@ -1644,7 +1644,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)
{
@ -1784,7 +1785,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)
{
@ -1827,7 +1829,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 */
@ -1902,9 +1904,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];
@ -2127,7 +2129,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)
{