Makefile set if variable is empty

前端 未结 6 479
暖寄归人
暖寄归人 2021-01-31 01:37

I want to set a variable if it is empty. I tried in this way:

....
TEST := $(something)
...
TEST ?= $(something else)

The first $(somethi

6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-31 02:01

    In case you need to distinguish if a variable is undefined or just has an empty value, use $(origin VARNAME) function:

    ifeq ($(origin VARNAME),undefined)
    VARNAME := "now it's finally defined"
    endif
    

    Note that VARNAME is not surrounded by $() - you literally give the name of the variable.

提交回复
热议问题