A Node.js CLI utility that watches a Makefile's dependency graph and automatically re-runs make whenever any dependency files change.
- Automatic dependency extraction — Uses
make -pnto parse the dependency graph, so all Makefile features work: variables, wildcards, shell calls, includes, pattern rules - Smart file watching — Watches only the files that actually depend on the target, avoiding unnecessary rebuilds
- Wildcard support — When new files are created that match
$(wildcard ...)or$(shell find ...)patterns, the tool detects them automatically - Debounced rebuilds — Rapid file changes are grouped into a single build (default: 300ms debounce)
- Live output — See full
makeoutput in real-time with colors and progress indicators - Graceful shutdown — Press Ctrl+C to cleanly close watchers and exit
- Node.js >= 18.20.0
- make — Standard Unix build tool (usually pre-installed on Linux/macOS)
Download the latest release, extract it, and run the install script:
tar xzf makewatch-*.tar.gz
cd makewatch-*
./scripts/install.sh
makewatch [options] [target]The scripts/install.sh script:
- Copies the package to
/opt/makewatch(or~/.local/opt/makewatchif/optisn't writable) - Installs dependencies
- Creates a
makewatchcommand in/usr/local/bin/(or~/.local/binif/usr/local/binisn't writable)
The script automatically detects write permissions and uses user-local directories (~/.local/) if system directories aren't accessible.
You can override the defaults:
INSTALL_PREFIX=~/.local/opt/makewatch BIN_PREFIX=~/.local/bin ./scripts/install.shmakewatch [options] [target]
Options:
-C <dir> Run make in this directory (default: current directory)
-f <file> Specify Makefile path
-d <ms> Debounce delay in milliseconds (default: 300)
-v Verbose output (show file change events)
-h Show help
--version Show version
Watch the default target and rebuild on changes:
makewatchWatch a specific target in a subdirectory:
makewatch -C src buildUse a custom Makefile:
makewatch -f custom.mkVerbose mode to see each file change:
makewatch -v allFast debounce (100ms) for responsive rebuilds:
makewatch -d 100 all- Parse dependencies — Run
make -pn <target>to get make's internal database of all rules and their prerequisites - Extract file list — Walk the dependency tree from the target, collecting all file paths (excluding phony targets)
- Watch files — Use chokidar (inotify-based) to monitor those files for changes
- Rebuild — When any file changes, debounce for ~300ms then run
make <target> - Re-parse — After each rebuild, re-parse dependencies to pick up newly-created files that match wildcard patterns
MIT