开发者

makefile can not detect missing prerequisites file

开发者 https://www.devze.com 2023-03-24 07:19 出处:网络
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.

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

精彩评论

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

关注公众号