2 # Copyright (C) 2018 Jeffery To
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
8 ifeq ($(origin GO_INCLUDE_DIR
),undefined
)
9 GO_INCLUDE_DIR
:=$(dir $(lastword
$(MAKEFILE_LIST
)))
12 include $(GO_INCLUDE_DIR
)/golang-version.mk
16 GOARCH GOBIN GOCACHE GODEBUG GOFLAGS GOHOSTARCH GOOS GOPATH GORACE GOROOT GOTMPDIR GCCGO \
18 CGO_CFLAGS CGO_CFLAGS_ALLOW CGO_CFLAGS_DISALLOW \
19 CGO_CPPFLAGS CGO_CPPFLAGS_ALLOW CGO_CPPFLAGS_DISALLOW \
20 CGO_CXXFLAGS CGO_CXXFLAGS_ALLOW CGO_CXXFLAGS_DISALLOW \
21 CGO_FFLAGS CGO_FFLAGS_ALLOW CGO_FFLAGS_DISALLOW \
22 CGO_LDFLAGS CGO_LDFLAGS_ALLOW CGO_LDFLAGS_DISALLOW \
23 GOARM GO386 GOMIPS GOMIPS64 \
25 GOROOT_FINAL GO_EXTLINK_ENABLED GIT_ALLOW_PROTOCOL \
26 CC_FOR_TARGET CXX_FOR_TARGET GO_DISTFLAGS GO_GCFLAGS GO_LDFLAGS GOBUILDTIMELOGFILE GOROOT_BOOTSTRAP \
27 BOOT_GO_GCFLAGS GOEXPERIMENT GOBOOTSTRAP_TOOLEXEC
28 # there are more magic environment variables to track down, but ain't nobody got time for that
31 aarch64
,arm64
,$(subst \
33 mipsel
,mipsle
,$(subst \
34 mips64el
,mips64le
,$(subst \
35 powerpc64
,ppc64
,$(subst \
36 x86_64
,amd64
,$(1)))))))
39 GO_ARCH
:=$(call go_arch
,$(ARCH
))
40 GO_OS_ARCH
:=$(GO_OS
)_
$(GO_ARCH
)
42 GO_HOST_OS
:=$(call tolower
,$(HOST_OS
))
43 GO_HOST_ARCH
:=$(call go_arch
,$(subst \
48 i686
,i386
,$(HOST_ARCH
)))))))
49 GO_HOST_OS_ARCH
:=$(GO_HOST_OS
)_
$(GO_HOST_ARCH
)
51 GO_HOST_TARGET_SAME
:=$(if
$(and
$(findstring $(GO_OS_ARCH
),$(GO_HOST_OS_ARCH
)),$(findstring $(GO_HOST_OS_ARCH
),$(GO_OS_ARCH
))),1)
52 GO_HOST_TARGET_DIFFERENT
:=$(if
$(GO_HOST_TARGET_SAME
),,1)
54 # ensure binaries can run on older CPUs
57 GO_ARM
:=$(if
$(CONFIG_arm_v7
),7,$(if
$(CONFIG_arm_v6
),6,$(if
$(findstring $(GO_ARCH
),arm
),5,)))
59 GO_MIPS
:=$(if
$(filter $(GO_ARCH
),mips mipsle
),$(if
$(CONFIG_HAS_FPU
),hardfloat
,softfloat
),)
61 GO_MIPS64
:=$(if
$(filter $(GO_ARCH
),mips64 mips64le
),$(if
$(CONFIG_HAS_FPU
),hardfloat
,softfloat
),)
63 # -fno-plt: causes "unexpected GOT reloc for non-dynamic symbol" errors
64 # -mips32r2: conflicts with -march=mips32 set by go
65 GO_CFLAGS_TO_REMOVE
:=$(if \
66 $(filter $(GO_ARCH
),386),-fno-plt
,$(if \
67 $(filter $(GO_ARCH
),mips mipsle
),-mips32r2
,))
69 GO_ARCH_DEPENDS
:=@
(aarch64||arm||i386||i686||mips||mips64||mips64el||mipsel||powerpc64||x86_64
)
71 GO_TARGET_PREFIX
:=/usr
72 GO_TARGET_VERSION_ID
:=$(GO_VERSION_MAJOR_MINOR
)
73 GO_TARGET_ROOT
:=$(GO_TARGET_PREFIX
)/lib
/go-
$(GO_TARGET_VERSION_ID
)