AFAICT, go build tags are a compile-time only construct, so there is no way to query whether a certain package was built with a specific tag. However, the 'netgo' tag triggers conditional compilation of the cgo_stubs.go file, and that file name ends up in the executable. (we could have looked for specific symbols in the 'net.a' library instead, but that requires locating it first, which is more hassle than it is worth) issue #93
34 lines
930 B
Makefile
34 lines
930 B
Makefile
.DEFAULT: all
|
|
|
|
# If you can use docker without being root, you can do "make SUDO="
|
|
SUDO=sudo
|
|
|
|
all: docker-image
|
|
|
|
weaver: ../*.go main.go
|
|
go get -tags netgo
|
|
go build -ldflags '-extldflags "-static"' -tags netgo
|
|
@strings $@ | grep cgo_stub\\\.go >/dev/null || { \
|
|
rm $@; \
|
|
echo "\nYour go standard library was built without the 'netgo' build tag."; \
|
|
echo "To fix that, run"; \
|
|
echo " sudo go install -a -tags netgo std"; \
|
|
false; \
|
|
}
|
|
|
|
.PHONY: docker-image
|
|
docker-image: /var/tmp/weave.tar
|
|
|
|
/var/tmp/weave.tar: Dockerfile weaver
|
|
$(SUDO) docker build -t zettio/weave .
|
|
$(SUDO) docker save zettio/weave > /var/tmp/weave.tar
|
|
|
|
publish: docker-image
|
|
$(SUDO) docker tag zettio/weave zettio/weave:git-`git rev-parse --short=12 HEAD`
|
|
$(SUDO) docker push zettio/weave:latest
|
|
$(SUDO) docker push zettio/weave:git-`git rev-parse --short=12 HEAD`
|
|
|
|
clean:
|
|
-$(SUDO) docker rmi zettio/weave
|
|
rm -f weaver /var/tmp/weave.tar
|