I have a make file that has two includes like this :
$ cat /src/Makefile
include ../rules.mk
Test:
echo $(DIST_ROOT)
include src.base.mk
Test2:
echo $(DIST_ROOT)
. PHONY: Test Test2
$ cat /rules.mk
DIST_ROOT = $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
$ cat /src/src.base.mk
srcdir = $(DIST_ROOT)/src
The issue is that the output of both is /src
but it should be /
.
How does this happen and how can I fix this?
I found the issue and a fix.
To answer my own question:
When assigning a variable with just equal sign, the variable gets cast everytime its just.
What I needed to add was ":" so it gets casted once and is set as wanted.
Based on this question.