from the .MAKEFLAGS global variable even if it's empty or
unset. This means setting MAKEFLAGS to just an empty string
in the latter case.
If not doing so, make(1) behaved inconsistently WRT MAKEFLAGS.
In particular, it would let a `-f foo' option down to sub-makes
if .MAKEFLAGS was unset. E.g.,
env MAKEFLAGS="-f mymakefile" make
would pass `-f mymakefile' down to sub-makes via their environment
(unless mymakefile added something to .MAKEFLAGS).
But any additional options appearing would change this behaviour to
not passing `-f mymakefile' to sub-makes, as in:
env MAKEFLAGS="-f mymakefile" make -D DUMMY
or
env MAKEFLAGS="-f mymakefile -D DUMMY" make
(unless mymakefile cleared .MAKEFLAGS).
Also make(1) would leave MAKEFLAGS at its initial value if the
makefile set .MAKEFLAGS to an empty value. I.e., it was impossible
to override MAKEFLAGS with an empty value. (Note well that makefiles
are not to touch MAKEFLAGS directly, they alter .MAKEFLAGS instead.
So make(1) can filter out things such as -f when copying MAKEFLAGS
to .MAKEFLAGS at startup. Direct modifications to MAKEFLAGS just go
nowhere.)
While the original intentions of the BSD make authors are somewhat
unclear here, the bug proves that NOT passing -f options down is
the settled behaviour because the opposite behaviour is totally
unreliable in the presence of any other options. In addition, not
passing down -f's found in the environment is consistent with doing
so WRT the command line.
Update the manpage accordingly and make the whole description of
MAKEFLAGS and .MAKEFLAGS more consistent as this change indeed
brings more consistency into the reliable behaviour of make(1).
Submitted by: ru (main.c)
Tested with: make world
explicitly rather than relying on name space pollution to pull it in
for us.
NB: The usage of INT_MIN is somewhat bogus and suspect to my eye, but this
commit doesn't address that issue.
The most important point is that -f option(s) are never copied from
.Ev MAKEFILE to .Va .MAKEFILE by make(1), which is consistent with
handling the command line. (-f silently sit in .Ev MAKEFILE and go
to make's children unless overwritten via .Va .MAKEFILE)
Bump .Dd.
This fixes infinite restart in the following case:
Makefile: foo
foo: bar
do-something
Unlike GNU make, BSD make considers "Makefile" node as remade even
if "foo" is up-to-date and was not actually rebuilt.
GNU make does not consider nodes without commands as remade if child nodes
were not actually rebuilt.
Most probably, more proper fix would be to bring BSD make behaviour in-line
with GNU make but this would be more intrusive change.
After reading Makefile and all the files that are included using .include
or .sinclude directives (source Makefiles) make considers each source
Makefile as a target and tries to rebuild it. Both explicit and implicit
rules are checked and all source Makefiles are updated if necessary. If
any of the source Makefiles were rebuilt, make restarts from clean state.
To prevent infinite loops the following source Makefile targets are
ignored:
- :: targets that have no prerequisites but have commands
- ! targets
- targets that have .PHONY or .EXEC attributes
- targets without prerequisites and without commands
When remaking a source Makefile options -t (touch target), -q (query
mode), and -n (no exec) do not take effect, unless source Makefile is
specified explicitly as a target in make command line.
Additionally, system makefiles and .depend are not considered as a
Makefiles that can be rebuilt.
Reviewed by: harti
error return from open(2), leading to an erroneous value of maxJobs and
a hung make when -f is standard input and -j is used.
PR: bin/101232
Submitted by: Nate Eldredge <nge@cs.hmc.edu>
looked for in the system make file directory or in the specified
-m paths instead of always looking in the other -I and .PATH
specified paths. (Commit log shamelessly stolen from NetBSD.)
Reviewed by: yar
commands for this target are appended to the .END target instead
of beeing executed now. They are executed when the graph is finished.
There was a bug with executing the .END target which came in when
doing conversion to LST_FOREACH() which caused make to dump core.
PR: bin/83698
Submitted by: Max Okumoto <okumoto@ucsd.edu>
MFC after: 3 days
the string. Until now this caused no harm, because the buffer code used
to tack two NULs onto buffers. With the new, soon to come, parsing code
this isn't the case anymore in all cases, so fix this.
rename the function to be consistent with the naming scheme in the rest
of make. No functional changes.
Obtained from: DragonFlyBSD (idea and most of shell.h)
before executing the shell. Until now this was done when the default
shell was the ksh. This failed if the default shell was sh or csh and
the user switched to ksh.
set the current shell to DEFSHELL. Put all these specifications into
a list. Add user specified new shells to this list. If the user
just selects one of the already know shells just pick the right one
off the list. This let's one do something like:
# Full specification of the user's shell. This also selects the shell.
.SHELL: name=myshell path=/somewhere/foo echo=loud ...
FOO != bar # use myshell here
.SHELL: name=sh
BAR != baz # use /bin/sh here
.SHELL: name=myshell # no need for full spec here.
# continue to use the user's special shell.
the list of shell builtins. Both of these are needed for the compat
mode where make directly executes commands if the command line contains
neither a shell meta character nor a shell builtin. The list of builtins
is not changed, but csh has '@' added as a meta-character.
Initialize the default shell by parsing a string as one would specify
to the .SHELL target. So we get rid of the CShell clone of struct Shell which
just contained const char * where struct Shell had char *.
Add a debugging function for dumping a parsed shell description to
stdout.
introduce a struct that holds all the information about an argument
vector and pass that around.
Author: Max Okumoto <okumoto@ucsd.edu>
Obtained from: DragonFlyBSD
Make sure we don't end up with shellPath beeing non-zero, but shellName
beeing zero in the error case - back out cleanly from the error.
When executing a command for macro assignment in Cmd_Exec() stuff the
path of the shell into argv[0], not the name. This makes no difference
from the functionality point of view, but allows the regression tests to
determine whether make executes the correct shell.
used so there is no need to stuff the value of .MAKE into it,
which btw isn't set for quite a while already.
Submitted by: Max Okumoto <okumoto@ucsd.edu> (7.239)
into job.c. Move retrieving of environment nearer to the place where it
is actually used and invert the preprocessor conditionals to use
positive logic.
Submitted by: Max Okumoto <okumoto@ucsd.edu> (7.236)
been two maxJobs variables: one static in job.c and one global used in
main.c and parse.c. Makeing one global out of these was the wrong way
to fix the problem. Instead rename the global one to jobLimit and keep
maxJobs static in job.c.
Suggested by: rwatson
PR: bin/72510
takes place in the child process in a function ProcExec(). Make sure,
that the child does not call malloc() or other potential dangerous
functions (there are still calls to Punt() in the error case that
should go away). Allocate the argv string via malloc to overcome
the non-constness bug of the execvp prototype. Change the handling of
shell meta-characters and move the builtin list near the list of shell
builtins. Both of these lists should actuall be configurable by the .SHELL
target since they depend on the shell used.
Patch: 7.21[2-9], 7.22[0-46]
Submitted by: Max Okumoto <okumoto@ucsd.edu>
where they actually belong to. Move the definitions of the strings
for special macros like "$*" from make.h to parse.h - they're used
only in the parser.
Submitted by: Max Okumoto <okumoto@ucsd.edu> (7.211)