Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 2 Jun 1998 07:32:48 -0400 (EDT)
From:      njs3@doc.ic.ac.uk
To:        FreeBSD-gnats-submit@FreeBSD.ORG
Subject:   bin/6830: make(1) exhibits confusing and non-standard behaviour
Message-ID:  <199806021132.HAA05318@www.in-design.com>

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

>Number:         6830
>Category:       bin
>Synopsis:       make(1) exhibits confusing and non-standard behaviour
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jun  2 04:40:01 PDT 1998
>Last-Modified:
>Originator:     njs3@doc.ic.ac.uk
>Organization:
>Release:        FreeBSD 2.2.5-RELEASE i386
>Environment:

>Description:

The := operator is used to force expansion of all variables on the RHS
of the operator, for example:

FOO     = bar
BAR     = ${FOO}
all:
 	echo ${BAR}
FOO     = feh

"make all" will echo "feh" since BAR is assigned ${FOO} and not the
contents of ${FOO} on line 2, and the last value assigned to FOO is "feh".
By using the := operator we can force ${FOO} to be expanded at the
point of assignment:

FOO     = bar
BAR     := ${FOO}
all:
 	echo ${BAR}
FOO     = feh

"make all" will echo "bar" in this case.  However, consider:

BAR     := ${FOO}
all:
 	echo ${BAR}
FOO     = feh

Contrary to the intuitive behaviour and all other implementation of
make, line one assigns ${FOO} to BAR and not the empty string.  This is
a bug, ${FOO} is a variable reference to an undefined variable which
by definition expands to the empty string.  However FreeBSD make does
not honor this behaviour and so "make all" prints "feh" instead of just
echoing a blank line.  Even more confusing is that:

FOO     =
BAR     := ${FOO}
all:
 	echo ${BAR}
FOO     = feh

behaves as expected, because FOO is defined to the empty string.

>How-To-Repeat:

>Fix:
	
I do not have time to provide a patch right now.
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message



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