Your a b c:
rule tells Make that this is how to build any of these targets, not how to build all of them. Make is not smart enough to analyze the commands and deduce that running the rule once will build all three. Make knows (from the output
rule) that it must rebuild a
, b
and c
, so that's what it does. It runs the first rule once for a
, once for b
and once for c
.
If you want to rebuild them individually, do this:
a b c:
echo "Creating $@"
touch $@
If you want to rebuild them all at once, do something like this:
.PHONY: things
things:
echo "Creating a b c"
touch a b c
output: things
cat a b c > output
or better still:
THINGS = a b c
.PHONY: things
things:
echo "Creating $(THINGS)"
touch $(THINGS)
output: things
cat $(THINGS) > output