| @@ -1,45 +1,55 @@ | | | @@ -1,45 +1,55 @@ |
1 | # $NetBSD: directive-ifmake.mk,v 1.3 2020/08/29 19:07:32 rillig Exp $ | | 1 | # $NetBSD: directive-ifmake.mk,v 1.4 2020/08/30 14:25:45 rillig Exp $ |
2 | # | | 2 | # |
3 | # Tests for the .ifmake directive, which provides a shortcut for asking | | 3 | # Tests for the .ifmake directive, which provides a shortcut for asking |
4 | # whether a certain target is requested to be made from the command line. | | 4 | # whether a certain target is requested to be made from the command line. |
5 | | | 5 | |
6 | # This is the most basic form. | | 6 | # This is the most basic form. |
7 | .ifmake first | | 7 | .ifmake first |
8 | .info ok: positive condition works | | 8 | .info ok: positive condition works |
9 | .else | | 9 | .else |
10 | .warning positive condition fails | | 10 | .warning positive condition fails |
11 | .endif | | 11 | .endif |
12 | | | 12 | |
13 | # The not operator works as expected. | | 13 | # The not operator works as expected. |
14 | # An alternative interpretation were that this condition is asking whether | | 14 | # An alternative interpretation were that this condition is asking whether |
15 | # the target "!first" was requested. To distinguish this, see the next test. | | 15 | # the target "!first" was requested. To distinguish this, see the next test. |
16 | .ifmake !first | | 16 | .ifmake !first |
17 | .warning unexpected | | 17 | .warning unexpected |
18 | .else | | 18 | .else |
19 | .info ok: negation works | | 19 | .info ok: negation works |
20 | .endif | | 20 | .endif |
21 | | | 21 | |
22 | # See if the exclamation mark really means "not", or if it is just part of | | 22 | # See if the exclamation mark really means "not", or if it is just part of |
23 | # the target name. | | 23 | # the target name. |
24 | .ifmake !!first | | 24 | .ifmake !!first |
25 | .info ok: double negation works | | 25 | .info ok: double negation works |
26 | .else | | 26 | .else |
27 | .warning double negation fails | | 27 | .warning double negation fails |
28 | .endif | | 28 | .endif |
29 | | | 29 | |
30 | # Multiple targets can be combined using the && and || operators. | | 30 | # Multiple targets can be combined using the && and || operators. |
31 | .ifmake first && second | | 31 | .ifmake first && second |
32 | .info ok: both mentioned | | 32 | .info ok: both mentioned |
33 | .else | | 33 | .else |
34 | .warning && does not work as expected | | 34 | .warning && does not work as expected |
35 | .endif | | 35 | .endif |
36 | | | 36 | |
37 | # Negation also works in complex conditions. | | 37 | # Negation also works in complex conditions. |
38 | .ifmake first && !unmentioned | | 38 | .ifmake first && !unmentioned |
39 | .info ok: only those mentioned | | 39 | .info ok: only those mentioned |
40 | .else | | 40 | .else |
41 | .warning && with ! does not work as expected | | 41 | .warning && with ! does not work as expected |
42 | .endif | | 42 | .endif |
43 | | | 43 | |
44 | first second unmentioned: | | 44 | # Using the .MAKEFLAGS special dependency target, arbitrary command |
| | | 45 | # line options can be added at parse time. This means that it is |
| | | 46 | # possible to extend the targets to be made. |
| | | 47 | .MAKEFLAGS: late-target |
| | | 48 | .ifmake late-target |
| | | 49 | .info Targets can even be added at parse time. |
| | | 50 | .else |
| | | 51 | .info No, targets cannot be added at parse time anymore. |
| | | 52 | .endif |
| | | 53 | |
| | | 54 | first second unmentioned late-target: |
45 | : $@ | | 55 | : $@ |