开发者

Conditional assignment of SHELL variable in Makefile

开发者 https://www.devze.com 2023-02-22 18:19 出处:网络
I have a Makefile variables VAR_1 and VAR_2. I need to assign the value of $($VAR1)_VAR2) to FINAL_VAR, ONLY if $($VAR1)_VAR2) is NOT EQUAL TO /dev/null. If $($VAR1)_VAR2) is EQUAL TO /dev/null then

I have a Makefile variables VAR_1 and VAR_2.

I need to assign the value of $($VAR1)_VAR2) to FINAL_VAR, ONLY if $($VAR1)_VAR2) is NOT EQUAL TO /dev/null. If $($VAR1)_VAR2) is EQUAL TO /dev/null then FINAL_VAR should be assigned some default value say "/usr/tmp"开发者_运维问答


In GNU make, you can use the ifneq directive:

ifneq ("$($(VAR1)_VAR2)","/dev/null")
    FINAL_VAR=$($(VAR1)_VAR2)
else
    FINAL_VAR=/usr/tmp
endif
0

精彩评论

暂无评论...
验证码 换一张
取 消