| 1 |
PKG?=github.com/smallstep/cli/cmd/step |
| 2 |
BINNAME?=step |
| 3 |
|
| 4 |
|
| 5 |
Q=$(if $V,,@) |
| 6 |
PREFIX?= |
| 7 |
SRC=$(shell find . -type f -name '*.go' -not -path "./vendor/*") |
| 8 |
GOOS_OVERRIDE ?= |
| 9 |
CGO_OVERRIDE ?= CGO_ENABLED=0 |
| 10 |
OUTPUT_ROOT=output/ |
| 11 |
|
| 12 |
.PHONY: all |
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
bootstra%: |
| 19 |
# Using a released version of golangci-lint to take into account custom replacements in their go.mod |
| 20 |
$Q curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.39.0 |
| 21 |
|
| 22 |
.PHONY: bootstra% |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
DATE := $(shell date -u '+%Y-%m-%d %H:%M UTC') |
| 29 |
LDFLAGS := -ldflags='-w -X "main.Version=$(VERSION)" -X "main.BuildTime=$(DATE)"' |
| 30 |
|
| 31 |
download: |
| 32 |
$Q go mod download |
| 33 |
|
| 34 |
build: $(PREFIX)bin/$(BINNAME) |
| 35 |
@echo "Build Complete!" |
| 36 |
|
| 37 |
$(PREFIX)bin/$(BINNAME): download $(call rwildcard,*.go) |
| 38 |
$Q mkdir -p $(@D) |
| 39 |
$Q $(GOOS_OVERRIDE) $(CGO_OVERRIDE) go build -v -o $@ $(LDFLAGS) $(PKG) |
| 40 |
|
| 41 |
.PHONY: build simple |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
generate: |
| 48 |
$Q go generate ./... |
| 49 |
|
| 50 |
.PHONY: generate |
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
test: |
| 56 |
$Q $(CGO_OVERRIDE) go test -short -coverprofile=coverage.out ./... |
| 57 |
|
| 58 |
.PHONY: test |
| 59 |
|
| 60 |
integrate: integration |
| 61 |
|
| 62 |
integration: bin/$(BINNAME) |
| 63 |
$Q $(CGO_OVERRIDE) go test -tags=integration ./integration/... |
| 64 |
|
| 65 |
.PHONY: integrate integration |
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
fmt: |
| 72 |
$Q gofmt -l -w $(SRC) |
| 73 |
|
| 74 |
lint: |
| 75 |
$Q LOG_LEVEL=error golangci-lint run --timeout=30m |
| 76 |
|
| 77 |
.PHONY: fmt lint |
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
INSTALL_PREFIX?=/usr/ |
| 84 |
|
| 85 |
install: $(PREFIX)bin/$(BINNAME) |
| 86 |
$Q install -D $(PREFIX)bin/$(BINNAME) $(DESTDIR)$(INSTALL_PREFIX)bin/$(BINNAME) |
| 87 |
|
| 88 |
uninstall: |
| 89 |
$Q rm -f $(DESTDIR)$(INSTALL_PREFIX)/bin/$(BINNAME) |
| 90 |
|
| 91 |
.PHONY: install uninstall |
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
clean: |
| 98 |
ifneq ($(BINNAME),"") |
| 99 |
$Q rm -f bin/$(BINNAME) |
| 100 |
endif |
| 101 |
|
| 102 |
.PHONY: clean |