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