makefile这东西, 不熟悉的话, 到处是坑, 比如, 该用tab的地方, 你用了空格, 那就呵呵哒了, 新手通常犯这个错误。
来看看最近遇到的:
all:
ifeq(hello, hello)
@echo "yes"
else
@echo "no"
endif
g++ test.cpp -lpthread
执行后, 提示:syntax error near unexpected token, 为什么呢? 因为ifeq不能缩进, 改为:
all:
ifeq(hello, hello)
@echo "yes"
else
@echo "no"
endif
g++ test.cpp -lpthread
执行后, 又提示:*** missing separator. Stop. 为什么呢? 因为ifeq后面需要空格, 改为:
all:
ifeq (hello, hello)
@echo "yes"
else
&echo "no"
endif
g++ test.cpp -lpthread
OK了。
另外, 这种也是不行的:
@echo "begin"
all:
ifeq (hello, hello)
@echo "yes"
else
@echo "no"
endif
g++ test.cpp -lpthread
而这种也不行:
all:
ifeq (hello, hello)
x:=good
else
x:=bad
endif
g++ test.cpp -lpthread
提到all外面才可:
ifeq (hello, hello)
x:=good
else
x:=bad
endif
all:
@echo $(x)
g++ test.cpp -lpthread
不多说。