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