From se@dialup124.zpr.uni-koeln.de  Sun Nov  2 02:59:03 1997
Received: from Octopussy.MI.Uni-Koeln.DE (Octopussy.MI.Uni-Koeln.DE [134.95.166.20])
          by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id CAA14892
          for <FreeBSD-gnats-submit@freebsd.org>; Sun, 2 Nov 1997 02:59:02 -0800 (PST)
          (envelope-from se@dialup124.zpr.uni-koeln.de)
Received: from dialup124.zpr.Uni-Koeln.DE (dialup124.zpr.Uni-Koeln.DE [134.95.219.124])
	by Octopussy.MI.Uni-Koeln.DE (8.8.7/8.8.7) with ESMTP id LAA09131
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 2 Nov 1997 11:58:59 +0100 (MET)
Received: (from se@localhost) by dialup124.zpr.Uni-Koeln.DE (8.8.7/8.6.9) id LAA12514; Sun, 2 Nov 1997 11:58:54 +0100 (CET)
Message-Id: <199711021058.LAA12514@dialup124.zpr.Uni-Koeln.DE>
Date: Sun, 2 Nov 1997 11:58:54 +0100 (CET)
From: Stefan Esser <se@dialup124.zpr.uni-koeln.de>
Reply-To: se@dialup124.zpr.uni-koeln.de
To: FreeBSD-gnats-submit@freebsd.org
Subject: Make fails to correctly substitute "Automatic Variable $"
X-Send-Pr-Version: 3.2

>Number:         4918
>Category:       bin
>Synopsis:       Make fails to correctly substitute "Automatic Variable $"
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    steve
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Nov  2 03:00:01 PST 1997
>Closed-Date:    Sun Jan 11 15:57:41 PST 1998
>Last-Modified:  Sun Jan 11 16:08:15 PST 1998
>Originator:     Stefan Esser
>Release:        FreeBSD 3.0-CURRENT i386
>Organization:
Just another Ports Maintainer :)
>Environment:
FreeBSD-current as of about October 15.
>Description:
I have more than once found a seemingly correct Makefile to fail 
with the FreeBSD make, but never had time to check why, and just 
worked around the problem by using gmake. While I had assumed 
that some software package just used gmake specific extensions,
I now found a simple example, where gmake succeeds, and our make
fails for non-obvious reasons.

Seems that "$<" is not equivalent to "$?" with a single dependency.
In fact, though the make rule matched for some dependency, "$y" is
passed empty to the dependent command invocation.
>How-To-Repeat:
I just extract the contents of the attached SHAR and type "make":

# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	Makefile
#	game.h
#	snake.h
#
echo x - Makefile
sed 's/^X//' >Makefile << 'END-of-Makefile'
X########### File Formats ###########
X
X.SUFFIXES: .cpp .moc
X
X.cpp.o:
X	@$(CXX) -c $(CXXFLAGS) $<
X
X.h.moc:
X	$(MOC) $< -o $@
X
Xall:	msnake.o mgame.o
X
X####### Meta classes
X
XMOC=	echo moc
XCXX=	echo c++
X
Xmsnake.cpp: snake.h
X	@$(MOC) -o $@ snake.h "<--" EXPECTED
X	@$(MOC) -o $@ $?
X
Xmgame.cpp: game.h
X	@$(MOC) -o $@ game.h "<--" EXPECTED
X	@$(MOC) -o $@ $<
END-of-Makefile
echo x - game.h
sed 's/^X//' >game.h << 'END-of-game.h'
END-of-game.h
echo x - snake.h
sed 's/^X//' >snake.h << 'END-of-snake.h'
END-of-snake.h
exit

>Fix:
Unknown.
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: gnats-admin->freebsd-bugs 
Responsible-Changed-By: max 
Responsible-Changed-When: Sun Nov 2 11:44:39 PST 1997 
Responsible-Changed-Why:  
Misfiled PR. 
State-Changed-From-To: open->closed 
State-Changed-By: steve 
State-Changed-When: Sun Jan 11 15:57:41 PST 1998 
State-Changed-Why:  
Posix 1003.2 says that $< shall only be evaluated in the 
.DEFAULT rule and inference (suffix) rules.  make(1) does 
the correct thing in your example by evaluating $< to an 
empty string because this is a target rule. 
>Unformatted:
