相关疑难解决方法(0)

在单独的对象目录中构建树外的Linux内核模块

我正在面对Linux内核构建系统(Kbuild,内核≥2.6.28)以及更大项目的目录结构和构建系统.我们的项目包含一个树外的Linux内核模块,我们的目录结构如下所示(显然是简化的):

checkout/src/common/*.c           source files (common to Linux and other platforms)
checkout/src/linux-driver/*.c     source files (for the Linux kernel driver)
checkout/build/linux/Kbuild       Kbuild
tmp/linux-2.6.xx/                 where the Linux kernel is unpacked and configured
output/linux-arm-debug/           where object files must end up
Run Code Online (Sandbox Code Playgroud)

构建过程不得修改任何内容checkout,并且构建模块不得修改任何内容tmp/linux-2.6.xx.所有输出文件必须最终output/linux-arm-debug(或在构建时选择任何体系结构和调试变体).

我已经阅读kbuild/modules.txt,并开始写我的Kbuild文件:

MOD_OUTPUT_DIR = ../../../output/linux-$(ARCH)-$(DEBUG)
obj-m += $(MOD_OUTPUT_DIR)/foo_mod.o
$(MOD_OUTPUT_DIR)/our_module-objs := $(MOD_OUTPUT_DIR)/foo_common.o $(MOD_OUTPUT_DIR)/foo_linux.o
Run Code Online (Sandbox Code Playgroud)

这会将目标文件存储在与Kbuild生命不同的目录中.现在我如何指定foo_common.o需要编译…/checkout/src/common/foo_common.cfoo_linux.o从中编译…/checkout/src/linux-driver/foo_linux.c

makefile linux-kernel kbuild

9
推荐指数
2
解决办法
2万
查看次数

标签 统计

kbuild ×1

linux-kernel ×1

makefile ×1