#!/bin/bash

export CGO_ENABLED=1
export GOARCH=amd64

if [[ "$1" == "win" ]]; then
    export CC=x86_64-w64-mingw32-gcc
    export CXX=x86_64-w64-mingw32-g++
    export CGO_LDFLAGS="-static-libgcc -static-libstdc++"
    export GOOS=windows

    echo "Building Windows AMD64 binaries"
    go-winres simply --icon ./src/icon.ico --manifest gui
    mv *.syso ./src
    go build -o ./raspscreen.exe -ldflags -H=windowsgui ./src
elif [[ "$1" == "linux" ]]; then
    export CC=gcc
    export CXX=g++
    export GOOS=linux

    echo "Building Linux AMD64 binaries"
    go build -o ./raspscreen ./src
fi
echo "Done"
exit 0