Commit Graph

1014 Commits

Author SHA1 Message Date
nakayama
c09c2a7b34 Fix build on Solaris 10. 2011-03-03 14:53:01 +00:00
sjg
4fab365c37 Fix rendering of :? example 2011-02-26 01:17:24 +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
sjg
0734782fbf Mark unused args. 2011-02-13 21:24:42 +00:00
sjg
8bb1fe5d14 When making a target that involves creating itermediate dirs,
realpath() will fail until after those dirs exist.
Try to ensure the same meta file name is used regardless.
2011-02-13 21:22:41 +00:00
sjg
8d31de3127 tmplen should be static 2011-02-08 05:29:13 +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
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