get a default value when variable is unset in make

后端 未结 4 1895
面向向阳花
面向向阳花 2020-12-31 09:10

(edit: question more accurate based on @Michael feedback)

In bash, I often use parameter expansion: the following commands print \"default value\" when

4条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-31 09:35

    If you want to test if a variable has a non-empty value, you can use:

    ifeq ($(VARNAME),)
            VARNAME="default value"
    else
            do_something_else
    endif
    

    For checking if a variable has been defined or not, use ifdef.

    Refer to Syntax of Conditionals in the manual for more.

提交回复
热议问题