在Makefile中分配路径变量,取决于路径是否存在 [英] In Makefile assign path variable dependent if path exists
问题描述
我在debian和ubuntu上交替开发了我的c ++应用程序,两个发行版上的notifyix数据库的库根目录都不同。
I develop my c++ app alternately on debian and ubuntu and the library root dir of informix database is different on both distributions.
在其中处理它的一种好方法是Makefile,所以我不必每次都手动更改它?
我想到了只是测试目录的存在性,因此更普遍的是检查uname或lsb-release或主机名。
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.
分配的语法如何有病吗我在try#2上收到缺少分隔符错误
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;
推荐答案
但是,如果您使用gnu make,则可以编写shell命令以测试您想要的任何内容,将结果分配给变量并使用 ifeq
?
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
?
这篇关于在Makefile中分配路径变量,取决于路径是否存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!