xref: /OK3568_Linux_fs/buildroot/package/go-bootstrap/go-bootstrap.mk (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1################################################################################
2#
3# go-bootstrap
4#
5################################################################################
6
7# Use last C-based Go compiler: v1.4.x
8# See https://golang.org/doc/install/source#bootstrapFromSource
9GO_BOOTSTRAP_VERSION = 1.4-bootstrap-20171003
10GO_BOOTSTRAP_SITE = https://dl.google.com/go
11GO_BOOTSTRAP_SOURCE = go$(GO_BOOTSTRAP_VERSION).tar.gz
12
13GO_BOOTSTRAP_LICENSE = BSD-3-Clause
14GO_BOOTSTRAP_LICENSE_FILES = LICENSE
15
16# To build programs that need cgo support the toolchain needs to be
17# available, so the toolchain is not needed to build host-go-bootstrap
18# itself, but needed by other packages that depend on
19# host-go-bootstrap.
20HOST_GO_BOOTSTRAP_DEPENDENCIES = toolchain
21
22HOST_GO_BOOTSTRAP_ROOT = $(HOST_DIR)/lib/go-$(GO_BOOTSTRAP_VERSION)
23
24# The go build system is not compatable with ccache, so use HOSTCC_NOCCACHE
25# here.  See https://github.com/golang/go/issues/11685.
26HOST_GO_BOOTSTRAP_MAKE_ENV = \
27	GOOS=linux \
28	GOROOT_FINAL="$(HOST_GO_BOOTSTRAP_ROOT)" \
29	GOROOT="$(@D)" \
30	GOBIN="$(@D)/bin" \
31	CC=$(HOSTCC_NOCCACHE) \
32	CGO_ENABLED=0
33
34define HOST_GO_BOOTSTRAP_BUILD_CMDS
35	cd $(@D)/src && $(HOST_GO_BOOTSTRAP_MAKE_ENV) ./make.bash
36endef
37
38define HOST_GO_BOOTSTRAP_INSTALL_CMDS
39	$(INSTALL) -D -m 0755 $(@D)/bin/go $(HOST_GO_BOOTSTRAP_ROOT)/bin/go
40	$(INSTALL) -D -m 0755 $(@D)/bin/gofmt $(HOST_GO_BOOTSTRAP_ROOT)/bin/gofmt
41
42	cp -a $(@D)/lib $(HOST_GO_BOOTSTRAP_ROOT)/
43	cp -a $(@D)/pkg $(HOST_GO_BOOTSTRAP_ROOT)/
44
45	# There is a known issue which requires the go sources to be installed
46	# https://golang.org/issue/2775
47	cp -a $(@D)/src $(HOST_GO_BOOTSTRAP_ROOT)/
48endef
49
50$(eval $(host-generic-package))
51