+ -
当前位置:首页 → 问答吧 → 【欢迎加入】 Linux技术交流群 26507421

【欢迎加入】 Linux技术交流群 26507421

时间:2011-06-29

来源:互联网

当前目录中的makefile,有一段如下:
###########################
.PHONY:sample
sample:
make -C $(SAMPLE_DIR)
sample_clean:
make -C $(SAMPLE_DIR) clean
############################
在子目录sample中,子makefile,有一段内容如下:
############################
target:=$(firstword $(MAKECMDGOALS))

.PHONY: $(target)

ifeq ($(target), all)
target=./
endif

ifeq ($(target), clean)
target=
endif
$(target):
echo $(target)
echo $(MAKECMDGOALS)
make -C $(MAKECMDGOALS)
all:
make -C xxxxx
make -C xxxxx
clean:
make -C xxxxx clean
make -C xxxxx clean
##################################
///////////////////////////////////////////////////////
当我在当前目录下,运行make sample时,执行的是如下的规则
all:
make -C xxxxx
make -C xxxxx
当我在当前目录下,运行make sample_clean时,执行的是如下的规则
clean:
make -C xxxxx clean
make -C xxxxx clean

我有几个疑惑点,
1)在执行make target时,target值是sample吗?
2)感觉下面的规则没有用
.PHONY: $(target)

ifeq ($(target), all)
target=./
endif

ifeq ($(target), clean)
target=
endif
$(target):
echo $(target)
echo $(MAKECMDGOALS)
make -C $(MAKECMDGOALS)
还是我理解的有问题。

作者: tosail2010   发布时间: 2011-06-29

热门下载

更多