Browse code

make windows cross compile static daemon work

Signed-off-by: Jessica Frazelle <acidburn@docker.com>

Jessica Frazelle authored on 2015/08/11 04:51:54
Showing 3 changed files
... ...
@@ -40,6 +40,7 @@ RUN apt-get update && apt-get install -y \
40 40
 	createrepo \
41 41
 	curl \
42 42
 	dpkg-sig \
43
+	gcc-mingw-w64 \
43 44
 	git \
44 45
 	iptables \
45 46
 	libapparmor-dev \
... ...
@@ -7,6 +7,18 @@ BINARY_FULLNAME="$BINARY_NAME$BINARY_EXTENSION"
7 7
 
8 8
 source "${MAKEDIR}/.go-autogen"
9 9
 
10
+(
11
+if [ "$(go env GOOS)/$(go env GOARCH)" != "$(go env GOHOSTOS)/$(go env GOHOSTARCH)" ]; then
12
+	# must be cross-compiling!
13
+	case "$(go env GOOS)/$(go env GOARCH)" in
14
+		windows/amd64)
15
+			export CC=x86_64-w64-mingw32-gcc
16
+			export CGO_ENABLED=1
17
+			export LDFLAGS_STATIC_DOCKER="${LDFLAGS_STATIC_DOCKER/-linkmode external/} -extld=${CC}"
18
+			;;
19
+	esac
20
+fi
21
+
10 22
 echo "Building: $DEST/$BINARY_FULLNAME"
11 23
 go build \
12 24
 	-o "$DEST/$BINARY_FULLNAME" \
... ...
@@ -16,6 +28,7 @@ go build \
16 16
 		$LDFLAGS_STATIC_DOCKER
17 17
 	" \
18 18
 	./docker
19
+)
19 20
 
20 21
 echo "Created binary: $DEST/$BINARY_FULLNAME"
21 22
 ln -sf "$BINARY_FULLNAME" "$DEST/docker$BINARY_EXTENSION"
... ...
@@ -5,6 +5,7 @@ set -e
5 5
 declare -A daemonSupporting
6 6
 daemonSupporting=(
7 7
 	[linux/amd64]=1
8
+	[windows/amd64]=1
8 9
 )
9 10
 
10 11
 # if we have our linux/amd64 version compiled, let's symlink it in