I have make file target like this
foo:
i = 1
@echo $(i)
when I run the make file like this:
$ make foo
In the first case you instruct the make to run a shell command: i = 1.
If you want a variable inside Makefile you should set without leading spaces/tabs.
I assume you use GNU's make and you want to check Recipe Syntax (or similar for other makes):
A variable definition in a “rule context” which is indented by a tab as the first character on the line, will be considered part of a recipe, not a make variable definition, and passed to the shell.