Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 4 Sep 2007 14:01:46 GMT
From:      Roy Marples <uberlord@gentoo.org>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   standards/116081: make does not work with the directive sinclude
Message-ID:  <200709041401.l84E1kH9077289@www.freebsd.org>
Resent-Message-ID: <200709041410.l84EA1cf081322@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>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@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:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200709041401.l84E1kH9077289>