| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
8.4 Functions for Conditionals
There are three functions that provide conditional expansion. A key aspect of these functions is that not all of the arguments are expanded initially. Only those arguments which need to be expanded, will be expanded.
$(if condition,then-part[,else-part])-
The
iffunction provides support for conditional expansion in a functional context (as opposed to the GNUmakemakefile conditionals such asifeq(see section Syntax of Conditionals).The first argument, condition, first has all preceding and trailing whitespace stripped, then is expanded. If it expands to any non-empty string, then the condition is considered to be true. If it expands to an empty string, the condition is considered to be false.
If the condition is true then the second argument, then-part, is evaluated and this is used as the result of the evaluation of the entire
iffunction.If the condition is false then the third argument, else-part, is evaluated and this is the result of the
iffunction. If there is no third argument, theiffunction evaluates to nothing (the empty string).Note that only one of the then-part or the else-part will be evaluated, never both. Thus, either can contain side-effects (such as
shellfunction calls, etc.) $(or condition1[,condition2[,condition3…]])-
The
orfunction provides a “short-circuiting” OR operation. Each argument is expanded, in order. If an argument expands to a non-empty string the processing stops and the result of the expansion is that string. If, after all arguments are expanded, all of them are false (empty), then the result of the expansion is the empty string. $(and condition1[,condition2[,condition3…]])-
The
andfunction provides a “short-circuiting” AND operation. Each argument is expanded, in order. If an argument expands to an empty string the processing stops and the result of the expansion is the empty string. If all arguments expand to a non-empty string then the result of the expansion is the expansion of the last argument.
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated on October 10, 2013 using texi2html 5.0.
