From e62745922feb580b3687571bb4c52db3de5157f7 Mon Sep 17 00:00:00 2001 From: Jessica Frazelle Date: Mon, 10 Aug 2015 12:51:54 -0700 Subject: [PATCH] make windows cross compile static daemon work Signed-off-by: Jessica Frazelle --- Dockerfile | 1 + hack/make/binary | 13 +++++++++++++ hack/make/cross | 1 + 3 files changed, 15 insertions(+) diff --git a/Dockerfile b/Dockerfile index 951c0cf7f5..e47908c421 100644 --- a/Dockerfile +++ b/Dockerfile @@ -40,6 +40,7 @@ RUN apt-get update && apt-get install -y \ createrepo \ curl \ dpkg-sig \ + gcc-mingw-w64 \ git \ iptables \ libapparmor-dev \ diff --git a/hack/make/binary b/hack/make/binary index d7643364db..7a3067fa48 100644 --- a/hack/make/binary +++ b/hack/make/binary @@ -7,6 +7,18 @@ BINARY_FULLNAME="$BINARY_NAME$BINARY_EXTENSION" source "${MAKEDIR}/.go-autogen" +( +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 + export LDFLAGS_STATIC_DOCKER="${LDFLAGS_STATIC_DOCKER/-linkmode external/} -extld=${CC}" + ;; + esac +fi + echo "Building: $DEST/$BINARY_FULLNAME" go build \ -o "$DEST/$BINARY_FULLNAME" \ @@ -16,6 +28,7 @@ go build \ $LDFLAGS_STATIC_DOCKER " \ ./docker +) echo "Created binary: $DEST/$BINARY_FULLNAME" ln -sf "$BINARY_FULLNAME" "$DEST/docker$BINARY_EXTENSION" diff --git a/hack/make/cross b/hack/make/cross index b5eab68124..ea8eee6cf2 100644 --- a/hack/make/cross +++ b/hack/make/cross @@ -5,6 +5,7 @@ set -e declare -A daemonSupporting daemonSupporting=( [linux/amd64]=1 + [windows/amd64]=1 ) # if we have our linux/amd64 version compiled, let's symlink it in