1
我想通过执行一个Makefile来创建多个内核模块。在不同的子目录中创建/构建多个内核模块
我有以下目录和文件:
- 顶级目录:
- subdir0:
- module0.c
- 的Makefile
- subdir1:
- module1.c
- 的Makefile
- subdir2:
- module2.c
- 的Makefile
- Makefile文件(我想执行这个)
- subdir0:
我想只执行顶级目录中的Makefile,并且应该执行所有子目录Makefile。我想为每个子目录获取一个内核模块。
这是我目前的设置,但它不起作用。如果我在子目录中执行make,它会生成正确的* .ko文件。但是如果我执行最高级别的Makefile,它只会生成Module.symvers和modules.order,并且输出看起来像每个Makefile都会被执行,但是在子目录内没有任何东西被创建。
我顶层Makefile文件有如下内容:
TARGETS := all clean
SUBDIRS := subdir0 subdir1 subdir2
.PHONY: $(TARGETS) $(SUBDIRS)
$(TARGETS): $(SUBDIRS)
$(SUBDIRS):
$(MAKE) -C [email protected] $(MAKECMDGOALS)
我子目录Makefile中有以下代码:
obj-m += module0.o
all:
$(MAKE) -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
$(MAKE) -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
我会很高兴,如果有人可以帮助我。
感谢, 米莎
Make toplevel * Makefile * similar,但使用'obj-y + = subdir0 /'等 – 0andriy
谢谢,我会试试看:) – p0kR
@ 0andriy这正是我想要的,非常感谢。 如果你已经写了这个答案,我已经接受了:) – p0kR