Skip to content

Commit 11dfe65

Browse files
authored
Merge pull request #1140 from dvzrv/dvzrv/makefile
Various Makefile improvements
2 parents 471c53d + ae7a5eb commit 11dfe65

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

Diff for: Makefile

+8-7
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@ endif
3333
PROJECT := github.com/kubernetes-sigs/cri-tools
3434
BINDIR ?= /usr/local/bin
3535

36-
VERSION := $(shell git describe --tags --dirty --always)
37-
VERSION := $(VERSION:v%=%)
38-
GO_LDFLAGS := -X $(PROJECT)/pkg/version.Version=$(VERSION)
36+
VERSION ?= $(shell git describe --tags --dirty --always | sed 's/^v//')
37+
CGO_ENABLED ?= 0
38+
GOFLAGS ?= -trimpath
39+
GO_LDFLAGS := $(GO_LDFLAGS) -X $(PROJECT)/pkg/version.Version=$(VERSION)
3940

4041
BUILD_PATH := $(shell pwd)/build
4142
BUILD_BIN_PATH := $(BUILD_PATH)/bin/$(GOOS)/$(GOARCH)
@@ -64,18 +65,18 @@ critest:
6465
@$(MAKE) -B $(CRITEST)
6566

6667
$(CRITEST):
67-
CGO_ENABLED=0 $(GO_TEST) -c -o $@ \
68+
CGO_ENABLED=$(CGO_ENABLED) $(GO_TEST) -c -o $@ \
6869
-ldflags '$(GO_LDFLAGS)' \
69-
-trimpath \
70+
$(GOFLAGS) \
7071
$(PROJECT)/cmd/critest
7172

7273
crictl:
7374
@$(MAKE) -B $(CRICTL)
7475

7576
$(CRICTL):
76-
CGO_ENABLED=0 $(GO_BUILD) -o $@ \
77+
CGO_ENABLED=$(CGO_ENABLED) $(GO_BUILD) -o $@ \
7778
-ldflags '$(GO_LDFLAGS)' \
78-
-trimpath \
79+
$(GOFLAGS) \
7980
$(PROJECT)/cmd/crictl
8081

8182
clean:

0 commit comments

Comments
 (0)