minor cleanup, wire .depend directly into make program -- necessary
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Fri, 4 May 1990 02:22:06 +0000 (18:22 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Fri, 4 May 1990 02:22:06 +0000 (18:22 -0800)
so that the depend file gets read at the right time and doesn't set the .MAIN
target.

SCCS-vsn: usr.bin/make/main.c 5.18

usr/src/usr.bin/make/main.c

index dfcad33..65fc85e 100644 (file)
@@ -27,7 +27,7 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)main.c     5.17 (Berkeley) %G%";
+static char sccsid[] = "@(#)main.c     5.18 (Berkeley) %G%";
 #endif /* not lint */
 
 /*-
 #endif /* not lint */
 
 /*-
@@ -450,6 +450,8 @@ main(argc, argv)
        } else if (!ReadMakefile("makefile"))
                (void)ReadMakefile("Makefile");
 
        } else if (!ReadMakefile("makefile"))
                (void)ReadMakefile("Makefile");
 
+       (void)ReadMakefile(".depend");
+
        Var_Append("MFLAGS", Var_Value(MAKEFLAGS, VAR_GLOBAL), VAR_GLOBAL);
 
        /* Install all the flags into the MAKE envariable. */
        Var_Append("MFLAGS", Var_Value(MAKEFLAGS, VAR_GLOBAL), VAR_GLOBAL);
 
        /* Install all the flags into the MAKE envariable. */
@@ -570,25 +572,29 @@ ReadMakefile(fname)
                Parse_File("(stdin)", stdin);
                Var_Set("MAKEFILE", "", VAR_GLOBAL);
        } else {
                Parse_File("(stdin)", stdin);
                Var_Set("MAKEFILE", "", VAR_GLOBAL);
        } else {
+               if (stream = fopen(fname, "r"))
+                       goto found;
                /* if we've chdir'd, rebuild the path name */
                if (curdir && *fname != '/') {
                        (void)sprintf(path, "%s/%s", curdir, fname);
                /* if we've chdir'd, rebuild the path name */
                if (curdir && *fname != '/') {
                        (void)sprintf(path, "%s/%s", curdir, fname);
-                       fname = path;
-               }
-               if (!(stream = fopen(fname, "r"))) {
-                       /* look in -I and system include directories. */
-                       if (!(name = Dir_FindFile(fname, parseIncPath)) &&
-                           !(name = Dir_FindFile(fname, sysIncPath)) ||
-                           !(stream = fopen(name, "r")))
-                               return(FALSE);
-                       fname = name;
+                       if (stream = fopen(path, "r")) {
+                               fname = path;
+                               goto found;
+                       }
                }
                }
+               /* look in -I and system include directories. */
+               name = Dir_FindFile(fname, parseIncPath);
+               if (!name)
+                       name = Dir_FindFile(fname, sysIncPath);
+               if (!name || !(stream = fopen(name, "r")))
+                       return(FALSE);
+               fname = name;
                /*
                 * set the MAKEFILE variable desired by System V fans -- the
                 * placement of the setting here means it gets set to the last
                 * makefile specified, as it is set by SysV make.
                 */
                /*
                 * set the MAKEFILE variable desired by System V fans -- the
                 * placement of the setting here means it gets set to the last
                 * makefile specified, as it is set by SysV make.
                 */
-               Var_Set("MAKEFILE", fname, VAR_GLOBAL);
+found:         Var_Set("MAKEFILE", fname, VAR_GLOBAL);
                Parse_File(fname, stream);
                (void)fclose(stream);
        }
                Parse_File(fname, stream);
                (void)fclose(stream);
        }