2013-12-02 22:48:26 +00:00
|
|
|
#!/bin/bash
|
2014-04-08 04:14:19 +00:00
|
|
|
set -e
|
2013-09-10 01:45:40 +00:00
|
|
|
|
2014-10-28 05:05:57 +00:00
|
|
|
BINARY_NAME="docker-$VERSION"
|
2015-01-10 00:28:40 +00:00
|
|
|
BINARY_EXTENSION="$(binary_extension)"
|
2014-11-18 22:44:05 +00:00
|
|
|
BINARY_FULLNAME="$BINARY_NAME$BINARY_EXTENSION"
|
|
|
|
|
2015-04-14 16:43:33 +00:00
|
|
|
source "${MAKEDIR}/.go-autogen"
|
2015-02-04 21:22:38 +00:00
|
|
|
|
2015-08-10 19:51:54 +00:00
|
|
|
(
|
2016-01-26 21:17:05 +00:00
|
|
|
export GOGC=${DOCKER_BUILD_GOGC:-1000}
|
|
|
|
|
2015-08-10 19:51:54 +00: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
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
2015-11-24 20:19:16 +00:00
|
|
|
if [ "$(go env GOOS)" == "linux" ] ; then
|
|
|
|
case "$(go env GOARCH)" in
|
|
|
|
arm*|386)
|
|
|
|
# linking for Linux on arm or x86 needs external linking to avoid
|
|
|
|
# https://github.com/golang/go/issues/9510 until we move to Go 1.6
|
|
|
|
if [ "$IAMSTATIC" == "true" ] ; then
|
|
|
|
export EXTLDFLAGS_STATIC="$EXTLDFLAGS_STATIC -zmuldefs"
|
|
|
|
export LDFLAGS_STATIC_DOCKER="$LDFLAGS_STATIC -extldflags \"$EXTLDFLAGS_STATIC\""
|
|
|
|
|
|
|
|
else
|
|
|
|
export LDFLAGS="$LDFLAGS -extldflags -zmuldefs"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
2016-03-25 04:08:03 +00:00
|
|
|
if [ "$IAMSTATIC" == "true" ] && [ "$(go env GOHOSTOS)" == "linux" ] && [ "$DOCKER_EXPERIMENTAL" ]; then
|
2015-11-09 01:59:09 +00:00
|
|
|
if [ "${GOOS}/${GOARCH}" == "darwin/amd64" ]; then
|
|
|
|
export CGO_ENABLED=1
|
|
|
|
export CC=o64-clang
|
|
|
|
export LDFLAGS='-linkmode external -s'
|
|
|
|
export LDFLAGS_STATIC_DOCKER='-extld='${CC}
|
|
|
|
else
|
|
|
|
export BUILDFLAGS=( "${BUILDFLAGS[@]/pkcs11 /}" ) # we cannot dlopen in pkcs11 in a static binary
|
|
|
|
fi
|
2015-10-31 01:14:10 +00:00
|
|
|
fi
|
|
|
|
|
2015-05-15 02:50:29 +00:00
|
|
|
echo "Building: $DEST/$BINARY_FULLNAME"
|
2014-03-07 02:55:22 +00:00
|
|
|
go build \
|
2014-11-18 22:44:05 +00:00
|
|
|
-o "$DEST/$BINARY_FULLNAME" \
|
2014-03-07 02:55:22 +00:00
|
|
|
"${BUILDFLAGS[@]}" \
|
|
|
|
-ldflags "
|
|
|
|
$LDFLAGS
|
|
|
|
$LDFLAGS_STATIC_DOCKER
|
|
|
|
" \
|
|
|
|
./docker
|
2015-08-10 19:51:54 +00:00
|
|
|
)
|
2015-03-18 03:17:28 +00:00
|
|
|
|
2014-11-18 22:44:05 +00:00
|
|
|
echo "Created binary: $DEST/$BINARY_FULLNAME"
|
|
|
|
ln -sf "$BINARY_FULLNAME" "$DEST/docker$BINARY_EXTENSION"
|
2014-03-16 21:10:59 +00:00
|
|
|
|
2016-03-22 21:12:29 +00:00
|
|
|
copy_containerd "$DEST" "hash"
|
2014-11-18 22:44:05 +00:00
|
|
|
hash_files "$DEST/$BINARY_FULLNAME"
|