GNU make - making one task do another task as well

35 views Asked by At

Here is my makefile:

z : a
    echo "REDOING Z" ; touch z

a : b b2
    touch a
    touch a2
    touch z # should disable z but doesn't

b : c c2
    touch b
    touch b2

When I do make a, z is touched twice, I want it to only be touched once, how do I do that?

1

There are 1 answers

3
Maxim Egorushkin On

The targets and recipes are in disconnect here: the recipes should only produce its targets, not other targets. E.g.:

z : a
    touch z

a : b b2
    touch a

b : c c2
    touch b

# add rules for b2, c and c2