<p><pre><code> BUILD=`git rev-parse HEAD`
LDFLAGS=-ldflags "-X main.Version=${VERSION} -X main.Build=${BUILD}"
# ...
$(BINARY):
go build ${LDFLAGS} -o {$BINARY} ./..
</code></pre>
Please don't do that. This ties the build process to be run from inside the
git repository, which starts to be a problem if you have any sane method of
code deployment (building source packages). Think of something different.<p>And yes, there is a typo in the build rules.
<p><pre><code> ${BINARY}: main.go
go build $< -o $@
</code></pre>
this way, make will know to re-build the binary only if the source code has changed.