In a Makefile, is there any way of making a rule an implicit dependency of all other rules?
Say, for instance, i wanted a rule run whenever the Makefile is run, regardless of which rule is actually being requested. How would i do that?
2 Answers 2
I have no idea why you'd want to do this, but in GNU make you can do this by -include-ing a .PHONY file:
.PHONY: run-always
-include run-always
run-always:
echo "trololol"
6 Comments
Include a wildcard rule:
%: mydependency
I've tried this, the following makefile is a proof of concept
all: a b
a:
touch $@
%: ccc
#
ccc::
touch ccc
Note the use of
In order to prevent the dependency from building unconditionally each time, you might want to make it an indirect dependency (requirement for the ccc:: rule above, instead of directly on the wildcard rule).
Good luck
2 Comments
code mini-markdown to work.