I ran into this useful tip that if you\'re working on files a lot and you want them to build automatically you run:
watch make
And it re-runs make every couple s
Here is a one-liner:
while true; do make -q || make; sleep 0.5; done
Using make -q || make
instead of just make
will only run the build if there is something to be done and will not output any messages otherwise.
You can add this as a rule to your project's Makefile:
watch:
while true; do $(MAKE) -q || $(MAKE); sleep 0.5; done
And then use make watch
to invoke it.
This technique will prevent Make from filling a terminal with "make: Nothing to be done for TARGET" messages.
It also does not retain a bunch of open file descriptors like some file-watcher solutions, which can lead to ulimit errors.