xref: /freebsd/contrib/bmake/unit-tests/cond-func-target.mk (revision 6a7405f5a6b639682cacf01e35d561411ff556aa)
1*6a7405f5SSimon J. Gerraty# $NetBSD: cond-func-target.mk,v 1.5 2025/01/10 23:00:38 rillig Exp $
22c3632d1SSimon J. Gerraty#
32c3632d1SSimon J. Gerraty# Tests for the target() function in .if conditions.
42c3632d1SSimon J. Gerraty
52c3632d1SSimon J. Gerraty.MAIN: all
62c3632d1SSimon J. Gerraty
72c3632d1SSimon J. Gerraty# The target "target" does not exist yet.
82c3632d1SSimon J. Gerraty.if target(target)
92c3632d1SSimon J. Gerraty.  error
102c3632d1SSimon J. Gerraty.endif
112c3632d1SSimon J. Gerraty
122c3632d1SSimon J. Gerratytarget:
132c3632d1SSimon J. Gerraty
142c3632d1SSimon J. Gerraty# The target exists, even though it does not have any commands.
152c3632d1SSimon J. Gerraty.if !target(target)
162c3632d1SSimon J. Gerraty.  error
172c3632d1SSimon J. Gerraty.endif
182c3632d1SSimon J. Gerraty
192c3632d1SSimon J. Gerratytarget:
202c3632d1SSimon J. Gerraty	# not a command
212c3632d1SSimon J. Gerraty
222c3632d1SSimon J. Gerraty# Adding a comment to an existing target does not change whether the target
232c3632d1SSimon J. Gerraty# is defined or not.
242c3632d1SSimon J. Gerraty.if !target(target)
252c3632d1SSimon J. Gerraty.  error
262c3632d1SSimon J. Gerraty.endif
272c3632d1SSimon J. Gerraty
282c3632d1SSimon J. Gerratytarget:
292c3632d1SSimon J. Gerraty	@:;
302c3632d1SSimon J. Gerraty
312c3632d1SSimon J. Gerraty# Adding a command to an existing target does not change whether the target
322c3632d1SSimon J. Gerraty# is defined or not.
332c3632d1SSimon J. Gerraty.if !target(target)
342c3632d1SSimon J. Gerraty.  error
352c3632d1SSimon J. Gerraty.endif
362c3632d1SSimon J. Gerraty
37*6a7405f5SSimon J. Gerraty# Expressions in the argument of a function call don't have to be defined.
38*6a7405f5SSimon J. Gerraty.if target(${UNDEF})
39*6a7405f5SSimon J. Gerraty.  error
40*6a7405f5SSimon J. Gerraty.endif
41*6a7405f5SSimon J. Gerraty
422c3632d1SSimon J. Gerratyall:
432c3632d1SSimon J. Gerraty	@:;
44