Skip to content

Commit 8f5cbe2

Browse files
authored
fix: build and no static build on mac (#7)
* fix: build and no static build on mac * f
1 parent 350de08 commit 8f5cbe2

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

Makefile

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,16 @@ TARGET_OS ?= linux
2121
BUILD_GO_FLAGS := -tags osusergo
2222
BUILD_GO_FLAGS += -asmflags "all=-trimpath=$(shell dirname $(PWD))"
2323
BUILD_GO_FLAGS += -gcflags "all=-trimpath=$(shell dirname $(PWD))"
24+
BUILD_GO_LDFLAGS_EXTRA := -extldflags=-static
25+
ifeq ($(shell go env GOOS),darwin)
26+
BUILD_GO_LDFLAGS_EXTRA =
27+
endif
28+
2429
LD_FLAGS := -X main.goos=$(shell go env GOOS)
2530
LD_FLAGS += -X main.goarch=$(shell go env GOARCH)
2631
LD_FLAGS += -X main.gitCommit=$(shell git rev-parse HEAD)
2732
LD_FLAGS += -X main.buildDate=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
33+
LD_FLAGS += $(BUILD_GO_LDFLAGS_EXTRA)
2834

2935
GO_SRCS := $(shell find . -type f -name '*.go' -not -name '*_test.go' -not -name 'zz_generated*')
3036

@@ -34,7 +40,7 @@ all: clean lint test build ## Run all commands to build the tool
3440
.PHONY: clean
3541
clean: ## Clean the bin directory
3642
rm -rf $(BIN_DIR)
37-
rm -rf static/bin/k0s
43+
rm -rf static/bin
3844
rm -rf static/helm/*tgz
3945
$(MAKE) -C inttest clean
4046

@@ -62,13 +68,22 @@ static/helm/000-admin-console-$(admin_console_version).tgz: helm
6268

6369
##@ Development
6470

71+
GOLANGCI_LINT = $(BIN_DIR)/golangci-lint
72+
.PHONY: golangci-lint
73+
golangci-lint:
74+
@[ -f $(GOLANGCI_LINT) ] || { \
75+
set -e ;\
76+
curl -fsSL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | \
77+
sh -s -- -b $(shell dirname $(GOLANGCI_LINT));\
78+
}
79+
6580
.PHONY: lint
6681
lint: golangci-lint go.sum ## Run golangci-lint linter
67-
golangci-lint run
82+
$(GOLANGCI_LINT) run --timeout=5m
6883

6984
.PHONY: lint-fix
70-
lint-fix: golangci-lint ## Run golangci-lint linter and perform fixes
71-
golangci-lint run --fix
85+
lint-fix: golangci-lint go.sum ## Run golangci-lint linter and perform fixes
86+
$(GOLANGCI_LINT) run --timeout=5m --fix
7287

7388
.PHONY: test
7489
test: GO_TEST_RACE ?= -race
@@ -82,15 +97,6 @@ $(smoketests): build
8297
.PHONY: smoketests
8398
smoketests: $(smoketests)
8499

85-
GOLANGCI_LINT = $(BIN_DIR)/golangci-lint
86-
.PHONY: golangci-lint
87-
golangci-lint:
88-
@[ -f $(GOLANGCI_LINT) ] || { \
89-
set -e ;\
90-
curl -fsSL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | \
91-
sh -s -- -b $(shell dirname $(GOLANGCI_LINT));\
92-
}
93-
94100
.PHONY: helm
95101
helm:
96102
@mkdir -p $(BIN_DIR)

0 commit comments

Comments
 (0)