"Fossies" - the Fresh Open Source Software Archive

Member "buildroot-2021.05/package/go/go.mk" (6 Jun 2021, 4696 Bytes) of package /linux/privat/buildroot-2021.05.tar.bz2:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Make source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes reports for "go.mk": 2021.05-rc3_vs_2021.05 or 2021.02.2_vs_2021.05.

    1 ################################################################################
    2 #
    3 # go
    4 #
    5 ################################################################################
    6 
    7 GO_VERSION = 1.16.5
    8 GO_SITE = https://storage.googleapis.com/golang
    9 GO_SOURCE = go$(GO_VERSION).src.tar.gz
   10 
   11 GO_LICENSE = BSD-3-Clause
   12 GO_LICENSE_FILES = LICENSE
   13 GO_CPE_ID_VENDOR = golang
   14 
   15 HOST_GO_DEPENDENCIES = host-go-bootstrap
   16 HOST_GO_GOPATH = $(HOST_DIR)/usr/share/go-path
   17 HOST_GO_HOST_CACHE = $(HOST_DIR)/usr/share/host-go-cache
   18 HOST_GO_ROOT = $(HOST_DIR)/lib/go
   19 HOST_GO_TARGET_CACHE = $(HOST_DIR)/usr/share/go-cache
   20 
   21 # We pass an empty GOBIN, otherwise "go install: cannot install
   22 # cross-compiled binaries when GOBIN is set"
   23 HOST_GO_COMMON_ENV = \
   24     GO111MODULE=on \
   25     GOFLAGS=-mod=vendor \
   26     GOROOT="$(HOST_GO_ROOT)" \
   27     GOPATH="$(HOST_GO_GOPATH)" \
   28     GOPROXY=off \
   29     PATH=$(BR_PATH) \
   30     GOBIN= \
   31     CGO_ENABLED=$(HOST_GO_CGO_ENABLED)
   32 
   33 ifeq ($(BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS),y)
   34 
   35 ifeq ($(BR2_arm),y)
   36 GO_GOARCH = arm
   37 ifeq ($(BR2_ARM_CPU_ARMV5),y)
   38 GO_GOARM = 5
   39 else ifeq ($(BR2_ARM_CPU_ARMV6),y)
   40 GO_GOARM = 6
   41 else ifeq ($(BR2_ARM_CPU_ARMV7A),y)
   42 GO_GOARM = 7
   43 else ifeq ($(BR2_ARM_CPU_ARMV8A),y)
   44 # Go doesn't support 32-bit GOARM=8 (https://github.com/golang/go/issues/29373)
   45 # but can still benefit from armv7 optimisations
   46 GO_GOARM = 7
   47 endif
   48 else ifeq ($(BR2_aarch64),y)
   49 GO_GOARCH = arm64
   50 else ifeq ($(BR2_i386),y)
   51 GO_GOARCH = 386
   52 # i386: use softfloat if no SSE2: https://golang.org/doc/go1.16#386
   53 ifneq ($(BR2_X86_CPU_HAS_SSE2),y)
   54 GO_GO386 = softfloat
   55 endif
   56 else ifeq ($(BR2_x86_64),y)
   57 GO_GOARCH = amd64
   58 else ifeq ($(BR2_powerpc64),y)
   59 GO_GOARCH = ppc64
   60 else ifeq ($(BR2_powerpc64le),y)
   61 GO_GOARCH = ppc64le
   62 else ifeq ($(BR2_mips64),y)
   63 GO_GOARCH = mips64
   64 else ifeq ($(BR2_mips64el),y)
   65 GO_GOARCH = mips64le
   66 else ifeq ($(BR2_s390x),y)
   67 GO_GOARCH = s390x
   68 endif
   69 
   70 # For the convienience of target packages.
   71 HOST_GO_TOOLDIR = $(HOST_GO_ROOT)/pkg/tool/linux_$(GO_GOARCH)
   72 HOST_GO_TARGET_ENV = \
   73     $(HOST_GO_COMMON_ENV) \
   74     GOARCH=$(GO_GOARCH) \
   75     GOCACHE="$(HOST_GO_TARGET_CACHE)" \
   76     CC="$(TARGET_CC)" \
   77     CXX="$(TARGET_CXX)" \
   78     CGO_CFLAGS="$(TARGET_CFLAGS)" \
   79     CGO_CXXFLAGS="$(TARGET_CXXFLAGS)" \
   80     CGO_LDFLAGS="$(TARGET_LDFLAGS)" \
   81     GOTOOLDIR="$(HOST_GO_TOOLDIR)"
   82 
   83 # The go compiler's cgo support uses threads.  If BR2_TOOLCHAIN_HAS_THREADS is
   84 # set, build in cgo support for any go programs that may need it.  Note that
   85 # any target package needing cgo support must include
   86 # 'depends on BR2_TOOLCHAIN_HAS_THREADS' in its config file.
   87 ifeq ($(BR2_TOOLCHAIN_HAS_THREADS),y)
   88 HOST_GO_CGO_ENABLED = 1
   89 else
   90 HOST_GO_CGO_ENABLED = 0
   91 endif
   92 
   93 HOST_GO_CROSS_ENV = \
   94     CC_FOR_TARGET="$(TARGET_CC)" \
   95     CXX_FOR_TARGET="$(TARGET_CXX)" \
   96     GOARCH=$(GO_GOARCH) \
   97     $(if $(GO_GO386),GO386=$(GO_GO386)) \
   98     $(if $(GO_GOARM),GOARM=$(GO_GOARM)) \
   99     GO_ASSUME_CROSSCOMPILING=1
  100 
  101 else # !BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS
  102 # host-go can still be used to build packages for the host. No need to set all
  103 # the arch stuff since we will not be cross-compiling.
  104 HOST_GO_CGO_ENABLED = 1
  105 endif # BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS
  106 
  107 # For the convenience of host golang packages
  108 HOST_GO_HOST_ENV = \
  109     $(HOST_GO_COMMON_ENV) \
  110     GOARCH="" \
  111     GOCACHE="$(HOST_GO_HOST_CACHE)" \
  112     CC="$(HOSTCC_NOCCACHE)" \
  113     CXX="$(HOSTCXX_NOCCACHE)" \
  114     CGO_CFLAGS="$(HOST_CFLAGS)" \
  115     CGO_CXXFLAGS="$(HOST_CXXFLAGS)" \
  116     CGO_LDFLAGS="$(HOST_LDFLAGS)"
  117 
  118 # The go build system is not compatible with ccache, so use
  119 # HOSTCC_NOCCACHE.  See https://github.com/golang/go/issues/11685.
  120 HOST_GO_MAKE_ENV = \
  121     GO111MODULE=off \
  122     GOCACHE=$(HOST_GO_HOST_CACHE) \
  123     GOROOT_BOOTSTRAP=$(HOST_GO_BOOTSTRAP_ROOT) \
  124     GOROOT_FINAL=$(HOST_GO_ROOT) \
  125     GOROOT="$(@D)" \
  126     GOBIN="$(@D)/bin" \
  127     GOOS=linux \
  128     CC=$(HOSTCC_NOCCACHE) \
  129     CXX=$(HOSTCXX_NOCCACHE) \
  130     CGO_ENABLED=$(HOST_GO_CGO_ENABLED) \
  131     $(HOST_GO_CROSS_ENV)
  132 
  133 define HOST_GO_BUILD_CMDS
  134     cd $(@D)/src && \
  135         $(HOST_GO_MAKE_ENV) ./make.bash $(if $(VERBOSE),-v)
  136 endef
  137 
  138 define HOST_GO_INSTALL_CMDS
  139     $(INSTALL) -D -m 0755 $(@D)/bin/go $(HOST_GO_ROOT)/bin/go
  140     $(INSTALL) -D -m 0755 $(@D)/bin/gofmt $(HOST_GO_ROOT)/bin/gofmt
  141 
  142     ln -sf ../lib/go/bin/go $(HOST_DIR)/bin/
  143     ln -sf ../lib/go/bin/gofmt $(HOST_DIR)/bin/
  144 
  145     cp -a $(@D)/lib $(HOST_GO_ROOT)/
  146 
  147     mkdir -p $(HOST_GO_ROOT)/pkg
  148     cp -a $(@D)/pkg/include $(@D)/pkg/linux_* $(HOST_GO_ROOT)/pkg/
  149     cp -a $(@D)/pkg/tool $(HOST_GO_ROOT)/pkg/
  150 
  151     # There is a known issue which requires the go sources to be installed
  152     # https://golang.org/issue/2775
  153     cp -a $(@D)/src $(HOST_GO_ROOT)/
  154 
  155     # Set all file timestamps to prevent the go compiler from rebuilding any
  156     # built in packages when programs are built.
  157     find $(HOST_GO_ROOT) -type f -exec touch -r $(@D)/bin/go {} \;
  158 endef
  159 
  160 $(eval $(host-generic-package))