Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 25 Aug 2005 23:53:03 -0600 (MDT)
From:      "M. Warner Losh" <imp@bsdimp.com>
To:        keramida@freebsd.org
Cc:        Emanuel.strobl@gmx.net, freebsd-current@freebsd.org, dpk@dpk.net, freebsd-questions@freebsd.org
Subject:   Re: make ".if exists" problem/question
Message-ID:  <20050825.235303.66274316.imp@bsdimp.com>
In-Reply-To: <20050825184614.GA97117@orion.daedalusnetworks.priv>
References:  <35c231bf05082511101884faf@mail.gmail.com> <200508252037.04779@harrymail> <20050825184614.GA97117@orion.daedalusnetworks.priv>

next in thread | previous in thread | raw e-mail | index | archive | help
Yes.  The thing to keep in mind is that much of the .if stuff is done
at parsing or rule construction time.  So if you change something
(creating a file, say), then that condition won't be re-evaluated.

For the specific example given, one could replace much of the goo
with:

target: foobar

foobar:
	touch foobar

if you wanted to create foobar.  Otherwise, I'd be tempted not to use
.if exists.  I'd be tempted to do something more like:

target:
	@-if [ -f foobar ]; then cat foobar; else touch foobar; fi

where you have the shell check.

The primary use of exists() I've seen is:

.if exists(foo.mk)
.include "foo.mk"
.endif

although I have seen others.

Warner



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