Armand Jordaan
Armand Jordaan

Reputation: 348

Need help in understanding why ifeq does not work

I have the following code in a makefile:

TEMP="VBU538ForBootloader"


# build
build: .build-post

.build-pre:
# Add your pre 'build' code here...

.build-post: .build-impl

    @echo "Current config:" $(CONF)
    @echo "Compare to:" $(TEMP)

ifeq ($(CONF),$(TEMP))
    @echo "Making production files for VBU538 .... "
else
    @echo "Skipping production files."
endif

Somehow the ifeq does not do what I expected, although it looks to me that my code is similar to other examples. The code produces the following output:

Current config: VBU538ForBootloader
Compare to: VBU538ForBootloader
Skipping production files.

I am always getting Skipping production files. although I expected that the output should have been Making production files for VBU538 ....

Does anyone know the reason why its not behaving as expected?

Upvotes: 0

Views: 157

Answers (2)

Armand Jordaan
Armand Jordaan

Reputation: 348

I eventually found the problem. Thanks for everybody's effort. Eventually I got a hunch that when I was calling make, the wrong make utility was being used. It turned out that I have to use the same make utility as the one that came with the IDE for the microcontroller. I am not sure why that would be needed, but using the make utility that came with the IDE solved the problem.

Upvotes: 0

Renaud Pacalet
Renaud Pacalet

Reputation: 29403

Your code is not an MCVE so it is difficult to help. It could be that your COMP and TEMP variables look identical but they are not (spaces, other invisible characters...) You could try to check this by using:

    @echo 'Current config: X$(CONF)X'
    @echo 'Compare to: X$(TEMP)X'

instead of

    @echo "Current config:" $(CONF)
    @echo "Compare to:" $(TEMP)

Upvotes: 2

Related Questions