PKG?=github.com/smallstep/cli/cmd/step BINNAME?=step # Set V to 1 for verbose output from the Makefile Q=$(if $V,,@) PREFIX?= SRC=$(shell find . -type f -name '*.go' -not -path "./vendor/*") GOOS_OVERRIDE ?= CGO_OVERRIDE ?= CGO_ENABLED=0 OUTPUT_ROOT=output/ .PHONY: all ######################################### # Bootstrapping ######################################### bootstra%: # Using a released version of golangci-lint to take into account custom replacements in their go.mod $Q curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.39.0 .PHONY: bootstra% ######################################### # Build ######################################### DATE := $(shell date -u '+%Y-%m-%d %H:%M UTC') LDFLAGS := -ldflags='-w -X "main.Version=$(VERSION)" -X "main.BuildTime=$(DATE)"' download: $Q go mod download build: $(PREFIX)bin/$(BINNAME) @echo "Build Complete!" $(PREFIX)bin/$(BINNAME): download $(call rwildcard,*.go) $Q mkdir -p $(@D) $Q $(GOOS_OVERRIDE) $(CGO_OVERRIDE) go build -v -o $@ $(LDFLAGS) $(PKG) .PHONY: build simple ######################################### # Go generate ######################################### generate: $Q go generate ./... .PHONY: generate ######################################### # Test ######################################### test: $Q $(CGO_OVERRIDE) go test -short -coverprofile=coverage.out ./... .PHONY: test integrate: integration integration: bin/$(BINNAME) $Q $(CGO_OVERRIDE) go test -tags=integration ./integration/... .PHONY: integrate integration ######################################### # Linting ######################################### fmt: $Q gofmt -l -w $(SRC) lint: $Q LOG_LEVEL=error golangci-lint run --timeout=30m .PHONY: fmt lint ######################################### # Install ######################################### INSTALL_PREFIX?=/usr/ install: $(PREFIX)bin/$(BINNAME) $Q install -D $(PREFIX)bin/$(BINNAME) $(DESTDIR)$(INSTALL_PREFIX)bin/$(BINNAME) uninstall: $Q rm -f $(DESTDIR)$(INSTALL_PREFIX)/bin/$(BINNAME) .PHONY: install uninstall ######################################### # Clean ######################################### clean: ifneq ($(BINNAME),"") $Q rm -f bin/$(BINNAME) endif .PHONY: clean