<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-us"><generator uri="https://gohugo.io/" version="0.101.0">Hugo</generator><title type="html">makefile on A Scripter's Notes</title><subtitle type="html">Emacs, scripting and anything text oriented.</subtitle><link href="https://scripter.co/categories/makefile/" rel="alternate" type="text/html" title="HTML"/><link href="https://scripter.co/categories/makefile/index.xml" rel="alternate" type="application/rss+xml" title="RSS"/><link href="https://scripter.co/categories/makefile/atom.xml" rel="self" type="application/atom+xml" title="Atom"/><link href="https://scripter.co/categories/makefile/jf2feed.json" rel="alternate" type="application/jf2feed+json" title="jf2feed"/><updated>2026-04-22T08:24:57-04:00</updated><author><name>Kaushal Modi</name><email>kaushal.modi@gmail.com</email></author><id>https://scripter.co/categories/makefile/</id><entry><title type="html">How to do math in Makefile?</title><link href="https://scripter.co/how-to-do-math-in-makefile/?utm_source=atom_feed" rel="alternate" type="text/html"/><id>https://scripter.co/how-to-do-math-in-makefile/</id><published>2014-03-05T13:38:08-05:00</published><updated>2014-03-05T13:38:08-05:00</updated><content type="html"><![CDATA[<p>If you have <code>bc</code> installed, you can use it to do math operations on
variables in a <em>Makefile</em>.</p>
<p>For me, it was installed in <code>/usr/bin/bc</code>.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-makefile" data-lang="makefile"><span class="line"><span class="cl"><span class="nv">VAR_A</span> <span class="o">=</span> <span class="m">10</span>
</span></span><span class="line"><span class="cl"><span class="nv">VAR_B</span> <span class="o">=</span> <span class="m">11</span>
</span></span><span class="line"><span class="cl"><span class="nv">VAR_C</span> <span class="o">=</span> <span class="k">$(</span>shell <span class="nb">echo</span> <span class="k">$(</span>VAR_A<span class="k">)</span><span class="se">\*</span><span class="k">$(</span>VAR_B<span class="k">)</span> <span class="p">|</span> bc<span class="k">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="nf">default</span><span class="o">:</span>
</span></span><span class="line"><span class="cl">	<span class="nb">echo</span> <span class="k">$(</span>VAR_C<span class="k">)</span>
</span></span></code></pre></div>]]></content><category scheme="https://scripter.co/categories/makefile" term="makefile" label="makefile"/><category scheme="https://scripter.co/categories/bc" term="bc" label="bc"/></entry></feed>