Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

How do I make this work? It errors out with "make: somevariable: Command not found"

sometarget:
    somevariable = somevalue

Full example:

CXXFLAGS = -I/usr/include/test -shared -fPIC

OBJ = main.o Server.o

blabla : $(OBJ) 
ifeq ($(argsexec),true) 
    # Creates an executable
    CXXFLAGS = -I/usr/include/test
    $(CXX) -o blabla $(OBJ) $(CXXFLAGS) 
else 
    # Creates a library
    DESTDIR = /home/pc
    $(CXX) -o blabla $(OBJ) $(CXXFLAGS) 
    ./bn.sh
endif
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
614 views
Welcome To Ask or Share your Answers For Others

1 Answer

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!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...