Re: make ".if exists" problem/question

From: M. Warner Losh <imp_at_bsdimp.com>
Date: Thu, 25 Aug 2005 23:53:03 -0600 (MDT)
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:
	_at_-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
Received on Fri Aug 26 2005 - 03:55:22 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:42 UTC