From dada@lend.tu-graz.ac.at  Thu Oct  9 07:50:43 1997
Received: from fcggsg07.icg.tu-graz.ac.at (fcggsg07.icg.tu-graz.ac.at [129.27.201.16])
          by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id HAA04644
          for <FreeBSD-gnats-submit@freebsd.org>; Thu, 9 Oct 1997 07:50:36 -0700 (PDT)
          (envelope-from dada@lend.tu-graz.ac.at)
Received: from lend.tu-graz.ac.at (isdn012.tu-graz.ac.at [129.27.240.12])
          by fcggsg07.icg.tu-graz.ac.at (8.8.4/8.8.4) with ESMTP
	  id QAA24994 for <FreeBSD-gnats-submit@freebsd.org>; Thu, 9 Oct 1997 16:49:57 +0200 (MDT)
Received: (from dada@localhost)
	by lend.tu-graz.ac.at (8.8.5/8.8.5) id QAA07975;
	Thu, 9 Oct 1997 16:47:47 +0200 (CEST)
Message-Id: <199710091447.QAA07975@lend.tu-graz.ac.at>
Date: Thu, 9 Oct 1997 16:47:47 +0200 (CEST)
From: Martin Kammerhofer <dada@sbox.tu-graz.ac.at>
Reply-To: dada@sbox.tu-graz.ac.at
To: FreeBSD-gnats-submit@freebsd.org
Subject: Bugs in /usr/share/mk/bsd.*.mk bsd-make include files
X-Send-Pr-Version: 3.2

>Number:         4736
>Category:       bin
>Synopsis:       Bugs in /usr/share/mk/bsd.*.mk bsd-make include files
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Oct  9 08:00:01 PDT 1997
>Closed-Date:    Sat Nov 15 09:55:51 PST 1997
>Last-Modified:  Sat Nov 15 09:56:26 PST 1997
>Originator:     Martin Kammerhofer
>Release:        FreeBSD 2.2.2-RELEASE i386
>Organization:
Graz University of Technology
>Environment:

        probably all BSDs, for sure in FreeBSD 2.2.2

>Description:

        There are make rules wich are intended to define default rules
        for undefined targets, i.e targets never occuring on the left
        side of a dependency.
        E.g. from bsd.subdir.mk:

.for __target in all checkdpadd clean cleandir depend lint \
                 maninstall obj objlink
.if !target(__target)
${__target}: _SUBDIRUSE
.endif
.endfor

        These do not work as intended because ``__target'' is taken
        literally. It should - of course - read:

.if !target(${__target})

        As a consequence these default rules are added *unconditionally*
        (except for the case where someone has explicitely defined
        a ``__target'' target, in which case no rule at all would get
        added).
        There are at least three of these bugs:

<ttyp4 /src/share/mk>fgrep -n target\(_ *
bsd.port.subdir.mk:51:.if !target(__target)
bsd.sgml.mk:152:.if !target(__target)
bsd.subdir.mk:31:.if !target(__target)

>How-To-Repeat:

<ttyp4 /var/tmp>cat Makefile

SUBDIR = nosuchsubdir

all:
        @echo "This rule won't fall over after fixing this bug"

clean: _SUBDIRUSE
        @echo "This is expected to fail"

.include <bsd.subdir.mk>

<ttyp4 /var/tmp>make
This rule won't fall over after fixing this bug
===> nosuchsubdir
cd: can't cd to /var/tmp/nosuchsubdir
*** Error code 2

Stop.
<ttyp4 /var/tmp>

>Fix:
        
        substitute ``target(${__target})'' for ``target(__target)''

        Note: Since this affects all makes it could theoretically break
              existing Makefiles if they relied on this bug.
              If you want the default rules added, you have to specify
              a ``_SUBDIRUSE'' dependency like in ``clean'' above.

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: wosch 
State-Changed-When: Sat Nov 15 09:55:51 PST 1997 
State-Changed-Why:  
Now fixed. Thanks! 

>Unformatted:
