Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 
 

59 wiersze
1.8 KiB

  1. # Constants
  2. MK_FILE_PATH = $(lastword $(MAKEFILE_LIST))
  3. PRJ_DIR = $(abspath $(dir $(MK_FILE_PATH))/..)
  4. DEV_DIR = $(PRJ_DIR)/_dev
  5. # Results will be produced in this directory (can be provided by a caller)
  6. BUILD_DIR ?= $(PRJ_DIR)/_dev/GOROOT
  7. # Compiler
  8. GO ?= go
  9. # Build environment
  10. OS ?= $(shell $(GO) env GOHOSTOS)
  11. ARCH ?= $(shell $(GO) env GOHOSTARCH)
  12. OS_ARCH := $(OS)_$(ARCH)
  13. VER_OS_ARCH := $(shell $(GO) version | cut -d' ' -f 3)_$(OS)_$(ARCH)
  14. GOROOT_ENV := $(shell $(GO) env GOROOT)
  15. GOROOT_LOCAL = $(BUILD_DIR)/$(OS_ARCH)
  16. # Flag indicates wheter invoke "go install -race std". Supported only on amd64 with CGO enabled
  17. INSTALL_RACE:= $(words $(filter $(ARCH)_$(shell go env CGO_ENABLED), amd64_1))
  18. # TODO: I'm not sure why we would remove it at the end
  19. # but I comment this code as tls.a is exactly what
  20. # I try to build here
  21. #GOROOT: GOROOT/$(OS_ARCH)/.ok_$(VER_OS_ARCH)
  22. # rm -f GOROOT/$(OS_ARCH)/pkg/*/crypto/tls.a
  23. $(BUILD_DIR)/$(OS_ARCH)/.ok_$(VER_OS_ARCH): clean
  24. # Create clean directory structure
  25. mkdir -p "$(GOROOT_LOCAL)/pkg"
  26. # Copy src/tools from system GOROOT
  27. cp -r $(GOROOT_ENV)/src $(GOROOT_LOCAL)/src
  28. cp -r $(GOROOT_ENV)/pkg/include $(GOROOT_LOCAL)/pkg/include
  29. cp -r $(GOROOT_ENV)/pkg/tool $(GOROOT_LOCAL)/pkg/tool
  30. # Swap TLS implementation
  31. rm -r $(GOROOT_LOCAL)/src/crypto/tls/*
  32. rsync -a $(PRJ_DIR)/ $(GOROOT_LOCAL)/src/crypto/tls/ --exclude=$(lastword $(subst /, ,$(DEV_DIR)))
  33. # Apply additional patches
  34. for p in $(wildcard $(DEV_DIR)/patches/*); do patch -d "$(GOROOT_LOCAL)" -p1 < "$$p"; done
  35. # Create go package
  36. GOARCH=$(ARCH) GOROOT="$(GOROOT_LOCAL)" $(GO) install -v std
  37. ifeq ($(INSTALL_RACE),1)
  38. GOARCH=$(ARCH) GOROOT="$(GOROOT_LOCAL)" $(GO) install -race -v std
  39. endif
  40. @touch "$@"
  41. clean:
  42. rm -rf $(BUILD_DIR)/$(OS_ARCH)
  43. clean-all:
  44. rm -rf $(BUILD_DIR)
  45. # PHONY targets
  46. .PHONY: $(BUILD_DIR) clean