From owner-freebsd-bugs@FreeBSD.ORG  Mon Jun 21 00:50:01 2010
Return-Path: <owner-freebsd-bugs@FreeBSD.ORG>
Delivered-To: freebsd-bugs@hub.freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 813821065679
	for <freebsd-bugs@hub.freebsd.org>;
	Mon, 21 Jun 2010 00:50:01 +0000 (UTC)
	(envelope-from gnats@FreeBSD.org)
Received: from freefall.freebsd.org (freefall.freebsd.org
	[IPv6:2001:4f8:fff6::28])
	by mx1.freebsd.org (Postfix) with ESMTP id 5DDA98FC13
	for <freebsd-bugs@hub.freebsd.org>;
	Mon, 21 Jun 2010 00:50:01 +0000 (UTC)
Received: from freefall.freebsd.org (localhost [127.0.0.1])
	by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id o5L0o17K031121
	for <freebsd-bugs@freefall.freebsd.org>; Mon, 21 Jun 2010 00:50:01 GMT
	(envelope-from gnats@freefall.freebsd.org)
Received: (from gnats@localhost)
	by freefall.freebsd.org (8.14.4/8.14.4/Submit) id o5L0o1pu031120;
	Mon, 21 Jun 2010 00:50:01 GMT (envelope-from gnats)
Resent-Date: Mon, 21 Jun 2010 00:50:01 GMT
Resent-Message-Id: <201006210050.o5L0o1pu031120@freefall.freebsd.org>
Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer)
Resent-To: freebsd-bugs@FreeBSD.org
Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org,
	Garrett Cooper <gcooper@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 63F0D1065672
	for <freebsd-gnats-submit@FreeBSD.org>;
	Mon, 21 Jun 2010 00:44:26 +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 1C71C8FC1C
	for <freebsd-gnats-submit@FreeBSD.org>;
	Mon, 21 Jun 2010 00:44:26 +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 o5L0iPOW000858
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 21 Jun 2010 00:44:25 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id o5L0iPXK000857;
	Mon, 21 Jun 2010 00:44:25 GMT (envelope-from nobody)
Message-Id: <201006210044.o5L0iPXK000857@www.freebsd.org>
Date: Mon, 21 Jun 2010 00:44:25 GMT
From: Garrett Cooper <gcooper@FreeBSD.org>
To: freebsd-gnats-submit@FreeBSD.org
X-Send-Pr-Version: www-3.1
Cc: 
Subject: bin/148024: Some built-in AT&T/POSIX compat make variables are
	broken
X-BeenThere: freebsd-bugs@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: Bug reports <freebsd-bugs.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-bugs>,
	<mailto:freebsd-bugs-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/freebsd-bugs>
List-Post: <mailto:freebsd-bugs@freebsd.org>
List-Help: <mailto:freebsd-bugs-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-bugs>,
	<mailto:freebsd-bugs-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Mon, 21 Jun 2010 00:50:01 -0000


>Number:         148024
>Category:       bin
>Synopsis:       Some built-in AT&T/POSIX compat make variables are broken
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jun 21 00:50:01 UTC 2010
>Closed-Date:
>Last-Modified:
>Originator:     Garrett Cooper
>Release:        9-CURRENT
>Organization:
Cisco Systems, Inc.
>Environment:
FreeBSD bayonetta.local 9.0-CURRENT FreeBSD 9.0-CURRENT #0 r206173M: Mon Apr 26 22:45:06 PDT 2010     root@bayonetta.local:/usr/obj/usr/src/sys/BAYONETTA.ata  amd64
>Description:
I'm trying to convert some GNU makefiles over to a POSIX compliant form, and it appears that our copy of make is broken in that respect.

Example:

$ cat ~/Makefile.prereq 
bar:

foo: bar
	@echo target: $@ prereq: $<
$ make -f ~/Makefile.prereq foo
target: foo prereq:

The above invocation should have printed out:

target: foo prereq: bar

Furthermore, even though FreeBSD's version of pmake claims to drop this support as per the manpage for backwards compatibility with AT&T...

     .ALLSRC   The list of all sources for this target; also known as `>'.

     .ARCHIVE  The name of the archive file; also known as `!'.

     .IMPSRC   The name/path of the source from which the target is to be
               transformed (the ``implied'' source); also known as `<'.

     .MEMBER   The name of the archive member; also known as `%'.

     .OODATE   The list of sources for this target that were deemed out-of-
               date; also known as `?'.

     .PREFIX   The file prefix of the file, containing only the file portion,
               no suffix or preceding directory components; also known as `*'.

     .TARGET   The name of the target; also known as `@'.

and POSIX specifies that these variables should exist, they don't function in our version of make:
The five internal macros are:

$@
    The $@ shall evaluate to the full target name of the current target, or the archive filename part of a library archive target. It shall be evaluated for both target and inference rules.

    For example, in the .c.a inference rule, $@ represents the out-of-date .a file to be built. Similarly, in a makefile target rule to build lib.a from file.c, $@ represents the out-of-date lib.a.
$%
    The $% macro shall be evaluated only when the current target is an archive library member of the form libname( member .o). In these cases, $@ shall evaluate to libname and $% shall evaluate to member .o. The $% macro shall be evaluated for both target and inference rules.

    For example, in a makefile target rule to build lib.a( file.o), $% represents file.o, as opposed to $@, which represents lib.a.
$?
    The $? macro shall evaluate to the list of prerequisites that are newer than the current target. It shall be evaluated for both target and inference rules.

    For example, in a makefile target rule to build prog from file1.o, file2.o, and file3.o, and where prog is not out-of-date with respect to file1.o, but is out-of-date with respect to file2.o and file3.o, $? represents file2.o and file3.o.
$<
    In an inference rule, the $< macro shall evaluate to the filename whose existence allowed the inference rule to be chosen for the target. In the .DEFAULT rule, the $< macro shall evaluate to the current target name. The meaning of the $< macro shall be otherwise unspecified.

    For example, in the .c.a inference rule, $< represents the prerequisite .c file.
$*
    The $* macro shall evaluate to the current target name with its suffix deleted. It shall be evaluated at least for inference rules.

    For example, in the .c.a inference rule, $*.o represents the out-of-date .o file that corresponds to the prerequisite .c file

See http://www.opengroup.org/onlinepubs/009695399/utilities/make.html for more details.
>How-To-Repeat:
See above testcase.
>Fix:
Looking at fixing this.

>Release-Note:
>Audit-Trail:
>Unformatted: