Skip to content

Instantly share code, notes, and snippets.

@wilem
Created April 16, 2014 07:30
Show Gist options
  • Save wilem/10824334 to your computer and use it in GitHub Desktop.
Save wilem/10824334 to your computer and use it in GitHub Desktop.
do math(arithmetic operation) in makefile.
# calculator by call (bash)shell command.
calc=$(shell echo $$\(\($(1)\)\))
foo=$(call calc,3*4)
SZ_1K:=$(call calc,32*32)
SZ_4K:=$(call calc,$(SZ_1K)*4)
SZ_4M:=$(call calc,$(SZ_4K)*$(SZ_1K))
SZ_4G:=$(call calc,$(SZ_4M)*$(SZ_1K))
SZ_8G=$(shell echo $(exp_8g))
SZ_4T=$(shell echo $(exp_4t))
math:
@echo foo is $(foo)
@echo "SZ_1K is:" $(SZ_1K)
@echo "SZ_4K is:" $(SZ_4K)
@echo "SZ_4M is:" $(SZ_4M)
@echo "SZ_4G is:" $(SZ_4G)
@echo "SZ_8G is:" $(SZ_8G)
@echo "SZ_4T is:" $(SZ_4T)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment