4 ms·
Unlike a target, .PHONY can be populated incrementally. For example, this: .PHONY: serve live-reload serve: init deps compile db-setup db-migrate
by goblin89 7y ago
Unlike a target, .PHONY can be populated incrementally. For example, this:
.PHONY: serve live-reload
serve: init deps compile db-setup db-migrate
rails server
live-reload: yarn
./bin/webpack-dev-server --host 127.0.0.1
can become this, making things a tiny bit easier to maintain when there are many targets:
.PHONY: serve
serve: init deps compile db-setup db-migrate
rails server
.PHONY: live-reload
live-reload: yarn
./bin/webpack-dev-server --host 127.0.0.1
Recently I joined an environment that uses Makefiles as the facade in front of pretty much everything, from git submodule update shortcuts to building code and running local development servers.
Surprising myself, I’ve quickly grown to appreciate working Makefiles. That said, since the syntax somewhat encourages terseness, when I need to fix a non-trivial target it tends to look like black magic—nothing reading a few man pages can’t fix, but it takes extra time.
It’s not my first choice overall, I prefer to leave out the extra layer and document direct command-line calls in a README. If a commonly used tool changes its call in a new version, with README it’s a documentation issue, but with Makefile it’s broken software.
- datashaman 7y agoSome neat tricks to be found here for documenting makefiles. https://gist.github.com/prwhite/8168133 https://gist.github.com/prwhite/8168133
- unhammer 7y ago> If a commonly used tool changes its call in a new version, with README it’s a documentation issue, but with Makefile it’s broken software. ie. the Makefile will be kept up-to-date
- goblin89 7y agoPerhaps I did not express that well. This is how things may go: (1) I need to build this, but the Makefile is broken. (2) I invoke the build directly by asking colleague for help. (3) Can I be bothered to update the docs? Maybe. Can I be bothered to fix Makefile targets? Much less likely.
- brandmeyer 7y agoAll targets can be populated incrementally. That's part of how GCC's family of -MD family works.