Import bmake-20130904

This commit is contained in:
Simon J. Gerraty 2013-09-05 15:49:22 +00:00
parent e0f69e1d23
commit 55ec07f91d
20 changed files with 196 additions and 48 deletions

View File

@ -1,3 +1,24 @@
2013-09-04 Simon J. Gerraty <sjg@bad.crufty.net>
* Makefile (MAKE_VERSION): 20130904
Merge with NetBSD make, pick up
o Add VAR_INTERNAL context, so that internal setting of
MAKEFILE does not override value set by makefiles.
2013-09-02 Simon J. Gerraty <sjg@bad.crufty.net>
* Makefile (MAKE_VERSION): 20130902
Merge with NetBSD make, pick up
o CompatRunCommand: only apply shellErrFlag when errCheck is true
2013-08-28 Simon J. Gerraty <sjg@bad.crufty.net>
* Makefile (MAKE_VERSION): 20130828
Merge with NetBSD make, pick up
o Fix VAR :sh = syntax from Will Andrews at freebsd.org
o Call Job_SetPrefix() from Job_Init() so makefiles have
opportunity to set .MAKE.JOB.PREFIX
2013-07-30 Simon J. Gerraty <sjg@bad.crufty.net> 2013-07-30 Simon J. Gerraty <sjg@bad.crufty.net>
* Makefile (MAKE_VERSION): 20130730 * Makefile (MAKE_VERSION): 20130730

1
FILES
View File

@ -114,6 +114,7 @@ unit-tests/order
unit-tests/phony-end unit-tests/phony-end
unit-tests/posix unit-tests/posix
unit-tests/qequals unit-tests/qequals
unit-tests/sunshcmd
unit-tests/sysv unit-tests/sysv
unit-tests/ternary unit-tests/ternary
unit-tests/test.exp unit-tests/test.exp

View File

@ -1,7 +1,7 @@
# $Id: Makefile,v 1.17 2013/07/30 19:13:53 sjg Exp $ # $Id: Makefile,v 1.20 2013/09/04 15:42:03 sjg Exp $
# Base version on src date # Base version on src date
MAKE_VERSION= 20130730 MAKE_VERSION= 20130904
PROG= bmake PROG= bmake

10
bmake.1
View File

@ -1,4 +1,4 @@
.\" $NetBSD: make.1,v 1.220 2013/07/30 19:09:57 sjg Exp $ .\" $NetBSD: make.1,v 1.222 2013/08/11 09:53:49 apb Exp $
.\" .\"
.\" Copyright (c) 1990, 1993 .\" Copyright (c) 1990, 1993
.\" The Regents of the University of California. All rights reserved. .\" The Regents of the University of California. All rights reserved.
@ -29,7 +29,7 @@
.\" .\"
.\" from: @(#)make.1 8.4 (Berkeley) 3/19/94 .\" from: @(#)make.1 8.4 (Berkeley) 3/19/94
.\" .\"
.Dd July 30, 2013 .Dd August 11, 2013
.Dt MAKE 1 .Dt MAKE 1
.Os .Os
.Sh NAME .Sh NAME
@ -1971,6 +1971,12 @@ If the source is the special
.Ic .DOTLAST .Ic .DOTLAST
target, then the current working target, then the current working
directory is searched last. directory is searched last.
.It Ic .PATH. Ns Va suffix
Like
.Ic .PATH
but applies only to files with a particular suffix.
The suffix must have been previously declared with
.Ic .SUFFIXES .
.It Ic .PHONY .It Ic .PHONY
Apply the Apply the
.Ic .PHONY .Ic .PHONY

View File

@ -1257,6 +1257,10 @@ SSPPEECCIIAALL TTAARRGGEETTSS
source is the special ..DDOOTTLLAASSTT target, then the current working source is the special ..DDOOTTLLAASSTT target, then the current working
directory is searched last. directory is searched last.
..PPAATTHH.._s_u_f_f_i_x
Like ..PPAATTHH but applies only to files with a particular suffix.
The suffix must have been previously declared with ..SSUUFFFFIIXXEESS.
..PPHHOONNYY Apply the ..PPHHOONNYY attribute to any specified sources. ..PPHHOONNYY Apply the ..PPHHOONNYY attribute to any specified sources.
..PPRREECCIIOOUUSS ..PPRREECCIIOOUUSS
@ -1374,4 +1378,4 @@ BBUUGGSS
There is no way of escaping a space character in a filename. There is no way of escaping a space character in a filename.
NetBSD 5.1 July 30, 2013 NetBSD 5.1 NetBSD 5.1 August 11, 2013 NetBSD 5.1

View File

@ -1,4 +1,4 @@
/* $NetBSD: compat.c,v 1.92 2013/07/05 22:14:56 sjg Exp $ */ /* $NetBSD: compat.c,v 1.93 2013/09/02 19:26:42 sjg Exp $ */
/* /*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California. * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@ -70,14 +70,14 @@
*/ */
#ifndef MAKE_NATIVE #ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: compat.c,v 1.92 2013/07/05 22:14:56 sjg Exp $"; static char rcsid[] = "$NetBSD: compat.c,v 1.93 2013/09/02 19:26:42 sjg Exp $";
#else #else
#include <sys/cdefs.h> #include <sys/cdefs.h>
#ifndef lint #ifndef lint
#if 0 #if 0
static char sccsid[] = "@(#)compat.c 8.2 (Berkeley) 3/19/94"; static char sccsid[] = "@(#)compat.c 8.2 (Berkeley) 3/19/94";
#else #else
__RCSID("$NetBSD: compat.c,v 1.92 2013/07/05 22:14:56 sjg Exp $"); __RCSID("$NetBSD: compat.c,v 1.93 2013/09/02 19:26:42 sjg Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
#endif #endif
@ -340,7 +340,7 @@ CompatRunCommand(void *cmdp, void *gnp)
/* /*
* The following work for any of the builtin shell specs. * The following work for any of the builtin shell specs.
*/ */
if (shellErrFlag) { if (errCheck && shellErrFlag) {
shargv[shargc++] = shellErrFlag; shargv[shargc++] = shellErrFlag;
} }
if (DEBUG(SHELL)) if (DEBUG(SHELL))

7
job.c
View File

@ -1,4 +1,4 @@
/* $NetBSD: job.c,v 1.175 2013/07/30 19:09:57 sjg Exp $ */ /* $NetBSD: job.c,v 1.176 2013/08/04 16:48:15 sjg Exp $ */
/* /*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California. * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@ -70,14 +70,14 @@
*/ */
#ifndef MAKE_NATIVE #ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: job.c,v 1.175 2013/07/30 19:09:57 sjg Exp $"; static char rcsid[] = "$NetBSD: job.c,v 1.176 2013/08/04 16:48:15 sjg Exp $";
#else #else
#include <sys/cdefs.h> #include <sys/cdefs.h>
#ifndef lint #ifndef lint
#if 0 #if 0
static char sccsid[] = "@(#)job.c 8.2 (Berkeley) 3/19/94"; static char sccsid[] = "@(#)job.c 8.2 (Berkeley) 3/19/94";
#else #else
__RCSID("$NetBSD: job.c,v 1.175 2013/07/30 19:09:57 sjg Exp $"); __RCSID("$NetBSD: job.c,v 1.176 2013/08/04 16:48:15 sjg Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
#endif #endif
@ -2214,6 +2214,7 @@ Job_SetPrefix(void)
void void
Job_Init(void) Job_Init(void)
{ {
Job_SetPrefix();
/* Allocate space for all the job info */ /* Allocate space for all the job info */
job_table = bmake_malloc(maxJobs * sizeof *job_table); job_table = bmake_malloc(maxJobs * sizeof *job_table);
memset(job_table, 0, maxJobs * sizeof *job_table); memset(job_table, 0, maxJobs * sizeof *job_table);

11
main.c
View File

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.222 2013/07/18 15:31:49 sjg Exp $ */ /* $NetBSD: main.c,v 1.224 2013/09/04 15:38:26 sjg Exp $ */
/* /*
* Copyright (c) 1988, 1989, 1990, 1993 * Copyright (c) 1988, 1989, 1990, 1993
@ -69,7 +69,7 @@
*/ */
#ifndef MAKE_NATIVE #ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: main.c,v 1.222 2013/07/18 15:31:49 sjg Exp $"; static char rcsid[] = "$NetBSD: main.c,v 1.224 2013/09/04 15:38:26 sjg Exp $";
#else #else
#include <sys/cdefs.h> #include <sys/cdefs.h>
#ifndef lint #ifndef lint
@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\
#if 0 #if 0
static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94"; static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94";
#else #else
__RCSID("$NetBSD: main.c,v 1.222 2013/07/18 15:31:49 sjg Exp $"); __RCSID("$NetBSD: main.c,v 1.224 2013/09/04 15:38:26 sjg Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
#endif #endif
@ -1026,7 +1026,6 @@ main(int argc, char **argv)
snprintf(pn, sizeof(pn), "%s[%d]", progname, makelevel); snprintf(pn, sizeof(pn), "%s[%d]", progname, makelevel);
progname = bmake_strdup(pn); progname = bmake_strdup(pn);
} }
Job_SetPrefix();
#ifdef USE_META #ifdef USE_META
meta_init(); meta_init();
@ -1415,7 +1414,7 @@ ReadMakefile(const void *p, const void *q MAKE_ATTR_UNUSED)
if (!strcmp(fname, "-")) { if (!strcmp(fname, "-")) {
Parse_File(NULL /*stdin*/, -1); Parse_File(NULL /*stdin*/, -1);
Var_Set("MAKEFILE", "", VAR_GLOBAL, 0); Var_Set("MAKEFILE", "", VAR_INTERNAL, 0);
} else { } else {
/* if we've chdir'd, rebuild the path name */ /* if we've chdir'd, rebuild the path name */
if (strcmp(curdir, objdir) && *fname != '/') { if (strcmp(curdir, objdir) && *fname != '/') {
@ -1464,7 +1463,7 @@ ReadMakefile(const void *p, const void *q MAKE_ATTR_UNUSED)
*/ */
found: found:
if (!doing_depend) if (!doing_depend)
Var_Set("MAKEFILE", fname, VAR_GLOBAL, 0); Var_Set("MAKEFILE", fname, VAR_INTERNAL, 0);
Parse_File(fname, fd); Parse_File(fname, fd);
} }
free(path); free(path);

10
make.1
View File

@ -1,4 +1,4 @@
.\" $NetBSD: make.1,v 1.220 2013/07/30 19:09:57 sjg Exp $ .\" $NetBSD: make.1,v 1.222 2013/08/11 09:53:49 apb Exp $
.\" .\"
.\" Copyright (c) 1990, 1993 .\" Copyright (c) 1990, 1993
.\" The Regents of the University of California. All rights reserved. .\" The Regents of the University of California. All rights reserved.
@ -29,7 +29,7 @@
.\" .\"
.\" from: @(#)make.1 8.4 (Berkeley) 3/19/94 .\" from: @(#)make.1 8.4 (Berkeley) 3/19/94
.\" .\"
.Dd July 30, 2013 .Dd August 11, 2013
.Dt MAKE 1 .Dt MAKE 1
.Os .Os
.Sh NAME .Sh NAME
@ -1971,6 +1971,12 @@ If the source is the special
.Ic .DOTLAST .Ic .DOTLAST
target, then the current working target, then the current working
directory is searched last. directory is searched last.
.It Ic .PATH. Ns Va suffix
Like
.Ic .PATH
but applies only to files with a particular suffix.
The suffix must have been previously declared with
.Ic .SUFFIXES .
.It Ic .PHONY .It Ic .PHONY
Apply the Apply the
.Ic .PHONY .Ic .PHONY

6
make.h
View File

@ -1,4 +1,4 @@
/* $NetBSD: make.h,v 1.91 2013/06/18 20:06:09 sjg Exp $ */ /* $NetBSD: make.h,v 1.92 2013/09/04 15:38:26 sjg Exp $ */
/* /*
* Copyright (c) 1988, 1989, 1990, 1993 * Copyright (c) 1988, 1989, 1990, 1993
@ -404,6 +404,10 @@ extern Boolean varNoExportEnv; /* TRUE if we should not export variables
extern GNode *DEFAULT; /* .DEFAULT rule */ extern GNode *DEFAULT; /* .DEFAULT rule */
extern GNode *VAR_INTERNAL; /* Variables defined internally by make
* which should not override those set by
* makefiles.
*/
extern GNode *VAR_GLOBAL; /* Variables defined in a global context, e.g extern GNode *VAR_GLOBAL; /* Variables defined in a global context, e.g
* in the Makefile itself */ * in the Makefile itself */
extern GNode *VAR_CMD; /* Variables defined on the command line */ extern GNode *VAR_CMD; /* Variables defined on the command line */

View File

@ -1,3 +1,14 @@
2013-09-04 Simon J. Gerraty <sjg@bad.crufty.net>
* gendirdeps.mk (_objtops): fix typo also
while processing M2D_OBJROOTS to gather qualdir_list
qualify $ql with loop iterator to ensure correct results.
2013-08-01 Simon J. Gerraty <sjg@bad.crufty.net>
* install-mk (MK_VERSION): 20130801
* libs.mk: update to match progs.mk
2013-07-26 Simon J. Gerraty <sjg@bad.crufty.net> 2013-07-26 Simon J. Gerraty <sjg@bad.crufty.net>
* install-mk (MK_VERSION): 20130726 * install-mk (MK_VERSION): 20130726

View File

@ -1,4 +1,4 @@
# $Id: gendirdeps.mk,v 1.22 2013/05/11 05:16:26 sjg Exp $ # $Id: gendirdeps.mk,v 1.23 2013/09/04 17:49:20 sjg Exp $
# Copyright (c) 2010-2013, Juniper Networks, Inc. # Copyright (c) 2010-2013, Juniper Networks, Inc.
# All rights reserved. # All rights reserved.
@ -162,7 +162,7 @@ dir_list != cd ${_OBJDIR} && \
.warning Skipping ${_DEPENDFILE:S,${SRCTOP}/,,} .warning Skipping ${_DEPENDFILE:S,${SRCTOP}/,,}
# we are not going to update anything # we are not going to update anything
.else .else
dpadd_dir_list=
.if !empty(DPADD) .if !empty(DPADD)
_nonlibs := ${DPADD:T:Nlib*:N*include} _nonlibs := ${DPADD:T:Nlib*:N*include}
.if !empty(_nonlibs) .if !empty(_nonlibs)
@ -174,6 +174,7 @@ ddep_list += $f.dirdep
ddep_list += ${f:H}.dirdep ddep_list += ${f:H}.dirdep
.else .else
dir_list += ${f:H:tA} dir_list += ${f:H:tA}
dpadd_dir_list += ${f:H:tA}
.endif .endif
.endfor .endfor
.if !empty(ddep_list) .if !empty(ddep_list)
@ -197,7 +198,7 @@ dir_list += ${ddeps}
# so we add # so we add
# ${"${dir_list:M*bsd/sys/${MACHINE_ARCH}/include}":?bsd/include:} # ${"${dir_list:M*bsd/sys/${MACHINE_ARCH}/include}":?bsd/include:}
# to GENDIRDEPS_DIR_LIST_XTRAS # to GENDIRDEPS_DIR_LIST_XTRAS
_objtops = ${OBJTOP} ${_OBJTOP} ${_obtop} _objtops = ${OBJTOP} ${_OBJTOP} ${_objtop}
_objtops := ${_objtops:O:u} _objtops := ${_objtops:O:u}
dirdep_list = \ dirdep_list = \
${_objtops:@o@${dir_list:M$o*/*:C,$o[^/]*/,,}@} \ ${_objtops:@o@${dir_list:M$o*/*:C,$o[^/]*/,,}@} \
@ -212,8 +213,11 @@ M2D_OBJROOTS := ${M2D_OBJROOTS:O:u:[-1..1]}
skip_ql= ${SRCTOP}* ${_objtops:@o@$o*@} skip_ql= ${SRCTOP}* ${_objtops:@o@$o*@}
.for o in ${M2D_OBJROOTS:${skip_ql:${M_ListToSkip}}} .for o in ${M2D_OBJROOTS:${skip_ql:${M_ListToSkip}}}
# we need := so only skip_ql to this point applies # we need := so only skip_ql to this point applies
ql := ${dir_list:${skip_ql:${M_ListToSkip}}:M$o*/*/*:C,$o([^/]+)/(.*),\2.\1,:S,.${HOST_TARGET},.host,} ql.$o := ${dir_list:${skip_ql:${M_ListToSkip}}:M$o*/*/*:C,$o([^/]+)/(.*),\2.\1,:S,.${HOST_TARGET},.host,}
qualdir_list += ${ql} qualdir_list += ${ql.$o}
.if ${DEBUG_GENDIRDEPS:Uno:@x@${RELDIR:M$x}@} != ""
.info ${RELDIR}: o=$o ${ql.$o qualdir_list:L:@v@$v=${$v}@}
.endif
skip_ql+= $o* skip_ql+= $o*
.endfor .endfor
@ -241,6 +245,7 @@ DIRDEPS := ${DIRDEPS:${GENDIRDEPS_FILTER:UNno:ts:}:O:u}
.if ${DEBUG_GENDIRDEPS:Uno:@x@${RELDIR:M$x}@} != "" .if ${DEBUG_GENDIRDEPS:Uno:@x@${RELDIR:M$x}@} != ""
.info ${RELDIR}: M2D_OBJROOTS=${M2D_OBJROOTS} .info ${RELDIR}: M2D_OBJROOTS=${M2D_OBJROOTS}
.info ${RELDIR}: dir_list='${dir_list}' .info ${RELDIR}: dir_list='${dir_list}'
.info ${RELDIR}: dpadd_dir_list='${dpadd_dir_list}'
.info ${RELDIR}: dirdep_list='${dirdep_list}' .info ${RELDIR}: dirdep_list='${dirdep_list}'
.info ${RELDIR}: qualdir_list='${qualdir_list}' .info ${RELDIR}: qualdir_list='${qualdir_list}'
.info ${RELDIR}: SKIP_GENDIRDEPS='${SKIP_GENDIRDEPS}' .info ${RELDIR}: SKIP_GENDIRDEPS='${SKIP_GENDIRDEPS}'

View File

@ -55,7 +55,7 @@
# Simon J. Gerraty <sjg@crufty.net> # Simon J. Gerraty <sjg@crufty.net>
# RCSid: # RCSid:
# $Id: install-mk,v 1.92 2013/07/27 05:37:37 sjg Exp $ # $Id: install-mk,v 1.93 2013/08/02 18:28:47 sjg Exp $
# #
# @(#) Copyright (c) 1994 Simon J. Gerraty # @(#) Copyright (c) 1994 Simon J. Gerraty
# #
@ -70,7 +70,7 @@
# sjg@crufty.net # sjg@crufty.net
# #
MK_VERSION=20130726 MK_VERSION=20130801
OWNER= OWNER=
GROUP= GROUP=
MODE=444 MODE=444

View File

@ -1,4 +1,4 @@
# $Id: libs.mk,v 1.2 2007/04/30 17:39:27 sjg Exp $ # $Id: libs.mk,v 1.3 2013/08/02 18:28:48 sjg Exp $
# #
# @(#) Copyright (c) 2006, Simon J. Gerraty # @(#) Copyright (c) 2006, Simon J. Gerraty
# #
@ -17,7 +17,15 @@
.if defined(LIBS) .if defined(LIBS)
# In meta mode, we can capture dependenices for _one_ of the progs.
# if makefile doesn't nominate one, we use the first.
.ifndef UPDATE_DEPENDFILE_LIB
UPDATE_DEPENDFILE_LIB = ${LIBS:[1]}
.export UPDATE_DEPENDFILE_LIB
.endif
.ifndef LIB .ifndef LIB
# They may have asked us to build just one
.for t in ${LIBS:R:T:S,^lib,,} .for t in ${LIBS:R:T:S,^lib,,}
.if make(lib$t) .if make(lib$t)
LIB?= $t LIB?= $t
@ -28,14 +36,41 @@ lib$t: all
.if defined(LIB) .if defined(LIB)
# just one of many # just one of many
.for v in DPADD SRCS CFLAGS ${LIB_VARS} LIB_VARS += \
$v += ${${v}_lib${LIB}} LIBDIR \
CFLAGS \
COPTS \
CPPFLAGS \
CXXFLAGS \
DPADD \
DPLIBS \
LDADD \
LDFLAGS \
MAN \
SRCS
.for v in ${LIB_VARS:O:u}
.if defined(${v}.${LIB}) || defined(${v}_${LIB})
$v += ${${v}_${LIB}:U${${v}.${LIB}}}
.endif
.endfor .endfor
# for meta mode, there can be only one!
.if ${LIB} == ${UPDATE_DEPENDFILE_LIB:Uno}
UPDATE_DEPENDFILE ?= yes
.endif
UPDATE_DEPENDFILE ?= NO
# ensure that we don't clobber each other's dependencies # ensure that we don't clobber each other's dependencies
DEPENDFILE?= .depend.${LIB} DEPENDFILE?= .depend.${LIB}
# lib.mk will do the rest # lib.mk will do the rest
.else .else
all: ${LIBS:S,^lib,,:@t@lib$t.a@} .MAKE all: ${LIBS:S,^lib,,:@t@lib$t.a@} .MAKE
# We cannot capture dependencies for meta mode here
UPDATE_DEPENDFILE = NO
# nor can we safely run in parallel.
.NOTPARALLEL:
.endif .endif
.endif .endif
@ -43,12 +78,16 @@ all: ${LIBS:S,^lib,,:@t@lib$t.a@} .MAKE
.include <${.PARSEFILE:S,libs,lib,}> .include <${.PARSEFILE:S,libs,lib,}>
.ifndef LIB .ifndef LIB
.for t in ${LIBS:R:T:S,^lib,,} # tell libs.mk we might want to install things
lib$t.a: ${SRCS} ${DPADD} ${SRCS_lib$t} ${DPADD_lib$t} LIBS_TARGETS+= cleandepend cleandir cleanobj depend install
(cd ${.CURDIR} && ${.MAKE} -f ${MAKEFILE} LIB=$t)
clean: $t.clean .for b in ${LIBS:R:T:S,^lib,,}
$t.clean: lib$b.a: ${SRCS} ${DPADD} ${SRCS_lib$b} ${DPADD_lib$b}
(cd ${.CURDIR} && ${.MAKE} -f ${MAKEFILE} LIB=$t ${@:E}) (cd ${.CURDIR} && ${.MAKE} -f ${MAKEFILE} LIB=$b)
.for t in ${LIBS_TARGETS:O:u}
$b.$t: .PHONY .MAKE
(cd ${.CURDIR} && ${.MAKE} -f ${MAKEFILE} LIB=$b ${@:E})
.endfor
.endfor .endfor
.endif .endif

View File

@ -1,4 +1,4 @@
# $Id: progs.mk,v 1.12 2013/04/22 18:10:04 sjg Exp $ # $Id: progs.mk,v 1.13 2013/08/02 18:28:48 sjg Exp $
# #
# @(#) Copyright (c) 2006, Simon J. Gerraty # @(#) Copyright (c) 2006, Simon J. Gerraty
# #
@ -35,9 +35,21 @@ PROG ?= $t
.if defined(PROG) .if defined(PROG)
# just one of many # just one of many
PROG_VARS += BINDIR CFLAGS CPPFLAGS CXXFLAGS DPADD DPLIBS LDADD MAN SRCS PROG_VARS += \
BINDIR \
CFLAGS \
COPTS \
CPPFLAGS \
CXXFLAGS \
DPADD \
DPLIBS \
LDADD \
LDFLAGS \
MAN \
SRCS
.for v in ${PROG_VARS:O:u} .for v in ${PROG_VARS:O:u}
.if defined(${v}.${PROG}) .if defined(${v}.${PROG}) || defined(${v}_${PROG})
$v += ${${v}_${PROG}:U${${v}.${PROG}}} $v += ${${v}_${PROG}:U${${v}.${PROG}}}
.endif .endif
.endfor .endfor

22
parse.c
View File

@ -1,4 +1,4 @@
/* $NetBSD: parse.c,v 1.189 2013/06/18 19:31:27 sjg Exp $ */ /* $NetBSD: parse.c,v 1.191 2013/08/28 21:56:49 sjg Exp $ */
/* /*
* Copyright (c) 1988, 1989, 1990, 1993 * Copyright (c) 1988, 1989, 1990, 1993
@ -69,14 +69,14 @@
*/ */
#ifndef MAKE_NATIVE #ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: parse.c,v 1.189 2013/06/18 19:31:27 sjg Exp $"; static char rcsid[] = "$NetBSD: parse.c,v 1.191 2013/08/28 21:56:49 sjg Exp $";
#else #else
#include <sys/cdefs.h> #include <sys/cdefs.h>
#ifndef lint #ifndef lint
#if 0 #if 0
static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94"; static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94";
#else #else
__RCSID("$NetBSD: parse.c,v 1.189 2013/06/18 19:31:27 sjg Exp $"); __RCSID("$NetBSD: parse.c,v 1.191 2013/08/28 21:56:49 sjg Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
#endif #endif
@ -1751,6 +1751,12 @@ Parse_IsVar(char *line)
ch = *line++; ch = *line++;
wasSpace = TRUE; wasSpace = TRUE;
} }
#ifdef SUNSHCMD
if (ch == ':' && strncmp(line, "sh", 2) == 0) {
line += 2;
continue;
}
#endif
if (ch == '=') if (ch == '=')
return TRUE; return TRUE;
if (*line == '=' && ISEQOPERATOR(ch)) if (*line == '=' && ISEQOPERATOR(ch))
@ -2582,6 +2588,16 @@ ParseGetLine(int flags, int *length)
if (cf->P_end == NULL) if (cf->P_end == NULL)
/* End of string (aka for loop) data */ /* End of string (aka for loop) data */
break; break;
/* see if there is more we can parse */
while (ptr++ < cf->P_end) {
if ((ch = *ptr) == '\n') {
if (ptr > line && ptr[-1] == '\\')
continue;
Parse_Error(PARSE_WARNING,
"Zero byte read from file, skipping rest of line.");
break;
}
}
if (cf->nextbuf != NULL) { if (cf->nextbuf != NULL) {
/* /*
* End of this buffer; return EOF and outer logic * End of this buffer; return EOF and outer logic

View File

@ -1,6 +1,6 @@
# $Id: Makefile.in,v 1.43 2013/07/16 21:14:30 sjg Exp $ # $Id: Makefile.in,v 1.44 2013/08/28 22:09:29 sjg Exp $
# #
# $NetBSD: Makefile,v 1.37 2013/07/16 19:59:28 sjg Exp $ # $NetBSD: Makefile,v 1.38 2013/08/28 21:56:50 sjg Exp $
# #
# Unit tests for make(1) # Unit tests for make(1)
# The main targets are: # The main targets are:
@ -45,6 +45,7 @@ SUBFILES= \
phony-end \ phony-end \
posix \ posix \
qequals \ qequals \
sunshcmd \
sysv \ sysv \
ternary \ ternary \
unexport \ unexport \

10
unit-tests/sunshcmd Normal file
View File

@ -0,0 +1,10 @@
BYECMD = echo bye
LATERCMD = echo later
TEST1 :sh = echo hello
TEST2 :sh = ${BYECMD}
TEST3 = ${LATERCMD:sh}
all:
@echo "TEST1=${TEST1}"
@echo "TEST2=${TEST2}"
@echo "TEST3=${TEST3}"

View File

@ -349,6 +349,9 @@ Now we expect an error...
*** Error code 1 (continuing) *** Error code 1 (continuing)
`all' not remade because of errors. `all' not remade because of errors.
V.i386 ?= OK V.i386 ?= OK
TEST1=hello
TEST2=bye
TEST3=later
FOOBAR = FOOBAR =
FOOBAR = foobar fubar FOOBAR = foobar fubar
fun fun

15
var.c
View File

@ -1,4 +1,4 @@
/* $NetBSD: var.c,v 1.183 2013/07/16 20:00:56 sjg Exp $ */ /* $NetBSD: var.c,v 1.184 2013/09/04 15:38:26 sjg Exp $ */
/* /*
* Copyright (c) 1988, 1989, 1990, 1993 * Copyright (c) 1988, 1989, 1990, 1993
@ -69,14 +69,14 @@
*/ */
#ifndef MAKE_NATIVE #ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: var.c,v 1.183 2013/07/16 20:00:56 sjg Exp $"; static char rcsid[] = "$NetBSD: var.c,v 1.184 2013/09/04 15:38:26 sjg Exp $";
#else #else
#include <sys/cdefs.h> #include <sys/cdefs.h>
#ifndef lint #ifndef lint
#if 0 #if 0
static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94"; static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94";
#else #else
__RCSID("$NetBSD: var.c,v 1.183 2013/07/16 20:00:56 sjg Exp $"); __RCSID("$NetBSD: var.c,v 1.184 2013/09/04 15:38:26 sjg Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
#endif #endif
@ -176,6 +176,7 @@ static char varNoError[] = "";
* The four contexts are searched in the reverse order from which they are * The four contexts are searched in the reverse order from which they are
* listed. * listed.
*/ */
GNode *VAR_INTERNAL; /* variables from make itself */
GNode *VAR_GLOBAL; /* variables from the makefile */ GNode *VAR_GLOBAL; /* variables from the makefile */
GNode *VAR_CMD; /* variables defined on the command-line */ GNode *VAR_CMD; /* variables defined on the command-line */
@ -408,6 +409,10 @@ VarFind(const char *name, GNode *ctxt, int flags)
(ctxt != VAR_GLOBAL)) (ctxt != VAR_GLOBAL))
{ {
var = Hash_FindEntry(&VAR_GLOBAL->context, name); var = Hash_FindEntry(&VAR_GLOBAL->context, name);
if ((var == NULL) && (ctxt != VAR_INTERNAL)) {
/* VAR_INTERNAL is subordinate to VAR_GLOBAL */
var = Hash_FindEntry(&VAR_INTERNAL->context, name);
}
} }
if ((var == NULL) && (flags & FIND_ENV)) { if ((var == NULL) && (flags & FIND_ENV)) {
char *env; char *env;
@ -429,6 +434,9 @@ VarFind(const char *name, GNode *ctxt, int flags)
(ctxt != VAR_GLOBAL)) (ctxt != VAR_GLOBAL))
{ {
var = Hash_FindEntry(&VAR_GLOBAL->context, name); var = Hash_FindEntry(&VAR_GLOBAL->context, name);
if ((var == NULL) && (ctxt != VAR_INTERNAL)) {
var = Hash_FindEntry(&VAR_INTERNAL->context, name);
}
if (var == NULL) { if (var == NULL) {
return NULL; return NULL;
} else { } else {
@ -4137,6 +4145,7 @@ Var_GetHead(char *file)
void void
Var_Init(void) Var_Init(void)
{ {
VAR_INTERNAL = Targ_NewGN("Internal");
VAR_GLOBAL = Targ_NewGN("Global"); VAR_GLOBAL = Targ_NewGN("Global");
VAR_CMD = Targ_NewGN("Command"); VAR_CMD = Targ_NewGN("Command");