I'm using Makefiles for a Python project. There are some Python configuration variables that I need to include in every Makefile, and the Makefiles may reside in various subdirectories within the project's root (though not more than one level deep).
In the root of the project, I created a Makefile.inc with, for example, the following contents:
define PYSCRIPT
from lib.custommodule import VAR1
print(VAR1)
endef
VAR1 := $(shell python -c '$(PYSCRIPT)')
'custommodule' lives inside a Python lib directory root of the project, and all Makefiles at the top-level that include Makefile.inc execute without errors.
In 'subdirectory/Makefile', I have:
include ../Makefile.inc
echo $(VAR1)
When I cd subdirectory && make, I receive the error:
ImportError: No module named custommodule
I've tried prepending the Python path in 'Makefile.inc' (in the define PYSCRIPT block) to include the parent directory, thinking that 'subdirectory/Makefile' was executing '../Makefile.inc' in it's own path versus its parent path, but that didn't work either.
Am I missing something that's preventing this from working? Or is there a better way of achieving what I'm attempting to?