所以,这很奇怪。在我的makefile中我有
CC:=icc
ifeq ($(CC),icc)
CFLAGS := $(ICCFLAGS)
LIBS := $(LIBS) -openmp
else
CFLAGS := $(GCCFLAGS)
LIBS := $(LIBS) -fopenmp
endif
对于make,条件为false但是
CCC:=icc
ifeq ($(CCC),icc)
CFLAGS := $(ICCFLAGS)
LIBS := $(LIBS) -openmp
else
CFLAGS := $(GCCFLAGS)
LIBS := $(LIBS) -fopenmp
endif
这里条件为真,
CC:=icc
CCC:=$(CC)
ifeq ($(CCC),icc)
CFLAGS := $(ICCFLAGS)
LIBS := $(LIBS) -openmp
else
CFLAGS := $(GCCFLAGS)
LIBS := $(LIBS) -fopenmp
endif
此处条件再次为假。到底是怎么回事?
答案 0 :(得分:1)
您似乎要将CC
作为命令行选项传递,例如:
make CC=...
...或使用-e
开关调用make,这会强制环境变量优先于Makefile中定义的变量。
您可以使用origin
function检查变量的定义方式:
CC := icc
$(error CC comes from $(origin CC))
如果打印command line
或environment override
,则解决方法是使用override
directive:
override CC := icc
即使命令行或环境中有另一个变量,也会设置CC
变量。