I am using Makefiles.
However, there is a command (zsh script) I want executed before any targets is executed. How do I do this?
Thanks!
There is a solution without modifying your existing Makefile
(main difference with the accepted answer). Just create a makefile
containing:
.PHONY: all
all:
pre-script
@$(MAKE) -f Makefile --no-print-directory $(MAKECMDGOALS) MAKE='$(MAKE) -f Makefile'
post-script
$(MAKECMDGOALS): all ;
The only drawback is that the pre- and post- scripts will always be run, even if there is nothing else to do. But they will not be run if you invoke make with one of the --dry-run
options (other difference with the accepted answer).