Performing greater-than less-than calculations in a Makefile

前端 未结 4 440
花落未央
花落未央 2021-01-11 09:40

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 ru         


        
4条回答
  •  死守一世寂寞
    2021-01-11 09:58

    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
    

    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.

提交回复
热议问题