78 GNU make
libs_for_gcc = -lgnu
normal_libs =
ifeq ($(CC),gcc)
libs=$(libs_for_gcc)
else
libs=$(normal_libs)
endif
foo: $(objects)
$(CC) -o foo $(objects) $(libs)
7.2 Syntax of Conditionals
The syntax of a simple conditional with no else is as follows:
conditional-directive
text-if-true
endif
The text-if-true may be any lines of text, to be considered as part of the makefile if the
condition is true. If the condition is false, no text is used instead.
The syntax of a complex conditional is as follows:
conditional-directive
text-if-true
else
text-if-false
endif
or:
conditional-directive-one
text-if-one-is-true
else conditional-directive-two
text-if-two-is-true
else
text-if-one-and-two-are-false
endif
There can be as many “else conditional-directive” clauses as necessary. Once a given
condition is true, text-if-true is used and no other clause is used; if no condition is true then
text-if-false is used. The text-if-true and text-if-false can be any number of lines of text.
The syntax of the conditional-directive is the same whether the conditional is simple
or complex; after an else or not. There are four different directives that test different
conditions. Here is a table of them:
Comentários a estes Manuais