Makefile 出现./simv up to date.如何解决?

如下图:MAKEFIEL执行好run时,不能执行,提示为:./simv up to date.

Makefile:

all: clean comp run

comp:

vcs ***********

run:

./simv 

clean:

rm -rf **********************


为什么生成的simv文件不能执行呢?

但是单独的手动执行simv是可以出现正确的结果的。说明是脚本的问题。

根据提示:simv up to date 查找下问题所在。

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

最近更新一个项目的makefile文件,在添加一个makefile target的时候,发现总是出现“is up to date”的提示,书写语法无任何不妥,始终找不到原因,最后google了下,找到了解决方案。


在stackoverflow上,有人给出的问题原因如下:

Your have directories with the same name as your targets.

Since your targets don't depend on anything, they'll always be considered up to date.


可见这是makefile target和dir名字冲突造成的,解决方法则是借助.PHONY。


在GNU的官网上,是这么解释的:

[plain]  view plain  copy
  1. A phony target is one that is not really the name of a file; rather it is just a name for a recipe to be executed when you make an explicit request. There are two reasons to use a phony target: to avoid a conflict with a file of the same name, and to improve performance.  
  2.   
  3. If you write a rule whose recipe will not create the target file, the recipe will be executed every time the target comes up for remaking.   


出处: http://www.gnu.org/software/make/manual/html_node/Phony-Targets.html


不难看出,GNU默认makefile target是一个文件,因此他会先检测同级目录下是否已存在这个文件,如果存在,则会abort掉make 进程,但目标不是文件的话,则会出现up to date的情况,这种情况需要.PHONY来避免问题的出现,phony的意思是“赝品”,在这里可以形象的理解成“不是文件”。

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

找到一大牛的解释。


从中看,说明是:有名字的冲突!

赶快看下:原来,在改写以前的脚本时,在同级目录下,留下了run没有删除。

删除掉run发现,可以按照正确的方式执行。

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值