问题描述
我只是被帮助了在Makefile中分配路径变量取决于路径存在,并且如果条件为true,则var的设置可以正常工作.
I just was helped In Makefile assign path variable dependent if path exists and setting of the var works fine if the condition is true.
INFORMIXDIR=$(shell test -d /opt/IBM/informix && echo /opt/IBM/informix )
所以我连续做了两个可能的条件
So I did both possible conditions in a row
INFORMIXDIR=$(shell test -d /opt/IBM/informix && echo /opt/IBM/informix )
INFORMIXDIR=$(shell test -d /usr/informix && echo /usr/informix )
但是如果条件为false,则shell命令返回的类型为null,因此将其重新设置,因此在第一个条件为true的系统上将无法使用.
but the shell command returns kind of null if the condition is false so it's unset again, so it won't work on the system where the first condition is true.
有时候,INFORMIXDIR已经在shell环境中设置了,因此也可以考虑一下.
Sometimes INFORMIXDIR is already set in shell environment, so it would be nice to consider this too.
推荐答案
可以更改为$(shell test -d /opt/IBM/informix && echo /opt/IBM/informix || echo )
吗?或使用一些后备值并在以下时间进行检查:$(shell test -d /opt/IBM/informix && echo /opt/IBM/informix || echo notset )
Could be changed to $(shell test -d /opt/IBM/informix && echo /opt/IBM/informix || echo )
? Or use some fallback value and check for it after: $(shell test -d /opt/IBM/informix && echo /opt/IBM/informix || echo notset )
这篇关于在Makefile中分配路径变量,取决于路径是否存在II的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!