![](/img/trans.png)
[英]How can I generate code coverage for Swift packages on Linux or OS X?
[英]How do I code a Makefile that can tell the difference between Intel OS X and Linux?
如何将条件写入 GNU make
Makefile,它可以识别架构(在这种情况下是英特尔 OS X 与 Linux),以便我可以适当地设置标志,而不需要最终用户在运行 656EF5D186C4AE3 时指定make -f
?
编辑
我应该指定我从包含 shell 命令的ifeq
语句中得到 makefile 错误,如果此条件位于目标之外:
'commands commence before first target. Stop.'
您应该能够检查其中一个uname
变体的 output,然后根据此选择使用makefile
的不同操作。
运行man uname
了解详细信息。
关于如何从 GNU make 使用它,您可以将信息从shell
function 获取到变量中,然后在该变量上使用ifeq
:
platform=$(shell uname -o)
ifeq ($(platform),Cygwin)
defrule:
echo I am running in Cygwin.
else
defrule:
echo I am running elsewhere.
endif
uname
是你的朋友。
$ uname -o
GNU/Linux
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.