[英]Building an out-of-tree linux kernel module with separate output directory
I want to build an out of tree kernel module with the output directory being separate from my source directory?我想构建一个树外内核模块,输出目录与我的源目录分开? How would I do this?
我该怎么做? I'm willing to go any route.
我愿意走任何一条路。 I'm okay with minimal changes to the kernel build system, I'm okay with copying source files (however I do not want to rebuild if I haven't made any changes to the source files and this doesn't work if I copy source files normally), and I'm okay with setting a parameter or something.
我对内核构建系统的改动很小,我可以复制源文件(但是,如果我没有对源文件进行任何更改,我不想重建,如果我复制,这将不起作用源文件通常),我可以设置参数或其他东西。
many many people face this problem, including me.很多人都面临这个问题,包括我。 To support build external module at separate output directory.
支持在单独的输出目录中构建外部模块。 I modify the kbuild:
我修改了kbuild:
firstly, modify src variable at scripts/Makefile.build
and scripts/Makefile.clean
首先,在
scripts/Makefile.build
和scripts/Makefile.clean
修改 src 变量
-src := $(obj)
+src := $(if $(KBUILD_EXTMOD_SRC),$(KBUILD_EXTMOD_SRC)$(patsubst $(KBUILD_EXTMOD)%,%,$(obj)),$(obj))
secondly, modify scripts/Makefile.modpost
其次,修改
scripts/Makefile.modpost
-src := $(obj)
+src := $(if $(KBUILD_EXTMOD_SRC),$(KBUILD_EXTMOD_SRC),$(obj))
# Include the module's Makefile to find KBUILD_EXTRA_SYMBOLS
-include $(if $(wildcard $(KBUILD_EXTMOD)/Kbuild), \
- $(KBUILD_EXTMOD)/Kbuild, $(KBUILD_EXTMOD)/Makefile)
+include $(if $(wildcard $(src)/Kbuild), \
+ $(src)/Kbuild, $(src)/Makefile)
then build external module like this:然后像这样构建外部模块:
make -c $(kernel_src) M=$(extmod_outpu_dir) KBUILD_EXTMOD_SRC=$(extmod_src_dir) modules
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.