I have a kernel module (often compiled using CONFIG_MYMODULE=m) which is set-up like the following:
mymodule/Makefile
../foo/Makefile
../foo/component1/Makefile
../foo/component2/Makefile
Currently what's being used is:
mymodule/Makefile:
mymodule-y += mod1file.o mod2file.o mod3file.o #etc
include ../foo/Makefile
mymodule-y += $(FOO_FILES)
obj-$(CONFIG_MYMODULE) += mymodule.o
../foo/Makefile:
include component1/Makefile
include component2/Makefile
and inside each component folder I have:
../foo/component1/Makefile
FOO_FILES += foo1file.o foo2file.o foo3file.o #etc
This definitely doesn't appear to be the proper way of going about this, as everything is included directly into the mymodule/Makefile and thus can't set folder-specific gcc flags.
What is the proper way of organizing this while still building everything into a single kernel module? I've read the kbuild/modules.txt documentation, but I haven't seen anything which relates directly, and I can't quite figure out how to go about this or if it's indeed possible.
Thanks
I've tried the following, but I get the following error:
"ld: cannot find foo: File format not recognized"
mymodule/Makefile:
mymodule-y += mod1file.o mod2file.o mod3file.o #etc
mymodule-y += ../foo/
obj-$(CONFIG_MYMODULE) += mymodule.o
../foo/Makefile
ccflags-y := -I$(src)/component1/ -I$(src)/component2/
foo-y := foo1file.o foo2file.o foo3file.o
foo-y += component1
foo-y += component2
../foo/component1/Makefile
component1-y := component1file.o component1file.o
../foo/component2/Makefile
component2-y := component2file.o component2file.o
If I change this to instead use obj-y += ../foo rather than mymodule-y += ../foo it at least enters the folder, but doesn't seem to attempt to complile, and I want this to be all a part of a single kernel module.