Commit Graph

178 Commits

Author SHA1 Message Date
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
christos a59b81d6d8 strlen returns size_t 2007-10-13 18:28:35 +00:00
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 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
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
dsl 1752887780 Delete some comments that refer to long-extinct code. 2007-05-23 19:03:56 +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
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
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