2 # Copyright (C) 2018, 2020 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)/VERSION" "$(2)/lib/go-$(3)/"
65 for file in AUTHORS CONTRIBUTING.md CONTRIBUTORS LICENSE PATENTS README.md SECURITY.md
; do \
66 if
[ -f
"$(1)/$$$$file" ]; then \
67 $(INSTALL_DATA
) -p
"$(1)/$$$$file" "$(2)/share/go-$(3)/" ; \
71 $(INSTALL_DIR
) "$(2)/lib/go-$(3)/bin"
73 ifeq ($(4),$(GO_HOST_OS_ARCH
))
74 $(INSTALL_BIN
) -p
"$(1)/bin"/* "$(2)/lib/go-$(3)/bin/"
76 $(INSTALL_BIN
) -p
"$(1)/bin/$(4)"/* "$(2)/lib/go-$(3)/bin/"
79 $(INSTALL_DIR
) "$(2)/lib/go-$(3)/pkg"
80 $(CP
) "$(1)/pkg/$(4)$(if $(5),_$(5))" "$(2)/lib/go-$(3)/pkg/"
82 $(INSTALL_DIR
) "$(2)/lib/go-$(3)/pkg/tool/$(4)"
83 $(INSTALL_BIN
) -p
"$(1)/pkg/tool/$(4)"/* "$(2)/lib/go-$(3)/pkg/tool/$(4)/"
86 # $(1) destination prefix
88 define GoCompiler
/Default
/Install
/BinLinks
89 $(INSTALL_DIR
) "$(1)/bin"
90 $(LN
) "../lib/go-$(2)/bin/go" "$(1)/bin/go"
91 $(LN
) "../lib/go-$(2)/bin/gofmt" "$(1)/bin/gofmt"
95 # $(2) destination prefix
97 define GoCompiler
/Default
/Install
/Doc
98 $(call GoCompiler
/Default
/Install
/make-dirs
,$(2),$(3))
100 $(call GoCompiler
/Default
/Install
/install-share-data
,$(1),$(2),$(3),doc
)
103 # $(1) source go root
104 # $(2) destination prefix
106 define GoCompiler
/Default
/Install
/Src
107 $(call GoCompiler
/Default
/Install
/make-dirs
,$(2),$(3))
109 $(call GoCompiler
/Default
/Install
/install-share-data
,$(1),$(2),$(3),lib
)
110 $(call GoCompiler
/Default
/Install
/install-share-data
,$(1),$(2),$(3),misc
)
111 $(call GoCompiler
/Default
/Install
/install-share-data
,$(1),$(2),$(3),src
)
112 $(call GoCompiler
/Default
/Install
/install-share-data
,$(1),$(2),$(3),test)
115 "$(2)/share/go-$(3)/src/" \
116 \
! -type d
-a \
( -name
"*.bat" -o
-name
"*.rc" \
) \
119 if
[ -d
"$(1)/pkg/include" ]; then \
120 $(INSTALL_DIR
) "$(2)/lib/go-$(3)/pkg" ; \
121 $(INSTALL_DIR
) "$(2)/share/go-$(3)/pkg" ; \
122 $(CP
) "$(1)/pkg/include" "$(2)/share/go-$(3)/pkg/" ; \
123 $(LN
) "../../../share/go-$(3)/pkg/include" "$(2)/lib/go-$(3)/pkg/" ; \
127 # $(1) destination prefix
129 define GoCompiler
/Default
/Uninstall
130 rm -rf
"$(1)/lib/go-$(2)"
131 rm -rf
"$(1)/share/go-$(2)"
134 # $(1) destination prefix
135 define GoCompiler
/Default
/Uninstall
/BinLinks
137 rm -f
"$(1)/bin/gofmt"
142 # $(2) source go root
143 # $(3) destination prefix
146 # $(6) install suffix (optional)
147 define GoCompiler
/AddProfile
149 # $$(1) valid GOOS_GOARCH combinations
150 define GoCompiler
/$(1)/CheckHost
151 $$(call GoCompiler
/Default
/CheckHost
,$$(1),$(4))
154 # $$(1) additional environment variables (optional)
155 define GoCompiler
/$(1)/Make
156 $$(call GoCompiler
/Default
/Make
,$(2),$(3),$(4),$$(1))
159 # $$(1) override install prefix (optional)
160 define GoCompiler
/$(1)/Install
/Bin
161 $$(call GoCompiler
/Default
/Install
/Bin
,$(2),$$(or
$$(1),$(3)),$(4),$(5),$(6))
164 # $$(1) override install prefix (optional)
165 define GoCompiler
/$(1)/Install
/BinLinks
166 $$(call GoCompiler
/Default
/Install
/BinLinks
,$$(or
$$(1),$(3)),$(4))
169 # $$(1) override install prefix (optional)
170 define GoCompiler
/$(1)/Install
/Doc
171 $$(call GoCompiler
/Default
/Install
/Doc
,$(2),$$(or
$$(1),$(3)),$(4))
174 # $$(1) override install prefix (optional)
175 define GoCompiler
/$(1)/Install
/Src
176 $$(call GoCompiler
/Default
/Install
/Src
,$(2),$$(or
$$(1),$(3)),$(4))
179 # $$(1) override install prefix (optional)
180 define GoCompiler
/$(1)/Uninstall
181 $$(call GoCompiler
/Default
/Uninstall
,$$(or
$$(1),$(3)),$(4))
184 # $$(1) override install prefix (optional)
185 define GoCompiler
/$(1)/Uninstall
/BinLinks
186 $$(call GoCompiler
/Default
/Uninstall
/BinLinks
,$$(or
$$(1),$(3)))