make: Conditional Functions
1
1 8.4 Functions for Conditionals
1 ==============================
1
1 There are three functions that provide conditional expansion. A key
1 aspect of these functions is that not all of the arguments are expanded
1 initially. Only those arguments which need to be expanded, will be
1 expanded.
1
1 '$(if CONDITION,THEN-PART[,ELSE-PART])'
1 The 'if' function provides support for conditional expansion in a
1 functional context (as opposed to the GNU 'make' makefile
11 conditionals such as 'ifeq' (⇒Syntax of Conditionals
Conditional Syntax.).
1
1 The first argument, CONDITION, first has all preceding and trailing
1 whitespace stripped, then is expanded. If it expands to any
1 non-empty string, then the condition is considered to be true. If
1 it expands to an empty string, the condition is considered to be
1 false.
1
1 If the condition is true then the second argument, THEN-PART, is
1 evaluated and this is used as the result of the evaluation of the
1 entire 'if' function.
1
1 If the condition is false then the third argument, ELSE-PART, is
1 evaluated and this is the result of the 'if' function. If there is
1 no third argument, the 'if' function evaluates to nothing (the
1 empty string).
1
1 Note that only one of the THEN-PART or the ELSE-PART will be
1 evaluated, never both. Thus, either can contain side-effects (such
1 as 'shell' function calls, etc.)
1
1 '$(or CONDITION1[,CONDITION2[,CONDITION3...]])'
1 The 'or' function provides a "short-circuiting" OR operation. Each
1 argument is expanded, in order. If an argument expands to a
1 non-empty string the processing stops and the result of the
1 expansion is that string. If, after all arguments are expanded,
1 all of them are false (empty), then the result of the expansion is
1 the empty string.
1
1 '$(and CONDITION1[,CONDITION2[,CONDITION3...]])'
1 The 'and' function provides a "short-circuiting" AND operation.
1 Each argument is expanded, in order. If an argument expands to an
1 empty string the processing stops and the result of the expansion
1 is the empty string. If all arguments expand to a non-empty string
1 then the result of the expansion is the expansion of the last
1 argument.
1