xref: /freebsd-src/contrib/bmake/unit-tests/cond-func-commands.mk (revision e2eeea75eb8b6dd50c1298067a0655880d186734)
1*e2eeea75SSimon J. Gerraty# $NetBSD: cond-func-commands.mk,v 1.5 2020/11/15 14:07:53 rillig Exp $
22c3632d1SSimon J. Gerraty#
32c3632d1SSimon J. Gerraty# Tests for the commands() function in .if conditions.
42c3632d1SSimon J. Gerraty
52c3632d1SSimon J. Gerraty.MAIN: all
62c3632d1SSimon J. Gerraty
7*e2eeea75SSimon J. Gerraty# At this point, the target 'target' does not exist yet, therefore it cannot
8*e2eeea75SSimon J. Gerraty# have commands.  Sounds obvious, but good to know that it is really so.
92c3632d1SSimon J. Gerraty.if commands(target)
102c3632d1SSimon J. Gerraty.  error
112c3632d1SSimon J. Gerraty.endif
122c3632d1SSimon J. Gerraty
132c3632d1SSimon J. Gerratytarget:
142c3632d1SSimon J. Gerraty
152c3632d1SSimon J. Gerraty# Now the target exists, but it still has no commands.
162c3632d1SSimon J. Gerraty.if commands(target)
172c3632d1SSimon J. Gerraty.  error
182c3632d1SSimon J. Gerraty.endif
192c3632d1SSimon J. Gerraty
202c3632d1SSimon J. Gerratytarget:
212c3632d1SSimon J. Gerraty	# not a command
222c3632d1SSimon J. Gerraty
232c3632d1SSimon J. Gerraty# Even after the comment, the target still has no commands.
242c3632d1SSimon J. Gerraty.if commands(target)
252c3632d1SSimon J. Gerraty.  error
262c3632d1SSimon J. Gerraty.endif
272c3632d1SSimon J. Gerraty
282c3632d1SSimon J. Gerratytarget:
292c3632d1SSimon J. Gerraty	@:;
302c3632d1SSimon J. Gerraty
312c3632d1SSimon J. Gerraty# Finally the target has commands.
322c3632d1SSimon J. Gerraty.if !commands(target)
332c3632d1SSimon J. Gerraty.  error
342c3632d1SSimon J. Gerraty.endif
352c3632d1SSimon J. Gerraty
362c3632d1SSimon J. Gerratyall:
372c3632d1SSimon J. Gerraty	@:;
38