【发布时间】:2014-10-01 12:13:24
【问题描述】:
我有 2 个系统,一个是 rhel4,另一个是 rhel6。 在编译时我想区分并进行相应的编译。
我的方法:
在 rhel5 机器上
-bash-4.1$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.5
在 rhel4 机器上
-bash-3.00$ cat /etc/redhat-release
Red Hat Enterprise Linux AS release 4
所以我想用这样的东西-
OSVERSION = cat /etc/redhat-release | cut -d "." -f 1 | cut -d " " -f 7
ifeq(OSVERSION,4)
XXXXXXXXXXX
else
YYYYYYYYYYY
endif
有没有更好的方法来做到这一点? 任何默认包含此信息的标志,我可以使用它吗?
【问题讨论】:
-
你的代码能用吗?
-
这只是我的想法。
-
ifeq ($(shell cat /etc/redhat-release | cut -d "." -f 1 | cut -d " " -f 7),6) CFLAGS += -DRhel6=1否则 CFLAGS += -DRhel6=0 endif