makefile递归调用的优先级是多少



拥有此生成文件:

# If KERNELRELEASE is defined, we've been invoked from the
# kernel build system and can use its language.
ifneq ($(KERNELRELEASE),)
obj-m := module.o
# Otherwise we were called directly from the command
# line; invoke the kernel build system.
else
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
default:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
endif

我只有一个问题。此生成文件被读取2次。第一次,它设置了$KERNELDIRPWD——else分支。第二次阅读时,我提出了一个问题——它只设置$obj-m,但如何设置?当"第二个"读取时,脚本应该调用源目录中的Makefile(用-C选项调用(,因此无法从我的当前目录中设置obj-m变量(前一个,它通过-C更改为源目录(。还是$(MAKE)的第二次调用继承了变量?

注意传递给子制造商的选项:M=$(PWD)

这意味着子make知道makefile所在的工作目录(在其$(M)变量中(,然后可以执行类似include $(M)/Makefile的操作来设置obj-m变量。

最新更新