Commit Graph

191 Commits

Author SHA1 Message Date
sjg
ec98624792 Fix parsing of SUNSHCMD style :sh = assigments.
Submitted by: Will Andrews at freebsd.org
2013-08-28 21:56:49 +00:00
sjg
7f708505a0 ParseGetLine: don't treat a zero byte as end of buffer if P_end says it isn't.
Consume up to next newline, and issue a parse warning.
If no newline found before P_end, carry on as before.
2013-08-10 21:20:03 +00:00
sjg
339d4acb06 Fix use after free bug.
Parse_SetInput:
curFile->fname was using the buffer passed to it - which ReadMakefile frees.
This change makes the comment in ParseEOF about leaking curFile->fname true.
2013-06-18 19:31:27 +00:00
sjg
cb29a22065 ParseGmakeExport: terminate variable at '=', or setenv(3) will fail
on some systems.
2013-03-22 16:07:59 +00:00
christos
ed82ee44b4 Add a .STALE special target that gets invoked when dependency files contain
stail entries.
2013-03-05 22:01:43 +00:00
christos
a11ae36917 Keep track of the location where a dependency is defined, so we can report
about it.
2013-03-05 02:04:10 +00:00
joerg
b1e1b1d4c2 Replace __dead, __unused and the various printf format attributes
with versions prefixed by MAKE_ATTR_* to avoid modifying the
implementation namespace. Make sure they are available in all places
using nonints.h to fix bootstrap on Linux.
2012-06-12 19:21:50 +00:00
sjg
845789be8d Restore previous behavior - supressing duplicate entries in
.MAKE.MAKEFILES - it is more efficient.
2012-04-24 20:12:16 +00:00
sjg
7a49f6a73f Fix some typos in/around ParseGmakeExport.
Remove the suppresssion of duplicate entries in .MAKE.MAKEFILES
2012-04-20 05:33:41 +00:00
christos
3ba1aa3bc8 Add a gmake inspired export command 2012-03-31 00:12:24 +00:00
sjg
006e190034 Avoid the need to escape the # in :[#] when parsing conditionals. 2012-03-24 20:28:41 +00:00
christos
f0528cf595 add debugging for parsedir and parsefile 2011-11-06 19:46:56 +00:00
plunky
9f61b80465 NULL does not need a cast 2011-08-31 16:24:54 +00:00
dsl
c5191c6734 If a makefile if a multiple of the page size and doesn't end with a
newline, then it all goes horribly wrong when make tries to terminate
the last input line.
This was all ok before the mmap changes (rev 1.169) because the last
32 bytes of the input buffer were never read into.
The non-mmap case has a similar problem.
Bug found because my .depend files don't have a newline at the end of
the .OPTIO|NAL line (don't know if that is a local change).
2011-05-17 21:56:51 +00:00
nakayama
c09c2a7b34 Fix build on Solaris 10. 2011-03-03 14:53:01 +00:00
joerg
bfc4d64e8a Use the current directory at start time for .PARSEDIR, if the filename
contains no /.
2011-02-20 23:12:09 +00:00
dholland
51eafd380d Remove the extra blank line after "Fatal errors encountered -- cannot
continue". This has been there since 1.1 but I don't think it was
intentional. If anyone actually cares about the blank line being there
for some reason, go ahead and revert this change...
2011-02-20 20:17:35 +00:00
dholland
90b9a73922 Remove stray extra newline in error message. 2011-02-20 20:15:36 +00:00
dholland
626c509661 erm. fix previous... 2010-12-25 21:39:11 +00:00
dholland
ad5f4cbc2e Maybe fix a problem that appeared on loonix. 2010-12-25 20:46:18 +00:00
dholland
e05b408d55 Uses stat; needs sys/stat.h. No idea what's pulling it in implicitly on
NetBSD so I didn't notice. Woops. Noted by Kurt Schreiner on current-users.
2010-12-25 17:19:04 +00:00
dholland
3f9d98c828 Begin cleanup of the make parser: separate out the logic for reading files
from the parsing goo. This will now use mmap for reading if it works and
fall back to read only for pipes and such. Step 1 of a cleanup program
proposed without objection on tech-toolchain.
2010-12-25 04:57:07 +00:00
dholland
75724edb45 typo in comment 2010-12-13 05:01:56 +00:00
dholland
a0bf60f562 Tables used by parser logic should be const. 2010-12-13 03:36:39 +00:00
dholland
0b6f5dd2c0 Remove stray extern definition that's already in jobs.h. 2010-12-13 03:35:13 +00:00
dholland
460acf6f5e Cosmetic: declare types before variables, group variables by role,
update some comments, format comments properly, etc. No functional
change intended.
2010-12-13 03:32:25 +00:00
sjg
4db43f7e0c Add meta.c which implements "meta" mode for make.
In this mode, a .meta file is created for each target, capturing
the expanded commands used, any command output, and if filemon(9)
is available, a record of system calls which are of interest.
Not enabled unless USE_META=yes is set when building make.
Also, if FILEMON_H exists, meta.c will be compiled to use filemon(9).
2010-09-13 15:36:57 +00:00
sjg
3e3df25ba3 Don't missinterpret targets that start with .info 2010-05-24 21:04:49 +00:00
sjg
b4a3c0bec3 fflush stdout, before writing to stderr. 2010-04-29 23:12:21 +00:00
sjg
dc03377f35 Process .ERROR the same as .BEGIN, .END etc
so that it cannot be the default target.
Add unit-tests for .info - .error, and .ERROR.
2010-04-08 17:41:29 +00:00
sjg
b6e2a6c85f Add:
.error "message"
.warning "message"
	based on FreeBSD implementation.
	add .info while were at it.

.ERROR:	a target to run on error.
	We pass the failing GNode to PrintOnError so it can set
	.ERROR_TARGET.

.MAKE.MAKEFILE_PREFERENCE
	As a means to control make's list of prefered makefile names.
	(Default: "makefile Makefile")

.MAKE.DEPENDFILE
	Names the file to read dependencies from
	(Default ".depend")

.MAKE.MODE
	Processed after all makefiles are read.
	Can put make into "compat" mode (more to come).

Fix:

compat.c: Error code should not be sent to debug_file.
Make_DoAllVar: use DONE_ALLSRC to avoid processing a node multiple times.
ReadMakefile: we can simply use doing_depend to control setting MAKEFILE.
2010-04-07 00:11:27 +00:00
sjg
f3c8b50aa4 Add .unexport - the exact opposite of .export
and .unexport-env which unexport's all previously .export'd globals
as well as clearing environ[].
Allow's sys.mk near total controll.

Reviewed by: apb
2009-11-19 00:30:24 +00:00
dsl
c85c5e109a Report lines that ought to contain a ':' operator but start with a '.'
as "Unknown directive" sinze they are more likely to be .elseif (etc).
Lets me close PR/37222!
2009-11-06 20:20:56 +00:00
sjg
baca35f4e0 The parser used to break dependency lines at ';' without regard
for substitution patterns.  This (perhaps coupled with the
new handling of .for variables in ${:U<value>...) caused interesting
results for lines like:

.for file in ${LIST}
for-subst:       ${file:S;^;${here}/;g}

add a unit-test to keep an eye on this.
2009-10-07 16:40:30 +00:00
dsl
0cbb4ab551 Change 'ClientData' to 'void *' so that relevant parameters can
be made 'const void *'.
2009-01-23 21:26:30 +00:00
dsl
e9eac4d91e Parse_Error() really doesn't need to cruft up a dummy structure for curFile.
It only needs the 'fname' and 'lineno' fields - so just use NULL/0 when
curFile is NULL.
2009-01-16 20:50:24 +00:00
dsl
40aa52653a Instead of stashing the body of every iteration of a .for loop, pass
Parse_SetInput() the name of a function to get the loop data blocks.
This should only be a change to the program logic.
2009-01-11 15:50:06 +00:00
dsl
a4f183d445 Fix PR bin/1443 properly!
Ignore '=' and ' ' inside {} and () when looking for an assignment operator.
Also require the operator be immediately after any whitespace.
XXX mismatched (){} in variable modifiers will not DTRT.
2009-01-08 21:12:09 +00:00
dsl
2aeb32481a Count () and {} when looking to the '=' that terminates the variable being
assigned to.
Should fix:  A.${B:S/=//} = c
2009-01-04 20:17:36 +00:00
dsl
8a143811b9 Use NULL instead of -1 cast to the relavant type (usually via NIL).
This was a suggestion from christos - so blame him if there is a deep
reason for using -1 :-)
2008-12-13 15:19:29 +00:00
dsl
6cb9ef7eef Split For_Eval() into two functions.
For_Eval() is now only called for the first line of a .for.
For_Accum() is called for the subsequent lines.
Stops any problems with forLevel being left invalid after an error.
Use a return value of -1 from For_Eval() to mean 'skip input line' to stop
a .for line with a syntax error being reparsed by make.
2008-11-29 17:50:11 +00:00
apb
39e209a580 intFile.fd should be initialised to -1, not 0. 2008-11-12 15:56:57 +00:00
christos
f7d6936d24 avoid using c99 struct named initializers because this is a host tool and
needs to be compiled by a host compiler which might not be c99 compliant.
2008-11-12 15:45:32 +00:00
sjg
16d084a837 If Parse_Error is called after curFile is invalid, set it to a dummy
to avoid seg-fault.  Also the NULL filename will cause ParseVErrorInternal
to skip trying to report file and line number info.

If CondToken is called outside the context of a .if etc, variables in
the expression being parsed will already be expanded, so allow for
an unqouted number to jump us back into the compare logic.
This allows ${${SomeNumber:U42} > 0:?True:False} to work anywhere.

Job_Finish should process postCommands if it has commands or children.
2008-10-29 15:37:08 +00:00
joerg
bd681a4d7e Don't use emalloc and friends directly, but call them consistently
bmake_malloc and friends. Implement them via macros for the native case
and provide fallback implementations otherwise. Avoid polluting the
namespace by not defining enomem globally. Don't bother to provide
strdup and strndup, they were only used for the estrdup and estrndup
comapt code.

This addresses the presence of emalloc in system libraries on A/UX and
resulted strange issues as reported by Timothy E. Larson.
2008-10-06 22:09:21 +00:00
christos
9f1edc04f7 PR/38840: Pierre Pronchery: make crashes while parsing long lines in Makefiles 2008-06-03 13:02:28 +00:00
christos
a686e4e754 back all changes out until I fix it properly. 2008-02-15 21:29:50 +00:00
christos
2b28370627 - use pid_t/size_t as appropriate instead of int.
- use %ld to print pids.
- fix a bit of lint.
- WARNS=4
2008-02-14 22:11:20 +00:00
dsl
6a6b0fc96a When we extend the buffer used to read makefiles (in order to read lines
longer than 32k) remember the new length so we DTRT for lines longer than 64k.
Should fix PR/37684
2008-01-03 22:14:53 +00:00
sjg
401ecd47f5 Allow .PATH<suffix> to be used for .include "". 2007-10-22 15:36:13 +00:00