[ACCEPTED]-Can't assign variable inside recipe-gnu-make

Accepted answer
Score: 78

I found a solution using the eval function:

$(eval variablename=whatever)

This works :)

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

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

Score: 4

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

I would try organising 5 it something like this:

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

OBJ = main.o Server.o

blabla : $(OBJ) 
    $(CXX) -o blabla $(OBJ) $(CXXFLAGS) 
ifneq ($(argsexec),true) 

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

More Related questions