从多个源文件构建内核模块,其中一个与模块同名 [英] Building a kernel module from several source files which one of them has the same name as the module
本文介绍了从多个源文件构建内核模块,其中一个与模块同名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以从多个源文件构建一个内核模块,其中一个与模块同名?
Is it possible to build a kernel module from several source files which one of them has the same name as the module?
例如:我想用以下源文件构建mymodule.ko":
mymodule.c
mymodule_func.c
For example:
I want to build "mymodule.ko" with the following source files:
mymodule.c
mymodule_func.c
此生成文件不起作用:
#Makefile
obj-m += mymodule.o
mymodule-objs := mymodule.o mymodule_func.o
谢谢
推荐答案
我找到了一个解决方案,我把我的源文件放在一个子文件夹中:
I found a solution, I placed my source file in a sub folder:
生成文件
src/mymodule.c
src/mymodule_func.c
Makefile
src/mymodule.c
src/mymodule_func.c
#Makefile
obj-m += mymodule.o
mymodule-objs := ./src/mymodule.o ./src/mymodule_func.o
all:
make -C $(KERNEL_PATH) M=$(PWD) modules
clean:
make -C $(KERNEL_PATH) M=$(PWD) clean
这篇关于从多个源文件构建内核模块,其中一个与模块同名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文