make ".if exists" problem/question

M. Warner Losh imp at
Fri Aug 26 05:55:22 GMT 2005

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

target: 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:

	@-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(
.include ""

although I have seen others.


More information about the freebsd-current mailing list