Home | History | Annotate | Line # | Download | only in unit-tests
      1 # $NetBSD: cond-func-commands.mk,v 1.6 2025/01/10 23:00:38 rillig Exp $
      2 #
      3 # Tests for the commands() function in .if conditions.
      4 
      5 .MAIN: all
      6 
      7 # At this point, the target 'target' does not exist yet, therefore it cannot
      8 # have commands.  Sounds obvious, but good to know that it is really so.
      9 .if commands(target)
     10 .  error
     11 .endif
     12 
     13 target:
     14 
     15 # Now the target exists, but it still has no commands.
     16 .if commands(target)
     17 .  error
     18 .endif
     19 
     20 target:
     21 	# not a command
     22 
     23 # Even after the comment, the target still has no commands.
     24 .if commands(target)
     25 .  error
     26 .endif
     27 
     28 target:
     29 	@:;
     30 
     31 # Finally the target has commands.
     32 .if !commands(target)
     33 .  error
     34 .endif
     35 
     36 # Expressions in the argument of a function call don't have to be defined.
     37 .if commands(${UNDEF})
     38 .  error
     39 .endif
     40 
     41 all:
     42 	@:;
     43