# Template file for 'go1.4-bootstrap'
pkgname=go1.4-bootstrap
version=20171003
revision=1
create_wrksrc=yes
build_wrksrc="go"
short_desc="Go 1.4 (bootstrap compiler)"
maintainer="Michael Aldridge <maldridge@VoidLinux.eu>"
license="3-clause-BSD"
homepage="https://golang.org"
distfiles="https://dl.google.com/go/go1.4-bootstrap-${version}.tar.gz"
checksum=f4ff5b5eb3a3cae1c993723f3eab519c5bae18866b5e5f96fe1102f0cb5c3e52

only_for_archs="x86_64 x86_64-musl i686 i686-musl"

nostrip=yes
noverifyrdeps=yes

do_build() {
	unset GCC CC CXX LD CFLAGS CXXFLAGS
	# FIXME: work around leaking go build-style vars when built as a
	# dependency
	unset CGO_CXXFLAGS CGO_CFLAGS CGO_ENABLED

	env > ENV.${XBPS_TARGET_MACHINE}
	case "${XBPS_TARGET_MACHINE}" in
		aarch64*) _goarch=arm64 ;;
		arm*) _goarch=arm ;;
		i686*) _goarch=386 ;;
		x86_64*) _goarch=amd64 ;;
		*) _goarch=${XBPS_TARGET_MACHINE} ;;
	esac

	export GOROOT="${PWD}"
	export GOARCH="${_goarch}"
	cd src
	GOROOT_FINAL="/usr/lib/go1.4" ./make.bash
}

do_install() {
	vmkdir usr/lib/go1.4
	vcopy bin usr/lib/go1.4
	vcopy src usr/lib/go1.4
	vcopy pkg usr/lib/go1.4
	vlicense LICENSE
}
