Module Name:    src
Committed By:   sjg
Date:           Thu Feb 18 05:02:49 UTC 2016

Modified Files:
        src/usr.bin/make: make.1 parse.c

Log Message:
Add support for .dinclude

Like .sinclude missing file will be ignored.
Like .depend stale dependencies will be ignored.
Allows better implementation of auto depend.

Reviewed by: christos
Requested by: Bryan Drewery at FreeBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.249 -r1.250 src/usr.bin/make/make.1
cvs rdiff -u -r1.209 -r1.210 src/usr.bin/make/parse.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/make.1
diff -u src/usr.bin/make/make.1:1.249 src/usr.bin/make/make.1:1.250
--- src/usr.bin/make/make.1:1.249	Fri Jun  5 07:33:40 2015
+++ src/usr.bin/make/make.1	Thu Feb 18 05:02:49 2016
@@ -1,4 +1,4 @@
-.\"	$NetBSD: make.1,v 1.249 2015/06/05 07:33:40 wiz Exp $
+.\"	$NetBSD: make.1,v 1.250 2016/02/18 05:02:49 sjg Exp $
 .\"
 .\" Copyright (c) 1990, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\"	from: @(#)make.1	8.4 (Berkeley) 3/19/94
 .\"
-.Dd June 4, 2015
+.Dd February 17, 2015
 .Dt MAKE 1
 .Os
 .Sh NAME
@@ -1530,12 +1530,20 @@ For compatibility with other versions of
 .Nm
 .Ql include file ...
 is also accepted.
+.Pp
 If the include statement is written as
 .Cm .-include
 or as
 .Cm .sinclude
 then errors locating and/or opening include files are ignored.
 .Pp
+If the include statement is written as
+.Cm .dinclude
+not only are errors locating and/or opening include files ignored,
+but stale dependencies within the included file will be ignored
+just like
+.Va .MAKE.DEPENDFILE .
+.Pp
 Conditional expressions are also preceded by a single dot as the first
 character of a line.
 The possible conditionals are as follows:

Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.209 src/usr.bin/make/parse.c:1.210
--- src/usr.bin/make/parse.c:1.209	Sun Jan 17 17:45:21 2016
+++ src/usr.bin/make/parse.c	Thu Feb 18 05:02:49 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.209 2016/01/17 17:45:21 christos Exp $	*/
+/*	$NetBSD: parse.c,v 1.210 2016/02/18 05:02:49 sjg Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: parse.c,v 1.209 2016/01/17 17:45:21 christos Exp $";
+static char rcsid[] = "$NetBSD: parse.c,v 1.210 2016/02/18 05:02:49 sjg Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)parse.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: parse.c,v 1.209 2016/01/17 17:45:21 christos Exp $");
+__RCSID("$NetBSD: parse.c,v 1.210 2016/02/18 05:02:49 sjg Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -157,6 +157,7 @@ typedef struct IFile {
     int             lineno;         /* current line number in file */
     int             first_lineno;   /* line number of start of text */
     int             cond_depth;     /* 'if' nesting when file opened */
+    Boolean         depending;      /* state of doing_depend on EOF */
     char            *P_str;         /* point to base of string buffer */
     char            *P_ptr;         /* point to next char of string buffer */
     char            *P_end;         /* point to the end of string buffer */
@@ -2139,7 +2140,7 @@ Parse_AddIncludeDir(char *dir)
  */
 
 static void
-Parse_include_file(char *file, Boolean isSystem, int silent)
+Parse_include_file(char *file, Boolean isSystem, Boolean depinc, int silent)
 {
     struct loadedfile *lf;
     char          *fullname;	/* full pathname of file */
@@ -2239,6 +2240,9 @@ Parse_include_file(char *file, Boolean i
     /* Start reading from this file next */
     Parse_SetInput(fullname, 0, -1, loadedfile_nextbuf, lf);
     curFile->lf = lf;
+    curFile->depending = doing_depend;	/* restore this on EOF */
+    if (depinc)
+	doing_depend = depinc;		/* only turn it on */
 }
 
 static void
@@ -2288,7 +2292,7 @@ ParseDoInclude(char *line)
      */
     file = Var_Subst(NULL, file, VAR_CMD, FALSE, TRUE, FALSE);
 
-    Parse_include_file(file, endc == '>', silent);
+    Parse_include_file(file, endc == '>', (*line == 'd'), silent);
     free(file);
 }
 
@@ -2532,7 +2536,7 @@ ParseTraditionalInclude(char *line)
 	else
 	    done = 1;
 
-	Parse_include_file(file, FALSE, silent);
+	Parse_include_file(file, FALSE, FALSE, silent);
     }
     free(all_files);
 }
@@ -2610,6 +2614,7 @@ ParseEOF(void)
 
     assert(curFile->nextbuf != NULL);
 
+    doing_depend = curFile->depending;	/* restore this */
     /* get next input buffer, if any */
     ptr = curFile->nextbuf(curFile->nextbuf_arg, &len);
     curFile->P_ptr = ptr;
@@ -2972,7 +2977,7 @@ Parse_File(const char *name, int fd)
 		    continue;
 		}
 		if (strncmp(cp, "include", 7) == 0 ||
-			((cp[0] == 's' || cp[0] == '-') &&
+			((cp[0] == 'd' || cp[0] == 's' || cp[0] == '-') &&
 			    strncmp(&cp[1], "include", 7) == 0)) {
 		    ParseDoInclude(cp);
 		    continue;

Reply via email to