Reputation: 20547
I have a Makefile like this
bin:
mkdir -p bin
bin/kustomize: bin
curl -fsSL "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash -s bin
When I run make bin/kustomize
it tries to download it, every time, even though it is already there. I would expect that make doesn't want to run that target.
When I remove the dependency to bin
, it works as I expect.
Upvotes: 0
Views: 175
Reputation: 1
Generally, using a directory as a build target, is a bad practice. Best if you use only files as target (or phony targets).
Reason is very simple: any time a new entry is created in the directory, that updates the modification time of the directory. Thus, if you create bin/kustomize
from "bin", then make will always see that the directory is newer as the kustomize
binary in it. Thus, it will always re-create.
Things are yet more worse: if anything creates or deletes a file in "bin", all what you have there, will be re-downloaded again.
I think, the rule what best qualifies your expectation is:
bin/kustomize:
mkdir -v bin && curl ...<long-url>...
Sometimes I have also such a construction:
work/.stamp:
mkdir -v work && touch .stamp
work/anything: work/.stamp
...things...
work/other: work/.stamp
...things...
Upvotes: -1