Since the conditional directive is ifeqoften used to compare words (s) extended from variables that often contain spaces, we might want and, in fact, require that Make separate any leading or trailing white space characters.
In fact, you may have the opposite view, that is, Make should store verbatim all the arguments in the ifeq conditional expression, since the user can have these spaces as part of the "test", with the intention for these spaces play a decisive factor in evaluating this directive ifeqas true or false .
I can’t decide which one is more correct.
In fact, I'm not alone!
Make yourself can not decide which one is right. Thus, it may or may not divide leading or trailing spaces.
In fact, sometimes it will only separate leading spaces .
Not disappointing, Make will sometimes only separate whitespace .
Of course, there are too many cases to check, so I will only do some of them.
Make file (VERSION 1):
ifeq ( a, a)
all::
echo 'true'
else
all::
echo 'false'
endif
Running, I get:
$ make -r
echo 'false'
false
Make file (VERSION 2):
ifeq (a ,a )
all::
echo 'true'
else
all::
echo 'false'
endif
Running, I get:
$ make -r
echo 'false'
false
Make file (VERSION 3):
ifeq ( a , a )
all::
echo 'true'
else
all::
echo 'false'
endif
Running, I get:
$ make -r
echo 'false'
false
Make file (VERSION 4):
ifeq (a , a)
all::
echo 'true'
else
all::
echo 'false'
endif
Running, I get:
$ make -r
echo 'true'
true
Make file (VERSION 5):
ifeq (a, a)
all::
echo 'true'
else
all::
echo 'false'
endif
Running, I get:
$ make -r
echo 'true'
true
To summarize, just a few cases, we have:
# Both, have only leading whitespace.
ifeq( a, a) as: false.
# Both, have only trailing whitespace.
ifeq(a ,a ) as: false.
# Both, have trailing AND trailing whitespace.
ifeq( a , a ) as: false.
# Left-hand-size has only trailing, and right-hand-size has only leading whitepsace.
ifeq(a , a) as: true.
# Left-hand-size has NO whitespace at-all, and right-hand-size has only leading whitepsace.
ifeq(a, a) as: true.
Thus, this methodology that Make uses to evaluate the veracity of a conditional directive ifeqdefinitely turns it into:
- Less consistent.
- Less comfortable.
- It’s harder to debug.
- .
- , ""!
?