libre2: fix pkgconfig paths
[feed/packages.git] / lang / golang / golang-values.mk
1 #
2 # Copyright (C) 2018-2023 Jeffery To
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7
8 ifeq ($(origin GO_INCLUDE_DIR),undefined)
9 GO_INCLUDE_DIR:=$(dir $(lastword $(MAKEFILE_LIST)))
10 endif
11
12
13 # Unset environment variables
14 # There are more magic variables to track down, but ain't nobody got time for that
15
16 # From https://pkg.go.dev/cmd/go#hdr-Environment_variables
17
18 # General-purpose environment variables:
19 unexport \
20 GO111MODULE \
21 GCCGO \
22 GOARCH \
23 GOBIN \
24 GOCACHE \
25 GOMODCACHE \
26 GODEBUG \
27 GOENV \
28 GOFLAGS \
29 GOOS \
30 GOPATH \
31 GOROOT \
32 GOTOOLCHAIN \
33 GOTMPDIR \
34 GOWORK
35 # Unmodified:
36 # GOINSECURE
37 # GOPRIVATE
38 # GOPROXY
39 # GONOPROXY
40 # GOSUMDB
41 # GONOSUMDB
42 # GOVCS
43
44 # Environment variables for use with cgo:
45 unexport \
46 AR \
47 CC \
48 CGO_ENABLED \
49 CGO_CFLAGS CGO_CFLAGS_ALLOW CGO_CFLAGS_DISALLOW \
50 CGO_CPPFLAGS CGO_CPPFLAGS_ALLOW CGO_CPPFLAGS_DISALLOW \
51 CGO_CXXFLAGS CGO_CXXFLAGS_ALLOW CGO_CXXFLAGS_DISALLOW \
52 CGO_FFLAGS CGO_FFLAGS_ALLOW CGO_FFLAGS_DISALLOW \
53 CGO_LDFLAGS CGO_LDFLAGS_ALLOW CGO_LDFLAGS_DISALLOW \
54 CXX \
55 FC
56 # Unmodified:
57 # PKG_CONFIG
58
59 # Architecture-specific environment variables:
60 unexport \
61 GOARM \
62 GO386 \
63 GOAMD64 \
64 GOMIPS \
65 GOMIPS64 \
66 GOPPC64 \
67 GOWASM
68
69 # Environment variables for use with code coverage:
70 unexport \
71 GOCOVERDIR
72
73 # Special-purpose environment variables:
74 unexport \
75 GCCGOTOOLDIR \
76 GOEXPERIMENT \
77 GOROOT_FINAL \
78 GO_EXTLINK_ENABLED
79 # Unmodified:
80 # GIT_ALLOW_PROTOCOL
81
82 # From https://pkg.go.dev/runtime#hdr-Environment_Variables
83 unexport \
84 GOGC \
85 GOMEMLIMIT \
86 GOMAXPROCS \
87 GORACE \
88 GOTRACEBACK
89
90 # From https://pkg.go.dev/cmd/cgo#hdr-Using_cgo_with_the_go_command
91 unexport \
92 CC_FOR_TARGET \
93 CXX_FOR_TARGET
94 # Todo:
95 # CC_FOR_${GOOS}_${GOARCH}
96 # CXX_FOR_${GOOS}_${GOARCH}
97
98 # From https://go.dev/doc/install/source#environment
99 unexport \
100 GOHOSTOS \
101 GOHOSTARCH
102
103 # From https://go.dev/src/make.bash
104 unexport \
105 GO_GCFLAGS \
106 GO_LDFLAGS \
107 GO_LDSO \
108 GO_DISTFLAGS \
109 GOBUILDTIMELOGFILE \
110 GOROOT_BOOTSTRAP
111
112 # From https://go.dev/doc/go1.9#parallel-compile
113 unexport \
114 GO19CONCURRENTCOMPILATION
115
116 # From https://go.dev/src/cmd/dist/build.go
117 unexport \
118 BOOT_GO_GCFLAGS \
119 BOOT_GO_LDFLAGS
120
121 # From https://go.dev/src/cmd/dist/buildtool.go
122 unexport \
123 GOBOOTSTRAP_TOOLEXEC
124
125
126 # GOOS / GOARCH
127
128 go_arch=$(subst \
129 aarch64,arm64,$(subst \
130 i386,386,$(subst \
131 mipsel,mipsle,$(subst \
132 mips64el,mips64le,$(subst \
133 powerpc64,ppc64,$(subst \
134 x86_64,amd64,$(1)))))))
135
136 GO_OS:=linux
137 GO_ARCH:=$(call go_arch,$(ARCH))
138 GO_OS_ARCH:=$(GO_OS)_$(GO_ARCH)
139
140 GO_HOST_OS:=$(call tolower,$(HOST_OS))
141 GO_HOST_ARCH:=$(call go_arch,$(subst \
142 armv6l,arm,$(subst \
143 armv7l,arm,$(subst \
144 i686,i386,$(HOST_ARCH)))))
145 GO_HOST_OS_ARCH:=$(GO_HOST_OS)_$(GO_HOST_ARCH)
146
147 ifeq ($(GO_OS_ARCH),$(GO_HOST_OS_ARCH))
148 GO_HOST_TARGET_SAME:=1
149 else
150 GO_HOST_TARGET_DIFFERENT:=1
151 endif
152
153 ifeq ($(GO_ARCH),386)
154 ifeq ($(CONFIG_TARGET_x86_geode)$(CONFIG_TARGET_x86_legacy),y)
155 GO_386:=softfloat
156 else
157 GO_386:=sse2
158 endif
159
160 # -fno-plt: causes "unexpected GOT reloc for non-dynamic symbol" errors
161 GO_CFLAGS_TO_REMOVE:=-fno-plt
162
163 else ifeq ($(GO_ARCH),amd64)
164 GO_AMD64:=v1
165
166 else ifeq ($(GO_ARCH),arm)
167 GO_TARGET_FPU:=$(word 2,$(subst +,$(space),$(call qstrip,$(CONFIG_CPU_TYPE))))
168
169 # FPU names from https://gcc.gnu.org/onlinedocs/gcc-8.4.0/gcc/ARM-Options.html#index-mfpu-1
170 # see also https://github.com/gcc-mirror/gcc/blob/releases/gcc-8.4.0/gcc/config/arm/arm-cpus.in
171
172 ifeq ($(GO_TARGET_FPU),)
173 GO_ARM:=5
174 else ifneq ($(filter $(GO_TARGET_FPU),vfp vfpv2),)
175 GO_ARM:=6
176 else
177 GO_ARM:=7
178 endif
179
180 else ifneq ($(filter $(GO_ARCH),mips mipsle),)
181 ifeq ($(CONFIG_HAS_FPU),y)
182 GO_MIPS:=hardfloat
183 else
184 GO_MIPS:=softfloat
185 endif
186
187 # -mips32r2: conflicts with -march=mips32 set by go
188 GO_CFLAGS_TO_REMOVE:=-mips32r2
189
190 else ifneq ($(filter $(GO_ARCH),mips64 mips64le),)
191 ifeq ($(CONFIG_HAS_FPU),y)
192 GO_MIPS64:=hardfloat
193 else
194 GO_MIPS64:=softfloat
195 endif
196
197 else ifeq ($(GO_ARCH),ppc64)
198 GO_PPC64:=power8
199
200 endif
201
202
203 # Target Go
204
205 GO_ARCH_DEPENDS:=@(aarch64||arm||i386||i686||mips||mips64||mips64el||mipsel||powerpc64||riscv64||x86_64)
206
207
208 # ASLR/PIE
209
210 # From https://go.dev/src/internal/platform/supported.go
211 GO_PIE_SUPPORTED_OS_ARCH:= \
212 android_386 android_amd64 android_arm android_arm64 \
213 linux_386 linux_amd64 linux_arm linux_arm64 \
214 windows_386 windows_amd64 windows_arm windows_arm64 \
215 \
216 darwin_amd64 darwin_arm64 \
217 ios_amd64 ios_arm64 \
218 \
219 freebsd_amd64 \
220 \
221 aix_ppc64 \
222 \
223 linux_loong64 linux_ppc64le linux_riscv64 linux_s390x
224
225 # From https://go.dev/src/cmd/go/internal/work/init.go
226 go_pie_install_suffix=$(if $(filter $(1),aix_ppc64 windows_386 windows_amd64 windows_arm windows_arm64),,shared)
227
228 ifneq ($(filter $(GO_HOST_OS_ARCH),$(GO_PIE_SUPPORTED_OS_ARCH)),)
229 GO_HOST_PIE_SUPPORTED:=1
230 GO_HOST_PIE_INSTALL_SUFFIX:=$(call go_pie_install_suffix,$(GO_HOST_OS_ARCH))
231 endif
232
233 ifneq ($(filter $(GO_OS_ARCH),$(GO_PIE_SUPPORTED_OS_ARCH)),)
234 GO_TARGET_PIE_SUPPORTED:=1
235 GO_TARGET_PIE_INSTALL_SUFFIX:=$(call go_pie_install_suffix,$(GO_OS_ARCH))
236 endif
237
238
239 # Spectre mitigations
240
241 GO_SPECTRE_SUPPORTED_ARCH:=amd64
242
243 ifneq ($(filter $(GO_HOST_ARCH),$(GO_SPECTRE_SUPPORTED_ARCH)),)
244 GO_HOST_SPECTRE_SUPPORTED:=1
245 endif
246
247 ifneq ($(filter $(GO_ARCH),$(GO_SPECTRE_SUPPORTED_ARCH)),)
248 GO_TARGET_SPECTRE_SUPPORTED:=1
249 endif
250
251
252 # General build info
253
254 GO_BUILD_CACHE_DIR:=$(or $(call qstrip,$(CONFIG_GOLANG_BUILD_CACHE_DIR)),$(TMP_DIR)/go-build)
255 GO_MOD_CACHE_DIR:=$(DL_DIR)/go-mod-cache
256
257 GO_MOD_ARGS= \
258 -modcacherw
259
260 GO_GENERAL_BUILD_CONFIG_VARS= \
261 CONFIG_GOLANG_MOD_CACHE_WORLD_READABLE="$(CONFIG_GOLANG_MOD_CACHE_WORLD_READABLE)" \
262 GO_BUILD_CACHE_DIR="$(GO_BUILD_CACHE_DIR)" \
263 GO_MOD_CACHE_DIR="$(GO_MOD_CACHE_DIR)" \
264 GO_MOD_ARGS="$(GO_MOD_ARGS)"
265
266 define Go/CacheCleanup
267 $(GO_GENERAL_BUILD_CONFIG_VARS) \
268 $(SHELL) $(GO_INCLUDE_DIR)/golang-build.sh cache_cleanup
269 endef