Subject: make: .PATH: work for .include
To: None <tech-toolchain@netbsd.org>
From: Simon Gerraty <sjg@juniper.net>
List: tech-toolchain
Date: 10/19/2007 10:52:55
make has the ability to do things like:

.SUFFIXES: .something
.PATH.something: /look/here /and/here

but Parse_include_file lacks the hook to use it for

.include "my.something"

Patch below fixes that

Index: parse.c
===================================================================
RCS file: /cvsroot/src/usr.bin/make/parse.c,v
retrieving revision 1.141
diff -u -p -r1.141 parse.c
--- parse.c	13 Oct 2007 18:28:35 -0000	1.141
+++ parse.c	19 Oct 2007 17:50:14 -0000
@@ -1785,18 +1785,29 @@ Parse_include_file(char *file, Boolean i
 	}
 	free(incdir);
 
-        if (fullname == NULL) {
+	if (fullname == NULL) {
 	    /*
     	     * Makefile wasn't found in same directory as included makefile.
 	     * Search for it first on the -I search path,
 	     * then on the .PATH search path, if not found in a -I directory.
-	     * XXX: Suffix specific?
+	     * If we have a suffix specific path we should use that.
 	     */
-	    fullname = Dir_FindFile(file, parseIncPath);
+	    char *suff;
+	    Lst	suffPath = NILLST;
+
+	    if ((suff = strrchr(file, '.'))) {
+		suffPath = Suff_GetPath(suff);
+		if (suffPath != NILLST) {
+		    fullname = Dir_FindFile(file, suffPath);
+		}
+	    }
 	    if (fullname == NULL) {
-	        fullname = Dir_FindFile(file, dirSearchPath);
+		fullname = Dir_FindFile(file, parseIncPath);
+		if (fullname == NULL) {
+		    fullname = Dir_FindFile(file, dirSearchPath);
+		}
 	    }
-        }
+	}
     }
 
     /* Looking for a system file or file still not found */