Gilles 'SO- stop being evil'
9
makefile
linux-kernel
kbuild
我正在面对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
构建过程不得修改任何内容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
这会将目标文件存储在与Kbuild生命不同的目录中.现在我如何指定foo_common.o需要编译…/checkout/src/common/foo_common.c和foo_linux.o从中编译…/checkout/src/linux-driver/foo_linux.c?