2013-12-02 17:48:26 -05:00
|
|
|
#!/bin/bash
|
2014-04-08 00:14:19 -04:00
|
|
|
set -e
|
2013-09-09 21:45:40 -04:00
|
|
|
|
2014-10-28 01:05:57 -04:00
|
|
|
BINARY_NAME="docker-$VERSION"
|
2015-01-09 19:28:40 -05:00
|
|
|
BINARY_EXTENSION="$(binary_extension)"
|
2014-11-18 17:44:05 -05:00
|
|
|
BINARY_FULLNAME="$BINARY_NAME$BINARY_EXTENSION"
|
|
|
|
|
2015-04-14 12:43:33 -04:00
|
|
|
source "${MAKEDIR}/.go-autogen"
|
2015-02-04 16:22:38 -05:00
|
|
|
|
2015-08-10 15:51:54 -04:00
|
|
|
(
|
|
|
|
if [ "$(go env GOOS)/$(go env GOARCH)" != "$(go env GOHOSTOS)/$(go env GOHOSTARCH)" ]; then
|
|
|
|
# must be cross-compiling!
|
|
|
|
case "$(go env GOOS)/$(go env GOARCH)" in
|
|
|
|
windows/amd64)
|
|
|
|
export CC=x86_64-w64-mingw32-gcc
|
|
|
|
export CGO_ENABLED=1
|
2015-10-27 15:56:57 -04:00
|
|
|
export LDFLAGS_STATIC_DOCKER="${LDFLAGS_STATIC_DOCKER/-linkmode external/-linkmode internal} -extld=${CC}"
|
2015-08-10 15:51:54 -04:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
2015-10-30 17:26:33 -04:00
|
|
|
if [ "$(go env GOHOSTOS)/$(go env GOHOSTARCH)" == "windows/amd64" ] && [ "$(go env GOOS)" == "windows" ]; then
|
|
|
|
# native compilation of Windows on Windows with golang 1.5+ needs linkmode internal
|
|
|
|
# https://github.com/golang/go/issues/13070
|
|
|
|
export LDFLAGS_STATIC_DOCKER="$LDFLAGS_STATIC_DOCKER -linkmode=internal"
|
|
|
|
fi
|
|
|
|
|
2015-05-14 22:50:29 -04:00
|
|
|
echo "Building: $DEST/$BINARY_FULLNAME"
|
2014-03-06 21:55:22 -05:00
|
|
|
go build \
|
2014-11-18 17:44:05 -05:00
|
|
|
-o "$DEST/$BINARY_FULLNAME" \
|
2014-03-06 21:55:22 -05:00
|
|
|
"${BUILDFLAGS[@]}" \
|
|
|
|
-ldflags "
|
|
|
|
$LDFLAGS
|
|
|
|
$LDFLAGS_STATIC_DOCKER
|
|
|
|
" \
|
|
|
|
./docker
|
2015-08-10 15:51:54 -04:00
|
|
|
)
|
2015-03-17 23:17:28 -04:00
|
|
|
|
2014-11-18 17:44:05 -05:00
|
|
|
echo "Created binary: $DEST/$BINARY_FULLNAME"
|
|
|
|
ln -sf "$BINARY_FULLNAME" "$DEST/docker$BINARY_EXTENSION"
|
2014-03-16 17:10:59 -04:00
|
|
|
|
2014-11-18 17:44:05 -05:00
|
|
|
hash_files "$DEST/$BINARY_FULLNAME"
|