amorimluc
amorimluc

Reputation: 1719

Why does my makefile variable not work when using the "define" directive?

I'm using GNU Make 3.81. The following makefile works correctly:

name=lucas

all: test

.PHONY: test
test: 
    echo $(name) # outputs variable correctly

But when I try defining the variable using the "define" directive it stops working:

define name =
lucas
endef

all: test

.PHONY: test
test: 
    echo $(name)

Why doesn't this second version work? Thanks.

EDIT: Found this related thread. Looks like it's a version thing. The = sign is recognized in define statements only since version 3.82 apparently.

Upvotes: 1

Views: 1542

Answers (2)

amorimluc
amorimluc

Reputation: 1719

Found this related thread. Looks like it's a version thing. The = sign isn't recognized in define statements for versions prior to 3.82 apparently.

Upvotes: 1

OrenIshShalom
OrenIshShalom

Reputation: 7132

I'm pretty sure your test target doesn't have a '\t' before echo $(name). When I copied and pasted your makefile code I saw that, and I don't think it's the markdown language because I checked other questions with makefiles and it worked there.

Upvotes: 1

Related Questions