Skip to content

Commit 0532a11

Browse files
michi-covalenttklauser
authored andcommitted
cilium-cli: Use the default Make target to build release binaries
The top-level Makefile.defs sets GOARCH to the local architecture by default as a Make variable, which gets used by the GO_BUILD variable. The local-release Make target in the cilium-cli directory explicitly sets GOARCH environment variable to build binaries for amd64 and arm64, but it gets overridden by the top-level GO_BUILD variable. This results in all the release binaries having GOARCH set to the architecture of the machine where they get built. To fix the issue, pass GOARCH (among other variables) to the default Make target to build release binaries instead of directly invoking go build. This way GO_BUILD variable gets updated with the correct GOARCH value for each release binary. Suggested-by: Hadrien Patte <hadrien.patte@datadoghq.com> Signed-off-by: Michi Mutsuzaki <michi@isovalent.com>
1 parent 62b3e7c commit 0532a11

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

cilium-cli/Makefile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,12 @@ GO_TAGS_FLAGS += $(GO_TAGS)
2020

2121
TEST_TIMEOUT ?= 5s
2222

23+
BUILDDIR ?= .
24+
EXT ?=
25+
2326
$(TARGET):
2427
$(GO_BUILD) \
25-
-o $(@) \
28+
-o $(BUILDDIR)/$(@)$(EXT) \
2629
$(CLI_MAIN_DIR)
2730

2831
local-release: clean
@@ -45,8 +48,7 @@ local-release: clean
4548
for ARCH in $$ARCHS; do \
4649
echo Building release binary for $$OS/$$ARCH...; \
4750
test -d release/$$OS/$$ARCH|| mkdir -p release/$$OS/$$ARCH; \
48-
env GOOS=$$OS GOARCH=$$ARCH $(GO_BUILD) \
49-
-o release/$$OS/$$ARCH/$(TARGET)$$EXT $(CLI_MAIN_DIR); \
51+
$(MAKE) GOOS=$$OS GOARCH=$$ARCH BUILDDIR=release/$$OS/$$ARCH EXT=$$EXT; \
5052
if [ $$OS = "windows" ]; \
5153
then \
5254
zip -j release/$(TARGET)-$$OS-$$ARCH.zip release/$$OS/$$ARCH/$(TARGET)$$EXT; \
@@ -61,7 +63,7 @@ local-release: clean
6163

6264
install: $(TARGET)
6365
$(INSTALL) -m 0755 -d $(DESTDIR)$(BINDIR)
64-
$(INSTALL) -m 0755 $(TARGET) $(DESTDIR)$(BINDIR)
66+
$(INSTALL) -m 0755 $(BUILDDIR)/$(TARGET)$(EXT) $(DESTDIR)$(BINDIR)
6567

6668
clean:
6769
rm -f $(TARGET)

0 commit comments

Comments
 (0)