+ -
当前位置:首页 → 问答吧 → [原创]Ubuntu 命令行基础入门教程

[原创]Ubuntu 命令行基础入门教程

时间: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

你加上 code 吧,tab 都被吃掉了

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

好长哦。
mark一下。
有空回来看。

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

MaskRay 写道:
你加上 code 吧,tab 都被吃掉了

OKay

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