1 ################################################################################
5 ################################################################################
8 GO_SITE
= https
://storage.googleapis.com
/golang
9 GO_SOURCE
= go
$(GO_VERSION
).src.
tar.gz
12 GO_LICENSE_FILES
= LICENSE
16 ifeq ($(BR2_ARM_CPU_ARMV5
),y
)
18 else ifeq ($(BR2_ARM_CPU_ARMV6
),y
)
20 else ifeq ($(BR2_ARM_CPU_ARMV7A
),y
)
23 else ifeq ($(BR2_aarch64
),y
)
25 else ifeq ($(BR2_i386
),y
)
27 else ifeq ($(BR2_x86_64
),y
)
29 else ifeq ($(BR2_powerpc64
),y
)
31 else ifeq ($(BR2_powerpc64le
),y
)
33 else ifeq ($(BR2_mips64
),y
)
35 else ifeq ($(BR2_mips64el
),y
)
39 HOST_GO_DEPENDENCIES
= host-go-bootstrap
40 HOST_GO_ROOT
= $(HOST_DIR
)/usr
/lib
/go
42 # For the convienience of target packages.
43 HOST_GO_TOOLDIR
= $(HOST_GO_ROOT
)/pkg
/tool
/linux_
$(GO_GOARCH
)
44 HOST_GO_TARGET_ENV
= \
46 GOROOT
="$(HOST_GO_ROOT)" \
49 GOTOOLDIR
="$(HOST_GO_TOOLDIR)"
51 # The go compiler's cgo support uses threads. If BR2_TOOLCHAIN_HAS_THREADS is
52 # set, build in cgo support for any go programs that may need it. Note that
53 # any target package needing cgo support must include
54 # 'depends on BR2_TOOLCHAIN_HAS_THREADS' in its config file.
55 ifeq (BR2_TOOLCHAIN_HAS_THREADS
,y
)
56 HOST_GO_CGO_ENABLED
= 1
58 HOST_GO_CGO_ENABLED
= 0
61 # The go build system doesn't have the notion of cross compiling, but just the
62 # notion of architecture. When the host and target architectures are different
63 # it expects to be given a target cross compiler in CC_FOR_TARGET. When the
64 # architectures are the same it will use CC_FOR_TARGET for both host and target
65 # compilation. To work around this limitation build and install a set of
66 # compiler and tool binaries built with CC_FOR_TARGET set to the host compiler.
67 # Also, the go build system is not compatible with ccache, so use
68 # HOSTCC_NOCCACHE. See https://github.com/golang/go/issues/11685.
70 GOROOT_BOOTSTRAP
=$(HOST_GO_BOOTSTRAP_ROOT
) \
71 GOROOT_FINAL
=$(HOST_GO_ROOT
) \
75 $(if
$(GO_GOARM
),GOARM
=$(GO_GOARM
)) \
77 CGO_ENABLED
=$(HOST_GO_CGO_ENABLED
) \
81 CC_FOR_TARGET
="$(TARGET_CC)" \
82 CXX_FOR_TARGET
="$(TARGET_CXX)"
85 CC_FOR_TARGET
=$(HOSTCC_NOCCACHE
) \
86 CXX_FOR_TARGET
=$(HOSTCC_NOCCACHE
)
88 HOST_GO_TMP
= $(@D
)/host-go-tmp
90 define HOST_GO_BUILD_CMDS
91 cd
$(@D
)/src
&& $(HOST_GO_MAKE_ENV
) $(HOST_GO_HOST_CC
) .
/make.bash
92 mkdir
-p
$(HOST_GO_TMP
)
93 mv
$(@D
)/pkg
/tool
$(HOST_GO_TMP
)/
94 mv
$(@D
)/bin
/ $(HOST_GO_TMP
)/
95 cd
$(@D
)/src
&& $(HOST_GO_MAKE_ENV
) $(HOST_GO_TARGET_CC
) .
/make.bash
98 define HOST_GO_INSTALL_CMDS
99 $(INSTALL
) -D
-m
0755 $(HOST_GO_TMP
)/bin
/go
$(HOST_GO_ROOT
)/bin
/go
100 $(INSTALL
) -D
-m
0755 $(HOST_GO_TMP
)/bin
/gofmt
$(HOST_GO_ROOT
)/bin
/gofmt
102 ln
-sf ..
/lib
/go
/bin
/go
$(HOST_DIR
)/usr
/bin
/
103 ln
-sf ..
/lib
/go
/bin
/gofmt
$(HOST_DIR
)/usr
/bin
/
105 cp
-a
$(@D
)/lib
$(HOST_GO_ROOT
)/
107 mkdir
-p
$(HOST_GO_ROOT
)/pkg
108 cp
-a
$(@D
)/pkg
/include $(@D
)/pkg
/linux_
* $(HOST_GO_ROOT
)/pkg
/
109 cp
-a
$(HOST_GO_TMP
)/tool
$(HOST_GO_ROOT
)/pkg
/
111 # There is a known issue which requires the go sources to be installed
112 # https://golang.org/issue/2775
113 cp
-a
$(@D
)/src
$(HOST_GO_ROOT
)/
115 # Set all file timestamps to prevent the go compiler from rebuilding any
116 # built in packages when programs are built.
117 find
$(HOST_GO_ROOT
) -type f
-exec touch
-r
$(HOST_GO_TMP
)/bin
/go
{} \
;
120 $(eval
$(host-generic-package
))