Commit Graph

1105 Commits

Author SHA1 Message Date
dholland
ad5f4cbc2e Maybe fix a problem that appeared on loonix. 2010-12-25 20:46:18 +00:00
dholland
f8d6aa2c68 Many C libraries don't set errno when malloc fails, so always use
strerror(ENOMEM).
2010-12-25 20:35:25 +00:00
dholland
305d151446 Improve confusing error message when getcwd() fails. 2010-12-25 20:34:08 +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
sjg
b3f04f7310 Invalidate meta_fname when we finish a job, so that in compat
mode, we do not report a previous .meta file as being involved
in an error.
2010-12-15 23:03:35 +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
dholland
e8acbf7847 Add const necessary for clean non-native build. 2010-12-13 01:48:50 +00:00
sjg
e2f0bc58ba fix style 2010-12-10 00:37:23 +00:00
sjg
d196fd3962 Need to export LC_ALL=C too 2010-12-10 00:36:33 +00:00
sjg
2550dc933f meta_oodate(): we should track 'latestdir' on a per process basis.
Also, only consider target out of date if a not-found file is outside
'CWD'.  Ignore anything in "/tmp/" or tmpdir.
2010-12-09 22:30:16 +00:00
christos
24e17e276b From Aleksey Cheusov: Fix unexpected behavior with:
all: test1 test2
test1:
	@echo ${foo::=foo-text}
test2:
	@echo $(foo::=foo-text)
Saying:
nbmake: Unclosed substitution for foo (} missing)
for test 2
2010-12-02 16:46:22 +00:00
christos
8d8e09f9aa add commented out a possible addition that provides $^ like gmake, but
I am not sure if we should add it, since we already have $> for it.
2010-12-02 16:36:55 +00:00
christos
f18b98792f fix typo (thanks simon) 2010-11-27 16:00:09 +00:00
sjg
1b59e5d011 When a source file moves, make will ignore the stale dependency,
but if the file in question is one that needs to be compiled (.c or .cc),
it still hands the bogus name to the compiler.

If Dir_MTime() cannot find such a file (gn->iParents is not empty),
see if the basename can be found via .PATH, and if so set gn->path to
the found file.   This prevents the stale path being given to the
compiler.

In meta_oodate(), if a referenced file no longer exists, consider the
target out-of-date.

Also, if meta_oodate() decides a target is out-of-date, and it
it uses .OODATE in its commands, we need .OODATE recomputed.
Undo our call to Make_DoAllVar() so that the call from Make_OODate()
will do the right thing.
2010-11-27 05:02:35 +00:00
christos
f8063a37d7 check for NULL before de-referencing. 2010-11-26 15:14:29 +00:00
christos
d670c5cfeb Instead of keeping around the mtime of the youngest child, keep a pointer
to it, so that we can print it when we do the out of date determination.
2010-11-25 21:31:08 +00:00
wiz
218cd6edd9 Remove trailing spaces, add a few serial commas. 2010-09-14 11:57:03 +00:00
sjg
e7543dc43a tools/make/buildmake.sh compiles *.c, make sure meta.c does nothing
unless USE_META is defined.
2010-09-13 21:31:59 +00:00
sjg
796c4b0282 We do not need filemon(9) to have a .meta file 2010-09-13 20:34:21 +00:00
sjg
c0dfab6508 Bump date 2010-09-13 16:32:00 +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
5bc2a55818 In jobs mode, if we cannot make a target we die without any further
clue.  Call PrintOnError() before DieHorribly().
2010-08-07 21:28:40 +00:00
sjg
55b9a99afa wait[pid]() is called in several places.
If we encounter an error and run the .ERROR target, we may
reap a pid which jobs is waiting for.  Ensure that we
cleanup so that make isn't left waiting for an already
deceased child.
2010-08-07 06:44:08 +00:00
christos
703b8bafda PR/43643: David A. Holland: dash prefix broken with make -j
As the comment says in JobPrintJob set JOB_IGNERR with - commands. Fix
whitespace so that the output is consistent, although there are two separate
execution logic implementations (command.c, job.c)
2010-07-20 16:39:27 +00:00
dholland
6b10e71eb2 Revert 1.80, which somehow manages to produce different (wrong)
behavior with -jN. Unfixes PR 43534. Need a different approach...
2010-07-06 03:56:59 +00:00
dholland
a472ed2f77 Document that suffix rules are not applied to PHONY targets, and also
document the .TARGETS builtin variable, which has existed since 4.4 days.
Bump date. Arises from discussion in PR 43502.
2010-06-30 01:03:54 +00:00
dholland
d6bfe606f5 Set .PREFIX early the same place .TARGET is set. This makes sure it's
defined even in cases where the suffix search logic is skipped, such
as .PHONY targets, and fixes PR 43534.

Note: because .PHONY targets do not get suffix searching, .PREFIX will
not have any suffixes removed. This seems vaguely logical, although
it's not the only reasonable interpretation.

We may also want to reconsider whether suffix rules are skipped for
phony targets, too. That behavior is somewhat counterintuitive.
2010-06-30 00:25:04 +00:00
dholland
563d98c883 fix previous, the source isn't exactly crystal clear and there's a bug that
makes the behavior misleading.
2010-06-27 00:53:32 +00:00
dholland
35590dfabc Clarify $(.PREFIX) / $*. Bump date. 2010-06-27 00:06:32 +00:00
sjg
aa86bc2068 JobFinish: call PrintOnError if we detected an error we are not ignoring.
This gives the .ERROR target a chance to run at the first sign of trouble.
2010-06-17 03:36:05 +00:00
wiz
e2a56e055d Whitespace. 2010-06-10 18:35:22 +00:00
christos
801f2ebf67 Explain variable expansion better. Requested by Aleksey Cheusov 2010-06-09 16:58:22 +00:00
wiz
76aa4cd57b Bump date for previous. 2010-06-06 17:28:48 +00:00
sjg
fbb620d711 Add .export-env which tells make to export a variable to the environment
but not to track it - as is done for .export
This allows the variable to be updated without affecting what was put
into the environment.
Older versions of make will simply treat this as .export
2010-06-06 01:13:12 +00:00
sjg
945e78bffe We have required sigaction() for quite a while.
Use bmake_signal() - a wrapper around sigaction()
rather than signal() to ensure that signals are handled
consistently.
2010-06-03 15:40:15 +00:00
sjg
3e3df25ba3 Don't missinterpret targets that start with .info 2010-05-24 21:04:49 +00:00
christos
b724c2d39e put back canonicalization, but avoid doing it for files that don't contain /
From dholland
2010-05-17 17:01:16 +00:00
joerg
3fc43397e7 Drop trailing white space. Use .Oo / .Oc explicitly to annotate that the
empty content is intended.
2010-05-13 18:10:16 +00:00
sjg
21d8983546 PrintOnError: run .ERROR last, so even if it causes problems we
still print MAKE_PRINT_VAR_ON_ERROR.
2010-05-10 15:54:21 +00:00
christos
9612529ef4 Revert bogus patch that attempted to canonicalize a non absolute argv[0] using
realpath(3). Consider: touch Makefile; mkdir make; make. This will set $MAKE
to $PWD/make so further attempts to use ${MAKE} will try to execute the
directory. This needs $ORIGIN to be fixed properly, or alternatively one
can duplicate the logic for execvp(3) and search the path for the make
executable. Not worth it. It was working just fine before!
2010-05-05 14:10:39 +00:00
sjg
25ba15c805 gcc defines __svr4__
SunPro compiler defines __SVR4
We need to check both to ensure that on SunOS signal is hooked into
sigaction - otherwise we do not pass the unit-tests due to missing
a SIGCHLD
2010-05-05 07:05:33 +00:00
sjg
b4a3c0bec3 fflush stdout, before writing to stderr. 2010-04-29 23:12:21 +00:00
sjg
83fb10e649 PR: 42850
Reviewed by:

Reduced the "expected to exist" dirs in path to just
/ /bin and /tmp
and change the "not expected to exist" dir to something
even less likely.
Add a comment to suggest why.
2010-04-23 15:43:28 +00:00
sjg
24157036cd On darwin at least, vfork() fails in child of vfork().
It probably shouldn't work anyway, so avoid this.
We use the macro vFork() - a function seems to cause problems
and is unnecessary overhead.
2010-04-23 00:18:50 +00:00
dholland
d1466497fc Use _PATH_TMP instead of a literal /tmp; noted by Christos 2010-04-22 22:39:13 +00:00
sjg
1870812db3 Force LANG=C to ensure sort(1) behaves as expected 2010-04-22 21:41:11 +00:00
dholland
fb0f75db1f don't use strlcpy; it causes bootstrap issues. (noted by moof) 2010-04-22 20:25:16 +00:00
sjg
7254a559b2 PR: 42850
Reviewed by:

modmisc: since we apply an exists() test to $paths, be conservative
in what we expect.

Run the unit tests with -r -m / so that we do not fail if there
is no sys.mk present.
2010-04-22 19:15:23 +00:00
sjg
a71a4119cf Just because $TMPDIR is set does not mean it is valid.
Add a central function for creating temp files so we have one place to
audit.

Reviewed by: dh
2010-04-22 19:11:17 +00:00
sjg
862d4ff05d If we do .export (all) and have any variables that involve :sh
we will hit an error (var is recursive) while trying to evaluate that.
Fix, and add a unit test for this.
2010-04-21 04:25:27 +00:00
sjg
b7f72d44a7 Behavior of realpath() appears to vary.
To ensure consistent results, use stat(2) as a final check for success.
2010-04-20 17:48:16 +00:00
sjg
197caaa8e0 On some systems realpath will prefix make with cwd, so make sure
we can stat(2) the value for .MAKE
2010-04-20 17:18:08 +00:00
sjg
290b1f00e6 Add :tA to attempt to resolve to absoute path using realpath(). 2010-04-15 03:48:39 +00:00
sjg
9334c6107c If argv[0] is not an absolute path, attempt to resolve it
using realpath() for setting .MAKE
2010-04-14 16:16:17 +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
wiz
6f9ff54b1b Sort a bit more. 2010-04-07 06:45:21 +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
joerg
87faf7cb4f \\ -> \e 2010-02-22 19:20:33 +00:00
dholland
607923e4ca Improve the error message that results when you have a multi-variable .for
and the substitution list doesn't divide evenly.
2010-02-06 20:37:13 +00:00
sjg
03c533138a We need to have set curdir before calling Dir_FindHereOrAbove().
We can call getcwd again if -C is used.
2010-01-04 17:05:25 +00:00
wiz
af753b56d3 New sentence, new line; remove trailing whitespace. 2009-11-19 06:48:37 +00:00
sjg
9772f81de8 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:25 +00:00
sjg
b87966b319 PR: make.unexport
Reviewed by:
2009-11-19 00:30:24 +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
dsl
9e7c371385 Change enum values so that TOK_FALSE is 0 and TOK_TRUE is 1.
Use this fact to remove loads of ? : clauses.
2009-11-06 19:44:06 +00:00
joerg
568625a8d1 Do not work around ancient groff limits with .Xo/.Xc. 2009-10-15 02:27:44 +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
wiz
3c9c8e60ab Remove trailing whitespace. 2009-10-02 07:43:15 +00:00
dsl
b7ab3bd781 Add example of how to use the ?: modifier properly. 2009-10-01 21:40:31 +00:00
sjg
d86fd0848e We must delay setting .CURDIR and .OBJDIR until after MainParseArgs()
in case -C is used - in which case we should also ignore $PWD.
2009-09-09 17:09:49 +00:00
sjg
44c6580dd0 Reviewed by: apb
Use .MAKE.LEVEL to track recursion.
The first instance of make will have .MAKE.LEVEL 0, which
can be handy for excluding rules which should not apply
in a sub-make.
gmake and freebsd's make have a similar mechanism, but each
uses a different variable to track it.  Since we cannot be
compatible with both, we allow the makefiles to cope if they want
by handling the export of .MAKE.LEVEL+1 in Var_Set().
2009-09-08 17:29:20 +00:00
sjg
cd5a3748ef PR: 41998
:Ufu\:goo

should expand to fu:goo even when it appears in :M${:Ufu\:goo}
When scanning for :M do not compress \: if we know we have
to call Var_Subst.
2009-09-07 17:56:23 +00:00
dholland
01f8dc7731 Use the W* macros to test wait results.
(Mentioned by Joerg in chat a few days ago.)
2009-09-03 06:45:23 +00:00
sjg
b69bd507ef Bump date 2009-08-26 23:18:57 +00:00
sjg
3745b729fb Add -C directory, same as gmake and freebsd make. 2009-08-26 23:17:11 +00:00
sjg
dd8e1ba252 JobExec: child of vfork must not empty the sigset_t that parent will
restore.  Use a separate mask.
2009-06-26 01:26:32 +00:00
sjg
39bb2e98a1 Child of vfork() must not alter the state of parent.
There is no need to touch the state of vars in child anyway.
Change 2nd arg to Var_Export1() to indicate if we are the parent or child,
and only set flags in the parent.
2009-06-16 05:44:06 +00:00
sjg
2428caab9f Missing ':' in .ORDER example 2009-06-01 23:28:39 +00:00
wiz
7560090357 Whitespace fix. 2009-05-13 22:56:42 +00:00
lukem
c1ceae17f0 Enable WARNS=4 by default for usr.bin, except for:
awk  bdes  checknr  compile_et  error  gss  hxtool  kgetcred  kinit
	klist  ldd  less  lex  locale  login  m4  man  menuc  mk_cmds
	mklocale  msgc  openssl  rpcgen  rpcinfo  sdiff  spell  ssh
	string2key  telnet  tn3270  verify_krb5_conf  xlint
2009-04-14 22:15:16 +00:00
snj
ab4a318284 Typo fix: many file -> many files. 2009-04-11 15:51:42 +00:00
wiz
8216b2d443 Bump date for previous. 2009-04-11 09:44:22 +00:00
apb
af9429a671 Honour the TMPDIR environment variable instead of always using /tmp
as a place to store temporary files.
2009-04-11 09:41:18 +00:00
perry
08429de660 remove unneeded special rule for main.o 2009-03-24 13:54:37 +00:00
perry
f113e91b18 per dholland, put back MAKE_VERSION for the benefit of third party users. 2009-03-24 13:53:21 +00:00
perry
a24e0ba1bb The Makefile and main.c arranged to put "netbsd-${DATE}" into the
executable. Remove this so that different compiles can be binary
compared. rcsid's for all files are already embedded in the executable
so versions can be easily distinguished. (I didn't catch this on
previous passes because I did my builds on the same day.)

Note: there's a special rule for main.o in Makefile with a purpose I
can't actually discern -- I think it isn't needed, and I've flagged it
with a comment.
2009-03-20 20:48:00 +00:00
christos
0efea3414c use progname instead of getprogname() for portability. 2009-03-18 22:02:49 +00:00
christos
20ad44cb97 use siginfo to report on the directory we are working on if available. 2009-03-01 01:49:17 +00:00
sno
6adead3ca0 replace c++ style comment by a c-style one 2009-02-25 21:17:21 +00:00
dholland
1fc98979b6 Use pid_t for the result of fork and wait. PR 38031 from Ryan Stutsman. 2009-02-22 07:33:00 +00:00
christos
a5e73ebace adjust patch to current. 2009-02-18 21:06:47 +00:00
christos
ca9294c412 CID 5044: Protect against NULL deref. 2009-02-18 20:08:32 +00:00
sjg
55d9c66506 Update expected results to match recent changes! 2009-02-03 23:11:12 +00:00
dsl
efe788379e Rename all the members of 'enum Token' to TOK_FOO.
Makes it rather more obvious wherethey belong - especially since
two of them were 'True' and 'False' (and not 1 and 0 either).
2009-01-30 23:07:17 +00:00
dsl
9c773fc1c6 Treat .ifdef ${foo} as .if defined(${foo}) not .if "${foo}" != "".
(and similarly for the other .ifxxx).
Do comparison against "" or 0 for .if "foo" and .if <numeric> directly
instead of faking up the operator string.
Rename error: to done: and use it for more exit paths.
Elucidate and correct some comments.

Fixes problems with makefiles that do:
.for var in var_1 var_2
.ifdef ${var}
...
which used to check whether var_1 was defined - because the .ifdef saw the
literal var_1, not a variable expansion due to the way .for loop variables
were substituted.
2009-01-30 22:35:10 +00:00
dholland
7f999162b5 Fix flagrantly wrong printf formats in compat strftime. 2009-01-29 09:03:04 +00:00
enami
ca3f8e6df1 Avoid infinite loop. 2009-01-29 07:48:39 +00:00
dsl
530cac2556 Allow for () in the argument to .ifdef et al.
Save/restore current values of global data across expression evaluation
to give ${foo:? ...} a change of working inside another .if.
2009-01-28 21:38:12 +00:00
dsl
b294f6c2a3 Fix sense of MAKE_NATICE test. 2009-01-24 23:19:50 +00:00
dsl
4802ea584f Add #ifndef MAKE_NATIVE around __RCSID 2009-01-24 23:07:48 +00:00
dsl
97347d2cbb Fixes to includes of make_malloc.h to that it actually builds when
USE_EMALLOC is undefined.
Fixes earlier fixes :-)
2009-01-24 14:43:28 +00:00
cegger
9fde1a673e buildfixes for OSX:
- include <sys/types> for size_t
- progname is undeclared
- include <string.h> for string functions like strlen()
- include <errno.h> for errno
2009-01-24 13:06:16 +00:00
wiz
6942778bea Sort sections. Fix typo (last line). 2009-01-24 13:02:33 +00:00
cegger
e6227c556c buildfix: remove RCSID. It conflicts with the definition in the .c files. 2009-01-24 12:59:51 +00:00
dsl
4fb693c12c Move the bmake_malloc() functions into their own .c and .h files.
Include instead of make.h in a few places.
2009-01-24 11:59:39 +00:00
dsl
5d04927c08 Correct the definition of the :? modifier - in particular the modifier
applies to the variable name, not its value!
Remove the set of examples that were recently added that failed to
explain why some worked and some didn't.
Add a not to the compatability section about the change in .for loop
substitution post 5.0.
Add a BUGS section.
XXX the BUGS section needs more entries :-)
2009-01-24 11:56:41 +00:00
dsl
a1e84ff783 Don't cast 'time_t' to 'void *' and back it will lose precision. 2009-01-24 10:59:09 +00:00
dsl
86df0d691f Sprinkle some const.
In particular for Lst_Find() and Lst_FindFrom().
Remove some unneeded casts and some now-undeeded UNCONST().
2009-01-23 21:58:27 +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
d6c81d7cf1 There is no point in saving the last character of a NUL-terminated
string in order to overwrite with a NUL, then restore the original value!
Remove and simplify the CondDoFoo() functions.
2009-01-23 20:22:50 +00:00
dsl
60ec4ca26f Revert previous - cause grief with .ifdef (foo)
Instead return False for exists(), defined(), make() etc when the
argument has length zero.
2009-01-18 17:30:19 +00:00
dsl
bae3fcc0c3 Only terminate a conditional function argument on ')' if we expect the
argument to be exclosed in (...).
'.if exists()' is parsed as '.ifdef exists()' and the ')' must not be
left over at the end.
I have no idea why any of my recent changes have affected this.
But pkgsrc/mk/compiler/gcc.mk (line 488) does .if exists(${FCPATH})
even though FCPATH is only set when the file exists.
2009-01-18 12:50:15 +00:00
lukem
ab93b4bc61 fix -Wsign-compare issues 2009-01-18 01:31:12 +00:00
dsl
18e81da746 __predict_false() isn't defined if we aren't netbsd, stub out. 2009-01-17 13:55:42 +00:00
dsl
462d090d0f Change 'Buffer' so that it is the actual struct, not a pointer to it.
Saves having to malloc/free a fixed size structure.
Buf_Init() now takes ptr to Buffer to initialiase.
Change Buf_Destroy() to return ptr to string when not freed.
Remove large number of casts to (Byte) and (Byte *) - 'Byte' is 'char' here.
Buf_AddByte[s] guarantees that the data is 0 termininated, so never add '\0'.
Keep 'count' not 'left' and 'inPtr', code is simplier with only one update.
Fix fallou, no functional change.
2009-01-17 13:29:37 +00:00
dsl
d020c6ab24 Allocate string vector in chunks, instead of calling realloc()
every time something is added.
2009-01-16 21:15:34 +00:00
dsl
74a68f7259 Debug print improvements. 2009-01-16 21:14:30 +00:00
dsl
cd6806d831 Send output of Error() to debug_file (unless stderr/stdout). 2009-01-16 21:13:13 +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
ac3b504aef Contrary to my previous thoughts, .for loop variable values do contain
variable references - eg ${.TARGET} since that can't be expanded earlier.
Also the variable gets re-expanded before modifiers are applied.
All this means that we do need to let :U expand variables and must not
just escape $.
2009-01-14 22:54:10 +00:00
dsl
be588a30bc When substituting .for control variables (as ${:U...}) escape '$' and '\'
as well as ':' and '}' or ')'.
The parameters have just been expanded (and will be expanded again) later
so don't need expanding as part of the :U process.
Seems to fix pkgsrc breakage at line 34 of bsd.pkginstall.mk doing:
.for i in ${PKG_USERS}
_PKG_VARS.pkginstall+=  PKG_UID.${u} PKG_GECOS.${u} PKG_HOME.${u} PKG_SHELL.${u}
.endfor
when PKG_USERS = ${AVAHI_USER}:${AVAHI_GROUP}::Avahi\ user:/nonexistent
(set at line 41 of the ahavi Makefile)
I really dont think the above has the desired effect!
2009-01-13 18:30:00 +00:00
dsl
54d6432069 Sprinkle a const. (arg of Main_ParseArgLine()) 2009-01-13 18:22:34 +00:00
dholland
dbfa1570e7 Fix blatantly wrong exposition of .WAIT example.
PR bin/40372 from Gao Ya'nan.
2009-01-12 09:28:10 +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
b19182e92b When substituting .for control variables any } or ) that matches the
${ or $( must be \ escaped.
Should fix some pkgsrc issues - eg 'clean' in print/gv.
2009-01-10 16:59:02 +00:00
dsl
aba4927178 Allow the user to save an unsigned int (eg the length or flags) with
each string.
2009-01-10 16:55:39 +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
aee1343f51 In the :M code, 'pattern' is always malloced memory - so unconditionally
free.
2008-12-29 10:18:38 +00:00
dsl
1fc20cc6eb Count both () and {} when looking for the end of a :M pattern.
In particular inside .if empty(...) it was only counting ().
In reality this needs further changes.
This may well fix recent pkgsrc breakage.
2008-12-29 10:12:30 +00:00
christos
644d31b987 if mtime == 0, make it 1 because the code expects 0 time to mean that the
file does not exist
2008-12-28 18:32:54 +00:00
christos
266b18d880 prepare for time_t 64 2008-12-28 18:31:51 +00:00
dsl
e4be9d4f2c Treat '\\' as a possible terminator for a loop control variable.
(Typically an escaped \: of a nested modifier.)
2008-12-23 21:56:38 +00:00
dsl
14bf83b326 Note that an unrecognised word in a .if is the same as in .ifdef and that
such a word has to be white-space separated.
From PR bin/30967 bin/37222 and maybe others!
2008-12-21 21:05:27 +00:00
dsl
f2de2e5cbd Add some notes about recursive expansion and expansion of variable names.
Note that any of "${}()" in variable names will be griefsome!
Remove the example of using ::= to apply a modifier to a .for loop
variable as that is no longer necessary.
Remember to change the date :-)
2008-12-21 19:32:16 +00:00
dsl
6cb006c860 Only escape ':' in the outer level of .for variable substitution.
XXX: like elsewhere this code just counts {( against })
2008-12-21 19:19:55 +00:00
dsl
c2cc9b5595 Change the way .for variables are substituted.
Instead of doing a full substitution giving plain text, just replace the
variable part with something that will expand to the required text - leaving
any modifiers for the later evaluation of the input line.
This stops .for being used as an 'eval' (previously you could generate .if etc)
and also means it is still a variable expansion - which some other parts need
to work in the expected fashion.
2008-12-21 18:06:53 +00:00
dsl
d003f8f69b Don't allow $) $} $: or $$ as variable expansions, they confuse other
parts of make that try to scan through variable expansions.
  (given the make syntax that is all rather doomed anyway!)
Move the check for $\0 to a place where it will be detected - otherwise
  the parser will run off the input buffer!
2008-12-21 10:44:10 +00:00
dsl
899813caea Add functions for processing extendable arrays of pointers to strings.
Use for the .for variables and substution items - changing the latter from
make's all conquering lst.lib functions.
Being able to index everything makes the code simpler.
No functional changes intended.
2008-12-20 22:41:53 +00:00
dsl
e06fc1c61f A lot of code assumes that the pointer returned by Buf_GetAll() is malloced.
Replace Buf_Discard() with Buf_Empty() since the former might leave the
'outPtr != buffer' and the only caller wanted all the data discared.
Remove 'outPtr' now that it always equals 'buffer'.
The assumption about Buf_GetAll()is now guaranteed by design.
2008-12-20 18:08:24 +00:00
dsl
0533dfcd70 Remove the definitions of NIL (now unused) and NULL (defined elsewhere). 2008-12-20 17:42:01 +00:00
dsl
b1e9c7dca0 Set the .for loop control variables in reverse order to avoid faffing. 2008-12-20 17:38:37 +00:00
dsl
03a9360df5 Do not allow Var_Set() or Var_Append() to set the empty variable (which will
now forever remain undefined).
Rework/simplify code to avoid UNCONST().
2008-12-20 17:14:04 +00:00
dsl
b7b48965cc Change some "^I *^I" to "^I^I" and align the comment block about
variable modifiers.
2008-12-20 16:03:59 +00:00
dsl
81b38761ef Delete very splurious 'free(buf)' that xtos added.
Fixes PR bin/40233
2008-12-20 09:42:02 +00:00
christos
6caebc4e79 PR/32154: Roland Illig: brk_string fails to report errors in unquoted strings. 2008-12-19 22:04:36 +00:00
christos
cd056136e4 if brk_string fail, so do we. 2008-12-19 22:03:41 +00:00
christos
1a59b518a0 if brk_string failed, use the shell. 2008-12-19 22:01:19 +00:00
christos
0bf1037e4e PR/34138: Roland Illig: In the non-expand case, fix brk_string not to eat
quotes.
2008-12-19 21:34:14 +00:00
christos
9faa233ea6 add a little more debugging. 2008-12-19 21:33:10 +00:00
dholland
ee1b2317fb fix typo in comment 2008-12-13 18:11:53 +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
40e0ab7a8f Do not let the variable name "" be set from the command line (-D "")
or from ::= modifiers (${::=foo}).
2008-12-13 14:26:10 +00:00
christos
c6121a89c8 explain compatibility mode better. 2008-12-07 16:10:34 +00:00
christos
6694d6b5ac add debug flag for cwd. 2008-12-07 04:50:15 +00:00
dsl
f8be892cab Correct some comments. 2008-12-01 21:05:21 +00:00
christos
132080e4f9 fix off-by-one allocation. functional change intended... 2008-12-01 19:35:55 +00:00
dsl
1e7b0ea1a2 Simplify somewhat the code that parses .for lines.
Use malloc to allocate space for teh strings (instead of a buf structure)
to make it mossible to not leak the associated memory (leak not fixed!).
No functional change intended.
2008-11-30 22:37:55 +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
dsl
34a8d95d66 Before deciding to use the default function in a .if, check whether the
token that follows the argument might be '==' or '!='.
If so then treat as a string comparison instead.
Fixes bin/15233 and bin/30967 provided some whitespace is present.
".if A==A" remains a check for defined(A==A) since make places no
restrictions on the names of variables!
2008-11-29 14:42:21 +00:00
dsl
b8ee15c2f2 Common up parsing .if defined() make() exists() target() commands() and empty()
Add a check for the '(' following the function name, if absent then treat
as if the function name is unknown - usually leading to a syntax error.
No other functional changes intended.
2008-11-29 14:12:48 +00:00
wiz
b410c46dc5 I think ':' is called "colon", not "column" :) 2008-11-26 19:08:05 +00:00
christos
53200e2e77 PR/40026: Aleksej Saushev: make(1) doesn't document VPATH, document it. 2008-11-25 20:34:19 +00:00
dsl
19426b3536 Do a string compare if the rh argument doesn't completely convert to a number
(instead of silently ignoring the chars that failed to convert).
Use strtoul() instead of homebrew copy.
Only use strtod() if strtoul() fails because the value is too large or
contains '.', 'e' or 'E'.
Do a compare for strings that start '-' or '+' as well as digits.
2008-11-23 10:52:58 +00:00
dsl
83146d79d6 Fix conversion of hex numerics in comparisons.
Broken by a fix from christos 14 years ago.
2008-11-22 23:42:16 +00:00
dsl
1d48e86ec4 Move two great chunks of code out of a switch statement and into
separate functions.
No functional change.
2008-11-22 18:47:47 +00:00
dsl
8ea16b81f0 If there is a syntax error in a .if expression then ignore the entire
conditional block (ie down to the matching .endif) instead of passing
the input line back to the normal parsing code.
Do the same if the maximum .if nesting (64 levels) is breached.
2008-11-22 18:05:13 +00:00
dsl
feafbbe6e5 Convert ADDWORD() to do { ... } while (0) 2008-11-22 17:34:56 +00:00
dsl
66da2b26ce Convert Buf_AddByte(0 to a more normal do { ... } while (0) form. 2008-11-22 17:33:57 +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
christos
79988dffe4 Don't use putenv() because it is not portable. 2008-10-31 17:42:14 +00:00
wiz
8d19dcbd2b Whitespace. 2008-10-30 08:44:18 +00:00
sjg
9bb1d7525f Update the modification date 2008-10-30 00:40:42 +00:00
sjg
b3afe166ae Add some examples of how to use :? 2008-10-29 23:30:08 +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
apb
f46c1de7cb Use ${TOOL_SED} instead if plain sed in Makefiles. 2008-10-25 22:27:34 +00:00
apb
675ed64522 Send debugging output to stderr by default, not to stderr.
If you really want debugging to stdout, specify "-dFstdout"
in MAKEFLAGS or on the command line.

Discussed in tech-userlevel.
2008-10-22 15:04:49 +00:00
wiz
bcb1e574cb Add missing dot before macro. 2008-10-19 16:59:08 +00:00
apb
3bf9f42fd4 Always make the debugging output unbuffered; in addition, if debugging
is enabled but debugging output is not directed to stdout, then make
stdout line buffered.

Previously, the code to make debug output unbuffered applied only if
debugging to a file, not if debugging to stdout or stderr.  Making
stdout line buffered when debugging was suggested by Steven Bellovin.
2008-10-19 08:30:10 +00:00
apb
56ce706140 Document how "-dF[+]filename" works. 2008-10-18 14:36:40 +00:00
apb
1dd3e3655e Allow optional "+" in "-dF[+]filename" even if the filename is "stdout"
or "stderr".  Previously, the "+" was alowed only for real file names,
but it's easier to write the documentation if the "+" is always allowed.
2008-10-18 14:35:32 +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
wiz
6ae5b86a80 Drop trailing whitespace. Use .Dq. 2008-08-10 23:25:50 +00:00
cube
dda0645b09 Clarify a bit .SUFFIXES and .IMPSRC. Should fix PR#37822. 2008-08-10 19:47:29 +00:00
joerg
f45c989c53 Micro-optimise VarQuote by exploiting that meta characters are normally
rare and skipping over normal characters with strcspn is therefore
faster. Further simplify logic by always setting newline and precompute
the size of the string.

OK christos@
2008-07-31 15:19:19 +00:00
joerg
2ad045d932 Meta characters are a constant, mark it so. 2008-07-31 14:59:39 +00:00
lukem
98e5374ccb Remove the \n and tabs from the __COPYRIGHT() strings.
Tweak to use a consistent format.
2008-07-21 14:19:20 +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
8567cf00de PR/38756: dominik: make dumps core on invalid makefile 2008-05-26 14:29:55 +00:00
sjg
f2c43a72d5 VAR_CMD context is used by conditionals and other purposes, so
actually set VAR_FROM_CMD when appropriate and only skip setting in
VAR_GLOBAL when that flag is set.
2008-05-15 21:05:54 +00:00
sjg
db7f6ac403 Disable this for now, VAR_CMD is abused for other purposes... 2008-05-15 18:25:12 +00:00
sjg
20275ee931 Do not set vars in VAR_GLOBAL context, if they have been set on the
command line.
Add a suitable unit-test.
2008-05-14 14:27:02 +00:00
martin
ce099b4099 Remove clause 3 and 4 from TNF licenses 2008-04-28 20:22:51 +00:00
sjg
98deadff04 If the name passed to Var_Exists contains '$' run it through Var_Subst. 2008-03-31 00:12:21 +00:00