<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>makefile on
A Scripter's Notes</title><link>https://scripter.co/categories/makefile/</link><description>Recent content in makefile
on A Scripter's Notes</description><language>en-us</language><managingEditor>kaushal.modi@gmail.com (Kaushal Modi)</managingEditor><webMaster>kaushal.modi@gmail.com (Kaushal Modi)</webMaster><lastBuildDate>Wed, 22 Apr 2026 08:24:58 -0400</lastBuildDate><generator>Hugo -- gohugo.io</generator><docs>https://validator.w3.org/feed/docs/rss2.html</docs><atom:link href="https://scripter.co/categories/makefile/index.xml" rel="self" type="application/rss+xml"/><item><title>How to do math in Makefile?</title><link>https://scripter.co/how-to-do-math-in-makefile/</link><description>&lt;p>If you have &lt;code>bc&lt;/code> installed, you can use it to do math operations on
variables in a &lt;em>Makefile&lt;/em>.&lt;/p>
&lt;p>For me, it was installed in &lt;code>/usr/bin/bc&lt;/code>.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-makefile" data-lang="makefile">&lt;span class="line">&lt;span class="cl">&lt;span class="nv">VAR_A&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="m">10&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="nv">VAR_B&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="m">11&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="nv">VAR_C&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="k">$(&lt;/span>shell &lt;span class="nb">echo&lt;/span> &lt;span class="k">$(&lt;/span>VAR_A&lt;span class="k">)&lt;/span>&lt;span class="se">\*&lt;/span>&lt;span class="k">$(&lt;/span>VAR_B&lt;span class="k">)&lt;/span> &lt;span class="p">|&lt;/span> bc&lt;span class="k">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="nf">default&lt;/span>&lt;span class="o">:&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nb">echo&lt;/span> &lt;span class="k">$(&lt;/span>VAR_C&lt;span class="k">)&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div></description><category domain="https://scripter.co/categories/makefile">makefile</category><category domain="https://scripter.co/categories/bc">bc</category><guid>https://scripter.co/how-to-do-math-in-makefile/</guid><pubDate>Wed, 05 Mar 2014 13:38:08 -0500</pubDate></item></channel></rss>