A Scripter's Notes

Emacs, scripting and anything text oriented.

How to do math in Makefile?

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)

	echo $(VAR_C)


comments powered by Disqus