Reputation: 2655
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?
Upvotes: 1
Views: 311
Reputation: 18657
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"
Upvotes: 3
Reputation: 392833
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
Upvotes: 0