Is there a smarter alternative to “watch make”?

Using classic gnu make and inotifywait, without interval-based polling:

watch:
    while true; do \
        $(MAKE) $(WATCHMAKE); \
        inotifywait -qre close_write .; \
    done

This way make is triggered on every file write in the current directory tree. You can specify the target by running

make watch WATCHMAKE=foo

Leave a Comment