Reputation: 11
I have Makefile where flag is set for IPv6 compilation.
IPV6 = 1
ifeq ($(IPV6), 1)
Then ipv6 targets are include for compilations.
Requirement: I want to enable this flag based on feature, and this feature is part of the CFLAG.
ifdef IPV6_FEATURE
IPV6=1
else
IPV6=0
endif
But since IPV6_FEATURE is not available in Makefile as it is a global include, it will always going to else.
Please let me know if any alternatives for this.
Upvotes: 1
Views: 2029
Reputation: 6978
If I understand your question, in the cases where IPV6_FEATURE
is defined, it gets included after the section where you are testing it. This does not work, since make evaluates conditionals when it reads the makefile.
The solution is to not use an ifdef
to set IPV6
, and use a conditional function instead.
IPV6 = $(if $(IPV6_FEATURE), 1, 0)
This will set IPV6=1
if IPV6_FEATURE
is defined to some non-empty value.
You may also need to change how you are using $(IPV6)
, so that you don't have an ifeq
conditional.
Upvotes: 1