开发者

In Makefile assign path variable dependent if path exists

I develop my c++ app alternately on debian and ubunt开发者_StackOverflow中文版u and the library root dir of informix database is different on both distributions.

What's a nice way of handling it in Makefile so i don't have to change it manually each time? I thought of just testing on existance of the directory so it's more general then checking uname or lsb-release or hostname.

And how is the syntax for assigning in a condition? I get the "missing seperator" error on try#2

// prepare
INFORMIXDIR_DEB=/usr/informix
INFORMIXDIR_UBU=/opt/IBM/informix 

// tried #1
$(INFORMIXDIR_DEB):  
        if [ -d $(INFORMIXDIR_DEB) ]; then INFORMIXDIR=$INFORMIXDIR_DEB; fi;

// tried #2
$(INFORMIXDIR_DEB):  
       INFORMIXDIR=$(INFORMIXDIR_DEB)

// tried #3
if [ -d $(INFORMIXDIR_UBU) ] ; 
    then INFORMIXDIR=$INFORMIXDIR_UBU;
fi;


But if you use gnu make, you can write shell command to test whatever you want, assign the result to the variable and play with ifeq?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜