blob: 8afda6b2ce55ce62e71a5de9514189945ac39ce1 [file] [log] [blame]
Brad Bishopd7bf8c12018-02-25 22:55:05 -05001inherit cross-canadian
2
3DEPENDS = "go-native virtual/${HOST_PREFIX}go-crosssdk virtual/nativesdk-${HOST_PREFIX}go-runtime \
4 virtual/${HOST_PREFIX}gcc-crosssdk virtual/nativesdk-${HOST_PREFIX}libc-for-gcc \
5 virtual/nativesdk-${HOST_PREFIX}compilerlibs"
6PN = "go-cross-canadian-${TRANSLATED_TARGET_ARCH}"
7
8export GOHOSTOS = "${BUILD_GOOS}"
9export GOHOSTARCH = "${BUILD_GOARCH}"
10export GOHOSTOS_CROSS = "${HOST_GOOS}"
11export GOHOSTARCH_CROSS = "${HOST_GOARCH}"
12export GOROOT_BOOTSTRAP = "${STAGING_LIBDIR_NATIVE}/go"
13export GOTOOLDIR_BOOTSTRAP = "${STAGING_LIBDIR_NATIVE}/${HOST_SYS}/go/pkg/tool/${BUILD_GOTUPLE}"
14export GOROOT_FINAL = "${libdir}/go"
15export CGO_ENABLED = "1"
16export CC_FOR_TARGET = "${TARGET_PREFIX}gcc"
17export CXX_FOR_TARGET = "${TARGET_PREFIX}g++"
18CC = "${HOST_PREFIX}gcc"
19export CGO_CFLAGS = "--sysroot=${STAGING_DIR_TARGET} ${HOST_CC_ARCH} ${CFLAGS}"
20export CGO_LDFLAGS = "--sysroot=${STAGING_DIR_TARGET} ${HOST_CC_ARCH} ${LDFLAGS}"
21export GO_LDFLAGS = '-linkmode external -extld ${HOST_PREFIX}gcc -extldflags "--sysroot=${STAGING_DIR_TARGET} ${HOST_CC_ARCH} ${LDFLAGS}"'
22
23do_configure[noexec] = "1"
24
25do_compile() {
26 export GOBIN="${B}/bin"
27 rm -rf ${GOBIN} ${B}/pkg
28 mkdir ${GOBIN}
29 cd src
30 ./make.bash --host-only --no-banner
31 cd ${B}
32}
33
34
35make_wrapper() {
36 rm -f ${D}${bindir}/$2
37 cat <<END >${D}${bindir}/$2
38#!/bin/sh
39here=\`dirname \$0\`
40native_goroot=\`readlink -f \$here/../../lib/${TARGET_SYS}/go\`
41export GOARCH="${TARGET_GOARCH}"
42export GOOS="${TARGET_GOOS}"
43test -n "\$GOARM" || export GOARM="${TARGET_GOARM}"
44test -n "\$GO386" || export GO386="${TARGET_GO386}"
45export GOTOOLDIR="\$native_goroot/pkg/tool/${HOST_GOTUPLE}"
46test -n "\$GOROOT" || export GOROOT="\$OECORE_TARGET_SYSROOT/${target_libdir}/go"
47\$here/../../lib/${TARGET_SYS}/go/bin/$1 "\$@"
48END
49 chmod +x ${D}${bindir}/$2
50}
51
52do_install() {
53 install -d ${D}${libdir}/go/pkg/tool
54 cp --preserve=mode,timestamps -R ${B}/pkg/tool/${HOST_GOTUPLE} ${D}${libdir}/go/pkg/tool/
55 install -d ${D}${bindir} ${D}${libdir}/go/bin
56 for f in ${B}/${GO_BUILD_BINDIR}/*
57 do
58 base=`basename $f`
59 install -m755 $f ${D}${libdir}/go/bin
60 make_wrapper $base ${TARGET_PREFIX}$base
61 done
62}