Subject: make and .OPTIONAL
To: None <tech-toolchain@netbsd.org>
From: David Laight <david@l8s.co.uk>
List: tech-toolchain
Date: 11/07/2003 19:19:35
I thought I'd try to stop the build failing when a .depend file
references an old .h file by changing mkdep so that it adds:

.OPTIONAL: header.h .....

This stops the build failing, but the program that depended on the
deleted .h file is always rebuilt.

The change to make below seems to fix this.
(Have I pulled in enough of Job_CheckCommands() ??)

It does also seem to remove the:
    make: don't know how to make x(ignored)
message - which may not be completely derisable.

	David

Index: make.c
===================================================================
RCS file: /cvsroot/src/usr.bin/make/make.c,v
retrieving revision 1.51
diff -u -p -r1.51 make.c
--- make.c	2003/08/07 11:14:54	1.51
+++ make.c	2003/11/07 18:32:22
@@ -280,16 +280,18 @@ Make_OODate(GNode *gn)
 	    }
 	}
 	oodate = TRUE;
-    } else if ((gn->mtime < gn->cmtime) ||
-	       ((gn->cmtime == 0) &&
-		((gn->mtime==0) || (gn->type & OP_DOUBLEDEP))))
+    } else if (gn->mtime < gn->cmtime ||
+	       (gn->cmtime == 0 &&
+		((gn->mtime == 0 && (!(gn->type & OP_OPTIONAL)
+				|| !Lst_IsEmpty(gn->commands)))
+		  || (gn->type & OP_DOUBLEDEP))))
     {
 	/*
 	 * A node whose modification time is less than that of its
 	 * youngest child or that has no children (cmtime == 0) and
-	 * either doesn't exist (mtime == 0) or was the object of a
-	 * :: operator is out-of-date. Why? Because that's the way Make does
-	 * it.
+	 * either doesn't exist (mtime == 0) and it isn't optional
+	 * or was the object of a * :: operator is out-of-date.
+	 * Why? Because that's the way Make does it.
 	 */
 	if (DEBUG(MAKE)) {
 	    if (gn->mtime < gn->cmtime) {
 
-- 
David Laight: david@l8s.co.uk