From nobody@FreeBSD.org  Wed Oct 14 13:23:25 2009
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 1F1B21065672
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 14 Oct 2009 13:23:25 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 0D8D88FC19
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 14 Oct 2009 13:23:25 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id n9EDNOv7084428
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 14 Oct 2009 13:23:24 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id n9EDNO1b084420;
	Wed, 14 Oct 2009 13:23:24 GMT
	(envelope-from nobody)
Message-Id: <200910141323.n9EDNO1b084420@www.freebsd.org>
Date: Wed, 14 Oct 2009 13:23:24 GMT
From: FUCHIGAMI Masachika <masatic@mbs.sphere.ne.jp>
To: freebsd-gnats-submit@FreeBSD.org
Subject: make(1): variable substitution for $@ in dependency source fails
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         139600
>Category:       bin
>Synopsis:       make(1): variable substitution for $@ in dependency source fails
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    gavin
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Oct 14 13:30:02 UTC 2009
>Closed-Date:    Wed Oct 14 20:10:08 UTC 2009
>Last-Modified:  Wed Oct 14 20:10:08 UTC 2009
>Originator:     FUCHIGAMI Masachika
>Release:        FreeBSD 7.0-RELEASE i386
>Organization:
>Environment:
FreeBSD inca 7.0-RELEASE FreeBSD 7.0-RELEASE #15: Tue Aug 25 08:58:13 JST 2009 root@inca:/usr/src/sys/i386/compile/INCA i386

>Description:
local variable substitution in dependency source fails when $@ is used in another variable name ( e.g. ${$(@)_SRC} ).

make(1) delayes load-time variable substitution for local variables by expanding local variables to itself ( $@ -> $@ ), but make(1) does not delay variables containing local variables.

>How-To-Repeat:
-- Makefile
FOO=bar
foo: $($@).txt
--
% touch bar.txt
% make foo
make: don't know how to make .txt. Stop

>Fix:
*** var.c	2006-07-18 06:05:27.000000000 +0900
--- var.c	2009-10-14 21:43:55.000000000 +0900
***************
*** 1924,1929 ****
--- 1924,1937 ----
  				return (value);
  			}
  		}
+ 		if( vlen >=1 && strchr( vname, '$' ) != NULL ) {
+ 			value = emalloc( consumed + 1 );
+ 			strncpy(value, vp->input, consumed);
+ 			value[consumed] = '\0';
+ 
+ 			*freeResult = TRUE;
+ 			return (value);
+ 		}
  
  		*freeResult = FALSE;
  		return (vp->err ? var_Error : varNoError);
***************
*** 2019,2024 ****
--- 2027,2040 ----
  				return (value);
  			}
  		}
+ 		if( vlen >=1 && strchr( vname, '$' ) != NULL ) {
+ 			value = emalloc( consumed + 1 );
+ 			strncpy(value, vp->input, consumed);
+ 			value[consumed] = '\0';
+ 
+ 			*freeResult = TRUE;
+ 			return (value);
+ 		}
  	} else {
  		/*
  		 * Check for D and F forms of local variables since we're in

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: gavin 
State-Changed-When: Wed Oct 14 20:09:32 UTC 2009 
State-Changed-Why:  
Duplicate of 139601 


Responsible-Changed-From-To: freebsd-bugs->gavin 
Responsible-Changed-By: gavin 
Responsible-Changed-When: Wed Oct 14 20:09:32 UTC 2009 
Responsible-Changed-Why:  


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