I have the following situation: I want several independent Makefiles to include a single file with all the rules (via include ... directive). So far, so good. However, that central rules file does need to use some other files next to it (shell-scripts and such). To name these other files, it needs to know its own path relative to the make invocation.
What would work is this:
# in the Makefiles
toolsPath := ../../generalStuff
include $(toolsPath)/generalRules.mk
# in the generalRules.mk
foo: ./$(toolsPath)/script
./$(toolsPath)/script foo
Yet, while this would work, it relies on the including Makefiles to honestly tell the general file its own path. And I'm wondering whether there is a way to avoid setting a toolsPath variable.
Is it possible to replace the $(toolsPath) in the included file with something that relies on make itself, rather than the including Makefiles?
I would like to be able to simply write this into the Makefiles:
include ../../generalStuff/generalRules.mk