gpt4 book ai didi

makefile - 内核模块 makefile 中的 SUBDIRS 变量

转载 作者:行者123 更新时间:2023-12-02 19:19:52 26 4
gpt4 key购买 nike

考虑以下 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

SUBDIRS 变量在内核模块 makefile 中的含义是什么?

最佳答案

内核文档在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

Same as M=. The SUBDIRS= syntax is kept for backwards compatibility.

来自 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.

关于makefile - 内核模块 makefile 中的 SUBDIRS 变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21129224/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com