Emacs, scripting and anything text oriented.

How to do math in Makefile?

Kaushal Modi

If you have bc installed, you can use it to do math operations on variables in a Makefile.

For me, it was installed in /usr/bin/bc.

VAR_A = 10
VAR_B = 11
VAR_C = $(shell echo $(VAR_A)\*$(VAR_B) | bc)

default:
	echo $(VAR_C)