help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: if-conditionals


From: Dill, John
Subject: Re: if-conditionals
Date: Mon, 13 Dec 2004 11:11:59 -0600

>Hi,
>
>I have 3 questions related to if-conditionals:
>
>1) I wonder, why are there never spaces after commas in 
>   the manual, like for example here: ifeq ($(CC),gcc).
>   Is it OK to put spaces after commas (I guess yes)?

This depends on the problem.  If doing raw text comparisons, then no because 
those spaces will be part of the comparison strings.  If the text is being used 
as a space delimited list, like in '$(foreach iter,your space  delimited      
list,$(iter))', then spaces do not matter.

>2) How do you test for OR-conditions?

Write a custom function.  If you interpret the empty text as false and any text 
as true, you can write this:

true:=true
false:=

# A function which performs the logical 'or' operation.
# $(1) - The first argument.
# $(2) - The second argument.
or=$(if $(strip $(1) $(2)),$(true),$(false))

>3) How do you search for a string, ignoring the case?

To ignore the case, it's quickest to use the shell and sed.

ECHO:=echo
SED:=sed

# This function converts all the text to uppercase.
# $(1) - The text to convert.
toupper=$(shell $(ECHO) '$(1)' | $(SED) -e 
'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/')

Then you can use $(filter $(call toupper,$(1)),$(call toupper,$(2))) 
substituting your text for 1 and 2 respectively.

>4) http://www.gnu.org/software/make/manual/html_node/make_77.html
>   says "Extra spaces are allowed and ignored at the beginning 
>   of the conditional directive line, but a tab is not allowed." 
>   Does it mean the tab in front of "if" word or also in the 
>   statements (i.e. may I indent the CXXFLAGS below)?

A tab is interpreted as a shell command, so CXXFLAGS should not have indented 
tabs.  You can use spaces though.

Hope this helps.
John




reply via email to

[Prev in Thread] Current Thread [Next in Thread]