在Makefile中执行大于小于的计算 [英] Performing greater-than less-than calculations in a Makefile

查看:774
本文介绍了在Makefile中执行大于小于的计算的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Makefile中执行此操作:

I'm trying to do this in a Makefile:

value = 2.0

if ${greaterthan ${value}, 1.50}
-> execute a rule
elseif ${lessthan ${value}, 0.50}
-> execute a rule
endif

想做似乎很普通的事情.最好的方法是什么?

It seems like quite a common thing to want to do. What's the best way of doing this?

推荐答案

类似于此问题,但基本上您可以在Makefile中使用Shell命令.因此,以下内容完全合法:

Similar to this question, but basically you can use shell commands inside a Makefile. So the following is perfectly legal:

foo:
    if [ ${value} -gt 2 ] ; then \
         #Do stuff;\
    fi

编辑一个小的免责声明:IIRC,bash不理解浮点运算.它可以将它们解释为 strings ,但是这可能会使事情变得有些奇怪.确保考虑到这一点.

Edit for a small disclaimer: IIRC, bash doesn't understand floating point arithmetic. It can interpret them as strings, but it might make things a little weird. Make sure you take this into consideration.

这篇关于在Makefile中执行大于小于的计算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆