内核源码广泛使用srctree 这个变量,在顶级Makefile可以找到相关定义
srctree: 顶级内核目录
# Use make M=dir to specify directory of external module to build
# Old syntax make ... SUBDIRS=$PWD is still supported
# Setting the environment variable KBUILD_EXTMOD take precedence
ifdef SUBDIRS
KBUILD_EXTMOD ?= $(SUBDIRS)
endif
ifeq ("$(origin M)", "command line")
KBUILD_EXTMOD := $(M)
endif
ifeq ($(KBUILD_SRC),)
# building in the source tree
srctree := .
else
ifeq ($(KBUILD_SRC)/,$(dir $(CURDIR)))
# building in a subdirectory of the source tree
srctree := ..
else
srctree := $(KBUILD_SRC)
endif
endif

本文详细介绍了Linux内核构建过程中srctree变量的作用,它是用于标识内核源码目录的关键变量。在不同情况下,srctree会根据当前目录和KBUILD_SRC环境变量进行相应设置,确保构建过程能找到正确的源码路径。这对于在源码树内外部编译模块至关重要。
289

被折叠的 条评论
为什么被折叠?



