#!/bin/bash
set -e

source $(dirname $0)/version

cd $(dirname $0)/..

mkdir -p bin
if [ "$(uname)" = "Linux" ]; then
    OTHER_LINKFLAGS="-extldflags -static -s"
fi
LINKFLAGS="-X github.com/rancher/klum.Version=$VERSION"
LINKFLAGS="-X github.com/rancher/klum.GitCommit=$COMMIT $LINKFLAGS"
CGO_ENABLED=0 go build -ldflags "$LINKFLAGS $OTHER_LINKFLAGS" -o bin/klum
if [ "$CROSS" = "true" ] && [ "$ARCH" = "amd64" ]; then
    GOOS=darwin go build -ldflags "$LINKFLAGS" -o bin/klum-darwin
    GOOS=windows go build -ldflags "$LINKFLAGS" -o bin/klum-windows
fi
