Commit Graph

494 Commits

Author SHA1 Message Date
sommerfeld dd9c50102d Fix token accounting for .BEGIN/.END jobs 2000-12-30 15:58:34 +00:00
sommerfeld 663ff035b1 Avoid token leaks when aborting after an error. 2000-12-30 14:21:22 +00:00
sommerfeld 129b8c6309 strdup tracefile so that it doesn't get smashed. 2000-12-30 02:52:03 +00:00
sommerfeld 9984263e63 Do lazy token release - don't return tokens to the pipe unless we're
waiting for something or we're done.
2000-12-30 02:51:21 +00:00
sommerfeld 8a39635d34 Back out debug cruft. 2000-12-30 02:06:42 +00:00
sommerfeld a804073cac Add a token-passing scheme to allow a recursive make to successfully
use -j; all make's in a recursive build cooperate to limit the total
number of jobs, using a token-passing scheme.

The current token passing algorithm is similar to the one implemented
by gmake; there is a single pipe which is inherited through the entire
process hierarchy; tokens are obtained by reading a byte from the
"read end" of the pipe, and are returned by writing them to the "write
end".  This exact algorithm is likely to change in the future.

Implementation details:
 - Use the new trace facility to allow measurement of the
effectiveness of different token-passing schemes
 - Get a token in MakeStartJobs(), return it in Make_Update()
 - Eliminate Job_Full() and the jobFull global since they are
redundant with token system.
 - Add an "internal" -J option (to pass the token pipe fd's down to
submakes) and a -T option for tracing.
 - Change how compatMake is forced so that -j means something when
inherited by submakes.
 - When waiting for a token, poll the token-passing pipe as well as
the output pipes of existing jobs.
2000-12-30 02:05:20 +00:00
sommerfeld 694b899b9c Quick and dirty trace mechanism to make it easier to look at how different
parallel make job distribution algorithms work in practice.
2000-12-29 23:11:08 +00:00
mycroft b91d3efb9a Make the fds[] realloc O(n). Also make the rethreading a lot simpler. 2000-12-05 21:57:20 +00:00
sommerfeld e65a50bf34 Boolean consistancy (use TRUE, not 1) 2000-12-05 17:07:01 +00:00
sommerfeld e3f68e5130 Make clearfd() take O(1) time instead of O(N) by moving only the last
job in the arrays to the hole made by the now-dead job.  No
measureable performance difference for -j4, but the code is simpler
this way.
2000-12-05 15:28:55 +00:00
sommerfeld b5e2403ec9 correct performance regression of recent change from select() to
poll() for parallel make:
 - Make the poll() code behave more like the select() code: sleep for
a bit waiting for output rather than busy-wait (eww).
 - Install a no-op SIGCHLD handler so that poll/select wake up early
(with -1/EINTR) when a child exits.
 - Change the default sleep time from 500ms to 5 seconds since we now
wake up promptly when a child exits.
2000-12-05 15:20:10 +00:00
christos fd8f9c7b9f oops forgot to commit this one. 2000-12-04 20:13:29 +00:00
christos 8ba1720b96 mycroft did not like my O(n^2) lookup algorithm, so I made things much
more complicated.
2000-12-04 17:45:17 +00:00
christos 105cc20925 1. switch to using poll by default; can be overriden by compiling with
-DUSE_SELECT
2. make sure that we don't overrun our allocated fd_set if USE_SELECT is defined
2000-12-03 02:19:32 +00:00
christos 709d0cf4cb add noreturn attribute to the functions that need it. 2000-12-03 02:18:14 +00:00
christos 9a19da76d7 1. the tfile patch was incorrect. If we are doing multiple jobs, we
try to open tfile many times, passing bad strings to mkstemp
2. remove extra semicolon after the MESSAGE macro
3. more error checking
4. be more careful about setting things to NULL after freeing.
5. fix a comment that does not apply anymore
2000-12-03 01:27:03 +00:00
christos 6a9332cff1 use 6 X's instead of 5 for portability. 2000-12-03 01:18:15 +00:00
is 135600f947 More format string cleanup by sommerfeld. 2000-10-11 14:46:00 +00:00
christos 89d34c0b70 fixed comment U -> u 2000-09-05 21:08:35 +00:00
christos 73e15c3ea3 :u modifier a'la uniq(1) [from der Mouse] 2000-09-05 17:57:52 +00:00
christos a9e7fd9028 don't attempt to free varNoError too. 2000-08-13 22:47:01 +00:00
christos e8b09532bb PR/10714: SUNAGAWA Keiki: Add newer hpux support, but without removing the
old hpux support.
2000-08-03 15:53:24 +00:00
mycroft d53a63dfff Use a lower threshold for rebuilding hash tables. 2000-06-11 07:54:32 +00:00
mycroft 796fb2ec8c Readd optimization last night. Problems earlier were partially due to the
arguments names on one function being swapped (by a previous author).

Do not do any duplicate suppression when a source list is created.  Instead:
* OP_MADE protects against trying to make the source multiple times.
* A new OP_MARK flag is introduced to suppress duplicates while expanding
  the .ALLSRC variable and .USE targets.
This turns the O(n^2) insertion into O(n) in most cases.

This is tested with a `make build' and some special test cases.
2000-06-11 07:39:52 +00:00
mycroft 83660a50d9 Back out last night's optimization for now. 2000-06-10 22:28:33 +00:00
mycroft 04af209e45 Don't use OP_MARK when attaching suffix transformations. 2000-06-10 22:24:21 +00:00
mycroft edfd0106e2 Introduce an OP_MARK bit, and use it to suppress duplicates during .ALLSRC
and .USE expansion.  Also, remove some more Lst_Member() checks that are now
redundant.
2000-06-10 21:44:08 +00:00
mycroft 83f22c12ea Nuke an `optimization' that made source list creation O(n^2). This may cause
more memory to be used with stupid Makefiles, but it saves a fair amount of
time (~13% just for libc) with sane ones.
2000-06-10 13:48:48 +00:00
sjg 70fc6bfcaf no need for v->name-- on JUNK vars anymore 2000-06-10 05:54:29 +00:00
mycroft b0d51d4783 For VAR_JUNK variables, defer freeing of the name string until the bottom of
Var_Parse(), as it may be used (strdup()ed) by some modifiers.
2000-06-10 04:51:00 +00:00
sjg 5d93c6ecfd Don't free v until after the last use. 2000-06-10 04:17:58 +00:00
mycroft 6bf47769cb Do some evil with VAR_KEEP to make it happier. This seems... wrong. 2000-06-06 09:00:49 +00:00
mycroft 39bf056eb6 Allow further patterns after a :D or :U, as in ODE make. (Copied some code
from VarGetPattern.  It should become more flexible instead.)
2000-06-06 08:44:57 +00:00
mycroft 123757193a Roll back my for-expansion changes. Doing this right is just too hard to be
worth it.
2000-06-06 04:56:52 +00:00
sjg 3d93bb57a6 Check_Cwd_av: Ensure that word after a '(', '{' etc is considered a command,
so that we spot the cd/chdir and don't put one in.
2000-06-06 03:00:11 +00:00
sjg 2293fdd17b Make ::= work again with the VAR_FOR context changes. 2000-06-01 09:39:02 +00:00
mycroft ea218bb6e9 Create a `for' context, and substitute iteration variable from it using the
normal Var_Parse() path.  This allows :R, etc. to work on iteration variables.
2000-06-01 04:16:39 +00:00
sjg cd8908a299 Rats! ${FOO:=bar} is a common usage of the SysV = modifier.
To avoid that, we now do ::[+?!]*= but the SysV = modifier can
conflict with any new modifier.  At there are currently no Makefiles
in our tree that use ${FOO::=bar}
2000-06-01 02:29:21 +00:00
sjg 339f702f71 Implemented a set of assignment modifiers. These solve obscure
problems such as using modifiers on .for loop iterators derived from
local variables (eg .TARGET).
Unless the variable already exists in a global context, these assignments are
local to the current context (this is usually what is wanted).
2000-05-30 02:32:21 +00:00
sjg 489a59f8c6 Expand variables that appear in a [No]Match pattern. Allows
[ x${DONE:M${.TARGET}} != x ] || blah
2000-05-14 15:14:41 +00:00
sjg 214b560694 allow .POSIX to define %POSIX as in FreeBSD 2000-05-11 08:22:40 +00:00
sjg edfc5b4270 Expand variables in variable name passed to Var_Set and Var_Append.
This allows ${FOO}.bar=fubar etc to work.
This does not impact any Makefiles in the current tree but allows
some cool magic (which I need elsewhere).
2000-05-11 07:43:42 +00:00
sjg 0051977fda Pass ctxt along to VarLoopExpand so that local variables such as .TARGET
can be expanded.
2000-05-11 03:32:56 +00:00
sjg 82abb388a6 Revert to the original behaviour wrt sysIncPath, ie if sysIncPath
is an empty list, use DEFSYSPATH.
The current behaviour may have been useful when DEFSYSMK was an
absolute path (hasn't been the case since 1996), but right now
make -m /no/such/dir will fail to find sys.mk and die.
2000-05-10 07:49:35 +00:00
drochner df45d3b6cf support OSF/1 2000-05-04 18:29:53 +00:00
drochner 6d10baf050 conditionalize prototypes for REMOTE support
(seems that REMOTE support is incomplete anyway)
2000-05-04 18:29:12 +00:00
drochner e1710a32d6 make cleaner C for more picky compilers 2000-05-04 18:27:53 +00:00
sjg 5fe132c5cb Added the :U :D :L :P :! and :@ modifiers as used by ODE make.
These allow some very useful magic in the makefiles.
The comment in var.c describing their behaviour is mostly lifted
from ODE make, but the implementation of the modifiers themselves
is quite different (much simpler) due to divergence of our code base.
2000-04-29 12:18:52 +00:00
sjg 6f4163b60c Allow MAKESYSPATH in the environment to override the default syspath. 2000-04-29 12:15:16 +00:00
sjg 0828d668af Changes to make MAKEOBJDIRPREFIX useful.
Firstly, we ignore getenv("PWD") if MAKEOBJDIRPREFIX is set so that we always
get the same value for .CURDIR regardless of how make was invoked.

Second, when executing a command we check if it is ${.MAKE} or ${.MAKE:T}
without a preceeding chdir, if so we insert a chdir(${.CURDIR}) so that
the Makefile will be found by the child make.  Note that this behaviour is
dissabled if MAKEOBJDIRPREFIX is not set or if NOCHECKMAKECHDIR is set.
See the comments in main.c for more detail.

With these two changes, one can successfully build usr/src using MAKEOBJDIRPREFIX
allowing the src to be mounted from a CD-ROM.
2000-04-20 11:23:25 +00:00
simonb ae62335eb5 Buf_GetAll() takes an int *, not a size_t *.
Build failure on alpha reported by Tim Rightnour on current-users.
2000-04-18 03:46:41 +00:00
christos 94c2d86134 Don't type && when you mean || (pointed out by David Holland) 2000-04-17 14:59:02 +00:00
christos 13a6d6acf1 PR/9898: David Holland: small glitch in var substitution for single letter
variables.
2000-04-16 23:35:16 +00:00
christos a4760ab7d0 prefix errors with the program name. 2000-04-16 23:24:23 +00:00
christos c097e3c5c2 Don't core-dump when the current working directory is not readable 2000-04-16 23:24:04 +00:00
christos c407ec1982 PR/9899: David A. Holland: multi-variable .for constructs in make 2000-04-16 22:08:06 +00:00
simonb d88dfea295 Don't declare 'extern opt*' getopt variables. 2000-04-14 06:11:07 +00:00
soren 89c5a767f8 Fix doubled 'the's. 2000-03-13 22:55:05 +00:00
sjg 90c80377e5 Fixed the oodate test to include the check of gn->cmtime == 0 without
breaking the original intent.

PR: 9503
2000-02-29 22:00:02 +00:00
sjg 14fcc9e86c Non-existent libs are always out of date.
This was not handled correctly on ELF where libs do not have T.O.C.

PR: 9393
Reviewed by: christos
2000-02-15 04:41:45 +00:00
sjg 448f091254 Mention MAKEOBJDIRPREFIX and explain how it or MAKEOBJDIR are used.
Also fixed a typo in the .SUFFIXES bit.
2000-02-08 12:56:28 +00:00
sjg 49984c2f37 Make chdir_verify_path() do variable expansion on path in case
someone wants to do freaky stuff with $MAKEOBJDIR.
Initialize the Var system and set .CURDIR, MACHINE and MACHINE_ARCH
before chdir_verify_path() is called.
2000-02-08 12:43:25 +00:00
sjg f618973b5f You cannot meaningfully test if a non-existent file has a correct
archive header, so don't try - just believe gn->type & OP_LIB.
2000-01-31 13:21:20 +00:00
mycroft 4e558e01fa Don't apply suffix rules for .PHONY targets. (gmake doesn't do this either.) 2000-01-22 19:28:11 +00:00
mycroft f5d7100e26 Nuke `extern int errno;' in code we compile with -Wstrict-prototypes. We get
the correct definition from errno.h.
2000-01-21 17:08:33 +00:00
christos 4cd25afac7 Create temporary files carefully, to avoid security problems. Idea borrowed
from the botched FreeBSD implementation...
2000-01-19 23:39:37 +00:00
wrstuden f21e998aad Add a few little changes needed to get this to compile on IRIX 6.4. 2000-01-06 22:23:20 +00:00
mrg f22d12ed49 back out rev 1.23 (don't stat PHONY targets). it broken the libcrypto
build by causing everything to be remade everytime.  this fixes PR#8419.
1999-11-25 22:34:16 +00:00
kristerw e71aea426d Typos (from OpenBSD) 1999-11-19 22:29:24 +00:00
msaitoh 0fcbe067c6 s/ the the / the / 1999-10-08 20:13:42 +00:00
kim 6c6c0c0d5c Make this compile on Solaris... 1999-09-16 19:57:54 +00:00
mycroft 2500a4b975 Some minor cleanup of :: tests. 1999-09-16 00:54:14 +00:00
mycroft ce14db1fcd Fix a bug in the previous. In the `compat' case, we don't actually use the
list of target nodes returned by Make_ExpandUse().  We have to search the
cohorts explicitly while iterating through the tree.  So, tweak CompatMake()
to do this.
1999-09-16 00:49:48 +00:00
sommerfeld bcb141e5d0 Reuse the Hash_Entry `name' field to store the variable name when we
can (i.e., everything except environment variables, which aren't
stored in hash tables).

While we're here, inline the body of VarDelete into Var_Delete since
it's the only caller and it's just simpler that way when v->name can
share storage with the hash entry and may not need to be freed
separately.

Speeds up the infamous libc build benchhmark maybe 1% on PIII, 4% on
alpha pc164

Suggested by Perry Metzger.
1999-09-15 22:51:05 +00:00
mycroft b12871c6cb Rework how :: dependencies are handled.
Build a list of `cohorts' as before, but do *not* link each one into all the
parent nodes; instead, copy the `cohort' lists into the stream of targets to
be built inside Make_ExpandUse().  Also do the attribute propagation as a
separate pass after parsing.
This eliminates several O(n^2) algorithms.
1999-09-15 10:47:37 +00:00
mycroft c29ad80902 More cleanup code bites it. 1999-09-15 08:48:17 +00:00
mycroft dd291116bc Don't bother iterating through all the data structures to free(3) everything
right before exiting.
(The code is still present, `#ifdef CLEANUP', in case someone needs it...)
1999-09-15 08:43:21 +00:00
mycroft 441a442e46 Fix another case where we stat(2)ed .PHONY targets. 1999-09-15 05:56:33 +00:00
mycroft ff6341a190 Nuke Buf_{G,Ung}etByte{,s}(), since they aren't used, and make BufExpand do
power-of-2 allocation.
1999-09-15 04:16:31 +00:00
mycroft c33b6eca55 Avoid using Lst_Member() in SuffExpandChildren(), by avoiding Lst_ForEach() and
passing in the LstNode of the child being inspected.  Shaves off another few %,
particularly when there are long child lists containing $ expansions (e.g. in
libc).
1999-09-15 03:59:44 +00:00
mycroft d2ec8b0e26 Replace the linear variable list in the GNode with a hash table. Gives a
small (~10% on my machine) speedup building libc.
Changes by: perry (+ bug fix and minor change by me)
Reviewed by: mycroft sommerfeld
1999-09-15 02:56:34 +00:00
christos ab01074993 Add :O var modifier, that sorts the words in a variable. 1999-09-12 00:17:50 +00:00
christos 7057287c54 PR/8259: Chris Demetriou: Fix stack overflow bugs exposed by the glibc-2.1.1
Makefile. Use snprintf everywhere.
1999-09-04 04:21:28 +00:00
simonb dcb4cadef7 Don't need strftime() on Ultrix either. 1999-08-27 00:47:25 +00:00
aidan 58f27ba58c Added .PARSEDIR and .PARSEFILE variables to make(1). 1999-08-09 21:06:28 +00:00
ross 7886a593e3 Back out part of previous, only the parse.c mod was intended. 1999-08-04 16:44:07 +00:00
ross 0728723c31 Trivial speed hack. 1999-08-04 02:54:56 +00:00
hubertf 5674691260 Save the walls, use fly swatters instead of machine guns!
(s/sscanf/strtol/, per Christos)
1999-08-02 17:23:58 +00:00
hubertf a38c426e1c Detect invalid arguments to -j and -L by using sscanf() instead of atoi().
Fixes PR 6743 by Assar Westerlund <assar@sics.se>
1999-08-02 15:23:11 +00:00
hubertf d5df2197fb sprite.h is private to make, so #include it with "sprite.h",
not <sprite.h>.

Problem reported in PR 4381 bye Soren S. Jorvang <soren@t.dk>
1999-07-29 19:45:32 +00:00
christos 10e7b7f04d Fix extreme brokeness with job control that appeared when we set USE_PGRP. 1999-07-16 05:38:20 +00:00
thorpej 70b6975a7e Fix a typo. 1999-07-12 18:22:49 +00:00
thorpej 484fe86089 Correct an inverse initialization of a variable, which caused all .PATHs
to be treated as .DOTLAST.
1999-07-12 17:29:32 +00:00
thorpej 5a0addc0ef Add a mechanism for specifying that ${.CURDIR} will be searched last
in the presence of .PATH directives by specifying:

.PATH: .DOTLAST

This will be used to fixup the build system to work with both crypto-us
and crypto-intl sub-trees.

Make(1) changes by Christos Zoulas, after much badgering by me :-)
1999-07-11 02:06:57 +00:00
christos 80d9d7d175 Regular bourne shells don't have the -q option (from Chuck Cranor) 1999-07-06 14:02:56 +00:00
christos 516292d398 apply solaris fixes 1999-06-29 07:44:21 +00:00
christos eee5bfa70d Revert previous change. I am a bonehead. 1999-06-06 21:16:23 +00:00
christos 9081585e9b remove accidentally left debugging code 1999-06-06 20:41:04 +00:00
christos 4d93254198 Allow junk variable to work in non dynamic contexts. Allows as to say things
like:
    .if defined(COPTS) && !empty(COPTS:M*-g*)
1999-06-06 20:24:02 +00:00
christos f15f83610f Fix awful bug where:
V := $V foo
	V := $V bar

would report that variable V is recursive...
1999-06-02 18:47:11 +00:00
christos 94df9ca047 Define USE_PGRP so that we send signals to our job's process group instead
of only pid.
1999-05-03 12:01:14 +00:00
christos 130a3bae01 killpg(pgrp, sig) == kill(-pgrp, sig) in the sysv case. 1999-05-03 09:49:55 +00:00
gwr 4761a8c13b Uh... should have been ${MACHINE} not hard coded... Duh! 1999-04-03 04:50:16 +00:00
gwr ae400a2e31 Define CC=gcc -O and add -DMACHINE=... 1999-04-03 04:39:10 +00:00
gwr 0a1b2f4b53 Make regex support conditional on NO_REGEX (was MAKE_BOOTSTRAP)
Solaris has a compatible regex, as do many others now...
1999-04-03 04:37:47 +00:00
sommerfe 1be2746ed5 report a sensible error if wait() fails. 1999-03-24 13:19:26 +00:00
christos 8001a619fc use emalloc() instead of malloc() 1999-03-19 16:11:02 +00:00
erh fa45851f9b Add missing .El line. 1999-03-10 05:14:51 +00:00
ross 7f8e818918 Missing .El. 1999-03-09 03:19:28 +00:00
mycroft a1c657fe56 Clean up SYNOPSIS formatting. 1999-03-07 11:29:58 +00:00
cjs d5ce180dc0 When giving the -v option to /bin/sh, also give the new -q option so that
the execution of $ENV isn't printed with every job that's started.
1999-02-04 00:40:55 +00:00
christos 24eea87b54 Allow system path to be overriden in the Makefile 1998-12-19 17:26:12 +00:00
ross 3eb0afd457 Fix a bug that apparently prevented, since day 1, the .-include / .sinclude
feature from ever working. Also, fix the man page that incorrectly described
the syntax of the feature that didn't work.
1998-11-17 23:56:23 +00:00
christos 4f3cc30bcc This patch fixes the problem introduced in the previous commit where
parents would be get remade, even if children were not really updated
by the commands executed for them. It also makes all the children have
the real modification time set if possible, so it should fix some other
timing weirdnesses...

- collapse childMade and make fields into flags and convert them to bits
  CHILDMADE and REMAKE
- introduce FORCE flag that gets set in all the parents of a child that
  has no sources and does not exist.
- set oodate if the FORCE flag is set, and not if CHILDMADE
- centralize the RECHECK into Make_Recheck() and use this in make.c and compat.c
- use Make_TimeStamp for all child -> parent timestamp propagations
1998-11-11 19:37:06 +00:00
christos 7e91b1976d PR/6426: Jim Bernard: make sometimes does not make directories on top of
a union mount.

	eg.
	src: FORCE

	FORCE is a fake target that does not have sources. When FORCE is
	considered made it gets updated with the current timestamp. If the
	directory happens to have the same timestamp too, then it will not
	be made because it is considered to be up-to-date with respect to
	the child. This can happen because the time resolution is only in
	seconds. It is more likely to happen on a union filesystem where
	the timestamps take longer to update.

	The fix is to consider the parent unmade when children have been
	updated.
1998-11-11 11:25:43 +00:00
christos 889ce7db6e - full prototypes
- more conservative printf
- char -> unsigned char
1998-11-06 23:31:09 +00:00
itohy 6aeb72f23f Reduced memory leaks.
I found some more leaks, but are not in inside of iterations.
1998-11-01 03:07:33 +00:00
itohy 841c52934a If the target name is shorter than the suffix,
the previous garbage bytes may be read.
Example: "make n" --- target = n, suffix = .ln

Changing interface of SuffSuffIsSuffix() is required to fix this bug.
1998-11-01 03:05:03 +00:00
itohy f748b52ef3 Avoid reading outside of allocated memory
on command execution if the output is empty.
1998-11-01 03:01:53 +00:00
christos ff08129ca5 strftime is not needed for svr4 machines; also fix the prototype footprint. 1998-10-18 14:24:16 +00:00
christos 3b7c5b4ed8 Only define const and volatile when __STDC__ is not defined (for BOOTSTRAP) 1998-10-18 14:23:48 +00:00
wsanchez 65b6624a6d Include sys/types.h 1998-10-13 17:09:16 +00:00
wsanchez 8a6084908f Use __ARCHITECTURE__, if defined, as MACHINE_ARCH 1998-10-13 17:08:34 +00:00
christos 82ee767393 Fix conditional variable expression parsing (reported by cgd) 1998-09-18 20:35:11 +00:00
christos 1b24c735a6 PR/6162: Greg A. Woods: pmake does not add suffix rules if gnodes have children.
This is traditional make behavior (Solaris make does the same), but
	 GNU does not. Lets see what breaks.
1998-09-18 20:20:52 +00:00
christos aed39ca72c PR/6174: ITOH Yasufumi: Purify bug and a compile error in utility code. 1998-09-18 20:15:36 +00:00
christos 8bd03e9aab - Add {.,}[s-]include for silent include file failures
- Make traditional include statement include more than one file if present
  on the line.

Keeping up with the other's :-)
1998-08-06 13:42:22 +00:00
christos ea21627e65 Fix access to freed memory; pointed out by Todd Miller. 1998-07-04 21:53:11 +00:00
christos 076a184bb0 PR/5690: Wolfgang Rupprecht: deleting a suffix that has 0 source references
causes core-dump. Fix: when an unused suffix gets removed, delete
	 it from the suffix list.
1998-07-02 23:30:18 +00:00
tv f0dcde8323 Make a MAKE_BOOTSTRAP case work on NetBSD, too, for cross-compile cases 1998-05-21 17:19:46 +00:00
cgd b374e69f29 in Var_Parse(), set delim in a couple of other paths into cleanup 1998-04-03 04:07:15 +00:00
kleink fb7502608a Need <time.h> for time() prototype. 1998-04-02 10:33:17 +00:00
christos 84e525a801 Add conditional variable evaluation from Alistair Crooks. 1998-04-01 14:18:10 +00:00
christos d611392726 PR/5225: Jason Thorpe: make with -j 4 and subdirs core-dumps.
This revealed another long standing problem with pmake's port to bsd.
.MAKE was not set as the manual page states. Set it and remove another
typo in my last commit.
1998-03-28 22:29:04 +00:00
christos f46f2d693e PR/5210: Hauke Fath: make core dumps with .SHELL
Unfortunately this revealed a deeper problem with the brk_string code.
To fix it:
	- remove sharing of the buffer between brk_string invocations
	- change the semantics of brk_string so that the argument array
	  starts with 0, and return the buffer where the strings are
	  stored
1998-03-26 19:20:36 +00:00
fair 78f41cb540 patch from PR#3573 to rename a variable "main" to "mainList" 1998-03-23 08:52:48 +00:00
hubertf 51dc9a9405 Fix typos from PR 5055 by NAKAJIMA Yoshihiro <nakayosh@kcn.or.jp>. 1998-02-24 18:34:31 +00:00
christos 79400c03dd Y2K fixes: use strftime(), and add a fake strftime() for systems that do
not have it.
1998-02-04 14:47:39 +00:00
thorpej f04b8efed3 Change an exit() to _exit(), so that it's safe for vfork(). 1997-12-31 06:06:12 +00:00
lukem 8640f5d0af getopt returns -1 not EOF, use memmove instead of bcopy 1997-11-08 09:33:15 +00:00
lukem 8ba07ab0b3 use CPPFLAGS instead of CFLAGS 1997-10-24 09:00:17 +00:00
lukem 6d1c625f54 fix up .Nm usage 1997-10-19 05:05:24 +00:00
lukem 00c29d5afe don't define WARNS=1 here 1997-10-19 04:23:02 +00:00
mikel d9c915fd1a add missing .Nm argument 1997-10-12 05:51:47 +00:00
mycroft e96e918e60 Use bsd.subdir.mk as appropriate. 1997-10-11 09:34:07 +00:00
thorpej 75b410b331 If printing a u_long, use the %lu format. 1997-10-03 17:58:00 +00:00
enami 5a3584034e Make this compile on NetBSD/alpha; use %ld and cast to u_long to print
a variable of type size_t.
1997-10-03 16:06:26 +00:00
lukem 2ba9e97765 wrap #include <sys/cdefs.h>, __RCSID(...) stuff in #ifndef MAKE_BOOTSTRAP 1997-09-28 03:30:58 +00:00
christos a004ae7f41 PR/4140: David A. Holland: use svr4 style archives for ELF environments 1997-09-26 13:29:05 +00:00
fair 7eaeaff5f2 fix some ints that should be "time_t" per PR#4139 1997-09-23 21:15:07 +00:00
christos 7b8cd5e6e3 Expand variables within variables correctly; eg.
foo.123=abc
bar=123
all:
	echo ${foo.${bar}}
1997-09-22 17:11:12 +00:00
kleink 66105c37fc Lseek(2) usage cleanup: the use of L_SET/L_INCR/L_XTND is deprecated,
use SEEK_SET/SEEK_CUR/SEEK_END instead.
1997-08-25 19:31:43 +00:00
christos 87d111ebee #if __STDC__ -> #ifdef __STDC__ 1997-07-11 20:17:37 +00:00
christos 4507c82bcc sprintf -> vsprintf 1997-07-11 20:16:01 +00:00
christos 487628a792 Fix memory corruption that was caused by debugging code leftovers. 1997-07-10 00:54:44 +00:00
christos e2d4e7ccc8 PR/3825: David A. Holland: global regexp handling gets stuck in infinite loop.
Actually there were two bugs:
	- Add REG_NOTBOL after the first substitution.
	- Handle the rm_so == rm_eo == 0 case, where in a substitution such
	  as 's/bzzzt/z*/g' the first time z* matches nothing.
1997-07-07 19:06:17 +00:00
christos 254d64f064 Add WARNS=1
RCSID police
1997-07-01 21:17:00 +00:00
christos 9981dd99c2 Apparently, using _doprnt(_IOREAD) to emulate vsnprintf() on SVR4 *sometimes*
core-dumps; use sprintf()+strlen() for now.
1997-06-07 16:42:31 +00:00
christos 702a3f7097 Deal with archive.a(member.o) nodes when expanding .USE dependencies or
adding children to .OODATE.
1997-06-07 16:41:09 +00:00
christos fab62ec0e9 Don't confuse `member' with `target' 1997-06-07 16:39:45 +00:00
pk 3552d54978 Erase spurious character. 1997-05-26 23:07:31 +00:00
pk 7abb0d066d Minor formatting glitch. 1997-05-26 21:04:28 +00:00
mycroft c19bda7d4c Check the .PHONY attribute... 1997-05-20 22:53:30 +00:00
christos 041c0c5158 Change the way curdir is handled [this started at the previous version]...
Instead of adding it in .PATH, handle it specially the same way as "." is
handled.
1997-05-09 17:05:59 +00:00
mycroft f88245a571 Make sure to propagate OP_PHONY to all cohorts that already existed. 1997-05-09 04:08:26 +00:00
mycroft 8aed472136 Fix description of .NOPATH. 1997-05-08 22:34:34 +00:00
gwr bf6930a26c Add the new .NOPATH feature which can be used to disable .PATH search
for particular targets, i.e. .depend, objects, etc.  (from Christos).
1997-05-08 21:24:41 +00:00
gwr 10e180cc49 Back out the .PATH.c changes. The .depend problem (and others)
will be fixed using the new .NOPATH make feature instead.
1997-05-08 21:11:01 +00:00
cjs 90423c173a If the -m option is used, make will check for the existence of the
directory specified, and add it to sysIncPath only if it exists.
However, afterwards make tested for the presence of a -m option by
checking to see if sysIncPath was an empty list, and assumed that
the -m option was not used if it was empty. This obviously breaks
if -m specified a non-existent directory. So I have added a flag
that is set if the -m option is used, and I test that instead.
1997-05-08 05:19:46 +00:00
mycroft 01925a4fb0 Copy the .PHONY attribute to the cohorts of a double dependency. 1997-05-07 13:12:33 +00:00
mycroft a66a01875e Ignore `-t' when the .MAKE attribute is set. 1997-05-07 07:31:37 +00:00
mycroft 755bc65362 Make sure `-n' is actually disabled for targets with the .MAKE attribute. 1997-05-06 23:51:29 +00:00
mycroft b160845c38 Document .PHONY better. 1997-05-06 22:29:43 +00:00
mycroft 5be8dcf32a Don't do a suffix search for a .PHONY target. 1997-05-06 22:06:58 +00:00
mycroft bcc725c5e3 Don't do a VPATH or .PATH search for .PHONY targets. (From Christos.) 1997-05-06 20:59:42 +00:00
mycroft 0997556292 Don't touch .PHONY targets. 1997-05-06 20:57:47 +00:00
gwr 012e528f2e Use .PATH.c: ... 1997-05-06 20:44:56 +00:00
christos 193e8d1b7d - Target searching addition:
Make used to only use the search path for nodes that were pure
	sources (not targets of other sources). This has been corrected
	and now gnu-autoconf generated Makefiles work in directories other
	than the source one.

- Suffix transformation rescanning:
	Suffix transformations (.c.o:; cc ...) were only recognized in
	the past when both suffixes were members of the suffix list.
	Thus a sequence like:
		.z.b:
			echo ${.TARGET}
		.SUFFIXES: .z
	would cause .z.b: to be inserted as a regular target (and the main
	target in this case). Other make programs always add rules that
	start with a period in the transformation list and never consider
	them as targets. We cannot do that (consider .depend files) so we
	resort to scanning the list of the current targets every time a
	suffix gets added, and we mutate existing targets that are now
	valid transformation rules into transformation rules. If the
	transformed target was also the main target, we set the main target
	to be the next target in the targets list.
1997-05-02 14:24:27 +00:00
christos 6cfa2388a9 Make used to add every directory where it found files in the search path.
I.e. if you had a line in your Makefile:
	../foo.o: foo.c
`..' would be added in the search path. The addition of such paths has
been now disabled. If a pathname contains a slash, then the directory
where such a file is found is not added to the search path. Of course
this eliminates most (all?) use of this function.
1997-05-02 14:23:51 +00:00
mellon 64b4faf663 Don't look at archive information on platforms that run ELF binaries 1997-04-26 07:11:14 +00:00
christos e5c746f479 Don't disable wildcards completely; they are used by other Makefiles. 1997-03-29 16:51:26 +00:00
christos bdae19cbd2 Make sure that the children of nodes that are marked .MADE, are marked
UPTODATE and their timestamps are consistent.
1997-03-28 22:31:21 +00:00
christos b4fe701a22 - Disable globbing for targets/dependencies when POSIX is defined.
- Fix globbing so that patterns that don't have a matching number of [] or {}
  don't get expanded. (before the [ case got expanded to nothing!) This is
  disabled.
1997-03-27 17:20:18 +00:00
gwr f17ca2c65c Do not compile-in ${MACHINE} (as per PR#3386, OK'ed by christos) 1997-03-24 20:56:36 +00:00
christos 69ad8a6988 Locate all the children of a node marked as MADE. 1997-03-23 01:25:28 +00:00
christos 161ba8eea5 Fix problems in the RE substitution error handling. 1997-03-18 19:24:46 +00:00
christos dd0a1d0814 Add a .MADE directive to indicated that the children of a target are
up-to-date, even when they are not. This is to simulate our current
make install behavior with proper dependencies.
1997-03-10 21:19:49 +00:00
christos 4417c4f61f Reported by cgd: fix .USE directive problems:
1. ${.*} variables did not get expanded in dependencies.
    2. expanded ${.*} variables in .USE dependencies can cause tree
       restructuring; handle it.
    3. in compat mode, expand .USE before evaluating the list of targets,
       instead of doing .USE expansions on demand, because they can cause
       tree restructuring.
1997-02-20 16:51:47 +00:00
christos b210ac559b make $MACHINE_ARCH settable from the environment. 1997-01-28 23:58:00 +00:00
christos f73f9b0103 Don't compile the regex code if MAKE_BOOTSTRAP (from gwr) 1996-12-31 18:03:30 +00:00
christos 4442744d56 BSD did not traditionally have <sys/cdefs.h>; use BSD4_4 instead and include
<sys/param.h> to grab it.
1996-12-31 18:02:22 +00:00
christos 59a3352108 implement snprintf() and vsnprintf() for non BSD4_4 systems. 1996-12-31 17:56:04 +00:00
christos e43039b92f add a missing 'static' decl. 1996-12-31 17:55:28 +00:00
christos 9a2fab368e define const and volatile for non __STDC__ 1996-12-31 17:55:02 +00:00
christos 87961728d3 - include <stdlib.h> to get getenv() prototype on SVR4
- if __STDC__ -> ifdef __STDC__ to appease SVR4
1996-12-31 17:54:16 +00:00
christos 9749ddca0f Use only integral types in procedure arguments. 1996-12-31 17:53:21 +00:00
christos 36d9e80aff Use explicit .c.o rule so that the bootstrap process works. 1996-12-31 17:52:23 +00:00
christos 8819044d2a [initial version of the substitution/regexp changes were courtesy of Der Mouse]
- fix the variable substitution code in make [PR/2748]
      1. change s/a/b/ so that it substitutes the first occurance of the
	 pattern on each word, not only the first word.
      2. add flag '1' to the variable substitution so that the substitutions
	 get performed only once.

  ***THIS IS AN INCOMPATIBLE CHANGE!***

  Unfortunately there was no way to make things consistent without
  modifying the current behavior. Fortunately none of our Makefiles
  depended on this.

	    OLD:

		VAR      = aa1 aa2 aa3 aa4

		S/a/b/   = ba1 aa2 aa3 aa4
		S/a/b/g  = bb1 bb2 bb3 bb4

	    NEW:

		VAR      = aa1 aa2 aa3 aa4

		S/a/b/   = ba1 ba2 ba3 ba4
		S/a/b/1  = ba1 aa2 aa3 aa4
		S/a/b/g  = bb1 bb2 bb3 bb4
		S/a/b/1g = bb1 aa2 aa3 aa4

- add regexp variable substitution via 'C/foo/bar/' [PR/2752]

- add variable quoting via the ${VAR:Q} modifier. This is useful when running
  recursive invocations of make(1):

	make VAR=${VAR:Q}

  will always work... (This may prove useful in the kernel builds...) [PR/2981]
1996-12-24 17:36:27 +00:00
christos 2f197a9f4d Fir PR/2930: declare missing variable. 1996-11-11 15:16:10 +00:00
christos aa49881371 - Merge in FreeBSD and Lite2 changes.
- Fix bug where a non-archive target with a .a suffix would always
  be considered to be out of date, since it does not have a TOC.
1996-11-06 17:58:58 +00:00
thorpej dff3ccad44 Fix extra "make:" and newline in error message.
From enami tsugutomo <enami@ba2.so-net.or.jp>, PR #2651.
1996-09-27 02:36:58 +00:00
christos 453e90716c - Fix bug where the first line after a conditionally skipped was not ready
in its entirety if it contained a continuation.
- Print the whole error line, not just the first 20 characters of it.
1996-09-13 04:22:09 +00:00
christos bb97544b1b Fix bug reported by Greg Hudson where leaf (source only) nodes were
referenced only by their basename and not by their full pathname. This
breaks when .PATH or MAKEOBJDIR are used. There might be Makefiles around
that try to work around this bug by prepending ${.CURDIR} to the sources,
and they should be found and fixed. Also a lot of the gunk in suff.c that
was attempting to work around the same problem could be removed.
1996-08-30 23:21:10 +00:00
thorpej bbb4184355 Tidy up some RCS ids a bit. 1996-08-30 17:59:37 +00:00
christos 091b5c0118 Add estrdup(), a checked version of strdup and use it. 1996-08-13 16:42:00 +00:00
christos 22770fe8ea Add strdup() since ultrix is missing it.
From Larry Schwimmer <rosebud@cyclone.Stanford.EDU>
1996-08-13 16:41:15 +00:00
christos ba78477e9d Various cleanups from: Larry Schwimmer <rosebud@cyclone.Stanford.EDU> 1996-08-13 16:40:31 +00:00
christos 1bc899a1ff Protect __P from being multiply defined (for systems that already define it) 1996-08-13 16:39:30 +00:00
christos 15d37e3539 Recognize SVR4 style long filename entries in archives. 1996-06-02 21:09:33 +00:00
christos 62be8b7e25 Fix bug where make will always exit with 0, even when one or more parallel
jobs failed. (Only affects parallel make code)
1996-05-29 15:28:05 +00:00
christos 5c1983c016 - Move -D flags from Makefile to config.h and explain what they do. Add
-Wall -Wno-unused to CFLAGS. Add new define SYSVVARSUB to enable SysV
  style variable substitutions and enable them.
- Add SunOS style command substitutions via SUNSHCMD
- Fix core dump with '{variable = value'
1996-05-28 23:34:35 +00:00
jtc cf957d3a75 Changed to use 1900 + tm_year instead of hardcoding "19" as the century.
From PR #2308 by Stephen J. Roznowski <sjr@zombie.ncsc.mil>.
1996-04-08 18:57:49 +00:00
christos c7f6ddc626 make emalloc and erealloc return void *; closes PR/2276 1996-03-31 21:30:05 +00:00
jtc fea2f4c4ca Added erealloc() function that calls enomem() if the allocation fails
(this is like the existing emalloc() function).  Changed all realloc()
calls to erealloc().
1996-03-29 02:17:13 +00:00
christos 0acf990595 Add PHONY attribute and target. This is the first step to cleanup the
xinstall and xlint crud.
1996-03-15 21:52:32 +00:00
christos 6750270dc6 data and date aren't the same... 1996-03-12 18:04:27 +00:00
christos 57cad0d107 Jonathan Stone's fixes:
main.c:	Remove double include of <sys/resource.h>; if MACHINE is defined, use
	that instead of uname.
Makefile: Add util.c.
1996-03-11 13:45:31 +00:00
christos 9779dee0b1 Fix PR/2118; apply sysincludes patch. 1996-03-06 00:15:17 +00:00
christos 1b11cdf58d if PR/2090, sysvinclude too optimistic, did not check for space after the
include keyword
1996-02-17 13:28:09 +00:00
thorpej fb02474c1f In ParseDoInclude(), make a temporary copy of the current file name
while searching for ""-type include files, since the current file name
might not be a writeable string.
1996-02-07 23:04:04 +00:00
christos 8862d696fa fix pr/1421 and pr/1997 1996-02-04 22:20:27 +00:00
christos b941a324f5 Support SVR4 style archives. 1996-02-04 20:34:41 +00:00
christos f0874be2f5 - Added .WAIT to synchronize between sources like other pmake variants.
- Updated documentation to include .ORDER .PARALLEL .NO_PARALLEL .NONPARALLEL
1995-12-16 05:03:09 +00:00
christos 6611cb1d0d Updates for POSIX/SVR4 compiling:
arch.c:		 Don't require ranlib stuff. Not everybody has it.
dir.c:		 SunOS-4 != Solaris; change #ifdef sun to #if sun && !__svr4__
job.c, compat.c: Don't use 'union wait', use int and the W*() macros.
main.c: 	 Check for uname() == -1; some unames return > 0...
util.c, job.c:	 Add signal() with BSD semantics for svr4, don't use bsd
		 sigmask and friends.
1995-11-22 17:39:53 +00:00
cgd e3c5125de9 pull in make.h. (PAlloc() now uses emalloc(), which is prototyped in
make.h.  If the prototype is not in scope on the Alpha, I see lots
of "cast to pointer from integer of different size" warnings.)
1995-11-10 21:27:27 +00:00
christos 027abce852 - Turn compat mode on by default. It gets turned off when the -j without
the -B flag is specified. [Thus you can use -j 1 to turn it off].
- Fix malloc -> emalloc as Gordon noted.
1995-11-08 02:30:53 +00:00
christos 61067003d8 Minor:
- ${.PREFIX} should never contain a full pathname
    - Fixed gcc -Wall warnings
Major:
    - compatMake is now FALSE. This means that we are now running in
      full pmake mode:
	  * rules on dependency lines can be executed in parallel and or
	    out of sequence:

	    foo: bar baz

	    can fire the rule for baz before the rule for bar is fired.
	    To enforce bar to be fired before baz, another rule needs to be
	    added. [bar: baz]
	  * adjacent shell commands in a target are now executed by a single
	    invocation of the shell, not one invocation of the shell per line
      (compatMake can be turned off using the -B flag)
    - The -j flag now works... I.e. make -j 4 will fork up to four jobs in
      parallel when it can. The target name is printed before each burst
      of output caused by the target execution as '--- target ---', when j > 1
    - I have changed all the Makefiles so that they work with make -j N, and
      I have tested the whole netbsd by:
	  'make -j 4 cleandir; make -j 4 depend; make -j 4; make -j 4 install'
    - I have not compiled or tested this version of make with -DREMOTE.
1995-11-02 23:54:35 +00:00
ws 337d0ee3b1 Always ensure space for trailing NULL in argv 1995-10-30 17:36:27 +00:00
jtc 95c465e08b Update lseek() constants:
L_SET	-> SEEK_SET
And add off_t cast to offset argument.
1995-09-27 18:44:38 +00:00
jtc 6a70570191 include <signal.h> instead of <sys/signal.h> 1995-09-27 18:42:21 +00:00
christos f4699a7dd3 Revert previous suffix fix. If the .a suffix is present and a .c.a rule is
there, then the rule should be applied. This is the correct behavior.
1995-09-25 02:46:30 +00:00
christos ae8c2b9dd3 Don't apply the default suffix rules for nodes that are not in our
current directory because we could be building things outside our
directory that were not meant to be build... Fixes PR/1488
1995-09-22 00:42:10 +00:00
christos 17c2255148 Fix PR/1443:
Dependency rules with `=' in the lhs are parsed as variable assignments.
E.g., the following Makefile fails:

A=a b c d
all: $(A:%=%b)
$(A:%=%b):
	@echo $@
1995-09-10 03:58:16 +00:00
christos b5f782e810 - $NetBSD$ rcsids
- Fixed so that .[A-Z]* targets that do not match keywords are ignored as
  Posix mandates
- Added .PHONY target keyword
1995-06-14 15:18:37 +00:00
ws de7fa9654c Sort keyword table correctly, so binary search really works 1995-05-15 13:10:10 +00:00
jtc d08e2815ca None of the functions in util.c are needed by NetBSD, so don't
bother to compile it.
1995-05-03 05:09:14 +00:00
christos 67c2aabd6c Fix small typo; from Chris Torek 1995-04-29 17:05:08 +00:00
christos f222a602cf Fixed so that orphan tabs are ignored. Should close PR760. 1995-02-08 04:36:41 +00:00
christos 85ac32e8d2 str.c: Don't free NULL; does not work with non posix frees.
var.c: Minor memory leak plugged.
suff.c: Don't add extra sources on the null suffix if it has dependency
	lines or commands attached to it [POSIX says so]
1995-02-04 23:44:41 +00:00
mycroft b36edbb4da Fix 4 typos pointed out by Jordan, and 1 by me. 1995-01-23 20:34:59 +00:00
christos 0036b358ae Fixed to parse correctly SysV variable substitutions ${VAR:P1=P2} when
P1 or P2 contain }'s or )'s. From mikeb@snow.datametrics.com
1995-01-20 04:35:10 +00:00
christos 77759e5c6d Fixed PR/724, 'make' runs commands when $? is empty
This is not the perfect fix. I think that the whole __SYMDEF
checking code should be removed. [I should also teach myself
how to deal with the PR stuff to mark this closed :-)]
1995-01-11 17:42:26 +00:00
christos 42d1db77e3 Save the name of the environment variables. Remove the comment that
says that we don't. from Paul Borman (prb@bsdi.com)
1995-01-09 18:31:41 +00:00
christos 95531c8e1f Fixes from Paul Borman (prb@bsdi.com)
1. Honor environment variable $MACHINE if set over uname.machine
2. archives with :: are always out of date, even when they have no children.
3. VAR= a b c     # comment, gets the trailing blanks trimmed, unless
   escaped by \. I'll have to read the posix manul to make sure that it
   is ok to handle escapes here.
1995-01-06 19:57:27 +00:00
cgd 7d82c5ab5d a few casts, for peace and quiet. 1994-12-24 16:54:24 +00:00
christos 218fbce657 Don't remove targets when the -n flag is given and make is interrupted.
(From Keith Bostic)
1994-11-25 19:16:45 +00:00
mycroft 126cf80fd0 Deal with lines that contain only spaces, per PR 515, but implemented
differently.
1994-10-18 20:36:26 +00:00
mycroft dfab95c9fe Remove an outdated comment that is very confusing. 1994-10-18 20:16:13 +00:00
gwr 4ca862ca1d Get the name of this type of MACHINE from utsname
so we can share an executable for similar machines.
(i.e. m68k: amiga hp300, mac68k, sun3, ...)
1994-09-30 03:14:21 +00:00
mycroft e046f69de1 Use getcwd(3), not getwd(3), and remove some old, unused compatibility code. 1994-09-23 09:33:21 +00:00