1inherit cross 2 3PROVIDES = "virtual/${TUNE_PKGARCH}-go" 4DEPENDS = "go-native" 5 6PN = "go-cross-${TUNE_PKGARCH}" 7 8export GOHOSTOS = "${BUILD_GOOS}" 9export GOHOSTARCH = "${BUILD_GOARCH}" 10export GOOS = "${TARGET_GOOS}" 11export GOARCH = "${TARGET_GOARCH}" 12export GOARM = "${TARGET_GOARM}" 13export GO386 = "${TARGET_GO386}" 14export GOMIPS = "${TARGET_GOMIPS}" 15export GOROOT_BOOTSTRAP = "${STAGING_LIBDIR_NATIVE}/go" 16export GOROOT_FINAL = "${libdir}/go" 17CC = "${@d.getVar('BUILD_CC').strip()}" 18 19do_configure[noexec] = "1" 20 21do_compile() { 22 export CC_FOR_${GOOS}_${GOARCH}="${TARGET_PREFIX}gcc ${TARGET_CC_ARCH} --sysroot=${STAGING_DIR_TARGET}" 23 export CXX_FOR_${GOOS}_${GOARCh}="${TARGET_PREFIX}g++ ${TARGET_CC_ARCH} --sysroot=${STAGING_DIR_TARGET}" 24 cd src 25 ./make.bash --host-only --no-banner 26 cd ${B} 27} 28do_compile[dirs] =+ "${GOTMPDIR} ${B}/bin ${B}/pkg" 29do_compile[cleandirs] += "${GOTMPDIR} ${B}/bin ${B}/pkg" 30 31make_wrapper() { 32 rm -f ${D}${bindir}/$2 33 cat <<END >${D}${bindir}/$2 34#!/bin/bash 35here=\`dirname \$0\` 36export GOARCH="${TARGET_GOARCH}" 37export GOOS="${TARGET_GOOS}" 38export GOARM="\${GOARM:-${TARGET_GOARM}}" 39export GO386="\${GO386:-${TARGET_GO386}}" 40export GOMIPS="\${GOMIPS:-${TARGET_GOMIPS}}" 41\$here/../../lib/${CROSS_TARGET_SYS_DIR}/go/bin/$1 "\$@" 42END 43 chmod +x ${D}${bindir}/$2 44} 45 46do_install() { 47 install -d ${D}${libdir}/go 48 cp --preserve=mode,timestamps -R ${B}/pkg ${D}${libdir}/go/ 49 install -d ${D}${libdir}/go/src 50 (cd ${S}/src; for d in *; do \ 51 [ ! -d $d ] || cp --preserve=mode,timestamps -R ${S}/src/$d ${D}${libdir}/go/src/; \ 52 done) 53 find ${D}${libdir}/go/src -depth -type d -name testdata -exec rm -rf {} \; 54 install -d ${D}${bindir} ${D}${libdir}/go/bin 55 for f in ${B}/bin/* 56 do 57 base=`basename $f` 58 install -m755 $f ${D}${libdir}/go/bin 59 make_wrapper $base ${TARGET_PREFIX}$base 60 done 61} 62