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