Subject: make: ReadMakefile
To: None <tech-toolchain@netbsd.org>
From: Simon J. Gerraty <sjg@quick.com.au>
List: tech-toolchain
Date: 12/16/2000 02:00:24
Figured I should poll a wider audience...
I'm planning to modify our ReadMakefile so that it behaves the same as
freebsd's which seems more correct.  As is, given:

src/obj/Makefile
src/Makefile

our make will read src/obj/Makefile and behave as if it
applies to SUBDIRs below src rather than src/obj

freebsd will read src/Makefile which has it simply
	cd obj && ${MAKE}

If someone can demonstrate a use for the existing behaviour
I can make the semantics configurable - at compile time or even
runtime, but the patch below is the neatest solution.

Thanks
--sjg

Index: main.c
===================================================================
RCS file: /cvsroot/basesrc/usr.bin/make/main.c,v
retrieving revision 1.57
diff -u -p -r1.57 main.c
--- main.c      2000/06/06 03:00:11     1.57
+++ main.c      2000/12/16 09:46:00
@@ -919,8 +919,6 @@ ReadMakefile(p, q)
                Parse_File("(stdin)", stdin);
                Var_Set("MAKEFILE", "", VAR_GLOBAL);
        } else {
-               if ((stream = fopen(fname, "r")) != NULL)
-                       goto found;
                /* if we've chdir'd, rebuild the path name */
                if (curdir != objdir && *fname != '/') {
                        size_t plen = strlen(curdir) + strlen(fname) + 2;
@@ -932,7 +930,8 @@ ReadMakefile(p, q)
                                fname = path;
                                goto found;
                        }
-               }
+               } else if ((stream = fopen(fname, "r")) != NULL)
+                       goto found;
                /* look in -I and system include directories. */
                name = Dir_FindFile(fname, parseIncPath);
                if (!name)