SILENCE
SILENCE

Reputation: 235

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.

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!!

Upvotes: 3

Views: 359

Answers (1)

Beta
Beta

Reputation: 99164

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 $< $@

Upvotes: 2

Related Questions