watch-make is a script that rebuilds your project only when make
detects it needs a rebuild, for example when source files change.
Features:
- Works with any existing Makefile based project.
- No dependencies apart from
make
.
- Passes any arguments to
make
(such as -C mydir
).
- Silent if there is nothing to build and does not swallow output when there is.
I wrote it in response to this Stack Overflow question.
The source code is hosted on GitHub.
Install it
curl -s https://raw.githubusercontent.com/chr15m/watch-make/master/watch-make > ~/bin/watch-make
chmod 755 ~/bin/watch-make
Full source code
#!/bin/sh
while true;
do
if ! make -q "$@";
then
echo "#-> Starting build: `date`"
make "$@";
echo "#-> Build complete."
fi
sleep 0.5;
done