Commit Graph

145 Commits

Author SHA1 Message Date
Hartmut Brandt
54a923046f Reshuffle functions to get rid of prototypes.
Submitted by:	Max Okumoto <okumoto@ucsd.edu> (7.235)
2005-05-12 14:35:01 +00:00
Hartmut Brandt
7594df85cf Move variable printing from main.c to var.c
Submitted by:	Max Okumoto <okumoto@ucsd.edu> (7.233)
2005-05-12 14:31:42 +00:00
Hartmut Brandt
8b8eb9e2ab Fix the fix for bin/72510 applied in job.c:1.70. Actually there have
been two maxJobs variables: one static in job.c and one global used in
main.c and parse.c. Makeing one global out of these was the wrong way
to fix the problem. Instead rename the global one to jobLimit and keep
maxJobs static in job.c.

Suggested by:	rwatson
PR:		bin/72510
2005-05-12 14:16:44 +00:00
Hartmut Brandt
0ec9b6feef Move some global variables to the correct files.
Submitted by:	Max Okumoto <okumoto@ucsd.edu> (7.232)
2005-05-12 11:58:39 +00:00
Hartmut Brandt
824060d705 Path_Expand() expects its first argument to be writeable so put the
default system directory into a writeable character array before passing
it to Path_Expand().

Submitted by:	Max Okumoto <okumoto@ucsd.edu> (7.210)
2005-05-10 14:23:31 +00:00
Hartmut Brandt
a139b7bac1 Move the remaining two prototypes from nonints.h to make.h and
remove nonints.h.

Patch:	7.204
Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-05-10 14:10:44 +00:00
Hartmut Brandt
626dc02016 Merge compat.c into job.c. There is a lot in common between these
files and we are going to factor this out.

Patch:		7.199 (slightly changed)
Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-05-10 13:45:29 +00:00
Hartmut Brandt
c26295ddea Move Cmd_Exec() from main.c to job.c and fix its prototype. This
results in a warning that will go away soon.

Patch:		7.198
Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-05-10 13:18:58 +00:00
Hartmut Brandt
103823e628 Make make a little bit more POSIXish with regard to option parsing:
take everything after -- as either a macro assignment or a target.
Note that make still reorders arguments before --: anything starting
with a dash is considered an option, anything which contains an equal
sign is considered a macro assignment and everything else a target.
This still is not POSIX with regard to the options, but it will probably
not change because it has been make's behaviour for ages.
Add a new function Var_Match() that correctly skips a macro call by just
doing the same as Var_Subst() but without producing output. This will help
making the parser more robust.

Patches:	7.190,7.191
Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-05-10 08:06:13 +00:00
Hartmut Brandt
02c3270da1 Split Var_Subst() into two functions: Var_SubstOnly() which substitutes
only one variable and Var_Subst() which substitutes all. Split out the
test whether a variable should not be expanded into match_var().
Make access to the input string consistently using str[]. Remove two
unused functions: Var_GetTail() and Var_GetHead().

Patches:	7.184-7.189
Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-05-09 14:06:04 +00:00
Hartmut Brandt
352a63dee8 Introduce a new pseudo-target .EXPORTVAR which allows to put a
make macro into the environment of programs executed by make. This
has approximately the same function as gmake's export directive.
The form of a pseudo target was deliberately choosen to minimize work
for POSIX compatibility (Makefiles are not allowed to use any targets
starting with a dot and consisting only of uppercase letters except those
specified in the standard when they want POSIX compatible behaviour, so
such a Makefile can never contain .EXPORTVAR.)
Change the handling of macros coming from the environment: instead
of asking the environment for each variable we could not find otherwise
put all the environment variables in a special variable environment just
at start up.

This has been tested on the ports cluster by kris.

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-05-06 18:30:06 +00:00
Hartmut Brandt
3dece030a5 Implement a pseudo-target .WARN that allows toggeling the warning flags
for the current make. This does not override flags specified on the
command line and these settings are not passed to sub-makes.
2005-04-29 14:37:44 +00:00
Hartmut Brandt
48c49ace00 Introduce a flag to enable extended warnings (-x) and make them off
by default. This should fix the problem of getting lots of errors
when building with an up-to-date make and old *.mk files.
2005-04-28 15:37:25 +00:00
Hartmut Brandt
9e1e6570f3 Remove an unneccesary forward declaration for MainParseArgs().
getopt() may be called several times - make sure to set optreset
to reset it. Cleanup handling of non-option arguments.
Remove some misleading comments.

Patch:		7.171

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-04-11 07:32:49 +00:00
Hartmut Brandt
8f5850c6f4 Remove the call to Parse_Init() - there is no need to initialize
a static variable to NULL. Forgot this in the previous commit to
parse.[ch].
2005-04-11 07:26:21 +00:00
Hartmut Brandt
ab9267be40 Style: Indentation. 2005-04-01 12:42:03 +00:00
Hartmut Brandt
5e0a7a4450 Almost complete rewrite of the archive code (except for the Makefile parsing
part). Archive handling was broken at least since the move from BSD ar/ranlib
to GNU binutils because of the different archive format. This rewrite fixes
this by making make to carry around the defines for all formats (it supports)
so it can support all of them independent of the actually used one. The
supported formats are: traditional BSD (this seems to come from V7 at least,
short names only and __.SYMDEF), BSD4.4 (long names with #1/ and __.SYMDEF)
and SysV (extra name table and //). The only format not supported are broken
traditional archives where the member names are truncated to 15 characters.

Errors in the archive are not ignored anymore, but cause make to stop with
an error message. The command line option -A causes these errors to become
non-fatal. This is almost compatible with previous usage except for the
error message printed in any case.

Use a type-safe intrusive list for the archive cache.

Reviewed by:	Max Okumoto <okumoto@ucsd.edu> (without new error handling)
2005-03-31 11:35:56 +00:00
Hartmut Brandt
fb1dac11b4 Make paths an explicite datatype instead of using the generic Lst.
A Path is now a TAILQ of PathElements each of which just points to
a reference counted directory. Rename all functions dealing with Paths
from the Dir_ prefix to a Path_ prefix.
2005-03-23 12:56:15 +00:00
Hartmut Brandt
1ff3feb03d An automatic variable in a local scope is (conceptionally) destroyed with
the closing brace so it is unwise to keep a pointer to it. Make
the variable static to fix this.

Patch:		7.152

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-22 07:56:22 +00:00
Hartmut Brandt
4896df6314 Simplify buffer access by using Buf_Data() and Buf_Peel() where
appropriate.

Patch:		7.147-7.151

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-22 07:50:40 +00:00
Hartmut Brandt
2559e71404 Replace a bogus use of Lst_Find with explicite LST_FOREACH calls
and remove the unneeded second argument to ReadMakefile.
2005-03-18 15:23:49 +00:00
Hartmut Brandt
7985e10d29 Remove leading underscores from the pathname defines. All identifiers
with leading underscore followed by an uppercase letter are in the
implementation namespace.
2005-03-11 13:02:38 +00:00
Hartmut Brandt
e390545124 Use Buf_Peel to get rid of a local variable. 2005-03-08 14:37:47 +00:00
Hartmut Brandt
09fdd614d4 Buf_GetAll wants a pointer as its second argument, not a boolean -
replace FALSE by NULL.

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-02-28 17:05:26 +00:00
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
3ff4a47ba0 Fix two typos in comments.
Submitted by:	ru & Max Okumoto <okumoto@ucsd.edu>
2005-02-17 09:09:34 +00:00
Hartmut Brandt
46f05faa3a Mostly stylistic issues: move a variable into local scope, make
condition positive and fix long lines.

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-02-16 17:20:09 +00:00
Hartmut Brandt
5e431bae8f Better version of the patch in 1.117: bring a variable into local scope
to prepare for function splitting and slightly reorganise the code
in anticipation of Var_Subst returning a Buffer.

Submitted by:	Max Okumoto <okumoto@ucsd.edu> (with slight changes)
2005-02-16 12:39:32 +00:00
Hartmut Brandt
0d63385639 Back out the previous commit. There is an obvious bug in it.
Pointy hat to:	harti
2005-02-13 13:33:56 +00:00
Hartmut Brandt
157e401636 Stylistic fixes: push variable into a local context (this part is going
to be split out into a function soon). Also there is no need to write
back the colon that we have NUL-ed - the string is going to be freed
anyway.

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-02-11 17:03:18 +00:00
Hartmut Brandt
46ca434737 Introduce Buf_StripNewLines() and use it where appropriate.
Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-02-07 11:27:47 +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
ab9e1eb050 Convert several typedefs from beeing pointers to structs to be the structs
itself. This will ease constification (think of what 'const Ptr foo'
means if Ptr is a pointer to a struct).

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-02-02 07:36:18 +00:00
Hartmut Brandt
042037eb6f Remove debugging stuff that crept in in the previous commit. 2005-02-01 11:39:45 +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
b071ad2dca Fix quoting of the MAKEFLAGS environment variable by only quoting spaces
and tabs. This is still not correct for command line variable values
ending in a backslash because this would require a larger effort.
Document this limitation in the BUGS section of the man page. The
quoting is mostly compatible with that of gmake and smake.

Tested by:	Max Okumoto and Joerg Sonnenberger from DragonFly BSD
Reviewed by:	ru (man page, partly)
2005-01-26 18:19:39 +00:00
Hartmut Brandt
674a77f864 Remove all the cleanup functions. There is no reason to free memory
just before exiting (especially given the number of memory leaks) -
it just costs time.
2004-12-17 13:20:19 +00:00
Ruslan Ermilov
025bfb24c4 Fix a long-standing bug when make(1) is passed the -V and
-f options in MAKEFLAGS environment variable, and some of
these options are also specified on the command line.

Thanks to:	marcel
Reviewed by:	harti
2004-12-16 19:46:50 +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
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
a8b951bb30 Fix breakage introduced on 64-bit platforms with my last commit. Need
to change to size_t in a couple of other places too.
2004-12-03 12:55:57 +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
1734fd27b4 Use typedefs for the types of the functions that are passed as arguments
to the list functions for better readability.

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2004-11-29 12:17:13 +00:00
Hartmut Brandt
ad67400c29 Include sys/sysctl.h on all architectures not only i386. 2004-11-25 12:50:16 +00:00
Juli Mallett
fb339f7a6d Gentle code cleanup for the maximum make(1) level foo. This moves it to a
function, and moves the related defines out of the middle of code body.

Submitted by:	Max Okumoto less-than okumoto at ucsd dot edu greater-than
2004-11-24 22:03:45 +00:00
Hartmut Brandt
33ece31cca Eliminate the define for POSIX and build with Posix behaviour.
Our make has been build with POSIX enabled from the first day
and the ifdef'ed out code served no purpose.
2004-11-17 11:32:46 +00:00
Poul-Henning Kamp
112807ca28 If -B is specified to get compat mode (as opposed to just not giving
a -j arg which does the same thing), remove the MAKE_JOBS_FIFO
environment variable so we decouple any resulting sub-makes from
the token pool.
2004-11-12 20:37:27 +00:00