Commit Graph

680 Commits

Author SHA1 Message Date
sjg e1e6c59ee6 Use of libutil to provide emalloc et al, should be predicated on
a native NetBSD build using TOOLDIR etc.
Otherwise use the local versions.

Reviewed by: christos
2006-11-01 23:48:20 +00:00
dsl 72c6703a09 Rename 'struct Lst' to 'struct List' and 'struct LstNode' to 'struct 'ListNode'
in lst.d remove a small barrowload of casts from the lst.lib bloatset.
2006-10-27 21:37:25 +00:00
dsl 16c8499ed2 Since 'ClientData' is 'void *', nuke almost all the (ClientData) casts. 2006-10-27 21:00:18 +00:00
dsl adb344c8f2 Rename Lst_Append() to Lst_InsertAfter() and Lst_Insert() to Lst_InsertBefore()
to better explain their actions.
2006-10-25 20:17:40 +00:00
dsl 7ef877a8c0 Fix previous - need to add a lstPrev() 2006-10-25 20:05:59 +00:00
dsl 95938658de Replace 'a == b ? FALSE : TRUE' with 'a != b'
Add missing () in expansion.
2006-10-25 19:45:22 +00:00
dsl 0ce4eb1f8a 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.
2006-10-25 19:44:10 +00:00
christos 088aec4701 sprinkle volatile. 2006-10-22 16:23:20 +00:00
dsl c183c301dc Add some more explanitory comments.
Rename 'allsrc' to 'curSrcs' so that the variable passed to ParseDoSrc (etc)
has the same name as the local in the calling routine, rather than a name
that seems to imply a more global and persistent list.
2006-10-15 21:17:27 +00:00
dsl fb889ecbbd Change a 'while' loop to a 'for' loop so we can add 'free(line)' into the
loop continue part.  Remove the 'free(line)' from teh end of the loop body,
change the gotos into continues and collapse out some 'else if's.
All in the name of code transparency.  No functional changes.
2006-10-15 18:08:14 +00:00
dsl 0195907f3d 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.
2006-10-15 08:38:21 +00:00
dsl 505a3bb2b7 There is no need to resize the pollfd array, it can only ever have 2+maxJobs
entries, so allocate at startup.
Use an 'int jobPipe[2]' within the job structure, and create pipes directly
into it.  Common up the code that creates all the pipes - making them all
non-block on the read side in the process.
Call Job_CatchChildren() directly from Job_CatchOutput() so that it only
gets called when a child actually exits.
NB: Something causes a 'pregnant pause' if (for example) you call 'nbmake obj'
in src/tools.  Introduced between netbsd 3 and 4.
2006-10-11 07:01:44 +00:00
apb 4e86f6ddf0 In a non-native build, always use a shell to execute commands. This may
be necessary in a weird cross-build environment.  Previously, if the
command looked simple enough, we would try to exec it directly.

OK sjg, christos
2006-10-09 20:46:33 +00:00
apb cd195008c6 Allow make(1) to be built with something other than "sh" as the
shell.  To use this, build with -D_PATH_DEFSHELLDIR=\"/path/to/dir\"
-D_BASENAME_DEFSHELL=\"shell\".

* Change the order of entries in shells[].  Now DEFSHELL defaults to 0,
  and shells[0] describes the default shell.  This will be "sh" in the
  usual case.

* If _BASENAME_DEFSHELL is defined, insert an additional entry above
  "sh" in the shells[] array, making this new entry shells[0].  The
  new entry is assumed to refer to an sh-compatible shell with a
  non-standard name.  (Tested using _PATH_DEFSHELLDIR="/usr/pkg/bin" and
  _BASENAME_DEFSHELL="bash".)

* In the shells[] entry for "sh", test defined(MAKE_NATIVE) &&
  defined(__NetBSD__) to decide whether we can use the "q" flag.

OK sjg, christos
2006-10-09 20:44:35 +00:00
dsl 01a426f62c Rip out the code for the undocumented -P (don't use pipes for command
output) option.  I'm sure it is baggage from the past.
2006-10-09 14:36:41 +00:00
dsl 4a7a153be0 Rip out the code for not 'USE_PGRP', I can't imagine it being useful!
My guess is that it is compat code for before the pgrp stuff was added.
2006-10-09 13:49:59 +00:00
dsl 9f624ea07b Instead of trying to report all the 'job suspended' and 'job resumed'
messages whan make itself is suspended (ie by ^Z) before make actually
suspends, supress the messages during this sequence.
This means we don't care that they would be output after the suspend
and we can stop attempting to reap child status from withing the signal
handler (which doesn't work for recursive parallel makes).
The code simplification means that we can remove much of the code that
blocked signals - since the signal handlers (expect that for ^C and friends)
now do almost no work.
2006-10-09 13:40:11 +00:00
peter e263dfd62f WFORMAT is no more... 2006-10-08 17:52:28 +00:00
dsl a178085551 Reap any dead children that we have at startup.
If there are any undead ones set a flag so we don't report the 'Child (pid)
not in table' message when they die - it is impossible to (portably) find
the childrens pids.
This happens when make is run as 'make -f- ... <<EOF' and the shell uses
a child of (what will be) make to write the data into a pipe.
2006-09-29 19:38:48 +00:00
dsl 56564e27f6 Complete revamp of the way make handles job control signals.
- Send each type of signal to its own handler.
- Only call JobFinish when a process exits, in particular don't 'fake up'
  'exitstatus' for jobs being continued, nor call it for suspends.
- When a job is stopped, use an entire variable to remember the fact, so
  we know we need to send a SIGCONT.  Don't change any other state.
- In order to report '*** [job3] Suspended' before we suspend ourselves we
  have to call waitpid() from the signal handler - where we don't want to
  process job termination events. Save the exit status and process later.
The code now handles:
- jobs that suspend themselves
- jobs exiting while suspended
- jobs that don't actually suspend at all
Hoewever it still does printfs() from the signal handler, and I haven't yet
stopped it thrashing the signal mask.
2006-09-23 20:51:28 +00:00
dsl 7adfa633e3 Fix build on 64 bit systems.
Remove now-unecessary temporary local.
2006-09-22 21:55:52 +00:00
dsl 11d35f72b2 Replace the two lists 'job_list' (previously 'jobs') and 'stoppedJobs'
with a table that is malloced with 'maxJobs' entries.
Add a 'job_state' field to the Job type that exactly follows which of
the old lists the job was on (or not).
Change all the code that scanned the lists to scan the array.
No logic changes in this commit.
(Soon we'll no longer need to lock out signals for the changes to job
statuses that are done from signal handlers now that there is no linked list.)
2006-09-22 19:07:09 +00:00
dsl edb0aa98de Rename the variable 'jobs' to 'job_list' in preparation for making it an array. 2006-09-21 19:56:05 +00:00
christos 55ee861f25 protect libutil with HOSTPROG 2006-08-29 16:54:03 +00:00
christos 03eff0d591 Fix non-native build. 2006-08-26 22:19:03 +00:00
christos 623c0a861f Don't include <util.h> if we are not NetBSD. Other OS's don't have it. 2006-08-26 22:13:00 +00:00
christos cdab3a7a06 More programs using efun. 2006-08-26 18:17:41 +00:00
christos 67a75c5772 If a word is "" eat the last quote since we ate the first. 2006-08-11 19:11:00 +00:00
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