Skip to content

Commit 464d645

Browse files
committed
Allow overriding GOFLAGS
Makefile: Allow providing `GOFLAGS` in the build environment to set go compiler flags and set the default to `-trimpath`. This is required for downstream distributions to be able to build position independent executables and working debug symbols.
1 parent e64d6e3 commit 464d645

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Diff for: Makefile

+3-2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ PROJECT := github.com/kubernetes-sigs/cri-tools
3434
BINDIR ?= /usr/local/bin
3535

3636
VERSION ?= $(shell git describe --tags --dirty --always | sed 's/^v//')
37+
GOFLAGS ?= -trimpath
3738
GO_LDFLAGS := $(GO_LDFLAGS) -X $(PROJECT)/pkg/version.Version=$(VERSION)
3839

3940
BUILD_PATH := $(shell pwd)/build
@@ -65,7 +66,7 @@ critest:
6566
$(CRITEST):
6667
CGO_ENABLED=0 $(GO_TEST) -c -o $@ \
6768
-ldflags '$(GO_LDFLAGS)' \
68-
-trimpath \
69+
$(GOFLAGS) \
6970
$(PROJECT)/cmd/critest
7071

7172
crictl:
@@ -74,7 +75,7 @@ crictl:
7475
$(CRICTL):
7576
CGO_ENABLED=0 $(GO_BUILD) -o $@ \
7677
-ldflags '$(GO_LDFLAGS)' \
77-
-trimpath \
78+
$(GOFLAGS) \
7879
$(PROJECT)/cmd/crictl
7980

8081
clean:

0 commit comments

Comments
 (0)