You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.5 KiB

  1. #
  2. # Copyright (C) 2018 Jeffery To
  3. #
  4. # This is free software, licensed under the GNU General Public License v2.
  5. # See /LICENSE for more information.
  6. #
  7. ifeq ($(origin GO_INCLUDE_DIR),undefined)
  8. GO_INCLUDE_DIR:=$(dir $(lastword $(MAKEFILE_LIST)))
  9. endif
  10. include $(GO_INCLUDE_DIR)/golang-version.mk
  11. unexport \
  12. GOARCH GOBIN GOCACHE GODEBUG GOHOSTARCH GOOS GOPATH GORACE GOROOT GOTMPDIR GCCGO \
  13. CGO_ENABLED \
  14. CGO_CFLAGS CGO_CFLAGS_ALLOW CGO_CFLAGS_DISALLOW \
  15. CGO_CPPFLAGS CGO_CPPFLAGS_ALLOW CGO_CPPFLAGS_DISALLOW \
  16. CGO_CXXFLAGS CGO_CXXFLAGS_ALLOW CGO_CXXFLAGS_DISALLOW \
  17. CGO_FFLAGS CGO_FFLAGS_ALLOW CGO_FFLAGS_DISALLOW \
  18. CGO_LDFLAGS CGO_LDFLAGS_ALLOW CGO_LDFLAGS_DISALLOW \
  19. GOARM GO386 GOMIPS \
  20. GOROOT_FINAL GO_EXTLINK_ENABLED GIT_ALLOW_PROTOCOL \
  21. CC_FOR_TARGET CXX_FOR_TARGET GO_DISTFLAGS GO_GCFLAGS GO_LDFLAGS GOBUILDTIMELOGFILE GOROOT_BOOTSTRAP \
  22. BOOT_GO_GCFLAGS GOEXPERIMENT GOBOOTSTRAP_TOOLEXEC
  23. # there are more magic environment variables to track down, but ain't nobody got time for that
  24. go_arch=$(subst \
  25. aarch64,arm64,$(subst \
  26. i386,386,$(subst \
  27. mipsel,mipsle,$(subst \
  28. mips64el,mips64le,$(subst \
  29. powerpc64,ppc64,$(subst \
  30. x86_64,amd64,$(1)))))))
  31. GO_OS:=linux
  32. GO_ARCH:=$(call go_arch,$(ARCH))
  33. GO_OS_ARCH:=$(GO_OS)_$(GO_ARCH)
  34. GO_HOST_OS:=$(call tolower,$(HOST_OS))
  35. GO_HOST_ARCH:=$(call go_arch,$(subst \
  36. armv6l,arm,$(subst \
  37. armv7l,arm,$(subst \
  38. i486,i386,$(subst \
  39. i586,i386,$(subst \
  40. i686,i386,$(HOST_ARCH)))))))
  41. GO_HOST_OS_ARCH:=$(GO_HOST_OS)_$(GO_HOST_ARCH)
  42. GO_HOST_TARGET_SAME:=$(if $(and $(findstring $(GO_OS_ARCH),$(GO_HOST_OS_ARCH)),$(findstring $(GO_HOST_OS_ARCH),$(GO_OS_ARCH))),1)
  43. GO_HOST_TARGET_DIFFERENT:=$(if $(GO_HOST_TARGET_SAME),,1)
  44. # ensure binaries can run on older CPUs
  45. GO_386:=387
  46. GO_ARM:=$(if $(CONFIG_arm_v7),7,$(if $(CONFIG_arm_v6),6,$(if $(findstring $(GO_ARCH),arm),5,)))
  47. GO_MIPS:=$(if $(filter $(GO_ARCH),mips mipsle),$(if $(CONFIG_HAS_FPU),hardfloat,softfloat),)
  48. # -fno-plt: causes "unexpected GOT reloc for non-dynamic symbol" errors
  49. # -mips32r2: conflicts with -march=mips32 set by go
  50. GO_CFLAGS_TO_REMOVE:=$(if \
  51. $(filter $(GO_ARCH),386),-fno-plt,$(if \
  52. $(filter $(GO_ARCH),mips mipsle),-mips32r2,))
  53. # mips64 / mips64el doesn't have softfloat support yet
  54. # https://github.com/golang/go/issues/14635
  55. GO_ARCH_DEPENDS:=@(aarch64||arm||i386||i686||mips||mipsel||powerpc64||x86_64)
  56. GO_TARGET_PREFIX:=/usr
  57. GO_TARGET_VERSION_ID:=$(GO_VERSION_MAJOR_MINOR)
  58. GO_TARGET_ROOT:=$(GO_TARGET_PREFIX)/lib/go-$(GO_TARGET_VERSION_ID)