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

why does make not expand stem in dependency when there is no action to take?

I have the following simplified Makefile:

foo-%: dep-%
        @echo in foo $*

bar-%: dep-%

dep-%:
        @echo in dep $*

make dep-aa works. What is interesting is that while make foo-aa works, make bar-aa does not, even though it has the same dependency on dep-%. Why is that? And how do you work around it?

$ make dep-aa
in dep aa
$ make foo-aa
in dep aa
in foo aa
$ make bar-aa
make: *** No rule to make target `bar-aa'.  Stop.

Obviously the simple case above does not add much, but if I have multiple sub-targets, it would be useful, e.g.

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

foo-%: abc-% def-% xyz-%

I figure I can do this somehow with static targets, not sure, but I would like to understand why the above does not work.

Thanks in advance

>Solution :

The documentation is pretty clear:

You can cancel a built-in implicit rule by defining a pattern rule with the same target and prerequisites, but no recipe. For example, the following would cancel the rule that runs the assembler:

%.o : %.s
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