简体   繁体   中英

Gnu make conditional on environment variable

I have the following in a Makefile:

ifndef MYVAR
$(error "MYVAR is not set")
else
$(warning "MYVAR is set to [$(MYVAR)]")
ifeq ($(MYVAR),"abc")
$(error "Value is known.")
else
$(error "Not known.")
endif
endif

I set MYVAR when calling make:

MYVAR=abc make

I would have expected to see "Value is known." but I get the following:

Makefile:4: "MYVAR is set to [abc]"
Makefile:8: *** "Not known.".  Stop.

Could someone please enlighten me on what is wrong with my ifeq statement?

Question answered by @melpomene in the comments. As so often before, a quotation error.

ifeq ($(MYVAR),abc) or MYVAR='"abc"' make

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM