内核模块makefile中的SUBDIRS变量

4

Consider the following makefile:

CUR = $(shell uname -r) 
DIR = /lib/modules/$(CUR)/build 
PWD = $(shell pwd) 
obj-m   := m1.o m2.o 
default: 
        $(MAKE) -C $(DIR) SUBDIRS=$(PWD) modules 
clean: 
        @rm -f *.o .*.cmd .*.flags *.mod.c *.order 
        @rm -f .*.*.cmd *~ *.*~ TODO.* 
        @rm -fR .tmp* 
        @rm -rf .tmp_versions 
disclean: clean 
        @rm *.ko *.symvers

在内核模块的makefile中,SUBDIRS变量的含义是什么?
1个回答

3

内核文档中在Documentation/kbuild/modules.txt中提到:

链接:https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/Documentation/kbuild/modules.txt?id=refs/tags/v2.6.34.14

与M=.相同。为了向后兼容性,SUBDIRS=语法被保留。

并且在Documentation/kbuild/kbuild.txt中也有提到:

链接:https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/Documentation/kbuild/kbuild.txt?id=refs/tags/v2.6.34.14

KBUILD_EXTMOD
--------------------------------------------------
Set the directory to look for the kernel source when building external
modules.
The directory can be specified in several ways:
1) Use "M=..." on the command line
2) Environmnet variable KBUILD_EXTMOD
3) Environmnet variable SUBDIRS
The possibilities are listed in the order they take precedence.
Using "M=..." will always override the others.

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接