I have a makefile containing an include statement. I have no control over the content of the included makefile. Still, I want to be able to add some pre-processing steps before "some" (not all) of the targets. Consider the following example:
install:
@echo "install target"
include othermakefile.mk
othermakefile.mk contains install target as well. If I run this script, make gives a warning and ignores the first install target.
Nothing easier:
install: pre_install
.PHONY: pre_install
pre_install:
do preinstallation things
include othermakefile.mk
EDIT:
If you want to run pre_install before install or any of its preqs, here is a way. It's crude and ugly, but it does the job:
install: pre_install
$(MAKE) -f othermakefile.mk $@
.PHONY: pre_install
pre_install:
do preinstallation things
Note that this will not necessarily rebuild all prerequisites of install, so some of them may remain in their old states and not reflect the effects of pre_install. If that's not good enough, and you want pre_install before all of the other prerequisites, you can add an option flag:
install: pre_install
$(MAKE) --always-make -f othermakefile.mk $@
Now Make will assume that all targets are out of date, and rebuild from the ground up (after pre_install).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With