2 # Copyright (C) 2018, 2020-2021, 2023 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-values.mk
15 # $(1) valid GOOS_GOARCH combinations
17 define GoCompiler
/Default
/CheckHost
18 $(if
$(filter $(GO_HOST_OS_ARCH
),$(1)),,$(error go-
$(2) cannot be installed on
$(GO_HOST_OS
)/$(GO_HOST_ARCH
)))
22 # $(2) destination prefix
24 # $(4) additional environment variables (optional)
25 define GoCompiler
/Default
/Make
28 $(if
$(2),GOROOT_FINAL
="$(2)/lib/go-$(3)") \
31 $(if
$(findstring s
,$(OPENWRT_VERBOSE
)),-v
) \
37 # $(1) destination prefix
39 define GoCompiler
/Default
/Install
/make-dirs
40 $(INSTALL_DIR
) "$(1)/lib/go-$(2)"
41 $(INSTALL_DIR
) "$(1)/share/go-$(2)"
45 # $(2) destination prefix
47 # $(4) file/directory name
48 define GoCompiler
/Default
/Install
/install-share-data
49 $(CP
) "$(1)/$(4)" "$(2)/share/go-$(3)/"
50 $(LN
) "../../share/go-$(3)/$(4)" "$(2)/lib/go-$(3)/"
54 # $(2) destination prefix
57 # $(5) install suffix (optional)
58 define GoCompiler
/Default
/Install
/Bin
59 $(call GoCompiler
/Default
/Install
/make-dirs
,$(2),$(3))
61 $(call GoCompiler
/Default
/Install
/install-share-data
,$(1),$(2),$(3),api
)
63 $(INSTALL_DATA
) -p
"$(1)/go.env" "$(2)/lib/go-$(3)/"
64 $(INSTALL_DATA
) -p
"$(1)/VERSION" "$(2)/lib/go-$(3)/"
66 for file in CONTRIBUTING.md LICENSE PATENTS README.md SECURITY.md
; do \
67 if
[ -f
"$(1)/$$$$file" ]; then \
68 $(INSTALL_DATA
) -p
"$(1)/$$$$file" "$(2)/share/go-$(3)/" ; \
72 $(INSTALL_DIR
) "$(2)/lib/go-$(3)/bin"
74 ifeq ($(4),$(GO_HOST_OS_ARCH
))
75 $(INSTALL_BIN
) -p
"$(1)/bin"/* "$(2)/lib/go-$(3)/bin/"
77 $(INSTALL_BIN
) -p
"$(1)/bin/$(4)"/* "$(2)/lib/go-$(3)/bin/"
80 if
[ -d
"$(1)/pkg/$(4)$(if $(5),_$(5))" ]; then \
81 $(INSTALL_DIR
) "$(2)/lib/go-$(3)/pkg" ; \
82 $(CP
) "$(1)/pkg/$(4)$(if $(5),_$(5))" "$(2)/lib/go-$(3)/pkg/" ; \
85 $(INSTALL_DIR
) "$(2)/lib/go-$(3)/pkg/tool/$(4)"
86 $(INSTALL_BIN
) -p
"$(1)/pkg/tool/$(4)"/* "$(2)/lib/go-$(3)/pkg/tool/$(4)/"
89 # $(1) destination prefix
91 define GoCompiler
/Default
/Install
/BinLinks
92 $(INSTALL_DIR
) "$(1)/bin"
93 $(LN
) "../lib/go-$(2)/bin/go" "$(1)/bin/go"
94 $(LN
) "../lib/go-$(2)/bin/gofmt" "$(1)/bin/gofmt"
98 # $(2) destination prefix
100 define GoCompiler
/Default
/Install
/Doc
101 $(call GoCompiler
/Default
/Install
/make-dirs
,$(2),$(3))
103 $(call GoCompiler
/Default
/Install
/install-share-data
,$(1),$(2),$(3),doc
)
106 # $(1) source go root
107 # $(2) destination prefix
109 define GoCompiler
/Default
/Install
/Src
110 $(call GoCompiler
/Default
/Install
/make-dirs
,$(2),$(3))
112 $(call GoCompiler
/Default
/Install
/install-share-data
,$(1),$(2),$(3),lib
)
113 $(call GoCompiler
/Default
/Install
/install-share-data
,$(1),$(2),$(3),misc
)
114 $(call GoCompiler
/Default
/Install
/install-share-data
,$(1),$(2),$(3),src
)
115 $(call GoCompiler
/Default
/Install
/install-share-data
,$(1),$(2),$(3),test)
118 "$(2)/share/go-$(3)/src/" \
119 \
! -type d
-a \
( -name
"*.bat" -o
-name
"*.rc" \
) \
122 if
[ -d
"$(1)/pkg/include" ]; then \
123 $(INSTALL_DIR
) "$(2)/lib/go-$(3)/pkg" ; \
124 $(INSTALL_DIR
) "$(2)/share/go-$(3)/pkg" ; \
125 $(CP
) "$(1)/pkg/include" "$(2)/share/go-$(3)/pkg/" ; \
126 $(LN
) "../../../share/go-$(3)/pkg/include" "$(2)/lib/go-$(3)/pkg/" ; \
130 # $(1) destination prefix
132 define GoCompiler
/Default
/Uninstall
133 rm -rf
"$(1)/lib/go-$(2)"
134 rm -rf
"$(1)/share/go-$(2)"
137 # $(1) destination prefix
138 define GoCompiler
/Default
/Uninstall
/BinLinks
140 rm -f
"$(1)/bin/gofmt"
145 # $(2) source go root
146 # $(3) destination prefix
149 # $(6) install suffix (optional)
150 define GoCompiler
/AddProfile
152 # $$(1) valid GOOS_GOARCH combinations
153 define GoCompiler
/$(1)/CheckHost
154 $$(call GoCompiler
/Default
/CheckHost
,$$(1),$(4))
157 # $$(1) additional environment variables (optional)
158 define GoCompiler
/$(1)/Make
159 $$(call GoCompiler
/Default
/Make
,$(2),$(3),$(4),$$(1))
162 # $$(1) override install prefix (optional)
163 define GoCompiler
/$(1)/Install
/Bin
164 $$(call GoCompiler
/Default
/Install
/Bin
,$(2),$$(or
$$(1),$(3)),$(4),$(5),$(6))
167 # $$(1) override install prefix (optional)
168 define GoCompiler
/$(1)/Install
/BinLinks
169 $$(call GoCompiler
/Default
/Install
/BinLinks
,$$(or
$$(1),$(3)),$(4))
172 # $$(1) override install prefix (optional)
173 define GoCompiler
/$(1)/Install
/Doc
174 $$(call GoCompiler
/Default
/Install
/Doc
,$(2),$$(or
$$(1),$(3)),$(4))
177 # $$(1) override install prefix (optional)
178 define GoCompiler
/$(1)/Install
/Src
179 $$(call GoCompiler
/Default
/Install
/Src
,$(2),$$(or
$$(1),$(3)),$(4))
182 # $$(1) override install prefix (optional)
183 define GoCompiler
/$(1)/Uninstall
184 $$(call GoCompiler
/Default
/Uninstall
,$$(or
$$(1),$(3)),$(4))
187 # $$(1) override install prefix (optional)
188 define GoCompiler
/$(1)/Uninstall
/BinLinks
189 $$(call GoCompiler
/Default
/Uninstall
/BinLinks
,$$(or
$$(1),$(3)))