Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

make runs target even though file already exists

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Your bin/ is a directory, not a plain file.

The GNU make dependency in your rule

bin/kustomize: bin

says that file bin/kustomize should be reconstructed every time the modification time of bin/ is changing.

But overwriting a file entry (technically associating a name to an an inode) inside a directory is changing the directory modification time.

As commented by HolyBlackCat you want an order-only prerequisite

Should you want the building rules to fire when a content is changed (and not just using modification time), consider using other builder software, maybe omake

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading