问题
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