Skip to content

Commit ad20e25

Browse files
committed
Makefile: move some Go-related variable definitions up
Otherwise we evaluate NATIVE_GOOS before it is set, which breaks the FreeBSD build since various make variables are not set correctly. Fixes: #26006 Signed-off-by: Mark Johnston <mark.johnston@klarasystems.com>
1 parent 1e4287d commit ad20e25

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

Makefile

+9-9
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@ SHELL := $(shell command -v bash;)
2525
GO ?= go
2626
GO_LDFLAGS:= $(shell if $(GO) version|grep -q gccgo ; then echo "-gccgoflags"; else echo "-ldflags"; fi)
2727
GOCMD = CGO_ENABLED=$(CGO_ENABLED) GOOS=$(GOOS) GOARCH=$(GOARCH) $(GO)
28+
# Podman does not work w/o CGO_ENABLED, except in some very specific cases.
29+
# Windows and Mac (both podman-remote client only) require CGO_ENABLED=0.
30+
CGO_ENABLED ?= 1
31+
# Default to the native OS type and architecture unless otherwise specified
32+
NATIVE_GOOS := $(shell env -u GOOS $(GO) env GOOS)
33+
GOOS ?= $(call err_if_empty,NATIVE_GOOS)
34+
# Default to the native architecture type
35+
NATIVE_GOARCH := $(shell env -u GOARCH $(GO) env GOARCH)
36+
GOARCH ?= $(NATIVE_GOARCH)
2837
COVERAGE_PATH ?= .coverage
2938
DESTDIR ?=
3039
EPOCH_TEST_COMMIT ?= $(shell git merge-base $${DEST_BRANCH:-main} HEAD)
@@ -179,15 +188,6 @@ CROSS_BUILD_TARGETS := \
179188
# Dereference variable $(1), return value if non-empty, otherwise raise an error.
180189
err_if_empty = $(if $(strip $($(1))),$(strip $($(1))),$(error Required variable $(1) value is undefined, whitespace, or empty))
181190

182-
# Podman does not work w/o CGO_ENABLED, except in some very specific cases.
183-
# Windows and Mac (both podman-remote client only) require CGO_ENABLED=0.
184-
CGO_ENABLED ?= 1
185-
# Default to the native OS type and architecture unless otherwise specified
186-
NATIVE_GOOS := $(shell env -u GOOS $(GO) env GOOS)
187-
GOOS ?= $(call err_if_empty,NATIVE_GOOS)
188-
# Default to the native architecture type
189-
NATIVE_GOARCH := $(shell env -u GOARCH $(GO) env GOARCH)
190-
GOARCH ?= $(NATIVE_GOARCH)
191191
ifeq ($(call err_if_empty,GOOS),windows)
192192
BINSFX := .exe
193193
SRCBINDIR := bin/windows

0 commit comments

Comments
 (0)