squarewav
squarewav

Reputation: 423

make simple file copying yields "Nothing to be done"

I'm trying to simply copy files that are modified using make. Here is the entire Makefile:

FILES = www/foo.html www/bar.html www/zap.php

all: $(FILES)

$(FILES): src/$@
    cp src/$@ $@

clean:
    rm $(FILES)

After modifying a file src/www/bar.html, make does not copy the file:

$ make
make: Nothing to be done for 'all'.
$ make www/bar.html
make: 'www/bar.html' is up to date.

Why does make not see the prerequisite has been modified and that the file needs to be copied?

If I run make clean, make it works (copies all files).

Upvotes: 0

Views: 28

Answers (1)

tripleee
tripleee

Reputation: 189587

src/$@ is not well-defined. You want

$(FILES): %: src/%

which declares a pattern rule, and restricts its scope to the files in $(FILES). (You might want or even need to remove this restriction.)

Upvotes: 1

Related Questions