DragonFly BSD
DragonFly submit List (threaded) for 2004-11
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

usr.bin/make More patches except phk's MAKE_JOBS_FIFO patches


From: Max Okumoto <okumoto@xxxxxxxx>
Date: Thu, 25 Nov 2004 01:59:57 -0800

patch-4.27      Reduce select timeout.
--------------------------------------------------------------
        PatchSet 328 Date: 2003/12/19 11:18:37 Author: scottl
                Change the select timeout from 100ms to 2 seconds
                now that SIGCHILD is handled.

patch-4.28      Standards patch.
--------------------------------------------------------------
        PatchSet 329 Date: 2004/01/10 16:30:29 Author: ru
                Moved the code for :U and :L modifiers where it
                belongs, so that the fallback for SysV (now in
                POSIX) variable substitution works for old_string
                arguments starting with 'U' or 'L'.

        PatchSet 330 Date: 2004/01/12 10:35:46 Author: harti
                Allow variable substitutions in SYSV variable
                substitutions like $(SRC:.c=$O). This brings us
                closer to other makes.  Obtained from: NetBSD

patch-4.29      NetBSD compat
--------------------------------------------------------------
        PatchSet 335 Date: 2004/03/09 17:36:55 Author: ru
                Make it possible to ``.undef ${VAR}'' (expanding
                VAR to get the variable name to undef).

patch-4.30      Better debug output
--------------------------------------------------------------
        PatchSet 334 Date: 2004/03/09 08:09:33 Author: ru
                Fixed line numbering inside the .for loops.

        PatchSet 336 Date: 2004/03/10 21:51:06 Author: ru
                Reworked the fix to print the useful line number
                on error in the .for loop:

                - Replaced four global variables in parse.c with
                  one.
                - Made Parse_FromString() accept the "lineno" as
                  an argument.
                - Fixed line numbering when there are escaped
                  newlines in the body of the .for loop.

patch-4.31      Add new functionality .warning
--------------------------------------------------------------
        PatchSet 339 Date: 2004/04/12 18:57:51 Author: ru
                Added the new .warning directive.

        PatchSet 340 Date: 2004/04/12 19:00:54 Author: ru
                Document the new .warning directive.

patch-4.32      Fix docs.
--------------------------------------------------------------
        PatchSet 343 Date: 2004/05/19 10:51:58 Author: ru
                Markup nits.

        PatchSet 347 Date: 2004/07/02 23:22:27 Author: ru
                Mechanically kill hard sentence breaks.

        PatchSet 349 Date: 2004/07/18 03:26:30 Author: keramida
                Remove the dependency of the :C/regexp/replacement/
                variable modifier from the :S modifier which follows
                a bit further below.  This way the reader can read
                each of these two descriptions without having to
                jump back and forth in the manpage.  PR: docs/26943

        PatchSet 350 Date: 2004/07/19 15:42:57 Author: harti
                Make it clearer what means 'won't work'
                for .if string == ${VAR}.

                Replace the use of '=' in conditionals in the
                examples by the more correct '=='.

                Clarify the example explaining that .for expansion
                takes place before .if handling by showing the
                correct code instead of saying 'the other way
                around'. Change a variable name there so the example
                is more parseable to the human reader.  PR: docs/65400

patch-4.33      Better diagnostic.
--------------------------------------------------------------
        PatchSet 351 Date: 2004/07/20 08:42:06 Author: harti
                Improve make's diagnostic of mistmatched .if-.endif.
                This patch is slightly different from the patch in
                the PR. The problem is, that make handles .if clauses
                inside false .if clauses simply by counting them -
                it doesn't put them onto the conditional stack, nor
                even parses them so we need an extra line number
                stack for these ifs.  PR: bin/61257

---------------------
        PatchSet 352 Date: 2004/07/22 12:12:01 Author: harti
                Fix handling of comments on .elif lines. The patch
                given in a followup to the PR failed, because the
                line skipping function is actually called from two
                places in the code to do quite different things
                (this should be two functions probably): in a false
                .if to skip to the next line beginning with a dot
                and to collect .for loops. In the seconds case we
                should not skip comments, because they are actually
                harder to handle than we need for the .if case and
                should defer this to the main code.  PR: bin/25627

patch-4.34      Add new functionality '+' flag standards
--------------------------------------------------------------
        PatchSet 353 Date: 2004/07/29 15:29:23 Author: harti
                Implement POSIX's '+' flag for command lines. This
                flag causes a line to be executed even when -n is
                given on the command line to make. This is very
                handy for calls to submakes.

                This is slightly changed from the original patch
                as obtained from NetBSD.  The NetBSD variant prints
                lines which have both '+' and '@' when -n is
                specified. The commited version always obeys '@'.

                Bump MAKE_VERSION so Makefiles can use this
                conditionally.

                PR: standards/66357 (partly)
                Obtained from: NetBSD

        PatchSet 354 Date: 2004/07/29 17:54:42 Author: harti
                Bump the date in .Dd for the recent '+' flag commit.

patch-4.35      Standards.
--------------------------------------------------------------
        PatchSet 356 Date: 2004/08/03 19:56:31 Author: harti
                Put variable assignments from the command line into
                the MAKEFLAGS variable as required by POSIX. This
                causes such variables to be pushed into all sub-makes
                called by the make (except when the MAKEFLAGS
                variable is explicitely changed in the sub-make's
                environment).  This makes them also mostly
                un-overrideable in sub-makes except on the sub-make's
                command line. Therefor specifying 'make CC=icc'
                will cause icc to be used as C compiler in all
                sub-makes no matter what the Makefiles itself try
                to do to the CC variable.

                This patch also corrects the handling of the MFLAGS
                variable. MFLAGS contains all the command line flags
                but not the command line variable assignments. The
                evaluation of the .MFLAGS or .MAKEFLAGS target now
                changes both MFLAGS and MAKEFLAGS (they used to
                change MAKEFLAGS only).  Makefiles can use MFLAGS
                for their own purposes given that they do not except
                MFLAGS to be undefined at the beginning and that
                they don't evaluate .MFLAGS or .MAKEFLAGS.  MFLAGS
                should be removed for POSIX compliance, but it is
                unfortunately heavily used by the X makefiles.

        PatchSet 357 Date: 2004/08/03 20:14:14 Author: harti
                Correct the description of the MFLAGS and .MAKEFLAGS
                variables. Add the MFLAGS target. Document that
                variable assignments from the MAKEFLAGS environment
                variable and the .MAKEFLAGS and .MFLAGS target have
                the same precedence as command line variable
                assignments.

        PatchSet 358 Date: 2004/08/04 16:10:35 Author: harti
                Correct the .Dd date. Pluralize 'assignment' in one
                place.


patch-4.36 New functionality for environment and cli variables. -------------------------------------------------------------- PatchSet 359 Date: 2004/08/09 17:13:54 Author: harti Make explicit that MAKEOBJDIRPREFIX and MAKOBJDIR must be set as environment variables and should not be set on make's command line. They happen to work accidentially as command line variables too when none of the sub-makes wants to play games with them (because make is putting command line variables into the environment and will find them there later on). Makefile.inc1 wants to change MAKEOBJDIRPREFIX. In this case one cannot set it on the command line.

        PatchSet 362 Date: 2004/09/06 16:25:07 Author: jmg
                remove XXX comment now that the kernel is fixed,
                there isn't any obvious reason to enable this as
                performance didn't significantly change...


patch-4.37 -------------------------------------------------------------- PatchSet 360 Date: 2004/08/12 12:49:55 Author: harti Put variable assignments on .MAKEFLAGS and .MFLAGS targets into the .MAKEFLAGS variable so that these are also passed to sub-makes. This makes the handling of variables in the command environment more consistent. PR: bin/68853

        PatchSet 361 Date: 2004/08/18 14:25:46 Author: ru
                Document the effects of modifying the .MAKEFLAGS
                internal variable and using the .MAKEFLAGS special
                target, and the differences between them.

patch-4.38      Remove code for remote execution.
--------------------------------------------------------------
        PatchSet 366 Date: 2004/11/04 12:57:41 Author: harti
                Remove the remote stuff from make. This actually
                never worked in our make because the necessary files
                were not imported with the original import.  If
                somebody really needs it, there is still the
                devel/pmake port.

                This is just the first step and removes just
                everything that is ifdef'ed out.  Otherwise the
                code is unchanged.

        PatchSet 367 Date: 2004/11/05 11:41:35 Author: harti
                Now with the remote job support removed there can
                be no remote jobs and no jobs that need to be
                remigrated. Remove the flags and the associated
                code.

        PatchSet 368 Date: 2004/11/11 12:23:39 Author: phk
                Get rid of now unused maxLocal variables.

        PatchSet 369 Date: 2004/11/11 12:52:15 Author: phk
                Get rid of more local/remote leftovers

patch-4.39      Bug fix and code cleanup for POSIX
--------------------------------------------------------------
        PatchSet 370 Date: 2004/11/12 07:57:17 Author: harti
                Fix a (very) long standing bug in make (this has
                been there probably from the beginning). Make used
                to handle all its interrupt-time stuff directly
                from the signal handler, including calls to printf,
                accessing global data and so on. This is of course
                wrong and could provoke a core dump when interrupting
                make. Just set a flag in the signal handler and do
                everything else from the main thread.  PR: bin/29103

        PatchSet 374 Date: 2004/11/17 11:32:46 Author: harti
                Eliminate the define for POSIX and build with Posix
                behaviour.  Our make has been build with POSIX
                enabled from the first day and the ifdef'ed out
                code served no purpose.

patch-4.40      Code cleanup
--------------------------------------------------------------
        PatchSet 365 Date: 2004/10/23 22:36:55 Author: ru
                "unset verbose" is 13 characters, not 10.

        PatchSet 375 Date: 2004/11/22 15:45:57 Author: harti
                Get rid of the shell table sentinel. It isn't needed
                anymore because JobMatchShell returns NULL when no
                shell name matches since revision 1.51.
---------------------
PatchSet 328
Date: 2003/12/19 11:18:37
Author: scottl
Log:
Change the select timeout from 100ms to 2 seconds now that SIGCHILD is
handled.

Members: 
	job.h:1.20->1.21 

Index: job.h
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/job.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- job.h	9 Oct 2002 01:56:02 -0000	1.20
+++ job.h	19 Dec 2003 11:18:37 -0000	1.21
@@ -56,8 +56,8 @@
  * before coming out to see if a child has finished. SEL_SEC is the number of
  * seconds and SEL_USEC is the number of micro-seconds
  */
-#define	SEL_SEC		0
-#define	SEL_USEC	100000
+#define	SEL_SEC		2
+#define	SEL_USEC	0
 #endif /* !USE_KQUEUE */
 
 
---------------------
PatchSet 329
Date: 2004/01/10 16:30:29
Author: ru
Log:
Moved the code for :U and :L modifiers where it belongs, so that
the fallback for SysV (now in POSIX) variable substitution works
for old_string arguments starting with 'U' or 'L'.

Members: 
	var.c:1.44->1.45 

Index: var.c
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/var.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -r1.44 -r1.45
--- var.c	6 Oct 2003 17:37:20 -0000	1.44
+++ var.c	10 Jan 2004 16:30:29 -0000	1.45
@@ -1160,38 +1160,6 @@
 
 	    DEBUGF(VAR, ("Applying :%c to \"%s\"\n", *tstr, str));
 	    switch (*tstr) {
-		case 'U':
-			if (tstr[1] == endc || tstr[1] == ':') {
-				Buffer buf;
-				buf = Buf_Init(MAKE_BSIZE);
-				for (cp = str; *cp ; cp++)
-					Buf_AddByte(buf, (Byte) toupper(*cp));
-
-				Buf_AddByte(buf, (Byte) '\0');
-				newStr = (char *) Buf_GetAll(buf, (int *) NULL);
-				Buf_Destroy(buf, FALSE);
-
-				cp = tstr + 1;
-				termc = *cp;
-				break;
-			}
-			/* FALLTHROUGH */
-		case 'L':
-			if (tstr[1] == endc || tstr[1] == ':') {
-				Buffer buf;
-				buf = Buf_Init(MAKE_BSIZE);
-				for (cp = str; *cp ; cp++)
-					Buf_AddByte(buf, (Byte) tolower(*cp));
-
-				Buf_AddByte(buf, (Byte) '\0');
-				newStr = (char *) Buf_GetAll(buf, (int *) NULL);
-				Buf_Destroy(buf, FALSE);
-
-				cp = tstr + 1;
-				termc = *cp;
-				break;
-			}
-			/* FALLTHROUGH */
 		case 'N':
 		case 'M':
 		{
@@ -1494,6 +1462,22 @@
 		    free(pattern.matches);
 		    break;
 		}
+		case 'L':
+		    if (tstr[1] == endc || tstr[1] == ':') {
+			Buffer buf;
+			buf = Buf_Init(MAKE_BSIZE);
+			for (cp = str; *cp ; cp++)
+			    Buf_AddByte(buf, (Byte) tolower(*cp));
+
+			Buf_AddByte(buf, (Byte) '\0');
+			newStr = (char *) Buf_GetAll(buf, (int *) NULL);
+			Buf_Destroy(buf, FALSE);
+
+			cp = tstr + 1;
+			termc = *cp;
+			break;
+		    }
+		    /* FALLTHROUGH */
 		case 'O':
 		    if (tstr[1] == endc || tstr[1] == ':') {
 			newStr = VarSortWords(str, SortIncreasing);
@@ -1518,6 +1502,22 @@
 			break;
 		    }
 		    /*FALLTHRU*/
+		case 'U':
+		    if (tstr[1] == endc || tstr[1] == ':') {
+			Buffer buf;
+			buf = Buf_Init(MAKE_BSIZE);
+			for (cp = str; *cp ; cp++)
+			    Buf_AddByte(buf, (Byte) toupper(*cp));
+
+			Buf_AddByte(buf, (Byte) '\0');
+			newStr = (char *) Buf_GetAll(buf, (int *) NULL);
+			Buf_Destroy(buf, FALSE);
+
+			cp = tstr + 1;
+			termc = *cp;
+			break;
+		    }
+		    /* FALLTHROUGH */
 		case 'H':
 		    if (tstr[1] == endc || tstr[1] == ':') {
 			newStr = VarModify (str, VarHead, (void *)0);
---------------------
PatchSet 330
Date: 2004/01/12 10:35:46
Author: harti
Log:
Allow variable substitutions in SYSV variable substitutions like
$(SRC:.c=$O). This brings us closer to other makes.

Reviewed by:	ru
Obtained from:	NetBSD

Members: 
	var.c:1.45->1.46 

Index: var.c
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/var.c,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -r1.45 -r1.46
--- var.c	10 Jan 2004 16:30:29 -0000	1.45
+++ var.c	12 Jan 2004 10:35:46 -0000	1.46
@@ -1592,37 +1592,48 @@
 			 * Now we break this sucker into the lhs and
 			 * rhs. We must null terminate them of course.
 			 */
-			for (cp = tstr; *cp != '='; cp++)
-			    continue;
-			pattern.lhs = tstr;
-			pattern.leftLen = cp - tstr;
-			*cp++ = '\0';
+			cp = tstr;
 
-			pattern.rhs = cp;
-			cnt = 1;
-			while (cnt) {
-			    if (*cp == endc)
-				cnt--;
-			    else if (*cp == startc)
-				cnt++;
-			    if (cnt)
-				cp++;
+			delim = '=';
+			if ((pattern.lhs = VarGetPattern(ctxt,
+			    err, &cp, delim, &pattern.flags, &pattern.leftLen,
+			    NULL)) == NULL) {
+				/* was: goto cleanup */
+				*lengthPtr = cp - start + 1;
+				if (*freePtr)
+				    free(str);
+				if (delim != '\0')
+				    Fatal("Unclosed substitution for %s (%c missing)",
+					  v->name, delim);
+				return (var_Error);
+			}
+
+			delim = endc;
+			if ((pattern.rhs = VarGetPattern(ctxt,
+			    err, &cp, delim, NULL, &pattern.rightLen,
+			    &pattern)) == NULL) {
+				/* was: goto cleanup */
+				*lengthPtr = cp - start + 1;
+				if (*freePtr)
+				    free(str);
+				if (delim != '\0')
+				    Fatal("Unclosed substitution for %s (%c missing)",
+					  v->name, delim);
+				return (var_Error);
 			}
-			pattern.rightLen = cp - pattern.rhs;
-			*cp = '\0';
 
 			/*
 			 * SYSV modifications happen through the whole
 			 * string. Note the pattern is anchored at the end.
 			 */
+			termc = *--cp;
+			delim = '\0';
 			newStr = VarModify(str, VarSYSVMatch,
 					   (void *)&pattern);
 
-			/*
-			 * Restore the nulled characters
-			 */
-			pattern.lhs[pattern.leftLen] = '=';
-			pattern.rhs[pattern.rightLen] = endc;
+			free(pattern.lhs);
+			free(pattern.rhs);
+
 			termc = endc;
 		    } else
 #endif
---------------------
PatchSet 335
Date: 2004/03/09 17:36:55
Author: ru
Log:
Make it possible to ``.undef ${VAR}'' (expanding VAR to get
the variable name to undef).

Submitted by:	Cyrille Lefevre

Members: 
	parse.c:1.51->1.52 

Index: parse.c
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/parse.c,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -r1.51 -r1.52
--- parse.c	9 Mar 2004 08:09:33 -0000	1.51
+++ parse.c	9 Mar 2004 17:36:55 -0000	1.52
@@ -2404,6 +2404,7 @@
 	            goto nextLine;	    
 		} else if (strncmp(cp, "undef", 5) == 0) {
 		    cp = stripvarname(cp + 5);
+		    cp = Var_Subst(NULL, cp, VAR_CMD, FALSE);
 		    Var_Delete(cp, VAR_GLOBAL);
 		    goto nextLine;
 		} else if (strncmp(cp, "makeenv", 7) == 0) {
---------------------
PatchSet 334
Date: 2004/03/09 08:09:33
Author: ru
Log:
Fixed line numbering inside the .for loops.

Submitted by:	Cyrille Lefevre

Members: 
	parse.c:1.50->1.51 

Index: parse.c
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/parse.c,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -r1.50 -r1.51
--- parse.c	28 Nov 2002 12:47:56 -0000	1.50
+++ parse.c	9 Mar 2004 08:09:33 -0000	1.51
@@ -112,6 +112,7 @@
 
 static char    	    *fname;	/* name of current file (for errors) */
 static int          lineno;	/* line number in current file */
+static int          savedlineno;	/* saved line number */
 static FILE   	    *curFILE = NULL; 	/* current makefile */
 
 static PTR 	    *curPTR = NULL; 	/* current makefile */
@@ -1792,7 +1793,7 @@
     curFILE = NULL;
     curPTR = (PTR *) emalloc (sizeof (PTR));
     curPTR->str = curPTR->ptr = str;
-    lineno = 0;
+    lineno = savedlineno;
     fname = estrdup(fname);
 }
 
@@ -2277,6 +2278,7 @@
 		if (For_Eval(line)) {
 		    int ok;
 		    free(line);
+		    savedlineno = lineno;
 		    do {
 			/*
 			 * Skip after the matching end
---------------------
PatchSet 336
Date: 2004/03/10 21:51:06
Author: ru
Log:
Reworked the fix to print the useful line number on error in
the .for loop:

- Replaced four global variables in parse.c with one.
- Made Parse_FromString() accept the "lineno" as an argument.
- Fixed line numbering when there are escaped newlines in the
  body of the .for loop.

Adopted from:	NetBSD

Members: 
	for.c:1.20->1.21 
	nonints.h:1.19->1.20 
	parse.c:1.52->1.53 

Index: for.c
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/for.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- for.c	8 Sep 2003 08:23:29 -0000	1.20
+++ for.c	10 Mar 2004 21:51:06 -0000	1.21
@@ -81,6 +81,7 @@
     Buffer	  buf;			/* Unexpanded buffer	*/
     char*	  var;			/* Index name		*/
     Lst  	  lst;			/* List of variables	*/
+    int  	  lineno;		/* Line #		*/
 } For;
 
 static int ForExec(void *, void *);
@@ -254,7 +255,7 @@
     Var_Set(arg->var, name, VAR_GLOBAL);
     DEBUGF(FOR, ("--- %s = %s\n", arg->var, name));
     Parse_FromString(Var_Subst(arg->var, (char *) Buf_GetAll(arg->buf, &len),
-			       VAR_GLOBAL, FALSE));
+			       VAR_GLOBAL, FALSE), arg->lineno);
     Var_Delete(arg->var, VAR_GLOBAL);
 
     return 0;
@@ -275,7 +276,7 @@
  *-----------------------------------------------------------------------
  */
 void
-For_Run(void)
+For_Run(int lineno)
 {
     For arg;
 
@@ -284,6 +285,7 @@
     arg.var = forVar;
     arg.buf = forBuf;
     arg.lst = forLst;
+    arg.lineno = lineno;
     forVar = NULL;
     forBuf = NULL;
     forLst = NULL;
Index: nonints.h
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/nonints.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- nonints.h	28 Oct 2002 23:33:57 -0000	1.19
+++ nonints.h	10 Mar 2004 21:51:06 -0000	1.20
@@ -59,7 +59,7 @@
 
 /* for.c */
 int For_Eval(char *);
-void For_Run (void);
+void For_Run(int);
 
 /* main.c */
 void Main_ParseArgLine(char *);
@@ -86,7 +86,7 @@
 void Parse_File(char *, FILE *);
 void Parse_Init(void);
 void Parse_End(void);
-void Parse_FromString(char *);
+void Parse_FromString(char *, int);
 Lst Parse_MainName(void);
 
 /* str.c */
Index: parse.c
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/parse.c,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -r1.52 -r1.53
--- parse.c	9 Mar 2004 17:36:55 -0000	1.52
+++ parse.c	10 Mar 2004 21:51:06 -0000	1.53
@@ -55,9 +55,9 @@
  *	those for the #include <...> are kept in the 'sysIncPath' Lst. The
  *	targets currently being defined are kept in the 'targets' Lst.
  *
- *	The variables 'fname' and 'lineno' are used to track the name
- *	of the current file and the line number in that file so that error
- *	messages can be more meaningful.
+ *	The variables 'curFile.fname' and 'curFile.lineno' are used to track
+ *	the name of the current file and the line number in that file so that
+ *	error messages can be more meaningful.
  *
  * Interface:
  *	Parse_Init	    	    Initialization function which must be
@@ -110,13 +110,6 @@
     char *ptr;
 } PTR;
 
-static char    	    *fname;	/* name of current file (for errors) */
-static int          lineno;	/* line number in current file */
-static int          savedlineno;	/* saved line number */
-static FILE   	    *curFILE = NULL; 	/* current makefile */
-
-static PTR 	    *curPTR = NULL; 	/* current makefile */
-
 static int	    fatals = 0;
 
 static GNode	    *mainNode;	/* The main target to create. This is the
@@ -132,6 +125,8 @@
     PTR *	    p;	    	    /* the char pointer */
 } IFile;
 
+static IFile	    curFile;
+
 static Lst      includes;  	/* stack of IFiles generated by
 				 * #includes */
 Lst         	parseIncPath;	/* list of directories for "..." includes */
@@ -251,7 +246,7 @@
 #endif
 static int ParseEOF(int);
 static char *ParseReadLine(void);
-static char *ParseSkipLine(int);
+static char *ParseSkipLine(int, int);
 static void ParseFinishLine(void);
 
 /*-
@@ -311,7 +306,8 @@
 	va_list ap;
 	va_start(ap, fmt);
 
-	(void)fprintf(stderr, "\"%s\", line %d: ", fname, lineno);
+	(void)fprintf(stderr, "\"%s\", line %d: ",
+	    curFile.fname, curFile.lineno);
 	if (type == PARSE_WARNING)
 		(void)fprintf(stderr, "warning: ");
 	(void)vfprintf(stderr, fmt, ap);
@@ -1576,7 +1572,8 @@
 	errmsg = Var_Subst(NULL, errmsg, VAR_GLOBAL, FALSE);
 
 	/* use fprintf/exit instead of Parse_Error to terminate immediately */
-	fprintf(stderr, "\"%s\", line %d: %s\n", fname, lineno, errmsg);
+	fprintf(stderr, "\"%s\", line %d: %s\n",
+	    curFile.fname, curFile.lineno, errmsg);
 	exit(1);
 }
 
@@ -1594,8 +1591,8 @@
  *	None
  *
  * Side Effects:
- *	A structure is added to the includes Lst and readProc, lineno,
- *	fname and curFILE are altered for the new file
+ *	A structure is added to the includes Lst and readProc, curFile.lineno,
+ *	curFile.fname and curFile.F are altered for the new file
  *---------------------------------------------------------------------
  */
 static void
@@ -1670,7 +1667,7 @@
 	char	  *prefEnd, *Fname;
 
 	/* Make a temporary copy of this, to be safe. */
-	Fname = estrdup(fname);
+	Fname = estrdup(curFile.fname);
 
 	prefEnd = strrchr (Fname, '/');
 	if (prefEnd != (char *)NULL) {
@@ -1732,11 +1729,7 @@
      * a very nice stack to track how we got here...
      */
     oldFile = (IFile *) emalloc (sizeof (IFile));
-    oldFile->fname = fname;
-
-    oldFile->F = curFILE;
-    oldFile->p = curPTR;
-    oldFile->lineno = lineno;
+    memcpy(oldFile, &curFile, sizeof (IFile));
 
     (void) Lst_AtFront (includes, (void *)oldFile);
 
@@ -1746,12 +1739,12 @@
      * name of the include file so error messages refer to the right
      * place. Naturally enough, we start reading at line number 0.
      */
-    fname = fullname;
-    lineno = 0;
+    curFile.fname = fullname;
+    curFile.lineno = 0;
 
-    curFILE = fopen (fullname, "r");
-    curPTR = NULL;
-    if (curFILE == (FILE * ) NULL) {
+    curFile.F = fopen (fullname, "r");
+    curFile.p = NULL;
+    if (curFile.F == (FILE * ) NULL) {
 	Parse_Error (PARSE_FATAL, "Cannot open %s", fullname);
 	/*
 	 * Pop to previous file
@@ -1771,30 +1764,27 @@
  *	None
  *
  * Side Effects:
- *	A structure is added to the includes Lst and readProc, lineno,
- *	fname and curFILE are altered for the new file
+ *	A structure is added to the includes Lst and readProc, curFile.lineno,
+ *	curFile.fname and curFile.F are altered for the new file
  *---------------------------------------------------------------------
  */
 void
-Parse_FromString(char *str)
+Parse_FromString(char *str, int lineno)
 {
     IFile         *oldFile;	/* state associated with this file */
 
-    DEBUGF(FOR, ("%s\n----\n", str));
+    DEBUGF(FOR, ("%s\n---- at line %d\n", str, lineno));
 
     oldFile = (IFile *) emalloc (sizeof (IFile));
-    oldFile->lineno = lineno;
-    oldFile->fname = fname;
-    oldFile->F = curFILE;
-    oldFile->p = curPTR;
+    memcpy(oldFile, &curFile, sizeof (IFile));
 
     (void) Lst_AtFront (includes, (void *)oldFile);
 
-    curFILE = NULL;
-    curPTR = (PTR *) emalloc (sizeof (PTR));
-    curPTR->str = curPTR->ptr = str;
-    lineno = savedlineno;
-    fname = estrdup(fname);
+    curFile.F = NULL;
+    curFile.p = (PTR *) emalloc (sizeof (PTR));
+    curFile.p->str = curFile.p->ptr = str;
+    curFile.lineno = lineno;
+    curFile.fname = estrdup(curFile.fname);
 }
 
 
@@ -1811,8 +1801,8 @@
  *	None
  *
  * Side Effects:
- *	A structure is added to the includes Lst and readProc, lineno,
- *	fname and curFILE are altered for the new file
+ *	A structure is added to the includes Lst and readProc, curFile.lineno,
+ *	curFile.fname and curFile.F are altered for the new file
  *---------------------------------------------------------------------
  */
 static void
@@ -1881,11 +1871,7 @@
      * a very nice stack to track how we got here...
      */
     oldFile = (IFile *) emalloc (sizeof (IFile));
-    oldFile->fname = fname;
-
-    oldFile->F = curFILE;
-    oldFile->p = curPTR;
-    oldFile->lineno = lineno;
+    memcpy(oldFile, &curFile, sizeof (IFile));
 
     (void) Lst_AtFront (includes, (void *)oldFile);
 
@@ -1895,12 +1881,12 @@
      * name of the include file so error messages refer to the right
      * place. Naturally enough, we start reading at line number 0.
      */
-    fname = fullname;
-    lineno = 0;
+    curFile.fname = fullname;
+    curFile.lineno = 0;
 
-    curFILE = fopen (fullname, "r");
-    curPTR = NULL;
-    if (curFILE == (FILE * ) NULL) {
+    curFile.F = fopen (fullname, "r");
+    curFile.p = NULL;
+    if (curFile.F == (FILE * ) NULL) {
 	Parse_Error (PARSE_FATAL, "Cannot open %s", fullname);
 	/*
 	 * Pop to previous file
@@ -1921,8 +1907,9 @@
  *	CONTINUE if there's more to do. DONE if not.
  *
  * Side Effects:
- *	The old curFILE, is closed. The includes list is shortened.
- *	lineno, curFILE, and fname are changed if CONTINUE is returned.
+ *	The old curFile.F is closed. The includes list is shortened.
+ *	curFile.lineno, curFile.F, and curFile.fname are changed if
+ *	CONTINUE is returned.
  *---------------------------------------------------------------------
  */
 static int
@@ -1935,19 +1922,16 @@
     }
 
     ifile = (IFile *) Lst_DeQueue (includes);
-    free (fname);
-    fname = ifile->fname;
-    lineno = ifile->lineno;
-    if (opened && curFILE) {
-	(void) fclose (curFILE);
-	Var_Append(".MAKEFILE_LIST", "..", VAR_GLOBAL);
-    }
-    if (curPTR) {
-	free(curPTR->str);
-	free(curPTR);
+    free (curFile.fname);
+    if (opened && curFile.F) {
+	(void) fclose (curFile.F);
+	Var_Append(".MAKEFILE_LIST", "..", VAR_GLOBAL);
+    }
+    if (curFile.p) {
+	free(curFile.p->str);
+	free(curFile.p);
     }
-    curFILE = ifile->F;
-    curPTR = ifile->p;
+    memcpy(&curFile, ifile, sizeof (IFile));
     free (ifile);
     return (CONTINUE);
 }
@@ -1964,11 +1948,11 @@
 static int
 ParseReadc(void)
 {
-    if (curFILE)
-	return fgetc(curFILE);
+    if (curFile.F)
+	return fgetc(curFile.F);
 
-    if (curPTR && *curPTR->ptr)
-	return *curPTR->ptr++;
+    if (curFile.p && *curFile.p->ptr)
+	return *curFile.p->ptr++;
     return EOF;
 }
 
@@ -1987,12 +1971,12 @@
 static void
 ParseUnreadc(int c)
 {
-    if (curFILE) {
-	ungetc(c, curFILE);
+    if (curFile.F) {
+	ungetc(c, curFile.F);
 	return;
     }
-    if (curPTR) {
-	*--(curPTR->ptr) = c;
+    if (curFile.p) {
+	*--(curFile.p->ptr) = c;
 	return;
     }
 }
@@ -2003,7 +1987,7 @@
  *	ignore such lines.
  */
 static char *
-ParseSkipLine(int skip)
+ParseSkipLine(int skip, int keep_newline)
 {
     char *line;
     int c, lastc, lineLength = 0;
@@ -2018,8 +2002,11 @@
         while (((c = ParseReadc()) != '\n' || lastc == '\\')
                && c != EOF) {
             if (c == '\n') {
-                Buf_ReplaceLastByte(buf, (Byte)' ');
-                lineno++;
+                if (keep_newline)
+                    Buf_AddByte(buf, (Byte)c);
+                else
+                    Buf_ReplaceLastByte(buf, (Byte)' ');
+                curFile.lineno++;
 
                 while ((c = ParseReadc()) == ' ' || c == '\t')
 		    continue;
@@ -2038,7 +2025,7 @@
             return((char *)NULL);
         }
 
-        lineno++;
+        curFile.lineno++;
         Buf_AddByte(buf, (Byte)'\0');
         line = (char *)Buf_GetAll(buf, &lineLength);
     } while (skip == 1 && line[0] != '.');
@@ -2079,6 +2066,7 @@
     char 	  *line;    	/* Result */
     char          *ep;		/* to strip trailing blanks */
     int	    	  lineLength;	/* Length of result */
+    int		  lineno;	/* Saved line # */
 
     semiNL = FALSE;
     ignDepOp = FALSE;
@@ -2098,7 +2086,7 @@
 	    ignComment = ignDepOp = TRUE;
 	    break;
 	} else if (c == '\n') {
-	    lineno++;
+	    curFile.lineno++;
 	} else if (c == '#') {
 	    ParseUnreadc(c);
 	    break;
@@ -2128,7 +2116,7 @@
 		 * semi-colon and semiNL is TRUE, it will be recognized as a
 		 * newline in the code below this...
 		 */
-		lineno++;
+		curFile.lineno++;
 		lastc = ' ';
 		while ((c = ParseReadc ()) == ' ' || c == '\t') {
 		    continue;
@@ -2229,7 +2217,7 @@
 
 	}
     line_read:
-	lineno++;
+	curFile.lineno++;
 
 	if (lastc != '\0') {
 	    Buf_AddByte (buf, (Byte)lastc);
@@ -2265,7 +2253,7 @@
 		 */
 		do {
 		    free (line);
-		    line = ParseSkipLine(1);
+		    line = ParseSkipLine(1, 0);
 		} while (line && Cond_Eval(line) != COND_PARSE);
 		if (line == NULL)
 		    break;
@@ -2278,12 +2266,12 @@
 		if (For_Eval(line)) {
 		    int ok;
 		    free(line);
-		    savedlineno = lineno;
+		    lineno = curFile.lineno;
 		    do {
 			/*
 			 * Skip after the matching end
 			 */
-			line = ParseSkipLine(0);
+			line = ParseSkipLine(0, 1);
 			if (line == NULL) {
 			    Parse_Error (PARSE_FATAL,
 				     "Unexpected end of file in for loop.\n");
@@ -2294,7 +2282,7 @@
 		    }
 		    while (ok);
 		    if (line != NULL)
-			For_Run();
+			For_Run(lineno);
 		    line = ParseReadLine();
 		}
 		break;
@@ -2359,9 +2347,9 @@
                   *line;	/* the line we're working on */
 
     inLine = FALSE;
-    fname = name;
-    curFILE = stream;
-    lineno = 0;
+    curFile.fname = name;
+    curFile.F = stream;
+    curFile.lineno = 0;
     fatals = 0;
 
     do {
---------------------
PatchSet 339
Date: 2004/04/12 18:57:51
Author: ru
Log:
Added the new .warning directive.

Submitted by:	Cyrille Lefevre

Members: 
	parse.c:1.53->1.54 

Index: parse.c
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/parse.c,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -r1.53 -r1.54
--- parse.c	10 Mar 2004 21:51:06 -0000	1.53
+++ parse.c	12 Apr 2004 17:57:51 -0000	1.54
@@ -241,6 +241,7 @@
 static void ParseHasCommands(void *);
 static void ParseDoInclude(char *);
 static void ParseDoError(char *);
+static void ParseDoWarning(char *);
 #ifdef SYSVINCLUDE
 static void ParseTraditionalInclude(char *);
 #endif
@@ -1571,12 +1572,38 @@
 	
 	errmsg = Var_Subst(NULL, errmsg, VAR_GLOBAL, FALSE);
 
-	/* use fprintf/exit instead of Parse_Error to terminate immediately */
-	fprintf(stderr, "\"%s\", line %d: %s\n",
-	    curFile.fname, curFile.lineno, errmsg);
+	Parse_Error(PARSE_FATAL, "%s", errmsg);
+	/* Terminate immediately. */
 	exit(1);
 }
 
+/*---------------------------------------------------------------------
+ * ParseDoWarning  --
+ *	Handle warning directive
+ *
+ *	The input is the line minus the ".warning".  We substitute variables
+ *	and print the message or just print a warning if the ".warning"
+ *	directive is malformed.
+ *
+ *---------------------------------------------------------------------
+ */
+static void
+ParseDoWarning(char *warnmsg)
+{
+	if (!isspace((unsigned char) *warnmsg)) {
+		Parse_Error(PARSE_WARNING, "invalid syntax: .warning%s",
+		    warnmsg);
+		return;
+	}
+	
+	while (isspace((unsigned char) *warnmsg))
+		warnmsg++;
+	
+	warnmsg = Var_Subst(NULL, warnmsg, VAR_GLOBAL, FALSE);
+
+	Parse_Error(PARSE_WARNING, "%s", warnmsg);
+}
+
 /*-
  *---------------------------------------------------------------------
  * ParseDoInclude  --
@@ -2367,6 +2394,9 @@
 		    goto nextLine;
 		} else if (strncmp (cp, "error", 5) == 0) {
 		    ParseDoError(cp + 5);
+	            goto nextLine;	    
+		} else if (strncmp (cp, "warning", 7) == 0) {
+		    ParseDoWarning(cp + 7);
 	            goto nextLine;	    
 		} else if (strncmp(cp, "undef", 5) == 0) {
 		    char *cp2;
---------------------
PatchSet 340
Date: 2004/04/12 19:00:54
Author: ru
Log:
Document the new .warning directive.

Members: 
	make.1:1.66->1.67 

Index: make.1
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/make.1,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -r1.66 -r1.67
--- make.1	21 Jan 2004 17:58:33 -0000	1.66
+++ make.1	12 Apr 2004 18:00:54 -0000	1.67
@@ -32,7 +32,7 @@
 .\"	@(#)make.1	8.8 (Berkeley) 6/13/95
 .\" $FreeBSD$
 .\"
-.Dd July 2, 2004
+.Dd April 12, 2004
 .Dt MAKE 1
 .Os
 .Sh NAME
@@ -760,9 +760,15 @@
 Terminate processing of the makefile immediately.
 The filename of the
 makefile, the line on which the error was encountered and the specified
-message are printed to standard output and
+message are printed to the standard error output and
 .Nm
 terminates with exit code 1.
+Variables in the message are expanded.
+.It Ic \&.warning Ar message
+Emit a warning message.
+The filename of the makefile,
+the line on which the warning was encountered,
+and the specified message are printed to the standard error output.
 Variables in the message are expanded.
 .El
 .Pp
---------------------
PatchSet 343
Date: 2004/05/19 10:51:58
Author: ru
Log:
Markup nits.

Members: 
	make.1:1.67->1.68 

Index: make.1
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/make.1,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -r1.67 -r1.68
--- make.1	12 Apr 2004 18:00:54 -0000	1.67
+++ make.1	19 May 2004 09:51:58 -0000	1.68
@@ -753,13 +753,13 @@
 .Fl I
 option are searched before the system
 makefile directory.
-.It Ic \&.undef Ar variable
+.It Ic .undef Ar variable
 Un-define the specified global variable.
 Only global variables may be un-defined.
 .It Ic \&.makeenv Ar variable
 Set the environment flag for a preexisting global variable.  The current
 and future contents of the variable will be exported to the environment.
-.It Ic \&.error Ar message
+.It Ic .error Ar message
 Terminate processing of the makefile immediately.
 The filename of the
 makefile, the line on which the error was encountered and the specified
@@ -764,7 +764,7 @@
 .Nm
 terminates with exit code 1.
 Variables in the message are expanded.
-.It Ic \&.warning Ar message
+.It Ic .warning Ar message
 Emit a warning message.
 The filename of the makefile,
 the line on which the warning was encountered,
@@ -779,7 +779,7 @@
 The following conditionals are supported:
 .Bl -tag -width Ds
 .It Xo
-.Ic \&.if
+.Ic .if
 .Oo \&! Oc Ns Ar expression
 .Op Ar operator expression ...
 .Xc
@@ -863,7 +863,7 @@
 .Ar operator
 may be any one of the following:
 .Bl -tag -width "Cm XX"
-.It Cm \&|\&|
+.It Cm ||
 logical
 .Tn OR
 .It Cm &&
@@ -972,7 +972,7 @@
 .Bl -tag -width indent -compact
 .It Ic .for Ar variable Ic in Ar expression
 .It <make-rules>
-.It Ic \&.endfor
+.It Ic .endfor
 .El
 .Pp
 After the for
@@ -986,7 +986,7 @@
 inside the body of the for loop.
 .Sh COMMENTS
 Comments begin with a hash
-.Pq Ql \&#
+.Pq Ql #
 character, anywhere but in a shell
 command line, and continue to the end of the line.
 .Sh SPECIAL SOURCES
---------------------
PatchSet 347
Date: 2004/07/02 23:22:27
Author: ru
Log:
Mechanically kill hard sentence breaks.

Members: 
	make.1:1.70->1.71 

Index: make.1
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/make.1,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -r1.70 -r1.71
--- make.1	2 Jul 2004 12:34:13 -0000	1.70
+++ make.1	2 Jul 2004 22:22:27 -0000	1.71
@@ -347,7 +347,7 @@
 .It Ic \&?=
 Assign the value to the variable if it is not already defined.
 .It Ic \&:=
-Assign with expansion, i.e. expand the value before assigning it
+Assign with expansion, i.e., expand the value before assigning it
 to the variable.
 Normally, expansion is not done until the variable is referenced.
 .It Ic \&!=
@@ -1058,7 +1058,7 @@
 detected and targets that form loops will be silently ignored.
 .El
 .Sh "SPECIAL TARGETS"
-Special targets may not be included with other targets, i.e. they must be
+Special targets may not be included with other targets, i.e., they must be
 the only target specified.
 .Bl -tag -width Ic
 .It Ic .BEGIN
---------------------
PatchSet 349
Date: 2004/07/18 03:26:30
Author: keramida
Log:
Remove the dependency of the :C/regexp/replacement/ variable modifier
from the :S modifier which follows a bit further below.  This way the
reader can read each of these two descriptions without having to jump
back and forth in the manpage.

PR:		docs/26943
Submitted by:	Alex Kapranoff <alex@xxxxxxxxxxxxxxxxxxxxxxxxxx>

Members: 
	make.1:1.71->1.72 

Index: make.1
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/make.1,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -r1.71 -r1.72
--- make.1	2 Jul 2004 22:22:27 -0000	1.71
+++ make.1	18 Jul 2004 02:26:30 -0000	1.72
@@ -618,16 +618,15 @@
 .No \&/ Op Cm 1g
 .Xc
 .Sm on
-The
-.Cm C
-modifier is just like the
-.Cm S
-modifier except that the old and new strings, instead of being
-simple strings, are an extended regular expression (see
+Modify each word of the value,
+substituting every match of the extended regular expression
+.Ar pattern
+(see
 .Xr re_format 7 )
-and an
+with the
 .Xr ed 1 Ns \-style
-replacement string.
+.Ar replacement
+string.
 Normally, the first occurrence of the pattern in
 each word of the value is changed.
 The
---------------------
PatchSet 350
Date: 2004/07/19 15:42:57
Author: harti
Log:
Make it clearer what means 'won't work' for .if string == ${VAR}.

Replace the use of '=' in conditionals in the examples
by the more correct '=='.

Clarify the example explaining that .for expansion takes place before
. if handling by showing the correct code instead of saying 'the other
way around'. Change a variable name there so the example is more parseable
to the human reader.

PR:		docs/65400
Submitted by:	Roman Neuhauser <neuhauser@xxxxxxxxx>

Members: 
	make.1:1.72->1.73 

Index: make.1
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/make.1,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -r1.72 -r1.73
--- make.1	18 Jul 2004 02:26:30 -0000	1.72
+++ make.1	19 Jul 2004 14:42:57 -0000	1.73
@@ -1270,19 +1270,26 @@
 Currently, the only form that works is
 .Ql .if ${VAR} op something
 For instance, you should write tests as
-.Ql .if ${VAR} = "string"
-not the other way around, which doesn't work.
+.Ql .if ${VAR} == "string"
+not the other way around, which would give you an error.
 .Pp
 For loops are expanded before tests, so a fragment such as:
 .Bd -literal -offset indent
-\&.for TMACHINE in ${SHARED_ARCHS}
-\&.if ${TMACHINE} = ${MACHINE}
+\&.for ARCH in ${SHARED_ARCHS}
+\&.if ${ARCH} == ${MACHINE}
      ...
 \&.endif
 \&.endfor
 .Ed
 .Pp
-won't work, and should be rewritten the other way around.
+won't work, and should be rewritten as:
+.Bd -literal -offset indent
+\&.for ARCH in ${SHARED_ARCHS}
+\&.if ${MACHINE} == ${ARCH} 
+     ...
+\&.endif
+\&.endfor
+.Ed
 .Pp
 The parsing code is broken with respect to handling a semicolon
 after a colon, so a fragment like this will fail:
---------------------
PatchSet 351
Date: 2004/07/20 08:42:06
Author: harti
Log:
Improve make's diagnostic of mistmatched .if-.endif. This patch is
slightly different from the patch in the PR. The problem is, that
make handles .if clauses inside false .if clauses simply by
counting them - it doesn't put them onto the conditional stack, nor even
parses them so we need an extra line number stack for these ifs.

PR:		bin/61257
Submitted by:	Mikhail Teterin <mi@xxxxxxxxxxxxxxxxx>

Members: 
	cond.c:1.27->1.28 
	make.h:1.23->1.24 
	parse.c:1.55->1.56 

Index: cond.c
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/cond.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- cond.c	7 Sep 2003 02:16:10 -0000	1.27
+++ cond.c	20 Jul 2004 07:42:06 -0000	1.28
@@ -133,8 +133,10 @@
 #define	MAXIF		30	  /* greatest depth of #if'ing */
 
 static Boolean	  condStack[MAXIF]; 	/* Stack of conditionals's values */
+static int	  condLineno[MAXIF];	/* Line numbers of the opening .if */
 static int  	  condTop = MAXIF;  	/* Top-most conditional */
 static int  	  skipIfLevel=0;    	/* Depth of skipped conditionals */
+static int	  skipIfLineno[MAXIF];  /* Line numbers of skipped .ifs */
 static Boolean	  skipLine = FALSE; 	/* Whether the parse module is skipping
 					 * lines */
 
@@ -1047,8 +1049,10 @@
     Boolean 	    isElse;
     Boolean 	    value = FALSE;
     int	    	    level;  	/* Level at which to report errors. */
+    int		    lineno;
 
     level = PARSE_FATAL;
+    lineno = curFile.lineno;
 
     for (line++; *line == ' ' || *line == '\t'; line++) {
 	continue;
@@ -1109,6 +1113,7 @@
 		return (COND_INVALID);
 	    } else if (skipIfLevel == 0) {
 		value = !condStack[condTop];
+		lineno = condLineno[condTop];
 	    } else {
 		return (COND_SKIP);
 	    }
@@ -1130,6 +1135,7 @@
 		 * undefined, for which there's an enclosing ifdef that
 		 * we're skipping...
 		 */
+	        skipIfLineno[skipIfLevel - 1] = lineno;
 		return(COND_SKIP);
 	    }
 	} else if (skipLine) {
@@ -1137,6 +1143,7 @@
 	     * Don't even try to evaluate a conditional that's not an else if
 	     * we're skipping things...
 	     */
+	    skipIfLineno[skipIfLevel] = lineno;
 	    skipIfLevel += 1;
 	    return(COND_SKIP);
 	}
@@ -1202,6 +1209,7 @@
 	return (COND_INVALID);
     } else {
 	condStack[condTop] = value;
+	condLineno[condTop] = lineno;
 	skipLine = !value;
 	return (value ? COND_PARSE : COND_SKIP);
     }
@@ -1223,9 +1231,20 @@
 void
 Cond_End(void)
 {
+    int level;
+
     if (condTop != MAXIF) {
-	Parse_Error(PARSE_FATAL, "%d open conditional%s", MAXIF-condTop,
-		    MAXIF-condTop == 1 ? "" : "s");
+	Parse_Error(PARSE_FATAL, "%d open conditional%s:",
+	    MAXIF - condTop + skipIfLevel,
+ 	    MAXIF - condTop + skipIfLevel== 1 ? "" : "s");
+
+	for (level = skipIfLevel; level > 0; level--)
+		Parse_Error(PARSE_FATAL, "\t%*sat line %d (skipped)",
+		    MAXIF - condTop + level + 1, "", skipIfLineno[level - 1]);
+	for (level = condTop; level < MAXIF; level++)
+		Parse_Error(PARSE_FATAL, "\t%*sat line %d "
+		    "(evaluated to %s)", MAXIF - level + skipIfLevel, "",
+		    condLineno[level], condStack[level] ? "true" : "false");
     }
     condTop = MAXIF;
 }
Index: make.h
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/make.h,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- make.h	10 Oct 2002 19:27:48 -0000	1.23
+++ make.h	20 Jul 2004 07:42:06 -0000	1.24
@@ -141,6 +141,21 @@
 				 * but the Suff module) */
 } GNode;
 
+
+/*
+ * Definitions for handling #include specifications
+ */
+typedef struct {
+    char *str;
+    char *ptr;
+} PTR;
+typedef struct IFile {
+    char            *fname;	    /* name of previous file */
+    int             lineno;	    /* saved line number */
+    FILE	    *F;		    /* the open stream */
+    PTR		    *p;	    	    /* the char pointer */
+} IFile;
+
 /*
  * The OP_ constants are used when parsing a dependency line as a way of
  * communicating to other parts of the program the way in which a target
@@ -273,6 +288,7 @@
 				 * make(...) statements */
 extern Lst     	dirSearchPath; 	/* The list of directories to search when
 				 * looking for targets */
+extern IFile	curFile;	/* current makefile */
 extern Lst	parseIncPath;	/* The list of directories to search when
 				 * looking for includes */
 
Index: parse.c
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/parse.c,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -r1.55 -r1.56
--- parse.c	2 Jul 2004 12:30:28 -0000	1.55
+++ parse.c	20 Jul 2004 07:42:06 -0000	1.56
@@ -105,27 +105,13 @@
 static Lst     	    targCmds;	/* command lines for targets */
 static Boolean	    inLine;	/* true if currently in a dependency
 				 * line or its commands */
-typedef struct {
-    char *str;
-    char *ptr;
-} PTR;
-
 static int	    fatals = 0;
 
 static GNode	    *mainNode;	/* The main target to create. This is the
 				 * first target on the first dependency
 				 * line in the first makefile */
-/*
- * Definitions for handling #include specifications
- */
-typedef struct IFile {
-    char           *fname;	    /* name of previous file */
-    int             lineno;	    /* saved line number */
-    FILE *          F;		    /* the open stream */
-    PTR *	    p;	    	    /* the char pointer */
-} IFile;
 
-static IFile	    curFile;
+IFile	    	curFile;	/* current makefile */
 
 static Lst      includes;  	/* stack of IFiles generated by
 				 * #includes */
---------------------
PatchSet 352
Date: 2004/07/22 12:12:01
Author: harti
Log:
Fix handling of comments on .elif lines. The patch given in a followup
to the PR failed, because the line skipping function is actually called
from two places in the code to do quite different things (this should
be two functions probably): in a false .if to skip to the next line
beginning with a dot and to collect .for loops. In the seconds case we
should not skip comments, because they are actually harder to handle than
we need for the .if case and should defer this to the main code.

PR:		bin/25627
Submitted by:	Seth Kingsley (original patch)

Members: 
	parse.c:1.56->1.57 

Index: parse.c
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/parse.c,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -r1.56 -r1.57
--- parse.c	20 Jul 2004 07:42:06 -0000	1.56
+++ parse.c	22 Jul 2004 11:12:01 -0000	1.57
@@ -2021,6 +2021,13 @@
 
         while (((c = ParseReadc()) != '\n' || lastc == '\\')
                && c != EOF) {
+            if (skip && c == '#' && lastc != '\\') {
+		/* let a comment be terminated even by an escaped \n.
+		 * This is consistent to comment handling in ParseReadLine */
+                while ((c = ParseReadc()) != '\n' && c != EOF)
+		    ;
+		break;
+	    }
             if (c == '\n') {
                 if (keep_newline)
                     Buf_AddByte(buf, (Byte)c);
---------------------
PatchSet 353
Date: 2004/07/29 15:29:23
Author: harti
Log:
Implement POSIX's '+' flag for command lines. This flag causes a line
to be executed even when -n is given on the command line to make. This is
very handy for calls to submakes.

This is slightly changed from the original patch as obtained from NetBSD.
The NetBSD variant prints lines which have both '+' and '@' when -n
is specified. The commited version always obeys '@'.

Bump MAKE_VERSION so Makefiles can use this conditionally.

PR:		standards/66357 (partly)
Submitted by:	Mark Baushke <mdb@xxxxxxxxxxx>
Obtained from:	NetBSD

Members: 
	Makefile:1.30->1.31 
	compat.c:1.36->1.37 
	job.c:1.49->1.50 
	make.1:1.73->1.74 
	nonints.h:1.20->1.21 

Index: Makefile
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/Makefile,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- Makefile	28 Oct 2002 23:33:57 -0000	1.30
+++ Makefile	29 Jul 2004 14:29:23 -0000	1.31
@@ -15,3 +15,3 @@
 
 NOSHARED?=	YES
 
-CFLAGS+=-DMAKE_VERSION=\"5200208240\"
+CFLAGS+=-DMAKE_VERSION=\"5200407290\"
Index: compat.c
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/compat.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- compat.c	3 Oct 2003 21:33:39 -0000	1.36
+++ compat.c	29 Jul 2004 14:29:23 -0000	1.37
@@ -80,7 +80,6 @@
 static GNode	    *curTarg = NULL;
 static GNode	    *ENDNode;
 static void CompatInterrupt(int);
-static int CompatRunCommand(void *, void *);
 static int CompatMake(void *, void *);
 static int shellneed(char *);
 
@@ -88,6 +87,20 @@
 	"alias", "cd", "eval", "exec", "exit", "read", "set", "ulimit", 
 	"unalias", "umask", "unset", "wait", ":", 0};
 
+static void
+CompatInit(void)
+{
+    char    	  *cp;	    /* Pointer to string of shell meta-characters */
+
+    for (cp = "#=|^(){};&<>*?[]:$`\\\n"; *cp != '\0'; cp++) {
+	meta[(unsigned char) *cp] = 1;
+    }
+    /*
+     * The null character serves as a sentinel in the string.
+     */
+    meta[0] = 1;
+}
+
 /*-
  *-----------------------------------------------------------------------
  * CompatInterrupt --
@@ -123,7 +136,7 @@
 	if (signo == SIGINT) {
 	    gn = Targ_FindNode(".INTERRUPT", TARG_NOCREATE);
 	    if (gn != NULL) {
-		Lst_ForEach(gn->commands, CompatRunCommand, (void *)gn);
+		Lst_ForEach(gn->commands, Compat_RunCommand, (void *)gn);
 	    }
 	}
 
@@ -162,7 +175,7 @@
 
 /*-
  *-----------------------------------------------------------------------
- * CompatRunCommand --
+ * Compat_RunCommand --
  *	Execute the next command for a target. If the command returns an
  *	error, the node's made field is set to ERROR and creation stops.
  *	The node from which the command came is also given.
@@ -175,12 +188,13 @@
  *
  *-----------------------------------------------------------------------
  */
-static int
-CompatRunCommand (void *cmdp, void *gnp)
+int
+Compat_RunCommand (void *cmdp, void *gnp)
 {
     char    	  *cmdStart;	/* Start of expanded command */
     char	  *cp;
     Boolean 	  silent,   	/* Don't print command */
+		  doit,		/* Execute even in -n */
 		  errCheck; 	/* Check errors */
     int 	  reason;   	/* Reason for child's death */
     int	    	  status;   	/* Description of child's death */
@@ -204,6 +218,7 @@
 #endif
     silent = gn->type & OP_SILENT;
     errCheck = !(gn->type & OP_IGNORE);
+    doit = FALSE;
 
     cmdNode = Lst_Member (gn->commands, (void *)cmd);
     cmdStart = Var_Subst (NULL, cmd, gn, FALSE);
@@ -232,11 +247,22 @@
 	return(0);
     }
 
-    while ((*cmd == '@') || (*cmd == '-')) {
-	if (*cmd == '@') {
+    while ((*cmd == '@') || (*cmd == '-') || (*cmd == '+')) {
+	switch (*cmd) {
+
+	  case '@':
 	    silent = DEBUG(LOUD) ? FALSE : TRUE;
-	} else {
+	    break;
+
+	  case '-':
 	    errCheck = FALSE;
+	    break;
+
+	  case '+':
+	    doit = TRUE;
+	    if (!meta[0])		/* we came here from jobs */
+		CompatInit();
+	    break;
 	}
 	cmd++;
     }
@@ -255,9 +281,9 @@
 
     /*
      * Print the command before echoing if we're not supposed to be quiet for
-     * this one. We also print the command if -n given.
+     * this one. We also print the command if -n given, but not if '+'.
      */
-    if (!silent || noExecute) {
+    if (!silent || (noExecute && !doit)) {
 	printf ("%s\n", cmd);
 	fflush(stdout);
     }
@@ -266,7 +292,7 @@
      * If we're not supposed to execute any commands, this is as far as
      * we go...
      */
-    if (noExecute) {
+    if (!doit && noExecute) {
 	return (0);
     }
 
@@ -470,7 +496,7 @@
 
 	/*
 	 * Alter our type to tell if errors should be ignored or things
-	 * should not be printed so CompatRunCommand knows what to do.
+	 * should not be printed so Compat_RunCommand knows what to do.
 	 */
 	if (Targ_Ignore (gn)) {
 	    gn->type |= OP_IGNORE;
@@ -486,7 +512,7 @@
 	     */
 	    if (!touchFlag) {
 		curTarg = gn;
-		Lst_ForEach (gn->commands, CompatRunCommand, (void *)gn);
+		Lst_ForEach (gn->commands, Compat_RunCommand, (void *)gn);
 		curTarg = NULL;
 	    } else {
 		Job_Touch (gn, gn->type & OP_SILENT);
@@ -625,10 +651,11 @@
 void
 Compat_Run(Lst targs)
 {
-    char    	  *cp;	    /* Pointer to string of shell meta-characters */
     GNode   	  *gn = NULL;/* Current root target */
     int	    	  errors;   /* Number of targets not remade due to errors */
 
+    CompatInit();
+
     if (signal(SIGINT, SIG_IGN) != SIG_IGN) {
 	signal(SIGINT, CompatInterrupt);
     }
@@ -642,14 +669,6 @@
 	signal(SIGQUIT, CompatInterrupt);
     }
 
-    for (cp = "#=|^(){};&<>*?[]:$`\\\n"; *cp != '\0'; cp++) {
-	meta[(unsigned char) *cp] = 1;
-    }
-    /*
-     * The null character serves as a sentinel in the string.
-     */
-    meta[0] = 1;
-
     ENDNode = Targ_FindNode(".END", TARG_CREATE);
     /*
      * If the user has defined a .BEGIN target, execute the commands attached
@@ -658,7 +677,7 @@
     if (!queryFlag) {
 	gn = Targ_FindNode(".BEGIN", TARG_NOCREATE);
 	if (gn != NULL) {
-	    Lst_ForEach(gn->commands, CompatRunCommand, (void *)gn);
+	    Lst_ForEach(gn->commands, Compat_RunCommand, (void *)gn);
             if (gn->made == ERROR) {
                 printf("\n\nStop.\n");
                 exit(1);
@@ -693,6 +712,6 @@
      * If the user has defined a .END target, run its commands.
      */
     if (errors == 0) {
-	Lst_ForEach(ENDNode->commands, CompatRunCommand, (void *)gn);
+	Lst_ForEach(ENDNode->commands, Compat_RunCommand, (void *)gn);
     }
 }
Index: job.c
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/job.c,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -r1.49 -r1.50
--- job.c	20 Apr 2004 22:04:12 -0000	1.49
+++ job.c	29 Jul 2004 14:29:23 -0000	1.50
@@ -550,13 +550,30 @@
     cmdTemplate = "%s\n";
 
     /*
-     * Check for leading @' and -'s to control echoing and error checking.
+     * Check for leading @', -' or +'s to control echoing, error checking,
+     * and execution on -n.
      */
-    while (*cmd == '@' || *cmd == '-') {
-	if (*cmd == '@') {
+    while (*cmd == '@' || *cmd == '-' || *cmd == '+') {
+	switch (*cmd) {
+
+	  case '@':
 	    shutUp = DEBUG(LOUD) ? FALSE : TRUE;
-	} else {
+	    break;
+
+	  case '-':
 	    errOff = TRUE;
+	    break;
+
+	  case '+':
+	    if (noSpecials) {
+		/*
+		 * We're not actually exececuting anything...
+		 * but this one needs to be - use compat mode just for it.
+		 */
+		Compat_RunCommand(cmdp, job->node);
+		return (0);
+	    }
+	    break;
 	}
 	cmd++;
     }
Index: make.1
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/make.1,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -r1.73 -r1.74
--- make.1	19 Jul 2004 14:42:57 -0000	1.73
+++ make.1	29 Jul 2004 14:29:23 -0000	1.74
@@ -320,10 +320,11 @@
 .Sq Ic ::
 operator is used.
 .Pp
-If the first or first two characters of the command line are
-.Sq Ic @
-and/or
+If the first characters of the command line are
+.Sq Ic @ ,
 .Sq Ic \- ,
+and/or
+.Sq Ic + ,
 the command is treated specially.
 A
 .Sq Ic @
@@ -331,6 +332,11 @@
 A
 .Sq Ic \-
 causes any non-zero exit status of the command line to be ignored.
+A
+.Sq Ic +
+causes the command to be executed even if
+.Fl n
+is specified on the command line.
 .Sh VARIABLE ASSIGNMENTS
 Variables in
 .Nm
Index: nonints.h
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/nonints.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- nonints.h	10 Mar 2004 21:51:06 -0000	1.20
+++ nonints.h	29 Jul 2004 14:29:23 -0000	1.21
@@ -52,6 +52,7 @@
 
 /* compat.c */
 void Compat_Run(Lst);
+int Compat_RunCommand(void *, void *);
 
 /* cond.c */
 int Cond_Eval(char *);
---------------------
PatchSet 354
Date: 2004/07/29 17:54:42
Author: harti
Log:
Bump the date in .Dd for the recent '+' flag commit.

Requested by: ru

Members: 
	make.1:1.74->1.75 

Index: make.1
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/make.1,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -r1.74 -r1.75
--- make.1	29 Jul 2004 14:29:23 -0000	1.74
+++ make.1	29 Jul 2004 16:54:42 -0000	1.75
@@ -32,7 +32,7 @@
 .\"	@(#)make.1	8.8 (Berkeley) 6/13/95
 .\" $FreeBSD$
 .\"
-.Dd April 12, 2004
+.Dd July 29, 2004
 .Dt MAKE 1
 .Os
 .Sh NAME
---------------------
PatchSet 356
Date: 2004/08/03 19:56:31
Author: harti
Log:
Put variable assignments from the command line into the MAKEFLAGS
variable as required by POSIX. This causes such variables to be
pushed into all sub-makes called by the make (except when the MAKEFLAGS
variable is explicitely changed in the sub-make's environment).
This makes them also mostly un-overrideable in sub-makes except on the
sub-make's command line. Therefor specifying 'make CC=icc' will cause
icc to be used as C compiler in all sub-makes no matter what the Makefiles
itself try to do to the CC variable.

This patch also corrects the handling of the MFLAGS variable. MFLAGS
contains all the command line flags but not the command line variable
assignments. The evaluation of the .MFLAGS or .MAKEFLAGS target now
changes both MFLAGS and MAKEFLAGS (they used to change MAKEFLAGS only).
Makefiles can use MFLAGS for their own purposes given that they do not
except MFLAGS to be undefined at the beginning and that they don't evaluate
. MFLAGS or .MAKEFLAGS. MFLAGS should be removed for POSIX compliance,
but it is unfortunately heavily used by the X makefiles.

This has been extensively tested by port builds (thanks to portmgr), new
worlds and kernels.

PR:		standards/57295 (1st part above)
Submitted by:	James E. Flemer <jflemer@xxxxxxxxxxxx>
Approved by:	portmgr
Obtained from:	NetBSD (1st part above)
MFC after:	4 weeks

Members: 
	Makefile:1.31->1.32 
	main.c:1.89->1.90 
	nonints.h:1.21->1.22 
	var.c:1.46->1.47 

Index: Makefile
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/Makefile,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- Makefile	29 Jul 2004 14:29:23 -0000	1.31
+++ Makefile	3 Aug 2004 18:56:31 -0000	1.32
@@ -15,4 +15,4 @@
 
 NOSHARED?=	YES
 
-CFLAGS+=-DMAKE_VERSION=\"5200407290\"
+CFLAGS+=-DMAKE_VERSION=\"5200408030\"
Index: main.c
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/main.c,v
retrieving revision 1.89
retrieving revision 1.90
diff -u -r1.89 -r1.90
--- main.c	3 Aug 2004 18:43:43 -0000	1.89
+++ main.c	3 Aug 2004 18:56:31 -0000	1.90
@@ -132,6 +132,21 @@
 static char *curdir;			/* startup directory */
 static char *objdir;			/* where we chdir'ed to */
 
+/*
+ * Append a flag with an optional argument to MAKEFLAGS and MFLAGS
+ */
+static void
+MFLAGS_append(char *flag, char *arg)
+{
+	Var_Append(MAKEFLAGS, flag, VAR_GLOBAL);
+	if (arg != NULL)
+		Var_Append(MAKEFLAGS, arg, VAR_GLOBAL);
+
+	Var_Append("MFLAGS", flag, VAR_GLOBAL);
+	if (arg != NULL)
+		Var_Append("MFLAGS", arg, VAR_GLOBAL);
+}
+
 /*-
  * MainParseArgs --
  *	Parse a given argument vector. Called from main() and from
@@ -166,25 +181,22 @@
 			break;
 		case 'D':
 			Var_Set(optarg, "1", VAR_GLOBAL);
-			Var_Append(MAKEFLAGS, "-D", VAR_GLOBAL);
-			Var_Append(MAKEFLAGS, optarg, VAR_GLOBAL);
+			MFLAGS_append("-D", optarg);
 			break;
 		case 'I':
 			Parse_AddIncludeDir(optarg);
-			Var_Append(MAKEFLAGS, "-I", VAR_GLOBAL);
-			Var_Append(MAKEFLAGS, optarg, VAR_GLOBAL);
+			MFLAGS_append("-I", optarg);
 			break;
 		case 'V':
 			(void)Lst_AtEnd(variables, (void *)optarg);
-			Var_Append(MAKEFLAGS, "-V", VAR_GLOBAL);
-			Var_Append(MAKEFLAGS, optarg, VAR_GLOBAL);
+			MFLAGS_append("-V", optarg);
 			break;
 		case 'X':
 			expandVars = FALSE;
 			break;
 		case 'B':
 			compatMake = TRUE;
-			Var_Append(MAKEFLAGS, "-B", VAR_GLOBAL);
+			MFLAGS_append("-B", NULL);
 			break;
 #ifdef REMOTE
 		case 'L': {
@@ -196,18 +208,17 @@
 				    optarg);
 				usage();
 			}
-			Var_Append(MAKEFLAGS, "-L", VAR_GLOBAL);
-			Var_Append(MAKEFLAGS, optarg, VAR_GLOBAL);
+			MFLAGS_append("-L", optarg);
 			break;
 		}
 #endif
 		case 'P':
 			usePipes = FALSE;
-			Var_Append(MAKEFLAGS, "-P", VAR_GLOBAL);
+			MFLAGS_append("-P", NULL);
 			break;
 		case 'S':
 			keepgoing = FALSE;
-			Var_Append(MAKEFLAGS, "-S", VAR_GLOBAL);
+			MFLAGS_append("-S", NULL);
 			break;
 		case 'd': {
 			char *modules = optarg;
@@ -261,27 +272,25 @@
 					warnx("illegal argument to d option -- %c", *modules);
 					usage();
 				}
-			Var_Append(MAKEFLAGS, "-d", VAR_GLOBAL);
-			Var_Append(MAKEFLAGS, optarg, VAR_GLOBAL);
+			MFLAGS_append("-d", optarg);
 			break;
 		}
 		case 'E':
 			p = emalloc(strlen(optarg) + 1);
 			(void)strcpy(p, optarg);
 			(void)Lst_AtEnd(envFirstVars, (void *)p);
-			Var_Append(MAKEFLAGS, "-E", VAR_GLOBAL);
-			Var_Append(MAKEFLAGS, optarg, VAR_GLOBAL);
+			MFLAGS_append("-E", optarg);
 			break;
 		case 'e':
 			checkEnvFirst = TRUE;
-			Var_Append(MAKEFLAGS, "-e", VAR_GLOBAL);
+			MFLAGS_append("-e", NULL);
 			break;
 		case 'f':
 			(void)Lst_AtEnd(makefiles, (void *)optarg);
 			break;
 		case 'i':
 			ignoreErrors = TRUE;
-			Var_Append(MAKEFLAGS, "-i", VAR_GLOBAL);
+			MFLAGS_append("-i", NULL);
 			break;
 		case 'j': {
 			char *endptr;
@@ -296,43 +305,41 @@
 #ifndef REMOTE
 			maxLocal = maxJobs;
 #endif
-			Var_Append(MAKEFLAGS, "-j", VAR_GLOBAL);
-			Var_Append(MAKEFLAGS, optarg, VAR_GLOBAL);
+			MFLAGS_append("-j", optarg);
 			break;
 		}
 		case 'k':
 			keepgoing = TRUE;
-			Var_Append(MAKEFLAGS, "-k", VAR_GLOBAL);
+			MFLAGS_append("-k", NULL);
 			break;
 		case 'm':
 			Dir_AddDir(sysIncPath, optarg);
-			Var_Append(MAKEFLAGS, "-m", VAR_GLOBAL);
-			Var_Append(MAKEFLAGS, optarg, VAR_GLOBAL);
+			MFLAGS_append("-m", optarg);
 			break;
 		case 'n':
 			noExecute = TRUE;
-			Var_Append(MAKEFLAGS, "-n", VAR_GLOBAL);
+			MFLAGS_append("-n", NULL);
 			break;
 		case 'q':
 			queryFlag = TRUE;
 			/* Kind of nonsensical, wot? */
-			Var_Append(MAKEFLAGS, "-q", VAR_GLOBAL);
+			MFLAGS_append("-q", NULL);
 			break;
 		case 'r':
 			noBuiltins = TRUE;
-			Var_Append(MAKEFLAGS, "-r", VAR_GLOBAL);
+			MFLAGS_append("-r", NULL);
 			break;
 		case 's':
 			beSilent = TRUE;
-			Var_Append(MAKEFLAGS, "-s", VAR_GLOBAL);
+			MFLAGS_append("-s", NULL);
 			break;
 		case 't':
 			touchFlag = TRUE;
-			Var_Append(MAKEFLAGS, "-t", VAR_GLOBAL);
+			MFLAGS_append("-t", NULL);
 			break;
 		case 'v':
 			beVerbose = TRUE;
-			Var_Append(MAKEFLAGS, "-v", VAR_GLOBAL);
+			MFLAGS_append("-v", NULL);
 			break;
 		default:
 		case '?':
@@ -638,6 +645,10 @@
 
 	MainParseArgs(argc, argv);
 
+#ifdef POSIX
+	Var_AddCmdLine(MAKEFLAGS);
+#endif
+
 	/*
 	 * Find where we are...
 	 * All this code is so that we know where we are when we start up
@@ -779,9 +790,6 @@
 		(void)ReadMakefile("Makefile", NULL);
 
 	(void)ReadMakefile(".depend", NULL);
-
-	Var_Append("MFLAGS", Var_Value(MAKEFLAGS, VAR_GLOBAL, &p1), VAR_GLOBAL);
-	free(p1);
 
 	/* Install all the flags into the MAKE envariable. */
 	if (((p = Var_Value(MAKEFLAGS, VAR_GLOBAL, &p1)) != NULL) && *p)
Index: nonints.h
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/nonints.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- nonints.h	29 Jul 2004 14:29:23 -0000	1.21
+++ nonints.h	3 Aug 2004 18:56:31 -0000	1.22
@@ -136,6 +136,7 @@
 void Var_Append(char *, char *, GNode *);
 Boolean Var_Exists(char *, GNode *);
 char *Var_Value(char *, GNode *, char **);
+void Var_AddCmdLine(char *);
 char *Var_Parse(char *, GNode *, Boolean, int *, Boolean *);
 char *Var_Subst(char *, char *, GNode *, Boolean);
 char *Var_GetTail(char *);
Index: var.c
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/var.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -r1.46 -r1.47
--- var.c	12 Jan 2004 10:35:46 -0000	1.46
+++ var.c	3 Aug 2004 18:56:31 -0000	1.47
@@ -832,6 +832,44 @@
 }
 
 
+#ifdef POSIX
+
+
+/* In POSIX mode, variable assignments passed on the command line are
+ * propagated to sub makes through MAKEFLAGS.
+ */
+void
+Var_AddCmdLine(char *name)
+{
+    const Var *v;
+    LstNode ln;
+    Buffer buf;
+    static const char quotable[] = " \t\n\\'\"";
+    char *s;
+    int first = 1;
+
+    buf = Buf_Init (MAKE_BSIZE);
+
+    for (ln = Lst_First(VAR_CMD->context); ln != NULL;
+	ln = Lst_Succ(ln)) {
+	    if (!first)
+	    	Buf_AddByte(buf, ' ');
+	    first = 0;
+	    /* We assume variable names don't need quoting */
+	    v = (Var *)Lst_Datum(ln);
+	    Buf_AddBytes(buf, strlen(v->name), v->name);
+	    Buf_AddByte(buf, '=');
+	    for (s = Buf_GetAll(v->val, (int *)NULL); *s != '\0'; s++) {
+		if (strchr(quotable, *s))
+		    Buf_AddByte(buf, '\\');
+		Buf_AddByte(buf, *s);
+	    }
+    }
+    Var_Append(name, Buf_GetAll(buf, (int *)NULL), VAR_GLOBAL);
+    Buf_Destroy(buf, 1);
+}
+#endif
+
 /*-
  *-----------------------------------------------------------------------
  * Var_Parse --
---------------------
PatchSet 357
Date: 2004/08/03 20:14:14
Author: harti
Log:
Correct the description of the MFLAGS and .MAKEFLAGS variables. Add
the MFLAGS target. Document that variable assignments from the MAKEFLAGS
environment variable and the .MAKEFLAGS and .MFLAGS target have the
same precedence as command line variable assignments.

Members: 
	make.1:1.75->1.76 

Index: make.1
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/make.1,v
retrieving revision 1.75
retrieving revision 1.76
diff -u -r1.75 -r1.76
--- make.1	29 Jul 2004 16:54:42 -0000	1.75
+++ make.1	3 Aug 2004 19:14:14 -0000	1.76
@@ -395,7 +395,12 @@
 .It Global variables
 Variables defined in the makefile or in included makefiles.
 .It Command line variables
-Variables defined as part of the command line.
+Variables defined as part of the command line and variables
+obtained from the
+.Ev MAKEFLAGS
+environment variable or the
+.Ic .MAKEFLAGS
+target.
 .It Local variables
 Variables that are defined specific to a certain target.
 The seven local variables are as follows:
@@ -559,9 +564,9 @@
 .Nm Ns 's
 .Va .MAKEFLAGS
 variable.
-Anything specified on
+All options and variable assignment specified on
 .Nm Ns 's
-command line is appended to the
+command line are appended to the
 .Va .MAKEFLAGS
 variable which is then
 entered into the environment as
@@ -570,9 +575,12 @@
 .Nm
 executes.
 .It Va MFLAGS
-A synonym for
-.Va .MAKEFLAGS
-provided for backward compatibility.
+is provided for backward compatibility and
+contains all the options from the
+.Ev MAKEFLAGS
+environment variable plus any options specified on
+.Nm Ns 's
+command line.
 .It Va .TARGETS
 List of targets
 .Nm
@@ -1131,6 +1139,8 @@
 .Fl f
 option will have
 no effect.
+.It Ic .MFLAGS
+Same as above, for backward compatibility.
 .\" XXX: NOT YET!!!!
 .\" .It Ic .NOTPARALLEL
 .\" The named targets are executed in non parallel mode. If no targets are
---------------------
PatchSet 358
Date: 2004/08/04 16:10:35
Author: harti
Log:
Correct the .Dd date. Pluralize 'assignment' in one place.

Requested by: ru

Members: 
	make.1:1.76->1.77 

Index: make.1
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/make.1,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -r1.76 -r1.77
--- make.1	3 Aug 2004 19:14:14 -0000	1.76
+++ make.1	4 Aug 2004 15:10:35 -0000	1.77
@@ -32,7 +32,7 @@
 .\"	@(#)make.1	8.8 (Berkeley) 6/13/95
 .\" $FreeBSD$
 .\"
-.Dd July 29, 2004
+.Dd August 4, 2004
 .Dt MAKE 1
 .Os
 .Sh NAME
@@ -564,7 +564,7 @@
 .Nm Ns 's
 .Va .MAKEFLAGS
 variable.
-All options and variable assignment specified on
+All options and variable assignments specified on
 .Nm Ns 's
 command line are appended to the
 .Va .MAKEFLAGS
---------------------
PatchSet 359
Date: 2004/08/09 17:13:54
Author: harti
Log:
Make explicit that MAKEOBJDIRPREFIX and MAKOBJDIR must be set
as environment variables and should not be set on make's command
line. They happen to work accidentially as command line variables
too when none of the sub-makes wants to play games with them (because
make is putting command line variables into the environment and will
find them there later on). Makefile.inc1 wants to change
MAKEOBJDIRPREFIX. In this case one cannot set it on the command line.

Members: 
	make.1:1.77->1.78 

Index: make.1
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/make.1,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -r1.77 -r1.78
--- make.1	4 Aug 2004 15:10:35 -0000	1.77
+++ make.1	9 Aug 2004 16:13:54 -0000	1.78
@@ -533,6 +533,13 @@
 .Nm
 is unable to change into any of the remaining three directories,
 then the current directory is used.
+Note, that
+.Ev MAKEOBJDIRPREFIX
+and
+.Ev MAKEOBJDIR
+must be environment variables and should not be set on
+.Nm Ns 's
+command line.
 .Pp
 The
 .Nm
---------------------
PatchSet 362
Date: 2004/09/06 16:25:07
Author: jmg
Log:
remove XXX comment now that the kernel is fixed, there isn't any obvious
reason to enable this as performance didn't significantly change...

MFC after:	3 days

Members: 
	Makefile:1.33->1.34 

Index: Makefile
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/Makefile,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- Makefile	12 Aug 2004 11:49:55 -0000	1.33
+++ Makefile	6 Sep 2004 15:25:07 -0000	1.34
@@ -20,7 +20,7 @@
 CFLAGS+=-D__FBSDID=__RCSID
 .endif
 
-# XXX: kernel currently broken
+# There is no obvious performance improvement currently.
 # CFLAGS+=-DUSE_KQUEUE
 
 main.o: ${MAKEFILE}
---------------------
PatchSet 360
Date: 2004/08/12 12:49:55
Author: harti
Log:
Put variable assignments on .MAKEFLAGS and .MFLAGS targets into
the .MAKEFLAGS variable so that these are also passed to sub-makes.
This makes the handling of variables in the command environment more
consistent.

PR:		bin/68853
Submitted by:	Martin Kamerhofer <data@xxxxxxxxxxxxxx>

Members: 
	Makefile:1.32->1.33 
	main.c:1.90->1.91 
	nonints.h:1.22->1.23 
	var.c:1.47->1.48 

Index: Makefile
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/Makefile,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- Makefile	3 Aug 2004 18:56:31 -0000	1.32
+++ Makefile	12 Aug 2004 11:49:55 -0000	1.33
@@ -15,4 +15,4 @@
 
 NOSHARED?=	YES
 
-CFLAGS+=-DMAKE_VERSION=\"5200408030\"
+CFLAGS+=-DMAKE_VERSION=\"5200408120\"
Index: main.c
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/main.c,v
retrieving revision 1.90
retrieving revision 1.91
diff -u -r1.90 -r1.91
--- main.c	3 Aug 2004 18:56:31 -0000	1.90
+++ main.c	12 Aug 2004 11:49:55 -0000	1.91
@@ -355,9 +355,14 @@
 	 * on the end of the "create" list.
 	 */
 	for (argv += optind, argc -= optind; *argv; ++argv, --argc)
-		if (Parse_IsVar(*argv))
+		if (Parse_IsVar(*argv)) {
+			char *ptr = Var_Quote(*argv);
+
+			Var_Append(MAKEFLAGS, ptr, VAR_GLOBAL);
+			free(ptr);
+
 			Parse_DoVar(*argv, VAR_CMD);
-		else {
+		} else {
 			if (!**argv)
 				Punt("illegal (null) argument.");
 			if (**argv == '-') {
@@ -644,10 +649,6 @@
 #endif
 
 	MainParseArgs(argc, argv);
-
-#ifdef POSIX
-	Var_AddCmdLine(MAKEFLAGS);
-#endif
 
 	/*
 	 * Find where we are...
Index: nonints.h
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/nonints.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- nonints.h	3 Aug 2004 18:56:31 -0000	1.22
+++ nonints.h	12 Aug 2004 11:49:55 -0000	1.23
@@ -136,7 +136,7 @@
 void Var_Append(char *, char *, GNode *);
 Boolean Var_Exists(char *, GNode *);
 char *Var_Value(char *, GNode *, char **);
-void Var_AddCmdLine(char *);
+char *Var_Quote(const char *);
 char *Var_Parse(char *, GNode *, Boolean, int *, Boolean *);
 char *Var_Subst(char *, char *, GNode *, Boolean);
 char *Var_GetTail(char *);
Index: var.c
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/var.c,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -r1.47 -r1.48
--- var.c	3 Aug 2004 18:56:31 -0000	1.47
+++ var.c	12 Aug 2004 11:49:55 -0000	1.48
@@ -815,45 +815,6 @@
     }
 }
 
-
-#ifdef POSIX
-
-
-/* In POSIX mode, variable assignments passed on the command line are
- * propagated to sub makes through MAKEFLAGS.
- */
-void
-Var_AddCmdLine(char *name)
-{
-    const Var *v;
-    LstNode ln;
-    Buffer buf;
-    static const char quotable[] = " \t\n\\'\"";
-    char *s;
-    int first = 1;
-
-    buf = Buf_Init (MAKE_BSIZE);
-
-    for (ln = Lst_First(VAR_CMD->context); ln != NULL;
-	ln = Lst_Succ(ln)) {
-	    if (!first)
-	    	Buf_AddByte(buf, ' ');
-	    first = 0;
-	    /* We assume variable names don't need quoting */
-	    v = (Var *)Lst_Datum(ln);
-	    Buf_AddBytes(buf, strlen(v->name), v->name);
-	    Buf_AddByte(buf, '=');
-	    for (s = Buf_GetAll(v->val, (int *)NULL); *s != '\0'; s++) {
-		if (strchr(quotable, *s))
-		    Buf_AddByte(buf, '\\');
-		Buf_AddByte(buf, *s);
-	    }
-    }
-    Var_Append(name, Buf_GetAll(buf, (int *)NULL), VAR_GLOBAL);
-    Buf_Destroy(buf, 1);
-}
-#endif
-
 /*-
  *-----------------------------------------------------------------------
  * Var_Quote --
@@ -773,7 +772,7 @@
 
 /*-
  *-----------------------------------------------------------------------
- * VarQuote --
+ * Var_Quote --
  *	Quote shell meta-characters in the string
  *
  * Results:
@@ -784,8 +783,8 @@
  *
  *-----------------------------------------------------------------------
  */
-static char *
-VarQuote(char *str)
+char *
+Var_Quote(const char *str)
 {
 
     Buffer  	  buf;
@@ -1526,7 +1486,7 @@
 		    /* FALLTHROUGH */
 		case 'Q':
 		    if (tstr[1] == endc || tstr[1] == ':') {
-			newStr = VarQuote (str);
+			newStr = Var_Quote (str);
 			cp = tstr + 1;
 			termc = *cp;
 			break;
---------------------
PatchSet 361
Date: 2004/08/18 14:25:46
Author: ru
Log:
Document the effects of modifying the .MAKEFLAGS internal
variable and using the .MAKEFLAGS special target, and the
differences between them.

Reviewed by:	harti

Members: 
	make.1:1.78->1.79 

Index: make.1
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/make.1,v
retrieving revision 1.78
retrieving revision 1.79
diff -u -r1.78 -r1.79
--- make.1	9 Aug 2004 16:13:54 -0000	1.78
+++ make.1	18 Aug 2004 13:25:46 -0000	1.79
@@ -32,7 +32,7 @@
 .\"	@(#)make.1	8.8 (Berkeley) 6/13/95
 .\" $FreeBSD$
 .\"
-.Dd August 4, 2004
+.Dd August 18, 2004
 .Dt MAKE 1
 .Os
 .Sh NAME
@@ -581,6 +581,15 @@
 for all programs which
 .Nm
 executes.
+By modifying the contents of the
+.Va .MAKEFLAGS
+variable, makefile can alter the contents of the
+.Va MAKEFLAGS
+environment variable made available for all programs which
+.Nm
+executes; compare with the
+.Ic .MAKEFLAGS
+special target below.
 .It Va MFLAGS
 is provided for backward compatibility and
 contains all the options from the
@@ -1146,6 +1155,20 @@
 .Fl f
 option will have
 no effect.
+Flags (except for
+.Fl f )
+and variable assignments specified as the source
+for this target are also appended to the
+.Va .MAKEFLAGS
+internal variable.
+Please note the difference between this target and the
+.Va .MAKEFLAGS
+internal variable: specifying an option or variable
+assignment as the source for this target will affect
+.Em both
+the current makefile and all processes that
+.Nm
+executes.
 .It Ic .MFLAGS
 Same as above, for backward compatibility.
 .\" XXX: NOT YET!!!!
---------------------
PatchSet 366
Date: 2004/11/04 12:57:41
Author: harti
Log:
Remove the remote stuff from make. This actually never worked in our make
because the necessary files were not imported with the original import.
If somebody really needs it, there is still the devel/pmake port.

This is just the first step and removes just everything that is ifdef'ed out.
Otherwise the code is unchanged.

Checked by:	md5

Approved by:	no objections on arch@

Members: 
	job.c:1.52->1.53 
	job.h:1.22->1.23 
	main.c:1.92->1.93 

Index: job.c
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/job.c,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -r1.52 -r1.53
--- job.c	23 Oct 2004 21:36:55 -0000	1.52
+++ job.c	4 Nov 2004 12:57:41 -0000	1.53
@@ -123,12 +123,8 @@
 #include "dir.h"
 #include "job.h"
 #include "pathnames.h"
-#ifdef REMOTE
-#include "rmt.h"
-# define STATIC
-#else
-# define STATIC static
-#endif
+
+#define STATIC static
 
 /*
  * error handling variables
@@ -239,14 +235,12 @@
 				 * running jobs equals the maximum allowed or
 				 * (2) a job can only be run locally, but
 				 * nLocal equals maxLocal */
-#ifndef RMT_WILL_WATCH
 #ifdef USE_KQUEUE
 static int	kqfd;		/* File descriptor obtained by kqueue() */
 #else
 static fd_set  	outputs;    	/* Set of descriptors of pipes connected to
 				 * the output channels of children */
 #endif
-#endif
 
 STATIC GNode   	*lastNode;	/* The node for which output was most recently
 				 * produced. */
@@ -254,15 +248,9 @@
 				 * job when it's not the most-recent job heard
 				 * from */
 
-#ifdef REMOTE
-# define TARG_FMT  "--- %s at %s ---\n" /* Default format */
-# define MESSAGE(fp, gn) \
-	(void) fprintf(fp, targFmt, gn->name, gn->rem.hname);
-#else
-# define TARG_FMT  "--- %s ---\n" /* Default format */
-# define MESSAGE(fp, gn) \
+#define	TARG_FMT  "--- %s ---\n" /* Default format */
+#define	MESSAGE(fp, gn) \
 	(void) fprintf(fp, targFmt, gn->name);
-#endif
 
 /*
  * When JobStart attempts to run a job remotely but can't, and isn't allowed
@@ -311,15 +299,8 @@
 static int JobPrintCommand(void *, void *);
 static int JobSaveCommand(void *, void *);
 static void JobClose(Job *);
-#ifdef REMOTE
-static int JobCmpRmtID(Job *, int);
-# ifdef RMT_WILL_WATCH
-static void JobLocalInput(int, Job *);
-# endif
-#else
 static void JobFinish(Job *, int *);
 static void JobExec(Job *, char **);
-#endif
 static void JobMakeArgv(Job *, char **);
 static void JobRestart(Job *);
 static int JobStart(GNode *, int, Job *);
@@ -348,20 +329,13 @@
 {
     Job	*job = (Job *) jobp;
     int	signo = *(int *) signop;
-#ifdef RMT_WANTS_SIGNALS
-    if (job->flags & JOB_REMOTE) {
-	(void) Rmt_Signal(job, signo);
-    } else {
-	KILL(job->pid, signo);
-    }
-#else
+
     /*
      * Assume that sending the signal to job->pid will signal any remote
      * job as well.
      */
     DEBUGF(JOB, ("JobCondPassSig passing signal %d to child %d.\n", signo, job->pid));
     KILL(job->pid, signo);
-#endif
     return 0;
 }
 
@@ -454,27 +428,6 @@
     return *(int *) pid - ((Job *) job)->pid;
 }
 
-#ifdef REMOTE
-/*-
- *-----------------------------------------------------------------------
- * JobCmpRmtID  --
- *	Compare the rmtID of the job with the given rmtID and return 0 if they
- *	are equal.
- *
- * Results:
- *	0 if the rmtID's match
- *
- * Side Effects:
- *	None.
- *-----------------------------------------------------------------------
- */
-static int
-JobCmpRmtID(void *job, void *rmtID)
-{
-    return(*(int *) rmtID - *(int *) job->rmtID);
-}
-#endif
-
 /*-
  *-----------------------------------------------------------------------
  * JobPrintCommand  --
@@ -702,9 +655,7 @@
 JobClose(Job *job)
 {
     if (usePipes) {
-#ifdef RMT_WILL_WATCH
-	Rmt_Ignore(job->inPipe);
-#elif !defined(USE_KQUEUE)
+#if !defined(USE_KQUEUE)
 	FD_CLR(job->inPipe, &outputs);
 #endif
 	if (job->outPipe != job->inPipe) {
@@ -759,18 +710,11 @@
 	 * cases, finish out the job's output before printing the exit
 	 * status...
 	 */
-#ifdef REMOTE
-	KILL(job->pid, SIGCONT);
-#endif
 	JobClose(job);
 	if (job->cmdFILE != NULL && job->cmdFILE != stdout) {
 	   (void) fclose(job->cmdFILE);
 	}
 	done = TRUE;
-#ifdef REMOTE
-	if (job->flags & JOB_REMOTE)
-	    Rmt_Done(job->rmtID, job->node);
-#endif
     } else if (WIFEXITED(*status)) {
 	/*
 	 * Deal with ignored errors in -B mode. We need to print a message
@@ -787,10 +731,6 @@
 	 * stuff?
 	 */
 	JobClose(job);
-#ifdef REMOTE
-	if (job->flags & JOB_REMOTE)
-	    Rmt_Done(job->rmtID, job->node);
-#endif /* REMOTE */
     } else {
 	/*
 	 * No need to close things down or anything.
@@ -851,10 +791,6 @@
 	    }
 	    job->flags |= JOB_RESUME;
 	    (void)Lst_AtEnd(stoppedJobs, (void *)job);
-#ifdef REMOTE
-	    if (job->flags & JOB_REMIGRATE)
-		JobRestart(job);
-#endif
 	    (void) fflush(out);
 	    return;
 	} else if (WTERMSIG(*status) == SIGCONT) {
@@ -1120,27 +1056,6 @@
     }
     return TRUE;
 }
-#ifdef RMT_WILL_WATCH
-/*-
- *-----------------------------------------------------------------------
- * JobLocalInput --
- *	Handle a pipe becoming readable. Callback function for Rmt_Watch
- *
- * Results:
- *	None
- *
- * Side Effects:
- *	JobDoOutput is called.
- *
- *-----------------------------------------------------------------------
- */
-/*ARGSUSED*/
-static void
-JobLocalInput(int stream, Job *job)
-{
-    JobDoOutput(job, FALSE);
-}
-#endif /* RMT_WILL_WATCH */
 
 /*-
  *-----------------------------------------------------------------------
@@ -1186,12 +1101,6 @@
 	lastNode = job->node;
     }
 
-#ifdef RMT_NO_EXEC
-    if (job->flags & JOB_REMOTE) {
-	goto jobExecFinish;
-    }
-#endif /* RMT_NO_EXEC */
-
     if ((cpid = vfork()) == -1) {
 	Punt("Cannot fork");
     } else if (cpid == 0) {
@@ -1245,20 +1154,12 @@
 # endif
 #endif /* USE_PGRP */
 
-#ifdef REMOTE
-	if (job->flags & JOB_REMOTE) {
-	    Rmt_Exec(shellPath, argv, FALSE);
-	} else
-#endif /* REMOTE */
-	   (void) execv(shellPath, argv);
+	(void) execv(shellPath, argv);
 
 	(void) write(STDERR_FILENO, "Could not execute shell\n",
 		     sizeof("Could not execute shell"));
 	_exit(1);
     } else {
-#ifdef REMOTE
-	long omask = sigblock(sigmask(SIGCHLD));
-#endif
 	job->pid = cpid;
 
 	if (usePipes && (job->flags & JOB_FIRST) ) {
@@ -1272,9 +1173,7 @@
 #endif
 	    job->curPos = 0;
 
-#ifdef RMT_WILL_WATCH
-	    Rmt_Watch(job->inPipe, JobLocalInput, job);
-#elif defined(USE_KQUEUE)
+#if defined(USE_KQUEUE)
 	    EV_SET(&kev[0], job->inPipe, EVFILT_READ, EV_ADD, 0, 0, job);
 	    EV_SET(&kev[1], job->pid, EVFILT_PROC, EV_ADD | EV_ONESHOT,
 		NOTE_EXIT, 0, NULL);
@@ -1285,15 +1184,11 @@
 	    }
 #else
 	    FD_SET(job->inPipe, &outputs);
-#endif /* RMT_WILL_WATCH */
+#endif /* USE_KQUEUE */
 	}
 
 	if (job->flags & JOB_REMOTE) {
-#ifndef REMOTE
 	    job->rmtID = 0;
-#else
-	    job->rmtID = Rmt_LastID(job->pid);
-#endif /* REMOTE */
 	} else {
 	    nLocal += 1;
 	    /*
@@ -1304,14 +1199,8 @@
 		job->cmdFILE = NULL;
 	    }
 	}
-#ifdef REMOTE
-	(void) sigsetmask(omask);
-#endif
     }
 
-#ifdef RMT_NO_EXEC
-jobExecFinish:
-#endif
     /*
      * Now the job is actually running, add it to the table.
      */
@@ -1391,80 +1280,41 @@
 static void
 JobRestart(Job *job)
 {
-#ifdef REMOTE
-    int host;
-#endif
 
     if (job->flags & JOB_REMIGRATE) {
-	if (
-#ifdef REMOTE
-	    verboseRemigrates ||
-#endif
-	    DEBUG(JOB)) {
+	if (DEBUG(JOB)) {
 	   (void) fprintf(stdout, "*** remigrating %x(%s)\n",
 			   job->pid, job->node->name);
 	   (void) fflush(stdout);
 	}
 
-#ifdef REMOTE
-	if (!Rmt_ReExport(job->pid, job->node, &host)) {
-	    if (verboseRemigrates || DEBUG(JOB)) {
-		(void) fprintf(stdout, "*** couldn't migrate...\n");
+	if (nLocal != maxLocal) {
+	    /*
+	     * Job cannot be remigrated, but there's room on the local
+	     * machine, so resume the job and note that another
+	     * local job has started.
+	     */
+	    if (DEBUG(JOB)) {
+		(void) fprintf(stdout, "*** resuming on local machine\n");
 		(void) fflush(stdout);
 	    }
-#endif
-	    if (nLocal != maxLocal) {
-		/*
-		 * Job cannot be remigrated, but there's room on the local
-		 * machine, so resume the job and note that another
-		 * local job has started.
-		 */
-		if (
-#ifdef REMOTE
-		    verboseRemigrates ||
-#endif
-		    DEBUG(JOB)) {
-		    (void) fprintf(stdout, "*** resuming on local machine\n");
-		    (void) fflush(stdout);
-		}
-		KILL(job->pid, SIGCONT);
-		nLocal +=1;
-#ifdef REMOTE
-		job->flags &= ~(JOB_REMIGRATE|JOB_RESUME|JOB_REMOTE);
-		job->flags |= JOB_CONTINUING;
-#else
-		job->flags &= ~(JOB_REMIGRATE|JOB_RESUME);
-#endif
-	} else {
-		/*
-		 * Job cannot be restarted. Mark the table as full and
-		 * place the job back on the list of stopped jobs.
-		 */
-		if (
-#ifdef REMOTE
-		    verboseRemigrates ||
-#endif
-		    DEBUG(JOB)) {
-		   (void) fprintf(stdout, "*** holding\n");
-		   (void) fflush(stdout);
-  		}
-		(void)Lst_AtFront(stoppedJobs, (void *)job);
-		jobFull = TRUE;
-		DEBUGF(JOB, ("Job queue is full.\n"));
-		return;
-	    }
-#ifdef REMOTE
+	    KILL(job->pid, SIGCONT);
+	    nLocal +=1;
+	    job->flags &= ~(JOB_REMIGRATE|JOB_RESUME);
 	} else {
 	    /*
-	     * Clear out the remigrate and resume flags. Set the continuing
-	     * flag so we know later on that the process isn't exiting just
-	     * because of a signal.
+	     * Job cannot be restarted. Mark the table as full and
+	     * place the job back on the list of stopped jobs.
 	     */
-	    job->flags &= ~(JOB_REMIGRATE|JOB_RESUME);
-	    job->flags |= JOB_CONTINUING;
-	    job->rmtID = host;
+	    if (DEBUG(JOB)) {
+	       (void) fprintf(stdout, "*** holding\n");
+	       (void) fflush(stdout);
+  	    }
+	    (void)Lst_AtFront(stoppedJobs, (void *)job);
+	    jobFull = TRUE;
+	    DEBUGF(JOB, ("Job queue is full.\n"));
+	    return;
 	}
-#endif
 
 	(void)Lst_AtEnd(jobs, (void *)job);
 	nJobs += 1;
@@ -1486,43 +1336,23 @@
 	JobMakeArgv(job, argv);
 
 	DEBUGF(JOB, ("Restarting %s...", job->node->name));
-#ifdef REMOTE
-	if ((job->node->type&OP_NOEXPORT) ||
- 	    (nLocal < maxLocal && runLocalFirst)
-# ifdef RMT_NO_EXEC
-	    || !Rmt_Export(shellPath, argv, job)
-# else
-	    || !Rmt_Begin(shellPath, argv, job->node)
-# endif
-#endif
-	{
-	    if (((nLocal >= maxLocal) && !(job->flags & JOB_SPECIAL))) {
-		/*
-		 * Can't be exported and not allowed to run locally -- put it
-		 * back on the hold queue and mark the table full
-		 */
-		DEBUGF(JOB, ("holding\n"));
-		(void)Lst_AtFront(stoppedJobs, (void *)job);
-		jobFull = TRUE;
-		DEBUGF(JOB, ("Job queue is full.\n"));
-		return;
-	    } else {
-		/*
-		 * Job may be run locally.
-		 */
-		DEBUGF(JOB, ("running locally\n"));
-		job->flags &= ~JOB_REMOTE;
-	    }
-	}
-#ifdef REMOTE
-	else {
+	if (((nLocal >= maxLocal) && !(job->flags & JOB_SPECIAL))) {
+	    /*
+	     * Can't be exported and not allowed to run locally -- put it
+	     * back on the hold queue and mark the table full
+	     */
+	    DEBUGF(JOB, ("holding\n"));
+	    (void)Lst_AtFront(stoppedJobs, (void *)job);
+	    jobFull = TRUE;
+	    DEBUGF(JOB, ("Job queue is full.\n"));
+	    return;
+	} else {
 	    /*
-	     * Can be exported. Hooray!
+	     * Job may be run locally.
 	     */
-	    DEBUGF(JOB, ("exporting\n"));
-	    job->flags |= JOB_REMOTE;
+	    DEBUGF(JOB, ("running locally\n"));
+	    job->flags &= ~JOB_REMOTE;
 	}
-#endif
 	JobExec(job, argv);
     } else {
 	/*
@@ -1532,14 +1362,8 @@
 	DEBUGF(JOB, ("Resuming %s...", job->node->name));
 	if (((job->flags & JOB_REMOTE) ||
 	    (nLocal < maxLocal) ||
-#ifdef REMOTE
-	    (((job->flags & JOB_SPECIAL) &&
-	      (job->node->type & OP_NOEXPORT)) &&
-	     (maxLocal == 0))) &&
-#else
 	    ((job->flags & JOB_SPECIAL) &&
 	     (maxLocal == 0))) &&
-#endif
 	   (nJobs != maxJobs))
 	{
 	    /*
@@ -1552,12 +1376,7 @@
 	    Boolean error;
 	    int status;
 
-#ifdef RMT_WANTS_SIGNALS
-	    if (job->flags & JOB_REMOTE) {
-		error = !Rmt_Signal(job, SIGCONT);
-	    } else
-#endif	/* RMT_WANTS_SIGNALS */
-		error = (KILL(job->pid, SIGCONT) != 0);
+	    error = (KILL(job->pid, SIGCONT) != 0);
 
 	    if (!error) {
 		/*
@@ -1839,27 +1658,11 @@
 	}
     }
 
-#ifdef REMOTE
-    if (!(gn->type & OP_NOEXPORT) && !(runLocalFirst && nLocal < maxLocal)) {
-#ifdef RMT_NO_EXEC
-	local = !Rmt_Export(shellPath, argv, job);
-#else
-	local = !Rmt_Begin(shellPath, argv, job->node);
-#endif /* RMT_NO_EXEC */
-	if (!local) {
-	    job->flags |= JOB_REMOTE;
-	}
-    } else
-#endif
-	local = TRUE;
+    local = TRUE;
 
     if (local && (((nLocal >= maxLocal) &&
 	!(job->flags & JOB_SPECIAL) &&
-#ifdef REMOTE
-	(!(gn->type & OP_NOEXPORT) || (maxLocal != 0))
-#else
 	(maxLocal != 0)
-#endif
 	)))
     {
 	/*
@@ -2192,14 +1995,7 @@
 	    nJobs -= 1;
 	    DEBUGF(JOB, ("Job queue is no longer full.\n"));
 	    jobFull = FALSE;
-#ifdef REMOTE
-	    if (!(job->flags & JOB_REMOTE)) {
-		DEBUGF(JOB, ("Job queue has one fewer local process.\n"));
-		nLocal -= 1;
-	    }
-#else
 	    nLocal -= 1;
-#endif
 	}
 
 	JobFinish(job, &status);
@@ -2236,34 +2032,9 @@
     LstNode		  ln;
     Job		   	  *job;
 #endif
-#ifdef RMT_WILL_WATCH
-    int	    	  	  pnJobs;   	/* Previous nJobs */
-#endif
 
     (void) fflush(stdout);
-#ifdef RMT_WILL_WATCH
-    pnJobs = nJobs;
 
-    /*
-     * It is possible for us to be called with nJobs equal to 0. This happens
-     * if all the jobs finish and a job that is stopped cannot be run
-     * locally (eg if maxLocal is 0) and cannot be exported. The job will
-     * be placed back on the stoppedJobs queue, Job_Empty() will return false,
-     * Make_Run will call us again when there's nothing for which to wait.
-     * nJobs never changes, so we loop forever. Hence the check. It could
-     * be argued that we should sleep for a bit so as not to swamp the
-     * exportation system with requests. Perhaps we should.
-     *
-     * NOTE: IT IS THE RESPONSIBILITY OF Rmt_Wait TO CALL Job_CatchChildren
-     * IN A TIMELY FASHION TO CATCH ANY LOCALLY RUNNING JOBS THAT EXIT.
-     * It may use the variable nLocal to determine if it needs to call
-     * Job_CatchChildren (if nLocal is 0, there's nothing for which to
-     * wait...)
-     */
-    while (nJobs != 0 && pnJobs == nJobs) {
-	Rmt_Wait();
-    }
-#else
     if (usePipes) {
 #ifdef USE_KQUEUE
 	if ((nfds = kevent(kqfd, NULL, 0, kev, KEV_SIZE, NULL)) == -1) {
@@ -2309,7 +2080,6 @@
 	}
 #endif /* !USE_KQUEUE */
     }
-#endif /* RMT_WILL_WATCH */
 }
 
 /*-
@@ -2379,11 +2149,7 @@
 
     lastNode =	  NULL;
 
-    if (maxJobs == 1 || beVerbose == 0
-#ifdef REMOTE
-	|| noMessages
-#endif
-		     ) {
+    if (maxJobs == 1 || beVerbose == 0) {
 	/*
 	 * If only one job can run at a time, there's no need for a banner,
 	 * no is there?
@@ -2423,7 +2189,7 @@
      * we're giving each job its own process group (since then it won't get
      * signals from the terminal driver as we own the terminal)
      */
-#if defined(RMT_WANTS_SIGNALS) || defined(USE_PGRP)
+#if defined(USE_PGRP)
     if (signal(SIGTSTP, SIG_IGN) != SIG_IGN) {
 	(void) signal(SIGTSTP, JobPassSig);
     }
@@ -2450,9 +2216,7 @@
 	JobStart(begin, JOB_SPECIAL, (Job *)0);
 	while (nJobs) {
 	    Job_CatchOutput();
-#ifndef RMT_WILL_WATCH
 	    Job_CatchChildren(!usePipes);
-#endif /* RMT_WILL_WATCH */
 	}
     }
     postCommands = Targ_FindNode(".END", TARG_CREATE);
@@ -2757,80 +2521,13 @@
 		Error("*** %s removed", file);
 	    }
 	}
-#ifdef RMT_WANTS_SIGNALS
-	if (job->flags & JOB_REMOTE) {
-	    /*
-	     * If job is remote, let the Rmt module do the killing.
-	     */
-	    if (!Rmt_Signal(job, signo)) {
-		/*
-		 * If couldn't kill the thing, finish it out now with an
-		 * error code, since no exit report will come in likely.
-		 */
-		int status;
-
-		status.w_status = 0;
-		status.w_retcode = 1;
-		JobFinish(job, &status);
-	    }
-	} else if (job->pid) {
-	    KILL(job->pid, signo);
-	}
-#else
 	if (job->pid) {
 	    DEBUGF(JOB, ("JobInterrupt passing signal to child %d.\n",
 		   job->pid));
 	    KILL(job->pid, signo);
 	}
-#endif /* RMT_WANTS_SIGNALS */
     }
 
-#ifdef REMOTE
-    (void)Lst_Open(stoppedJobs);
-    while ((ln = Lst_Next(stoppedJobs)) != NULL) {
-	job = (Job *) Lst_Datum(ln);
-
-	if (job->flags & JOB_RESTART) {
-	    DEBUGF(JOB, "JobInterrupt skipping job on stopped queue"
-		   "-- it was waiting to be restarted.\n");
-	    continue;
-	}
-	if (!Targ_Precious(job->node)) {
-	    char  	*file = (job->node->path == NULL ?
-				 job->node->name :
-				 job->node->path);
-	    if (eunlink(file) == 0) {
-		Error("*** %s removed", file);
-	    }
-	}
-	/*
-	 * Resume the thing so it will take the signal.
-	 */
-	DEBUGF(JOB, ("JobInterrupt passing CONT to stopped child %d.\n", job->pid));
-	KILL(job->pid, SIGCONT);
-#ifdef RMT_WANTS_SIGNALS
-	if (job->flags & JOB_REMOTE) {
-	    /*
-	     * If job is remote, let the Rmt module do the killing.
-	     */
-	    if (!Rmt_Signal(job, SIGINT)) {
-		/*
-		 * If couldn't kill the thing, finish it out now with an
-		 * error code, since no exit report will come in likely.
-		 */
-		int status;
-		status.w_status = 0;
-		status.w_retcode = 1;
-		JobFinish(job, &status);
-	    }
-	} else if (job->pid) {
-	    DEBUGF(JOB, "JobInterrupt passing interrupt to stopped child %d.\n",
-		   job->pid);
-	    KILL(job->pid, SIGINT);
-	}
-#endif /* RMT_WANTS_SIGNALS */
-    }
-#endif
     Lst_Close(stoppedJobs);
 
     if (runINTERRUPT && !touchFlag) {
@@ -2841,9 +2538,7 @@
 	    JobStart(interrupt, JOB_IGNDOTS, (Job *)0);
 	    while (nJobs) {
 		Job_CatchOutput();
-#ifndef RMT_WILL_WATCH
 		Job_CatchChildren(!usePipes);
-#endif /* RMT_WILL_WATCH */
 	    }
 	}
     }
@@ -2870,9 +2565,7 @@
 
 	    while (nJobs) {
 		Job_CatchOutput();
-#ifndef RMT_WILL_WATCH
 		Job_CatchChildren(!usePipes);
-#endif /* RMT_WILL_WATCH */
 	    }
 	}
     }
@@ -2899,9 +2592,7 @@
     aborting = ABORT_WAIT;
     while (nJobs != 0) {
 	Job_CatchOutput();
-#ifndef RMT_WILL_WATCH
 	Job_CatchChildren(!usePipes);
-#endif /* RMT_WILL_WATCH */
     }
     aborting = 0;
 }
@@ -2939,18 +2630,8 @@
 	     * kill the child process with increasingly drastic signals to make
 	     * darn sure it's dead.
 	     */
-#ifdef RMT_WANTS_SIGNALS
-	    if (job->flags & JOB_REMOTE) {
-		Rmt_Signal(job, SIGINT);
-		Rmt_Signal(job, SIGKILL);
-	    } else {
-		KILL(job->pid, SIGINT);
-		KILL(job->pid, SIGKILL);
-	    }
-#else
 	    KILL(job->pid, SIGINT);
 	    KILL(job->pid, SIGKILL);
-#endif /* RMT_WANTS_SIGNALS */
 	}
     }
 
@@ -2961,51 +2642,6 @@
 	continue;
 }
 
-#ifdef REMOTE
-/*-
- *-----------------------------------------------------------------------
- * JobFlagForMigration --
- *	Handle the eviction of a child. Called from RmtStatusChange.
- *	Flags the child as remigratable and then suspends it.  Takes
- *	the ID of the host we used, for matching children.
- *
- * Results:
- *	none.
- *
- * Side Effects:
- *	The job descriptor is flagged for remigration.
- *
- *-----------------------------------------------------------------------
- */
-void
-JobFlagForMigration(int hostID)
-{
-    Job		  *job;	    	/* job descriptor for dead child */
-    LstNode       jnode;    	/* list element for finding job */
-
-    DEBUGF(JOB, ("JobFlagForMigration(%d) called.\n", hostID));
-    jnode = Lst_Find(jobs, (void *)hostID, JobCmpRmtID);
-
-    if (jnode == NULL) {
-	jnode = Lst_Find(stoppedJobs, (void *)hostID, JobCmpRmtID);
-		if (jnode == NULL) {
-		    if (DEBUG(JOB)) {
-			Error("Evicting host(%d) not in table", hostID);
-		    }
-		    return;
-		}
-    }
-    job = (Job *) Lst_Datum(jnode);
-
-    DEBUGF(JOB, ("JobFlagForMigration(%d) found job '%s'.\n", hostID, job->node->name));
-
-    KILL(job->pid, SIGSTOP);
-
-    job->flags |= JOB_REMIGRATE;
-}
-
-#endif
-
 /*-
  *-----------------------------------------------------------------------
  * JobRestartJobs --
Index: main.c
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/main.c,v
retrieving revision 1.92
retrieving revision 1.93
diff -u -r1.92 -r1.93
--- main.c	23 Oct 2004 21:34:41 -0000	1.92
+++ main.c	4 Nov 2004 12:57:41 -0000	1.93
@@ -168,11 +168,7 @@
 	int c;
 
 	optind = 1;	/* since we're called more than once */
-#ifdef REMOTE
-# define OPTFLAGS "BC:D:E:I:L:PSV:Xd:ef:ij:km:nqrstv"
-#else
-# define OPTFLAGS "BC:D:E:I:PSV:Xd:ef:ij:km:nqrstv"
-#endif
+#define OPTFLAGS "BC:D:E:I:PSV:Xd:ef:ij:km:nqrstv"
 rearg:	while((c = getopt(argc, argv, OPTFLAGS)) != -1) {
 		switch(c) {
 		case 'C':
@@ -198,20 +194,6 @@
 			compatMake = TRUE;
 			MFLAGS_append("-B", NULL);
 			break;
-#ifdef REMOTE
-		case 'L': {
-			char *endptr;
-
-			maxLocal = strtol(optarg, &endptr, 10);
-			if (maxLocal < 0 || *endptr != '\0') {
-				warnx("illegal number, -L argument -- %s",
-				    optarg);
-				usage();
-			}
-			MFLAGS_append("-L", optarg);
-			break;
-		}
-#endif
 		case 'P':
 			usePipes = FALSE;
 			MFLAGS_append("-P", NULL);
@@ -302,9 +284,7 @@
 				    optarg);
 				usage();
 			}
-#ifndef REMOTE
 			maxLocal = maxJobs;
-#endif
 			MFLAGS_append("-j", optarg);
 			break;
 		}
@@ -599,11 +579,7 @@
 	jobsRunning = FALSE;
 
 	maxLocal = DEFMAXLOCAL;		/* Set default local max concurrency */
-#ifdef REMOTE
-	maxJobs = DEFMAXJOBS;		/* Set default max concurrency */
-#else
 	maxJobs = maxLocal;
-#endif
 	forceJobs = FALSE;              /* No -j flag */
 	compatMake = FALSE;		/* No compat mode */
 
Index: job.h
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/job.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- job.h	23 Oct 2004 21:34:41 -0000	1.22
+++ job.h	4 Nov 2004 12:57:41 -0000	1.23
@@ -207,22 +207,2 @@
-
-/*
- * If REMOTE is defined then these things need exposed, otherwise they are
- * static to job.c!
- */
-#ifdef REMOTE
-extern char 	*targFmt;   	/* Format string for banner that separates
-				 * output from multiple jobs. Contains a
-				 * single %s where the name of the node being
-				 * made should be put. */
-extern GNode	*lastNode;  	/* Last node for which a banner was printed.
-				 * If Rmt module finds it necessary to print
-				 * a banner, it should set this to the node
-				 * for which the banner was printed */
-extern int  	nJobs;	    	/* Number of jobs running (local and remote) */
-extern int  	nLocal;	    	/* Number of jobs running locally */
-extern Lst  	jobs;	    	/* List of active job descriptors */
-extern Lst  	stoppedJobs;	/* List of jobs that are stopped or didn't
-				 * quite get started */
-extern Boolean	jobFull;    	/* Non-zero if no more jobs should/will start*/
-#endif
 extern int	maxJobs;	/* Number of jobs that may run */
+
---------------------
PatchSet 367
Date: 2004/11/05 11:41:35
Author: harti
Log:
Now with the remote job support removed there can be no remote jobs and
no jobs that need to be remigrated. Remove the flags and the associated
code.

Members: 
	config.h:1.12->1.13 
	job.c:1.53->1.54 
	job.h:1.23->1.24 

Index: config.h
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/config.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- config.h	17 Sep 2002 21:29:06 -0000	1.12
+++ config.h	5 Nov 2004 11:41:35 -0000	1.13
@@ -44,7 +44,7 @@
  * DEFMAXJOBS
  * DEFMAXLOCAL
  *	These control the default concurrency. On no occasion will more
- *	than DEFMAXJOBS targets be created at once (locally or remotely)
+ *	than DEFMAXJOBS targets be created at once.
  *	DEFMAXLOCAL is the highest number of targets which will be
  *	created on the local machine at once. Note that if you set this
  *	to 0, nothing will ever happen...
Index: job.c
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/job.c,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -r1.53 -r1.54
--- job.c	4 Nov 2004 12:57:41 -0000	1.53
+++ job.c	5 Nov 2004 11:41:35 -0000	1.54
@@ -253,14 +253,14 @@
 	(void) fprintf(fp, targFmt, gn->name);
 
 /*
- * When JobStart attempts to run a job remotely but can't, and isn't allowed
- * to run the job locally, or when Job_CatchChildren detects a job that has
- * been migrated home, the job is placed on the stoppedJobs queue to be run
+ * When JobStart attempts to run a job but isn't allowed to
+ * or when Job_CatchChildren detects a job that has
+ * been stopped somehow, the job is placed on the stoppedJobs queue to be run
  * when the next job finishes.
  */
 STATIC Lst	stoppedJobs;	/* Lst of Job structures describing
 				 * jobs that were stopped due to concurrency
-				 * limits or migration home */
+				 * limits or externally */
 
 
 #if defined(USE_PGRP) && defined(SYSV)
@@ -313,8 +313,7 @@
 /*-
  *-----------------------------------------------------------------------
  * JobCondPassSig --
- *	Pass a signal to a job if the job is remote or if USE_PGRP
- *	is defined.
+ *	Pass a signal to a job if USE_PGRP is defined.
  *
  * Results:
  *	=== 0
@@ -330,11 +329,8 @@
     Job	*job = (Job *) jobp;
     int	signo = *(int *) signop;
 
-    /*
-     * Assume that sending the signal to job->pid will signal any remote
-     * job as well.
-     */
-    DEBUGF(JOB, ("JobCondPassSig passing signal %d to child %d.\n", signo, job->pid));
+    DEBUGF(JOB, ("JobCondPassSig passing signal %d to child %d.\n",
+	signo, job->pid));
     KILL(job->pid, signo);
     return 0;
 }
@@ -342,7 +338,7 @@
 /*-
  *-----------------------------------------------------------------------
  * JobPassSig --
- *	Pass a signal on to all remote jobs and to all local jobs if
+ *	Pass a signal on to all local jobs if
  *	USE_PGRP is defined, then die ourselves.
  *
  * Results:
@@ -785,10 +781,8 @@
 		MESSAGE(out, job->node);
 		lastNode = job->node;
 	    }
-	    if (!(job->flags & JOB_REMIGRATE)) {
-		(void) fprintf(out, "*** Stopped -- signal %d\n",
-		    WSTOPSIG(*status));
-	    }
+	    (void) fprintf(out, "*** Stopped -- signal %d\n",
+		WSTOPSIG(*status));
 	    job->flags |= JOB_RESUME;
 	    (void)Lst_AtEnd(stoppedJobs, (void *)job);
 	    (void) fflush(out);
@@ -799,7 +793,7 @@
 	     * list to the running one (or re-stop it if concurrency is
 	     * exceeded) and go and get another child.
 	     */
-	    if (job->flags & (JOB_RESUME|JOB_REMIGRATE|JOB_RESTART)) {
+	    if (job->flags & (JOB_RESUME|JOB_RESTART)) {
 		if (usePipes && job->node != lastNode) {
 		    MESSAGE(out, job->node);
 		    lastNode = job->node;
@@ -821,10 +815,8 @@
 	    job->flags &= ~JOB_CONTINUING;
  	    Lst_AtEnd(jobs, (void *)job);
 	    nJobs += 1;
-	    if (!(job->flags & JOB_REMOTE)) {
-		DEBUGF(JOB, ("Process %d is continuing locally.\n", job->pid));
-		nLocal += 1;
-	    }
+	    DEBUGF(JOB, ("Process %d is continuing locally.\n", job->pid));
+	    nLocal += 1;
 	    if (nJobs == maxJobs) {
 		jobFull = TRUE;
 		DEBUGF(JOB, ("Job queue is full.\n"));
@@ -1080,8 +1072,7 @@
     if (DEBUG(JOB)) {
 	int 	  i;
 
-	DEBUGF(JOB, ("Running %s %sly\n", job->node->name,
-	       job->flags&JOB_REMOTE?"remote":"local"));
+	DEBUGF(JOB, ("Running %s\n", job->node->name));
 	DEBUGF(JOB, ("\tCommand: "));
 	for (i = 0; argv[i] != NULL; i++) {
 	    DEBUGF(JOB, ("%s ", argv[i]));
@@ -1187,17 +1178,10 @@
 #endif /* USE_KQUEUE */
 	}
 
-	if (job->flags & JOB_REMOTE) {
-	    job->rmtID = 0;
-	} else {
-	    nLocal += 1;
-	    /*
-	     * XXX: Used to not happen if REMOTE. Why?
-	     */
-	    if (job->cmdFILE != NULL && job->cmdFILE != stdout) {
-		(void) fclose(job->cmdFILE);
-		job->cmdFILE = NULL;
-	    }
+	nLocal += 1;
+	if (job->cmdFILE != NULL && job->cmdFILE != stdout) {
+	    (void) fclose(job->cmdFILE);
+	    job->cmdFILE = NULL;
 	}
     }
 
@@ -1281,48 +1265,7 @@
 JobRestart(Job *job)
 {
 
-    if (job->flags & JOB_REMIGRATE) {
-	if (DEBUG(JOB)) {
-	   (void) fprintf(stdout, "*** remigrating %x(%s)\n",
-			   job->pid, job->node->name);
-	   (void) fflush(stdout);
-	}
-
-	if (nLocal != maxLocal) {
-	    /*
-	     * Job cannot be remigrated, but there's room on the local
-	     * machine, so resume the job and note that another
-	     * local job has started.
-	     */
-	    if (DEBUG(JOB)) {
-		(void) fprintf(stdout, "*** resuming on local machine\n");
-		(void) fflush(stdout);
-	    }
-	    KILL(job->pid, SIGCONT);
-	    nLocal +=1;
-	    job->flags &= ~(JOB_REMIGRATE|JOB_RESUME);
-	} else {
-	    /*
-	     * Job cannot be restarted. Mark the table as full and
-	     * place the job back on the list of stopped jobs.
-	     */
-	    if (DEBUG(JOB)) {
-	       (void) fprintf(stdout, "*** holding\n");
-	       (void) fflush(stdout);
-  	    }
-	    (void)Lst_AtFront(stoppedJobs, (void *)job);
-	    jobFull = TRUE;
-	    DEBUGF(JOB, ("Job queue is full.\n"));
-	    return;
-	}
-
-	(void)Lst_AtEnd(jobs, (void *)job);
-	nJobs += 1;
-	if (nJobs == maxJobs) {
-	    jobFull = TRUE;
-	    DEBUGF(JOB, ("Job queue is full.\n"));
-	}
-    } else if (job->flags & JOB_RESTART) {
+    if (job->flags & JOB_RESTART) {
 	/*
 	 * Set up the control arguments to the shell. This is based on the
 	 * flags set earlier for this job. If the JOB_IGNERR flag is clear,
@@ -1351,7 +1294,6 @@
 	     * Job may be run locally.
 	     */
 	    DEBUGF(JOB, ("running locally\n"));
-	    job->flags &= ~JOB_REMOTE;
 	}
 	JobExec(job, argv);
     } else {
@@ -1360,18 +1302,14 @@
 	 * we don't know...
 	 */
 	DEBUGF(JOB, ("Resuming %s...", job->node->name));
-	if (((job->flags & JOB_REMOTE) ||
-	    (nLocal < maxLocal) ||
+	if (((nLocal < maxLocal) ||
 	    ((job->flags & JOB_SPECIAL) &&
 	     (maxLocal == 0))) &&
 	   (nJobs != maxJobs))
 	{
 	    /*
-	     * If the job is remote, it's ok to resume it as long as the
-	     * maximum concurrency won't be exceeded. If it's local and
-	     * we haven't reached the local concurrency limit already (or the
-	     * job must be run locally and maxLocal is 0), it's also ok to
-	     * resume it.
+	     * If we haven't reached the concurrency limit already (or the
+	     * job must be run and maxLocal is 0), it's ok to resume it.
 	     */
 	    Boolean error;
 	    int status;
@@ -1431,12 +1369,11 @@
     Job	  	  *job;       /* new job descriptor */
     char	  *argv[4];   /* Argument vector to shell */
     Boolean	  cmdsOK;     /* true if the nodes commands were all right */
-    Boolean 	  local;      /* Set true if the job was run locally */
     Boolean 	  noExec;     /* Set true if we decide not to run the job */
     int		  tfd;	      /* File descriptor for temp file */
 
     if (previous != NULL) {
-	previous->flags &= ~(JOB_FIRST|JOB_IGNERR|JOB_SILENT|JOB_REMOTE);
+	previous->flags &= ~(JOB_FIRST|JOB_IGNERR|JOB_SILENT);
 	job = previous;
     } else {
 	job = (Job *) emalloc(sizeof(Job));
@@ -1658,21 +1595,13 @@
 	}
     }
 
-    local = TRUE;
-
-    if (local && (((nLocal >= maxLocal) &&
-	!(job->flags & JOB_SPECIAL) &&
-	(maxLocal != 0)
-	)))
-    {
+    if ((nLocal >= maxLocal) && !(job->flags & JOB_SPECIAL) &&
+	(maxLocal != 0)) {
 	/*
-	 * The job can only be run locally, but we've hit the limit of
-	 * local concurrency, so put the job on hold until some other job
-	 * finishes. Note that the special jobs (.BEGIN, .INTERRUPT and .END)
-	 * may be run locally even when the local limit has been reached
-	 * (e.g. when maxLocal == 0), though they will be exported if at
-	 * all possible. In addition, any target marked with .NOEXPORT will
-	 * be run locally if maxLocal is 0.
+	 * We've hit the limit of concurrency, so put the job on hold until
+	 * some other job finishes. Note that the special jobs (.BEGIN,
+	 * .INTERRUPT and .END) may be run even when the limit has been reached
+	 * (e.g. when maxLocal == 0).
 	 */
 	jobFull = TRUE;
 
@@ -1680,7 +1609,7 @@
 	job->flags |= JOB_RESTART;
 	(void) Lst_AtEnd(stoppedJobs, (void *)job);
     } else {
-	if ((nLocal >= maxLocal) && local) {
+	if (nLocal >= maxLocal) {
 	    /*
 	     * If we're running this job locally as a special case (see above),
 	     * at least say the table is full.
@@ -2527,8 +2456,6 @@
 	    KILL(job->pid, signo);
 	}
     }
-
-    Lst_Close(stoppedJobs);
 
     if (runINTERRUPT && !touchFlag) {
 	interrupt = Targ_FindNode(".INTERRUPT", TARG_NOCREATE);
Index: job.h
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/job.h,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- job.h	4 Nov 2004 12:57:41 -0000	1.23
+++ job.h	5 Nov 2004 11:41:36 -0000	1.24
@@ -80,9 +80,7 @@
  *	   maintained for each job. If, on the other hand, usePipes is false,
  *	   the output is routed to a temporary file and all that is kept
  *	   is the name of the file and the descriptor open to the file.
- *	6) An identifier provided by and for the exclusive use of the
- *	   Rmt module.
- *	7) A word of flags which determine how the module handles errors,
+ *	6) A word of flags which determine how the module handles errors,
  *	   echoing, etc. for the job
  *
  * The job "table" is kept as a linked Lst in 'jobs', with the number of
@@ -103,7 +101,6 @@
 			     * saved when the job has been run */
     FILE 	*cmdFILE;   /* When creating the shell script, this is
 			     * where the commands go */
-    int    	rmtID;     /* ID returned from Rmt module */
     short      	flags;	    /* Flags to control treatment of job */
 #define	JOB_IGNERR	0x001	/* Ignore non-zero exits */
 #define	JOB_SILENT	0x002	/* no output */
@@ -111,9 +108,7 @@
 				 * if we can't export it and maxLocal is 0 */
 #define	JOB_IGNDOTS	0x008  	/* Ignore "..." lines when processing
 				 * commands */
-#define	JOB_REMOTE	0x010	/* Job is running remotely */
 #define	JOB_FIRST	0x020	/* Job is first job for the node */
-#define	JOB_REMIGRATE	0x040	/* Job needs to be remigrated */
 #define	JOB_RESTART	0x080	/* Job needs to be completely restarted */
 #define	JOB_RESUME	0x100	/* Job needs to be resumed b/c it stopped,
 				 * for some reason */
@@ -223,6 +218,5 @@
 int Job_Finish(void);
 void Job_Wait(void);
 void Job_AbortAll(void);
-void JobFlagForMigration(int);
 
 #endif /* _JOB_H_ */
---------------------
PatchSet 368
Date: 2004/11/11 12:23:39
Author: phk
Log:
Get rid of now unused maxLocal variables.

Members: 
	config.h:1.13->1.14 
	main.c:1.93->1.94 

Index: config.h
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/config.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- config.h	5 Nov 2004 11:41:35 -0000	1.13
+++ config.h	11 Nov 2004 12:23:39 -0000	1.14
@@ -42,15 +42,10 @@
 
 /*
  * DEFMAXJOBS
- * DEFMAXLOCAL
- *	These control the default concurrency. On no occasion will more
+ *	This control the default concurrency. On no occasion will more
  *	than DEFMAXJOBS targets be created at once.
- *	DEFMAXLOCAL is the highest number of targets which will be
- *	created on the local machine at once. Note that if you set this
- *	to 0, nothing will ever happen...
  */
-#define	DEFMAXJOBS	4
-#define	DEFMAXLOCAL	1
+#define	DEFMAXJOBS	1
 
 /*
  * INCLUDES
Index: main.c
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/main.c,v
retrieving revision 1.93
retrieving revision 1.94
diff -u -r1.93 -r1.94
--- main.c	4 Nov 2004 12:57:41 -0000	1.93
+++ main.c	11 Nov 2004 12:23:39 -0000	1.94
@@ -91,10 +91,6 @@
 
 #define WANT_ENV_MKLVL	1
 
-#ifndef	DEFMAXLOCAL
-#define	DEFMAXLOCAL DEFMAXJOBS
-#endif	/* DEFMAXLOCAL */
-
 #define	MAKEFLAGS	".MAKEFLAGS"
 
 Lst			create;		/* Targets to be made */
@@ -108,7 +104,6 @@
 static Lst		variables;	/* list of variables to print */
 int			maxJobs;	/* -j argument */
 static Boolean          forceJobs;      /* -j argument given */
-static int		maxLocal;	/* -L argument */
 Boolean			compatMake;	/* -B argument */
 Boolean			debug;		/* -d flag */
 Boolean			noExecute;	/* -n flag */
@@ -284,7 +279,6 @@
 				    optarg);
 				usage();
 			}
-			maxLocal = maxJobs;
 			MFLAGS_append("-j", optarg);
 			break;
 		}
@@ -578,8 +572,7 @@
 	debug = 0;			/* No debug verbosity, please. */
 	jobsRunning = FALSE;
 
-	maxLocal = DEFMAXLOCAL;		/* Set default local max concurrency */
-	maxJobs = maxLocal;
+	maxJobs = DEFMAXJOBS;
 	forceJobs = FALSE;              /* No -j flag */
 	compatMake = FALSE;		/* No compat mode */
 
@@ -859,9 +852,7 @@
 			 * being executed should it exist).
 			 */
 			if (!queryFlag) {
-				if (maxLocal == -1)
-					maxLocal = maxJobs;
-				Job_Init(maxJobs, maxLocal);
+				Job_Init(maxJobs, maxJobs);
 				jobsRunning = TRUE;
 			}
 
---------------------
PatchSet 369
Date: 2004/11/11 12:52:15
Author: phk
Log:
Get rid of more local/remote leftovers

Members: 
	job.c:1.54->1.55 
	job.h:1.24->1.25 
	main.c:1.94->1.95 

Index: job.c
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/job.c,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -r1.54 -r1.55
--- job.c	5 Nov 2004 11:41:35 -0000	1.54
+++ job.c	11 Nov 2004 12:52:15 -0000	1.55
@@ -226,15 +226,11 @@
 
 
 static int  	maxJobs;    	/* The most children we can run at once */
-static int  	maxLocal;    	/* The most local ones we can have */
 STATIC int     	nJobs;	    	/* The number of children currently running */
-STATIC int	nLocal;    	/* The number of local children */
 STATIC Lst     	jobs;		/* The structures that describe them */
 STATIC Boolean	jobFull;    	/* Flag to tell when the job table is full. It
 				 * is set TRUE when (1) the total number of
-				 * running jobs equals the maximum allowed or
-				 * (2) a job can only be run locally, but
-				 * nLocal equals maxLocal */
+				 * running jobs equals the maximum allowed */
 #ifdef USE_KQUEUE
 static int	kqfd;		/* File descriptor obtained by kqueue() */
 #else
@@ -816,7 +812,6 @@
  	    Lst_AtEnd(jobs, (void *)job);
 	    nJobs += 1;
 	    DEBUGF(JOB, ("Process %d is continuing locally.\n", job->pid));
-	    nLocal += 1;
 	    if (nJobs == maxJobs) {
 		jobFull = TRUE;
 		DEBUGF(JOB, ("Job queue is full.\n"));
@@ -1178,7 +1173,6 @@
 #endif /* USE_KQUEUE */
 	}
 
-	nLocal += 1;
 	if (job->cmdFILE != NULL && job->cmdFILE != stdout) {
 	    (void) fclose(job->cmdFILE);
 	    job->cmdFILE = NULL;
@@ -1279,7 +1273,7 @@
 	JobMakeArgv(job, argv);
 
 	DEBUGF(JOB, ("Restarting %s...", job->node->name));
-	if (((nLocal >= maxLocal) && !(job->flags & JOB_SPECIAL))) {
+	if (((nJobs >= maxJobs) && !(job->flags & JOB_SPECIAL))) {
 	    /*
 	     * Can't be exported and not allowed to run locally -- put it
 	     * back on the hold queue and mark the table full
@@ -1302,14 +1296,14 @@
 	 * we don't know...
 	 */
 	DEBUGF(JOB, ("Resuming %s...", job->node->name));
-	if (((nLocal < maxLocal) ||
+	if (((nJobs < maxJobs) ||
 	    ((job->flags & JOB_SPECIAL) &&
-	     (maxLocal == 0))) &&
+	     (maxJobs == 0))) &&
 	   (nJobs != maxJobs))
 	{
 	    /*
 	     * If we haven't reached the concurrency limit already (or the
-	     * job must be run and maxLocal is 0), it's ok to resume it.
+	     * job must be run and maxJobs is 0), it's ok to resume it.
 	     */
 	    Boolean error;
 	    int status;
@@ -1595,13 +1589,12 @@
 	}
     }
 
-    if ((nLocal >= maxLocal) && !(job->flags & JOB_SPECIAL) &&
-	(maxLocal != 0)) {
+    if ((nJobs >= maxJobs) && !(job->flags & JOB_SPECIAL) && (maxJobs != 0)) {
 	/*
 	 * We've hit the limit of concurrency, so put the job on hold until
 	 * some other job finishes. Note that the special jobs (.BEGIN,
 	 * .INTERRUPT and .END) may be run even when the limit has been reached
-	 * (e.g. when maxLocal == 0).
+	 * (e.g. when maxJobs == 0).
 	 */
 	jobFull = TRUE;
 
@@ -1609,7 +1602,7 @@
 	job->flags |= JOB_RESTART;
 	(void) Lst_AtEnd(stoppedJobs, (void *)job);
     } else {
-	if (nLocal >= maxLocal) {
+	if (nJobs >= maxJobs) {
 	    /*
 	     * If we're running this job locally as a special case (see above),
 	     * at least say the table is full.
@@ -1894,7 +1887,7 @@
     /*
      * Don't even bother if we know there's no one around.
      */
-    if (nLocal == 0) {
+    if (nJobs == 0) {
 	return;
     }
 
@@ -1924,7 +1917,6 @@
 	    nJobs -= 1;
 	    DEBUGF(JOB, ("Job queue is no longer full.\n"));
 	    jobFull = FALSE;
-	    nLocal -= 1;
 	}
 
 	JobFinish(job, &status);
@@ -2050,8 +2042,7 @@
 /*-
  *-----------------------------------------------------------------------
  * Job_Init --
- *	Initialize the process module, given a maximum number of jobs, and
- *	a maximum number of local jobs.
+ *	Initialize the process module, given a maximum number of jobs.
  *
  * Results:
  *	none
@@ -2061,16 +2052,14 @@
  *-----------------------------------------------------------------------
  */
 void
-Job_Init(int maxproc, int maxlocal)
+Job_Init(int maxproc)
 {
     GNode         *begin;     /* node for commands to do at the very start */
 
     jobs =  	  Lst_Init(FALSE);
     stoppedJobs = Lst_Init(FALSE);
     maxJobs = 	  maxproc;
-    maxLocal = 	  maxlocal;
     nJobs = 	  0;
-    nLocal = 	  0;
     jobFull = 	  FALSE;
 
     aborting = 	  0;
Index: job.h
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/job.h,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- job.h	5 Nov 2004 11:41:36 -0000	1.24
+++ job.h	11 Nov 2004 12:52:16 -0000	1.25
@@ -211,7 +211,7 @@
 void Job_CatchChildren(Boolean);
 void Job_CatchOutput(void);
 void Job_Make(GNode *);
-void Job_Init(int, int);
+void Job_Init(int);
 Boolean Job_Full(void);
 Boolean Job_Empty(void);
 ReturnStatus Job_ParseShell(char *);
Index: main.c
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/main.c,v
retrieving revision 1.94
retrieving revision 1.95
diff -u -r1.94 -r1.95
--- main.c	11 Nov 2004 12:23:39 -0000	1.94
+++ main.c	11 Nov 2004 12:52:16 -0000	1.95
@@ -852,7 +852,7 @@
 			 * being executed should it exist).
 			 */
 			if (!queryFlag) {
-				Job_Init(maxJobs, maxJobs);
+				Job_Init(maxJobs);
 				jobsRunning = TRUE;
 			}
 
---------------------
PatchSet 370
Date: 2004/11/12 07:57:17
Author: harti
Log:
Fix a (very) long standing bug in make (this has been there probably
from the beginning). Make used to handle all its interrupt-time stuff
directly from the signal handler, including calls to printf, accessing
global data and so on. This is of course wrong and could provoke a core
dump when interrupting make. Just set a flag in the signal handler and
do everything else from the main thread.

PR:		bin/29103

Members: 
	compat.c:1.38->1.39 
	job.c:1.55->1.56 

Index: compat.c
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/compat.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- compat.c	23 Oct 2004 21:34:41 -0000	1.38
+++ compat.c	12 Nov 2004 07:57:17 -0000	1.39
@@ -79,6 +79,8 @@
 
 static GNode	    *curTarg = NULL;
 static GNode	    *ENDNode;
+static sig_atomic_t interrupted;
+
 static void CompatInterrupt(int);
 static int CompatMake(void *, void *);
 static int shellneed(char *);
@@ -101,6 +103,16 @@
     meta[0] = 1;
 }
 
+/*
+ * Interrupt handler - set flag and defer handling to the main code
+ */
+static void
+CompatCatchSig(int signo)
+{
+
+	interrupted = signo;
+}
+
 /*-
  *-----------------------------------------------------------------------
  * CompatInterrupt --
@@ -120,6 +132,17 @@
 CompatInterrupt (int signo)
 {
     GNode   *gn;
+    sigset_t nmask, omask;
+
+    sigemptyset(&nmask);
+    sigaddset(&nmask, SIGINT);
+    sigaddset(&nmask, SIGTERM);
+    sigaddset(&nmask, SIGHUP);
+    sigaddset(&nmask, SIGQUIT);
+    sigprocmask(SIG_SETMASK, &nmask, &omask);
+
+    /* prevent recursion in evaluation of .INTERRUPT */
+    interrupted = 0;
 
     if ((curTarg != NULL) && !Targ_Precious (curTarg)) {
 	char	  *p1;
@@ -129,18 +152,20 @@
 	    printf ("*** %s removed\n", file);
 	}
 	free(p1);
+    }
 
-	/*
-	 * Run .INTERRUPT only if hit with interrupt signal
-	 */
-	if (signo == SIGINT) {
-	    gn = Targ_FindNode(".INTERRUPT", TARG_NOCREATE);
-	    if (gn != NULL) {
-		Lst_ForEach(gn->commands, Compat_RunCommand, (void *)gn);
-	    }
+    /*
+     * Run .INTERRUPT only if hit with interrupt signal
+     */
+    if (signo == SIGINT) {
+	gn = Targ_FindNode(".INTERRUPT", TARG_NOCREATE);
+	if (gn != NULL) {
+	    Lst_ForEach(gn->commands, Compat_RunCommand, (void *)gn);
 	}
-
     }
+
+    sigprocmask(SIG_SETMASK, &omask, NULL);
+
     if (signo == SIGQUIT)
 	exit(signo);
     (void) signal(signo, SIG_DFL);
@@ -373,10 +398,12 @@
     while (1) {
 
 	while ((rstat = wait(&reason)) != cpid) {
-	    if (rstat == -1 && errno != EINTR) {
-		break;
+	    if (interrupted || (rstat == -1 && errno != EINTR)) {
+		    break;
 	    }
 	}
+	if (interrupted)
+	    CompatInterrupt(interrupted);
 
 	if (rstat > -1) {
 	    if (WIFSTOPPED(reason)) {
@@ -660,16 +687,16 @@
     Shell_Init();		/* Set up shell. */
 
     if (signal(SIGINT, SIG_IGN) != SIG_IGN) {
-	signal(SIGINT, CompatInterrupt);
+	signal(SIGINT, CompatCatchSig);
     }
     if (signal(SIGTERM, SIG_IGN) != SIG_IGN) {
-	signal(SIGTERM, CompatInterrupt);
+	signal(SIGTERM, CompatCatchSig);
     }
     if (signal(SIGHUP, SIG_IGN) != SIG_IGN) {
-	signal(SIGHUP, CompatInterrupt);
+	signal(SIGHUP, CompatCatchSig);
     }
     if (signal(SIGQUIT, SIG_IGN) != SIG_IGN) {
-	signal(SIGQUIT, CompatInterrupt);
+	signal(SIGQUIT, CompatCatchSig);
     }
 
     ENDNode = Targ_FindNode(".END", TARG_CREATE);
Index: job.c
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/job.c,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -r1.55 -r1.56
--- job.c	11 Nov 2004 12:52:15 -0000	1.55
+++ job.c	12 Nov 2004 07:57:17 -0000	1.56
@@ -259,6 +259,9 @@
 				 * limits or externally */
 
 
+static sig_atomic_t interrupted;
+
+
 #if defined(USE_PGRP) && defined(SYSV)
 # define KILL(pid, sig)		killpg(-(pid), (sig))
 #else
@@ -306,6 +309,19 @@
 static void JobInterrupt(int, int);
 static void JobRestartJobs(void);
 
+/*
+ * JobCatchSignal
+ *
+ * Got a signal. Set global variables and hope that someone will
+ * handle it.
+ */
+static void
+JobCatchSig(int signo)
+{
+
+	interrupted = signo;
+}
+
 /*-
  *-----------------------------------------------------------------------
  * JobCondPassSig --
@@ -351,6 +367,10 @@
     sigset_t nmask, omask;
     struct sigaction act;
 
+    sigemptyset(&nmask);
+    sigaddset(&nmask, signo);
+    sigprocmask(SIG_SETMASK, &nmask, &omask);
+
     DEBUGF(JOB, ("JobPassSig(%d) called.\n", signo));
     Lst_ForEach(jobs, JobCondPassSig, (void *) &signo);
 
@@ -377,10 +397,8 @@
      * Note we block everything else possible while we're getting the signal.
      * This ensures that all our jobs get continued when we wake up before
      * we take any other signal.
+     * XXX this comment seems wrong.
      */
-    sigemptyset(&nmask);
-    sigaddset(&nmask, signo);
-    sigprocmask(SIG_SETMASK, &nmask, &omask);
     act.sa_handler = SIG_DFL;
     sigemptyset(&act.sa_mask);
     act.sa_flags = 0;
@@ -1366,6 +1384,10 @@
     Boolean 	  noExec;     /* Set true if we decide not to run the job */
     int		  tfd;	      /* File descriptor for temp file */
 
+    if (interrupted) {
+        JobPassSig(interrupted);
+        return (JOB_ERROR);
+    }
     if (previous != NULL) {
 	previous->flags &= ~(JOB_FIRST|JOB_IGNERR|JOB_SILENT);
 	job = previous;
@@ -1709,6 +1731,14 @@
 
 	nRead = read(job->inPipe, &job->outBuf[job->curPos],
 			 JOB_BUFSIZE - job->curPos);
+	/*
+	 * Check for interrupt here too, because the above read may block
+	 * when the child process is stopped. In this case the interrupt
+	 * will unblock it (we don't use SA_RESTART).
+	 */
+	if (interrupted)
+	    JobPassSig(interrupted);
+
 	if (nRead < 0) {
 	    DEBUGF(JOB, ("JobDoOutput(piperead)"));
 	    nr = 0;
@@ -1921,6 +1951,8 @@
 
 	JobFinish(job, &status);
     }
+    if (interrupted)
+        JobPassSig(interrupted);
 }
 
 /*-
@@ -1961,6 +1993,8 @@
 	if ((nfds = kevent(kqfd, NULL, 0, kev, KEV_SIZE, NULL)) == -1) {
 	    if (errno != EINTR)
 		Punt("kevent: %s", strerror(errno));
+	    if (interrupted)
+		JobPassSig(interrupted);
 	} else {
 	    for (i = 0; i < nfds; i++) {
 		if (kev[i].flags & EV_ERROR) {
@@ -1984,9 +2018,11 @@
 	timeout.tv_usec = SEL_USEC;
 
 	if ((nfds = select(FD_SETSIZE, &readfds, (fd_set *) 0,
-			   (fd_set *) 0, &timeout)) <= 0)
+			   (fd_set *) 0, &timeout)) <= 0) {
+	    if (interrupted)
+		JobPassSig(interrupted);
 	    return;
-	else {
+	} else {
 	    if (Lst_Open(jobs) == FAILURE) {
 		Punt("Cannot open job table");
 	    }
@@ -2055,6 +2091,7 @@
 Job_Init(int maxproc)
 {
     GNode         *begin;     /* node for commands to do at the very start */
+    struct sigaction sa;
 
     jobs =  	  Lst_Init(FALSE);
     stoppedJobs = Lst_Init(FALSE);
@@ -2087,19 +2124,24 @@
 
     /*
      * Catch the four signals that POSIX specifies if they aren't ignored.
-     * JobPassSig will take care of calling JobInterrupt if appropriate.
+     * JobCatchSignal will just set global variables and hope someone
+     * else is going to handle the interrupt.
      */
+    sa.sa_handler = JobCatchSig;
+    sigemptyset(&sa.sa_mask);
+    sa.sa_flags = 0;
+
     if (signal(SIGINT, SIG_IGN) != SIG_IGN) {
-	(void) signal(SIGINT, JobPassSig);
+	(void) sigaction(SIGINT, &sa, NULL);
     }
     if (signal(SIGHUP, SIG_IGN) != SIG_IGN) {
-	(void) signal(SIGHUP, JobPassSig);
+	(void) sigaction(SIGHUP, &sa, NULL);
     }
     if (signal(SIGQUIT, SIG_IGN) != SIG_IGN) {
-	(void) signal(SIGQUIT, JobPassSig);
+	(void) sigaction(SIGQUIT, &sa, NULL);
     }
     if (signal(SIGTERM, SIG_IGN) != SIG_IGN) {
-	(void) signal(SIGTERM, JobPassSig);
+	(void) sigaction(SIGTERM, &sa, NULL);
     }
     /*
      * There are additional signals that need to be caught and passed if
@@ -2109,16 +2151,16 @@
      */
 #if defined(USE_PGRP)
     if (signal(SIGTSTP, SIG_IGN) != SIG_IGN) {
-	(void) signal(SIGTSTP, JobPassSig);
+	(void) sigaction(SIGTSTP, &sa, NULL);
     }
     if (signal(SIGTTOU, SIG_IGN) != SIG_IGN) {
-	(void) signal(SIGTTOU, JobPassSig);
+	(void) sigaction(SIGTTOU, &sa, NULL);
     }
     if (signal(SIGTTIN, SIG_IGN) != SIG_IGN) {
-	(void) signal(SIGTTIN, JobPassSig);
+	(void) sigaction(SIGTTIN, &sa, NULL);
     }
     if (signal(SIGWINCH, SIG_IGN) != SIG_IGN) {
-	(void) signal(SIGWINCH, JobPassSig);
+	(void) sigaction(SIGWINCH, &sa, NULL);
     }
 #endif
 
@@ -2447,6 +2489,10 @@
     }
 
     if (runINTERRUPT && !touchFlag) {
+	/* clear the interrupted flag because we would get an
+	 * infinite loop otherwise */
+	interrupted = 0;
+
 	interrupt = Targ_FindNode(".INTERRUPT", TARG_NOCREATE);
 	if (interrupt != NULL) {
 	    ignoreErrors = FALSE;
---------------------
PatchSet 374
Date: 2004/11/17 11:32:46
Author: harti
Log:
Eliminate the define for POSIX and build with Posix behaviour.
Our make has been build with POSIX enabled from the first day
and the ifdef'ed out code served no purpose.

Members: 
	config.h:1.14->1.15 
	main.c:1.97->1.98 
	parse.c:1.57->1.58 

Index: config.h
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/config.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- config.h	11 Nov 2004 12:23:39 -0000	1.14
+++ config.h	17 Nov 2004 11:32:46 -0000	1.15
@@ -78,15 +78,6 @@
 #define	RECHECK
 
 /*
- * POSIX
- *	Adhere to the POSIX 1003.2 draft for the make(1) program.
- *	- Use MAKEFLAGS instead of MAKE to pick arguments from the
- *	  environment.
- *	- Allow empty command lines if starting with tab.
- */
-#define	POSIX
-
-/*
  * SYSVINCLUDE
  *	Recognize system V like include directives [include "filename"]
  * SYSVVARSUB
Index: main.c
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/main.c,v
retrieving revision 1.97
retrieving revision 1.98
diff -u -r1.97 -r1.98
--- main.c	12 Nov 2004 20:37:27 -0000	1.97
+++ main.c	17 Nov 2004 11:32:46 -0000	1.98
@@ -612,11 +612,7 @@
 	 * (Note this is *not* MAKEFLAGS since /bin/make uses that and it's
 	 * in a different format).
 	 */
-#ifdef POSIX
 	Main_ParseArgLine(getenv("MAKEFLAGS"));
-#else
-	Main_ParseArgLine(getenv("MAKE"));
-#endif
 
 	MainParseArgs(argc, argv);
 
@@ -766,11 +762,7 @@
 
 	/* Install all the flags into the MAKE envariable. */
 	if (((p = Var_Value(MAKEFLAGS, VAR_GLOBAL, &p1)) != NULL) && *p)
-#ifdef POSIX
 		setenv("MAKEFLAGS", p, 1);
-#else
-		setenv("MAKE", p, 1);
-#endif
 	free(p1);
 
 	/*
Index: parse.c
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/parse.c,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -r1.57 -r1.58
--- parse.c	22 Jul 2004 11:12:01 -0000	1.57
+++ parse.c	17 Nov 2004 11:32:46 -0000	1.58
@@ -143,9 +143,7 @@
     Parallel,	    /* .PARALLEL */
     ExPath,	    /* .PATH */
     Phony,	    /* .PHONY */
-#ifdef POSIX
     Posix,	    /* .POSIX */
-#endif
     Precious,	    /* .PRECIOUS */
     ExShell,	    /* .SHELL */
     Silent,	    /* .SILENT */
@@ -199,9 +197,7 @@
 { ".PARALLEL",	  Parallel,	0 },
 { ".PATH",	  ExPath,	0 },
 { ".PHONY",	  Phony,	OP_PHONY },
-#ifdef POSIX
 { ".POSIX",	  Posix,	0 },
-#endif
 { ".PRECIOUS",	  Precious, 	OP_PRECIOUS },
 { ".RECURSIVE",	  Attribute,	OP_MAKE },
 { ".SHELL", 	  ExShell,    	0 },
@@ -1034,11 +1030,9 @@
 	    case ExPath:
 		Lst_ForEach(paths, ParseClearPath, (void *)NULL);
 		break;
-#ifdef POSIX
 	    case Posix:
 		Var_Set("%POSIX", "1003.2", VAR_GLOBAL);
 		break;
-#endif
 	    default:
 		break;
 	}
@@ -2428,9 +2422,6 @@
 		 * If a line starts with a tab, it can only hope to be
 		 * a creation command.
 		 */
-#ifndef POSIX
-	    shellCommand:
-#endif
 		for (cp = line + 1; isspace ((unsigned char) *cp); cp++) {
 		    continue;
 		}
@@ -2474,10 +2465,6 @@
 		 * line's script, we assume it's actually a shell command
 		 * and add it to the current list of targets.
 		 */
-#ifndef POSIX
-		Boolean	nonSpace = FALSE;
-#endif
-
 		cp = line;
 		if (isspace((unsigned char) line[0])) {
 		    while ((*cp != '\0') && isspace((unsigned char) *cp)) {
@@ -2486,44 +2473,24 @@
 		    if (*cp == '\0') {
 			goto nextLine;
 		    }
-#ifndef POSIX
-		    while ((*cp != ':') && (*cp != '!') && (*cp != '\0')) {
-			nonSpace = TRUE;
-			cp++;
-		    }
-#endif
 		}
 
-#ifndef POSIX
-		if (*cp == '\0') {
-		    if (inLine) {
-			Parse_Error (PARSE_WARNING,
-				     "Shell command needs a leading tab");
-			goto shellCommand;
-		    } else if (nonSpace) {
-			Parse_Error (PARSE_FATAL, "Missing operator");
-		    }
-		} else {
-#endif
-		    ParseFinishLine();
+		ParseFinishLine();
 
-		    cp = Var_Subst (NULL, line, VAR_CMD, TRUE);
-		    free (line);
-		    line = cp;
+		cp = Var_Subst (NULL, line, VAR_CMD, TRUE);
+		free (line);
+		line = cp;
 
-		    /*
-		     * Need a non-circular list for the target nodes
-		     */
-		    if (targets)
-			Lst_Destroy(targets, NOFREE);
+		/*
+		 * Need a non-circular list for the target nodes
+		 */
+		if (targets)
+		    Lst_Destroy(targets, NOFREE);
 
-		    targets = Lst_Init (FALSE);
-		    inLine = TRUE;
+		targets = Lst_Init (FALSE);
+		inLine = TRUE;
 
-		    ParseDoDependency (line);
-#ifndef POSIX
-		}
-#endif
+		ParseDoDependency (line);
 	    }
 
 	    nextLine:
---------------------
PatchSet 365
Date: 2004/10/23 22:36:55
Author: ru
Log:
"unset verbose" is 13 characters, not 10.

Members: 
	job.c:1.51->1.52 

Index: job.c
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/job.c,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -r1.51 -r1.52
--- job.c	23 Oct 2004 21:34:41 -0000	1.51
+++ job.c	23 Oct 2004 21:36:55 -0000	1.52
@@ -182,7 +182,7 @@
      */
 {
     "csh",
-    TRUE, "unset verbose", "set verbose", "unset verbose", 10,
+    TRUE, "unset verbose", "set verbose", "unset verbose", 13,
     FALSE, "echo \"%s\"\n", "csh -c \"%s || exit 0\"",
     "v", "e",
 },
---------------------
PatchSet 375
Date: 2004/11/22 15:45:57
Author: harti
Log:
Get rid of the shell table sentinel. It isn't needed anymore because
JobMatchShell returns NULL when no shell name matches since revision 1.51.

Members: 
	job.c:1.58->1.59 

Index: job.c
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/job.c,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -r1.58 -r1.59
--- job.c	12 Nov 2004 13:14:56 -0000	1.58
+++ job.c	22 Nov 2004 15:45:57 -0000	1.59
@@ -205,15 +205,6 @@
     TRUE, "set -e", "set +e",
     "v", "e",
 },
-    /*
-     * UNKNOWN.
-     */
-{
-    (char *) 0,
-    FALSE, (char *) 0, (char *) 0, (char *) 0, 0,
-    FALSE, (char *) 0, (char *) 0,
-    (char *) 0, (char *) 0,
-}
 };
 static Shell 	*commandShell = &shells[DEFSHELL];/* this is the shell to
 						   * which we pass all
@@ -2345,7 +2336,7 @@
 
     match = NULL;
 
-    for (sh = shells; sh->name != NULL; sh++) {
+    for (sh = shells; sh < shells + sizeof(shells) / sizeof(shells[0]); sh++) {
 	for (cp1 = eoname - strlen(sh->name), cp2 = sh->name;
 	     *cp1 != '\0' && *cp1 == *cp2;
 	     cp1++, cp2++) {


[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]