Commit Graph

969 Commits

Author SHA1 Message Date
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