Commit Graph

881 Commits

Author SHA1 Message Date
dsl 5dc59d0d4b When processing .include "../../foo.mk" lexically process the leading ../
against the directory name of the makefile being processed.
Shortens a lot of pathnames (especially in pkgsrc) and significantly
reduces the number of duplicate entries in .MAKE.MAKEFILES
2007-10-13 11:08:05 +00:00
dsl 5651920158 The 'job_prefix' string can be static but not const 'hi xtos'. 2007-10-13 08:58:48 +00:00
dsl fad077a68d If we are going to save the names of all opened makefiles, do so when files
are first processed, not for every line of every loop inside the file.
When (attempting) to check for duplicate names, use the spaces between names
as separators rather than using strstr() - which is slow and wont find
duplicates after an incorect early match.
However the duplicate check is rather broken (especially for pkgsrc) where
names like ../../devel/atk/../../devel/glib2/../../devel/gettext-lib/ \
../../devel/gettext-lib/../../mk/buildlink3/../../mk/bsd.prefs.mk
which need (some form of) realpath() processing.
'cd pkgsrc/xaa/gtk2; make show-var VARNAME=.MAKE.MAKEFILES' shows the problem.
2007-10-12 23:38:27 +00:00
christos 0f19d8c420 static a const string. 2007-10-12 23:13:16 +00:00
christos 31bed26f71 improve on previous 2007-10-12 23:07:04 +00:00
dsl bb4beef604 Var_Subst() seems to write into its input string! So we do need a copy. 2007-10-12 22:49:36 +00:00
dsl 215593ad6c Remove tmp[] buffer and strncpy() call. 2007-10-12 21:47:25 +00:00
sjg 1050c04a22 If _BASENAME_DEFSHELL is defined, it might be a full path,
in which case we should not prepend _PATH_DEFSHELLDIR.
2007-10-11 21:19:28 +00:00
sjg 3a5409e4eb Fix an off-by-one error in handing mal-formed modifiers.
The issue seems to have been present for some time, only showed up
when running unit-tests on SunOS.
Make sure we get an error message, but otherwise behave as before.
2007-10-09 05:55:03 +00:00
sjg e73405e272 Use .MAKE.MAKEFILES to track all the makefiles that have been read
so they can be used in dependency rules.
2007-10-08 20:26:36 +00:00
sjg f28827375c Add the ability to .export variables to the environment. 2007-10-05 15:27:45 +00:00
sjg 216e9ba475 Add the ability to tweak the token output before targets in job mode.
Eg.
.MAKE.JOB.PREFIX=${.newline}---${.MAKE:T}[${.MAKE.PID}]
would produce
---make[1234] target ---
2007-10-01 22:14:09 +00:00
uwe 7a8181d0dc Revert 1.34 (CFLAGS+=-g) that have been commited by mistake (hi, xtos). 2007-09-25 21:28:26 +00:00
rillig 3911c95333 A small word can sometimes express things clearer ... 2007-08-13 06:14:08 +00:00
dsl 53bf780833 Under DEBUG(VAR) report when the variable wasn't found.
Disposes of pr bin/15842
2007-06-16 19:47:29 +00:00
dsl 1752887780 Delete some comments that refer to long-extinct code. 2007-05-23 19:03:56 +00:00
christos fc1f18e6ca kill clobbered warning from Tobias Nygren 2007-04-05 14:11:35 +00:00
dsl 69a5cd957a Don't increment 'cp' twice when looking for commands following ';' on a
dependency line.
This makes the line "foo:;echo bar" not try to execute "cho bar", and the
line "baz:;" not treat the rest of the makefile as commands.
Pointed out by Takahiro Kambe on current-users.
2007-02-24 17:55:54 +00:00
dsl 8732462d65 Add code to ensure that .if/.endif are correctly nested with .for/.endfor
and also include files don't have mismatched .if/.endif
It has been suggested that make used to have this test, but I can't
remember removing any code that might have performed it.
2007-02-04 19:23:49 +00:00
dsl 9ac7863b40 Check of open conditionals before we trash 'curFile' - so we can actually
report the filename of the error (without core dumping!).
Also fix tests for reporting errors to the debug_file, and don't add $PWD
to (stdin).
2007-01-24 21:43:01 +00:00
wiz 6aacb705f6 4 -> 4.0, since Nx does not accept all arguments without complaint. 2007-01-23 22:23:48 +00:00
dsl bbdea71364 Don't delete '\' from before '#' in shell command lines.
Probably fixes build of pkgsrc:editors/xemacs.
Pointed out by Richard Earnshaw.
2007-01-18 20:22:44 +00:00
hubertf 48b31403c5 Remove duplicate #includes
From Slava Semushin <slava.semushin@gmail.com>, via private mail
2007-01-17 00:21:43 +00:00
christos 66fbdf9319 Avoid coredumping. Found by accidentally running make instead of gmake
in java's control/make directory.
2007-01-15 01:26:32 +00:00
dsl 8a7693fba6 Don't delete whitespace before a "\\\n" sequence. Somewhere I'd misread
the required behaviour and replaced it with something more sensible - except
for makefiles that contain "\n\t\\\n shell command"...
2007-01-02 23:22:37 +00:00
dsl 8b25f96e43 Remove the (now redundant) MAKE_BSIZE, BUF_DEF_SIZE from buf.c is used instead. 2007-01-01 21:48:43 +00:00
dsl 4d3c468f96 Rework the code that separates the makefile into lines.
Instead of copying the file byte by byte into an expanding line buffer, just
scan the file buffer for (unescaped) newlines.
Escaped newlines (etc) are processed by modifying the file buffer later.
Speeds up 'nbmake obj' by a factor of 2.
I suspect it will do wonders for parts of pkgsrc as well, since it largely
eliminates cpu cycles from the false part of .ifs.
2007-01-01 21:47:32 +00:00
dsl d6cad2789c Request the 'verbose' node print when aborting and scheduling nodes. 2007-01-01 21:42:42 +00:00
dsl 75dd4686a9 Add the other half of the fix to stop stuff that depends on .WAIT nodes
being always rebuilt.
2007-01-01 21:39:58 +00:00
dsl 388fdf7f68 Don't force things that have dependencies against .WAIT nodes to be rebuilt.
This is what causes all of ksh to be built every time through.
2007-01-01 21:35:40 +00:00
dsl 3780cb6cd8 Remove 'else' after 'return', and similar whitspace changes.
Extra debug on where files are actually found.
2007-01-01 21:31:51 +00:00
dsl b7483eac69 Since the 'buf' code here is only used by make, we don't need two names
for the default buffer size of 256.
Also allow for the trailing 0 byte!
2007-01-01 21:29:01 +00:00
wiz 4cc41386ba Fix a typo. Use Nx. 2006-12-23 07:25:41 +00:00
erh d96de9f7f0 Correctly handle '\' at the end of a variable in the non-expanding case. 2006-12-22 20:28:31 +00:00
dsl d8f5679725 Fix breakage of previous commit. 2006-12-21 20:05:37 +00:00
dsl c26f3a4858 Fix detection and reporting of dependency loops in parallel makes.
make's unit_tests should now run again.
2006-12-20 20:46:35 +00:00
christos 83508cedc2 From Anon Ymous:
Removed two "(void)&" constructs as there is no setjmp() or vfork() insight.
Flagged a few parameters __unused so this will compile with -Wextra now.
2006-12-18 15:06:16 +00:00
dsl c822b38662 Use open/read/close instead of stdio for makefiles.
Commons up the code for reading files and buffers, and allows a further
change where we don't copy the data out of the buffer when generating 'lines.
This will speed up makefile parsing (esp .if clauses).
2006-12-16 08:59:29 +00:00
dsl edc84458bf Fix a comment that has been wrong since rev 1.1, minor layout fix. 2006-12-16 08:51:12 +00:00
dsl 82e7102f1f Revert part of a recent commit.
ParseEOF() shouldn't close the original file.
2006-12-07 21:34:16 +00:00
dsl a294d83a63 Put the big block of code that was common to ParseDoInclude() and
ParseTraditionalInclude() into a separate routine.
Fix the 'use after free' and 'free on item not malloced' that got added
to ParseTraditionalInclude() in Feb 2006 (rev 1.111).
Kill the 'PTR' struct and put both its members into IFile.
Remove the parameter from ParseEOF(), 1 of the 3 calls passed the wrong value!
Fortunately another test stopped anything nasty happening, we'll use that
test instead.
2006-12-07 21:07:01 +00:00
dsl f01b961f16 Add anewline to the end of the error message output when the debug log
file cannot be opened.
2006-12-06 20:38:21 +00:00
dsl 014cba747c There really is no point calling estrdup() to get a copy of the makefile name
into every 'gnode' (aka target), instead just copy a pointer to the string
and avoid freeing the original name when we close the file.
I can't imagine any makefile set where this gives a larger footprint!
2006-12-04 21:34:47 +00:00
dsl 8416a0f46b Unknot this code slightly by avoiding 'break/return; else' and by putting
the short parts of some conditionals first.
First step towards speeding up the parsing of makefiles (esp. the unwanted
parts of .if clauses).
There should be no changes to the logic.
2006-12-03 20:40:44 +00:00
dsl 8b27f0807d Some minor changes:
- Only test 'printVars' once.
  Has side effect of not trying to find the 'main' target for '-V varname'.
- Only reap the single child process in Cmd_Exec(),
  I think this is for 'xx != cmd' so probobably no other children should exist.
- Don't read and parse .depend if '-r' and '-V varname' are set.
  I suspect that .depend shouldn't affect the output of any -V command...
2006-12-03 20:37:39 +00:00
dsl dc6b659187 Simplify the code that processes .if lines.
It doesn't need a two-dimensional array to remember the states of .if lines.
It would be even simpler if we didn't try to detect .else and .elif lines
that follow .else lines.
Unfortunately this isn't the code that is stupendously slow...
2006-12-02 15:50:45 +00:00
dsl b45e829a99 Update information on .ORDER and .WAIT.
Document the -d-flags and -dFfilename.%d options.
Mention MAKEFLAGS at the top, reword to make it clear that makefile and
Makefile are only used if no -f makefile is given.
2006-11-19 10:08:18 +00:00
dsl b5e3384b9c 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).
2006-11-17 22:07:39 +00:00
dsl 29479294dd If the last 3 bytes of the debug filename supplied with -DFxxxx are .%d then
replace the %d with getpid().
Allows the trace files for different make process is a big recursive make
to be written to different files - and have a slight chance of being useful.
2006-11-11 22:07:37 +00:00
dsl d2c6b9d3fe Return the non-zero value that caused the Lst_ForEach[From] call to
terminate early to the caller.
2006-11-11 21:23:36 +00:00
dsl e2455acf6d Point a few diagnostic printfs (the ones that got away) to debug_file
instead of stdout.
2006-11-11 21:21:17 +00:00
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
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