0

So, this is odd. In my makefile I have

CC:=icc
ifeq ($(CC),icc)
CFLAGS := $(ICCFLAGS)
LIBS := $(LIBS) -openmp
else
CFLAGS := $(GCCFLAGS)
LIBS := $(LIBS) -fopenmp
endif

for make, the condition is false but

CCC:=icc
ifeq ($(CCC),icc)
CFLAGS := $(ICCFLAGS)
LIBS := $(LIBS) -openmp
else
CFLAGS := $(GCCFLAGS)
LIBS := $(LIBS) -fopenmp
endif

here the condition is true, and

CC:=icc
CCC:=$(CC)
ifeq ($(CCC),icc)
CFLAGS := $(ICCFLAGS)
LIBS := $(LIBS) -openmp
else
CFLAGS := $(GCCFLAGS)
LIBS := $(LIBS) -fopenmp
endif

here the condition is false again. What the hell is going on?

Eldar Abusalimov
  • 24,387
  • 4
  • 67
  • 71
Patrik
  • 845
  • 2
  • 8
  • 20
  • Try putting `$(info CC is $(CC))` at different places in the makefile (e.g. at the very top, just before `CC := icc`, just *after* `CC := icc`). That will give us a better idea of where the problem is. – Beta Mar 30 '12 at 14:31

1 Answers1

1

It seem that you're either passing CC as a command line option, like:

make CC=...

... or invoking make with -e switch, which forces environment variables to take precedence over the ones defined in Makefile.

You can use origin function to check how the variable has been defined:

CC := icc
$(error CC comes from $(origin CC))

If this prints command line or environment override, then the solution is to use override directive:

override CC := icc

This will set CC variable even if there is another one from command line or environment.

Eldar Abusalimov
  • 24,387
  • 4
  • 67
  • 71