From sje2bk@marconi.com  Mon Jun 25 02:40:51 2001
Return-Path: <sje2bk@marconi.com>
Received: from cvis29.marconicomms.com (cvis29.marconicomms.com [195.99.244.61])
	by hub.freebsd.org (Postfix) with ESMTP id 6FCD537B401
	for <freebsd-gnats-submit@freebsd.org>; Mon, 25 Jun 2001 02:40:47 -0700 (PDT)
	(envelope-from sje2bk@marconi.com)
Received: from cvis01.gpt.co.uk (unverified) by cvis29.marconicomms.com
 (Content Technologies SMTPRS 4.1.5) with ESMTP id <T01010101545b937111@cvis29.marconicomms.com>;
 Mon, 25 Jun 2001 10:40:42 +0100
Received: from bkrzu6.de.marconicomms.com by cvis01.gpt.co.uk with ESMTP
 (8.8.8+Sun/cvms-32) id KAA10929; Mon, 25 Jun 2001 10:40:40 +0100 (BST)
Received: from bk4957.de.marconicomms.com (bk4957.de.marconicomms.com [172.28.39.232])
	by bkrzu6.de.marconicomms.com (8.9.3 (PHNE_22672)/8.9.3) with ESMTP id LAA27683;
	Mon, 25 Jun 2001 11:40:14 +0200 (METDST)
Received: (from sje2bk@localhost)
	by bk4957.de.marconicomms.com (8.11.1/8.11.1) id f5P9eDh00461;
	Mon, 25 Jun 2001 11:40:13 +0200 (CEST)
	(envelope-from sje2bk)
Message-Id: <20010625114013.A289@bk4957.de.marconicomms.com>
Date: Mon, 25 Jun 2001 11:40:13 +0200
From: Jens Schweikhardt <Jens.Schweikhardt@marconi.com>
To: Giorgos Keramidas <keramida@ceid.upatras.gr>
Cc: jens@schweikhardt.net, freebsd-gnats-submit@FreeBSD.org
In-Reply-To: <OFCB67EF9E.6BF8E9FE-ON80256A74.006C9206@de.marconicomms.com>; from keramida@ceid.upatras.gr on Sat, Jun 23, 2001 at 05:47:04PM +0000
Subject: Re: make(1) does not correctly substitute in internal macros like $(@F:.o=.c)
References: <OFCB67EF9E.6BF8E9FE-ON80256A74.006C9206@de.marconicomms.com>

>Number:         28403
>Category:       bin
>Synopsis:       Re: make(1) does not correctly substitute in internal macros like $(@F:.o=.c)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jun 25 02:50:00 PDT 2001
>Closed-Date:    Tue Oct 16 17:29:43 PDT 2001
>Last-Modified:  Tue Oct 16 17:30:11 PDT 2001
>Originator:     
>Release:        
>Organization:
>Environment:
>Description:
 On Sat, Jun 23, 2001 at 05:47:04PM +0000, Giorgos Keramidas wrote:
 # On Tue, Jan 16, 2001 at 02:44:12AM -0800, Jens.Schweikhardt@marconi.com wrote:
 # 
 # > >Description:
 # > 
 # > It seems, make(1) doesn't understand substitutions in what the POSIX
 # > standard calls internal variables ($@, $%, $?, $< and $*).
 # > In the following example, the intent is to substitute any *.o in a *.c,
 # > i.e. echo foo.c.
 # > 
 # > >How-To-Repeat:
 # > $ cat Makefile                  
 # > .POSIX:
 # > foo.o:
 # >         echo $(@F:.o=.c)
 # > $ /usr/bin/make
 # > echo foo.o.o=.c)
 # > Syntax error: ")" unexpected
 # > *** Error code 2
 # > 
 # > Stop in /usr/home/sje2bk.
 # 
 # Jens, are you sure this problem still persists to bug you?
  
 Yes.
 
 # Well, the syntax is slightly different in the make(1) program I have
 # on my 5.0-CURRENT, and by looking at the CVS logs, it seems that its
 # been like that for a while.  The way that BSD make does substitution
 # in variables, special or not is described in the paper found at
 # /usr/share/doc/psd/12.make/paper.* and an example of it is shown
 # below:
  
 That document also says:
 
   In addition, the System V style of substitution is also sup-
   ported.  This looks like:
 
         $(VARIABLE:search-string=replacement)
 
 and I can see nothing that says I couldn't use @F for VARIABLE here.
 
 ...
 # Am afraid that I don't know if POSIX specifies a different syntax than
 # the ${VARIABLE:modifier} that BSD make uses.
 
 I've got the old (1995) and soon-to-be (2001) POSIX specs near me.
 They are very clear. I know of the workaround; but I'm interested in
 having /usr/bin/make be POSIX compliant. There are makefiles out there
 that use this feature and they fail on BSD for no good reason.
 The latest and final POSIX draft says;
 
  Macro expansions using the forms $(string1[:subst1=[subst2]]) or
  ${string1[:subst1=[subst2]]} can be used to replace all occurrences of
  subst1 with subst2 when the macro substitution is performed. The subst1
  to be replaced shall be recognized when it is a suffix at the end of a
  word in string1 (where a word, in this context, is defined to be a
  string delimited by the beginning of the line, a <blank> or <newline>).
  If string1 in a macro expansion contains a macro expansion, the results
  are unspecified. Macro expansions in string1 of macro definition lines
  shall be evaluated when read. Macro expansions in string2 of macro
  definition lines shall be performed when the macro identified by
  string1 is expanded in a rule or command.
 
 #  On the other hand, the
 # version of GNU make that I have says in its manuals that substitution
 # in variables works a little differently than what you wrote.
  
 Not really; the % way of doing substitution is a GNU extension.
 It's not POSIX. It's just another (albeit more flexible) way of doing
 substitution. And as you can see in my original PR, GNU gets the POSIX
 substitution right.
 
 # 	% cat GNUmakefile 
 # 	
 # 	SRCS=   main.c foo.c
 # 	
 # 	OBJS=   $(SRCS:%.c=%.o)
 # 	
 # 	all:
 # 		echo $(OBJS)
 # 	
 # 	% gmake -f GNUmakefile 
 # 	
 # 	echo main.o foo.o
 # 	main.o foo.o
 # 
 # I think we can close this PR, if thats ok with you Jens too.
 
 Please leave it open. This is a real bug. POSIX substitution
 works in other circumstance with regular variables, just not with
 automatics using D (directory part) and F (filename part) modifiers:
 
 .POSIX:
 FOO = bar.o
 
 all:
     @echo '$(FOO:.o=.c)'
 bar.o:
     @echo '$(@F:.o=.c)'
 zap.o:
     @echo '$(@:.o=.c)'
 
 
 $ make all
 bar.c                  # works
 $ make bar.o
 bar.o.o=.c)            # buggy, should be bar.c
 $ make zap.o
 zap.c                  # works
 
 Regards,
 
 	Jens
 -- 
 Jens Schweikhardt  http://www.schweikhardt.net/
 SIGSIG -- signature too long (core dumped)
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: gnats-admin->will 
Responsible-Changed-By: greid 
Responsible-Changed-When: Mon Jul 2 11:32:42 PDT 2001 
Responsible-Changed-Why:  
Misfiled; should be part of the audit trail of 24377 which will is responsible for. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=28403 
Responsible-Changed-From-To: will->freebsd-bugs 
Responsible-Changed-By: will 
Responsible-Changed-When: Wed Aug 29 16:25:17 PDT 2001 
Responsible-Changed-Why:  
I don't have time for make(1) anymore... 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=28403 
State-Changed-From-To: open->closed 
State-Changed-By: keramida 
State-Changed-When: Tue Oct 16 17:29:43 PDT 2001 
State-Changed-Why:  
This is a duplicate of 24377. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=28403 
>Unformatted:
