Browse Source

golang: Reorganize GoPackage/Environment and Makefile variables

* Move more environment variables into GoPackage/Environment
* Split GoPackage/Environment into target and build sections
* Do not set GOROOT_FINAL for Go packages (setting it should only affect
  the Go compiler and not Go packages)
* Set CGO_LDFLAGS to $(TARGET_LDFLAGS)
* Move GO_TARGET_* variables from golang-values.mk, and GO_VERSION_*
  variables from golang-version.mk, into golang/Makefile

This also updates runc, containerd, and docker-ce to reflect the changes
in GoPackage/Environment.

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
lilik-openwrt-22.03
Jeffery To 5 years ago
parent
commit
89d3f0ab54
7 changed files with 37 additions and 63 deletions
  1. +17
    -9
      lang/golang/golang-package.mk
  2. +0
    -6
      lang/golang/golang-values.mk
  3. +0
    -14
      lang/golang/golang-version.mk
  4. +14
    -8
      lang/golang/golang/Makefile
  5. +2
    -9
      utils/containerd/Makefile
  6. +2
    -8
      utils/docker-ce/Makefile
  7. +2
    -9
      utils/runc/Makefile

+ 17
- 9
lang/golang/golang-package.mk View File

@ -165,7 +165,7 @@ define GoPackage/GoSubMenu
CATEGORY:=Languages CATEGORY:=Languages
endef endef
define GoPackage/Environment/Default
define GoPackage/Environment/Target
GOOS=$(GO_OS) \ GOOS=$(GO_OS) \
GOARCH=$(GO_ARCH) \ GOARCH=$(GO_ARCH) \
GO386=$(GO_386) \ GO386=$(GO_386) \
@ -173,9 +173,23 @@ define GoPackage/Environment/Default
GOMIPS=$(GO_MIPS) \ GOMIPS=$(GO_MIPS) \
GOMIPS64=$(GO_MIPS64) \ GOMIPS64=$(GO_MIPS64) \
CGO_ENABLED=1 \ CGO_ENABLED=1 \
CC=$(TARGET_CC) \
CXX=$(TARGET_CXX) \
CGO_CFLAGS="$(filter-out $(GO_CFLAGS_TO_REMOVE),$(TARGET_CFLAGS))" \ CGO_CFLAGS="$(filter-out $(GO_CFLAGS_TO_REMOVE),$(TARGET_CFLAGS))" \
CGO_CPPFLAGS="$(TARGET_CPPFLAGS)" \ CGO_CPPFLAGS="$(TARGET_CPPFLAGS)" \
CGO_CXXFLAGS="$(filter-out $(GO_CFLAGS_TO_REMOVE),$(TARGET_CXXFLAGS))"
CGO_CXXFLAGS="$(filter-out $(GO_CFLAGS_TO_REMOVE),$(TARGET_CXXFLAGS))" \
CGO_LDFLAGS="$(TARGET_LDFLAGS)"
endef
define GoPackage/Environment/Build
GOPATH=$(GO_PKG_BUILD_DIR) \
GOCACHE=$(GO_PKG_CACHE_DIR) \
GOENV=off
endef
define GoPackage/Environment/Default
$(call GoPackage/Environment/Target) \
$(call GoPackage/Environment/Build)
endef endef
GoPackage/Environment=$(call GoPackage/Environment/Default) GoPackage/Environment=$(call GoPackage/Environment/Default)
@ -264,13 +278,7 @@ endef
define GoPackage/Build/Compile define GoPackage/Build/Compile
( \ ( \
cd $(GO_PKG_BUILD_DIR) ; \ cd $(GO_PKG_BUILD_DIR) ; \
export GOPATH=$(GO_PKG_BUILD_DIR) \
GOCACHE=$(GO_PKG_CACHE_DIR) \
GOENV=off \
GOROOT_FINAL=$(GO_TARGET_ROOT) \
CC=$(TARGET_CC) \
CXX=$(TARGET_CXX) \
$(call GoPackage/Environment) ; \
export $(call GoPackage/Environment) ; \
\ \
echo "Finding targets" ; \ echo "Finding targets" ; \
targets=$$$$(go list $(GO_PKG_BUILD_PKG)) ; \ targets=$$$$(go list $(GO_PKG_BUILD_PKG)) ; \


+ 0
- 6
lang/golang/golang-values.mk View File

@ -9,8 +9,6 @@ ifeq ($(origin GO_INCLUDE_DIR),undefined)
GO_INCLUDE_DIR:=$(dir $(lastword $(MAKEFILE_LIST))) GO_INCLUDE_DIR:=$(dir $(lastword $(MAKEFILE_LIST)))
endif endif
include $(GO_INCLUDE_DIR)/golang-version.mk
# Unset environment variables # Unset environment variables
# There are more magic variables to track down, but ain't nobody got time for that # There are more magic variables to track down, but ain't nobody got time for that
@ -209,10 +207,6 @@ endif
GO_ARCH_DEPENDS:=@(aarch64||arm||i386||i686||mips||mips64||mips64el||mipsel||powerpc64||x86_64) GO_ARCH_DEPENDS:=@(aarch64||arm||i386||i686||mips||mips64||mips64el||mipsel||powerpc64||x86_64)
GO_TARGET_PREFIX:=/usr
GO_TARGET_VERSION_ID:=$(GO_VERSION_MAJOR_MINOR)
GO_TARGET_ROOT:=$(GO_TARGET_PREFIX)/lib/go-$(GO_TARGET_VERSION_ID)
# ASLR/PIE # ASLR/PIE


+ 0
- 14
lang/golang/golang-version.mk View File

@ -1,14 +0,0 @@
#
# Copyright (C) 2018 Jeffery To
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
ifeq ($(origin GO_INCLUDE_DIR),undefined)
GO_INCLUDE_DIR:=$(dir $(lastword $(MAKEFILE_LIST)))
endif
GO_VERSION_MAJOR_MINOR:=1.13
GO_VERSION_PATCH:=7

+ 14
- 8
lang/golang/golang/Makefile View File

@ -6,7 +6,9 @@
# #
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
include ../golang-version.mk
GO_VERSION_MAJOR_MINOR:=1.13
GO_VERSION_PATCH:=7
PKG_NAME:=golang PKG_NAME:=golang
PKG_VERSION:=$(GO_VERSION_MAJOR_MINOR)$(if $(GO_VERSION_PATCH),.$(GO_VERSION_PATCH)) PKG_VERSION:=$(GO_VERSION_MAJOR_MINOR)$(if $(GO_VERSION_PATCH),.$(GO_VERSION_PATCH))
@ -34,6 +36,10 @@ PKG_GO_WORK_DIR:=$(PKG_BUILD_DIR)/.go_work
PKG_GO_HOST_CACHE_DIR:=$(PKG_GO_WORK_DIR)/host_cache PKG_GO_HOST_CACHE_DIR:=$(PKG_GO_WORK_DIR)/host_cache
PKG_GO_TARGET_CACHE_DIR:=$(PKG_GO_WORK_DIR)/target_cache PKG_GO_TARGET_CACHE_DIR:=$(PKG_GO_WORK_DIR)/target_cache
PKG_GO_PREFIX:=/usr
PKG_GO_VERSION_ID:=$(GO_VERSION_MAJOR_MINOR)
PKG_GO_ROOT:=$(PKG_GO_PREFIX)/lib/go-$(PKG_GO_VERSION_ID)
HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/go-$(PKG_VERSION) HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/go-$(PKG_VERSION)
HOST_BUILD_PARALLEL:=1 HOST_BUILD_PARALLEL:=1
@ -178,7 +184,7 @@ $(eval $(call Download,golang-bootstrap))
$(eval $(call GoCompiler/AddProfile,Bootstrap,$(BOOTSTRAP_BUILD_DIR),,bootstrap,$(GO_HOST_OS_ARCH))) $(eval $(call GoCompiler/AddProfile,Bootstrap,$(BOOTSTRAP_BUILD_DIR),,bootstrap,$(GO_HOST_OS_ARCH)))
$(eval $(call GoCompiler/AddProfile,Host,$(HOST_BUILD_DIR),$(HOST_GO_PREFIX),$(HOST_GO_VERSION_ID),$(GO_HOST_OS_ARCH),$(HOST_GO_INSTALL_SUFFIX))) $(eval $(call GoCompiler/AddProfile,Host,$(HOST_BUILD_DIR),$(HOST_GO_PREFIX),$(HOST_GO_VERSION_ID),$(GO_HOST_OS_ARCH),$(HOST_GO_INSTALL_SUFFIX)))
$(eval $(call GoCompiler/AddProfile,Package,$(PKG_BUILD_DIR),$(GO_TARGET_PREFIX),$(GO_TARGET_VERSION_ID),$(GO_OS_ARCH),$(PKG_GO_INSTALL_SUFFIX)))
$(eval $(call GoCompiler/AddProfile,Package,$(PKG_BUILD_DIR),$(PKG_GO_PREFIX),$(PKG_GO_VERSION_ID),$(GO_OS_ARCH),$(PKG_GO_INSTALL_SUFFIX)))
define Host/Prepare define Host/Prepare
$(call Host/Prepare/Default) $(call Host/Prepare/Default)
@ -278,8 +284,9 @@ define Build/Compile
( \ ( \
cd $(PKG_BUILD_DIR)/bin ; \ cd $(PKG_BUILD_DIR)/bin ; \
export $(call GoPackage/Environment/Target) ; \
$(CP) go go-host ; \ $(CP) go go-host ; \
GOROOT_FINAL=$(GO_TARGET_ROOT) \
GOROOT_FINAL=$(PKG_GO_ROOT) \
GOCACHE=$(PKG_GO_TARGET_CACHE_DIR) \ GOCACHE=$(PKG_GO_TARGET_CACHE_DIR) \
GOENV=off \ GOENV=off \
GO_GCC_HELPER_CC="$(TARGET_CC)" \ GO_GCC_HELPER_CC="$(TARGET_CC)" \
@ -289,7 +296,6 @@ define Build/Compile
CXX=g++ \ CXX=g++ \
PKG_CONFIG=pkg-config \ PKG_CONFIG=pkg-config \
PATH=$(HOST_GO_ROOT)/openwrt:$$$$PATH \ PATH=$(HOST_GO_ROOT)/openwrt:$$$$PATH \
$(call GoPackage/Environment) \
./go-host install -a $(if $(PKG_GO_ENABLE_PIE),-buildmode=pie) std cmd ; \ ./go-host install -a $(if $(PKG_GO_ENABLE_PIE),-buildmode=pie) std cmd ; \
retval=$$$$? ; \ retval=$$$$? ; \
rm -f go-host ; \ rm -f go-host ; \
@ -298,16 +304,16 @@ define Build/Compile
endef endef
define Package/golang/install define Package/golang/install
$(call GoCompiler/Package/Install/Bin,$(1)$(GO_TARGET_PREFIX))
$(call GoCompiler/Package/Install/BinLinks,$(1)$(GO_TARGET_PREFIX))
$(call GoCompiler/Package/Install/Bin,$(1)$(PKG_GO_PREFIX))
$(call GoCompiler/Package/Install/BinLinks,$(1)$(PKG_GO_PREFIX))
endef endef
define Package/golang-doc/install define Package/golang-doc/install
$(call GoCompiler/Package/Install/Doc,$(1)$(GO_TARGET_PREFIX))
$(call GoCompiler/Package/Install/Doc,$(1)$(PKG_GO_PREFIX))
endef endef
define Package/golang-src/install define Package/golang-src/install
$(call GoCompiler/Package/Install/Src,$(1)$(GO_TARGET_PREFIX))
$(call GoCompiler/Package/Install/Src,$(1)$(PKG_GO_PREFIX))
endef endef
# src/debug contains ELF executables as test data # src/debug contains ELF executables as test data


+ 2
- 9
utils/containerd/Makefile View File

@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=containerd PKG_NAME:=containerd
PKG_VERSION:=1.2.10 PKG_VERSION:=1.2.10
PKG_RELEASE:=2
PKG_RELEASE:=3
PKG_LICENSE:=Apache-2.0 PKG_LICENSE:=Apache-2.0
PKG_LICENSE_FILES:=LICENSE PKG_LICENSE_FILES:=LICENSE
@ -49,14 +49,7 @@ endef
GO_PKG_INSTALL_ALL:=1 GO_PKG_INSTALL_ALL:=1
MAKE_PATH:=$(GO_PKG_WORK_DIR_NAME)/build/src/$(GO_PKG) MAKE_PATH:=$(GO_PKG_WORK_DIR_NAME)/build/src/$(GO_PKG)
MAKE_VARS += \
GOPATH=$(GO_PKG_BUILD_DIR) \
GOCACHE=$(GO_PKG_CACHE_DIR) \
GOTMPDIR=$(GO_PKG_TMP_DIR) \
GOROOT_FINAL=$(GO_TARGET_ROOT) \
CC=$(TARGET_CC) \
CXX=$(TARGET_CXX) \
$(call GoPackage/Environment)
MAKE_VARS += $(call GoPackage/Environment)
MAKE_FLAGS += \ MAKE_FLAGS += \
DESTDIR="$(PKG_INSTALL_DIR)" \ DESTDIR="$(PKG_INSTALL_DIR)" \
VERSION=$(PKG_VERSION) \ VERSION=$(PKG_VERSION) \


+ 2
- 8
utils/docker-ce/Makefile View File

@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=docker-ce PKG_NAME:=docker-ce
PKG_VERSION:=19.03.5 PKG_VERSION:=19.03.5
PKG_RELEASE:=1
PKG_RELEASE:=2
PKG_LICENSE:=Apache-2.0 PKG_LICENSE:=Apache-2.0
PKG_LICENSE_FILES:=components/cli/LICENSE components/engine/LICENSE PKG_LICENSE_FILES:=components/cli/LICENSE components/engine/LICENSE
@ -78,13 +78,7 @@ endif
define Build/Compile define Build/Compile
( \ ( \
export GOPATH=$(GO_PKG_BUILD_DIR) \
GOCACHE=$(GO_PKG_CACHE_DIR) \
GOTMPDIR=$(GO_PKG_TMP_DIR) \
GOROOT_FINAL=$(GO_TARGET_ROOT) \
CC=$(TARGET_CC) \
CXX=$(TARGET_CXX) \
$(call GoPackage/Environment) \
export $(call GoPackage/Environment) \
GITCOMMIT=$(PKG_SOURCE_VERSION) \ GITCOMMIT=$(PKG_SOURCE_VERSION) \
DOCKER_GITCOMMIT=$(PKG_SOURCE_VERSION) \ DOCKER_GITCOMMIT=$(PKG_SOURCE_VERSION) \
DOCKER_BUILDTAGS='$(BUILDTAGS)' \ DOCKER_BUILDTAGS='$(BUILDTAGS)' \


+ 2
- 9
utils/runc/Makefile View File

@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=runc PKG_NAME:=runc
PKG_VERSION:=1.0.0-rc8+91-3e425f80 PKG_VERSION:=1.0.0-rc8+91-3e425f80
PKG_RELEASE:=2
PKG_RELEASE:=3
PKG_LICENSE:=Apache-2.0 PKG_LICENSE:=Apache-2.0
PKG_LICENSE_FILES:=LICENSE PKG_LICENSE_FILES:=LICENSE
@ -51,14 +51,7 @@ endef
GO_PKG_INSTALL_ALL:=1 GO_PKG_INSTALL_ALL:=1
MAKE_PATH:=$(GO_PKG_WORK_DIR_NAME)/build/src/$(GO_PKG) MAKE_PATH:=$(GO_PKG_WORK_DIR_NAME)/build/src/$(GO_PKG)
MAKE_VARS += \
GOPATH=$(GO_PKG_BUILD_DIR) \
GOCACHE=$(GO_PKG_CACHE_DIR) \
GOTMPDIR=$(GO_PKG_TMP_DIR) \
GOROOT_FINAL=$(GO_TARGET_ROOT) \
CC=$(TARGET_CC) \
CXX=$(TARGET_CXX) \
$(call GoPackage/Environment)
MAKE_VARS += $(call GoPackage/Environment)
MAKE_FLAGS += \ MAKE_FLAGS += \
COMMIT=$(PKG_SOURCE_VERSION) COMMIT=$(PKG_SOURCE_VERSION)


Loading…
Cancel
Save