如下图: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的官网上,是这么解释的:
不难看出,GNU默认makefile target是一个文件,因此他会先检测同级目录下是否已存在这个文件,如果存在,则会abort掉make 进程,但目标不是文件的话,则会出现up to date的情况,这种情况需要.PHONY来避免问题的出现,phony的意思是“赝品”,在这里可以形象的理解成“不是文件”。
找到一大牛的解释。
从中看,说明是:有名字的冲突!
赶快看下:原来,在改写以前的脚本时,在同级目录下,留下了run没有删除。
删除掉run发现,可以按照正确的方式执行。