Import bmake-20240625
Intersting/relevant changes since bmake-20240520
ChangeLog since bmake-20240520
2024-06-25 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240625
Merge with NetBSD make, pick up
o job.c: ensure shellPath is always duped, avoid upsetting free()
2024-06-16 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240616
Merge with NetBSD make, pick up
o clean up collection of context information for error messages
o in warnings, move the word "warning" to the front
o var.c: throw an error on attempt to override an internal
read-only variable
2024-06-10 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240610
Merge with NetBSD make, pick up
o for.c: remove redundant shortcut for building the .for loop body
2024-06-02 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240602
Merge with NetBSD make, pick up
o rename some VarEvalMode constants to better match debug names.
o var.c: avoid out-of-bounds read when parsing indirect modifiers.
2024-06-01 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240601
Merge with NetBSD make, pick up
o add .export-all rather than allow .export with no argument
which can happen accidentally.
o if lua is available, run check-expect.lua after unit-tests
o main.c: use snprintf rather than strncpy
fix memory leak when purging realpath cache.
2024-05-28 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240528
Merge with NetBSD make, pick up
o fix a number of memory leaks
o replace magic numbers with POSIX FILENO constants
o hash.c: remove dead code from HashTable_DeleteEntry
o main.c: when complaining about unusable .OBJDIR
call PrintOnError if MAKE_DEBUG_OBJDIR_CHECK_WRITABLE is true.
o parse.c: use fewer technical terms in debug message for dependency
mk/ChangeLog since bmake-20240520
2024-06-22 Simon J Gerraty <sjg@beast.crufty.net>
* install-mk (MK_VERSION): 20240616
* dirdeps.mk: apply DEP_DIRDEPS_BUILD_DIR_FILTER after we have
computed build dirs, since some filters cannot be easily expressed via
DEP_DIRDEPS_FILTER.
2024-05-31 Simon J Gerraty <sjg@beast.crufty.net>
* dirdeps.mk: move reset of DIRDEPS_EXPORT_VARS
until after we a finished with it if building a cache.
2024-06-29 00:16:32 +00:00
|
|
|
/* $NetBSD: targ.c,v 1.183 2024/05/25 21:07:48 rillig Exp $ */
|
2012-06-08 21:57:36 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 1988, 1989, 1990, 1993
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2020-11-20 03:54:37 +00:00
|
|
|
/*
|
|
|
|
* Maintaining the targets and sources, which are both implemented as GNode.
|
2012-06-08 21:57:36 +00:00
|
|
|
*
|
|
|
|
* Interface:
|
2020-11-20 03:54:37 +00:00
|
|
|
* Targ_Init Initialize the module.
|
2020-11-07 19:39:21 +00:00
|
|
|
*
|
2020-11-20 03:54:37 +00:00
|
|
|
* Targ_End Clean up the module.
|
2012-06-08 21:57:36 +00:00
|
|
|
*
|
2020-11-07 19:39:21 +00:00
|
|
|
* Targ_List Return the list of all targets so far.
|
2012-06-08 21:57:36 +00:00
|
|
|
*
|
2022-02-05 20:03:50 +00:00
|
|
|
* GNode_New Create a new GNode with the given name, don't add it
|
|
|
|
* to allNodes.
|
2012-06-08 21:57:36 +00:00
|
|
|
*
|
2020-11-07 19:39:21 +00:00
|
|
|
* Targ_FindNode Find the node, or return NULL.
|
2012-06-08 21:57:36 +00:00
|
|
|
*
|
2020-11-07 19:39:21 +00:00
|
|
|
* Targ_GetNode Find the node, or create it.
|
2012-06-08 21:57:36 +00:00
|
|
|
*
|
2020-11-07 19:39:21 +00:00
|
|
|
* Targ_NewInternalNode
|
|
|
|
* Create an internal node.
|
2012-06-08 21:57:36 +00:00
|
|
|
*
|
2020-11-07 19:39:21 +00:00
|
|
|
* Targ_FindList Given a list of names, find nodes for all
|
|
|
|
* of them, creating them as necessary.
|
2012-06-08 21:57:36 +00:00
|
|
|
*
|
2020-11-07 19:39:21 +00:00
|
|
|
* Targ_Propagate Propagate information between related nodes.
|
|
|
|
* Should be called after the makefiles are parsed
|
|
|
|
* but before any action is taken.
|
2012-06-08 21:57:36 +00:00
|
|
|
*
|
|
|
|
* Debugging:
|
2020-11-07 19:39:21 +00:00
|
|
|
* Targ_PrintGraph
|
2021-01-14 01:24:34 +00:00
|
|
|
* Print out the entire graph, all variables and
|
2022-02-05 20:03:50 +00:00
|
|
|
* statistics for the directory cache.
|
2012-06-08 21:57:36 +00:00
|
|
|
*/
|
|
|
|
|
2020-11-07 19:39:21 +00:00
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
#include "make.h"
|
|
|
|
#include "dir.h"
|
2012-06-08 21:57:36 +00:00
|
|
|
|
2020-11-07 19:39:21 +00:00
|
|
|
/* "@(#)targ.c 8.2 (Berkeley) 3/19/94" */
|
Import bmake-20240625
Intersting/relevant changes since bmake-20240520
ChangeLog since bmake-20240520
2024-06-25 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240625
Merge with NetBSD make, pick up
o job.c: ensure shellPath is always duped, avoid upsetting free()
2024-06-16 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240616
Merge with NetBSD make, pick up
o clean up collection of context information for error messages
o in warnings, move the word "warning" to the front
o var.c: throw an error on attempt to override an internal
read-only variable
2024-06-10 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240610
Merge with NetBSD make, pick up
o for.c: remove redundant shortcut for building the .for loop body
2024-06-02 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240602
Merge with NetBSD make, pick up
o rename some VarEvalMode constants to better match debug names.
o var.c: avoid out-of-bounds read when parsing indirect modifiers.
2024-06-01 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240601
Merge with NetBSD make, pick up
o add .export-all rather than allow .export with no argument
which can happen accidentally.
o if lua is available, run check-expect.lua after unit-tests
o main.c: use snprintf rather than strncpy
fix memory leak when purging realpath cache.
2024-05-28 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240528
Merge with NetBSD make, pick up
o fix a number of memory leaks
o replace magic numbers with POSIX FILENO constants
o hash.c: remove dead code from HashTable_DeleteEntry
o main.c: when complaining about unusable .OBJDIR
call PrintOnError if MAKE_DEBUG_OBJDIR_CHECK_WRITABLE is true.
o parse.c: use fewer technical terms in debug message for dependency
mk/ChangeLog since bmake-20240520
2024-06-22 Simon J Gerraty <sjg@beast.crufty.net>
* install-mk (MK_VERSION): 20240616
* dirdeps.mk: apply DEP_DIRDEPS_BUILD_DIR_FILTER after we have
computed build dirs, since some filters cannot be easily expressed via
DEP_DIRDEPS_FILTER.
2024-05-31 Simon J Gerraty <sjg@beast.crufty.net>
* dirdeps.mk: move reset of DIRDEPS_EXPORT_VARS
until after we a finished with it if building a cache.
2024-06-29 00:16:32 +00:00
|
|
|
MAKE_RCSID("$NetBSD: targ.c,v 1.183 2024/05/25 21:07:48 rillig Exp $");
|
2012-06-08 21:57:36 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
/*
|
|
|
|
* All target nodes that appeared on the left-hand side of one of the
|
|
|
|
* dependency operators ':', '::', '!'.
|
|
|
|
*/
|
|
|
|
static GNodeList allTargets = LST_INIT;
|
2020-11-20 03:54:37 +00:00
|
|
|
static HashTable allTargetsByName;
|
2012-06-08 21:57:36 +00:00
|
|
|
|
|
|
|
#ifdef CLEANUP
|
2021-01-14 01:24:34 +00:00
|
|
|
static GNodeList allNodes = LST_INIT;
|
2020-11-20 03:54:37 +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
|
|
|
static void GNode_Free(GNode *);
|
2012-06-08 21:57:36 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
void
|
|
|
|
Targ_Init(void)
|
|
|
|
{
|
2021-01-14 01:24:34 +00:00
|
|
|
HashTable_Init(&allTargetsByName);
|
2012-06-08 21:57:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Targ_End(void)
|
|
|
|
{
|
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
|
|
|
#ifdef CLEANUP
|
|
|
|
GNodeListNode *ln;
|
|
|
|
#endif
|
2021-01-14 01:24:34 +00:00
|
|
|
Targ_Stats();
|
2012-06-08 21:57:36 +00:00
|
|
|
#ifdef CLEANUP
|
2021-01-14 01:24:34 +00:00
|
|
|
Lst_Done(&allTargets);
|
|
|
|
HashTable_Done(&allTargetsByName);
|
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
|
|
|
for (ln = allNodes.first; ln != NULL; ln = ln->next)
|
|
|
|
GNode_Free(ln->datum);
|
|
|
|
Lst_Done(&allNodes);
|
2012-06-08 21:57:36 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2020-09-05 16:11:04 +00:00
|
|
|
void
|
|
|
|
Targ_Stats(void)
|
|
|
|
{
|
2021-01-14 01:24:34 +00:00
|
|
|
HashTable_DebugStats(&allTargetsByName, "targets");
|
2020-09-05 16:11:04 +00:00
|
|
|
}
|
|
|
|
|
2020-11-20 03:54:37 +00:00
|
|
|
/*
|
|
|
|
* Return the list of all targets, which are all nodes that appear on the
|
|
|
|
* left-hand side of a dependency declaration such as "target: source".
|
|
|
|
* The returned list does not contain pure sources.
|
|
|
|
*/
|
2020-11-07 19:39:21 +00:00
|
|
|
GNodeList *
|
2012-06-08 21:57:36 +00:00
|
|
|
Targ_List(void)
|
|
|
|
{
|
2021-01-14 01:24:34 +00:00
|
|
|
return &allTargets;
|
2012-06-08 21:57:36 +00:00
|
|
|
}
|
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
/*
|
|
|
|
* Create a new graph node, but don't register it anywhere.
|
2012-06-08 21:57:36 +00:00
|
|
|
*
|
2023-01-28 00:23:54 +00:00
|
|
|
* Graph nodes that occur on the left-hand side of a dependency line such
|
2020-11-20 03:54:37 +00:00
|
|
|
* as "target: source" are called targets. XXX: In some cases (like the
|
2023-01-28 00:23:54 +00:00
|
|
|
* .ALLTARGETS variable), other nodes are called targets as well, even if
|
|
|
|
* they never occur on the left-hand side of a dependency line.
|
2020-11-20 03:54:37 +00:00
|
|
|
*
|
|
|
|
* Typical names for graph nodes are:
|
2023-01-28 00:23:54 +00:00
|
|
|
* "src.c" an ordinary file
|
|
|
|
* "clean" a .PHONY target
|
|
|
|
* ".END" a special hook target
|
|
|
|
* "-lm" a library
|
|
|
|
* "libm.a(sin.o)" an archive member
|
2012-06-08 21:57:36 +00:00
|
|
|
*/
|
|
|
|
GNode *
|
2020-11-20 03:54:37 +00:00
|
|
|
GNode_New(const char *name)
|
2012-06-08 21:57:36 +00:00
|
|
|
{
|
2021-01-14 01:24:34 +00:00
|
|
|
GNode *gn;
|
|
|
|
|
|
|
|
gn = bmake_malloc(sizeof *gn);
|
|
|
|
gn->name = bmake_strdup(name);
|
|
|
|
gn->uname = NULL;
|
|
|
|
gn->path = NULL;
|
|
|
|
gn->type = name[0] == '-' && name[1] == 'l' ? OP_LIB : OP_NONE;
|
2021-12-18 07:27:22 +00:00
|
|
|
memset(&gn->flags, 0, sizeof(gn->flags));
|
2021-01-14 01:24:34 +00:00
|
|
|
gn->made = UNMADE;
|
|
|
|
gn->unmade = 0;
|
|
|
|
gn->mtime = 0;
|
|
|
|
gn->youngestChild = NULL;
|
|
|
|
Lst_Init(&gn->implicitParents);
|
|
|
|
Lst_Init(&gn->parents);
|
|
|
|
Lst_Init(&gn->children);
|
|
|
|
Lst_Init(&gn->order_pred);
|
|
|
|
Lst_Init(&gn->order_succ);
|
|
|
|
Lst_Init(&gn->cohorts);
|
|
|
|
gn->cohort_num[0] = '\0';
|
|
|
|
gn->unmade_cohorts = 0;
|
|
|
|
gn->centurion = NULL;
|
|
|
|
gn->checked_seqno = 0;
|
|
|
|
HashTable_Init(&gn->vars);
|
|
|
|
Lst_Init(&gn->commands);
|
|
|
|
gn->suffix = NULL;
|
|
|
|
gn->fname = NULL;
|
|
|
|
gn->lineno = 0;
|
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
|
|
|
gn->exit_status = 0;
|
2012-06-08 21:57:36 +00:00
|
|
|
|
|
|
|
#ifdef CLEANUP
|
2021-01-14 01:24:34 +00:00
|
|
|
Lst_Append(&allNodes, gn);
|
2012-06-08 21:57:36 +00:00
|
|
|
#endif
|
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
return gn;
|
2012-06-08 21:57:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CLEANUP
|
|
|
|
static void
|
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
|
|
|
GNode_Free(GNode *gn)
|
2012-06-08 21:57:36 +00:00
|
|
|
{
|
Import bmake-20240625
Intersting/relevant changes since bmake-20240520
ChangeLog since bmake-20240520
2024-06-25 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240625
Merge with NetBSD make, pick up
o job.c: ensure shellPath is always duped, avoid upsetting free()
2024-06-16 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240616
Merge with NetBSD make, pick up
o clean up collection of context information for error messages
o in warnings, move the word "warning" to the front
o var.c: throw an error on attempt to override an internal
read-only variable
2024-06-10 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240610
Merge with NetBSD make, pick up
o for.c: remove redundant shortcut for building the .for loop body
2024-06-02 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240602
Merge with NetBSD make, pick up
o rename some VarEvalMode constants to better match debug names.
o var.c: avoid out-of-bounds read when parsing indirect modifiers.
2024-06-01 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240601
Merge with NetBSD make, pick up
o add .export-all rather than allow .export with no argument
which can happen accidentally.
o if lua is available, run check-expect.lua after unit-tests
o main.c: use snprintf rather than strncpy
fix memory leak when purging realpath cache.
2024-05-28 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240528
Merge with NetBSD make, pick up
o fix a number of memory leaks
o replace magic numbers with POSIX FILENO constants
o hash.c: remove dead code from HashTable_DeleteEntry
o main.c: when complaining about unusable .OBJDIR
call PrintOnError if MAKE_DEBUG_OBJDIR_CHECK_WRITABLE is true.
o parse.c: use fewer technical terms in debug message for dependency
mk/ChangeLog since bmake-20240520
2024-06-22 Simon J Gerraty <sjg@beast.crufty.net>
* install-mk (MK_VERSION): 20240616
* dirdeps.mk: apply DEP_DIRDEPS_BUILD_DIR_FILTER after we have
computed build dirs, since some filters cannot be easily expressed via
DEP_DIRDEPS_FILTER.
2024-05-31 Simon J Gerraty <sjg@beast.crufty.net>
* dirdeps.mk: move reset of DIRDEPS_EXPORT_VARS
until after we a finished with it if building a cache.
2024-06-29 00:16:32 +00:00
|
|
|
Var_DeleteAll(gn);
|
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
free(gn->name);
|
|
|
|
free(gn->uname);
|
|
|
|
free(gn->path);
|
|
|
|
|
|
|
|
/* Don't free gn->youngestChild since it is not owned by this node. */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* In the following lists, only free the list nodes, but not the
|
|
|
|
* GNodes in them since these are not owned by this node.
|
|
|
|
*/
|
|
|
|
Lst_Done(&gn->implicitParents);
|
|
|
|
Lst_Done(&gn->parents);
|
|
|
|
Lst_Done(&gn->children);
|
|
|
|
Lst_Done(&gn->order_pred);
|
|
|
|
Lst_Done(&gn->order_succ);
|
|
|
|
Lst_Done(&gn->cohorts);
|
|
|
|
|
|
|
|
HashTable_Done(&gn->vars);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Do not free the commands themselves, as they may be shared with
|
|
|
|
* other nodes.
|
|
|
|
*/
|
|
|
|
Lst_Done(&gn->commands);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* gn->suffix is not owned by this node.
|
|
|
|
*
|
|
|
|
* XXX: gn->suffix should be unreferenced here. This requires a
|
|
|
|
* thorough check that the reference counting is done correctly in
|
|
|
|
* all places, otherwise a suffix might be freed too early.
|
|
|
|
*/
|
|
|
|
|
|
|
|
free(gn);
|
2012-06-08 21:57:36 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2020-11-07 19:39:21 +00:00
|
|
|
/* Get the existing global node, or return NULL. */
|
2012-06-08 21:57:36 +00:00
|
|
|
GNode *
|
2020-11-07 19:39:21 +00:00
|
|
|
Targ_FindNode(const char *name)
|
2012-06-08 21:57:36 +00:00
|
|
|
{
|
2021-01-14 01:24:34 +00:00
|
|
|
return HashTable_FindValue(&allTargetsByName, name);
|
2020-11-07 19:39:21 +00:00
|
|
|
}
|
2012-06-08 21:57:36 +00:00
|
|
|
|
2020-11-07 19:39:21 +00:00
|
|
|
/* Get the existing global node, or create it. */
|
|
|
|
GNode *
|
|
|
|
Targ_GetNode(const char *name)
|
|
|
|
{
|
2021-06-25 18:16:24 +00:00
|
|
|
bool isNew;
|
2021-01-14 01:24:34 +00:00
|
|
|
HashEntry *he = HashTable_CreateEntry(&allTargetsByName, name, &isNew);
|
|
|
|
if (!isNew)
|
|
|
|
return HashEntry_Get(he);
|
|
|
|
|
|
|
|
{
|
|
|
|
GNode *gn = Targ_NewInternalNode(name);
|
|
|
|
HashEntry_Set(he, gn);
|
|
|
|
return gn;
|
|
|
|
}
|
2020-11-07 19:39:21 +00:00
|
|
|
}
|
2012-06-08 21:57:36 +00:00
|
|
|
|
2020-11-20 03:54:37 +00:00
|
|
|
/*
|
|
|
|
* Create a node, register it in .ALLTARGETS but don't store it in the
|
2020-11-07 19:39:21 +00:00
|
|
|
* table of global nodes. This means it cannot be found by name.
|
|
|
|
*
|
2020-11-20 03:54:37 +00:00
|
|
|
* This is used for internal nodes, such as cohorts or .WAIT nodes.
|
|
|
|
*/
|
2020-11-07 19:39:21 +00:00
|
|
|
GNode *
|
|
|
|
Targ_NewInternalNode(const char *name)
|
|
|
|
{
|
2021-01-14 01:24:34 +00:00
|
|
|
GNode *gn = GNode_New(name);
|
2021-02-11 01:51:11 +00:00
|
|
|
Global_Append(".ALLTARGETS", name);
|
2021-01-14 01:24:34 +00:00
|
|
|
Lst_Append(&allTargets, gn);
|
|
|
|
DEBUG1(TARG, "Adding \"%s\" to all targets.\n", gn->name);
|
|
|
|
if (doing_depend)
|
2021-12-18 07:27:22 +00:00
|
|
|
gn->flags.fromDepend = true;
|
2021-01-14 01:24:34 +00:00
|
|
|
return gn;
|
2012-06-08 21:57:36 +00:00
|
|
|
}
|
|
|
|
|
2020-11-20 03:54:37 +00:00
|
|
|
/*
|
|
|
|
* Return the .END node, which contains the commands to be run when
|
|
|
|
* everything else has been made.
|
|
|
|
*/
|
2021-01-14 01:24:34 +00:00
|
|
|
GNode *
|
|
|
|
Targ_GetEndNode(void)
|
2020-11-07 19:39:21 +00:00
|
|
|
{
|
2021-01-14 01:24:34 +00:00
|
|
|
/*
|
|
|
|
* Save the node locally to avoid having to search for it all
|
|
|
|
* the time.
|
|
|
|
*/
|
|
|
|
static GNode *endNode = NULL;
|
|
|
|
|
|
|
|
if (endNode == NULL) {
|
|
|
|
endNode = Targ_GetNode(".END");
|
|
|
|
endNode->type = OP_SPECIAL;
|
|
|
|
}
|
|
|
|
return endNode;
|
2012-06-08 21:57:36 +00:00
|
|
|
}
|
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
/* Add the named nodes to the list, creating them as necessary. */
|
|
|
|
void
|
|
|
|
Targ_FindList(GNodeList *gns, StringList *names)
|
2012-06-08 21:57:36 +00:00
|
|
|
{
|
2021-01-14 01:24:34 +00:00
|
|
|
StringListNode *ln;
|
2012-06-08 21:57:36 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
for (ln = names->first; ln != NULL; ln = ln->next) {
|
|
|
|
const char *name = ln->datum;
|
|
|
|
GNode *gn = Targ_GetNode(name);
|
|
|
|
Lst_Append(gns, gn);
|
|
|
|
}
|
2012-06-08 21:57:36 +00:00
|
|
|
}
|
|
|
|
|
2020-11-07 19:39:21 +00:00
|
|
|
static void
|
|
|
|
PrintNodeNames(GNodeList *gnodes)
|
2012-06-08 21:57:36 +00:00
|
|
|
{
|
2021-01-14 01:24:34 +00:00
|
|
|
GNodeListNode *ln;
|
2012-06-08 21:57:36 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
for (ln = gnodes->first; ln != NULL; ln = ln->next) {
|
|
|
|
GNode *gn = ln->datum;
|
|
|
|
debug_printf(" %s%s", gn->name, gn->cohort_num);
|
|
|
|
}
|
2012-06-08 21:57:36 +00:00
|
|
|
}
|
|
|
|
|
2020-11-07 19:39:21 +00:00
|
|
|
static void
|
|
|
|
PrintNodeNamesLine(const char *label, GNodeList *gnodes)
|
|
|
|
{
|
2021-01-14 01:24:34 +00:00
|
|
|
if (Lst_IsEmpty(gnodes))
|
|
|
|
return;
|
|
|
|
debug_printf("# %s:", label);
|
|
|
|
PrintNodeNames(gnodes);
|
|
|
|
debug_printf("\n");
|
2020-11-07 19:39:21 +00:00
|
|
|
}
|
2012-06-08 21:57:36 +00:00
|
|
|
|
2020-11-07 19:39:21 +00:00
|
|
|
void
|
|
|
|
Targ_PrintCmds(GNode *gn)
|
2012-06-08 21:57:36 +00:00
|
|
|
{
|
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;
|
|
|
|
debug_printf("\t%s\n", cmd);
|
|
|
|
}
|
2012-06-08 21:57:36 +00:00
|
|
|
}
|
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
/*
|
|
|
|
* Format a modification time in some reasonable way and return it.
|
|
|
|
* The formatted time is placed in a static area, so it is overwritten
|
|
|
|
* with each call.
|
|
|
|
*/
|
|
|
|
const char *
|
2012-06-08 21:57:36 +00:00
|
|
|
Targ_FmtTime(time_t tm)
|
|
|
|
{
|
2021-01-14 01:24:34 +00:00
|
|
|
static char buf[128];
|
2012-06-08 21:57:36 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
struct tm *parts = localtime(&tm);
|
2021-06-25 18:16:24 +00:00
|
|
|
(void)strftime(buf, sizeof buf, "%H:%M:%S %b %d, %Y", parts);
|
2021-01-14 01:24:34 +00:00
|
|
|
return buf;
|
2012-06-08 21:57:36 +00:00
|
|
|
}
|
|
|
|
|
2020-09-05 16:11:04 +00:00
|
|
|
/* Print out a type field giving only those attributes the user can set. */
|
2012-06-08 21:57:36 +00:00
|
|
|
void
|
2021-12-18 07:27:22 +00:00
|
|
|
Targ_PrintType(GNodeType type)
|
2012-06-08 21:57:36 +00:00
|
|
|
{
|
2021-12-18 07:27:22 +00:00
|
|
|
static const struct {
|
|
|
|
GNodeType bit;
|
|
|
|
bool internal;
|
|
|
|
const char name[10];
|
|
|
|
} names[] = {
|
|
|
|
{ OP_MEMBER, true, "MEMBER" },
|
|
|
|
{ OP_LIB, true, "LIB" },
|
|
|
|
{ OP_ARCHV, true, "ARCHV" },
|
|
|
|
{ OP_PHONY, true, "PHONY" },
|
|
|
|
{ OP_NOTMAIN, false, "NOTMAIN" },
|
|
|
|
{ OP_INVISIBLE, false, "INVISIBLE" },
|
|
|
|
{ OP_MADE, true, "MADE" },
|
|
|
|
{ OP_JOIN, false, "JOIN" },
|
|
|
|
{ OP_MAKE, false, "MAKE" },
|
|
|
|
{ OP_SILENT, false, "SILENT" },
|
|
|
|
{ OP_PRECIOUS, false, "PRECIOUS" },
|
|
|
|
{ OP_IGNORE, false, "IGNORE" },
|
|
|
|
{ OP_EXEC, false, "EXEC" },
|
|
|
|
{ OP_USE, false, "USE" },
|
2022-04-22 20:34:55 +00:00
|
|
|
{ OP_USEBEFORE, false, "USEBEFORE" },
|
2021-12-18 07:27:22 +00:00
|
|
|
{ OP_OPTIONAL, false, "OPTIONAL" },
|
|
|
|
};
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
for (i = 0; i < sizeof(names) / sizeof(names[0]); i++) {
|
|
|
|
if (type & names[i].bit) {
|
|
|
|
if (names[i].internal)
|
|
|
|
DEBUG1(TARG, " .%s", names[i].name);
|
|
|
|
else
|
|
|
|
debug_printf(" .%s", names[i].name);
|
2021-01-14 01:24:34 +00:00
|
|
|
}
|
2012-06-08 21:57:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-11 01:51:11 +00:00
|
|
|
const char *
|
|
|
|
GNodeMade_Name(GNodeMade made)
|
2012-06-08 21:57:36 +00:00
|
|
|
{
|
2021-01-14 01:24:34 +00:00
|
|
|
switch (made) {
|
|
|
|
case UNMADE: return "unmade";
|
|
|
|
case DEFERRED: return "deferred";
|
|
|
|
case REQUESTED: return "requested";
|
|
|
|
case BEINGMADE: return "being made";
|
|
|
|
case MADE: return "made";
|
|
|
|
case UPTODATE: return "up-to-date";
|
|
|
|
case ERROR: return "error when made";
|
|
|
|
case ABORTED: return "aborted";
|
|
|
|
default: return "unknown enum_made value";
|
|
|
|
}
|
2012-06-08 21:57:36 +00:00
|
|
|
}
|
|
|
|
|
2020-11-07 19:39:21 +00:00
|
|
|
static const char *
|
|
|
|
GNode_OpName(const GNode *gn)
|
2012-06-08 21:57:36 +00:00
|
|
|
{
|
2021-01-14 01:24:34 +00:00
|
|
|
switch (gn->type & OP_OPMASK) {
|
|
|
|
case OP_DEPENDS:
|
|
|
|
return ":";
|
|
|
|
case OP_FORCE:
|
|
|
|
return "!";
|
|
|
|
case OP_DOUBLEDEP:
|
|
|
|
return "::";
|
|
|
|
}
|
|
|
|
return "";
|
2020-11-07 19:39:21 +00:00
|
|
|
}
|
2012-06-08 21:57:36 +00:00
|
|
|
|
2021-12-18 07:27:22 +00:00
|
|
|
static bool
|
|
|
|
GNodeFlags_IsNone(GNodeFlags flags)
|
|
|
|
{
|
|
|
|
return !flags.remake
|
|
|
|
&& !flags.childMade
|
|
|
|
&& !flags.force
|
|
|
|
&& !flags.doneWait
|
|
|
|
&& !flags.doneOrder
|
|
|
|
&& !flags.fromDepend
|
|
|
|
&& !flags.doneAllsrc
|
|
|
|
&& !flags.cycle
|
|
|
|
&& !flags.doneCycle;
|
|
|
|
}
|
|
|
|
|
2020-11-07 19:39:21 +00:00
|
|
|
/* Print the contents of a node. */
|
|
|
|
void
|
|
|
|
Targ_PrintNode(GNode *gn, int pass)
|
|
|
|
{
|
2021-01-14 01:24:34 +00:00
|
|
|
debug_printf("# %s%s", gn->name, gn->cohort_num);
|
|
|
|
GNode_FprintDetails(opts.debug_file, ", ", gn, "\n");
|
2021-12-18 07:27:22 +00:00
|
|
|
if (GNodeFlags_IsNone(gn->flags))
|
2021-01-14 01:24:34 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (!GNode_IsTarget(gn))
|
|
|
|
return;
|
2012-06-08 21:57:36 +00:00
|
|
|
|
2020-11-07 19:39:21 +00:00
|
|
|
debug_printf("#\n");
|
2022-02-05 20:03:50 +00:00
|
|
|
if (gn == mainNode)
|
2021-01-14 01:24:34 +00:00
|
|
|
debug_printf("# *** MAIN TARGET ***\n");
|
|
|
|
|
2012-06-08 21:57:36 +00:00
|
|
|
if (pass >= 2) {
|
2021-01-14 01:24:34 +00:00
|
|
|
if (gn->unmade > 0)
|
|
|
|
debug_printf("# %d unmade children\n", gn->unmade);
|
|
|
|
else
|
|
|
|
debug_printf("# No unmade children\n");
|
|
|
|
if (!(gn->type & (OP_JOIN | OP_USE | OP_USEBEFORE | OP_EXEC))) {
|
|
|
|
if (gn->mtime != 0) {
|
|
|
|
debug_printf("# last modified %s: %s\n",
|
|
|
|
Targ_FmtTime(gn->mtime),
|
2021-02-11 01:51:11 +00:00
|
|
|
GNodeMade_Name(gn->made));
|
2021-01-14 01:24:34 +00:00
|
|
|
} else if (gn->made != UNMADE) {
|
|
|
|
debug_printf("# nonexistent (maybe): %s\n",
|
2021-02-11 01:51:11 +00:00
|
|
|
GNodeMade_Name(gn->made));
|
2021-01-14 01:24:34 +00:00
|
|
|
} else
|
|
|
|
debug_printf("# unmade\n");
|
2012-06-08 21:57:36 +00:00
|
|
|
}
|
2021-01-14 01:24:34 +00:00
|
|
|
PrintNodeNamesLine("implicit parents", &gn->implicitParents);
|
2012-06-08 21:57:36 +00:00
|
|
|
} else {
|
2021-01-14 01:24:34 +00:00
|
|
|
if (gn->unmade != 0)
|
|
|
|
debug_printf("# %d unmade children\n", gn->unmade);
|
2012-06-08 21:57:36 +00:00
|
|
|
}
|
2021-01-14 01:24:34 +00:00
|
|
|
|
|
|
|
PrintNodeNamesLine("parents", &gn->parents);
|
|
|
|
PrintNodeNamesLine("order_pred", &gn->order_pred);
|
|
|
|
PrintNodeNamesLine("order_succ", &gn->order_succ);
|
2012-06-08 21:57:36 +00:00
|
|
|
|
2020-11-07 19:39:21 +00:00
|
|
|
debug_printf("%-16s%s", gn->name, GNode_OpName(gn));
|
2012-06-08 21:57:36 +00:00
|
|
|
Targ_PrintType(gn->type);
|
2021-01-14 01:24:34 +00:00
|
|
|
PrintNodeNames(&gn->children);
|
2020-11-07 19:39:21 +00:00
|
|
|
debug_printf("\n");
|
|
|
|
Targ_PrintCmds(gn);
|
|
|
|
debug_printf("\n\n");
|
2021-01-14 01:24:34 +00:00
|
|
|
if (gn->type & OP_DOUBLEDEP)
|
|
|
|
Targ_PrintNodes(&gn->cohorts, pass);
|
2012-06-08 21:57:36 +00:00
|
|
|
}
|
|
|
|
|
2020-11-07 19:39:21 +00:00
|
|
|
void
|
|
|
|
Targ_PrintNodes(GNodeList *gnodes, int pass)
|
|
|
|
{
|
2021-01-14 01:24:34 +00:00
|
|
|
GNodeListNode *ln;
|
|
|
|
|
|
|
|
for (ln = gnodes->first; ln != NULL; ln = ln->next)
|
|
|
|
Targ_PrintNode(ln->datum, pass);
|
2020-11-07 19:39:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
PrintOnlySources(void)
|
2012-06-08 21:57:36 +00:00
|
|
|
{
|
2021-01-14 01:24:34 +00:00
|
|
|
GNodeListNode *ln;
|
2012-06-08 21:57:36 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
for (ln = allTargets.first; ln != NULL; ln = ln->next) {
|
|
|
|
GNode *gn = ln->datum;
|
|
|
|
if (GNode_IsTarget(gn))
|
|
|
|
continue;
|
2012-06-08 21:57:36 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
debug_printf("#\t%s [%s]", gn->name, GNode_Path(gn));
|
|
|
|
Targ_PrintType(gn->type);
|
|
|
|
debug_printf("\n");
|
|
|
|
}
|
2012-06-08 21:57:36 +00:00
|
|
|
}
|
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
/*
|
|
|
|
* Input:
|
2020-09-05 16:11:04 +00:00
|
|
|
* pass 1 => before processing
|
|
|
|
* 2 => after processing
|
|
|
|
* 3 => after processing, an error occurred
|
2012-06-08 21:57:36 +00:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
Targ_PrintGraph(int pass)
|
|
|
|
{
|
2021-01-14 01:24:34 +00:00
|
|
|
debug_printf("#*** Input graph:\n");
|
|
|
|
Targ_PrintNodes(&allTargets, pass);
|
|
|
|
debug_printf("\n");
|
|
|
|
debug_printf("\n");
|
2020-11-20 03:54:37 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
debug_printf("#\n");
|
|
|
|
debug_printf("# Files that are only sources:\n");
|
|
|
|
PrintOnlySources();
|
2020-11-20 03:54:37 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
debug_printf("#*** Global Variables:\n");
|
2021-02-11 01:51:11 +00:00
|
|
|
Var_Dump(SCOPE_GLOBAL);
|
2020-11-20 03:54:37 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
debug_printf("#*** Command-line Variables:\n");
|
2021-02-11 01:51:11 +00:00
|
|
|
Var_Dump(SCOPE_CMDLINE);
|
2020-11-20 03:54:37 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
debug_printf("\n");
|
|
|
|
Dir_PrintDirectories();
|
|
|
|
debug_printf("\n");
|
2020-11-20 03:54:37 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
Suff_PrintAll();
|
2012-06-08 21:57:36 +00:00
|
|
|
}
|
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
/*
|
|
|
|
* Propagate some type information to cohort nodes (those from the '::'
|
2020-09-05 16:11:04 +00:00
|
|
|
* dependency operator).
|
2012-06-08 21:57:36 +00:00
|
|
|
*
|
2020-09-05 16:11:04 +00:00
|
|
|
* Should be called after the makefiles are parsed but before any action is
|
2021-01-14 01:24:34 +00:00
|
|
|
* taken.
|
|
|
|
*/
|
2020-09-05 16:11:04 +00:00
|
|
|
void
|
|
|
|
Targ_Propagate(void)
|
2012-06-08 21:57:36 +00:00
|
|
|
{
|
2021-01-14 01:24:34 +00:00
|
|
|
GNodeListNode *ln, *cln;
|
2012-06-08 21:57:36 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
for (ln = allTargets.first; ln != NULL; ln = ln->next) {
|
|
|
|
GNode *gn = ln->datum;
|
|
|
|
GNodeType type = gn->type;
|
2012-06-08 21:57:36 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
if (!(type & OP_DOUBLEDEP))
|
|
|
|
continue;
|
2012-06-08 21:57:36 +00:00
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
for (cln = gn->cohorts.first; cln != NULL; cln = cln->next) {
|
|
|
|
GNode *cohort = cln->datum;
|
2012-06-08 21:57:36 +00:00
|
|
|
|
2023-01-28 00:23:54 +00:00
|
|
|
cohort->type |= type & (unsigned)~OP_OPMASK;
|
2021-01-14 01:24:34 +00:00
|
|
|
}
|
2020-09-05 16:11:04 +00:00
|
|
|
}
|
2012-06-08 21:57:36 +00:00
|
|
|
}
|