Makefile:当函数被调用时

时间:2016-12-29 07:20:08

标签: makefile

我们准备创建关于ucore.img的目标文件

$(kernel):
    @echo test

$(call create_target,kernel)

# ------------------------------------------------------------------- 
bootblock = $(call totarget,bootblock)

$(bootblock): $(call toobj,boot/bootasm.S) $(call toobj,$(bootfiles)) 
    @echo + ld $@

$(call create_target,bootblock)

# -------------------------------------------------------------------
$(call create_target_host,sign,sign)

# -------------------------------------------------------------------

# create ucore.img
UCOREIMG    := $(call totarget,ucore.img)

$(UCOREIMG): $(kernel) $(bootblock)
    $(V)dd if=/dev/zero of=$@ count=10000

$(call create_target,ucore.img)

但我看不出这些关于call的函数何时会被调用

$(call create_target,kernel)
$(call create_target,bootblock)
$(call create_target,ucore.img)

1 个答案:

答案 0 :(得分:0)

我真的不明白你问的问题。因为这些函数显示为普通的makefile语句,而不是在配方内或正常(递归)赋值语句的右侧,所以它们将在解析makefile时进行扩展。

因此,当make正在读取你的makefile并且它看到了这行:

$(call create_target,kernel)

在尝试解析下一行之前,它会扩展那个call函数引用。您没有向我们展示create_targettotargettoobj的任何实际宏定义是什么,因此我们无法提供有关该扩展的结果可能是什么的任何信息