Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 21 Jun 2010 00:44:25 GMT
From:      Garrett Cooper <gcooper@FreeBSD.org>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   bin/148024: Some built-in AT&T/POSIX compat make variables are broken
Message-ID:  <201006210044.o5L0iPXK000857@www.freebsd.org>
Resent-Message-ID: <201006210050.o5L0o1pu031120@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>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:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201006210044.o5L0iPXK000857>