make: Testing Flags

1 
1 7.3 Conditionals that Test Flags
1 ================================
1 
1 You can write a conditional that tests 'make' command flags such as '-t'
1 by using the variable 'MAKEFLAGS' together with the 'findstring'
11 function (⇒Functions for String Substitution and Analysis Text
 Functions.).  This is useful when 'touch' is not enough to make a file
1 appear up to date.
1 
1    The 'findstring' function determines whether one string appears as a
1 substring of another.  If you want to test for the '-t' flag, use 't' as
1 the first string and the value of 'MAKEFLAGS' as the other.
1 
1    For example, here is how to arrange to use 'ranlib -t' to finish
1 marking an archive file up to date:
1 
1      archive.a: ...
1      ifneq (,$(findstring t,$(MAKEFLAGS)))
1              +touch archive.a
1              +ranlib -t archive.a
1      else
1              ranlib archive.a
1      endif
1 
1 The '+' prefix marks those recipe lines as "recursive" so that they will
11 be executed despite use of the '-t' flag.  ⇒Recursive Use of
 'make' Recursion.
1