80 GNU make
return true for all definitions except those like foo =. To test for an empty
value, use ifeq ($(foo),). For example,
bar =
foo = $(bar)
ifdef foo
frobozz = yes
else
frobozz = no
endif
sets ‘frobozz’ to ‘yes’, while:
foo =
ifdef foo
frobozz = yes
else
frobozz = no
endif
sets ‘frobozz’ to ‘no’.
ifndef variable-name
If the variable variable-name has an empty value, the text-if-true is effective;
otherwise, the text-if-false, if any, is effective. The rules for expansion and
testing of variable-name are identical to the ifdef directive.
Extra spaces are allowed and ignored at the beginning of the conditional directive line,
but a tab is not allowed. (If the line begins with a tab, it will be considered part of a recipe
for a rule.) Aside from this, extra spaces or tabs may be inserted with no effect anywhere
except within the directive name or within an argument. A comment starting with ‘#’ may
appear at the end of the line.
The other two directives that play a part in a conditional are else and endif. Each of
these directives is written as one word, with no arguments. Extra spaces are allowed and
ignored at the beginning of the line, and spaces or tabs at the end. A comment starting
with ‘#’ may appear at the end of the line.
Conditionals affect which lines of the makefile make uses. If the condition is true, make
reads the lines of the text-if-true as part of the makefile; if the condition is false, make
ignores those lines completely. It follows that syntactic units of the makefile, such as rules,
may safely be split across the beginning or the end of the conditional.
make evaluates conditionals when it reads a makefile. Consequently, you cannot use
automatic variables in the tests of conditionals because they are not defined until recipes
are run (see Section 10.5.3 [Automatic Variables], page 120).
To prevent intolerable confusion, it is not permitted to start a conditional in one makefile
and end it in another. However, you may write an include directive within a conditional,
provided you do not attempt to terminate the conditional inside the included file.
7.3 Conditionals that Test Flags
You can write a conditional that tests make command flags such as ‘-t’ by using the variable
MAKEFLAGS together with the findstring function (see Section 8.2 [Functions for String
Comentarios a estos manuales