From gibbs@narnia.plutotech.com  Tue Aug 26 20:40:07 1997
Received: from narnia.plutotech.com (narnia.plutotech.com [206.168.67.130])
          by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id UAA02462
          for <FreeBSD-gnats-submit@freebsd.org>; Tue, 26 Aug 1997 20:40:07 -0700 (PDT)
Received: (from gibbs@localhost) by narnia.plutotech.com (8.8.7/8.7.3) id VAA19884; Tue, 26 Aug 1997 21:38:27 -0600 (MDT)
Message-Id: <199708270338.VAA19884@narnia.plutotech.com>
Date: Tue, 26 Aug 1997 21:38:27 -0600 (MDT)
From: "Justin T. Gibbs" <gibbs@narnia.plutotech.com>
Reply-To: gibbs@narnia.plutotech.com
To: FreeBSD-gnats-submit@freebsd.org
Subject: make searches for it's Makefile in MAKEOBJDIR before curdir.
X-Send-Pr-Version: 3.2

>Number:         4401
>Category:       bin
>Synopsis:       make searches for it's Makefile in MAKEOBJDIR before curdir.
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Aug 26 20:50:03 PDT 1997
>Closed-Date:    Tue Aug 26 23:33:26 PDT 1997
>Last-Modified:  Tue Aug 26 23:33:41 PDT 1997
>Originator:     Justin T. Gibbs
>Release:        FreeBSD 3.0-CURRENT i386
>Organization:
Pluto Technologies International Inc.
>Environment:
>Description:

	If MAKEOBJDIR is set to a directory that happens to contain
	a Makefile, make will execute it instead of the Makefile in
	the current directory.

>How-To-Repeat:

	export MAKEOBJDIR=/usr/src/sys/compile/MYKERNEL
	cd /usr/src/bin/ls
	make
	
	Kernel gets built instead of ls. 8-)

>Fix:
	
Index: main.c
===================================================================
RCS file: /usr/cvs/src/usr.bin/make/main.c,v
retrieving revision 1.21
diff -c -r1.21 main.c
*** main.c	1997/08/25 21:35:44	1.21
--- main.c	1997/08/26 20:18:50
***************
*** 834,841 ****
  		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 != '/') {
  			(void)sprintf(path, "%s/%s", curdir, fname);
--- 834,839 ----
***************
*** 843,849 ****
  				fname = path;
  				goto found;
  			}
! 		}
  		/* look in -I and system include directories. */
  		name = Dir_FindFile(fname, parseIncPath);
  		if (!name)
--- 841,848 ----
  				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)

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: jkh 
State-Changed-When: Tue Aug 26 23:33:26 PDT 1997 
State-Changed-Why:  
Suggested fix tested and committed. 
>Unformatted:
