wim
wim

Reputation: 363133

makefile conditional - strip whitespace from variable

Following the syntax given in the documentation here.

# Makefile
S='    '

spam:
ifneq ($(strip $(S)),)
    @echo nonempty
else
    @echo empty
endif

But when executing make spam, it still goes into the nonempty block here, expected the empty block.

What am I doing wrong?

Upvotes: 1

Views: 1092

Answers (1)

Etan Reisner
Etan Reisner

Reputation: 81012

make variable assignments aren't like shell assignments. You don't need the quotes.

You are setting the value of your variable to ' ' and not like you are expecting.

So strip then converts it to ' ' which is not equal to the empty string.

Remove the quotes on the assignment line.

Upvotes: 2

Related Questions