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

phony for targets with variable name using percent sign

I have a makefile that is using %.target. I am wondering how I could add those to .PHONY.

Simplified, this might look like this.

%.build:
    docker build -t $* .

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 :

It’s not exactly clear what you want to do but if what you want is for any command line goal that matches the pattern %.build to be treated as phony you can add this to your makefile:

.PHONY: $(filter %.build,$(MAKECMDGOALS))
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