summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/go/go.inc
blob: 0b0cbf19ad64e075966f7c8183b5c715ac5ef09c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
inherit goarch
# libgcc is required for the target specific libraries to build properly
DEPENDS += "go-bootstrap-native libgcc"
# Prevent runstrip from running because you get errors when the host arch != target arch
INHIBIT_PACKAGE_STRIP = "1"
INHIBIT_SYSROOT_STRIP = "1"

# x32 ABI is not supported on go compiler so far
COMPATIBLE_HOST_linux-gnux32 = "null"
# ppc32 is not supported in go compilers
COMPATIBLE_HOST_powerpc = "null"

export GOHOSTOS = "${BUILD_GOOS}"
export GOHOSTARCH = "${BUILD_GOARCH}"
export GOOS = "${TARGET_GOOS}"
export GOARCH = "${TARGET_GOARCH}"
export GOARM = "${TARGET_GOARM}"
export GOROOT_BOOTSTRAP = "${STAGING_LIBDIR_NATIVE}/go1.4"
export GOROOT_FINAL = "${libdir}/go"
export CGO_ENABLED = "1"
export CC_FOR_TARGET = "${CC}"
export CXX_FOR_TARGET = "${CXX}"

do_configure[noexec] = "1"

do_compile_prepend_class-cross() {
	export CGO_ENABLED=0
}

do_compile() {
	export GOBIN="${B}/bin"
	export CC="${@d.getVar('BUILD_CC', True).strip()}"
	rm -rf ${GOBIN} ${B}/pkg
	mkdir ${GOBIN}

	export TMPDIR=${WORKDIR}/build-tmp
	mkdir -p ${WORKDIR}/build-tmp

	cd src
	./make.bash --host-only
	# Ensure cgo.a is built with the target toolchain
	export GOBIN="${B}/target/bin"
	rm -rf ${GOBIN}
	mkdir -p ${GOBIN}
	GO_FLAGS="-a" ./make.bash
}

do_install_class-target() {
	install -d ${D}${libdir}/go
	cp -a ${B}/pkg ${D}${libdir}/go/
	install -d ${D}${libdir}/go/src
	(cd ${S}/src; for d in *; do \
		[ -d $d ] && cp -a ${S}/src/$d ${D}${libdir}/go/src/; \
	done)
	install -d ${D}${bindir}
	if [ -d ${B}/bin/${GOOS}_${GOARCH} ]
	then
		install -m 0755 ${B}/bin/${GOOS}_${GOARCH}/* ${D}${bindir}
	else
		install -m 0755 ${B}/bin/* ${D}${bindir}
	fi
}

do_install_class-cross() {
	install -d ${D}${libdir}/go
	cp -a ${B}/pkg ${D}${libdir}/go/
	install -d ${D}${libdir}/go/src
	(cd ${S}/src; for d in *; do \
		[ -d $d ] && cp -a ${S}/src/$d ${D}${libdir}/go/src/; \
	done)
	install -d ${D}${bindir}
	for f in ${B}/bin/go*
	do
		install -m755 $f ${D}${bindir}
	done
}

INSANE_SKIP_${PN} += "staticdev"
RDEPENDS_${PN} += "perl"

do_package[noexec] = "1"
do_packagedata[noexec] = "1"
do_package_write_ipk[noexec] = "1"
do_package_write_deb[noexec] = "1"
do_package_write_rpm[noexec] = "1"