Import bmake-20240430
Intersting/relevant changes since bmake-20240309
ChangeLog since bmake-20240309
2024-04-30 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240430
Merge with NetBSD make, pick up
o main.c: ensure '.include <makefile>' respects MAKESYSPATH.
Dir_FindFile will search .CURDIR first unless ".DOTLAST" is seen.
2024-04-28 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240428
Merge with NetBSD make, pick up
o simplify freeing of lists
o arch.c: trim pointless comments
o var.c: delay variable assignments until actually needed
don't reallocate memory after evaluating an expression, result is
almost always short-lived.
2024-04-26 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240426
Merge with NetBSD make, pick up
o job.c: in debug output, print the directory in which a job
failed at same time as failed target so it is more easily found in
build log.
2024-04-24 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240424
Merge with NetBSD make, pick up
o clean up comments, code and tests
2024-04-23 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240422
Merge with NetBSD make, pick up
o var.c: avoid LazyBuf for :*time modifiers.
LazyBuf's are not nul terminated so not suitable for passing to
functions that expect that. These modifiers are used sparingly so
an extra allocation is not a problem.
2024-04-20 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240420
Merge with NetBSD make, pick up
o provide more context information for parse/evaluate errors
2024-04-14 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240414
Merge with NetBSD make, pick up
o parse.c: print -dp debug info earlier so we see which
.if or .for line is being parsed.
2024-04-04 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240404
Merge with NetBSD make, pick up
o fix some unit tests for Cygwin
o parse.c: exit immediately after reading a null byte from a makefile
* fix generation of bmake.cat1
2024-03-19 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240314
Add/Improve support for Cygwin
o uname -s output isn't useful so allow configure to
set FORCE_MAKE_OS - to force the value of .MAKE.OS
and use Cygwin which matches uname -o
o fix some unit-tests for Cygwin
* configure.in: use_makefile=no for Cygwin et al.
NOTE: bmake does not support Cygwin and likely never will,
mk/ChangeLog since bmake-20240309
2024-04-24 Simon J Gerraty <sjg@beast.crufty.net>
* meta.autodep.mk: do not override start_utc
2024-04-18 Simon J Gerraty <sjg@beast.crufty.net>
* sys.dirdeps.mk: set defaults for DEP_* at level 0 too.
These help when first include of Makefile.depend happens in a leaf
dir.
* install-mk (MK_VERSION): 20240414
2024-04-09 Simon J Gerraty <sjg@beast.crufty.net>
* install-mk (MK_VERSION): 20240408
* init.mk: allow for _ as well as . to join V
and Q from QUALIFIED_VAR_LIST and VAR_QUALIFIER_LIST.
* progs.mk: avoid overlap between PROG_VARS and
init.mk's QUALIFIED_VAR_LIST since PROG would also
match its VAR_QUALIFIER_LIST,
libs.mk does not have the same issue.
* subdir.mk: _SUBDIRUSE for realinstall should run install
remove include of ${.CURDIR}/Makefile.inc that can be done via
local.subdir.mk where needed
* own.mk: do not conflict with man.mk
2024-03-19 Simon J Gerraty <sjg@beast.crufty.net>
* install-mk (MK_VERSION): 20240314
* add sys/Cygwin.mk from Christian Franke
2024-05-03 22:43:12 +00:00
|
|
|
/* $NetBSD: compat.c,v 1.255 2024/04/20 10:18:55 rillig Exp $ */
|
2012-06-08 21:57:36 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to Berkeley by
|
|
|
|
* Adam de Boor.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
1996-10-06 15:57:15 +00:00
|
|
|
/*
|
2012-06-08 21:57:36 +00:00
|
|
|
* Copyright (c) 1988, 1989 by Adam de Boor
|
1996-10-06 15:57:15 +00:00
|
|
|
* Copyright (c) 1989 by Berkeley Softworks
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to Berkeley by
|
|
|
|
* Adam de Boor.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the University of
|
|
|
|
* California, Berkeley and its contributors.
|
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2021-02-11 01:51:11 +00:00
|
|
|
/*
|
2022-07-26 15:52:53 +00:00
|
|
|
* This file implements the full-compatibility mode of make, which makes the
|
|
|
|
* targets without parallelism and without a custom shell.
|
1996-10-06 15:57:15 +00:00
|
|
|
*
|
|
|
|
* Interface:
|
2022-07-26 15:52:53 +00:00
|
|
|
* Compat_MakeAll Initialize this module and make the given targets.
|
1996-10-06 15:57:15 +00:00
|
|
|
*/
|
|
|
|
|
2012-06-08 21:57:36 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
2020-11-07 19:39:21 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include "wait.h"
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
#include <signal.h>
|
|
|
|
|
|
|
|
#include "make.h"
|
|
|
|
#include "dir.h"
|
|
|
|
#include "job.h"
|
|
|
|
#include "metachar.h"
|
|
|
|
#include "pathnames.h"
|
|
|
|
|
|
|
|
/* "@(#)compat.c 8.2 (Berkeley) 3/19/94" */
|
Import bmake-20240430
Intersting/relevant changes since bmake-20240309
ChangeLog since bmake-20240309
2024-04-30 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240430
Merge with NetBSD make, pick up
o main.c: ensure '.include <makefile>' respects MAKESYSPATH.
Dir_FindFile will search .CURDIR first unless ".DOTLAST" is seen.
2024-04-28 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240428
Merge with NetBSD make, pick up
o simplify freeing of lists
o arch.c: trim pointless comments
o var.c: delay variable assignments until actually needed
don't reallocate memory after evaluating an expression, result is
almost always short-lived.
2024-04-26 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240426
Merge with NetBSD make, pick up
o job.c: in debug output, print the directory in which a job
failed at same time as failed target so it is more easily found in
build log.
2024-04-24 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240424
Merge with NetBSD make, pick up
o clean up comments, code and tests
2024-04-23 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240422
Merge with NetBSD make, pick up
o var.c: avoid LazyBuf for :*time modifiers.
LazyBuf's are not nul terminated so not suitable for passing to
functions that expect that. These modifiers are used sparingly so
an extra allocation is not a problem.
2024-04-20 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240420
Merge with NetBSD make, pick up
o provide more context information for parse/evaluate errors
2024-04-14 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240414
Merge with NetBSD make, pick up
o parse.c: print -dp debug info earlier so we see which
.if or .for line is being parsed.
2024-04-04 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240404
Merge with NetBSD make, pick up
o fix some unit tests for Cygwin
o parse.c: exit immediately after reading a null byte from a makefile
* fix generation of bmake.cat1
2024-03-19 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240314
Add/Improve support for Cygwin
o uname -s output isn't useful so allow configure to
set FORCE_MAKE_OS - to force the value of .MAKE.OS
and use Cygwin which matches uname -o
o fix some unit-tests for Cygwin
* configure.in: use_makefile=no for Cygwin et al.
NOTE: bmake does not support Cygwin and likely never will,
mk/ChangeLog since bmake-20240309
2024-04-24 Simon J Gerraty <sjg@beast.crufty.net>
* meta.autodep.mk: do not override start_utc
2024-04-18 Simon J Gerraty <sjg@beast.crufty.net>
* sys.dirdeps.mk: set defaults for DEP_* at level 0 too.
These help when first include of Makefile.depend happens in a leaf
dir.
* install-mk (MK_VERSION): 20240414
2024-04-09 Simon J Gerraty <sjg@beast.crufty.net>
* install-mk (MK_VERSION): 20240408
* init.mk: allow for _ as well as . to join V
and Q from QUALIFIED_VAR_LIST and VAR_QUALIFIER_LIST.
* progs.mk: avoid overlap between PROG_VARS and
init.mk's QUALIFIED_VAR_LIST since PROG would also
match its VAR_QUALIFIER_LIST,
libs.mk does not have the same issue.
* subdir.mk: _SUBDIRUSE for realinstall should run install
remove include of ${.CURDIR}/Makefile.inc that can be done via
local.subdir.mk where needed
* own.mk: do not conflict with man.mk
2024-03-19 Simon J Gerraty <sjg@beast.crufty.net>
* install-mk (MK_VERSION): 20240314
* add sys/Cygwin.mk from Christian Franke
2024-05-03 22:43:12 +00:00
|
|
|
MAKE_RCSID("$NetBSD: compat.c,v 1.255 2024/04/20 10:18:55 rillig Exp $");
|
2020-11-07 19:39:21 +00:00
|
|
|
|
|
|
|
static GNode *curTarg = NULL;
|
2017-07-24 00:52:52 +00:00
|
|
|
static pid_t compatChild;
|
|
|
|
static int compatSigno;
|
2012-06-08 21:57:36 +00:00
|
|
|
|
2016-12-19 21:50:59 +00:00
|
|
|
/*
|
2023-01-28 00:23:54 +00:00
|
|
|
* Delete the file of a failed, interrupted, or otherwise duffed target,
|
|
|
|
* unless inhibited by .PRECIOUS.
|
2016-12-19 21:50:59 +00:00
|
|
|
*/
|
|
|
|
static void
|
|
|
|
CompatDeleteTarget(GNode *gn)
|
|
|
|
{
|
2023-04-24 23:44:30 +00:00
|
|
|
if (gn != NULL && !GNode_IsPrecious(gn) &&
|
|
|
|
(gn->type & OP_PHONY) == 0) {
|
2021-01-14 01:24:34 +00:00
|
|
|
const char *file = GNode_VarTarget(gn);
|
Import bmake-20240108
Interesting/relevant changes since bmake-20230909
* VERSION (_MAKE_VERSION): 20240106
Merge with NetBSD make, pick up
o fix duplicate progname when reporting an unknown target
o unit tests for Cmd_Exec using temp file
* VERSION (_MAKE_VERSION): 20240105
Merge with NetBSD make, pick up
o main.c: Cmd_Exec write cmd to a file if too big
avoid blowing commandline/env limits
* VERSION (_MAKE_VERSION): 20240101
o util.c: flesh out more of strftime
* configure.in: add --with-bmake-strftime
it is not a full implementation but enough to pass all
the unit-tests.
* parse.c: LoadFile do not append \n to empty buffer.
* VERSION (_MAKE_VERSION): 20231230
Merge with NetBSD make, pick up
o simplify memory allocation for string buffers
o fix declared types of list nodes
o suff.c: clean up freeing of suffixes
o var.c: simplify debug message for the ':@var@...@' modifier
clean up variable handling
* VERSION (_MAKE_VERSION): 20231226
Merge with NetBSD make, pick up
o compat.c: ensure make's output is correctly ordered with that of
the target when not going to a tty
o main.c: check for shellPath whether to call Shell_Init()
* VERSION (_MAKE_VERSION): 20231224
Merge with NetBSD make, pick up
o compat.c: check for shellPath whether to call Shell_Init()
tweak the unit test to detect the bug thus fixed.
o make.1: do not claim .SHELL is only used by jobs mode.
* VERSION (_MAKE_VERSION): 20231220
Merge with NetBSD make, pick up
o str.c: speed up pattern matching in the ':M' modifier
o var.c: fix confusing debug logging when deleting a variable
use consistent debug messages style when ignoring variables
* VERSION (_MAKE_VERSION): 20231210
Merge with NetBSD make, pick up
o var.c: avoid segfault on empty :C match expression
explain in debug log why variable assignment is ignored.
* VERSION (_MAKE_VERSION): 20231208
Merge with NetBSD make, pick up
o var.c: ensure fromCmd is set correctly for variables set on
command line.
* VERSION (_MAKE_VERSION): 20231124
Merge with NetBSD make, pick up
o main.c: cleanup processing of -j
fix lint warning about strchr
o var.c: more accurate error message for invalid ':mtime' argument
cleanup :[...] modifier
avoid reading beyond substring when comparing
o unit-tests cover all cases of :mtime, test and explain exporting
of variables
o cleanup comments
* bsd.after-import.mk (ECHO_TAG): FreeBSD no longer uses
$FreeBSD$ tag, so avoid adding it.
mk/ChangeLog since bmake-20230909
* dirdeps.mk: for MAKE_VERSION 20240105 we do not have the same
limits on command line length, so skip export of lists to env.
* jobs.mk: avoid C suffix in JOB_MAX_C if factor is floating
point. This keeps JOB_MAX numeric incase another makefile does
comparisons.
* gendirdeps.mk: if META_XTRAS is passed to us, add to META_FILES
2024-01-14 01:16:25 +00:00
|
|
|
if (!opts.noExecute && unlink_file(file) == 0)
|
2021-01-14 01:24:34 +00:00
|
|
|
Error("*** %s removed", file);
|
2016-12-19 21:50:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
/*
|
|
|
|
* Interrupt the creation of the current target and remove it if it ain't
|
2020-09-05 16:11:04 +00:00
|
|
|
* precious. Then exit.
|
1996-10-06 15:57:15 +00:00
|
|
|
*
|
2020-09-05 16:11:04 +00:00
|
|
|
* If .INTERRUPT exists, its commands are run first WITH INTERRUPTS IGNORED.
|
1996-10-06 15:57:15 +00:00
|
|
|
*
|
2016-12-19 21:50:59 +00:00
|
|
|
* XXX: is .PRECIOUS supposed to inhibit .INTERRUPT? I doubt it, but I've
|
|
|
|
* left the logic alone for now. - dholland 20160826
|
1996-10-06 15:57:15 +00:00
|
|
|
*/
|
|
|
|
static void
|
2012-06-08 21:57:36 +00:00
|
|
|
CompatInterrupt(int signo)
|
1996-10-06 15:57:15 +00:00
|
|
|
{
|
2021-01-14 01:24:34 +00:00
|
|
|
CompatDeleteTarget(curTarg);
|
|
|
|
|
2022-02-05 20:03:50 +00:00
|
|
|
if (curTarg != NULL && !GNode_IsPrecious(curTarg)) {
|
Import bmake-20240108
Interesting/relevant changes since bmake-20230909
* VERSION (_MAKE_VERSION): 20240106
Merge with NetBSD make, pick up
o fix duplicate progname when reporting an unknown target
o unit tests for Cmd_Exec using temp file
* VERSION (_MAKE_VERSION): 20240105
Merge with NetBSD make, pick up
o main.c: Cmd_Exec write cmd to a file if too big
avoid blowing commandline/env limits
* VERSION (_MAKE_VERSION): 20240101
o util.c: flesh out more of strftime
* configure.in: add --with-bmake-strftime
it is not a full implementation but enough to pass all
the unit-tests.
* parse.c: LoadFile do not append \n to empty buffer.
* VERSION (_MAKE_VERSION): 20231230
Merge with NetBSD make, pick up
o simplify memory allocation for string buffers
o fix declared types of list nodes
o suff.c: clean up freeing of suffixes
o var.c: simplify debug message for the ':@var@...@' modifier
clean up variable handling
* VERSION (_MAKE_VERSION): 20231226
Merge with NetBSD make, pick up
o compat.c: ensure make's output is correctly ordered with that of
the target when not going to a tty
o main.c: check for shellPath whether to call Shell_Init()
* VERSION (_MAKE_VERSION): 20231224
Merge with NetBSD make, pick up
o compat.c: check for shellPath whether to call Shell_Init()
tweak the unit test to detect the bug thus fixed.
o make.1: do not claim .SHELL is only used by jobs mode.
* VERSION (_MAKE_VERSION): 20231220
Merge with NetBSD make, pick up
o str.c: speed up pattern matching in the ':M' modifier
o var.c: fix confusing debug logging when deleting a variable
use consistent debug messages style when ignoring variables
* VERSION (_MAKE_VERSION): 20231210
Merge with NetBSD make, pick up
o var.c: avoid segfault on empty :C match expression
explain in debug log why variable assignment is ignored.
* VERSION (_MAKE_VERSION): 20231208
Merge with NetBSD make, pick up
o var.c: ensure fromCmd is set correctly for variables set on
command line.
* VERSION (_MAKE_VERSION): 20231124
Merge with NetBSD make, pick up
o main.c: cleanup processing of -j
fix lint warning about strchr
o var.c: more accurate error message for invalid ':mtime' argument
cleanup :[...] modifier
avoid reading beyond substring when comparing
o unit-tests cover all cases of :mtime, test and explain exporting
of variables
o cleanup comments
* bsd.after-import.mk (ECHO_TAG): FreeBSD no longer uses
$FreeBSD$ tag, so avoid adding it.
mk/ChangeLog since bmake-20230909
* dirdeps.mk: for MAKE_VERSION 20240105 we do not have the same
limits on command line length, so skip export of lists to env.
* jobs.mk: avoid C suffix in JOB_MAX_C if factor is floating
point. This keeps JOB_MAX numeric incase another makefile does
comparisons.
* gendirdeps.mk: if META_XTRAS is passed to us, add to META_FILES
2024-01-14 01:16:25 +00:00
|
|
|
/* Run .INTERRUPT only if hit with interrupt signal. */
|
2021-01-14 01:24:34 +00:00
|
|
|
if (signo == SIGINT) {
|
|
|
|
GNode *gn = Targ_FindNode(".INTERRUPT");
|
Import bmake-20240108
Interesting/relevant changes since bmake-20230909
* VERSION (_MAKE_VERSION): 20240106
Merge with NetBSD make, pick up
o fix duplicate progname when reporting an unknown target
o unit tests for Cmd_Exec using temp file
* VERSION (_MAKE_VERSION): 20240105
Merge with NetBSD make, pick up
o main.c: Cmd_Exec write cmd to a file if too big
avoid blowing commandline/env limits
* VERSION (_MAKE_VERSION): 20240101
o util.c: flesh out more of strftime
* configure.in: add --with-bmake-strftime
it is not a full implementation but enough to pass all
the unit-tests.
* parse.c: LoadFile do not append \n to empty buffer.
* VERSION (_MAKE_VERSION): 20231230
Merge with NetBSD make, pick up
o simplify memory allocation for string buffers
o fix declared types of list nodes
o suff.c: clean up freeing of suffixes
o var.c: simplify debug message for the ':@var@...@' modifier
clean up variable handling
* VERSION (_MAKE_VERSION): 20231226
Merge with NetBSD make, pick up
o compat.c: ensure make's output is correctly ordered with that of
the target when not going to a tty
o main.c: check for shellPath whether to call Shell_Init()
* VERSION (_MAKE_VERSION): 20231224
Merge with NetBSD make, pick up
o compat.c: check for shellPath whether to call Shell_Init()
tweak the unit test to detect the bug thus fixed.
o make.1: do not claim .SHELL is only used by jobs mode.
* VERSION (_MAKE_VERSION): 20231220
Merge with NetBSD make, pick up
o str.c: speed up pattern matching in the ':M' modifier
o var.c: fix confusing debug logging when deleting a variable
use consistent debug messages style when ignoring variables
* VERSION (_MAKE_VERSION): 20231210
Merge with NetBSD make, pick up
o var.c: avoid segfault on empty :C match expression
explain in debug log why variable assignment is ignored.
* VERSION (_MAKE_VERSION): 20231208
Merge with NetBSD make, pick up
o var.c: ensure fromCmd is set correctly for variables set on
command line.
* VERSION (_MAKE_VERSION): 20231124
Merge with NetBSD make, pick up
o main.c: cleanup processing of -j
fix lint warning about strchr
o var.c: more accurate error message for invalid ':mtime' argument
cleanup :[...] modifier
avoid reading beyond substring when comparing
o unit-tests cover all cases of :mtime, test and explain exporting
of variables
o cleanup comments
* bsd.after-import.mk (ECHO_TAG): FreeBSD no longer uses
$FreeBSD$ tag, so avoid adding it.
mk/ChangeLog since bmake-20230909
* dirdeps.mk: for MAKE_VERSION 20240105 we do not have the same
limits on command line length, so skip export of lists to env.
* jobs.mk: avoid C suffix in JOB_MAX_C if factor is floating
point. This keeps JOB_MAX numeric incase another makefile does
comparisons.
* gendirdeps.mk: if META_XTRAS is passed to us, add to META_FILES
2024-01-14 01:16:25 +00:00
|
|
|
if (gn != NULL)
|
2021-01-14 01:24:34 +00:00
|
|
|
Compat_Make(gn, gn);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (signo == SIGQUIT)
|
|
|
|
_exit(signo);
|
1996-10-06 15:57:15 +00:00
|
|
|
|
|
|
|
/*
|
2021-01-14 01:24:34 +00:00
|
|
|
* If there is a child running, pass the signal on.
|
|
|
|
* We will exist after it has exited.
|
1996-10-06 15:57:15 +00:00
|
|
|
*/
|
2021-01-14 01:24:34 +00:00
|
|
|
compatSigno = signo;
|
|
|
|
if (compatChild > 0) {
|
|
|
|
KILLPG(compatChild, signo);
|
|
|
|
} else {
|
|
|
|
bmake_signal(signo, SIG_DFL);
|
|
|
|
kill(myPid, signo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-06-25 18:16:24 +00:00
|
|
|
DebugFailedTarget(const char *cmd, const GNode *gn)
|
2021-01-14 01:24:34 +00:00
|
|
|
{
|
|
|
|
const char *p = cmd;
|
|
|
|
debug_printf("\n*** Failed target: %s\n*** Failed command: ",
|
2022-02-05 20:03:50 +00:00
|
|
|
gn->name);
|
2021-01-14 01:24:34 +00:00
|
|
|
|
2022-02-05 20:03:50 +00:00
|
|
|
/*
|
|
|
|
* Replace runs of whitespace with a single space, to reduce the
|
|
|
|
* amount of whitespace for multi-line command lines.
|
|
|
|
*/
|
2021-01-14 01:24:34 +00:00
|
|
|
while (*p != '\0') {
|
|
|
|
if (ch_isspace(*p)) {
|
|
|
|
debug_printf(" ");
|
|
|
|
cpp_skip_whitespace(&p);
|
|
|
|
} else {
|
|
|
|
debug_printf("%c", *p);
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
debug_printf("\n");
|
1996-10-06 15:57:15 +00:00
|
|
|
}
|
2020-09-05 16:11:04 +00:00
|
|
|
|
2021-06-25 18:16:24 +00:00
|
|
|
static bool
|
2021-01-14 01:24:34 +00:00
|
|
|
UseShell(const char *cmd MAKE_ATTR_UNUSED)
|
|
|
|
{
|
2021-12-18 07:27:22 +00:00
|
|
|
#if defined(FORCE_USE_SHELL) || !defined(MAKE_NATIVE)
|
2021-01-14 01:24:34 +00:00
|
|
|
/*
|
|
|
|
* In a non-native build, the host environment might be weird enough
|
|
|
|
* that it's necessary to go through a shell to get the correct
|
|
|
|
* behaviour. Or perhaps the shell has been replaced with something
|
|
|
|
* that does extra logging, and that should not be bypassed.
|
|
|
|
*/
|
2021-06-25 18:16:24 +00:00
|
|
|
return true;
|
2021-01-14 01:24:34 +00:00
|
|
|
#else
|
|
|
|
/*
|
|
|
|
* Search for meta characters in the command. If there are no meta
|
|
|
|
* characters, there's no need to execute a shell to execute the
|
|
|
|
* command.
|
|
|
|
*
|
|
|
|
* Additionally variable assignments and empty commands
|
|
|
|
* go to the shell. Therefore treat '=' and ':' like shell
|
|
|
|
* meta characters as documented in make(1).
|
|
|
|
*/
|
|
|
|
|
|
|
|
return needshell(cmd);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Execute the next command for a target. If the command returns an error,
|
2020-11-07 19:39:21 +00:00
|
|
|
* the node's made field is set to ERROR and creation stops.
|
1996-10-06 15:57:15 +00:00
|
|
|
*
|
2012-06-08 21:57:36 +00:00
|
|
|
* Input:
|
|
|
|
* cmdp Command to execute
|
2021-01-14 01:24:34 +00:00
|
|
|
* gn Node from which the command came
|
|
|
|
* ln List node that contains the command
|
2012-06-08 21:57:36 +00:00
|
|
|
*
|
1996-10-06 15:57:15 +00:00
|
|
|
* Results:
|
2022-02-05 20:03:50 +00:00
|
|
|
* true if the command succeeded.
|
1996-10-06 15:57:15 +00:00
|
|
|
*/
|
2022-02-05 20:03:50 +00:00
|
|
|
bool
|
2021-01-14 01:24:34 +00:00
|
|
|
Compat_RunCommand(const char *cmdp, GNode *gn, StringListNode *ln)
|
1996-10-06 15:57:15 +00:00
|
|
|
{
|
2021-01-14 01:24:34 +00:00
|
|
|
char *cmdStart; /* Start of expanded command */
|
2023-05-13 17:03:50 +00:00
|
|
|
char *volatile bp;
|
2021-06-25 18:16:24 +00:00
|
|
|
bool silent; /* Don't print command */
|
|
|
|
bool doIt; /* Execute even if -n */
|
2022-02-05 20:03:50 +00:00
|
|
|
volatile bool errCheck; /* Check errors */
|
2021-01-14 01:24:34 +00:00
|
|
|
WAIT_T reason; /* Reason for child's death */
|
|
|
|
WAIT_T status; /* Description of child's death */
|
|
|
|
pid_t cpid; /* Child actually found */
|
|
|
|
pid_t retstat; /* Result of wait */
|
|
|
|
const char **volatile av; /* Argument vector for thing to exec */
|
|
|
|
char **volatile mav; /* Copy of the argument vector for freeing */
|
2022-02-05 20:03:50 +00:00
|
|
|
bool useShell; /* True if command should be executed using a
|
|
|
|
* shell */
|
2021-01-14 01:24:34 +00:00
|
|
|
const char *volatile cmd = cmdp;
|
1996-10-06 15:57:15 +00:00
|
|
|
|
2021-12-18 07:27:22 +00:00
|
|
|
silent = (gn->type & OP_SILENT) != OP_NONE;
|
2021-01-14 01:24:34 +00:00
|
|
|
errCheck = !(gn->type & OP_IGNORE);
|
2021-06-25 18:16:24 +00:00
|
|
|
doIt = false;
|
2012-06-08 21:57:36 +00:00
|
|
|
|
Import bmake-20240430
Intersting/relevant changes since bmake-20240309
ChangeLog since bmake-20240309
2024-04-30 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240430
Merge with NetBSD make, pick up
o main.c: ensure '.include <makefile>' respects MAKESYSPATH.
Dir_FindFile will search .CURDIR first unless ".DOTLAST" is seen.
2024-04-28 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240428
Merge with NetBSD make, pick up
o simplify freeing of lists
o arch.c: trim pointless comments
o var.c: delay variable assignments until actually needed
don't reallocate memory after evaluating an expression, result is
almost always short-lived.
2024-04-26 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240426
Merge with NetBSD make, pick up
o job.c: in debug output, print the directory in which a job
failed at same time as failed target so it is more easily found in
build log.
2024-04-24 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240424
Merge with NetBSD make, pick up
o clean up comments, code and tests
2024-04-23 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240422
Merge with NetBSD make, pick up
o var.c: avoid LazyBuf for :*time modifiers.
LazyBuf's are not nul terminated so not suitable for passing to
functions that expect that. These modifiers are used sparingly so
an extra allocation is not a problem.
2024-04-20 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240420
Merge with NetBSD make, pick up
o provide more context information for parse/evaluate errors
2024-04-14 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240414
Merge with NetBSD make, pick up
o parse.c: print -dp debug info earlier so we see which
.if or .for line is being parsed.
2024-04-04 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240404
Merge with NetBSD make, pick up
o fix some unit tests for Cygwin
o parse.c: exit immediately after reading a null byte from a makefile
* fix generation of bmake.cat1
2024-03-19 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240314
Add/Improve support for Cygwin
o uname -s output isn't useful so allow configure to
set FORCE_MAKE_OS - to force the value of .MAKE.OS
and use Cygwin which matches uname -o
o fix some unit-tests for Cygwin
* configure.in: use_makefile=no for Cygwin et al.
NOTE: bmake does not support Cygwin and likely never will,
mk/ChangeLog since bmake-20240309
2024-04-24 Simon J Gerraty <sjg@beast.crufty.net>
* meta.autodep.mk: do not override start_utc
2024-04-18 Simon J Gerraty <sjg@beast.crufty.net>
* sys.dirdeps.mk: set defaults for DEP_* at level 0 too.
These help when first include of Makefile.depend happens in a leaf
dir.
* install-mk (MK_VERSION): 20240414
2024-04-09 Simon J Gerraty <sjg@beast.crufty.net>
* install-mk (MK_VERSION): 20240408
* init.mk: allow for _ as well as . to join V
and Q from QUALIFIED_VAR_LIST and VAR_QUALIFIER_LIST.
* progs.mk: avoid overlap between PROG_VARS and
init.mk's QUALIFIED_VAR_LIST since PROG would also
match its VAR_QUALIFIER_LIST,
libs.mk does not have the same issue.
* subdir.mk: _SUBDIRUSE for realinstall should run install
remove include of ${.CURDIR}/Makefile.inc that can be done via
local.subdir.mk where needed
* own.mk: do not conflict with man.mk
2024-03-19 Simon J Gerraty <sjg@beast.crufty.net>
* install-mk (MK_VERSION): 20240314
* add sys/Cygwin.mk from Christian Franke
2024-05-03 22:43:12 +00:00
|
|
|
EvalStack_Push(gn->name, NULL, NULL);
|
2023-04-24 23:44:30 +00:00
|
|
|
cmdStart = Var_Subst(cmd, gn, VARE_WANTRES);
|
Import bmake-20240430
Intersting/relevant changes since bmake-20240309
ChangeLog since bmake-20240309
2024-04-30 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240430
Merge with NetBSD make, pick up
o main.c: ensure '.include <makefile>' respects MAKESYSPATH.
Dir_FindFile will search .CURDIR first unless ".DOTLAST" is seen.
2024-04-28 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240428
Merge with NetBSD make, pick up
o simplify freeing of lists
o arch.c: trim pointless comments
o var.c: delay variable assignments until actually needed
don't reallocate memory after evaluating an expression, result is
almost always short-lived.
2024-04-26 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240426
Merge with NetBSD make, pick up
o job.c: in debug output, print the directory in which a job
failed at same time as failed target so it is more easily found in
build log.
2024-04-24 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240424
Merge with NetBSD make, pick up
o clean up comments, code and tests
2024-04-23 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240422
Merge with NetBSD make, pick up
o var.c: avoid LazyBuf for :*time modifiers.
LazyBuf's are not nul terminated so not suitable for passing to
functions that expect that. These modifiers are used sparingly so
an extra allocation is not a problem.
2024-04-20 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240420
Merge with NetBSD make, pick up
o provide more context information for parse/evaluate errors
2024-04-14 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240414
Merge with NetBSD make, pick up
o parse.c: print -dp debug info earlier so we see which
.if or .for line is being parsed.
2024-04-04 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240404
Merge with NetBSD make, pick up
o fix some unit tests for Cygwin
o parse.c: exit immediately after reading a null byte from a makefile
* fix generation of bmake.cat1
2024-03-19 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240314
Add/Improve support for Cygwin
o uname -s output isn't useful so allow configure to
set FORCE_MAKE_OS - to force the value of .MAKE.OS
and use Cygwin which matches uname -o
o fix some unit-tests for Cygwin
* configure.in: use_makefile=no for Cygwin et al.
NOTE: bmake does not support Cygwin and likely never will,
mk/ChangeLog since bmake-20240309
2024-04-24 Simon J Gerraty <sjg@beast.crufty.net>
* meta.autodep.mk: do not override start_utc
2024-04-18 Simon J Gerraty <sjg@beast.crufty.net>
* sys.dirdeps.mk: set defaults for DEP_* at level 0 too.
These help when first include of Makefile.depend happens in a leaf
dir.
* install-mk (MK_VERSION): 20240414
2024-04-09 Simon J Gerraty <sjg@beast.crufty.net>
* install-mk (MK_VERSION): 20240408
* init.mk: allow for _ as well as . to join V
and Q from QUALIFIED_VAR_LIST and VAR_QUALIFIER_LIST.
* progs.mk: avoid overlap between PROG_VARS and
init.mk's QUALIFIED_VAR_LIST since PROG would also
match its VAR_QUALIFIER_LIST,
libs.mk does not have the same issue.
* subdir.mk: _SUBDIRUSE for realinstall should run install
remove include of ${.CURDIR}/Makefile.inc that can be done via
local.subdir.mk where needed
* own.mk: do not conflict with man.mk
2024-03-19 Simon J Gerraty <sjg@beast.crufty.net>
* install-mk (MK_VERSION): 20240314
* add sys/Cygwin.mk from Christian Franke
2024-05-03 22:43:12 +00:00
|
|
|
EvalStack_Pop();
|
2021-01-14 01:24:34 +00:00
|
|
|
/* TODO: handle errors */
|
2012-06-08 21:57:36 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
if (cmdStart[0] == '\0') {
|
|
|
|
free(cmdStart);
|
2022-02-05 20:03:50 +00:00
|
|
|
return true;
|
2021-01-14 01:24:34 +00:00
|
|
|
}
|
|
|
|
cmd = cmdStart;
|
|
|
|
LstNode_Set(ln, cmdStart);
|
|
|
|
|
|
|
|
if (gn->type & OP_SAVE_CMDS) {
|
|
|
|
GNode *endNode = Targ_GetEndNode();
|
|
|
|
if (gn != endNode) {
|
|
|
|
/*
|
|
|
|
* Append the expanded command, to prevent the
|
|
|
|
* local variables from being interpreted in the
|
2021-02-11 01:51:11 +00:00
|
|
|
* scope of the .END node.
|
2021-01-14 01:24:34 +00:00
|
|
|
*
|
|
|
|
* A probably unintended side effect of this is that
|
|
|
|
* the expanded command will be expanded again in the
|
|
|
|
* .END node. Therefore, a literal '$' in these
|
|
|
|
* commands must be written as '$$$$' instead of the
|
|
|
|
* usual '$$'.
|
|
|
|
*/
|
|
|
|
Lst_Append(&endNode->commands, cmdStart);
|
2022-02-05 20:03:50 +00:00
|
|
|
return true;
|
2021-01-14 01:24:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (strcmp(cmdStart, "...") == 0) {
|
|
|
|
gn->type |= OP_SAVE_CMDS;
|
2022-02-05 20:03:50 +00:00
|
|
|
return true;
|
2021-01-14 01:24:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
if (*cmd == '@')
|
|
|
|
silent = !DEBUG(LOUD);
|
|
|
|
else if (*cmd == '-')
|
2021-06-25 18:16:24 +00:00
|
|
|
errCheck = false;
|
Import bmake-20240108
Interesting/relevant changes since bmake-20230909
* VERSION (_MAKE_VERSION): 20240106
Merge with NetBSD make, pick up
o fix duplicate progname when reporting an unknown target
o unit tests for Cmd_Exec using temp file
* VERSION (_MAKE_VERSION): 20240105
Merge with NetBSD make, pick up
o main.c: Cmd_Exec write cmd to a file if too big
avoid blowing commandline/env limits
* VERSION (_MAKE_VERSION): 20240101
o util.c: flesh out more of strftime
* configure.in: add --with-bmake-strftime
it is not a full implementation but enough to pass all
the unit-tests.
* parse.c: LoadFile do not append \n to empty buffer.
* VERSION (_MAKE_VERSION): 20231230
Merge with NetBSD make, pick up
o simplify memory allocation for string buffers
o fix declared types of list nodes
o suff.c: clean up freeing of suffixes
o var.c: simplify debug message for the ':@var@...@' modifier
clean up variable handling
* VERSION (_MAKE_VERSION): 20231226
Merge with NetBSD make, pick up
o compat.c: ensure make's output is correctly ordered with that of
the target when not going to a tty
o main.c: check for shellPath whether to call Shell_Init()
* VERSION (_MAKE_VERSION): 20231224
Merge with NetBSD make, pick up
o compat.c: check for shellPath whether to call Shell_Init()
tweak the unit test to detect the bug thus fixed.
o make.1: do not claim .SHELL is only used by jobs mode.
* VERSION (_MAKE_VERSION): 20231220
Merge with NetBSD make, pick up
o str.c: speed up pattern matching in the ':M' modifier
o var.c: fix confusing debug logging when deleting a variable
use consistent debug messages style when ignoring variables
* VERSION (_MAKE_VERSION): 20231210
Merge with NetBSD make, pick up
o var.c: avoid segfault on empty :C match expression
explain in debug log why variable assignment is ignored.
* VERSION (_MAKE_VERSION): 20231208
Merge with NetBSD make, pick up
o var.c: ensure fromCmd is set correctly for variables set on
command line.
* VERSION (_MAKE_VERSION): 20231124
Merge with NetBSD make, pick up
o main.c: cleanup processing of -j
fix lint warning about strchr
o var.c: more accurate error message for invalid ':mtime' argument
cleanup :[...] modifier
avoid reading beyond substring when comparing
o unit-tests cover all cases of :mtime, test and explain exporting
of variables
o cleanup comments
* bsd.after-import.mk (ECHO_TAG): FreeBSD no longer uses
$FreeBSD$ tag, so avoid adding it.
mk/ChangeLog since bmake-20230909
* dirdeps.mk: for MAKE_VERSION 20240105 we do not have the same
limits on command line length, so skip export of lists to env.
* jobs.mk: avoid C suffix in JOB_MAX_C if factor is floating
point. This keeps JOB_MAX numeric incase another makefile does
comparisons.
* gendirdeps.mk: if META_XTRAS is passed to us, add to META_FILES
2024-01-14 01:16:25 +00:00
|
|
|
else if (*cmd == '+')
|
2021-06-25 18:16:24 +00:00
|
|
|
doIt = true;
|
Import bmake-20240108
Interesting/relevant changes since bmake-20230909
* VERSION (_MAKE_VERSION): 20240106
Merge with NetBSD make, pick up
o fix duplicate progname when reporting an unknown target
o unit tests for Cmd_Exec using temp file
* VERSION (_MAKE_VERSION): 20240105
Merge with NetBSD make, pick up
o main.c: Cmd_Exec write cmd to a file if too big
avoid blowing commandline/env limits
* VERSION (_MAKE_VERSION): 20240101
o util.c: flesh out more of strftime
* configure.in: add --with-bmake-strftime
it is not a full implementation but enough to pass all
the unit-tests.
* parse.c: LoadFile do not append \n to empty buffer.
* VERSION (_MAKE_VERSION): 20231230
Merge with NetBSD make, pick up
o simplify memory allocation for string buffers
o fix declared types of list nodes
o suff.c: clean up freeing of suffixes
o var.c: simplify debug message for the ':@var@...@' modifier
clean up variable handling
* VERSION (_MAKE_VERSION): 20231226
Merge with NetBSD make, pick up
o compat.c: ensure make's output is correctly ordered with that of
the target when not going to a tty
o main.c: check for shellPath whether to call Shell_Init()
* VERSION (_MAKE_VERSION): 20231224
Merge with NetBSD make, pick up
o compat.c: check for shellPath whether to call Shell_Init()
tweak the unit test to detect the bug thus fixed.
o make.1: do not claim .SHELL is only used by jobs mode.
* VERSION (_MAKE_VERSION): 20231220
Merge with NetBSD make, pick up
o str.c: speed up pattern matching in the ':M' modifier
o var.c: fix confusing debug logging when deleting a variable
use consistent debug messages style when ignoring variables
* VERSION (_MAKE_VERSION): 20231210
Merge with NetBSD make, pick up
o var.c: avoid segfault on empty :C match expression
explain in debug log why variable assignment is ignored.
* VERSION (_MAKE_VERSION): 20231208
Merge with NetBSD make, pick up
o var.c: ensure fromCmd is set correctly for variables set on
command line.
* VERSION (_MAKE_VERSION): 20231124
Merge with NetBSD make, pick up
o main.c: cleanup processing of -j
fix lint warning about strchr
o var.c: more accurate error message for invalid ':mtime' argument
cleanup :[...] modifier
avoid reading beyond substring when comparing
o unit-tests cover all cases of :mtime, test and explain exporting
of variables
o cleanup comments
* bsd.after-import.mk (ECHO_TAG): FreeBSD no longer uses
$FreeBSD$ tag, so avoid adding it.
mk/ChangeLog since bmake-20230909
* dirdeps.mk: for MAKE_VERSION 20240105 we do not have the same
limits on command line length, so skip export of lists to env.
* jobs.mk: avoid C suffix in JOB_MAX_C if factor is floating
point. This keeps JOB_MAX numeric incase another makefile does
comparisons.
* gendirdeps.mk: if META_XTRAS is passed to us, add to META_FILES
2024-01-14 01:16:25 +00:00
|
|
|
else if (!ch_isspace(*cmd))
|
2023-01-28 00:23:54 +00:00
|
|
|
/* Ignore whitespace for compatibility with gnu make */
|
2021-01-14 01:24:34 +00:00
|
|
|
break;
|
|
|
|
cmd++;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (ch_isspace(*cmd))
|
|
|
|
cmd++;
|
|
|
|
if (cmd[0] == '\0')
|
2022-02-05 20:03:50 +00:00
|
|
|
return true;
|
2021-01-14 01:24:34 +00:00
|
|
|
|
|
|
|
useShell = UseShell(cmd);
|
Import bmake-20240108
Interesting/relevant changes since bmake-20230909
* VERSION (_MAKE_VERSION): 20240106
Merge with NetBSD make, pick up
o fix duplicate progname when reporting an unknown target
o unit tests for Cmd_Exec using temp file
* VERSION (_MAKE_VERSION): 20240105
Merge with NetBSD make, pick up
o main.c: Cmd_Exec write cmd to a file if too big
avoid blowing commandline/env limits
* VERSION (_MAKE_VERSION): 20240101
o util.c: flesh out more of strftime
* configure.in: add --with-bmake-strftime
it is not a full implementation but enough to pass all
the unit-tests.
* parse.c: LoadFile do not append \n to empty buffer.
* VERSION (_MAKE_VERSION): 20231230
Merge with NetBSD make, pick up
o simplify memory allocation for string buffers
o fix declared types of list nodes
o suff.c: clean up freeing of suffixes
o var.c: simplify debug message for the ':@var@...@' modifier
clean up variable handling
* VERSION (_MAKE_VERSION): 20231226
Merge with NetBSD make, pick up
o compat.c: ensure make's output is correctly ordered with that of
the target when not going to a tty
o main.c: check for shellPath whether to call Shell_Init()
* VERSION (_MAKE_VERSION): 20231224
Merge with NetBSD make, pick up
o compat.c: check for shellPath whether to call Shell_Init()
tweak the unit test to detect the bug thus fixed.
o make.1: do not claim .SHELL is only used by jobs mode.
* VERSION (_MAKE_VERSION): 20231220
Merge with NetBSD make, pick up
o str.c: speed up pattern matching in the ':M' modifier
o var.c: fix confusing debug logging when deleting a variable
use consistent debug messages style when ignoring variables
* VERSION (_MAKE_VERSION): 20231210
Merge with NetBSD make, pick up
o var.c: avoid segfault on empty :C match expression
explain in debug log why variable assignment is ignored.
* VERSION (_MAKE_VERSION): 20231208
Merge with NetBSD make, pick up
o var.c: ensure fromCmd is set correctly for variables set on
command line.
* VERSION (_MAKE_VERSION): 20231124
Merge with NetBSD make, pick up
o main.c: cleanup processing of -j
fix lint warning about strchr
o var.c: more accurate error message for invalid ':mtime' argument
cleanup :[...] modifier
avoid reading beyond substring when comparing
o unit-tests cover all cases of :mtime, test and explain exporting
of variables
o cleanup comments
* bsd.after-import.mk (ECHO_TAG): FreeBSD no longer uses
$FreeBSD$ tag, so avoid adding it.
mk/ChangeLog since bmake-20230909
* dirdeps.mk: for MAKE_VERSION 20240105 we do not have the same
limits on command line length, so skip export of lists to env.
* jobs.mk: avoid C suffix in JOB_MAX_C if factor is floating
point. This keeps JOB_MAX numeric incase another makefile does
comparisons.
* gendirdeps.mk: if META_XTRAS is passed to us, add to META_FILES
2024-01-14 01:16:25 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
if (!silent || !GNode_ShouldExecute(gn)) {
|
|
|
|
printf("%s\n", cmd);
|
|
|
|
fflush(stdout);
|
|
|
|
}
|
2012-06-08 21:57:36 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
if (!doIt && !GNode_ShouldExecute(gn))
|
2022-02-05 20:03:50 +00:00
|
|
|
return true;
|
2021-01-14 01:24:34 +00:00
|
|
|
|
|
|
|
DEBUG1(JOB, "Execute: '%s'\n", cmd);
|
|
|
|
|
Import bmake-20240108
Interesting/relevant changes since bmake-20230909
* VERSION (_MAKE_VERSION): 20240106
Merge with NetBSD make, pick up
o fix duplicate progname when reporting an unknown target
o unit tests for Cmd_Exec using temp file
* VERSION (_MAKE_VERSION): 20240105
Merge with NetBSD make, pick up
o main.c: Cmd_Exec write cmd to a file if too big
avoid blowing commandline/env limits
* VERSION (_MAKE_VERSION): 20240101
o util.c: flesh out more of strftime
* configure.in: add --with-bmake-strftime
it is not a full implementation but enough to pass all
the unit-tests.
* parse.c: LoadFile do not append \n to empty buffer.
* VERSION (_MAKE_VERSION): 20231230
Merge with NetBSD make, pick up
o simplify memory allocation for string buffers
o fix declared types of list nodes
o suff.c: clean up freeing of suffixes
o var.c: simplify debug message for the ':@var@...@' modifier
clean up variable handling
* VERSION (_MAKE_VERSION): 20231226
Merge with NetBSD make, pick up
o compat.c: ensure make's output is correctly ordered with that of
the target when not going to a tty
o main.c: check for shellPath whether to call Shell_Init()
* VERSION (_MAKE_VERSION): 20231224
Merge with NetBSD make, pick up
o compat.c: check for shellPath whether to call Shell_Init()
tweak the unit test to detect the bug thus fixed.
o make.1: do not claim .SHELL is only used by jobs mode.
* VERSION (_MAKE_VERSION): 20231220
Merge with NetBSD make, pick up
o str.c: speed up pattern matching in the ':M' modifier
o var.c: fix confusing debug logging when deleting a variable
use consistent debug messages style when ignoring variables
* VERSION (_MAKE_VERSION): 20231210
Merge with NetBSD make, pick up
o var.c: avoid segfault on empty :C match expression
explain in debug log why variable assignment is ignored.
* VERSION (_MAKE_VERSION): 20231208
Merge with NetBSD make, pick up
o var.c: ensure fromCmd is set correctly for variables set on
command line.
* VERSION (_MAKE_VERSION): 20231124
Merge with NetBSD make, pick up
o main.c: cleanup processing of -j
fix lint warning about strchr
o var.c: more accurate error message for invalid ':mtime' argument
cleanup :[...] modifier
avoid reading beyond substring when comparing
o unit-tests cover all cases of :mtime, test and explain exporting
of variables
o cleanup comments
* bsd.after-import.mk (ECHO_TAG): FreeBSD no longer uses
$FreeBSD$ tag, so avoid adding it.
mk/ChangeLog since bmake-20230909
* dirdeps.mk: for MAKE_VERSION 20240105 we do not have the same
limits on command line length, so skip export of lists to env.
* jobs.mk: avoid C suffix in JOB_MAX_C if factor is floating
point. This keeps JOB_MAX numeric incase another makefile does
comparisons.
* gendirdeps.mk: if META_XTRAS is passed to us, add to META_FILES
2024-01-14 01:16:25 +00:00
|
|
|
if (useShell && shellPath == NULL)
|
|
|
|
Shell_Init(); /* we need shellPath */
|
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
if (useShell) {
|
|
|
|
static const char *shargv[5];
|
|
|
|
|
|
|
|
/* The following work for any of the builtin shell specs. */
|
|
|
|
int shargc = 0;
|
|
|
|
shargv[shargc++] = shellPath;
|
|
|
|
if (errCheck && shellErrFlag != NULL)
|
|
|
|
shargv[shargc++] = shellErrFlag;
|
|
|
|
shargv[shargc++] = DEBUG(SHELL) ? "-xc" : "-c";
|
|
|
|
shargv[shargc++] = cmd;
|
|
|
|
shargv[shargc] = NULL;
|
|
|
|
av = shargv;
|
|
|
|
bp = NULL;
|
|
|
|
mav = NULL;
|
|
|
|
} else {
|
2021-06-25 18:16:24 +00:00
|
|
|
Words words = Str_Words(cmd, false);
|
2021-01-14 01:24:34 +00:00
|
|
|
mav = words.words;
|
|
|
|
bp = words.freeIt;
|
|
|
|
av = (void *)mav;
|
|
|
|
}
|
2020-07-08 18:32:15 +00:00
|
|
|
|
2012-06-08 21:57:36 +00:00
|
|
|
#ifdef USE_META
|
2022-02-05 20:03:50 +00:00
|
|
|
if (useMeta)
|
2021-01-14 01:24:34 +00:00
|
|
|
meta_compat_start();
|
2012-06-08 21:57:36 +00:00
|
|
|
#endif
|
2016-03-11 00:37:02 +00:00
|
|
|
|
Import bmake-20240309
Intersting/relevant changes since bmake-20240108
ChangeLog since bmake-20240108
2024-03-10 Simon J Gerraty <sjg@beast.crufty.net>
* boot-strap: tests can take a long time; use a cookie to
skip them if bmake has not been updated since tests last
ran successfully.
* Makefile: Cygwin handles MANTARGET man
* unit-tests/Makefile: set BROKEN_TESTS for Cygwin
2024-03-09 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240309
Merge with NetBSD make, pick up
o set .ERROR_EXIT to the exit status of .ERROR_TARGET
this allows a .ERROR target to ignore the case of
.ERROR_EXIT==6 which just means that the build actually
failed somewhere else.
2024-03-04 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240303
* var.c: on IRIX we need both inttypes.h and stdint.h
2024-03-01 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240301
Merge with NetBSD make, pick up
o export variables with value from target scope
when appropriate.
2024-02-12 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240212
Merge with NetBSD make, pick up
o remove unneeded conditional-compilation toggles
INCLUDES, LIBRARIES, POSIX, SYSVINCLUDE, SYSVVARSUB,
GMAKEEXPORT NO_REGEX and SUNSHCMD
* configure.in: add check for regex.h
* var.c: replace use of NO_REGEX with HAVE_REGEX_H
2024-02-04 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240204
Merge with NetBSD make, pick up
o var.c: fix some lint (-dL) mode parsing issues
2024-02-02 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION: (_MAKE_VERSION): 20240202
Merge with NetBSD make, pick up
o make.1: note that arg to :D and :U can be empty
o var.c: $$ is not a parse error when .MAKE.SAVE_DOLLARS=no
mk/ChangeLog since bmake-20240108
2024-03-09 Simon J Gerraty <sjg@beast.crufty.net>
* install-mk (MK_VERSION): 20240309
* meta.sys.mk: _metaError: if .ERROR_EXIT == 6, we do not
want to save the .ERROR_META_FILE
2024-02-20 Simon J Gerraty <sjg@beast.crufty.net>
* install-mk (MK_VERSION): 20240220
* sys.dirdeps.mk, dirdeps-targets.mk, init.mk:
do not set .MAIN: dirdeps in sys.dirdeps.mk
dirdeps-targets.mk will do that for top-level builds
and init.mk will do it for others.
This allows a Makefile which has no need of 'dirdeps' to
set .MAIN for itself and "just work".
2024-02-18 Simon J Gerraty <sjg@beast.crufty.net>
* bsd.*.mk: for makefiles that get a bsd. symlink,
use _this in multiple inclusion tags since .PARSEFILE will not
DTRT when such a makefile is included directly by Makefile and
automatically (without bsd. prefix).
Since we cannot guarantee that our sys.mk will be used, we provide
a default _this in each makefile that gets a bsd. prefix such that
the value is the same regardless of bsd. prefix.
* subdir.mk: drop the !target guard on $SUBDIR_TARGETS
2024-02-12 Simon J Gerraty <sjg@beast.crufty.net>
* install-mk (MK_VERSION): 20240212
* SPDX-License-Identifier: BSD-2-Clause
Add SPDX-License-Identifier to inidicate that I consider
my copyright on any of these makefiles equivalent to BSD-2-Clause
* autoconf.mk: allow for configure.ac as currently recommended
* subdir.mk: support @auto
which is replaced with each subdir that
has a [Mm]akefile.
* subdir.mk: include local.subdir.mk if it exists.
* subdir.mk: rework to handle .WAIT
2024-02-11 Simon J Gerraty <sjg@beast.crufty.net>
* subdir.mk: _SUBDIRUSE report the target we are entering subdirs for.
2024-02-10 Simon J Gerraty <sjg@beast.crufty.net>
* prog.mk: treat empty SRCS the same as undefined
2024-02-02 Simon J Gerraty <sjg@beast.crufty.net>
* Avoid undefined errors in lint (-dL) mode
* man.mk (CMT2DOC_FLAGS): note that -mm does mdoc(7)
2024-01-28 Simon J Gerraty <sjg@beast.crufty.net>
* install-mk (MK_VERSION): 20240128
* FILES: add ccm.dep.mk for C++ modules
add suffixes.mk for common location for generic SUFFIX rules.
* auto.dep.mk autodep.mk meta.autodep.mk: include ccm.dep.mk
replace OBJ_EXTENSIONS with OBJ_SUFFIXES
* autodep.mk: leverage CXX_SUFFIXES for __depsrcs
and update style (spaces around = etc)
* init.mk: add OBJS_SRCS_FILTER to filter SRCS when
setting OBJS
* meta2deps.py: handle multiple ./ embedded in path better.
2024-03-14 02:14:41 +00:00
|
|
|
Var_ReexportVars(gn);
|
2016-03-11 00:37:02 +00:00
|
|
|
|
2021-02-11 01:51:11 +00:00
|
|
|
compatChild = cpid = vfork();
|
2022-02-05 20:03:50 +00:00
|
|
|
if (cpid < 0)
|
2021-01-14 01:24:34 +00:00
|
|
|
Fatal("Could not fork");
|
2022-02-05 20:03:50 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
if (cpid == 0) {
|
|
|
|
#ifdef USE_META
|
2022-02-05 20:03:50 +00:00
|
|
|
if (useMeta)
|
2021-01-14 01:24:34 +00:00
|
|
|
meta_compat_child();
|
|
|
|
#endif
|
|
|
|
(void)execvp(av[0], (char *const *)UNCONST(av));
|
|
|
|
execDie("exec", av[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
free(mav);
|
|
|
|
free(bp);
|
|
|
|
|
|
|
|
/* XXX: Memory management looks suspicious here. */
|
|
|
|
/* XXX: Setting a list item to NULL is unexpected. */
|
|
|
|
LstNode_SetNull(ln);
|
2012-06-08 21:57:36 +00:00
|
|
|
|
|
|
|
#ifdef USE_META
|
2022-02-05 20:03:50 +00:00
|
|
|
if (useMeta)
|
2021-01-14 01:24:34 +00:00
|
|
|
meta_compat_parent(cpid);
|
2012-06-08 21:57:36 +00:00
|
|
|
#endif
|
|
|
|
|
Import bmake-20240108
Interesting/relevant changes since bmake-20230909
* VERSION (_MAKE_VERSION): 20240106
Merge with NetBSD make, pick up
o fix duplicate progname when reporting an unknown target
o unit tests for Cmd_Exec using temp file
* VERSION (_MAKE_VERSION): 20240105
Merge with NetBSD make, pick up
o main.c: Cmd_Exec write cmd to a file if too big
avoid blowing commandline/env limits
* VERSION (_MAKE_VERSION): 20240101
o util.c: flesh out more of strftime
* configure.in: add --with-bmake-strftime
it is not a full implementation but enough to pass all
the unit-tests.
* parse.c: LoadFile do not append \n to empty buffer.
* VERSION (_MAKE_VERSION): 20231230
Merge with NetBSD make, pick up
o simplify memory allocation for string buffers
o fix declared types of list nodes
o suff.c: clean up freeing of suffixes
o var.c: simplify debug message for the ':@var@...@' modifier
clean up variable handling
* VERSION (_MAKE_VERSION): 20231226
Merge with NetBSD make, pick up
o compat.c: ensure make's output is correctly ordered with that of
the target when not going to a tty
o main.c: check for shellPath whether to call Shell_Init()
* VERSION (_MAKE_VERSION): 20231224
Merge with NetBSD make, pick up
o compat.c: check for shellPath whether to call Shell_Init()
tweak the unit test to detect the bug thus fixed.
o make.1: do not claim .SHELL is only used by jobs mode.
* VERSION (_MAKE_VERSION): 20231220
Merge with NetBSD make, pick up
o str.c: speed up pattern matching in the ':M' modifier
o var.c: fix confusing debug logging when deleting a variable
use consistent debug messages style when ignoring variables
* VERSION (_MAKE_VERSION): 20231210
Merge with NetBSD make, pick up
o var.c: avoid segfault on empty :C match expression
explain in debug log why variable assignment is ignored.
* VERSION (_MAKE_VERSION): 20231208
Merge with NetBSD make, pick up
o var.c: ensure fromCmd is set correctly for variables set on
command line.
* VERSION (_MAKE_VERSION): 20231124
Merge with NetBSD make, pick up
o main.c: cleanup processing of -j
fix lint warning about strchr
o var.c: more accurate error message for invalid ':mtime' argument
cleanup :[...] modifier
avoid reading beyond substring when comparing
o unit-tests cover all cases of :mtime, test and explain exporting
of variables
o cleanup comments
* bsd.after-import.mk (ECHO_TAG): FreeBSD no longer uses
$FreeBSD$ tag, so avoid adding it.
mk/ChangeLog since bmake-20230909
* dirdeps.mk: for MAKE_VERSION 20240105 we do not have the same
limits on command line length, so skip export of lists to env.
* jobs.mk: avoid C suffix in JOB_MAX_C if factor is floating
point. This keeps JOB_MAX numeric incase another makefile does
comparisons.
* gendirdeps.mk: if META_XTRAS is passed to us, add to META_FILES
2024-01-14 01:16:25 +00:00
|
|
|
/* The child is off and running. Now all we can do is wait... */
|
2021-01-14 01:24:34 +00:00
|
|
|
while ((retstat = wait(&reason)) != cpid) {
|
|
|
|
if (retstat > 0)
|
2021-06-25 18:16:24 +00:00
|
|
|
JobReapChild(retstat, reason, false); /* not ours? */
|
Import bmake-20240108
Interesting/relevant changes since bmake-20230909
* VERSION (_MAKE_VERSION): 20240106
Merge with NetBSD make, pick up
o fix duplicate progname when reporting an unknown target
o unit tests for Cmd_Exec using temp file
* VERSION (_MAKE_VERSION): 20240105
Merge with NetBSD make, pick up
o main.c: Cmd_Exec write cmd to a file if too big
avoid blowing commandline/env limits
* VERSION (_MAKE_VERSION): 20240101
o util.c: flesh out more of strftime
* configure.in: add --with-bmake-strftime
it is not a full implementation but enough to pass all
the unit-tests.
* parse.c: LoadFile do not append \n to empty buffer.
* VERSION (_MAKE_VERSION): 20231230
Merge with NetBSD make, pick up
o simplify memory allocation for string buffers
o fix declared types of list nodes
o suff.c: clean up freeing of suffixes
o var.c: simplify debug message for the ':@var@...@' modifier
clean up variable handling
* VERSION (_MAKE_VERSION): 20231226
Merge with NetBSD make, pick up
o compat.c: ensure make's output is correctly ordered with that of
the target when not going to a tty
o main.c: check for shellPath whether to call Shell_Init()
* VERSION (_MAKE_VERSION): 20231224
Merge with NetBSD make, pick up
o compat.c: check for shellPath whether to call Shell_Init()
tweak the unit test to detect the bug thus fixed.
o make.1: do not claim .SHELL is only used by jobs mode.
* VERSION (_MAKE_VERSION): 20231220
Merge with NetBSD make, pick up
o str.c: speed up pattern matching in the ':M' modifier
o var.c: fix confusing debug logging when deleting a variable
use consistent debug messages style when ignoring variables
* VERSION (_MAKE_VERSION): 20231210
Merge with NetBSD make, pick up
o var.c: avoid segfault on empty :C match expression
explain in debug log why variable assignment is ignored.
* VERSION (_MAKE_VERSION): 20231208
Merge with NetBSD make, pick up
o var.c: ensure fromCmd is set correctly for variables set on
command line.
* VERSION (_MAKE_VERSION): 20231124
Merge with NetBSD make, pick up
o main.c: cleanup processing of -j
fix lint warning about strchr
o var.c: more accurate error message for invalid ':mtime' argument
cleanup :[...] modifier
avoid reading beyond substring when comparing
o unit-tests cover all cases of :mtime, test and explain exporting
of variables
o cleanup comments
* bsd.after-import.mk (ECHO_TAG): FreeBSD no longer uses
$FreeBSD$ tag, so avoid adding it.
mk/ChangeLog since bmake-20230909
* dirdeps.mk: for MAKE_VERSION 20240105 we do not have the same
limits on command line length, so skip export of lists to env.
* jobs.mk: avoid C suffix in JOB_MAX_C if factor is floating
point. This keeps JOB_MAX numeric incase another makefile does
comparisons.
* gendirdeps.mk: if META_XTRAS is passed to us, add to META_FILES
2024-01-14 01:16:25 +00:00
|
|
|
if (retstat == -1 && errno != EINTR)
|
2021-01-14 01:24:34 +00:00
|
|
|
break;
|
1996-10-06 15:57:15 +00:00
|
|
|
}
|
2012-06-08 21:57:36 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
if (retstat < 0)
|
|
|
|
Fatal("error in wait: %d: %s", retstat, strerror(errno));
|
2020-11-07 19:39:21 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
if (WIFSTOPPED(reason)) {
|
Import bmake-20240108
Interesting/relevant changes since bmake-20230909
* VERSION (_MAKE_VERSION): 20240106
Merge with NetBSD make, pick up
o fix duplicate progname when reporting an unknown target
o unit tests for Cmd_Exec using temp file
* VERSION (_MAKE_VERSION): 20240105
Merge with NetBSD make, pick up
o main.c: Cmd_Exec write cmd to a file if too big
avoid blowing commandline/env limits
* VERSION (_MAKE_VERSION): 20240101
o util.c: flesh out more of strftime
* configure.in: add --with-bmake-strftime
it is not a full implementation but enough to pass all
the unit-tests.
* parse.c: LoadFile do not append \n to empty buffer.
* VERSION (_MAKE_VERSION): 20231230
Merge with NetBSD make, pick up
o simplify memory allocation for string buffers
o fix declared types of list nodes
o suff.c: clean up freeing of suffixes
o var.c: simplify debug message for the ':@var@...@' modifier
clean up variable handling
* VERSION (_MAKE_VERSION): 20231226
Merge with NetBSD make, pick up
o compat.c: ensure make's output is correctly ordered with that of
the target when not going to a tty
o main.c: check for shellPath whether to call Shell_Init()
* VERSION (_MAKE_VERSION): 20231224
Merge with NetBSD make, pick up
o compat.c: check for shellPath whether to call Shell_Init()
tweak the unit test to detect the bug thus fixed.
o make.1: do not claim .SHELL is only used by jobs mode.
* VERSION (_MAKE_VERSION): 20231220
Merge with NetBSD make, pick up
o str.c: speed up pattern matching in the ':M' modifier
o var.c: fix confusing debug logging when deleting a variable
use consistent debug messages style when ignoring variables
* VERSION (_MAKE_VERSION): 20231210
Merge with NetBSD make, pick up
o var.c: avoid segfault on empty :C match expression
explain in debug log why variable assignment is ignored.
* VERSION (_MAKE_VERSION): 20231208
Merge with NetBSD make, pick up
o var.c: ensure fromCmd is set correctly for variables set on
command line.
* VERSION (_MAKE_VERSION): 20231124
Merge with NetBSD make, pick up
o main.c: cleanup processing of -j
fix lint warning about strchr
o var.c: more accurate error message for invalid ':mtime' argument
cleanup :[...] modifier
avoid reading beyond substring when comparing
o unit-tests cover all cases of :mtime, test and explain exporting
of variables
o cleanup comments
* bsd.after-import.mk (ECHO_TAG): FreeBSD no longer uses
$FreeBSD$ tag, so avoid adding it.
mk/ChangeLog since bmake-20230909
* dirdeps.mk: for MAKE_VERSION 20240105 we do not have the same
limits on command line length, so skip export of lists to env.
* jobs.mk: avoid C suffix in JOB_MAX_C if factor is floating
point. This keeps JOB_MAX numeric incase another makefile does
comparisons.
* gendirdeps.mk: if META_XTRAS is passed to us, add to META_FILES
2024-01-14 01:16:25 +00:00
|
|
|
status = WSTOPSIG(reason);
|
2021-01-14 01:24:34 +00:00
|
|
|
} else if (WIFEXITED(reason)) {
|
Import bmake-20240108
Interesting/relevant changes since bmake-20230909
* VERSION (_MAKE_VERSION): 20240106
Merge with NetBSD make, pick up
o fix duplicate progname when reporting an unknown target
o unit tests for Cmd_Exec using temp file
* VERSION (_MAKE_VERSION): 20240105
Merge with NetBSD make, pick up
o main.c: Cmd_Exec write cmd to a file if too big
avoid blowing commandline/env limits
* VERSION (_MAKE_VERSION): 20240101
o util.c: flesh out more of strftime
* configure.in: add --with-bmake-strftime
it is not a full implementation but enough to pass all
the unit-tests.
* parse.c: LoadFile do not append \n to empty buffer.
* VERSION (_MAKE_VERSION): 20231230
Merge with NetBSD make, pick up
o simplify memory allocation for string buffers
o fix declared types of list nodes
o suff.c: clean up freeing of suffixes
o var.c: simplify debug message for the ':@var@...@' modifier
clean up variable handling
* VERSION (_MAKE_VERSION): 20231226
Merge with NetBSD make, pick up
o compat.c: ensure make's output is correctly ordered with that of
the target when not going to a tty
o main.c: check for shellPath whether to call Shell_Init()
* VERSION (_MAKE_VERSION): 20231224
Merge with NetBSD make, pick up
o compat.c: check for shellPath whether to call Shell_Init()
tweak the unit test to detect the bug thus fixed.
o make.1: do not claim .SHELL is only used by jobs mode.
* VERSION (_MAKE_VERSION): 20231220
Merge with NetBSD make, pick up
o str.c: speed up pattern matching in the ':M' modifier
o var.c: fix confusing debug logging when deleting a variable
use consistent debug messages style when ignoring variables
* VERSION (_MAKE_VERSION): 20231210
Merge with NetBSD make, pick up
o var.c: avoid segfault on empty :C match expression
explain in debug log why variable assignment is ignored.
* VERSION (_MAKE_VERSION): 20231208
Merge with NetBSD make, pick up
o var.c: ensure fromCmd is set correctly for variables set on
command line.
* VERSION (_MAKE_VERSION): 20231124
Merge with NetBSD make, pick up
o main.c: cleanup processing of -j
fix lint warning about strchr
o var.c: more accurate error message for invalid ':mtime' argument
cleanup :[...] modifier
avoid reading beyond substring when comparing
o unit-tests cover all cases of :mtime, test and explain exporting
of variables
o cleanup comments
* bsd.after-import.mk (ECHO_TAG): FreeBSD no longer uses
$FreeBSD$ tag, so avoid adding it.
mk/ChangeLog since bmake-20230909
* dirdeps.mk: for MAKE_VERSION 20240105 we do not have the same
limits on command line length, so skip export of lists to env.
* jobs.mk: avoid C suffix in JOB_MAX_C if factor is floating
point. This keeps JOB_MAX numeric incase another makefile does
comparisons.
* gendirdeps.mk: if META_XTRAS is passed to us, add to META_FILES
2024-01-14 01:16:25 +00:00
|
|
|
status = WEXITSTATUS(reason);
|
2012-06-08 21:57:36 +00:00
|
|
|
#if defined(USE_META) && defined(USE_FILEMON_ONCE)
|
2022-02-05 20:03:50 +00:00
|
|
|
if (useMeta)
|
|
|
|
meta_cmd_finish(NULL);
|
2012-06-08 21:57:36 +00:00
|
|
|
#endif
|
2021-01-14 01:24:34 +00:00
|
|
|
if (status != 0) {
|
|
|
|
if (DEBUG(ERROR))
|
|
|
|
DebugFailedTarget(cmd, gn);
|
|
|
|
printf("*** Error code %d", status);
|
1996-10-06 15:57:15 +00:00
|
|
|
}
|
2021-01-14 01:24:34 +00:00
|
|
|
} else {
|
Import bmake-20240108
Interesting/relevant changes since bmake-20230909
* VERSION (_MAKE_VERSION): 20240106
Merge with NetBSD make, pick up
o fix duplicate progname when reporting an unknown target
o unit tests for Cmd_Exec using temp file
* VERSION (_MAKE_VERSION): 20240105
Merge with NetBSD make, pick up
o main.c: Cmd_Exec write cmd to a file if too big
avoid blowing commandline/env limits
* VERSION (_MAKE_VERSION): 20240101
o util.c: flesh out more of strftime
* configure.in: add --with-bmake-strftime
it is not a full implementation but enough to pass all
the unit-tests.
* parse.c: LoadFile do not append \n to empty buffer.
* VERSION (_MAKE_VERSION): 20231230
Merge with NetBSD make, pick up
o simplify memory allocation for string buffers
o fix declared types of list nodes
o suff.c: clean up freeing of suffixes
o var.c: simplify debug message for the ':@var@...@' modifier
clean up variable handling
* VERSION (_MAKE_VERSION): 20231226
Merge with NetBSD make, pick up
o compat.c: ensure make's output is correctly ordered with that of
the target when not going to a tty
o main.c: check for shellPath whether to call Shell_Init()
* VERSION (_MAKE_VERSION): 20231224
Merge with NetBSD make, pick up
o compat.c: check for shellPath whether to call Shell_Init()
tweak the unit test to detect the bug thus fixed.
o make.1: do not claim .SHELL is only used by jobs mode.
* VERSION (_MAKE_VERSION): 20231220
Merge with NetBSD make, pick up
o str.c: speed up pattern matching in the ':M' modifier
o var.c: fix confusing debug logging when deleting a variable
use consistent debug messages style when ignoring variables
* VERSION (_MAKE_VERSION): 20231210
Merge with NetBSD make, pick up
o var.c: avoid segfault on empty :C match expression
explain in debug log why variable assignment is ignored.
* VERSION (_MAKE_VERSION): 20231208
Merge with NetBSD make, pick up
o var.c: ensure fromCmd is set correctly for variables set on
command line.
* VERSION (_MAKE_VERSION): 20231124
Merge with NetBSD make, pick up
o main.c: cleanup processing of -j
fix lint warning about strchr
o var.c: more accurate error message for invalid ':mtime' argument
cleanup :[...] modifier
avoid reading beyond substring when comparing
o unit-tests cover all cases of :mtime, test and explain exporting
of variables
o cleanup comments
* bsd.after-import.mk (ECHO_TAG): FreeBSD no longer uses
$FreeBSD$ tag, so avoid adding it.
mk/ChangeLog since bmake-20230909
* dirdeps.mk: for MAKE_VERSION 20240105 we do not have the same
limits on command line length, so skip export of lists to env.
* jobs.mk: avoid C suffix in JOB_MAX_C if factor is floating
point. This keeps JOB_MAX numeric incase another makefile does
comparisons.
* gendirdeps.mk: if META_XTRAS is passed to us, add to META_FILES
2024-01-14 01:16:25 +00:00
|
|
|
status = WTERMSIG(reason);
|
2021-01-14 01:24:34 +00:00
|
|
|
printf("*** Signal %d", status);
|
2020-11-07 19:39:21 +00:00
|
|
|
}
|
2012-06-08 21:57:36 +00:00
|
|
|
|
1996-10-06 15:57:15 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
if (!WIFEXITED(reason) || status != 0) {
|
|
|
|
if (errCheck) {
|
2012-06-08 21:57:36 +00:00
|
|
|
#ifdef USE_META
|
2022-02-05 20:03:50 +00:00
|
|
|
if (useMeta)
|
2021-06-25 18:16:24 +00:00
|
|
|
meta_job_error(NULL, gn, false, status);
|
2012-06-08 21:57:36 +00:00
|
|
|
#endif
|
2021-01-14 01:24:34 +00:00
|
|
|
gn->made = ERROR;
|
Import bmake-20240309
Intersting/relevant changes since bmake-20240108
ChangeLog since bmake-20240108
2024-03-10 Simon J Gerraty <sjg@beast.crufty.net>
* boot-strap: tests can take a long time; use a cookie to
skip them if bmake has not been updated since tests last
ran successfully.
* Makefile: Cygwin handles MANTARGET man
* unit-tests/Makefile: set BROKEN_TESTS for Cygwin
2024-03-09 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240309
Merge with NetBSD make, pick up
o set .ERROR_EXIT to the exit status of .ERROR_TARGET
this allows a .ERROR target to ignore the case of
.ERROR_EXIT==6 which just means that the build actually
failed somewhere else.
2024-03-04 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240303
* var.c: on IRIX we need both inttypes.h and stdint.h
2024-03-01 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240301
Merge with NetBSD make, pick up
o export variables with value from target scope
when appropriate.
2024-02-12 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240212
Merge with NetBSD make, pick up
o remove unneeded conditional-compilation toggles
INCLUDES, LIBRARIES, POSIX, SYSVINCLUDE, SYSVVARSUB,
GMAKEEXPORT NO_REGEX and SUNSHCMD
* configure.in: add check for regex.h
* var.c: replace use of NO_REGEX with HAVE_REGEX_H
2024-02-04 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240204
Merge with NetBSD make, pick up
o var.c: fix some lint (-dL) mode parsing issues
2024-02-02 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION: (_MAKE_VERSION): 20240202
Merge with NetBSD make, pick up
o make.1: note that arg to :D and :U can be empty
o var.c: $$ is not a parse error when .MAKE.SAVE_DOLLARS=no
mk/ChangeLog since bmake-20240108
2024-03-09 Simon J Gerraty <sjg@beast.crufty.net>
* install-mk (MK_VERSION): 20240309
* meta.sys.mk: _metaError: if .ERROR_EXIT == 6, we do not
want to save the .ERROR_META_FILE
2024-02-20 Simon J Gerraty <sjg@beast.crufty.net>
* install-mk (MK_VERSION): 20240220
* sys.dirdeps.mk, dirdeps-targets.mk, init.mk:
do not set .MAIN: dirdeps in sys.dirdeps.mk
dirdeps-targets.mk will do that for top-level builds
and init.mk will do it for others.
This allows a Makefile which has no need of 'dirdeps' to
set .MAIN for itself and "just work".
2024-02-18 Simon J Gerraty <sjg@beast.crufty.net>
* bsd.*.mk: for makefiles that get a bsd. symlink,
use _this in multiple inclusion tags since .PARSEFILE will not
DTRT when such a makefile is included directly by Makefile and
automatically (without bsd. prefix).
Since we cannot guarantee that our sys.mk will be used, we provide
a default _this in each makefile that gets a bsd. prefix such that
the value is the same regardless of bsd. prefix.
* subdir.mk: drop the !target guard on $SUBDIR_TARGETS
2024-02-12 Simon J Gerraty <sjg@beast.crufty.net>
* install-mk (MK_VERSION): 20240212
* SPDX-License-Identifier: BSD-2-Clause
Add SPDX-License-Identifier to inidicate that I consider
my copyright on any of these makefiles equivalent to BSD-2-Clause
* autoconf.mk: allow for configure.ac as currently recommended
* subdir.mk: support @auto
which is replaced with each subdir that
has a [Mm]akefile.
* subdir.mk: include local.subdir.mk if it exists.
* subdir.mk: rework to handle .WAIT
2024-02-11 Simon J Gerraty <sjg@beast.crufty.net>
* subdir.mk: _SUBDIRUSE report the target we are entering subdirs for.
2024-02-10 Simon J Gerraty <sjg@beast.crufty.net>
* prog.mk: treat empty SRCS the same as undefined
2024-02-02 Simon J Gerraty <sjg@beast.crufty.net>
* Avoid undefined errors in lint (-dL) mode
* man.mk (CMT2DOC_FLAGS): note that -mm does mdoc(7)
2024-01-28 Simon J Gerraty <sjg@beast.crufty.net>
* install-mk (MK_VERSION): 20240128
* FILES: add ccm.dep.mk for C++ modules
add suffixes.mk for common location for generic SUFFIX rules.
* auto.dep.mk autodep.mk meta.autodep.mk: include ccm.dep.mk
replace OBJ_EXTENSIONS with OBJ_SUFFIXES
* autodep.mk: leverage CXX_SUFFIXES for __depsrcs
and update style (spaces around = etc)
* init.mk: add OBJS_SRCS_FILTER to filter SRCS when
setting OBJS
* meta2deps.py: handle multiple ./ embedded in path better.
2024-03-14 02:14:41 +00:00
|
|
|
if (WIFEXITED(reason))
|
|
|
|
gn->exit_status = status;
|
2021-01-14 01:24:34 +00:00
|
|
|
if (opts.keepgoing) {
|
|
|
|
/*
|
|
|
|
* Abort the current target,
|
|
|
|
* but let others continue.
|
|
|
|
*/
|
|
|
|
printf(" (continuing)\n");
|
|
|
|
} else {
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
if (deleteOnError)
|
|
|
|
CompatDeleteTarget(gn);
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Continue executing commands for this target.
|
|
|
|
* If we return 0, this will happen...
|
|
|
|
*/
|
|
|
|
printf(" (ignored)\n");
|
|
|
|
status = 0;
|
|
|
|
}
|
Import bmake-20240108
Interesting/relevant changes since bmake-20230909
* VERSION (_MAKE_VERSION): 20240106
Merge with NetBSD make, pick up
o fix duplicate progname when reporting an unknown target
o unit tests for Cmd_Exec using temp file
* VERSION (_MAKE_VERSION): 20240105
Merge with NetBSD make, pick up
o main.c: Cmd_Exec write cmd to a file if too big
avoid blowing commandline/env limits
* VERSION (_MAKE_VERSION): 20240101
o util.c: flesh out more of strftime
* configure.in: add --with-bmake-strftime
it is not a full implementation but enough to pass all
the unit-tests.
* parse.c: LoadFile do not append \n to empty buffer.
* VERSION (_MAKE_VERSION): 20231230
Merge with NetBSD make, pick up
o simplify memory allocation for string buffers
o fix declared types of list nodes
o suff.c: clean up freeing of suffixes
o var.c: simplify debug message for the ':@var@...@' modifier
clean up variable handling
* VERSION (_MAKE_VERSION): 20231226
Merge with NetBSD make, pick up
o compat.c: ensure make's output is correctly ordered with that of
the target when not going to a tty
o main.c: check for shellPath whether to call Shell_Init()
* VERSION (_MAKE_VERSION): 20231224
Merge with NetBSD make, pick up
o compat.c: check for shellPath whether to call Shell_Init()
tweak the unit test to detect the bug thus fixed.
o make.1: do not claim .SHELL is only used by jobs mode.
* VERSION (_MAKE_VERSION): 20231220
Merge with NetBSD make, pick up
o str.c: speed up pattern matching in the ':M' modifier
o var.c: fix confusing debug logging when deleting a variable
use consistent debug messages style when ignoring variables
* VERSION (_MAKE_VERSION): 20231210
Merge with NetBSD make, pick up
o var.c: avoid segfault on empty :C match expression
explain in debug log why variable assignment is ignored.
* VERSION (_MAKE_VERSION): 20231208
Merge with NetBSD make, pick up
o var.c: ensure fromCmd is set correctly for variables set on
command line.
* VERSION (_MAKE_VERSION): 20231124
Merge with NetBSD make, pick up
o main.c: cleanup processing of -j
fix lint warning about strchr
o var.c: more accurate error message for invalid ':mtime' argument
cleanup :[...] modifier
avoid reading beyond substring when comparing
o unit-tests cover all cases of :mtime, test and explain exporting
of variables
o cleanup comments
* bsd.after-import.mk (ECHO_TAG): FreeBSD no longer uses
$FreeBSD$ tag, so avoid adding it.
mk/ChangeLog since bmake-20230909
* dirdeps.mk: for MAKE_VERSION 20240105 we do not have the same
limits on command line length, so skip export of lists to env.
* jobs.mk: avoid C suffix in JOB_MAX_C if factor is floating
point. This keeps JOB_MAX numeric incase another makefile does
comparisons.
* gendirdeps.mk: if META_XTRAS is passed to us, add to META_FILES
2024-01-14 01:16:25 +00:00
|
|
|
fflush(stdout);
|
2021-01-14 01:24:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
free(cmdStart);
|
|
|
|
compatChild = 0;
|
|
|
|
if (compatSigno != 0) {
|
|
|
|
bmake_signal(compatSigno, SIG_DFL);
|
|
|
|
kill(myPid, compatSigno);
|
|
|
|
}
|
|
|
|
|
2022-02-05 20:03:50 +00:00
|
|
|
return status == 0;
|
1996-10-06 15:57:15 +00:00
|
|
|
}
|
2020-09-05 16:11:04 +00:00
|
|
|
|
2020-11-07 19:39:21 +00:00
|
|
|
static void
|
|
|
|
RunCommands(GNode *gn)
|
|
|
|
{
|
2021-01-14 01:24:34 +00:00
|
|
|
StringListNode *ln;
|
|
|
|
|
|
|
|
for (ln = gn->commands.first; ln != NULL; ln = ln->next) {
|
|
|
|
const char *cmd = ln->datum;
|
2022-02-05 20:03:50 +00:00
|
|
|
if (!Compat_RunCommand(cmd, gn, ln))
|
2021-01-14 01:24:34 +00:00
|
|
|
break;
|
|
|
|
}
|
2020-11-07 19:39:21 +00:00
|
|
|
}
|
|
|
|
|
2022-07-26 15:52:53 +00:00
|
|
|
static void
|
|
|
|
MakeInRandomOrder(GNode **gnodes, GNode **end, GNode *pgn)
|
|
|
|
{
|
|
|
|
GNode **it;
|
|
|
|
size_t r;
|
|
|
|
|
|
|
|
for (r = (size_t)(end - gnodes); r >= 2; r--) {
|
|
|
|
/* Biased, but irrelevant in practice. */
|
|
|
|
size_t i = (size_t)random() % r;
|
|
|
|
GNode *t = gnodes[r - 1];
|
|
|
|
gnodes[r - 1] = gnodes[i];
|
|
|
|
gnodes[i] = t;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (it = gnodes; it != end; it++)
|
|
|
|
Compat_Make(*it, pgn);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
MakeWaitGroupsInRandomOrder(GNodeList *gnodes, GNode *pgn)
|
|
|
|
{
|
|
|
|
Vector vec;
|
|
|
|
GNodeListNode *ln;
|
|
|
|
GNode **nodes;
|
|
|
|
size_t i, n, start;
|
|
|
|
|
|
|
|
Vector_Init(&vec, sizeof(GNode *));
|
|
|
|
for (ln = gnodes->first; ln != NULL; ln = ln->next)
|
|
|
|
*(GNode **)Vector_Push(&vec) = ln->datum;
|
|
|
|
nodes = vec.items;
|
|
|
|
n = vec.len;
|
|
|
|
|
|
|
|
start = 0;
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
if (nodes[i]->type & OP_WAIT) {
|
|
|
|
MakeInRandomOrder(nodes + start, nodes + i, pgn);
|
|
|
|
Compat_Make(nodes[i], pgn);
|
|
|
|
start = i + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
MakeInRandomOrder(nodes + start, nodes + i, pgn);
|
|
|
|
|
|
|
|
Vector_Done(&vec);
|
|
|
|
}
|
|
|
|
|
2020-11-07 19:39:21 +00:00
|
|
|
static void
|
|
|
|
MakeNodes(GNodeList *gnodes, GNode *pgn)
|
|
|
|
{
|
2021-01-14 01:24:34 +00:00
|
|
|
GNodeListNode *ln;
|
|
|
|
|
2022-07-26 15:52:53 +00:00
|
|
|
if (Lst_IsEmpty(gnodes))
|
|
|
|
return;
|
|
|
|
if (opts.randomizeTargets) {
|
|
|
|
MakeWaitGroupsInRandomOrder(gnodes, pgn);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
for (ln = gnodes->first; ln != NULL; ln = ln->next) {
|
2022-07-26 15:52:53 +00:00
|
|
|
GNode *cgn = ln->datum;
|
|
|
|
Compat_Make(cgn, pgn);
|
2021-01-14 01:24:34 +00:00
|
|
|
}
|
2020-11-07 19:39:21 +00:00
|
|
|
}
|
|
|
|
|
2021-06-25 18:16:24 +00:00
|
|
|
static bool
|
2021-01-14 01:24:34 +00:00
|
|
|
MakeUnmade(GNode *gn, GNode *pgn)
|
1996-10-06 15:57:15 +00:00
|
|
|
{
|
2020-11-20 03:54:37 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
assert(gn->made == UNMADE);
|
|
|
|
|
1996-10-06 15:57:15 +00:00
|
|
|
/*
|
|
|
|
* First mark ourselves to be made, then apply whatever transformations
|
|
|
|
* the suffix module thinks are necessary. Once that's done, we can
|
|
|
|
* descend and make all our children. If any of them has an error
|
2021-06-25 18:16:24 +00:00
|
|
|
* but the -k flag was given, our 'make' field will be set to false
|
2020-11-20 03:54:37 +00:00
|
|
|
* again. This is our signal to not attempt to do anything but abort
|
|
|
|
* our parent as well.
|
1996-10-06 15:57:15 +00:00
|
|
|
*/
|
2021-12-18 07:27:22 +00:00
|
|
|
gn->flags.remake = true;
|
1996-10-06 15:57:15 +00:00
|
|
|
gn->made = BEINGMADE;
|
2021-01-14 01:24:34 +00:00
|
|
|
|
2020-11-07 19:39:21 +00:00
|
|
|
if (!(gn->type & OP_MADE))
|
2021-01-14 01:24:34 +00:00
|
|
|
Suff_FindDeps(gn);
|
|
|
|
|
|
|
|
MakeNodes(&gn->children, gn);
|
|
|
|
|
2021-12-18 07:27:22 +00:00
|
|
|
if (!gn->flags.remake) {
|
2021-01-14 01:24:34 +00:00
|
|
|
gn->made = ABORTED;
|
2021-12-18 07:27:22 +00:00
|
|
|
pgn->flags.remake = false;
|
2021-06-25 18:16:24 +00:00
|
|
|
return false;
|
1996-10-06 15:57:15 +00:00
|
|
|
}
|
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
if (Lst_FindDatum(&gn->implicitParents, pgn) != NULL)
|
2021-02-11 01:51:11 +00:00
|
|
|
Var_Set(pgn, IMPSRC, GNode_VarTarget(gn));
|
2012-06-08 21:57:36 +00:00
|
|
|
|
1996-10-06 15:57:15 +00:00
|
|
|
/*
|
2020-11-07 19:39:21 +00:00
|
|
|
* All the children were made ok. Now youngestChild->mtime contains the
|
2012-06-08 21:57:36 +00:00
|
|
|
* modification time of the newest child, we need to find out if we
|
|
|
|
* exist and when we were modified last. The criteria for datedness
|
2020-11-20 03:54:37 +00:00
|
|
|
* are defined by GNode_IsOODate.
|
1996-10-06 15:57:15 +00:00
|
|
|
*/
|
2020-11-07 19:39:21 +00:00
|
|
|
DEBUG1(MAKE, "Examining %s...", gn->name);
|
2020-11-20 03:54:37 +00:00
|
|
|
if (!GNode_IsOODate(gn)) {
|
2021-01-14 01:24:34 +00:00
|
|
|
gn->made = UPTODATE;
|
|
|
|
DEBUG0(MAKE, "up-to-date.\n");
|
2021-06-25 18:16:24 +00:00
|
|
|
return false;
|
2021-01-14 01:24:34 +00:00
|
|
|
}
|
1996-10-06 15:57:15 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If the user is just seeing if something is out-of-date, exit now
|
|
|
|
* to tell him/her "yes".
|
|
|
|
*/
|
2021-01-14 01:24:34 +00:00
|
|
|
DEBUG0(MAKE, "out-of-date.\n");
|
2023-01-28 00:23:54 +00:00
|
|
|
if (opts.query && gn != Targ_GetEndNode())
|
2021-01-14 01:24:34 +00:00
|
|
|
exit(1);
|
1996-10-06 15:57:15 +00:00
|
|
|
|
|
|
|
/*
|
2021-01-14 01:24:34 +00:00
|
|
|
* We need to be re-made.
|
|
|
|
* Ensure that $? (.OODATE) and $> (.ALLSRC) are both set.
|
1996-10-06 15:57:15 +00:00
|
|
|
*/
|
2021-06-25 18:16:24 +00:00
|
|
|
GNode_SetLocalVars(gn);
|
2012-06-08 21:57:36 +00:00
|
|
|
|
1996-10-06 15:57:15 +00:00
|
|
|
/*
|
|
|
|
* Alter our type to tell if errors should be ignored or things
|
2021-01-14 01:24:34 +00:00
|
|
|
* should not be printed so Compat_RunCommand knows what to do.
|
1996-10-06 15:57:15 +00:00
|
|
|
*/
|
2021-01-14 01:24:34 +00:00
|
|
|
if (opts.ignoreErrors)
|
|
|
|
gn->type |= OP_IGNORE;
|
2022-02-05 20:03:50 +00:00
|
|
|
if (opts.silent)
|
2021-01-14 01:24:34 +00:00
|
|
|
gn->type |= OP_SILENT;
|
1996-10-06 15:57:15 +00:00
|
|
|
|
2012-06-08 21:57:36 +00:00
|
|
|
if (Job_CheckCommands(gn, Fatal)) {
|
2022-02-05 20:03:50 +00:00
|
|
|
if (!opts.touch || (gn->type & OP_MAKE)) {
|
2021-01-14 01:24:34 +00:00
|
|
|
curTarg = gn;
|
2012-06-08 21:57:36 +00:00
|
|
|
#ifdef USE_META
|
2022-02-05 20:03:50 +00:00
|
|
|
if (useMeta && GNode_ShouldExecute(gn))
|
2021-01-14 01:24:34 +00:00
|
|
|
meta_job_start(NULL, gn);
|
2012-06-08 21:57:36 +00:00
|
|
|
#endif
|
2021-01-14 01:24:34 +00:00
|
|
|
RunCommands(gn);
|
|
|
|
curTarg = NULL;
|
|
|
|
} else {
|
2021-12-18 07:27:22 +00:00
|
|
|
Job_Touch(gn, (gn->type & OP_SILENT) != OP_NONE);
|
2021-01-14 01:24:34 +00:00
|
|
|
}
|
1996-10-06 15:57:15 +00:00
|
|
|
} else {
|
2021-01-14 01:24:34 +00:00
|
|
|
gn->made = ERROR;
|
1996-10-06 15:57:15 +00:00
|
|
|
}
|
2012-06-08 21:57:36 +00:00
|
|
|
#ifdef USE_META
|
2020-11-07 19:39:21 +00:00
|
|
|
if (useMeta && GNode_ShouldExecute(gn)) {
|
2021-01-14 01:24:34 +00:00
|
|
|
if (meta_job_finish(NULL) != 0)
|
|
|
|
gn->made = ERROR;
|
2012-06-08 21:57:36 +00:00
|
|
|
}
|
|
|
|
#endif
|
1996-10-06 15:57:15 +00:00
|
|
|
|
|
|
|
if (gn->made != ERROR) {
|
2021-01-14 01:24:34 +00:00
|
|
|
/*
|
|
|
|
* If the node was made successfully, mark it so, update
|
|
|
|
* its modification time and timestamp all its parents.
|
|
|
|
* This is to keep its state from affecting that of its parent.
|
|
|
|
*/
|
|
|
|
gn->made = MADE;
|
|
|
|
if (Make_Recheck(gn) == 0)
|
2021-12-18 07:27:22 +00:00
|
|
|
pgn->flags.force = true;
|
2021-01-14 01:24:34 +00:00
|
|
|
if (!(gn->type & OP_EXEC)) {
|
2021-12-18 07:27:22 +00:00
|
|
|
pgn->flags.childMade = true;
|
2021-01-14 01:24:34 +00:00
|
|
|
GNode_UpdateYoungestChild(pgn, gn);
|
|
|
|
}
|
2020-11-07 19:39:21 +00:00
|
|
|
} else if (opts.keepgoing) {
|
2021-12-18 07:27:22 +00:00
|
|
|
pgn->flags.remake = false;
|
1996-10-06 15:57:15 +00:00
|
|
|
} else {
|
2022-02-05 20:03:50 +00:00
|
|
|
PrintOnError(gn, "\nStop.\n");
|
2021-01-14 01:24:34 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
2021-06-25 18:16:24 +00:00
|
|
|
return true;
|
2021-01-14 01:24:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
MakeOther(GNode *gn, GNode *pgn)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (Lst_FindDatum(&gn->implicitParents, pgn) != NULL) {
|
|
|
|
const char *target = GNode_VarTarget(gn);
|
2021-02-11 01:51:11 +00:00
|
|
|
Var_Set(pgn, IMPSRC, target != NULL ? target : "");
|
2021-01-14 01:24:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (gn->made) {
|
|
|
|
case BEINGMADE:
|
2012-06-08 21:57:36 +00:00
|
|
|
Error("Graph cycles through %s", gn->name);
|
1996-10-06 15:57:15 +00:00
|
|
|
gn->made = ERROR;
|
2021-12-18 07:27:22 +00:00
|
|
|
pgn->flags.remake = false;
|
1996-10-06 15:57:15 +00:00
|
|
|
break;
|
2021-01-14 01:24:34 +00:00
|
|
|
case MADE:
|
2020-11-20 03:54:37 +00:00
|
|
|
if (!(gn->type & OP_EXEC)) {
|
2021-12-18 07:27:22 +00:00
|
|
|
pgn->flags.childMade = true;
|
2021-01-14 01:24:34 +00:00
|
|
|
GNode_UpdateYoungestChild(pgn, gn);
|
1996-10-06 15:57:15 +00:00
|
|
|
}
|
|
|
|
break;
|
2021-01-14 01:24:34 +00:00
|
|
|
case UPTODATE:
|
2020-11-20 03:54:37 +00:00
|
|
|
if (!(gn->type & OP_EXEC))
|
2021-01-14 01:24:34 +00:00
|
|
|
GNode_UpdateYoungestChild(pgn, gn);
|
1996-10-06 15:57:15 +00:00
|
|
|
break;
|
2021-01-14 01:24:34 +00:00
|
|
|
default:
|
1996-10-06 15:57:15 +00:00
|
|
|
break;
|
|
|
|
}
|
2021-01-14 01:24:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Make a target.
|
|
|
|
*
|
|
|
|
* If an error is detected and not being ignored, the process exits.
|
|
|
|
*
|
|
|
|
* Input:
|
|
|
|
* gn The node to make
|
|
|
|
* pgn Parent to abort if necessary
|
|
|
|
*
|
|
|
|
* Output:
|
|
|
|
* gn->made
|
|
|
|
* UPTODATE gn was already up-to-date.
|
|
|
|
* MADE gn was recreated successfully.
|
|
|
|
* ERROR An error occurred while gn was being created,
|
|
|
|
* either due to missing commands or in -k mode.
|
|
|
|
* ABORTED gn was not remade because one of its
|
|
|
|
* dependencies could not be made due to errors.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
Compat_Make(GNode *gn, GNode *pgn)
|
|
|
|
{
|
|
|
|
if (shellName == NULL) /* we came here from jobs */
|
|
|
|
Shell_Init();
|
|
|
|
|
|
|
|
if (gn->made == UNMADE && (gn == pgn || !(pgn->type & OP_MADE))) {
|
|
|
|
if (!MakeUnmade(gn, pgn))
|
|
|
|
goto cohorts;
|
|
|
|
|
|
|
|
/* XXX: Replace with GNode_IsError(gn) */
|
|
|
|
} else if (gn->made == ERROR) {
|
|
|
|
/*
|
|
|
|
* Already had an error when making this.
|
|
|
|
* Tell the parent to abort.
|
|
|
|
*/
|
2021-12-18 07:27:22 +00:00
|
|
|
pgn->flags.remake = false;
|
2021-01-14 01:24:34 +00:00
|
|
|
} else {
|
|
|
|
MakeOther(gn, pgn);
|
|
|
|
}
|
1996-10-06 15:57:15 +00:00
|
|
|
|
2012-06-08 21:57:36 +00:00
|
|
|
cohorts:
|
2021-01-14 01:24:34 +00:00
|
|
|
MakeNodes(&gn->cohorts, pgn);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
MakeBeginNode(void)
|
|
|
|
{
|
|
|
|
GNode *gn = Targ_FindNode(".BEGIN");
|
|
|
|
if (gn == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
Compat_Make(gn, gn);
|
|
|
|
if (GNode_IsError(gn)) {
|
2022-02-05 20:03:50 +00:00
|
|
|
PrintOnError(gn, "\nStop.\n");
|
2021-01-14 01:24:34 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
InitSignals(void)
|
|
|
|
{
|
|
|
|
if (bmake_signal(SIGINT, SIG_IGN) != SIG_IGN)
|
|
|
|
bmake_signal(SIGINT, CompatInterrupt);
|
|
|
|
if (bmake_signal(SIGTERM, SIG_IGN) != SIG_IGN)
|
|
|
|
bmake_signal(SIGTERM, CompatInterrupt);
|
|
|
|
if (bmake_signal(SIGHUP, SIG_IGN) != SIG_IGN)
|
|
|
|
bmake_signal(SIGHUP, CompatInterrupt);
|
|
|
|
if (bmake_signal(SIGQUIT, SIG_IGN) != SIG_IGN)
|
|
|
|
bmake_signal(SIGQUIT, CompatInterrupt);
|
1996-10-06 15:57:15 +00:00
|
|
|
}
|
2020-09-05 16:11:04 +00:00
|
|
|
|
1996-10-06 15:57:15 +00:00
|
|
|
void
|
2022-07-26 15:52:53 +00:00
|
|
|
Compat_MakeAll(GNodeList *targs)
|
1996-10-06 15:57:15 +00:00
|
|
|
{
|
2021-01-14 01:24:34 +00:00
|
|
|
GNode *errorNode = NULL;
|
|
|
|
|
|
|
|
if (shellName == NULL)
|
|
|
|
Shell_Init();
|
1996-10-06 15:57:15 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
InitSignals();
|
|
|
|
|
2022-02-05 20:03:50 +00:00
|
|
|
/*
|
|
|
|
* Create the .END node now, to keep the (debug) output of the
|
|
|
|
* counter.mk test the same as before 2020-09-23. This
|
|
|
|
* implementation detail probably doesn't matter though.
|
|
|
|
*/
|
2021-01-14 01:24:34 +00:00
|
|
|
(void)Targ_GetEndNode();
|
|
|
|
|
2022-02-05 20:03:50 +00:00
|
|
|
if (!opts.query)
|
2021-01-14 01:24:34 +00:00
|
|
|
MakeBeginNode();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Expand .USE nodes right now, because they can modify the structure
|
|
|
|
* of the tree.
|
|
|
|
*/
|
|
|
|
Make_ExpandUse(targs);
|
|
|
|
|
|
|
|
while (!Lst_IsEmpty(targs)) {
|
|
|
|
GNode *gn = Lst_Dequeue(targs);
|
|
|
|
Compat_Make(gn, gn);
|
|
|
|
|
|
|
|
if (gn->made == UPTODATE) {
|
|
|
|
printf("`%s' is up to date.\n", gn->name);
|
|
|
|
} else if (gn->made == ABORTED) {
|
|
|
|
printf("`%s' not remade because of errors.\n",
|
2022-02-05 20:03:50 +00:00
|
|
|
gn->name);
|
2021-01-14 01:24:34 +00:00
|
|
|
}
|
|
|
|
if (GNode_IsError(gn) && errorNode == NULL)
|
|
|
|
errorNode = gn;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (errorNode == NULL) {
|
|
|
|
GNode *endNode = Targ_GetEndNode();
|
|
|
|
Compat_Make(endNode, endNode);
|
|
|
|
if (GNode_IsError(endNode))
|
|
|
|
errorNode = endNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (errorNode != NULL) {
|
2021-02-11 01:51:11 +00:00
|
|
|
if (DEBUG(GRAPH2))
|
|
|
|
Targ_PrintGraph(2);
|
|
|
|
else if (DEBUG(GRAPH3))
|
|
|
|
Targ_PrintGraph(3);
|
2022-02-05 20:03:50 +00:00
|
|
|
PrintOnError(errorNode, "\nStop.\n");
|
2021-01-14 01:24:34 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
1996-10-06 15:57:15 +00:00
|
|
|
}
|