standards/116081: make does not work with the directive sinclude

Roy Marples uberlord at gentoo.org
Tue Sep 4 07:10:02 PDT 2007


>Number:         116081
>Category:       standards
>Synopsis:       make does not work with the directive sinclude
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-standards
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Sep 04 14:10:01 GMT 2007
>Closed-Date:
>Last-Modified:
>Originator:     Roy Marples
>Release:        FreeBSD-6.2
>Organization:
Gentoo
>Environment:
FreeBSD uberlaptop 6.2-RELEASE FreeBSD Gentoo 6.2-r2 #1: Sun Jul 29 22:45:11 BST 2007     root at uberlaptop:/usr/src/sys-6.2-r2/i386/compile/UBERKERNEL  i386
>Description:
Makefiles commonly need to include files. Sometimes they need to optionally include a file. There is currently no standard way of including an optional file in FreeBSD make that also works with other make systems.

NetBSD have updated their make so that either sinclude or -include directives work in Makefiles.
>How-To-Repeat:

>Fix:
Attached is a patch that mirrors the fix found in NetBSD make.

Patch attached with submission follows:

--- parse.c.orig	2007-09-04 14:39:07 +0100
+++ parse.c	2007-09-04 14:51:00 +0100
@@ -1602,8 +1602,8 @@
  * ParseTraditionalInclude  --
  *	Push to another file.
  *
- *	The input is the line minus the "include".  The file name is
- *	the string following the "include".
+ *	The input is the current line. The file name(s) are
+ *	following the "include".
  *
  * Results:
  *	None
@@ -1614,10 +1614,12 @@
  *---------------------------------------------------------------------
  */
 static void
-ParseTraditionalInclude(char *file)
+ParseTraditionalInclude(char *line)
 {
 	char	*fullname;	/* full pathname of file */
 	char	*cp;		/* current position in file spec */
+	int	silent = (line[0] != 'i') ? 1 : 0;
+	char	*file = &line[silent + 7];
 
 	/*
 	 * Skip over whitespace
@@ -1665,7 +1667,9 @@
 	}
 
 	if (fullname == NULL) {
-		Parse_Error(PARSE_FATAL, "Could not find %s", file);
+		if (!silent) {
+			Parse_Error(PARSE_FATAL, "Could not find %s", file);
+		}
 		/* XXXHB free(file) */
 		return;
 	}
@@ -2416,14 +2420,16 @@
 				}
 			}
 #ifdef SYSVINCLUDE
-		} else if (strncmp(line, "include", 7) == 0 &&
-		    isspace((unsigned char)line[7]) &&
-		    strchr(line, ':') == NULL) {
+		} else if (((strncmp(line, "include", 7) == 0 &&
+				isspace((unsigned char) line[7])) ||
+					((line[0] == 's' || line[0] == '-') &&
+						strncmp(&line[1], "include", 7) == 0 &&
+						isspace((unsigned char) line[8]))) &&
+					strchr(line, ':') == NULL) {
 			/*
 			 * It's an S3/S5-style "include".
 			 */
-			ParseTraditionalInclude(line + 7);
-			goto nextLine;
+			ParseTraditionalInclude(line);
 #endif
 		} else if (Parse_IsVar(line)) {
 			ParseFinishLine();


>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-standards mailing list