Learning GNU Make Functions with Arithmetic

This article shows you how you can evaluate arithmetic expressions using GNU make, and even includes an implementation of a reverse polish notation calculator. Not only did the author spend the time to come up with this wild hack, but then he wrote an article about it!

GNU Make has no built-in arithmetic capability. In this article I present a collection of GNU Make macros that implement functions for addition, subtraction, multiplication, and division of integers. Functions are also provided for integer comparisons such as “greater than” and “not equal.” These macros are implemented entirely using GNU Make’s built-in string manipulation functions.

Leave a Reply