blob: c5cb97e73e78bd8b1e5c00ca0c067514839f2814 [file] [log] [blame]
Andrew Geisslerd25ed322020-06-27 00:28:28 -05001# This recipe builds a native Go (written in Go) by first building an old Go 1.4
2# (written in C). However this old Go does not support all hosts platforms.
3
Brad Bishop19323692019-04-05 15:28:33 -04004require go-${PV}.inc
Andrew Geisslerd25ed322020-06-27 00:28:28 -05005
6inherit native
7
8SRC_URI_append = " https://dl.google.com/go/go1.4-bootstrap-20171003.tar.gz;name=bootstrap;subdir=go1.4"
9SRC_URI[bootstrap.md5sum] = "dbf727a4b0e365bf88d97cbfde590016"
10SRC_URI[bootstrap.sha256sum] = "f4ff5b5eb3a3cae1c993723f3eab519c5bae18866b5e5f96fe1102f0cb5c3e52"
11
12export GOOS = "${BUILD_GOOS}"
13export GOARCH = "${BUILD_GOARCH}"
14CC = "${@d.getVar('BUILD_CC').strip()}"
15
16GOMAKEARGS ?= "--no-banner"
17
18do_configure() {
19 cd ${WORKDIR}/go1.4/go/src
20 CGO_ENABLED=0 GOROOT=${WORKDIR}/go1.4/go ./make.bash
21}
22
23do_compile() {
24 export GOROOT_FINAL="${libdir_native}/go"
25 export GOROOT_BOOTSTRAP="${WORKDIR}/go1.4/go"
26
27 cd src
28 ./make.bash ${GOMAKEARGS}
29 cd ${B}
30}
31do_compile[dirs] =+ "${GOTMPDIR} ${B}/bin"
32do_compile[cleandirs] += "${GOTMPDIR} ${B}/bin"
33
34make_wrapper() {
35 rm -f ${D}${bindir}/$2$3
36 cat <<END >${D}${bindir}/$2$3
37#!/bin/bash
38here=\`dirname \$0\`
39export GOROOT="${GOROOT:-\`readlink -f \$here/../lib/go\`}"
40\$here/../lib/go/bin/$1 "\$@"
41END
42 chmod +x ${D}${bindir}/$2
43}
44
45do_install() {
46 install -d ${D}${libdir}/go
47 cp --preserve=mode,timestamps -R ${B}/pkg ${D}${libdir}/go/
48 install -d ${D}${libdir}/go/src
49 (cd ${S}/src; for d in *; do \
50 [ -d $d ] && cp -a ${S}/src/$d ${D}${libdir}/go/src/; \
51 done)
52 find ${D}${libdir}/go/src -depth -type d -name testdata -exec rm -rf {} \;
53 install -d ${D}${bindir} ${D}${libdir}/go/bin
54 for f in ${B}/bin/*
55 do
56 base=`basename $f`
57 install -m755 $f ${D}${libdir}/go/bin
58 make_wrapper $base $base
59 done
60}