tohava
tohava

Reputation: 5412

GNU make - making one task do another task as well

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?

Upvotes: 0

Views: 36

Answers (1)

Maxim Egorushkin
Maxim Egorushkin

Reputation: 136306

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

Upvotes: 1

Related Questions