I’m trying to write a makefile to package up some PHP scripts. I would also like it to check for syntax errors (using the built in php lint tool) before building the final zip file, to prevent any accidental errors slipping in.
So far I have
all: dist
clean:
rm -f output.zip
dist: clean
for i in `find . -name "*.php"`; do php -l $$i; done
zip -r output.zip src -x "*/.*" "*/tests*"
This works, but if there is a PHP error I would like it to break and not continue building the zip file (for obvious reasons). Currently they may just get lost in the pages of output from successful lint runs and the zip file.
Am I going about this the right way? Should I be using a make loop rather than a shell loop? How to you get make to abort on shell command errors?
You can do something like this: