简体   繁体   English

使用单独的输出目录构建树外 linux 内核模块

[英]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.buildscripts/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.

相关问题 在单独的对象目录中构建树外 Linux 内核模块 - Building an out-of-tree Linux kernel module in a separate object directory 构建一个树外的Linux内核模块,它们与导出的符号共享目标文件 - Building an out-of-tree Linux kernel modules which share object files with exported symbols 针对文件系统上的任何内核源代码树编译树外内核模块 - Compiling out-of-tree kernel module against any kernel source tree on the filesystem 针对内核源代码树构建Linux内核模块? - Building Linux Kernel Module against kernel source tree? 如何使用额外的include路径(包括外部头文件,yaml,boost等库文件)构建树外linux模块 - How to build an out-of-tree linux module with an additional include path (includes external header files, librairies like yaml, boost…) 如何理解 Linux 内核模块的“构建单独文件”? - How to understand “Building Separate Files” for a Linux kernel module? 如何使用预构建的内核输出目录构建Linux内核模块? - How to build a linux kernel module against with a prebuilt kernel output directory? 从源代码树构建Linux内核模块 - Build a Linux Kernel Module from a source tree 如何判断是否配置并支持树外构建? - How to tell if configure and make support out-of-tree builds? Linux出树模块构建问题 - Linux out of tree module build issue
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM