How do I perform arithmetic in a makefile?

后端 未结 8 1026
终归单人心
终归单人心 2020-12-01 10:12

Is it possible to perform some operations on variables in a makefile? For instance, defining

JPI=4
JPJ=2

Is it possible to define in the sa

8条回答
  •  悲&欢浪女
    2020-12-01 10:51

    It's clumsy (or brilliant, depending on your perspective), but you can do arithmetic directly in GNU make. See Learning GNU Make Functions with Arithmetic. Be aware though that this method doesn't scale well. It will work wonderfully for small numbers as you have shown in your question, but it doesn't do well when you're working with numbers with a large magnitude (greater than 10,000,000).

提交回复
热议问题