From marcs@valis.worldgate.com  Sun Oct  5 11:44:28 1997
Received: from valis.worldgate.com (marcs@valis.worldgate.com [198.161.84.2])
          by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id LAA03937
          for <FreeBSD-gnats-submit@freebsd.org>; Sun, 5 Oct 1997 11:44:27 -0700 (PDT)
Received: (from marcs@localhost)
	by valis.worldgate.com (8.8.7/8.8.7) id MAA29710;
	Sun, 5 Oct 1997 12:44:26 -0600 (MDT)
Message-Id: <199710051844.MAA29710@valis.worldgate.com>
Date: Sun, 5 Oct 1997 12:44:26 -0600 (MDT)
From: marcs@znep.com
Reply-To: marcs@znep.com
To: FreeBSD-gnats-submit@freebsd.org
Subject: make doesn't handle dependencies with forced target correctly
X-Send-Pr-Version: 3.2

>Number:         4697
>Category:       bin
>Synopsis:       make doesn't handle dependencies with forced target correctly
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Oct  5 11:50:01 PDT 1997
>Closed-Date:    Mon Aug 7 05:01:04 PDT 2000
>Last-Modified:  Mon Aug 07 05:01:28 PDT 2000
>Originator:     Marc Slemko
>Release:        FreeBSD 2.2-STABLE i386
>Organization:
>Environment:

FreeBSD 2.2-stable as of a few weeks ago, source examination shows
it to be in -current as well.
	

>Description:

When you have forced dependencies in a makefile that have the same
name as a file or directory, they are not called if the mtime
on the file is the same as the current time.
	

>How-To-Repeat:

If I create the below Makefile:

#----------------------------------------------------------------------
default: proxy
	@echo "Done building module subdirectories"

proxy: ForceMe
	@echo making: $@

ForceMe:
#----------------------------------------------------------------------

then do:

marcs@alive:/tmp/tm$ touch proxy ; make
Done building module subdirectories
marcs@alive:/tmp/tm$ touch proxy ; sleep 1 ; make
making: proxy
Done building module subdirectories

It doesn't execute the proxy target unless I make it pause in
between.
>Fix:

Index: compat.c
===================================================================
RCS file: /mnt/misc1/cvs//src/usr.bin/make/compat.c,v
retrieving revision 1.8
diff -u -r1.8 compat.c
--- compat.c	1997/02/22 19:27:07	1.8
+++ compat.c	1997/09/06 17:37:23
@@ -486,7 +486,7 @@
 	     * check for gn->children being empty as well...
 	     */
 	    if (!Lst_IsEmpty(gn->commands) || Lst_IsEmpty(gn->children)) {
-		gn->mtime = now;
+		gn->mtime = now+1;
 	    }
 #else
 	    /*
@@ -508,7 +508,7 @@
 	     * -- ardeb 1/12/88
 	     */
 	    if (noExecute || Dir_MTime(gn) == 0) {
-		gn->mtime = now;
+		gn->mtime = now+1;
 	    }
 	    if (gn->cmtime > gn->mtime)
 		gn->mtime = gn->cmtime;
>Release-Note:
>Audit-Trail:

From: Johan Karlsson <k@numeri.campus.luth.se>
To: freebsd-gnats-submit@FreeBSD.org
Cc: marcs@znep.com
Subject: Re: bin/4697: make doesn't handle dependencies with forced target 
 correctly
Date: Sun, 06 Aug 2000 12:40:53 +0200

 Hi Marc
 
 To force a target to be executed in make one should use .PHONY.
 
 With the following makefile your test case works as expected.
 
 #----------------------------
 default: proxy
 	@echo "Done building module subdirectories"
 
 .PHONY: proxy
 
 proxy:
 	@echo making: $@
 #-----------------------------
 
 
 This is the case in at least FreeBSD 4.1 and hence -current.
 
 Thanks
 Johan K
 
 
State-Changed-From-To: open->closed 
State-Changed-By: sheldonh 
State-Changed-When: Mon Aug 7 05:01:04 PDT 2000 
State-Changed-Why:  
Three cheers for PHONY targets. 


http://www.freebsd.org/cgi/query-pr.cgi?pr=4697 
>Unformatted:
