unbesiegbar
unbesiegbar

Reputation: 461

Makefile ifneq condition fails

I am adding some conditional flag which depends upon the gcc version Below if the makefile snippet

CPPFLAGS :=  -O0  -g
CXXFLAGS := -fPIC
GCCVERSION = $(shell gcc --version | grep ^gcc |cut -b11-16)
ifneq ($(GCCVERSION),"4.1.2")
CPPFLAGS +=  -std=c++0x
CXXFLAGS += -m64
endif

The ifneq condition fails. I have checked that my $(GCCVERSION)=4.1.2 as expected.

EDIT:
I have already tried below options
ifneq ($(GCCVERSION),4.1.2)
ifneq ($(GCCVERSION),'4.1.2')
ifneq ("$(GCCVERSION)","4.1.2")

Upvotes: 0

Views: 400

Answers (1)

leiyc
leiyc

Reputation: 973

You need to strip $(GCCVERSION):

CPPFLAGS :=  -O0  -g
CXXFLAGS := -fPIC
GCCVERSION = $(shell gcc --version | grep ^gcc |cut -b11-16)
ifneq ($(strip $(GCCVERSION)),4.1.2)
CPPFLAGS +=  -std=c++0x
CXXFLAGS += -m64
endif

Upvotes: 2

Related Questions