abinfo "Setting GOPATH ..."
export GOPATH="$SRCDIR"

abinfo "Setting GO111MODULE to auto ..."
export GO111MODULE=auto

abinfo "Preparing build environment ..."
mkdir -pv "$SRCDIR"/src/github.com/golang/dep
mv -vT "$SRCDIR"/dep \
    "$SRCDIR"/src/github.com/golang/dep

abinfo "Building Dep ..."
(
    cd "$SRCDIR"/src/github.com/golang/dep/cmd/dep
    if [[ "${CROSS:-$ARCH}" != "loongson3" ]]; then
        go build \
            -buildmode=pie \
            -o "$SRCDIR"/bin/dep
    else
        go build \
            -o "$SRCDIR"/bin/dep
    fi
)

abinfo "Installing Dep ..."
install -Dvm755 "$SRCDIR"/bin/dep \
    "$PKGDIR"/usr/bin/dep
