Reputation: 59287
What's the easiest way to make a target depend on a file to be created, inside its recipe? I could use some shell magic:
target:
[ -e file ] || touch file
But ideally, I'd like to leave the test with make. Is it possible? The target commands should only run if the file doesn't exist yet.
Upvotes: 0
Views: 625
Reputation: 16790
If you give more information about what you're trying to accomplish, we may be able to help you better. Based on what you've said so far, it sounds like regular old make
prerequisites should do the trick for you:
target: file
touch target
file:
touch file
If file
does not exist, it will be created; if it does, the commands for file
will not be executed.
Upvotes: 3