In Makefile assign path variable dependent if path exists II

半城伤御伤魂 提交于 2019-12-11 14:18:17

问题


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 )

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.

Sometimes INFORMIXDIR is already set in shell environment, so it would be nice to consider this too.


回答1:


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 )



来源:https://stackoverflow.com/questions/4942919/in-makefile-assign-path-variable-dependent-if-path-exists-ii

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!