github.com/shiroyuki/docker@v1.9.0/hack/make/binary (about)

     1  #!/bin/bash
     2  set -e
     3  
     4  BINARY_NAME="docker-$VERSION"
     5  BINARY_EXTENSION="$(binary_extension)"
     6  BINARY_FULLNAME="$BINARY_NAME$BINARY_EXTENSION"
     7  
     8  source "${MAKEDIR}/.go-autogen"
     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  
    22  echo "Building: $DEST/$BINARY_FULLNAME"
    23  go build \
    24  	-o "$DEST/$BINARY_FULLNAME" \
    25  	"${BUILDFLAGS[@]}" \
    26  	-ldflags "
    27  		$LDFLAGS
    28  		$LDFLAGS_STATIC_DOCKER
    29  	" \
    30  	./docker
    31  )
    32  
    33  echo "Created binary: $DEST/$BINARY_FULLNAME"
    34  ln -sf "$BINARY_FULLNAME" "$DEST/docker$BINARY_EXTENSION"
    35  
    36  hash_files "$DEST/$BINARY_FULLNAME"