Can't assign variable inside recipe

匆匆过客 提交于 2019-11-30 07:53:40
Blub

I found a solution using the eval function:

$(eval variablename=whatever)

This works :)

(although I may now try to find an easier build system ;))

Thanks everyone for reading and also of course @eriktous for writing!

If you write it like you did, the assignment will be executed as a shell command, which gives the error you got.

I would try organising it something like this:

CXXFLAGS = -I/usr/include/test
ifneq ($(argsexec),true) 
  CXXFLAGS += -shared -fPIC
  DESTDIR = /home/pc
endif

OBJ = main.o Server.o

blabla : $(OBJ) 
    $(CXX) -o blabla $(OBJ) $(CXXFLAGS) 
ifneq ($(argsexec),true) 
    ./bn.sh
endif

This should do what you want, although I'm not quite happy with using the ifneq construct twice. I'd have to think harder to come up with something that avoids that.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!