1inherit crosssdk
2
3DEPENDS = "go-native virtual/${TARGET_PREFIX}gcc-crosssdk virtual/nativesdk-${TARGET_PREFIX}compilerlibs virtual/${TARGET_PREFIX}binutils-crosssdk"
4PN = "go-crosssdk-${SDK_SYS}"
5PROVIDES = "virtual/${TARGET_PREFIX}go-crosssdk"
6
7do_configure[noexec] = "1"
8
9do_compile() {
10	export CC_FOR_${TARGET_GOTUPLE}="${TARGET_PREFIX}gcc ${TARGET_CC_ARCH} --sysroot=${STAGING_DIR_TARGET}${SDKPATHNATIVE}"
11	export CXX_FOR_${TARGET_GOTUPLE}="${TARGET_PREFIX}g++ ${TARGET_CC_ARCH} --sysroot=${STAGING_DIR_TARGET}${SDKPATHNATIVE}"
12	cd src
13	./make.bash --host-only --no-banner
14	cd ${B}
15}
16do_compile[dirs] =+ "${GOTMPDIR} ${B}/bin ${B}/pkg"
17do_compile[cleandirs] += "${GOTMPDIR} ${B}/bin ${B}/pkg"
18
19make_wrapper() {
20    rm -f ${D}${bindir}/$2
21    cat <<END >${D}${bindir}/$2
22#!/bin/bash
23here=\`dirname \$0\`
24export GOARCH="${TARGET_GOARCH}"
25export GOOS="${TARGET_GOOS}"
26\$here/../../lib/${CROSS_TARGET_SYS_DIR}/go/bin/$1 "\$@"
27END
28    chmod +x ${D}${bindir}/$2
29}
30
31do_install() {
32	install -d ${D}${libdir}/go
33	install -d ${D}${libdir}/go/bin
34	install -d ${D}${libdir}/go/pkg/tool
35	install -d ${D}${bindir}
36	cp --preserve=mode,timestamps -R ${S}/pkg/tool/${BUILD_GOTUPLE} ${D}${libdir}/go/pkg/tool/
37	for f in ${B}/bin/*
38	do
39		base=`basename $f`
40		install -m755 $f ${D}${libdir}/go/bin
41		make_wrapper $base ${TARGET_PREFIX}$base
42	done
43}
44