Commit Graph

126 Commits

Author SHA1 Message Date
Hartmut Brandt
179078e76d Change the return value of Var_Subst to return a Buffer instead
of a char *.

Patch:		7.49

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-02-25 13:16:56 +00:00
Hartmut Brandt
96089951e4 Initialise the status variable. W_SETTERMSIG uses its value.
Submitted by:	stefanf
2005-02-10 14:32:14 +00:00
Hartmut Brandt
f6dc7bd983 Use tabs to move to the comments instead of wild mixes of tabs and spaces.
Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-02-04 08:11:58 +00:00
Hartmut Brandt
e23bc3a201 Some more easy constification.
Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-02-04 07:51:00 +00:00
Hartmut Brandt
7a2029bac2 Clean up include files and file including. Split nonints.h into pieces
that get included just where they are needed. All headers include the
headers that they need to compile (just with an empty .c file). Sort
includes alphabetically where apropriate and fix some duplicate commenting
for struct Job, struct GNode and struct Shell by removing one version and
inlining the comments into the structure declaration (the comments have been
somewhat outdated).

This patch does not contain functional changes (checked with md5).

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-02-01 10:50:37 +00:00
Hartmut Brandt
5dd8ec0fd1 Fix compilation for the USE_KQUEUE case.
Submitted by:	Emil Mikulic <emikulic@dmr.ath.cx>
2004-12-20 10:21:27 +00:00
Hartmut Brandt
0512b0a6c7 maxJobs is declared extern in job.h so it cannot be static in job.c.
PR:		bin/75210
Submitted by:	Andreas Jochens; Robert Millan <rmh@debian.org>
2004-12-20 10:14:05 +00:00
Hartmut Brandt
1d614caea7 Instead of dynamically allocating list heads allocated them statically
now that their size is only two pointers. This eliminates a lot of calls
to Lst_Init and from there to malloc together with many calls to
Lst_Destroy (in places where the list is obviously empty). This also
reduces the chance to leave a list uninitilized so we can remove more
NULL pointer checks and probably eliminates a couple of memory leaks.
2004-12-16 16:14:16 +00:00
Hartmut Brandt
c76d7d5047 Get rid of the sequential access feature of the lists. This was used
only in a couple of places and all of them except for one were easily
converted to use Lst_First/Lst_Succ. The one place is compatibility
mode in job.c where the it was used to advance to the next command on
each invocation of JobStart. For this case add a pointer to the node to
hold the currently executed command.
2004-12-08 16:22:01 +00:00
Hartmut Brandt
db7ce92a3c Constify the arguments to the list compare function. This temporarily
requires to make a copy of the filename in ReadMakefile and to duplicate
two small functions in suff.c. This hopefully will go away when everything
is constified.

Submitted by:	Max Okumoto <okumoto@ucsd.edu> (partly)
2004-12-08 12:59:27 +00:00
Hartmut Brandt
bf1ead0608 Typedefs of pointers to structs are evil. Make Lst and LstNode typedef of
the structs itself not of pointers to them. This will simplify constification.

Checked by: diff on the object files
2004-12-07 13:49:13 +00:00
Hartmut Brandt
644a6874f9 Make needs no circular lists so remove them from the list code. 2004-12-07 10:14:16 +00:00
Hartmut Brandt
421cdafee3 Change the algorithm that matches the builtin shells from the name keyword
of the .SHELL target. Formerly it used to select the shell with the
longest common trailing substring, so that bash would select sh, but pocsh
would select csh. Now an exact match is required so that specifying bash
without also giving a path and the other keywords will give an error.

PR:
Submitted by:
Reviewed by:	ru
Approved by:
Obtained from:
MFC after:
2004-12-03 08:02:52 +00:00
Hartmut Brandt
d21474cec4 Style: remove a lot of unnecessary casts, add some and spell the null
pointer constant as NULL.

Checked by: diff -r on the object files before and after
2004-12-01 10:29:20 +00:00
Hartmut Brandt
e6417f6fe2 Stylification: missing spaces, extra space after function names, casts
and the sizeof operator, missing empty lines, void casts, extra empty lines.

Checked by: diff on make *.o lst.lib/*.o

Submitted by:	Max Okumoto <okumoto@soe.ucsd.edu> (partly)
2004-11-30 17:46:29 +00:00
Hartmut Brandt
17446c050c Constify the array of predefined shells. It turns out that we need two
versions of the structure definition for this: one with const char
pointers, because otherwise gcc won't let us initialize the fields with
constant strings, and one without the const, because we need to work
with the structure.
2004-11-30 15:35:51 +00:00
Hartmut Brandt
21d15001f9 Fix a very long-standing error in handling .SHELL targets: this target
uses the brk_string function to parse the line. That function uses static
storage for both the expanded string and the returned argv[] vector.
The JobParseShell function simply stored away pointers into this static
storage. On the next use of something like ${FOO:O} this storage would
get overwritten with fatal results.

This also allows us to make the shells[] array const bringing us one step
further in making make WARNS=4 ready.
2004-11-25 10:01:26 +00:00
Hartmut Brandt
d96b4f0130 Get rid of the shell table sentinel. It isn't needed anymore because
JobMatchShell returns NULL when no shell name matches since revision 1.51.
2004-11-22 15:45:57 +00:00
Ceri Davies
f4422f46b8 Wrap a comment properly. 2004-11-12 13:14:56 +00:00
Poul-Henning Kamp
1d66b1beec Add code to enforce the paralleism count (-j N) for the entire tree
of submakes spawned during processing.

We create a fifo and stuff one character into it for each job we are
allowed to run.  The name of the fifo is passed to child processes
in the MAKE_JOBS_FIFO environment variable.

A make which finds this variable on startup will open the fifo and
only spawn jobs when it managed to read a token from the fifo.
When the job completes a token is writen back to the fifo.

Slave make processes get one token for free: the one their parent
make got in order to run them.  This makes the make processes
themselves invisible in the process counts.

The net effect is that "make -j 12 -s buildworld" will start at
most 12 jobs at the same time, instead of as previously up to
65 jobs would get started.
2004-11-12 08:58:07 +00:00
Hartmut Brandt
4253bd82b6 Fix a (very) long standing bug in make (this has been there probably
from the beginning). Make used to handle all its interrupt-time stuff
directly from the signal handler, including calls to printf, accessing
global data and so on. This is of course wrong and could provoke a core
dump when interrupting make. Just set a flag in the signal handler and
do everything else from the main thread.

PR:		bin/29103
2004-11-12 07:57:17 +00:00
Poul-Henning Kamp
414fa5e8fc Get rid of more local/remote leftovers 2004-11-11 12:52:16 +00:00
Hartmut Brandt
afa99554de Now with the remote job support removed there can be no remote jobs and
no jobs that need to be remigrated. Remove the flags and the associated
code.
2004-11-05 11:41:36 +00:00
Hartmut Brandt
dd1fa6553d Remove the remote stuff from make. This actually never worked in our make
because the necessary files were not imported with the original import.
If somebody really needs it, there is still the devel/pmake port.

This is just the first step and removes just everything that is ifdef'ed out.
Otherwise the code is unchanged.

Checked by:	md5

Approved by:	no objections on arch@
2004-11-04 12:57:41 +00:00
Ruslan Ermilov
e3168409f1 "unset verbose" is 13 characters, not 10. 2004-10-23 21:36:55 +00:00
Ruslan Ermilov
3ecaab1c99 Expand the scope of the .SHELL specification to also cover
the compat mode of operation and the != operator.

While here, fixed a bug in the .SHELL directive processing
when only the name= attribute is specified and no built-in
shell matches this name, causing null pointer dereference.

Obtained from:	NetBSD (except for bugs)
2004-10-23 21:34:41 +00:00
Hartmut Brandt
34c9c43931 Implement POSIX's '+' flag for command lines. This flag causes a line
to be executed even when -n is given on the command line to make. This is
very handy for calls to submakes.

This is slightly changed from the original patch as obtained from NetBSD.
The NetBSD variant prints lines which have both '+' and '@' when -n
is specified. The commited version always obeys '@'.

Bump MAKE_VERSION so Makefiles can use this conditionally.

PR:		standards/66357 (partly)
Submitted by:	Mark Baushke <mdb@juniper.net>
Obtained from:	NetBSD
2004-07-29 14:29:23 +00:00
Brian Feldman
59fb7e543f Treat kevent(2) returning an error EINTR as the non-error it is. 2004-04-20 22:04:12 +00:00
Ruslan Ermilov
9f80feb348 Bootstrapping aid from pre-kqueue(2) systems, e.g. 4.0-RELEASE.
Submitted by:	jmallett
Approved by:	re (bmah)
2002-12-01 13:38:25 +00:00
Juli Mallett
85779f0ead Split var.c into var.c and var_modify.c and move all the modification funcs
to var_modify.c, for readability.  constify some low hanging fruit (string
manipulation functions) and the upper layers appropriately.  No longer use
the private strstr(3) implementation, while changing string code.

Tested by:      lots of successful make buildworld.
2002-10-28 23:33:57 +00:00
Juli Mallett
cbfcb39874 Remove efree(), it isn't used consistently enough to even pretend that it
might help on the systems it could possibly be used as a bandaid for.  In
fact, the only thing it's useful for is instrumenting free(3) calls, and in
that capacity, it's better served as a local patch, than a public wrapper.
2002-10-23 23:16:43 +00:00
Juli Mallett
4526ed6ffb Convert make(1) to use ANSI style function declarations. Variable
documentation already adequatedly existed in the description in most
cases.  Where it did not, it was added.  If no documentation existed
beforehand, then none was added.  Some unused dummies for use in the
traversal functions were marked as __unused during the conversion.
Occasionally, local style fixes were applied to lines already being
modified or influenced.

Now make(1) should always build with WARNS=3.
2002-10-09 03:42:10 +00:00
Poul-Henning Kamp
5fd43411f3 Give make(1) the ability to use KQUEUE to wait for worker processes
instead of polling for them.

Unfortunately we cannot enable it yet because it panics the kernel
somewhere in kqueue.

Submitted by:	Stefan Farfeleder <e0026813@stud3.tuwien.ac.at>
2002-10-04 20:30:03 +00:00
Juli Mallett
40eecdba73 Fix spurious three-space indentation in a four-space indentation file. 2002-09-29 00:20:28 +00:00
Juli Mallett
1e3d8881cf Add empty default cases where they should be, remove non-local execution stuff
in compat.c which doesn't even have preprocessor-conditional-hidden support
code, and add a debugging statement where we might end up with a nil list
somehow, but where I doubt it.

First confirmed userland kill for Flexelint.

Sponsored by:	Bright Path Solutions
2002-09-28 20:03:26 +00:00
Juli Mallett
2dbb6cf1cb Make the DEBUGF() macro portable by (ugh) adding a Debug() function, which
is merely printf() but to stderr.  This takes care of the caveat which lead
to the use of a vararg macro -- getting everything to stderr.
2002-09-18 16:13:03 +00:00
Juli Mallett
cdba64071c Move common use of if (DEBUG(FOO)) printf... to DEBUGF(FOO, ...), using
variable length arguments to a macro.  Bump version as this makes DEBUG
statements *always* go to stderr rather than sometimes stdout.  There are
a few stragglers, which I will take care of as soon as I can.  Mostly these
relate to the need-for-death-of some of the remote job code.

Nearby stylistic nits and XXX added/fixed where appropriate.
2002-09-17 22:31:26 +00:00
Juli Mallett
37721c8309 #define<space> -> #define<tab> 2002-09-17 21:29:06 +00:00
Juli Mallett
83739a1077 Diff reduction for great justice against NetBSD, cast to unsigned char when
passing an argument to isspace(3).
2002-06-20 19:28:00 +00:00
Juli Mallett
22c26d85e3 The error functions take constant pointers to strings for their format. 2002-06-12 04:11:01 +00:00
Ruslan Ermilov
1737392273 Back out the ``run shell from $PATH'' change; this was an overkill
and is insecure.

Requested by:	bde
2002-05-24 15:51:27 +00:00
Ruslan Ermilov
ea98f295f7 Do not run shell from /bin, run it from $PATH.
Bump MAKE_VERSION to 5200205221.
2002-05-22 14:53:18 +00:00
David E. O'Brien
664a5a88d4 Prefer BSDmakefile over makefile and Makefile.
Submitted by:	jmallett
Obtained from:	OpenBSD
2002-04-13 12:18:00 +00:00
David E. O'Brien
9b24805230 Fix copyrights, and undo SCS ID damage. 2002-04-13 10:57:56 +00:00
David E. O'Brien
4d1f4209a6 Update SCM ID method. 2002-04-13 10:17:18 +00:00
David E. O'Brien
a59e308cd7 De'register. 2002-04-13 10:05:30 +00:00
David E. O'Brien
da363cd56a Check to make sure fdopen() succeeds in make(1).
Submitted by:	jmallett
Inspired by:	NetBSD
2002-04-13 09:10:07 +00:00
Philippe Charnier
cb497d661f Reorder #include. Cast arg #2 of lseek to an off_t when constant. No need to
test if failsafe memory allocation fails, it can't. perror -> warn. Use
failsafe memory allocation provided.

Use .Pa and .Ar. Uppercase (first letter) programname after dot.
2002-04-12 13:23:33 +00:00
Warner Losh
d3cb5ded92 remove __P 2002-03-22 01:33:25 +00:00
Sheldon Hearn
e1b4d8d074 Use STD{ERR,IN,OUT}_FILENO instead of their numeric values. The
definitions are more readable, and it's possible that they're
more portable to pathalogical platforms.

Submitted by:   David Hill <david@phobia.ms>
2001-07-26 11:02:39 +00:00
Jeroen Ruigrok van der Werven
d7d97eb0aa Preceed/preceeding are not english words. Use precede and preceding. 2001-02-18 10:43:53 +00:00
Will Andrews
1a1a8c9324 There's also no point in #typedef'ing void/char pointers. Accordingly,
rip out ClientData/Address pointers and use standard types.

Obtained from:	OpenBSD
2000-12-02 20:24:42 +00:00
Will Andrews
98c28d6cc5 There's no reason to use fancy forms of NULL. Replace all instances
of NIL, NILLST, NILLGNODE, etc. with NULL.

Obtained from:		OpenBSD
2000-12-02 18:58:01 +00:00
Kris Kennaway
29ac114aae Unlink the temporary file immediately so it is removed on exit.
Obtained from:	OpenBSD
2000-11-19 12:04:12 +00:00
Ruslan Ermilov
c2a62388b7 Remove gratuitous free() call when we use special .SHELL target. 2000-08-18 10:41:37 +00:00
Brian Feldman
c7322223b9 Allow use of the ${MAKE_SHELL} variable to specify alternate shells for
make(1) to use.  Setting it to "sh" and "ksh" are the only values which
work right ATM; I wouldn't expect "csh" to get you far ;)
2000-08-16 23:31:43 +00:00
Wilfredo Sanchez
023944f435 Use __RCSID() 2000-07-09 02:54:54 +00:00
Wilfredo Sanchez
1ae30690d2 Initialize variable 2000-07-09 00:05:09 +00:00
Will Andrews
ea9b438956 Add loud debugging facility (-dl option) which allows programmers/developers
to override @-prefixed commands in Makefiles.  It is especially useful for
debugging ports and/or complex Makefiles in such a manner that is basically
a last resort, but is quite effective if the output is well-handled.

I'll update the manpage after dinner.  ;-)

Better patch submitted by:	steve
Reviewed by:			phk, steve, chuckr, obrien,
				Lyndon Nerenberg <lyndon@orthanc.ab.ca>
2000-05-14 22:24:28 +00:00
Kris Kennaway
6470ba8b28 Create tempfiles securely.
Reviewed by:	imp
2000-01-17 06:43:41 +00:00
Tim Vanderhoek
06b1dcf182 Unduplicate IDs from comments, do $Id -> $FreeBSD$ (submitted-by: bde) 1999-09-11 13:08:02 +00:00
Peter Wemm
c3aac50f28 $Id$ -> $FreeBSD$ 1999-08-28 01:08:13 +00:00
Tim Vanderhoek
a6ad7c7f78 Fix a temp file race occurring only when -j is used.
Noticed by:	ru
Obtained from:	OpenBSD
1999-08-22 05:28:13 +00:00
Tim Vanderhoek
9bd2d6eee4 Merge style- and trivial- only changes from OpenBSD (dated 1999/07/29-19:55+1).
Obtained from:	OpenBSD, sometimes indirected from NetBSD; myself
1999-08-17 00:39:26 +00:00
Dmitrij Tejblum
69a6a9961e Remove couple of 'extern int errno'. (They turned to something funny when
<errno.h> included).
1999-02-14 22:22:54 +00:00
David Greenman
7009ec844f Added a -v (verbose) option and hid multi-job file banner generation
behind it.
1998-11-14 16:15:04 +00:00
Martin Cracauer
9a4902a99f When exiting on SIGINT, exit with signal status 1998-08-24 10:17:20 +00:00
Bruce Evans
822aa079ec Don't forget to pretend that `make -n -jN' makes the targets that it
says it pretends to make.

This bug was apparently harmless except for normal cases involving
.ORDER statements when it made debugging of -jN using -n very
confusing.  E.g., for:

.ORDER: beforedepend .depend
depend: beforedepend .depend

where beforedepend depends on something so that it is not initially
up to date, `make [-n] -j2 depend' causes `make' to wait for itself
to make beforedepend.  This works fine without -n.  The job to make
beforedepend has normally been started, and beforedepend is marked
as made when the job completes.  However, with -n, the pseudo-job
for making beforedepend has normally completed, and in any case
there was no chance of beforedepend being marked as made.  `make'
actually exited almost immediately with status 0 instead of waiting
forever.
1998-06-04 05:48:57 +00:00
Warner Losh
3a42f937f1 Use historically correct error message in some cases, optionally. 1998-04-28 05:08:10 +00:00
Peter Wemm
53faa0dade Revert $FreeBSD$ to $Id$ 1997-02-22 19:29:21 +00:00
Jordan K. Hubbard
1130b656e5 Make the long-awaited change from $Id$ to $FreeBSD$
This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore.  This update would have been
insane otherwise.
1997-01-14 07:20:47 +00:00
Steve Price
5d55a64610 O' to be bitten by CVS. Cleanup after import
of Christos' version of make(1) and add Id's.

Set straight by: Bruce Evans and Peter Wemm :)
1996-10-08 04:07:59 +00:00
Steve Price
c0d06fe463 Merge in NetBSD's changes to make(1). Changes include:
- Add the .PHONY, .PARALLEL, and .WAIT directives
	- Added the -B and -m commandline flags
	- misc. man page cleanups
	- numerous job-related enhancements
	- removed unused header file (bit.h)
	- add util.c for functions not found in other envs.
	- and a few coordinated whitespace changes

Special thanks to Christos Zoulas <christos@netbsd.org>
for help in the merge.  A 'diff -ur' between Net and
FreeBSD now only contains sccsid-related diffs. :)

Obtained from: NetBSD, christos@netbsd.org, and me
1996-10-06 02:35:38 +00:00
Rodney W. Grimes
7799f52a32 Remove trailing whitespace. 1995-05-30 06:41:30 +00:00
Jordan K. Hubbard
9f574f9a90 Bring in a number of changes from NetBSD's make, fixing quite a few
problems in the process:

1. Quoting should work properly now.  In particular, Chet's reported bash
   make problem has gone away.
2. A lot of memory that just wasn't being free'd after use is now freed.
   This should cause make to take up a LOT less memory when dealing with
   archive targets.
3. Give proper credit to Adam de Boor in a number of files.
Obtained from: NetBSD (and Adam de Boor)
1995-01-23 21:03:17 +00:00
Rodney W. Grimes
9b50d90275 BSD 4.4 Lite Usr.bin Sources 1994-05-27 12:33:43 +00:00