I'm writing kernel modules to do unit test for a project. Due to I need to include source files inside the project, I expect to use absolute path to those files. Which would make my Makefile like this
foo-objs := dir1/src1.o dir1/src2.o
foo-objs += dir2/src3.o src4.o
foo-objs := $(addprefix $(PROJECT_ROOT),$(foo-objs))
...
all:
$(MAKE) -C /lib/modules/"$(shell uname -r)"/build M=$(PWD)
$(PROJECT_ROOT) would be a environment variable recording absolute path of the project root.
By this way, I believe is much clearer and easier to maintain many unit tests.
But when I do make
, kernel Makefile try to compile $(PWD)/$(PROJECT_ROOT)/src1.o, which of course does not exist. It seems to treat all object file as relative path.
As a result, I wonder that if there is a way to make kernel Makefile for modules to recognize absolute path, thanks a lot.