Commit Graph

852 Commits

Author SHA1 Message Date
sjg 7ab69f08a8 Indicate which modifier a result applies to, helps debug complex cases. 2006-07-28 17:08:55 +00:00
sjg ba9f975490 Add debug output for CondDoExists() - the results can be surprising. 2006-07-28 17:07:33 +00:00
sjg 772ecb66aa Fix minor mem leak in PrintOnError(). 2006-07-28 17:06:14 +00:00
rillig 9edce8b593 Fixed gcc warnings about signed vs. unsigned in comparisons. 2006-06-29 22:02:06 +00:00
rillig a3ea8b9d59 Fixed the bug reported in PR 33866, which is that the :Q operator does not
handle newlines correctly. Ok'ed by christos.
2006-06-29 22:01:17 +00:00
reed c5f16e7060 Fix mispelling. 2006-06-17 02:06:17 +00:00
skrll f1713aebe3 Remove a hack that's no longer needed with gcc 3.3.6. 2006-06-15 10:55:02 +00:00
christos 236f8aef2c Coverity CI D3758: Plug memory leak. 2006-05-19 17:29:01 +00:00
christos 19d4b5c5e9 Coverity CID 3757: Plug memory leak. 2006-05-19 17:27:06 +00:00
christos ffbb87954b Coverity CID 3147: Plug memory leak. 2006-05-19 17:21:46 +00:00
sjg fc23c7c758 Remove the modterm case from moderrs, the syntax errors
generated by /bin/sh on other systems are not consistent.
2006-05-11 18:48:33 +00:00
sjg 03cbcf6532 Extract the variable modifier logic to a separate function.
This cuts Var_Parse in half! and allows the modifier logic to
be used recursively - when getting modifiers via variables.

Add new unit-test, to check that certain error cases are handled
correctly.
2006-05-11 15:37:07 +00:00
he b28792d8d4 Our gcc 3.3.3 (nb3) for hppa gets an "unrecognized insn" internal
compiler error when building buf.c with -O2, so reduce optimization
level to -O1 for this single file.
To be documented in docs/HACKS, discussed with skrll.
2006-05-08 11:07:57 +00:00
christos 3d5b8ce5a8 Coverity CID 529: Call VarFreeEnv to prevent leak. 2006-04-22 19:40:40 +00:00
christos ac5c384e1b Coverity CID 534: Free junk variables on return from Var_Parse. 2006-04-22 19:32:35 +00:00
christos bb46846e03 Coverity CID 533: Plug memory leak.
Add a new function VarFreeEnv() to free environment variables and use it.
2006-04-22 19:28:51 +00:00
christos 58c48be0b3 Coverity CID 526: Check for condTop < 0 where we decrement it, not later
when the damage is already done.
2006-04-22 18:53:32 +00:00
christos 1c603f6321 Coverity CID 527: Make it painfully obvious that av is freed. 2006-04-22 18:48:46 +00:00
christos 0f515a9e28 Coverity CID 528: Avoid NULL deref. 2006-04-22 18:47:10 +00:00
christos f2f8f4c25a Coverity CID 530: Don't leak the argument vector. 2006-04-22 18:43:06 +00:00
christos 1456136e74 Coverity CID 523: Fix off by one mistake. 2006-04-22 18:38:38 +00:00
sjg d7df397808 Change ReadMakefile to return 0 on success so that it better meets
the expectations of Lst_Find*.  This way we only read the first sys.mk
found via sysIncPath.
At the same time we need to add a ReadAllMakefiles() for the case
where multiple -f makefile args are provided (uncommon, but documented).
2006-04-12 20:32:27 +00:00
christos 8533275dab Remove bogus debugging code I accidentally committed. 2006-04-02 00:15:53 +00:00
christos e052a053e4 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.
2006-03-31 21:58:08 +00:00
dsl 33369a0245 There is no need to count jobs and job tokens.
If we don't create the job pipe, use the '-j n' option to limit the number
of tokens we will remove from the pipe.
2006-03-31 21:05:34 +00:00
christos ec5cc02622 Coverity CID 544: Fix memory leak. 2006-03-31 20:30:46 +00:00
ginsbach a8cd0ffcee - Change where variable substitution is done when processing traditional
include statements so that if a variable expands to more than one file
  name make will "do the right thing".
- Add additional debug print

Reviewed by christos.
2006-03-28 17:41:35 +00:00
wiz 59ba5fe8d1 New sentence, new line. 2006-03-19 10:45:03 +00:00
sjg 98b766c482 Fix :P modifier so it actually works as described.
I.e ${var.c:P} should expand to the absolute path of var.c found via .PATH
2006-03-19 01:54:21 +00:00
sjg 8af5ec82ab Document an interesting kwirk in := handling of undefined variables. 2006-03-19 01:53:01 +00:00
christos 75f03570ec Coverity CID 2719: argvalue can be NULL when passed into functions.
De-obfuscate by undefining optarg, and check explicitly for NULL before
use.
2006-03-17 15:39:44 +00:00
dsl 5f31eae781 nJobs and jobTokensRunning are both counting the same thing.
Kill nJobs and just use the count of tokens in use.
Don't eat job tokens when we are ignoring errors.
2006-03-15 20:33:19 +00:00
dsl f26d89e3d9 JOB_FIRST is always set (since we only execute the shell once for every
target). Nuke it.
2006-03-13 20:35:09 +00:00
dsl b85c051fa8 Remove the 'never non-NULL' 'previous' argument to JobStart.
Looks like it was intended as a minor (and pointless) optimisation to
remove a free() malloc() pair.
Make he comment about the stoppedJobs list more correct.
2006-03-12 20:14:56 +00:00
dsl a484dfd693 It isn't possibly to execute any part of job.c that references compatMake
when it is 'true'.  So delete the unexecutable code.
2006-03-12 19:14:51 +00:00
dsl c9b3912b1e Remove most of the code seemed to be there to support 'remote jobs'.
It isn't clear that it ever worked, if it did it has almost certainly
bitrotted in the last 12 years.  I'm not even sure all the required
components were present.
I suspect it was written to attempt to use a 'farm' of diskless sun3s.
In any case the apparant random assignment fo jobs to other systems doesn't
actually seem like a good idea!
Things like 'distcc' han be used to help slow systems run native builds.
Removing this code also simplifies make, and should let me speed up some of
its processing - without worrying about bitrotting it further.
2006-03-11 17:18:00 +00:00
wiz 904496fbc8 Markup fixes. 2006-03-11 12:02:20 +00:00
christos 5e6b1075e2 PR/33049: OKANO Takayoshi: Fix the spelling of NetBSD RCS tags. 2006-03-10 15:53:55 +00:00
dsl 5e60bf00ce Avoid calling JobRestartJobs() from the SIGCONT signal handler, instead
push a byte through the (now badly named) exit_pipe and call JobRestartJobs()
from the main code path when poll() wakes up.
Part of a plan to remove JobSigLock() and the zillions of system calls
it does.
2006-03-08 22:11:48 +00:00
apb f34c12e989 Make ".WAIT" apply recursively to all children of nodes on the right
hand side of the .WAIT, except when the recursive interpretation would
cause a cycle in the dependency graph.

Discussed in tech-toolchain.  Reviewed by christos, sjg.
2006-02-26 22:45:46 +00:00
wiz 3ea7f78b57 Fix typo. 2006-02-26 22:40:50 +00:00
sjg 701c9d99a7 Using ./bin in the test case, causes problems when 'make test' is
run from 'unit-tests' rather than the parent dir.
2006-02-26 22:20:55 +00:00
sjg 2bc18a45e6 Update man page and add test case for specifying modifiers via variable.
Also allow said variable to appear anywhere in the modifier list.
2006-02-26 21:43:00 +00:00
tsutsui 8c30474280 Don't use data in freed stack. 2006-02-18 04:10:05 +00:00
sjg 051abc7bc4 Allow variable modifiers to be specified via variable. 2006-02-18 01:29:27 +00:00
sjg 555fff313b Fix enum for better portability 2006-02-18 01:28:48 +00:00
apb c5bdb87cca Escape dots in sed regexps. Without this patch, and without
an OBJDIR, "make test" in usr.bin/make fails.
2006-02-13 18:17:36 +00:00
dsl 2bfcea2ea3 Add some more debug prints. 2006-02-11 20:59:49 +00:00
dsl e99202b6cf Actually SIG_DFL the correct signal (not SIGINT every time) just prior to
exec'ing a program in the child.
2006-02-11 20:58:53 +00:00
dsl 26ed52262a Delete obsolete static defn.
Trace number of unmade children on pass 1
2006-02-11 20:19:36 +00:00
dsl 49c83bef6a Debug trace all the targets we are actually intending making.
De-optimise the getting of a job token so we don't re-order the job
list when there are no tokens.
This might have helped etc/Makefile, but isn't enough.
2006-02-11 18:37:36 +00:00
dsl de841c2752 Make .NOTPARALLEL stop the job engine issuing more than one token (instead
of trying to de-jobify the make.
You can now put .NOTPARALLEL in a submake of a recursive make (where it is
using a job-token pipe from the outer make and have it only run a single job.
You can also specify .NOTPARRALEL in the root makefile of a large recursive
make and have the submakes run multiple commands.
Add some diagnostics printfs (enabled with -dp) to the parser.
2006-01-22 19:54:55 +00:00
dsl 363c3a143d Check the 'job_pipe' for the error token 'E' before every job, including
the first one for each make.  This significantly speeds up the detection
of errors in other branches of the make (ie those running in a different
make process).  The cost of reading and writing a byte from the pipe
should be insignificant.
Defer replacing job tokens until we've decided there is an error.
If we detect an error in another branch of the make, then call Fatal(),
setting 'aborting' and failing to return a token leads to infinite loops.
Now parallel makes actually stop with the failing command on the screen.
2006-01-21 19:18:37 +00:00
dsl 8cc9d75901 Include the 'preds' and 'successors' in the diag output.
These are the values that are actually used to control what is built.
(I suspect .WAIT info added in the previous delta isn't always useful.)
2006-01-08 17:43:31 +00:00
dsl 07c6949e33 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.
2006-01-08 12:59:52 +00:00
dsl 94a49912ba Include .WAIT in the debug output for dependency lists. 2006-01-08 11:54:13 +00:00
dsl 913c34c213 Expunge last references to jobTokensFree 2006-01-04 21:35:44 +00:00
dsl 1f61a1399d When a parallel make job completes, always put the job token back into the
job_pipe and collect another one for the next job.
If we are aborting, remove all the 'normal' job tokens and add an 'error' one.
If we get an 'error' token, remove any other tokens, re-insert the error
token and exit (with error 'cos that is easier).
Add the current pid to some of the DEBUG(JOB) traces.
Combined effect is that parallel makes actually stop some fairly shortly
after an error, rather than running on long enough to fill the scrollback.
2006-01-04 21:31:55 +00:00
dsl 261501b75e F_DUPFD the job_pipe fds onto higher numbers (>15) to make it less likely
that they will get closed in a complex recursive parallel make.
2006-01-04 21:25:03 +00:00
dsl 68ab653c0c For parallel makes, don't recycle the job token when we decide not to
run anything.
2006-01-04 21:16:53 +00:00
dsl 12dafa0b4a If -s (silent) is specified, don't output the target name before target
output in parallel makes.
After all with -s you wouldn't know the command for a non-parallel make.
Makes (sic) the output of parallel NetBSD build fathomable.
2006-01-04 20:56:05 +00:00
perry 0f0296d88a Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete. 2005-12-24 20:45:08 +00:00
christos efc9df200f PR/31077: Wil L: /usr/bin/make can read off of end of buffer 2005-08-27 08:04:26 +00:00
christos abefed98a7 Add typedefs for DuplicateProc and FreeProc from Max Okumoto. 2005-08-09 21:36:42 +00:00
christos 81b135acdf From Max Okumoto:
- Remove casts to NULL.
- Remove space between cast and object.
2005-08-08 16:42:54 +00:00
christos 6240774069 More KNF cleanups from Max Okumoto 2005-08-05 00:53:18 +00:00
christos 9f80093159 remove unnecessary casts to void * functions (Max Okumoto) 2005-08-04 00:20:12 +00:00
christos 62a6753895 from Max Okumoto: debug should be int, not boolean. 2005-08-03 20:55:01 +00:00
christos b3350d3e14 Remove unused files. From Max Okumoto. 2005-07-30 00:49:13 +00:00
christos 3692d77541 Whitespace KNF cleanup from Max Okumoto 2005-07-25 22:55:58 +00:00
sjg c3c1fc597e Expected results were not updated for comment testing. 2005-07-11 17:55:19 +00:00
christos 3d520edd5e PR/29985: Roland Illig: make(1) interprets backslash wrongly in for
loop expansions, when the expanded variable ends in backslash and
the backslash is the last character on the line. While this fix is
ugly (detect the condition and append a space), it is the least
intrusive for now.
2005-07-01 16:45:38 +00:00
christos b775b6932a Don't apply .DEFAULT commands to special targets (.BEGIN, .END, .INTERRUPT). 2005-06-29 19:59:42 +00:00
wiz 3051d76108 Consistency. Use Pp instead of br. 2005-06-27 09:51:09 +00:00
lukem 2bf924f405 Restore the rework from rev 1.115 and expand the description of .OBJDIR
to document the behaviour that is currently in use (the "./obj" and
"/usr/obj/`pwd`" behaviour).
Hopefully the existing .OBJDIR behaviour is clearer now.
2005-06-27 00:17:08 +00:00
wiz 47fb7786c1 Since the obj dir handling changes in the code have been
reverted, revert them in the man page too (i.e., revert v1.115).
2005-06-26 10:14:43 +00:00
lukem 50e70cd0ee revert previous for now 2005-06-24 04:33:25 +00:00
lukem 62955ed1ec Revert rev 1.110 and restore the previous "automagic objdir" support;
at least until we clean up the objdir semantics in <bsd.obj.mk> for
NetBSD builds.
2005-06-24 02:53:27 +00:00
lukem a6a204d392 Deprecate support for automagically setting the .OBJDIR to
./obj.${MACHINE}
	./obj
	/usr/obj/${PWD}

The rules for the default .OBJDIR setting are now simplified to
(and documented as) trying the chdir to the following
(if the appropriate variable is defined):
	${MAKEOBJDIRPREFIX}${.CURDIR}
	${MAKEOBJDIR}
	${.CURDIR}

.OBJDIR can be overridden in the makefile.
<bsd.obj.mk> uses this to provide the "culled" .OBJDIR semantics
for NetBSD's /usr/src builds.

MAKEOBJDIRPREFIX & MAKEOBJDIR still can only be provided
in the environment or on make(1)'s command line.

Per discussion on tech-toolchain.
This should reduce a lot of lossage people have experienced over
the years with various .OBJDIR setups.
2005-06-23 02:31:31 +00:00
wiz 19a870f516 Fix an article, and drop trailing whitespace. 2005-06-19 17:26:07 +00:00
rpaulo 9e77e5175e Change "non-escaped" to "unescaped".
Reviewed by hubertf.
2005-06-18 14:34:55 +00:00
rpaulo a0c960912d Add a new test case to reflect the problem found on PR toolchain/30536.
Reviewed by sjg and hubertf.
2005-06-18 14:33:15 +00:00
rpaulo f0f2f92389 PR standards/17732: make doesn't honour escaped comment lines. Now with
a real fix.
Ok'ed by sjg and hubertf.
2005-06-18 14:32:04 +00:00
wiz 7fba66045a Bump date for -jn, and add some formatting. 2005-06-17 19:30:49 +00:00
jmc 736ef19188 Add new debugging option '-dn' which will leave the scripts fed into make on
-j jobs in /tmp for debugging purposes. Add a note to the man page that
this could cause problems if run a lot (due to the number of files created)
2005-06-17 19:25:20 +00:00
jmc e72c744fe2 If the line being passed to the shell is a blank line and we're not in compat
mode, use the ignErr template for the command as shell doesn't like an empty
construct of the form { } || <something>. Fixes build breakage on cats
distrib where a command ends up expanding to nothing.
2005-06-16 18:07:45 +00:00
rpaulo a94394c1d9 Back it out while I'm working on a real fix without introducing new bugs. 2005-06-16 14:54:10 +00:00
rpaulo 9eb6f66b9a We now support comments until the end of a non-escaped line.
Ok'ed by hubertf.
2005-06-15 22:39:27 +00:00
rpaulo d0727c5f5b Add a unit-test for comments.
Addition to PR bin/17732.
Approved by sjg and christos.
2005-06-15 22:32:22 +00:00
rpaulo 72c3c708ca PR bin/17732: Allow make to understand escaped comments.
Approved by sjg, christos and hubertf.
2005-06-15 22:26:54 +00:00
lukem 0f422228f9 appease gcc -Wuninitialized 2005-06-03 16:15:46 +00:00
lukem 366252f608 * Improve error handling with unrecognized chars after :t.
* Explicitly goto default_case for unknown chars encountered after
  various : modifiers, rather than multiple FALLTHRUs.
* Appease gcc -Wuninitialized for sv_name and v_ctxt.

Discussed with sjg.
2005-06-03 07:02:39 +00:00
lukem fb0f76d8e8 cosmetic comment tweak 2005-06-03 05:56:25 +00:00
lukem a3b235bbd2 appease gcc -Wuninitialized 2005-06-02 01:53:01 +00:00
wiz 7aee94451b New sentence, new line; grammar improvements. 2005-06-01 17:33:21 +00:00
sjg 5f60a7de65 Add :Ox for random ordering, based on patch from
Mike M. Volokhov <mishka@apk.od.ua>
2005-06-01 17:17:34 +00:00
christos ec9ba17179 Don't complain that we cannot make .END. 2005-05-08 04:19:12 +00:00
christos 733e0e6e72 Now that dependencies in .BEGIN, .END, and .INTERRUPT work, allow them. 2005-05-08 00:38:47 +00:00
christos c9da1629b6 Mark the interrupt job as special so that when we hit ^C with -j and we
have a .INTERRUPT target we don't print "token botch".
2005-05-03 22:58:14 +00:00
christos 592ba37fd4 Don't accept dependencies for .BEGIN, .END, and .INTERRUPT since they
don't make sense or work anyway.
2005-05-01 01:25:36 +00:00
christos 66b68ce36c PR/9566: Arne H. Juul: Document special targets that do not obey dependencies. 2005-05-01 00:37:10 +00:00
christos 13481917e0 When parsing conditional tokens, make sure that the token is followed by
a non-alpha character, so that .elsefoo is not parsed as .else leading
to confusion later.
2005-03-01 04:34:55 +00:00
sjg 34180b9ccc In the case of :? modifier, variable can be an expression - say so. 2005-02-23 17:22:29 +00:00
christos 63fca13660 PR/29203, PR/29204: Max Okumoto: KNF changes to make [no functional changes] 2005-02-16 15:11:52 +00:00
christos 6e40c9e6fb PR/22559: Valeriy E. Ushakov: make -j can execute commands in wrong directory
(not in the obj dir).
Fixed by detecting when we cd, and cd'ing back.
2005-01-31 22:41:43 +00:00
christos f3ff62b84d Add comments in the pmake style, and factor out a local variable.
No functional change.
2004-12-29 01:55:25 +00:00
christos 8415275dbd 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.
2004-12-29 00:43:02 +00:00
dsl 108eb2ab42 Add (unsigned char) cast to ctype functions 2004-10-30 20:39:35 +00:00
yamt fb79fa6390 define __GNUC_PREREQ__ if it isn't available on host. 2004-07-15 09:01:29 +00:00
wiz 13d5df6555 Sync usage with man page; from Kouichirou Hiratsuka in PR 26223. 2004-07-13 11:59:12 +00:00
wiz d2c6d0c9f5 Sort options in synopsis. 2004-07-13 11:58:55 +00:00
jmc a2bacbeec5 Change to use __unused instead and provide a compat definition in make.h if
not already defined from cdefs.h
2004-07-01 20:38:09 +00:00
jmc 71a252d58b Add some checks for gcc around a few function declarations and note the
unused variables. Also fix a few other warnings that PR#22118 shows when
trying to compile bmake on non-NetBSD hosts
2004-07-01 04:39:30 +00:00
jmc f648d12d47 Add missing NetBSD ID tags 2004-06-30 03:26:26 +00:00
uwe 06c338a198 Fit ASCII output onto an 80-column terminal. From FreeBSD. 2004-06-27 19:12:33 +00:00
uwe 150ca6a7f2 Fix a few typos. From FreeBSD. 2004-06-27 19:04:54 +00:00
wiz faa47b7058 Add comma in enumerations; fix a sentence; plural needs no apostrophe. 2004-05-07 08:23:31 +00:00
sjg 4d3fc51f60 Remove use of sh -e when running in compat mode.
Its not posix compliant and serves very little purpose.
With this change compat and jobs modes are consistent wrt how
they treat each line of a script.

Add support for the '+' command line prefix as required by posix.
Lines prefixed with '+' are executed even when -n is given.
[Actually posix says they should also be done for -q and -t]

PR:
Reviewed by: jmc
2004-05-07 08:12:15 +00:00
ross 42dbdbd46a 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
2004-05-07 00:04:38 +00:00
ross dcdf1bd27a Instead of including from the wrong directory and then fixing it (-I)
in the Makefile, how about just doing the right include?
2004-05-06 23:15:46 +00:00
ross fcce1f91eb Recognize -- (dash dash) and apply the usual interpretation.
Notes:

* The immediately previous version of make errored out on --,
which is what needs fixing.

* Historic bsd make silently ate -- and continued to process
options, so this is a behavior change from that, too, but presumably
there is more to gain in fixing it than in being bug-compatible.
2004-04-22 21:19:02 +00:00
sjg 3c6b696332 Allow "string" and "${varspec}" on lhs of conditionals.
This makes it possible to use expressions like
${("${LIST:Msomething"}):?present:absent}
it also makes treatment of lhs and rhs more consistent, and
makes CondToken easier to read.

Update unit-test/cond1 to test new features.
2004-04-13 16:06:23 +00:00
sjg df910819de Revised patch for catching extraneous .else's
We actually need to tack condTop and skipIfLevel.
Bump MAXIF while here.
Enhance the unit-test for conditionals to exercise more code.

PR: 24420
2004-04-08 07:24:26 +00:00
sjg ab4f0bc644 Back out previous patch for now.
Breaks bsd.obj.mk
2004-04-08 01:35:33 +00:00
sjg 8bef426d13 Add check for extraneous .else's - based on patch from Arne H. Juul
in PR/24420.
Add a unit-test for conditionals.
Also in the unit-test makefile strip any .CURDIR in output.

PR: 24420
2004-04-08 00:59:01 +00:00
enami 84b05f6e6e Validate existence of arguemnt. PR#24933. 2004-03-27 00:17:08 +00:00
fair 11b2aeb6e2 Fix comment per PR 24437; make(1) tries "makefile" first, and then
"Makefile", not the other way around as previously documented.
2004-03-24 00:59:40 +00:00
enami 222e389ef2 Print useful line number on error while executing .for directive. 2004-03-06 03:57:07 +00:00
sjg a3cc11808b Fix :M so that modifiers in nested variables don't terminate parsing
early.  Add a unit-test to verify it works and keeps working.
Re-jig the unit-tests so that all are sub makefiles.
2004-02-20 09:03:26 +00:00
sjg 79e5bb77fc Use ${.MAKE:S,^./,${.CURDIR}/,} so that when someone does
./make test
it works.  Note use .CURDIR rather than .OBJDIR since the later
_may_ not always be correct (eg. symlink in .CURDIR for make).
2004-02-15 19:05:45 +00:00
wiz e3fc4b66c3 Spell the plural of suffix "suffixes", not "suffices".
Inspired by PR 24400 by Todd Vierling.
2004-02-13 17:56:17 +00:00
wiz 56bb942672 Bump date; uppercase POSIX. 2004-02-05 23:51:46 +00:00
ross 3856fab870 Briefly document the posix command line order and add that this
is (unfortunately) not enforced.
2004-02-05 23:40:52 +00:00
ross 380bdcb7fb Parse args with open code to eliminate use of getopt(3).
No functional change under NetBSD.

Restarting a getopt(3) loop is an extension to the posix getopt(3)
behavior and is not portable.

Fixes tools build (tools/groff) under Cygwin.
2004-02-05 23:31:34 +00:00
wiz c732f0a853 Use more mdoc macros; new sentence, new line; bump date for previous. 2004-02-04 00:37:45 +00:00
chuck 51659857a7 add parent directory search for make as discussed on tech-toolchain.
- new dir.c function: Dir_FindHereOrAbove:
      Search for a path in the current directory and then all the directories
      above it in turn until the path is found or we reach the root ("/").
 - add hooks to use it in main.c for -m and syspath (compiled in
      _PATH_DEFSYSPATH and $MAKESYSPATH).
 - updated man page
2004-02-03 19:25:29 +00:00
lukem f83f942f81 Document more SPECIAL SOURCES (aka ATTRIBUTES).
Improve description of variable modifiers.
In the variable list, be more specific referring to "environment variables"
rather than just relying upon the formatting difference between .Ev and .Va.
2004-01-27 01:38:01 +00:00
dsl c3032ca9a0 Restore correct name string when VarGetPattern() returns.
Stops error from free() evaluating ${x::=y} when x is undefined.
(Erm why is free() allowed to write to fd 2?)
2004-01-24 19:58:54 +00:00
sjg 4d32648363 ternary is .PHONY 2004-01-19 00:32:26 +00:00
dsl 4169574d6f Reindent search loop in SuffFindCmds using 'continue' and 'break' instead
of netsted ifs.  No logic change.
2004-01-11 17:24:25 +00:00
dsl 742a98df46 Change DEBUG(DIR) traces to indent subsequent filenames instead of
generating very long lines (basically changes "..." into " ...\n   ").
2004-01-11 12:22:40 +00:00
sjg 71746b839b Add unit test for ternary modifier 2004-01-09 00:56:44 +00:00
sjg 1752434408 Fix :?: modifier so that it works again. 2004-01-08 23:55:05 +00:00
sjg 345311007d Handle more complex conditional expressions.
CondCvtArg now returns NULL if it consumed all input, or a pointer
to any left overs.
2004-01-06 01:18:52 +00:00
jmmv b635f565e7 Homogenize usage messages: make the 'usage' word all lowercase, as this seems
to be the most common practice in our tree.
2004-01-05 23:23:32 +00:00
wiz 8114895bf3 Bump date for previous; use macros for marking up
the dollar sign.
2003-12-26 23:22:31 +00:00
jmc 31e37b335f Note that variable expansion can occur within SYSV style = substitions. 2003-12-26 23:18:18 +00:00
jmc 3eb499682d Support variable expansions inside of SYSV style = substitutions. Better matches
expectations (and some cases of historical behavior I've found). Also fixes
PR#3865
2003-12-26 23:13:32 +00:00
jmc c7c6bf2bbd Don't assume startc is always {, set delim to endc when separating the args to
the ? test.
2003-12-26 08:03:06 +00:00
jmc 1664a90985 Fixes for PR#18573 (make -j not stopping correctly on error).
Using -e in sh/ksh to stop on error doesn't work with grouped commands. At
least for any SUSE compliant sh(1). Instead, extend the Shell struct and add
errOut which provides a template to use to check error status from commands.
2003-12-20 00:18:22 +00:00
jmc be1cdb8652 When looking for a makefile and curdir != objdir (i.e. working inside of an
objdir) try opening the file from curdir and if that fails try from objdir.
This way .depend files get picked up via their full path names rather than
just .depend so vars like PARSEDIR, PARSEFILE are then set correctly. This
fixes PR#13289 reporting incorrect pathnames for .depends with errors in
them
2003-12-18 22:36:18 +00:00
wiz 15dcc3baa6 Drop trailing spaces. 2003-12-07 20:48:25 +00:00
dsl 2bd419cb33 Add back 'on error' that got deleted by mistake. 2003-12-07 20:46:44 +00:00
dsl 7da2fe51b3 Add a -Dg3 which outputs the 'input graph' only on error exit.
Lets you see the wood for the trees...
2003-12-07 20:30:28 +00:00
dsl eceb7dddfb Don't create targets if dependant files marked .OPTIONAL are missing. 2003-11-14 22:32:44 +00:00
lukem a2f8083d5d Add some subsections in the VARIABLE ASSIGNMENTS section.
In the "modifier description" list, show each modifier with the leading `:'.
Rationale: it's hard to search for modifiers without it, and we already do
the same thing in the -options and .makecommands lists.  I now find it much
easier to find the description for a modifier in the man page.
2003-11-07 01:01:46 +00:00
lukem 171d653219 Overhaul how `build.sh tools' are used:
*	Rename "config.h" to "nbtool_config.h" and
	HAVE_CONFIG_H to HAVE_NBTOOL_CONFIG_H.
	This makes in more obvious in the source when we're using
	tools/compat/config.h versus "standard autoconf" config.h

    *	Consistently move the inclusion of nbtool_config.h to before
    	<sys/cdefs.h> so that the former can provide __RCSID() (et al),
    	and there's no need to protect those macros any more.

These changes should make it easier to "tool-ify" a program by adding:
	#if HAVE_NBTOOL_CONFIG_H
	#include "nbtool_config.h"
	#endif
to the top of the source files (for the general case).
2003-10-27 00:12:41 +00:00
jmc 89996408fa Fixes from PR#23210 to eliminate use of asprintf which makes cross building
on non-NetBSD hosts work again
2003-10-23 15:58:29 +00:00
jdolecek e9a93e256b properly dottify .\" comments; this fixes output of [range] paragraph 2003-10-09 16:56:06 +00:00
sjg d388dcd1a3 Implement :[] modifier to allow picking a range of words out of a variable.
Also :tW and a W flag to :C and :S to allow treating value as a single word.
Add unit tests for the above, and fix some corner cases.
Based on patches supplied by Alan Barrett <apb@cequrux.com>
2003-09-27 21:29:37 +00:00
jmmv 6c008dec3b Add the 'e' debug flag (i.e., '-d e'): when enabled, show the "target
failed" and "command failed" messages added recently.  These introduce
too much noise when debugging some kind of problems, specially in pkgsrc.
2003-09-10 18:04:22 +00:00
jmmv 328ce86893 Document the '-d f' flag. 2003-09-10 08:44:31 +00:00
lukem f741d2d094 when displaying the 'Failed command:', collapse runs of whitespace in the
command to a single space.   suggested by David Laight in private mail.
2003-09-09 16:16:02 +00:00
drochner 1a9a16338e Remove some code which makes file lookup rely on the fact that
the first two directory entries are "." and "..".
This behaviour is not required by applicable standards, and
actually not provided by "coda".
Now we get the "." and ".." into the per-directiry hash tables,
but this should not hurt.
2003-09-09 14:44:35 +00:00
lukem 16cddad1c8 don't free cmdStart too early, as cmd points somewhere in there and we
may want cmd for error messages.
should fix [bin/22705] from itojun@
2003-09-08 23:54:54 +00:00
sjg 435f6fef84 Make empty() consider an undefined variable as empty,
rather than throw a syntax error.
2003-09-06 06:52:08 +00:00
wiz 91f2a1b827 Whitespace nits. 2003-09-05 06:55:46 +00:00
sjg 9ab525fdf0 Allow -V '${FOO}' to print the expanded version of FOO.
A side effect of adding and removing a -E option for the above is that
the cases in MainParseArgs are now ordered correctly?
2003-09-05 06:52:11 +00:00
lukem 5bb8036aeb Also display failed target. Given
printf "all:\n\ttrue\n\t@false\n" | make -f -
the error output now looks like:
	*** Failed target:  all
	*** Failed command: false
	*** Error code 1
instead of just
	*** Error code 1

XXX: add this support for  make -j  builds.
2003-09-02 23:40:11 +00:00
lukem ea878e8983 display the command that failed.
this is useful if the command-line had been suppressed.
2003-09-02 12:17:40 +00:00
sjg a41eaef46a Hook make unit-tests into regress 2003-08-08 06:42:38 +00:00
agc 89aaa1bb64 Move UCB-licensed code from 4-clause to 3-clause licence.
Patches provided by Joel Baker in PR 22365, verified by myself.
2003-08-07 11:13:06 +00:00
sjg 3dfdacc170 Avoid \a as a test of invalid separator, since if we make ksh the default
shell, we get different results.  \x seems safe.
2003-08-01 04:57:20 +00:00
sjg 86b9a219d4 Fix for TEST_MAKE from Alan Barrett 2003-08-01 03:55:59 +00:00
sjg 3716ad7f49 Allow .SHELL: to control the shell used by compat mode too.
Add a shell spec for ksh - a nice portable posix shell.
Document .SHELL:
2003-08-01 00:39:52 +00:00
scw bc25d2ab5f Const poisoning. 2003-07-31 13:48:11 +00:00
sjg 1ebbf35953 Test behavior of commandline variable assignments. 2003-07-31 00:46:15 +00:00
sjg 82cba16bce A couple of other places where delim should be set 2003-07-29 09:06:29 +00:00
sjg b806b12f2d First bug picked up by the unit tests - delim wasn't always initialized.
Avoid putting '\' in test case script lines since shell's like that on
SunOS insist on interpreting them.
2003-07-29 08:44:41 +00:00
sjg e3cd1dc68c Use single quotes to protect everything from shell's that might
alter the results.
2003-07-29 08:16:01 +00:00
sjg 6b9a4c9477 Regardless of the name of TEST_MAKE, force it to make in test.exp
to avoid needless failures.
2003-07-29 06:35:09 +00:00
sjg db7ca3c993 Fix parsing bug for :ts - patch from Alan Barrett <apb@cequrux.com>
Also add simple unit-test jig (regress/usr.bin/make will use it too)
but having it local here makes inclusion in bmake simpler.
2003-07-28 22:52:10 +00:00
mrg 8c66a01dc4 build var.c with -Wno-cast-qual - gcc3.3 complains about VarWordCompare() 2003-07-26 16:04:29 +00:00
sjg 59b1f67a11 Fix merge problem with ts modifier and const correctness.
Need to pass nstr to VarModify.
2003-07-23 18:06:46 +00:00
wiz aeb7902476 Bump date for tu addition; drop trailing space; sort a bit. 2003-07-16 11:34:16 +00:00
itojun a5450bcac9 backout. make(1) either uses strcpy() to malloc'ed region (enough size),
or function signature prohibits us from using strlcpy().
2003-07-16 07:16:24 +00:00
itojun 06ded73d5a we can't use snprintf here, as sizeof(pathname) is unknown 2003-07-16 07:11:29 +00:00
itojun bd8e1178ee strlcpy (fixed) 2003-07-15 05:39:28 +00:00
itojun 885eddc2ed strlcpy 2003-07-15 05:38:24 +00:00
sjg 8186ad8ad9 Fix a couple of missing UNCONST's that hit bmake. 2003-07-14 21:13:48 +00:00
sjg f1cf540a8d Add a :ts[c] modifier to allow controlling the separator used between
words in a variable expansion.  If 'c' is omitted no separator is used.
2003-07-14 20:39:20 +00:00
christos 6a7d20bb25 Pass WARNS=3 2003-07-14 18:19:11 +00:00
wiz 95ad95491e Fix two minor whitespace problems. 2003-07-14 08:55:18 +00:00
wiz 664b3c96d5 Misc mdoc fixes (mostly quoting). 2003-06-26 18:21:45 +00:00
matt 78735dbbe5 For a library, only check in cmtime (children's modification) if there are
children.  This prevents spurious out-of-date failures when you have a
rules checking for a library's existance (and no children).
2003-06-02 21:49:00 +00:00
wiz 7fbb5054ee New sentence, new line; bump date for last. 2003-05-23 18:15:17 +00:00
christos 7ce8fa7806 PR/10917: John Hawkinson: Document $MAKE and say which one we want to be using. 2003-05-23 17:25:10 +00:00
christos 11dc6dfd26 PR/19781: Thomas Klausner: make error message not helpful on unclosed ${var:foo 2003-05-22 18:20:10 +00:00
jmmv afa06162bc Remove extra space in usage message. 2003-05-10 19:21:40 +00:00
sjg 414c86b6d1 math.h is not needed and including it introduces uncessary dependencies
on some systems.

PR: 21204
2003-04-17 15:57:52 +00:00
wiz 7b31891279 Bump date for last. 2003-04-16 09:44:07 +00:00
christos 9d921a9a8d PR/1523: Chris Demetriou: don't count a library as built, if there is no way
to build it.
2003-04-08 17:46:59 +00:00
jrf 9350d70e69 Added MAKESYSPATH environment variable as per jmmv's suggestion in
PR 18030
2003-04-01 14:00:58 +00:00
sjg 62d1f2d214 Comment in ParseDoSrc was no longer accurate.
Explain the difference between handling of src node
in ParseDoSpecialSrc cf. ParseDoSrc.
2003-03-23 22:48:35 +00:00
sjg 50ca80687f We are supposed to pass the node for our expanded src to ParseAddDep
for each entry in allsrc.  Just like ParseDoSrc.  The only difference
in handling these special expanded srcs in in the call to ParseLinkSrc.
2003-03-23 05:11:22 +00:00
sjg 77076c2d51 ParseDoSpecialSrc: since we're already being called for each target
make it depend only on the expansion of src that matches.
Otherwise given:

a b c:  ${.TARGET}.x

a b and c will each depend on a.x, b.x and c.x

Further, we only _need_ to do ParseDoSpecialSrc if a .WAIT appears
in the source list - so establish that up front.
2003-03-22 23:41:02 +00:00
christos bef3a7f735 don't mess with suffix rules. 2003-03-21 19:14:53 +00:00
sjg 9db7e8cb6d Missed a s/tn->name/pref/ 2003-03-21 16:48:21 +00:00
sjg 0220f09cfc Add ParseDoSpecialSrc() to handle srcs that refer to ${.TARGET} etc.
These are expanded for each target (set in its own context) and
ParseDoSrc() is then called for the expanded src.

PR: 20828
Reviewed by: christos
2003-03-21 15:52:57 +00:00
thorpej c5007c219b Add a -X option, which prevents make(1) from putting variables
set on the command line into the environment individually.  This
can be useful on systems which have a tight limit on the size
of the argument space.
2003-03-14 05:19:43 +00:00
sjg cc9d340ac8 Add -B to MAKEFLAGS so that it propagates to sub-makes.
This allows one to use -j1 -B at some point in a tree to
overcome a -jN (which is the main reason one would use -B).
2003-02-26 08:59:12 +00:00
wiz 990562bfef .Nm does not need a dummy argument ("") before punctuation or
for correct formatting of the SYNOPSIS any longer.
2003-02-25 10:34:36 +00:00
perry 8a49ec08e4 "Utilize" has exactly the same meaning as "use," but it is more
difficult to read and understand. Most manuals of English style
therefore say that you should use "use".
2003-02-04 23:07:28 +00:00
wiz 9115df8c49 success, not sucess. Noted by mjl. 2003-01-28 22:35:02 +00:00
uebayasi 3d7c8fcb51 Be more specific how to call arguments of modifiers.
Reviewed By: wiz
2003-01-09 01:22:30 +00:00
mjl 037d3d9eb9 Tyop fixes 2003-01-03 14:11:18 +00:00
sjg 32a3b241bf Treat an unquoted '#' as end of line when parsing conditionals.
This ensures that comments are ok at the end of line.

PR: 19596
Reviewed by: christos
2002-12-30 18:03:09 +00:00
gson 936f6a1c3c When JobExec() was called from JobRestartJobs() via JobRestart(), it
executed the make job with sigprocmask(SIG_BLOCK) in effect for a
number of signals including SIGCHLD.  This caused recursive submakes
of the make process in question not to receive SIGCHLDs when their
jobs exited.  This was a second, independent cause of bin/18895 in
addition to the race condition already fixed.  Fixed by unblocking all
signals before executing the job.
2002-12-09 01:23:53 +00:00
scw ffeb337cd7 Lst exp -> Lst explist, to avoid warnings about gcc-current's
builtin exp() function.
2002-12-05 15:56:52 +00:00
sjg ecdc5fc7ad Parse_DoVar: don't free cp until we are done with it!
Reviewed by: hannken
2002-12-01 05:53:30 +00:00
wiz 80dfe4a842 Bump date for .PATH description; begin sentence with upper case letter;
new sentence, new line.
2002-11-29 19:10:25 +00:00
sjg 78610dd53d Whenever we update .PATH, set the variable ${.PATH} to reflect the
search list that will be used.  Thus 'dot' and 'cur' will appear in
${.PATH} either at the start or end depending on .DOTLAST even though
they are not strictly in dirSearchPath.

When .CURDIR is assigned to - re-set the 'cur' Path.

Finally, when checking subdirs, look in 'dot' and 'cur' (first or last
depending on .DOTLAST) just as we do in other situations.
2002-11-26 06:12:59 +00:00
enami b3e831985f Call fcntl() on the right file descriptors. 2002-11-26 05:30:01 +00:00
gson 96f1cc8289 Fixed race condition that would cause make -j to pause for five
seconds if a SIGCHLD arrived while make was not blocked in poll(),
by making the SIGCHLD handler write to a pipe included in the poll.
Avoided the need to implement a duplicate fix for the USE_SELECT case
by emulating poll() in terms of select() when USE_SELECT is defined.
Fixes bin/18895.
2002-11-16 22:22:23 +00:00
perry 2bf91ba1e8 environment variables, not environmental variables 2002-11-02 04:13:41 +00:00
grant be8ae688ae New sentence, new line. 2002-09-30 11:08:56 +00:00
wiz 09ee17ab5a Fix an Xr, add a comma and join two short lines. In short, minor changes :) 2002-09-24 15:31:30 +00:00
christos d72855f015 add missing Lt. 2002-09-24 15:19:26 +00:00
lukem ad5f5e697c HP/UX fixes from Giles Lean:
- consistently support __hpux (which the HP compilers define) as well
  as __hpux__ (not sure which compilers set this, but retained anyway)
- fix a typo in the definition of signal().  arguably the codebase should
  just be converted to sigaction()...
2002-09-22 01:19:08 +00:00
thorpej 34269821f1 If MAKE_BOOTSTRAP and HAVE_CONFIG_H, pull in "config.h" so that
we get the correct _PATH_BSHELL definition.
2002-09-14 15:23:49 +00:00
wiz 3c7935455d End some sentences with a dot. bin/17987 by Julio Merino. 2002-08-19 11:14:23 +00:00
wiz 86ebbc3a0e Remove !__STDC__ stuff, de-__P(), ANSIfy, and de-register. 2002-06-15 18:24:55 +00:00
itojun f51456c273 err/errx/warn/warnx do not need \n at the end 2002-06-11 06:06:18 +00:00
wiz 6e749bff5c Comment out token after #endif. 2002-05-16 19:48:18 +00:00
wiz 19f4778435 Comment out token after #endif. (Hmmmmmmm.) 2002-05-16 19:47:47 +00:00
bjh21 b846107274 Rather than hardcoding "/bin/sh", use _PATH_BSHELL. To allow bootstrapping,
provide a default for this in pathnames.h, and only include <paths.h> ifndef
MAKE_BOOTSTRAP.
2002-04-27 15:14:30 +00:00
bjh21 628b5efe85 Allow the makefile to override _PATH_DEFSHELLDIR as well. 2002-04-24 20:38:47 +00:00
christos 3baa6002c6 PR/16361: J. Mallett: make(1)'s job.c does not properly initialise postCommands 2002-04-15 12:45:33 +00:00
pk 53dab8cf3b Darn.. remove test code from previous commit. 2002-03-21 11:42:21 +00:00
pk 971b06b979 When looking at predecessor/successor dependencies, we need to consult a
cohort's centurion as well.
2002-03-21 11:34:17 +00:00
christos a7ffc9ca78 don't print extra newlines on errors. 2002-03-21 01:24:43 +00:00
pk e9b668c861 Xref: parse.c, rev 1.46; make.c, rev 1.23
In these revisions `::' dependency handling was simplified by not linking
the cohort nodes into the dependency graph. This broke dependency checking
on all but the first instance of a `::' target since all of the cohort nodes
now just form a collection of disconnected dependency graphs.

Fix this by keeping a back-reference in each cohort to its leader (the
first instance of a :: node with the same name) and a count of the number
of cohorts that need to be made before dependent nodes are scheduled.

Classically, we'd need six centurions for cohort, but in this case one
suffices...
2002-03-20 18:10:30 +00:00
lukem dadfca12c4 clarify how :U works 2002-03-19 22:17:30 +00:00
pk 48f5b2bd9d Fix some of the syntax errors (in unused code) and layout glitches. 2002-03-18 13:32:36 +00:00
pk b9f8785382 Block signals during Lst_Open/Lst_Close list traverals and in JobExec
while setting up a child process. This prevents the major sources of
list inconsistencies that may result from doing list manipulations
from a signal handler.

XXX - all Lst_*() operations are at risk; look for ways to avoid touching
so much global state from the signal handlers.
2002-03-18 13:28:25 +00:00
pk f41ec821b9 Fix signal-handling bogons in JobPassSig():
- don't block the signal we're about to send to ourselves to
	  take the default action for
	- restore the signal handler for the current signal
	- remove duplicate sigprocmask() call

As a result, restoring the SIGTSTP handler in JobContinueSig() is no longer
necessary.
2002-03-18 12:28:07 +00:00
pk e962f03d24 JobInterrupt(): don't try to unlink JOIN or PHONY targets. 2002-03-18 08:23:33 +00:00
pk fe31442363 Remove bogons from JobMatchShell() 2002-03-18 07:54:33 +00:00
pk 9fee4daa5f Job_ParseShell(): fix keyword counting error. 2002-03-15 15:54:41 +00:00
pk 0debc78bef JobExec(): don't use Punt() in the child; it can't possibly DTRT, and will also
mess up the parents variables.

Instead, use execError() for all error paths in the child code.
2002-03-14 16:08:37 +00:00