Not it's not necessary. You need a header files that contains function and types declarations. You also kernel tree with Makefiles and Kconfig but without sources. This kernel tree is needed by kbuild - kernel building system.
Absolutely not. You can build a single module without building whole kernel regardless of it's out-of-tree or in-tree module.
How to build kernel module without full kernel source tree?
-
26-06-2023 - |
Question
I would like to build kernel module without kernel source tree.
Instead that, I specified the kernel header directory only.
This reference link tell me it should be workable :
build kernel module w/o source source tree
But some other reference links tell me should build module with full kernel source tree!
My question is :
1. Shall I build kernel module link with full kernel source tree ?
2. Is it necessary to do a full build under kernel source tree before build my single module ?
Solution
OTHER TIPS
No to both questions. You're talking about out-of-tree (or "external") modules.
Here is a tutorial of Building External Modules.
And here is a simple sample of a Makefile.
obj-m += your-module.o
KDIR=/lib/modules/`uname -r`/build
default:
$(MAKE) -C $(KDIR) M=$(PWD) modules
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow