Home | History | Annotate | Download | only in make
History log of /src/usr.bin/make/suff.c
RevisionDateAuthorComments
 1.384  18-May-2025  rillig make: rename variables, remove now-redundant comments
 1.383  14-Jan-2025  rillig make: clarify that undefined expressions are allowed in dependencies
 1.382  07-Jul-2024  rillig make: only generate code for cleanup functions in CLEANUP mode
 1.381  05-Jul-2024  rillig make: reduce lint-specific comments about ARGSUSED
 1.380  02-Jun-2024  rillig make: sync VarEvalMode constant names with their debug log names
 1.379  25-May-2024  rillig make: fix some more memory leaks
 1.378  07-Feb-2024  rillig make: remove unneeded conditional-compilation toggles

The toggles INCLUDES, LIBRARIES, POSIX, SYSVINCLUDE, SYSVVARSUB,
GMAKEEXPORT and SUNSHCMD are no longer needed, they were unconditionally
set.

The toggle NO_REGEX was configurable from the command line, but
disabling it would result in various error messages about the unknown
':C' modifier.

OK sjg@.
 1.377  05-Jan-2024  rillig make: miscellaneous cleanups
 1.376  30-Dec-2023  rillig make: clean up freeing of suffixes

No functional change.
 1.375  30-Dec-2023  rillig make: remove unused field from suffix

No functional change.
 1.374  29-Dec-2023  rillig make: fix declared types of list nodes

No functional change.
 1.373  29-Dec-2023  rillig make: simplify memory allocation for string buffers

In edge cases and short-lived buffers, the initial buffer size is
irrelevant, so use the default.

No functional change.
 1.372  19-Dec-2023  rillig make: clean up comments

No binary change, except for line numbers in assertions.
 1.371  17-Dec-2023  rillig make: clean up names of local variables

No binary change.
 1.370  19-Nov-2023  rillig make: replace 'variable expression' with 'expression' in comments

No binary change.
 1.369  19-Nov-2023  rillig make: replace 'variable expression' with 'expression' in diagnostics
 1.368  14-Feb-2023  rillig make: clean up calls to Var_Subst

None of the calls to Var_Subst used the return value, and the return
value was always VPR_OK.

No functional change.
 1.367  14-Feb-2023  rillig make: reduce complexity of evaluating expressions

No functional change.
 1.366  04-Mar-2022  sjg Fix some unused warnings
 1.365  03-Mar-2022  rillig make: improve comments and a parameter name

No binary change.
 1.364  07-Jan-2022  rillig make: remove redundant function parameter in suffix handling

Now that mainNode is globally visible, there is no need to pass it
through function parameters.

No functional change.
 1.363  07-Jan-2022  rillig make: merge duplicate variables for the main target

No functional change.
 1.362  01-Jan-2022  rillig make: remove redundant comments from ParseDependencySourceSpecial
 1.361  28-Dec-2021  rillig make: extract OP_NOTARGET into separate function

No binary change, except for line numbers in assertions.
 1.360  15-Dec-2021  rillig make: format comments according to /usr/share/misc/style

Assisted by indent(1), with manual corrections due to its many remaining
bugs.

No functional change.
 1.359  15-Dec-2021  rillig make: use consistent indentation for statements and continuations

No binary change, except for line numbers in assertions in suff.c.
 1.358  13-Dec-2021  rillig make: fix memory leak when evaluating ${.SUFFIX} (since yesterday)
 1.357  12-Dec-2021  sjg Add .SUFFIXES as read-only variable.

References to ${.SUFFIXES} are handled dynamically in
ParseVarnameLong by calling Suff_NamesStr.

The variable cannot be set normally.

Reviewed by: rillig
 1.356  09-Dec-2021  rillig make: remove period from end of error messages and warnings

The majority of the existing error messages and warnings does not
include a period at the end. Follow this style consistently.
 1.355  28-Nov-2021  rillig make: move duplicate function Buf_AddFlag to buf.c

It is used only for debug output, therefore performance doesn't matter.

No functional change.
 1.354  28-Nov-2021  rillig make: inline SuffixFlags_ToString into Suffix_Print

This gets rid of the string literal "none" and the complicated memory
handling.

No functional change.
 1.353  28-Nov-2021  rillig make: inline SuffixFlags into the Suffix itself

No functional change.
 1.352  28-Nov-2021  rillig make: replace bloated bit-set-to-string code with simple code

It was a nice idea to implement a bit-set using an enum type and have a
generic ToString function for them. In the end, the implementation
involved really heavy preprocessor magic and was probably difficult to
understand. Replace all the code with a few bits of straight-forward
preprocessor magic that can be readily understood by just looking 5
lines around, instead of digging through 130 lines of lengthy macro
definitions.

Curiously, this reduces the binary size even though the 3 ToString
functions now have a few lines of duplicate code and there are more
explicit function calls.

The ToString functions are only seldom used, so the additional memory
allocation is acceptable.

No functional change.
 1.351  31-Jul-2021  rillig make: fix lint warnings

The string functions from str.h are declared as 'static __unused' when
compiled with GCC, but lint explicitly undefines __GCC__ during
preprocessing. Therefore, make those functions inline, to prevent
warnings that they are unused.

The macro UNCONST is used in a few places, and (again) since lint
undefines __GCC__, that macro expanded to a simple type cast, which lint
warned about. To prevent this warning, implement UNCONST as a function
that works everywhere and hides the type cast.

In filemon_open, the code for closing F->in was obviously unreachable.

No functional change.
 1.350  04-Apr-2021  rillig make: rename a few functions to be more descriptive

No functional change.
 1.349  03-Apr-2021  rillig make: use C99 bool type instead of defining its own

No functional change.
 1.348  15-Mar-2021  rillig make: replace enum bit-field with struct bit-field for VarEvalFlags

This makes the code easier to read, especially in var.c. It also makes
debugging sessions easier since some debuggers don't show enum
bit-fields symbolically as soon as more than one bit is set.

The code outside var.c is basically unchanged, except that instead of
passing the individual flags, there are 4 predefined evaluation modes.
These suffice for all practical use cases. Only in the implementation
deep inside var.c, the value of the flags keepDollar and keepUndef
differs.

There is no way of passing the struct to EnumFlags_ToString, which means
the ToString function has to be spelled out explicitly. This allows for
fine-tuning the representation in the debug log, to reduce the amount of
uppercae letters.

No functional change.
 1.347  15-Mar-2021  rillig make: rename VARE_NONE to VARE_PARSE_ONLY

The name 'NONE' described the bit pattern, which was not useful to
understand its meaning. Omitting VARE_WANTRES only parses the
expression, without evaluating any part of it.

No functional change, not even in debug mode since Enum_FlagsToString
always returns "none" for all-bits-unset.
 1.346  23-Feb-2021  rillig make: improve error message for unclosed modifier

Replace "variable specification" with the more modern "variable
expression", reduce the number of parentheses, output more than a single
character for modifiers, make it obvious that in expressions such as
${:Serror}, the "" means a variable name.
 1.345  05-Feb-2021  rillig make: in the Var_ functions, move the scope to the front

This change provides for a more natural reading order in the code.
Placing the scope first makes it immediately clear in which context the
remaining parameters are interpreted.

No functional change.
 1.344  04-Feb-2021  rillig make: rename context and ctxt to scope

This continues the previous commit, in which VAR_GLOBAL, VAR_INTERNAL
and VAR_CMDLINE were renamed.

Renaming the variable 'ctxt' was trivial since that word is used nowhere
else. In the comments though, each occurrence of the word 'context' had
to be checked individually since the word 'context' was not only used
for referring to a variable scope. It is also used to distinguish
different situations where characters are escaped in a certain way
('parsing context') and in a few other expressions.
 1.343  03-Feb-2021  rillig make: replace Global_SetExpand with Global_Set for constant names
 1.342  03-Feb-2021  rillig make: use shortcut functions Global_SetExpand and Global_AppendExpand

There are many places where global variables are set or appended to. To
reduce clutter and code size, encode the VAR_GLOBAL in the function
name.

The word Expand in the function names says that the variable name is
expanded. In most of the cases, this is not necessary, but there are no
corresponding functions Global_Set or Global_Append yet.

Encoding the information whether the name is expanded or not in the
function name will make inconsistencies obvious in future manual code
reviews. Letting the compiler check this by using different types for
unexpanded and expanded variable names is probably not worth the effort.
There are still a few bugs to be fixed, such as in SetVar, which expands
the variable name twice in a row.
 1.341  30-Jan-2021  rillig make(1): reduce boilerplate for printing bit sets in debug mode

No functional change.
 1.340  24-Jan-2021  rillig make(1): convert SearchPath to struct

This prepares for making dotLast a simple struct member instead of a
fake CachedDir, which is easier to understand.
 1.339  23-Jan-2021  rillig make(1): rename local variable in FindCmds
 1.338  23-Jan-2021  rillig make(1): remove the remaining beasts from the comments
 1.337  23-Jan-2021  rillig make(1): rename Dir_AddDir, reorder parameters of SearchPath_ToFlags
 1.336  23-Jan-2021  rillig make(1): rename Dir_Expand to SearchPath_Expand

The main subject of this function is the search path. In this search
path the pattern is expanded.
 1.335  10-Jan-2021  rillig make(1): consistently use boolean expressions in conditions

Most of the make code already followed the style of explicitly writing
(ptr != NULL) instead of the shorter (ptr) in conditions.

The remaining 50 instances have been found by an experimental,
unpublished check in lint(1) that treats bool expressions as
incompatible to any other scalar type, just as in Java, C#, Pascal and
several other languages.

The only unsafe operation on Boolean that is left over is (flags &
FLAG), for an enum implementing a bit set. If Boolean is an ordinary
integer type (the default), some high bits may get lost. But if Boolean
is the same as _Bool (by compiling with -DUSE_C99_BOOLEAN), C99 6.3.1.2
defines that a conversion from any scalar to the type _Bool acts as a
comparison to 0, which cannot lose any bits.
 1.334  09-Jan-2021  rillig make(1): fix lint warnings
 1.333  30-Dec-2020  rillig make(1): format multi-line comments
 1.332  20-Dec-2020  rillig make(1): return FStr from Var_Parse

This reduces the number of variable declarations at the call sites.
 1.331  18-Dec-2020  rillig make(1): spell nonexistent consistently
 1.330  13-Dec-2020  rillig make(1): add str_basename to reduce duplicate code

The function basename from POSIX has a few unfortunate properties, it is
allowed to return a pointer to static memory. This is too unreliable,
therefore this trivial own implementation.
 1.329  07-Dec-2020  rillig make(1): actually fix the use-after-free bug and the double-free

The use-after-free bug had been there since 2020-11-22, the double-free
bug since a few minutes.
 1.328  07-Dec-2020  rillig make(1): fix use-after-free in -DDEBUG_SRC mode (since 2020-11-22)
 1.327  06-Dec-2020  rillig make(1): inline macros for debug logging

No changes to the resulting binary, except for the line numbers in
assertions.
 1.326  05-Dec-2020  rillig make(1): define constants for enum zero-values
 1.325  05-Dec-2020  rillig make(1): extract ExpandChildrenRegular from ExpandChildren
 1.324  05-Dec-2020  rillig make(1): indent suff.c with tabs instead of spaces

ExpandChildren is way too deeply nested.
 1.323  29-Nov-2020  rillig make(1): reduce memory allocation for dirSearchPath
 1.322  29-Nov-2020  rillig make(1): reduce memory allocations in suffix storage
 1.321  29-Nov-2020  rillig make(1): reduce memory allocations in suffix handling
 1.320  29-Nov-2020  rillig make(1): reduce memory allocation in ExpandWildcards for suffixes
 1.319  29-Nov-2020  rillig make(1): reduce memory allocation in ExpandChildren for suffixes
 1.318  29-Nov-2020  rillig make(1): reduce memory allocation in suffix candidate search
 1.317  29-Nov-2020  rillig make(1): reduce memory allocation in suffix rule handling
 1.316  29-Nov-2020  rillig make(1): reduce memory allocation in suffix handling

The function Lst_MoveAll previously freed the source list. This
function was only used in a few places, and none of them really needed
the allocation.
 1.315  28-Nov-2020  rillig make(1): replace Dir_Destroy with SearchPath_Free

The function Dir_Destroy is an implementation detail of the cached
directories, and it should not be exported to the other modules. The
search paths, on the other hand, are the high-level API that may be used
by the other modules, as the concept of search paths is documented in
the manual page.
 1.314  28-Nov-2020  rillig make(1): rename some Dir functions to SearchPath

These functions have the search path as their main subject.
 1.313  28-Nov-2020  rillig make(1): reduce pointer indirection for GNode.implicitParents
 1.312  28-Nov-2020  rillig make(1): reduce pointer indirection for GNode.cohorts
 1.311  28-Nov-2020  rillig make(1): reduce pointer indirection for GNode.order_pred and order_succ
 1.310  28-Nov-2020  rillig make(1): reduce memory allocation for GNode.parents and GNode.children
 1.309  28-Nov-2020  rillig make(1): remove pointer indirection from GNode.commands

Just to save a few memory allocations. No noticeable effect on the
performance though.
 1.308  23-Nov-2020  rillig make(1): align end-of-line comments with tabs
 1.307  23-Nov-2020  rillig make(1): add HashSet type

This makes the code for handling suffixes simpler since it doesn't need
the clumsy API of HashTable_CreateEntry anymore.
 1.306  23-Nov-2020  rillig make(1): fix endless loop when resolving circular suffix rules
 1.305  23-Nov-2020  rillig make(1): make control flow simpler in FindThem
 1.304  23-Nov-2020  rillig make(1): fix DEBUG_SRC logging in FindThem

The node is also removed from the list if it is neither found in the
nodes nor in the file system. The logging did not reflect this.
 1.303  22-Nov-2020  rillig make(1): add high-level API for CandidateSearcher

This avoids passing invisible void pointers around in Lst_Append. It
also provides a convenient place to document what it means to "add a
candidate to the searcher".
 1.302  22-Nov-2020  rillig make(1): add CandidateSearcher to resolve transformation rules

Having a simple list of candidates is not enough. It is currently
possible to construct endless loops with huge memory usage, as
demonstrated in suff-transform-endless.mk.

To fix this, a straight-forward idea is to remember which candidates
have already been searched and to not search them again.

This also fixes a small inconsistency in the code. Most parameters had
been named slst (the s came from a time when Candidate was named Src),
except for Suff_FindDeps, where the variable was named srcs. The
confusing thing about this was that the name srcs is used throughout the
file for a different purpose. Only in FindThem there were two
parameters of the same type, which made this even more confusing.
 1.301  22-Nov-2020  rillig make(1): add more debugging for searching transformation rules
 1.300  22-Nov-2020  rillig make(1): add debug logging for setting and resetting the main target

The suffix code still doesn't behave as expected. Make sure that at
least setting the main target works as expected. It does, and the added
debug logging provides further hints for debugging the suffix handling
code.
 1.299  22-Nov-2020  rillig make(1): rename local variable in UpdateTargets
 1.298  22-Nov-2020  rillig make(1): extract FindDepsLib from FindDepsRegularKnown
 1.297  22-Nov-2020  rillig make(1): rename Candidate.pref to prefix

The new name nicely matches the .PREFIX variable.
 1.296  22-Nov-2020  rillig make(1): improve documentation of Candidate fields
 1.295  22-Nov-2020  rillig make(1): extract ExpandMember from FindDepsArchive
 1.294  22-Nov-2020  rillig make(1): extract ExpandAllChildren from FindDepsArchive
 1.293  22-Nov-2020  rillig make(1): extract string handling from Suffix_GetSuffix

Finding a suffix of a string is not the job of the Suffix type.
 1.292  22-Nov-2020  rillig make(1): rename StrIsPrefix to StrTrimPrefix

Only functions returning Boolean should have the word Is in their name.
 1.291  22-Nov-2020  rillig make(1): fix C99-ism in Suffix_GetSuffix
 1.290  22-Nov-2020  rillig make(1): fix type of local variable in FindDepsRegular

The compiler cannot check these since all lists and list nodes are
aliases to each other.

Maybe it's time to add type-generic lists to the code, to delegate these
checks to the compiler.
 1.289  22-Nov-2020  rillig make(1): add comment about missing unit test for .MAIN in suffixes
 1.288  22-Nov-2020  rillig make(1): remove last occurrences of Src
 1.287  22-Nov-2020  rillig make(1): clean up comment about single-suffix inference rules
 1.286  22-Nov-2020  rillig make(1): merge functions for suffix handling

The names of the functions AddSources and AddLevel were not as precise
and guiding as possible. Merging them into a single function makes the
code indented a little more, but on the other hand provides a function
with an easy to grasp purpose.
 1.285  22-Nov-2020  rillig make(1): clean up comments for Suff_AddInclude and Suff_AddLib
 1.284  22-Nov-2020  rillig make(1): document possible bug in UpdateTarget in suffix handling
 1.283  22-Nov-2020  rillig make(1): rename type SrcList to CandidateList

The variable names will be renamed in a follow-up commit, as necessary.
 1.282  22-Nov-2020  rillig make(1): rename type Src to Candidate

In all this code about sources, targets, parents and children, it's been
way too difficult to decide whether each word 'src' meant a source as
opposed to target, or just a possible source on its own.
 1.281  21-Nov-2020  rillig make(1): remove module name from local functions in Suff module

The module name doesn't provide any useful information. More often than
not, it creates a wrong impression of a very specific function name; the
function name has to be expressive enough even without the module name.
The word Suff may have even be misleading since not all of the functions
in this module affect suffixes, some also simply work on strings.

Module boundaries are marked by function names of the form Module_Func.
Therefore, local function names don't need to start with the module
name.

Rename the FindDeps functions to list their hierarchical position in the
function name, from broad to narrow.
 1.280  21-Nov-2020  rillig make(1): remove redundant null check in SuffFindCmds

Src.suff is never null. It is initialized in the constructor and then
never modified again. It cannot be marked as const though because memory
allocation and initialization are separated in SrcNew.
 1.279  21-Nov-2020  rillig make(1): clean up Suffix_GetSuffix

This eliminates the unspecific variable names p1 and p2 and furthermore
ensures that there is never a pointer that points out of bounds.

The code could have used memcmp or strncmp as well, but since the
suffixes are usuall very short, there is no benefit over a direct loop
comparing individual characters.
 1.278  21-Nov-2020  rillig make(1): fix indentation in SuffixList_Insert
 1.277  21-Nov-2020  rillig make(1): make srclist a local variable

In all current unit tests, the variable srclist was empty both when
entering Suff_FindDeps and when leaving it. Since that's the only
function that used this variable, it has been converted to a local
variable instead, to limit its scope.

To protect against accidental implementation mistakes, an assertion has
been added to ensure that at the end, everything could be cleaned up
properly. This assertion was missing before, and if there had really
been a case where the list were non-empty, make would have resolved
completely wrong candidates for the implied sources.
 1.276  21-Nov-2020  rillig make(1): improve local variable name in SuffRemoveSrc
 1.275  21-Nov-2020  rillig make(1): move prototype of SuffFindDeps further down

Just to limit its scope.
 1.274  21-Nov-2020  rillig make(1): move SuffExpandWildcards further up

This avoids an unnecessary forward declaration.
 1.273  21-Nov-2020  rillig make(1): document Suffix and Src
 1.272  21-Nov-2020  rillig make(1): improve comment for Suffix_GetSuffix
 1.271  21-Nov-2020  rillig make(1): rename Suff functions whose subject is a single suffix

The naming scheme Suffix_Func makes these functions easily
distinguishable from those that merely happen to be in the Suff module
but have nothing to do with suffixes, such as SuffStrIsPrefix.
 1.270  21-Nov-2020  rillig make(1): rename type SuffFlags to SuffixFlags
 1.269  21-Nov-2020  rillig make(1): rename SuffList to SuffixList
 1.268  21-Nov-2020  rillig make(1): rename type Suff to Suffix

This avoids confusion with the module suff.c of the same name.

The existing naming convention is that the module's public functions are
named Suff_Func and its private functions are named SuffFunc. This
collides with the naming convention that a the functions of the type Suff
are called Suff_Func as well.

To resolve this collision, rename Suff to Suffix. The related types like
SuffList and the affected functions like SuffRef will be renamed in a
follow-up commit.
 1.267  21-Nov-2020  rillig make(1): rename suffNull to nullSuff

This variable is internal to the suff.c module, therefore there is no
need to prefix it with the module name. The new name follows the naming
convention established by emptySuff.
 1.266  21-Nov-2020  rillig make(1): improve name of local variable in SrcList_Add

Now that nothing in suff.c is named 's' anymore, there is no need for
's2' either.
 1.265  21-Nov-2020  rillig make(1): rename SuffAddSrc to SrcList_Add

The main character in this function is the list of sources, therefore
make it the subject.
 1.264  21-Nov-2020  rillig make(1): improve parameter name in SuffUpdateTarget
 1.263  21-Nov-2020  rillig make(1): document necessary condition in SuffUpdateTarget
 1.262  21-Nov-2020  rillig make(1): in SuffExpandChildren, only expand ${VAr} if needed
 1.261  21-Nov-2020  rillig make(1): clean up reference counting in SuffList_Insert
 1.260  21-Nov-2020  rillig make(1): move reference counting for suffixes to SrcNew
 1.259  21-Nov-2020  rillig make(1): clean up reference counting for suffixes
 1.258  21-Nov-2020  rillig make(1): add explanation for test suff-rebuild
 1.257  21-Nov-2020  rillig make(1): add more debug logging for suffixes

The "Removing suffix" is not covered by the current tests. It would be
best if that code were unreachable at all, since a reference count of -1
doesn't make sense.
 1.256  21-Nov-2020  rillig make(1): add debug logging when adding a suffix to the global list
 1.255  21-Nov-2020  rillig make(1): rename local variable s to suff

The name s was ambiguous. It could have meant suffix, src, str, and
probably more.
 1.254  21-Nov-2020  rillig make(1): make debug logging more precise in Suff_EndTransform
 1.253  21-Nov-2020  rillig make(1): flatten Suff_EndTransform

This avoids the duplicate code for testing OP_TRANSFORM.
 1.252  21-Nov-2020  rillig make(1): rename SuffScanTargets to SuffUpdateTarget

The word "scan" no longer applies to this function since that is done by
SuffUpdateTargets instead.
 1.251  21-Nov-2020  rillig make(1): clean up parameter names for SuffScanTargets

The prefix "gs" came from a time when SuffScanTargets was called via
Lst_ForEach, passing it a struct GNodeSuff. The "gs" had just been the
abbreviation for "GNode + Suff", which was already non-expressive. On
top of that, the struct had a third field "r", also with an unclear name,
which was not even mentioned in the name of the struct.

For now, just remove the needless prefix since it has absolutely no
meaning anymore. Maybe it will become clear what the "r" was supposed to
mean, it could be some kind of "result".
 1.250  19-Nov-2020  rillig make(1): mark srclist as a bad global variable

The previous comment "List of sources" didn't tell anything about the
purpose of the variable, it was only useful before July 2020, when its
data type was still Lst, without any type information.

Having a global variable here seems pointless, but all the code about
suffix transformations is so tricky and not well covered by tests that I
don't dare to convert the global variable to a local variable in
Suff_FindDeps. The change itself would be trivial, but the hidden and
undocumented intentions of the original author probably aren't.
 1.249  19-Nov-2020  rillig make(1): compare pointers against NULL instead of implicit conversion
 1.248  19-Nov-2020  rillig make(1): fix compilation error in -DDEBUG_SRC mode
 1.247  16-Nov-2020  rillig make(1): rename local functions in suffix handling

Name these functions after their main object, which is the suffix list.
 1.246  16-Nov-2020  rillig make(1): merge duplicate calls to SuffInsert
 1.245  16-Nov-2020  rillig make(1): clean up code style in make.c and suff.c
 1.244  16-Nov-2020  rillig make(1): rename Targ_NewGN to GNode_New

This function is a classical constructor function, and if it weren't for
CLEANUP mode, it would have no dependencies on anything else besides the
memory allocator. Therefore it doesn't really matter which module
defines this function, and there is no need for the "Targ" to be part of
the function name.
 1.243  16-Nov-2020  rillig make(1): inline SUFF_DEBUG3 and SUFF_DEBUG4

Each of them was only used a single time, which was not worth an
additional macro.
 1.242  16-Nov-2020  rillig make(1): clean up coding style in suff.c
 1.241  16-Nov-2020  rillig make(1): improve local variable names in suff.c

The name 's' was used for both 'suff' and 'src', which was unnecessarily
confusing.
 1.240  16-Nov-2020  rillig make(1): remove redundant braces and parentheses from suff.c
 1.239  16-Nov-2020  rillig make(1): use boolean expressions in conditions
 1.238  16-Nov-2020  rillig make(1): clean up comments in suff.c
 1.237  16-Nov-2020  rillig make(1): mark Suff.ref as probably unused
 1.236  15-Nov-2020  rillig make(1): clean up coding style in compat, parse, suff
 1.235  08-Nov-2020  rillig make(1): clean up code related to VarEvalFlags

Mention VARE_WANTRES before VARE_UNDEFERR since the latter depends on
the former.

In ApplyModifier_Assign, VARE_KEEP_DOLLAR doesn't have to be removed
from eflags since ParseModifierPart does this already.

In EvalUndefined, testing for VARE_WANTRES is redundant if VARE_UNDEFERR
is already set.
 1.234  08-Nov-2020  rillig make(1): rename Src.children to numChildren

There are several other types that have a field named 'children' that is
a list. To avoid confusion, rename this one to differentiate them.
 1.233  08-Nov-2020  rillig make(1): clean up local variable names in suffix handling

The file suff.c defines both Src and Suff, which makes the variable name
s ambiguous.

The word 'target' is ambiguous as well since it could mean a GNode or the
target suffix of a transformation. Therefore, make the variable names
longer but more precise.

The comment about the nil return and the beanhead had been outdated
already in 1993. There is no nil return anywhere nearby. The longer
variable names make the rest of the comment redundant.
 1.232  07-Nov-2020  rillig make(1): add pp_skip_hspace to skip horizontal whitespace during parsing
 1.231  05-Nov-2020  rillig make(1): remove redundant parentheses from sizeof operator

The parentheses are only needed if the argument is a type, not an
expression.
 1.230  31-Oct-2020  rillig make(1): do not look up local variables like .TARGET anywhere else

Nobody defines a global variable named .TARGET since that would have
many unpredictable effects, applying to all targets at once.

Nobody defines an environment variable named .TARGET since that's
against the naming conventions for environment variables and would have
the same effect.

Because of this, there is no point looking up the variables that are
local to a GNode anywhere else. This means they cannot come from the
environment and thus their value doesn't need to be freed after use,
which makes the code simpler.

The newly added accessor functions in make.h refer to external
functions, but since that header is not used anywhere outside of
usr.bin/make, it doesn't matter. Between 2020-08-25 and 2020-10-30,
that header had been referenced by usr.bin/xinstall.
 1.229  30-Oct-2020  rillig make(1): change char * to void * in Var_Value

The only purpose of the parameter freeIt is to free the memory
associated with the return value. To do this, no pointer arithmetic is
needed. Therefore, change to a void pointer, to catch accidental use of
that pointer.
 1.228  30-Oct-2020  rillig make(1): fix indentation in source code
 1.227  26-Oct-2020  rillig make(1): convert a few strings to const strings in suff.c
 1.226  25-Oct-2020  rillig make(1): properly terminate debug output with newline

Without this, NetBSD's sed adds the missing newline at the end of the
file, while other sed implementations don't do that.
 1.225  25-Oct-2020  rillig make(1): add GNode_Path to access the path of a GNode
 1.224  25-Oct-2020  rillig make(1): add more details to DEBUG_SRC log
 1.223  25-Oct-2020  rillig make(1): replace Dir_CopyDir with Dir_CopyDirSearchPath

Callback functions for the Lst functions do not belong in the public API
of a module.
 1.222  24-Oct-2020  rillig make(1): remove unused Lst_Find and Lst_FindFrom
 1.221  24-Oct-2020  rillig make(1): don't modify GNode name while rebuilding the suffix graph
 1.220  24-Oct-2020  rillig make(1): improve local variable names in SuffFindThem
 1.219  23-Oct-2020  rillig make(1): improve variable names in SuffRebuildGraph
 1.218  23-Oct-2020  rillig make(1): negate OP_NOP and rename it to GNode_IsTarget
 1.217  22-Oct-2020  rillig make(1): add Lst_ForEachUntilConcurrent

Previously, Lst_ForEachUntil allowed the list to be modified while
iterating. Almost none of the code needs this, and it's also confusing
for human readers.

None of the current unit tests makes use of this concurrent modification
right now, but that's not evidence enough. Only 72% of the code are
covered by unit tests right now, and there are lots of edge cases
(whether intended or not) that are not covered by unit tests.

Therefore, all calls to Lst_ForEachUntil were changed to
Lst_ForEachUntilConcurrent and those that were obvious were changed
back. The remaining calls probably don't need the concurrent
modification code, but that's not obvious from looking at the code.
 1.216  22-Oct-2020  rillig make(1): replace Lst_Open with simple iteration in SuffFindCmds

Again, no concurrent modification nearby.
 1.215  22-Oct-2020  rillig make(1): rename local variables in SuffFindCmds

Several types have fields named "parents" and "children", which makes an
expression like s->children ambiguous.
 1.214  22-Oct-2020  rillig make(1): migrate Lst_Open to simple iteration in SuffRemoveSrc

During the iteration, the list is modified. But after the modification,
the iteration stops by returning, therefore the additional complexity of
Lst_Open is not needed in this case.
 1.213  22-Oct-2020  rillig make(1): remove redundant type casts

This mainly affects the void pointers in callback functions for lists.
These had been necessary once when the parameter type was still
ClientData instead of void pointer.
 1.212  21-Oct-2020  rillig make(1): add suffix number to the debug log

Previously, I had taken that lonely number in the debug log for the
sNum, but it was the reference count.
 1.211  21-Oct-2020  rillig make(1): rename Src.cp to childrenList
 1.210  21-Oct-2020  rillig make(1): replace SuffGNHasName with FindTransformByName
 1.209  21-Oct-2020  rillig make(1): extract code to allocate a Src

Separating this code from the rest of the initialization makes it
obvious that there are inconsistencies in memory handling (owned vs.
shared pointers, reference counts). It also forces a consistent order
of specifying the fields of a Src.
 1.208  21-Oct-2020  rillig make(1): clean up suffix handling code

Using (name, nameLen) is easier to understand than the unusual (nameLen,
nameEnd).
 1.207  21-Oct-2020  rillig make(1): inline struct SuffSuffGetSuffixArgs in suffix search
 1.206  21-Oct-2020  rillig make(1): reduce indentation in SuffFindNormalDepsPath
 1.205  21-Oct-2020  rillig make(1): extract path search from SuffFindNormalDeps
 1.204  21-Oct-2020  rillig make(1): unindent SuffFindNormalDepsUnknown
 1.203  21-Oct-2020  rillig make(1): clean up SuffFindNormalDepsKnown
 1.202  21-Oct-2020  rillig make(1): extract handling of unknown suffix from SuffFindNormalDeps
 1.201  21-Oct-2020  rillig make(1): extract handling of known suffix from SuffFindNormalDeps
 1.200  21-Oct-2020  rillig make(1): merge duplicate code for -DDEBUG_SRC
 1.199  20-Oct-2020  rillig make(1): remove strange off-by-one feature in SuffSuffGetSuffix

The code worked as intended, yet it was strange to modify cp[1] to
temporarily shorten a string. Using cp[0] for this purpose is common
style.
 1.198  20-Oct-2020  rillig make(1): improve debug messages for suff.c

Especially for the null suffix, the previous message was hard to read.
Who would guess that in "inserting (0)", there is an empty string before
the parenthesis? The new format uses quotes to make the suffixes
clearly visible.

While here, improve some local variable names. In a file that defines
both Suff and Src, using s for a variable is just too ambiguous. The
variable name l can easily be confused with a 1, so name it list
instead.
 1.197  20-Oct-2020  rillig make(1): inline SuffSuffIsPrefix into SuffParseTransform
 1.196  20-Oct-2020  rillig make(1): untangle SuffParseTransform

That function was probably not meant to be a brain-twister, but the
convoluted loop combined with Lst_Find/Lst_FindFrom and the deeply
indented second pass for the single suffix made the code harder to
understand than necessary.

No functional change intended, that's why I had to split and enable the
test suffixes.mk first.
 1.195  19-Oct-2020  rillig make(1): inline simple Lst getters

The function call variant takes more screen space than the direct field
access. Having an abstract API is usually a good idea, in this case of
simple read-only member access it makes the code more difficult to read.

LstNode_Set has been kept as a function since it is not a read-only
accessor function.
 1.194  19-Oct-2020  rillig make(1): use consistent formatting for DEBUG_SRC

No trailing whitespace anymore, %p instead of %lx.
 1.193  19-Oct-2020  rillig make(1): remove void pointers from DEBUG_SRC debugging code

This debugging code is completely broken. Part of the output goes to
debug_file, the other part goes to stdout. The spacing in the output is
inconsistent. The printf directives vary between %p and %lx.

All these inconsistencies have already been there in June 2020, before
the big refactoring started.
 1.192  19-Oct-2020  rillig make(1): remove void pointers from SuffRebuildGraph
 1.191  19-Oct-2020  rillig make(1): remove void pointers from suffix debug printing
 1.190  18-Oct-2020  rillig make(1): extract duplicate code from SuffAddSrc into separate function
 1.189  18-Oct-2020  rillig make(1): add tags to enum types

This allows IDEs to offer better type information than "anonymous enum".
 1.188  18-Oct-2020  rillig make(1): improve parameter names for suffix functions

Both gs_gnp and gnp were terrible variable names that didn't give the
slightest clue about the variable's purpose.
 1.187  18-Oct-2020  rillig make(1): extract UpdateTargets from Suff_AddSuffix
 1.186  18-Oct-2020  rillig make(1): inline struct SuffScanTargetsArgs into SuffScanTargets
 1.185  18-Oct-2020  rillig make(1): rename struct GNodeSuff to SuffScanTargetsArgs
 1.184  18-Oct-2020  rillig make(1): inline struct LstSrc into SuffAddSrc

The variable names are still confusing. There was no useful
documentation on the struct, and the code in SuffAddSrc is highly
redundant. Maybe the next few refactorings will shed light on this part
of the code.
 1.183  18-Oct-2020  rillig make(1): remove void pointers from SuffAddSrc
 1.182  18-Oct-2020  rillig make(1): replace Lst_Open with simple iteration in SuffInsert
 1.181  18-Oct-2020  rillig make(1): replace Lst_Open in Suff_DoPaths with simple iteration

Since sufflist is not modified during iteration, there is no need for
the extra complexity of Lst_Open.
 1.180  18-Oct-2020  rillig make(1): rename Lst_Init to Lst_New

For the other types such as HashTable and Buffer, the Init function does
not allocate the memory for the structure itself, it only fills it.
 1.179  17-Oct-2020  rillig make(1): normalize initialization and cleanup of the modules
 1.178  17-Oct-2020  rillig make(1): fix indentation
 1.177  05-Oct-2020  rillig make(1): prepare job.c, main.c, parse.c, suff.c for WARNS=6

In job.c, GCC 5 complains about the macro FILENO that it has type
unsigned int, which is then passed as the argument of dup2, which
expects a simple int. Maybe this workaround from 1995 is not necessary
anymore, or maybe it is but can be restricted to the few affected
platforms.

This leaves meta.c and the filemon files to be converted. I didn't do
them since they are not well covered by the unit tests.
 1.176  05-Oct-2020  rillig make(1): revert previous commit

It had accidentally reverted all the work from the past few days.
 1.175  05-Oct-2020  rillig make(1): fix double-free bug in -DCLEANUP mode (since 2020-10-02)

The bug had been introduced with dir.c 1.155 on 2020-10-02 22:20:25. In
that commit, openDirectories was replaced with a combination of a list
with a hash table, for more efficient lookup by name.

Upon cleanup, OpenDirs_Done is called, which in turn called
Dir_ClearPath. Dir_ClearPath takes full ownership of the given list and
empties it. This was no problem before since afterwards the list was
empty and calling Lst_Free just frees the remaining list pointer.

With OpenDirs, this list was combined with a hash table, and the hash
table contains the list nodes, assuming that the OpenDirs functions have
full ownership of both the list and the hash table. This assumption was
generally correct, except for the one moment during cleanup where full
ownership of the list was passed to Dir_ClearPath, while the hash table
still contained pointers to the (now freed) list nodes. This by itself
was not a problem since the hash table would be freed afterwards. But
as part of Dir_ClearPath, OpenDirs_Remove was called, which looked up
the freed directory by name and now found the freed list node, trying to
free it again. Boom.

Fixed by replacing the call to Dir_ClearPath with code that only frees
the directories, without giving up control over the list.
 1.174  03-Oct-2020  rillig make(1): clean up #include sections
 1.173  28-Sep-2020  rillig make(1): replace += 1 with ++ and -= 1 with --

Just for visual consistency. The generated code stays exactly the same.
 1.172  28-Sep-2020  rillig make(1): make debug logging simpler

This avoids referring to the debug_file variable in many places where
this implementation detail is not necessary.
 1.171  28-Sep-2020  rillig make(1): make debugging code shorter
 1.170  27-Sep-2020  rillig make(1): normalize whitespace in source code

There is no more space tab. Either only tabs or only spaces or tabs
followed by spaces, but not spaces followed by tabs.
 1.169  26-Sep-2020  rillig make(1): inline and remove LstNode_Prev and LstNode_Next

These functions made the code larger than necessary. The prev and next
fields are published intentionally since navigating in a doubly-linked
list is simple to do and there is no need to wrap this in a layer of
function calls, not even syntactically. (On the execution level, the
function calls had been inlined anyway.)
 1.168  26-Sep-2020  rillig make(1): clean up API for finding and creating GNodes

The previous API had complicated rules for the cases in which the single
function returned NULL or what it did. The flags for that function were
confusing since passing TARG_NOHASH would create a new node even though
TARG_CREATE was not included in that bit mask.

Splitting the function into 3 separate functions avoids this confusion.
It also reveals several places where the complicated API led to
unreachable code. Such code has been removed.
 1.167  25-Sep-2020  rillig make(1): declare strings for suff.c constant
 1.166  25-Sep-2020  rillig make(1): in FindSuffByName, return the suffix instead of a list node

None of the callers was interested in the list node.
 1.165  25-Sep-2020  rillig make(1): migrate suff.c from Lst_ForEachUntil to Lst_ForEach
 1.164  25-Sep-2020  rillig make(1): convert int to size_t for string lengths

Just for formal reasons. There is no practical scenario in which any
filename suffix would grow larger than a few kilocharacters.
 1.163  25-Sep-2020  rillig make(1): don't use reserved names in type names
 1.162  25-Sep-2020  rillig make(1): replace Lst_Find with FindSuffByName
 1.161  25-Sep-2020  rillig make(1): add tags to some of the unnamed structs

The tags prevent the structs from accidentally becoming compatible
types.

While here, remove a few typedefs for structs that are single-purpose,
since there is no point in abstracting from the actual representation of
these types.
 1.160  24-Sep-2020  rillig make(1): remove redundant function prototypes in suff.c
 1.159  24-Sep-2020  rillig make(1): rename Lst_ForEach to Lst_ForEachUntil

Since the callback function returns a terminating condition, this is not
really a foreach loop.

Many of the calls to Lst_ForEachUntil don't make use of the terminating
condition, and several don't modify the list structurally, which means
they don't need this complicated implementation.

In a follow-up commit, Lst_ForEach will be added back with a much
simpler implementation that iterates over the list naively, without a
terminating condition and without taking the iteration state from
Lst_Open/Lst_Next/Lst_Close into account. The migration to this simpler
implementation will be done step by step since each callback function
needs to be examined closely.
 1.158  22-Sep-2020  rillig make(1): prepare Var_Subst for proper error handling

Returning a VarParseResult instead of a string makes it possible to let
the error bubble up, until it reaches the main expression.
 1.157  22-Sep-2020  rillig make(1): use fine-grained type names for lists and their nodes

This is only intended to help the human reader. There is no additional
type safety yet.
 1.156  13-Sep-2020  rillig make(1): prepare Var_Parse for proper error handling and reporting

Right now, Var_Parse swallows many errors during parsing and evaluation.
Ideally, these errors should propagate from the deeply nested
expressions where they occur up to the top-level expressions. When such
an error occurs, the depending expressions should not be evaluated any
further. They may still be parsed, but side effects should be
minimized.

The goal is to prevent incomplete expressions like the "xy}" in
moderrs.exp:106 from being evaluated and eventually passed to the shell
for execution. This expression is a left-over from a parse error in the
mod-t-parse target in moderrs.mk:154.

This commit is a first step in analyzing and verifying the current state
of affairs. The modelling in VarParseErrors already looks complicated
but is expected to closely match reality.
 1.155  13-Sep-2020  rillig make(1): clean up RCSID blocks

These blocks mostly consisted of redundant structure, following the same
#ifndef pattern over and over, with only minimal variation.

It's easier to maintain if the common structure is only written once and
encapsulated in a macro.

To avoid "defined but unused" warnings from GCC in the case where
MAKE_NATIVE is not defined, I had to add volatile. Adding
MAKE_ATTR_UNUSED alone would not preserve the rcsid variable in the
resulting binary.
 1.154  13-Sep-2020  rillig make(1): remove #endif comments for very short blocks
 1.153  12-Sep-2020  rillig make(1): reword variable invocation to variable expression

Variables are a passive thing. They cannot be invoked, they can only be
evaluated.
 1.152  12-Sep-2020  rillig make(1): rename Var_ParsePP back to Var_Parse

The migration to the "parsing position" pointer has been done.
 1.151  12-Sep-2020  rillig make(1): fix API for Targ_PrintCmd

The previous API was too low-level and not strictly typed.
 1.150  12-Sep-2020  rillig make(1): fix prototype of Suff_EndTransform
 1.149  12-Sep-2020  rillig make(1): move PrintAddr to where it belongs
 1.148  12-Sep-2020  rillig make(1): fix inconsistent code indentation
 1.147  11-Sep-2020  rillig make(1): rename GNodeSuff.gn to gnp

It was confusing to have a field called "gn" that was not a pointer to a
GNode, but a double-pointer to GNode instead.
 1.146  11-Sep-2020  rillig make(1): replace *a->b with a->b[0]

This allows the code to be read strictly from left to right. In most
places this style was already used.
 1.145  08-Sep-2020  rillig make(1): fix off-by-one error in SuffExpandChildren

In suff.c r1.144 from yesterday, in the line "cp += nested_p - cp", I
accidentally removed the "- 1". Since these "- 1" lines lead to slow
execution, each branch now increments the pointer separately by the
actually needed amount.

Fixing this bug posed way more new questions than it answered, and it
revealed an inconsistency in the parser about how characters are to be
escaped, and missing details in the documentation of Var_Parse, as well
as a parse error that unexpectedly doesn't stop make from continuing.
 1.144  07-Sep-2020  rillig make(1): migrate SuffExpandChildren to Var_ParsePP
 1.143  05-Sep-2020  rillig make(1): remove trailing whitespace in -dg1 debug output
 1.142  31-Aug-2020  rillig make(1): fix compilation for -DNDEBUG and -O3

The -O3 option of GCC 5.5 is unsure about whether s and t are always
defined, since SuffParseTransform only defines them if it returns TRUE.

Therefore assert that it does. When compiled with -NDEBUG, this would
result in an unused variable, therefore use it using the well-known
cast-to-void pattern.
 1.141  31-Aug-2020  rillig make(1): fix unbalanced Lst_Open/Lst_Close in SuffFindCmds

This bug had been there since the initial import of make, on 1993-03-21.
It just never broke the build because of the missing assertion.

https://mail-index.netbsd.org/tech-toolchain/2020/08/30/msg003847.html

The error message "cd: can't cd to include" that I got when I first
applied the fix was unrelated. It was caused by an extra directory
"include" in src/tools/compat that didn't belong there. With that
directory removed, running "./build.sh -j8 tools" succeeds as expected.
 1.140  30-Aug-2020  rillig make(1): add debug macros to suff.c

This reduces the visual space that the debugging statements need.
 1.139  30-Aug-2020  rillig make(1): rename GNode.iParents to implicitParents

The i alone was too ambiguous. It could have meant ignore, implicit,
interactive, and probably many more.
 1.138  30-Aug-2020  rillig make(1): rename Lst_Datum to LstNode_Datum
 1.137  30-Aug-2020  rillig make(1): rename Lst_Memeber to Lst_FindDatum

The new name nicely aligns with Lst_Find and Lst_FindFrom.
 1.136  29-Aug-2020  rillig make(1): trust that Var_Parse never returns NULL

That function is quite long, but all its return paths lead either to the
expanded variable expression, or to var_Error or varNoError.
 1.135  29-Aug-2020  rillig make(1): trust that Var_Subst never returns NULL

It really never does, and it doesn't even report errors. It just
returns the content of the buffer, up to the first parse error.
 1.134  29-Aug-2020  rillig make(1): clean up comments in suff.c, small refactorings

In SuffParseTransform, the parameter names have been renamed to make the
"side effects" comment redundant.

In Suff_AddSuffix and Suff_AddLib, the parameter has been made const.

In SuffRemoveSrc, the unused variable has been removed, and the return
type has been fixed.
 1.133  29-Aug-2020  rillig make(1): add bmake_strsedup for duplicating a substring
 1.132  29-Aug-2020  rillig make(1): merge duplicate code for bmake_strldup
 1.131  29-Aug-2020  rillig make(1): rename LstNode functions to match their type
 1.130  29-Aug-2020  rillig make(1): rename Lst_FindB back to Lst_Find

The migration from "comparison function" to "match function" is done,
the "B" in the names is no longer needed.
 1.129  29-Aug-2020  rillig make(1): migrate remaining Lst_Find to Lst_FindB

While here, rename SuffSuffIsSuffix to SuffSuffGetSuffix since a
function named "is" should return a boolean, not a string pointer.
 1.128  28-Aug-2020  rillig make(1): rename SuffixCmpData to SuffSuffIsSuffixArgs

The new name makes the comment above that struct redundant.
 1.127  28-Aug-2020  rillig make(1): clean up suffix handling
 1.126  28-Aug-2020  rillig make(1): fix assertion failure in suffix handling

Found by running ./build.sh, in the very early stage.
Fixed by restoring the previous behavior of returning NULL for invalid
arguments.
 1.125  28-Aug-2020  rillig make(1): remove trailing 'S' from names of Lst functions

The migration from null-passing Lst functions to argument-checking Lst
functions is completed.

There were 2 surprises: The targets list may be NULL, and in Dir_AddDir,
the path may be NULL. The latter case is especially surprising since
that function turns into an almost-nop in that case. This is another
case where probably 2 independent functions have been squeezed into a
single function. This may be improved in a follow-up commit.

All other lists were fine. They were always defined and thus didn't
need much work.
 1.124  28-Aug-2020  rillig make(1): migrate Lst_Find to Lst_FindS
 1.123  28-Aug-2020  rillig make(1): migrate Lst_First to Lst_FirstS
 1.122  28-Aug-2020  rillig make(1): print suffix flags in the standard way

This changes the output (it is now SUFF_NULL instead of just NULL), and
the order of the flags in the output is reversed.
 1.121  27-Aug-2020  rillig make(1): migrate Lst_IsEmpty to Lst_IsEmptyS
 1.120  27-Aug-2020  rillig make(1): migrate Lst_Last to Lst_LastS
 1.119  27-Aug-2020  rillig make(1): migrate Lst_Succ to Lst_SuccS
 1.118  27-Aug-2020  rillig make(1): migrate Lst_ForEach to Lst_ForEachS

Most lists are always valid. Only the "targets" variable may be null in
some cases, probably.
 1.117  26-Aug-2020  rillig make(1): merge duplicate code for creating a new suffix
 1.116  26-Aug-2020  rillig make(1): add stricter variants for remaining Lst functions

In most cases the Lst functions are only called when the arguments are
indeed valid. It's not guaranteed though, therefore each function call
needs to be analyzed and converted individually.

While here, remove a few statements that were only useful when the Lst
functions handled circular lists.
 1.115  25-Aug-2020  rillig make(1): fix obvious bugs in -DCLEANUP mode

The outdated type name FreeProc had been renamed to LstFreeProc.
Casting the function free to it is not necessary since the type of this
function is already exactly the correct type. Anything else would be
undefined behavior anyway.

The uninitialized sufflist in Suff_ClearSuffixes was ok until now
because the Lst functions had silently skipped any calls with invalid
arguments. This silent skipping is a good argument to have strict
argument validation since it detects these unintended control flows.
 1.114  23-Aug-2020  rillig make(1): reverse order of the Lst_Find parameters

The other callbacks all have (function, param), only the Lst_Find had
(param, function), which was inconsistent.
 1.113  23-Aug-2020  rillig make(1): unroll loop in SuffFindArchiveDeps

The compiler had unrolled this loop anyway, and for humans it is more
readable as well.

The comments "must be first" and "must be second" came from a time when
the variables were stored in a linked list instead of a hash table.
Maybe this "must" was about performance back then. Anyway, the tests
run fine with either order, and there is absolutely no evidence that the
order of these variables could have any effect.
 1.112  22-Aug-2020  rillig make(1): replace Lst_Duplicate with Lst_CopyS

Lst_Duplicate would have passed through any null pointer, which was not
needed for make. It was the last function that used Lst_AtEnd, which in
turn was the last function that used LstInsertAfter. As a result, these
two functions have been removed.
 1.111  22-Aug-2020  rillig make(1): make moving and copying lists simpler

Instead of the two-in-one Lst_Concat, having two separate functions is
easier to understand. There is no need for a long API comment anymore
since the new functions have a single purpose that is accurately
described by their name.

The long comment inside Lst_Concat has been removed since it only
repeated the exact code, only in more words.

The comments in make.c about appending the cohorts had been wrong. They
were not appended but prepended. Once more, the function name expresses
everything that the comment said, making the comment redundant. There
is no need to test whether the cohorts list is empty, doing nothing is
implied by the word All in Lst_PrependAllS.
 1.110  22-Aug-2020  rillig make(1): make Lst_Prev stricter regarding null pointers
 1.109  22-Aug-2020  rillig make(1): clean up headers

Remove redundant headers that are already included by "make.h".
Make <assert.h> available to all compilation units that use "make.h".
 1.108  22-Aug-2020  rillig make(1): convert GNode type constants to enum

This allows debuggers to print symbolic names for the type flags.

The names of these constants need to be revised. These flags probably
started as the 3 dependency operators (:, !, ::), and at that time, the
prefix OP_ made sense. The other flags are not related to the type of
the dependency operator and could have been placed in GNode.flags as
well.
 1.107  22-Aug-2020  rillig make(1): require argument of Lst_Member to be non-null

Since the lists don't contain null pointers, it doesn't make sense to
search for a null pointer. All calls but one already had obviously
non-null arguments. The one remaining call using targ->suff has been
guarded for now.

The code for Lst_Member became much simpler than before. Partly because
the old code had an extra condition for circular lists, which are not
used by make.
 1.106  22-Aug-2020  rillig make(1): replace Lst_Datum with non-null guaranteeing Lst_DatumS
 1.105  22-Aug-2020  rillig make(1): add strict argument checks for Lst_InsertBefore

As with the other modifying operations on lists, the callers already
made sure that the arguments are valid.
 1.104  22-Aug-2020  rillig make(1): convert Lst_Enqueue and Lst_Dequeue to nonnull variants

Except for once instance in parse.c, the usage pattern for Lst_Dequeue
was to first test whether the list is empty. This pattern allowed the
implementation of Lst_Dequeue to become simpler since the null check is
not needed anymore.

The calls to Lst_Enqueue never pass an invalid list or a null pointer,
therefore making them strict was trivial.
 1.103  22-Aug-2020  rillig make(1): convert remaining Lst_AtEnd to the stricter Lst_Append

The general-purpose list library that is included in make allows to call
Lst_AtEnd for invalid lists, silently ignoring this programming error.
This is a flexibility that make doesn't need.

Another unneeded "feature" is that list items can theoretically be null
pointers. This doesn't make sense as well and is therefore not needed
by make.

These programming errors are now caught early by assertions.
 1.102  22-Aug-2020  rillig make(1): replace "(void)Lst_AtEnd" with stricter "Lst_AppendS"

This change ensures that there is actually something added to the list.
Lst_AtEnd had silently skipped the addition if the list was invalid
(null pointer), which was not intended in these cases. The "(void)" is
assumed to mean "I know that this cannot fail", while it could also mean
"I don't care whether something actually happened".

Running "./build.sh -j6 tools" still succeeds after this change,
therefore chances are very low that this change breaks anything. If
there is any change, it's an obvious assertion failure. There is no
silent change in behavior though.
 1.101  22-Aug-2020  rillig make(1): remove form feeds in the code
 1.100  21-Aug-2020  rillig make(1): use stricter list API for sequential access

In several places, it just doesn't make sense to have a null pointer
when a list is expected.

In the existing unit tests, the list passed to Lst_Open is always valid,
but that's not a guarantee for real-world usage. Therefore, Lst_Open
has been left for now, and Lst_OpenS is only the preferred alternative
to it.
 1.99  21-Aug-2020  rillig make(1): assert correct usage of the Lst_Open API

All calls to Lst_Next are properly protected by Lst_Open, so there is no
possible assertion failure here.
 1.98  21-Aug-2020  rillig make(1): make list library code stricter

Up to now, the list library didn't distinguish between programming
mistakes (violations of invariants, illegal parameter values) and
actually interesting situations like "element not found in list".

The current code contains many branches for conditions that are neither
exercised by the unit tests nor by real-world usage. There is no point
in keeping this unnecessary code.

The list functions will be migrated from their lenient variants to the
stricter variants in small parts, each function getting the S suffix
when it is made strict, to avoid any confusion about how strict a
particular function is. When all functions have been migrated, they
will be renamed back to their original names.

While here, the comments of the functions are cleaned up since they
mention irrelevant implementation details in the API comments, as well
as "side effects" that are really main effects.
 1.97  21-Aug-2020  rillig make(1): remove unused code for circular lists

The list library had probably been imported from a general-purpose
library that also supported circular lists. These are not used by make
though.

After replacing Lst_Init(FALSE) with Lst_Init(), only a single call to
Lst_Init remained with a non-constant argument, and that was in
Lst_Concat, which was to be expected.
 1.96  11-Aug-2020  rillig make(1): convert Suff.flags from #define to enum

This increases debugging support since the debugger can now display
symbolic names instead of an integer bit mask.
 1.95  10-Aug-2020  rillig make(1): replace str_concat with str_concat2 and str_concat3

The new functions have a simpler interface, and str_concat3 is even more
general-purpose, since the middle string is no longer required to be
exactly of length 1.
 1.94  10-Aug-2020  rillig make(1): fix parameter name of str_concat

The previous documentation mentioned Str_Concat, but str_concat has been
written in lowercase for years. The "flags" are not flags since they
cannot be combined, not even when they are written in hex.
 1.93  01-Aug-2020  rillig make(1): use consistent indentation in source code

Tabs for multiples of 8, then spaces.

The usage string has been kept as-is since the spaces there are
indentional and do influence the output.
 1.92  01-Aug-2020  rillig make(1): avoid calls to free(3) in the common case of a NULL pointer
 1.91  28-Jul-2020  rillig make(1): remove dead code from Var_Subst

The first parameter from Var_Subst had been a literal NULL in all cases.
These have been fixed using this command:

sed -i 's|Var_Subst(NULL, |Var_Subst(|' *.c

The one remaining case was not found because the "NULL," was followed by
a line break instead of a space.

The removed code probably wouldn't have worked as expected anyway.
Expanding a single variable to a literal string would have led to
unexpected behavior for cases like ${VAR:M${pattern}}, in case pattern
would contain an unescaped ':' itself.
 1.90  26-Jul-2020  rillig make(1): make return value of Var_Parse constant

This return value is not supposed to be modified since it can be a string
literal. The modifiable part is returned via freePtr, but only for
freeing, not for actually modifying anything.
 1.89  19-Jul-2020  rillig make(1): rename Varf_Flags to VarEvalFlags

In var.c there are lots of different flag types. To make any accidental
mixture obvious, each flag group gets its own prefix.

The only flag group that is visible outside of var.c is concerned with
evaluating variables, therefore the "e", which replaces the former "f"
that probably just meant "flag".
 1.88  03-Jul-2020  rillig make(1): remove redundant parentheses around return values
 1.87  02-Jul-2020  rillig make(1): remove useless parameter from Var_Set

The enum corresponding to this int parameter is only defined in var.c,
which makes it impractical for the outside to set this parameter to
anything but 0.

On x86_64, this reduces the size of the resulting executable by 5 kB.
 1.86  16-Apr-2017  riastradh Assert archive member syntax. Cite who guarantees it.
 1.85  16-Apr-2017  riastradh Use, don't kludge, MAKE_ATTR_UNUSED.

CID 1300234
CID 1300237
CID 1300238
CID 1300245
CID 1300255
CID 1300267
CID 1300284
 1.84  30-Jun-2016  dholland branches: 1.84.2; 1.84.4;
Fix DEBUG_SRC build. Partly from PR 51191.
 1.83  30-Jun-2016  dholland Cleanse an old mangy way of avoiding an unused variable warning.
PR 51191 from David Binderman.
 1.82  30-Jun-2016  dholland Fix botched logic; PR 51191 from David Binderman.
 1.81  15-Mar-2016  matthias Another small change to make archive member rules work. With this change
archive member rules seem to work as expected again.
 1.80  15-Mar-2016  matthias dynamic dependencies for library member targets are working again.
 1.79  14-Mar-2016  matthias make $@ an alias for $! in archive member rules (compatibility with
other makes).
 1.78  18-Feb-2016  christos Collapse the 3 boolean parameter to 1 flags parameter. No functional change.
 1.77  17-Jan-2016  christos remove free NULL checks (Tilman Sauerbeck)
 1.76  09-Jan-2016  christos Preserve $$ in := assignments..

FOO=\$$CRAP
BAR:=${FOO}

all:
echo ${FOO}
echo ${BAR}
 1.75  20-Dec-2015  sjg Suff_ClearSuffixes() needs to re-initialize suffNull,
otherwise its children retain old suffixes.
Have Suff_Init() call Suff_ClearSuffixes() for consistency.
 1.74  11-Oct-2015  sjg Add Boolean wantit to Var_Parse and Var_Subst

wantit will be FALSE when we are just consuming to discard
in which case we skip "expensive" things like Cmd_Exec.

Reviewed by: christos
 1.73  07-Sep-2014  joerg Revert all make changes except the unit tests to the state of three
weeks ago. Individual changes can be reapplied after review.
 1.72  27-Aug-2014  christos Make .INVISIBLE nodes be ignored by suffix transformations.
 1.71  23-Aug-2014  christos PR/46096: Jarmo Jaakkola: fix many problems with dependencies (PR 49086)

Quite extensive rewrite of the Suff module. Some ripple effects into
Parse and Targ modules too.

Dependency searches in general were made to honor explicit rules so
implicit and explicit sources are no longer applied on targets that
do not invoke a transformation rule.

Archive member dependency search was rewritten. Explicit rules now
work properly and $(.TARGET) is set correctly. POSIX semantics for
lib(member.o) and .s1.a rules are supported.

.SUFFIXES list maintenance was rewritten so that scanning of existing
rules works when suffixes are added and that clearing the suffix list
removes single suffix rules too. Transformation rule nodes are now
mixed with regular nodes so they are available as regular targets too
if needed (especially after the known suffixes are cleared).

The .NULL target was documented in the manual page, especially to
warn against using it when a single suffix rule would work.
A deprecation warning was also added to the manual and make also
warns the user if it encounters .NULL.

Search for suffix rules no longer allows the explicit dependencies
to override the selected transformation rule. A check is made in
the search that the transformation that would be tried does not
already exist in the chain. This prevents getting stuck in an infinite
loop under specific circumstances. Local variables are now set
before node's children are expanded so dynamic sources work in
multi-stage transformations. Make_HandleUse() no longer expands
the added children for transformation nodes, preventing triple
expansion and allowing the Suff module to properly postpone their
expansion until proper values are set for the local variables.

Directory prefix is no longer removed from $(.PREFIX) if the target
is found via directory search.

The last rule defined is now used instead of the first one (POSIX
requirement) in case a rule is defined multiple times. Everything
defined in the first instance is undone, but things added "globally"
are honored. To implement this, each node tracks attribute bits
which have been set by special targets (global) instead of special
sources (local). They also track dependencies that were added by
a rule with commands (local) instead of rule with no commands (global).

New attribute, OP_FROM_SYS_MK is introduced. It is set on all targets
found in system makefiles so that they are not eligible to become
the main target. We cannot just set OP_NOTMAIN because it is one of
the attributes inherited from transformation and .USE rules and would
make any eligible target that uses a built-in inference rule ineligible.

The $(.IMPSRC) local variable now works like in gmake: it is set to
the first prerequisite for explicit rules. For implicit rules it
is still the implied source.

The manual page is improved regarding the fixed features. Test cases
for the fixed problems are added.

Other improvements in the Suff module include:
- better debug messages for transformation rule search (length of
the chain is now visualized by indentation)
- Suff structures are created, destroyed and moved around by a set
of maintenance functions so their reference counts are easier
to track (this also gets rid of a lot of code duplication)
- some unreasonably long functions were split into smaller ones
- many local variables had their names changed to describe their
purpose instead of their type
 1.70  18-May-2013  sjg We cannot skip all Suff processing for .PHONY targets,
else, srcs which are wildcards do not get expanded as needed.
 1.69  29-Sep-2011  sjg branches: 1.69.2; 1.69.8;
Make sure .PHONY targets get .TARGET set.
This wasn't happening when a dependency of .END.
Set .PREFIX too and add a unit-test.

PR: 43534
 1.68  30-Jun-2011  wiz dependant -> dependent
 1.67  23-Jan-2009  dsl Sprinkle some const.
In particular for Lst_Find() and Lst_FindFrom().
Remove some unneeded casts and some now-undeeded UNCONST().
 1.66  23-Jan-2009  dsl Change 'ClientData' to 'void *' so that relevant parameters can
be made 'const void *'.
 1.65  13-Dec-2008  dsl Use NULL instead of -1 cast to the relavant type (usually via NIL).
This was a suggestion from christos - so blame him if there is a deep
reason for using -1 :-)
 1.64  06-Oct-2008  joerg Don't use emalloc and friends directly, but call them consistently
bmake_malloc and friends. Implement them via macros for the native case
and provide fallback implementations otherwise. Avoid polluting the
namespace by not defining enomem globally. Don't bother to provide
strdup and strndup, they were only used for the estrdup and estrndup
comapt code.

This addresses the presence of emalloc in system libraries on A/UX and
resulted strange issues as reported by Timothy E. Larson.
 1.63  15-Feb-2008  christos back all changes out until I fix it properly.
 1.62  14-Feb-2008  christos - use pid_t/size_t as appropriate instead of int.
- use %ld to print pids.
- fix a bit of lint.
- WARNS=4
 1.61  17-Nov-2006  dsl A rather large rototil in the way the parallel make code schedules jobs.
This gives a considerable speedup in the processing of .WAIT and .ORDER.
Both .WAIT and .ORDER stop both the commands of the node, and its dependant
nodes being built until the LH nodes are complete.
.WAIT only applies to the dependency line on which it appears, whereas
.ORDER applies globally between the two nodes.
In both cases dependant nodes can be built because other targets need them.
make now processes the target list left to right, scheduling child nodes
as they are needed to make other nodes (instead of attempting to generate
a bottom-up dependency graph at the start). This means that 'make -j1'
will tend to build in the same order as a non-parallel make.
Note that:
all: x y
x: a .WAIT b
y: b .WAIT a
does not generate a dependency loop.
But
x: y
.ORDER y x
does (unless something elswhere causes 'y' to be built).
 1.60  11-Nov-2006  dsl Point a few diagnostic printfs (the ones that got away) to debug_file
instead of stdout.
 1.59  27-Oct-2006  dsl Since 'ClientData' is 'void *', nuke almost all the (ClientData) casts.
 1.58  25-Oct-2006  dsl Rename Lst_Append() to Lst_InsertAfter() and Lst_Insert() to Lst_InsertBefore()
to better explain their actions.
 1.57  25-Oct-2006  dsl Fix previous - need to add a lstPrev()
 1.56  25-Oct-2006  dsl Only do dynamic dependecy expansion once, and follow by a single filename
globbing.
The old behaviour was the perform variable expansion and globbing on the
output of both the variable expansion and globbing. Which allows some very
strange behaviour if, for example, globbed filenames contain $ symbols.
Unconditionally add new nodes from these expansions even if the names are
already children. The .WAIT code needs the order of children preserved.
 1.55  15-Oct-2006  dsl Output all debug trace output through 'debug_file' defaulting to 'stdout'.
(Almost all the debug output went there, but some went to stderr.)
Split the parsing of -d (debug flags) out into its own routine.
Allow the output filename to be changed by specifying -dF<file> to create
a log file, or -dF+<file> to append to it. <file> may be stdout or stderr.
Also change so that -d-<flags> acts on <flags> locally but doesn't copy
them to MAKEFLAGS so they aren't inherited by child makes.
I'm not 100% happy with the command line syntax for the above, so they are
currently undocumented.
 1.54  29-Jun-2006  rillig Fixed gcc warnings about signed vs. unsigned in comparisons.
 1.53  31-Mar-2006  christos Add some coverity allocation comments, and change the way the allocator
functions work. When they allocate storage that needs to be freed, instead
of setting a boolean, set the pointer to be freed. Plug some more memory
leaks found by inspection.
 1.52  08-Jan-2006  dsl Don't (try to) use files marked .OPTIONAL as implicit sources.
There existance hasn't been verified at the point the implicit rules are
checked.
 1.51  08-Aug-2005  christos From Max Okumoto:
- Remove casts to NULL.
- Remove space between cast and object.
 1.50  05-Aug-2005  christos More KNF cleanups from Max Okumoto
 1.49  25-Jul-2005  christos Whitespace KNF cleanup from Max Okumoto
 1.48  16-Feb-2005  christos PR/29203, PR/29204: Max Okumoto: KNF changes to make [no functional changes]
 1.47  29-Dec-2004  christos Add comments in the pmake style, and factor out a local variable.
No functional change.
 1.46  29-Dec-2004  christos Dir_MTime did not search for a file using the correct parh; i.e. it was
ignoring suffix-specific path search. So if a node was marked .MADE,
then suffix rules would not be applied to it, and we would look for
the file only in the default path, not the suffix-specific path.

XXX: Now that we looked for the suffix, we can save it in the GNode,
but we don't do this yet.
 1.45  07-May-2004  ross Simplify build, no functional changes.

Instead of adding MAKE_BOOTSTRAP for hosted environments, i.e., when
you want things simple, instead add MAKE_NATIVE to get those hugely
important features like __RCSID().

It's now possible to build make on some hosts with: cc *.c */*.c
 1.44  13-Feb-2004  wiz branches: 1.44.2;
Spell the plural of suffix "suffixes", not "suffices".
Inspired by PR 24400 by Todd Vierling.
 1.43  11-Jan-2004  dsl Reindent search loop in SuffFindCmds using 'continue' and 'break' instead
of netsted ifs. No logic change.
 1.42  07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22365, verified by myself.
 1.41  14-Jul-2003  christos Pass WARNS=3
 1.40  05-Dec-2002  scw Lst exp -> Lst explist, to avoid warnings about gcc-current's
builtin exp() function.
 1.39  15-Jun-2002  wiz Remove !__STDC__ stuff, de-__P(), ANSIfy, and de-register.
 1.38  04-Feb-2002  christos branches: 1.38.2;
Remove OP_NOSUFF, fix OP_MADE in compat mode [from pk], and make the OP_MADE
comment reflect reality.
 1.37  03-Feb-2002  christos Bring down the number of stat(2) system calls from 682 to 294. This change
adds a .NOSUFF directive that has been applied to targets that have been
already made, and are not supposed to have suffix rules applied to them.
 1.36  27-Jan-2002  reinoud Fix major bug in make(1) ... due to shadowing of the dotLast path used for
the .DOTLAST primitive by a boolean variable with the same name, this whole
mechanism was broken ... it doesn't save much stat calls but it was wrong.

Thanks to Jason Thorpe for the other shadow-variable fixing patches he
made.
 1.35  14-Nov-2001  tv Fix a very old and annoying bug: Adding suffixes to sufflist wasn't setting
a refCount of 1 to indicate its presence on sufflist. Hence suffixes were
being removed by Suff_EndTransform() and being freed before all the
referential links were removed. This resulted in a malloc warning on 1.5.x:
make in free(): warning: chunk is already free.

This could be reproduced with the following simple Makefile passed to
"make -r":
=====
.SUFFIXES: .l .c
.l.c:
foo:
 1.34  20-Aug-2001  wiz precede, not preceed.
 1.33  12-Jun-2001  sjg Add 4th arg (flags) to Var_Set so that VarLoopExpand can tell it not
to export interator variables when using context VAR_CMD.

Reviewed: christos
 1.32  08-May-2001  aymeric Fix core dump triggered by a .DEFAULT target with no commands.
Bug reported privately by Nicolas Ollinger <nollinge@ens-lyon.fr>.

You can trigger this bug prior to updating your sources with for example:
% cat > Makefile <<EOF
.DEFAULT:
a
EOF
% make
 1.31  11-Jun-2000  mycroft Readd optimization last night. Problems earlier were partially due to the
arguments names on one function being swapped (by a previous author).

Do not do any duplicate suppression when a source list is created. Instead:
* OP_MADE protects against trying to make the source multiple times.
* A new OP_MARK flag is introduced to suppress duplicates while expanding
the .ALLSRC variable and .USE targets.
This turns the O(n^2) insertion into O(n) in most cases.

This is tested with a `make build' and some special test cases.
 1.30  10-Jun-2000  mycroft Back out last night's optimization for now.
 1.29  10-Jun-2000  mycroft Introduce an OP_MARK bit, and use it to suppress duplicates during .ALLSRC
and .USE expansion. Also, remove some more Lst_Member() checks that are now
redundant.
 1.28  22-Jan-2000  mycroft branches: 1.28.2;
Don't apply suffix rules for .PHONY targets. (gmake doesn't do this either.)
 1.27  16-Sep-1999  mycroft Some minor cleanup of :: tests.
 1.26  15-Sep-1999  mycroft Rework how :: dependencies are handled.
Build a list of `cohorts' as before, but do *not* link each one into all the
parent nodes; instead, copy the `cohort' lists into the stream of targets to
be built inside Make_ExpandUse(). Also do the attribute propagation as a
separate pass after parsing.
This eliminates several O(n^2) algorithms.
 1.25  15-Sep-1999  mycroft Don't bother iterating through all the data structures to free(3) everything
right before exiting.
(The code is still present, `#ifdef CLEANUP', in case someone needs it...)
 1.24  15-Sep-1999  mycroft Avoid using Lst_Member() in SuffExpandChildren(), by avoiding Lst_ForEach() and
passing in the LstNode of the child being inspected. Shaves off another few %,
particularly when there are long child lists containing $ expansions (e.g. in
libc).
 1.23  01-Nov-1998  itohy Reduced memory leaks.
I found some more leaks, but are not in inside of iterations.
 1.22  01-Nov-1998  itohy If the target name is shorter than the suffix,
the previous garbage bytes may be read.
Example: "make n" --- target = n, suffix = .ln

Changing interface of SuffSuffIsSuffix() is required to fix this bug.
 1.21  18-Sep-1998  christos PR/6162: Greg A. Woods: pmake does not add suffix rules if gnodes have children.
This is traditional make behavior (Solaris make does the same), but
GNU does not. Lets see what breaks.
 1.20  04-Jul-1998  christos Fix access to freed memory; pointed out by Todd Miller.
 1.19  02-Jul-1998  christos PR/5690: Wolfgang Rupprecht: deleting a suffix that has 0 source references
causes core-dump. Fix: when an unused suffix gets removed, delete
it from the suffix list.
 1.18  28-Sep-1997  lukem wrap #include <sys/cdefs.h>, __RCSID(...) stuff in #ifndef MAKE_BOOTSTRAP
 1.17  01-Jul-1997  christos Add WARNS=1
RCSID police
 1.16  08-May-1997  gwr Add the new .NOPATH feature which can be used to disable .PATH search
for particular targets, i.e. .depend, objects, etc. (from Christos).
 1.15  06-May-1997  mycroft Don't do a suffix search for a .PHONY target.
 1.14  02-May-1997  christos - Target searching addition:
Make used to only use the search path for nodes that were pure
sources (not targets of other sources). This has been corrected
and now gnu-autoconf generated Makefiles work in directories other
than the source one.

- Suffix transformation rescanning:
Suffix transformations (.c.o:; cc ...) were only recognized in
the past when both suffixes were members of the suffix list.
Thus a sequence like:
.z.b:
echo ${.TARGET}
.SUFFIXES: .z
would cause .z.b: to be inserted as a regular target (and the main
target in this case). Other make programs always add rules that
start with a period in the transformation list and never consider
them as targets. We cannot do that (consider .depend files) so we
resort to scanning the list of the current targets every time a
suffix gets added, and we mutate existing targets that are now
valid transformation rules into transformation rules. If the
transformed target was also the main target, we set the main target
to be the next target in the targets list.
 1.13  06-Nov-1996  christos - Merge in FreeBSD and Lite2 changes.
- Fix bug where a non-archive target with a .a suffix would always
be considered to be out of date, since it does not have a TOC.
 1.12  13-Aug-1996  christos Add estrdup(), a checked version of strdup and use it.
 1.11  02-Nov-1995  christos branches: 1.11.4;
Minor:
- ${.PREFIX} should never contain a full pathname
- Fixed gcc -Wall warnings
Major:
- compatMake is now FALSE. This means that we are now running in
full pmake mode:
* rules on dependency lines can be executed in parallel and or
out of sequence:

foo: bar baz

can fire the rule for baz before the rule for bar is fired.
To enforce bar to be fired before baz, another rule needs to be
added. [bar: baz]
* adjacent shell commands in a target are now executed by a single
invocation of the shell, not one invocation of the shell per line
(compatMake can be turned off using the -B flag)
- The -j flag now works... I.e. make -j 4 will fork up to four jobs in
parallel when it can. The target name is printed before each burst
of output caused by the target execution as '--- target ---', when j > 1
- I have changed all the Makefiles so that they work with make -j N, and
I have tested the whole netbsd by:
'make -j 4 cleandir; make -j 4 depend; make -j 4; make -j 4 install'
- I have not compiled or tested this version of make with -DREMOTE.
 1.10  25-Sep-1995  christos Revert previous suffix fix. If the .a suffix is present and a .c.a rule is
there, then the rule should be applied. This is the correct behavior.
 1.9  22-Sep-1995  christos Don't apply the default suffix rules for nodes that are not in our
current directory because we could be building things outside our
directory that were not meant to be build... Fixes PR/1488
 1.8  14-Jun-1995  christos - $NetBSD$ rcsids
- Fixed so that .[A-Z]* targets that do not match keywords are ignored as
Posix mandates
- Added .PHONY target keyword
 1.7  04-Feb-1995  christos str.c: Don't free NULL; does not work with non posix frees.
var.c: Minor memory leak plugged.
suff.c: Don't add extra sources on the null suffix if it has dependency
lines or commands attached to it [POSIX says so]
 1.6  06-Jun-1994  jtc Fixes from Christos Zoulas, who used purify, objectcenter and testcenter
to find memory leaks and illegal memory accesses.
 1.5  23-Mar-1994  jtc Fixes from Christos Zoulas:
The following two patches fix a couple of problems with make(1)

1. Null Suffixes were not being copied, but they were being free'd
This caused rules of the form:

.c:
${CC} ...

to access invalid memory and potentially core dump..
[That was always broken; I did not break that one :-)]

2. My recent fixes to parse ${VAR:%.foo=%.bar} handled the null string
case incorrectly (${VAR:=.c} was broken).
 1.4  05-Mar-1994  cgd fixes/improvements from Christos Zoulas <christos@deshaw.com>.
 1.3  13-Jan-1994  jtc Include appropriate header files to bring prototypes into scope.
 1.2  01-Aug-1993  mycroft Add RCS identifiers.
 1.1  21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2  28-Dec-1996  tls Import 4.4BSD-Lite2 sources onto CSRG branch (already merged at head)
 1.1.1.1  21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.11.4.1  26-Jan-1997  rat Update make(1) from trunk, by request from Christos Zoulas. Fixes many bugs.
 1.28.2.1  23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.38.2.1  23-Jul-2004  tron Apply patch (requested by dbj in ticket 1724):
Fix problems when building the netbsd-1-6 branch with GCC 3.3.3.
 1.44.2.1  10-May-2004  tron Pull up revision 1.45 (requested by sjg in ticket #282):
Simplify build, no functional changes.
Instead of adding MAKE_BOOTSTRAP for hosted environments, i.e., when
you want things simple, instead add MAKE_NATIVE to get those hugely
important features like __RCSID().
It's now possible to build make on some hosts with: cc *.c */*.c
 1.69.8.1  23-Jun-2013  tls resync from head
 1.69.2.1  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.84.4.1  21-Apr-2017  bouyer Sync with HEAD
 1.84.2.1  26-Apr-2017  pgoyette Sync with HEAD

RSS XML Feed