开发者

makefile can not detect missing prerequisites file

I have a makefile that takes care of copying file from folder A to folder B.

here I have simple makefile to describe the problem I encounter. ex:

all: a.txt b.txt

%.txt: test/%.txt
        cp -a $< $@

when I invoke make command:

make

It copy 2 txt files开发者_JAVA技巧.

after that, I remove a.txt in test folder and run make again

rm test/a.txt
make

I suppose make will detect unavailable prerequisites but it output:

make: Nothing to be done for `all'.

How can I have error output for this situation?

thanks!!


You are using a pattern rule, which Make ignores if the prerequisites are not available. Try this:

TEXTS := a.txt b.txt

all: $(TEXTS)

$(TEXTS): % : test/%
        cp -a $< $@
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜