mirror of https://github.com/k3d-io/k3d
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
1.8 KiB
63 lines
1.8 KiB
SHELL := /bin/bash
|
|
|
|
# Build targets
|
|
TARGETS ?= darwin/amd64 linux/amd64 linux/386 linux/arm linux/arm64 windows/amd64
|
|
TARGET_OBJS ?= darwin-amd64.tar.gz darwin-amd64.tar.gz.sha256 linux-amd64.tar.gz linux-amd64.tar.gz.sha256 linux-386.tar.gz linux-386.tar.gz.sha256 linux-arm.tar.gz linux-arm.tar.gz.sha256 linux-arm64.tar.gz linux-arm64.tar.gz.sha256 windows-amd64.zip windows-amd64.zip.sha256
|
|
|
|
# get git tag
|
|
GIT_TAG := $(shell git describe --tags)
|
|
ifeq ($(GIT_TAG),)
|
|
GIT_TAG := $(shell git describe --always)
|
|
endif
|
|
|
|
# Go options
|
|
GO ?= go
|
|
PKG := $(shell go mod vendor)
|
|
TAGS :=
|
|
TESTS := .
|
|
TESTFLAGS :=
|
|
LDFLAGS := -w -s -X github.com/iwilltry42/k3d/version.Version=${GIT_TAG}
|
|
GOFLAGS :=
|
|
BINDIR := $(CURDIR)/bin
|
|
BINARIES := k3d
|
|
|
|
export GO111MODULE=on
|
|
|
|
# go source files, ignore vendor directory
|
|
SRC = $(shell find . -type f -name '*.go' -not -path "./*/*")
|
|
|
|
.PHONY: all build build-cross clean fmt simplify check
|
|
|
|
all: clean fmt check build
|
|
|
|
build:
|
|
$(GO) build -i $(GOFLAGS) -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o '$(BINDIR)/$(BINARIES)'
|
|
|
|
build-cross: LDFLAGS += -extldflags "-static"
|
|
build-cross:
|
|
CGO_ENABLED=0 gox -parallel=3 -output="_dist/$(BINARIES)-{{.OS}}-{{.Arch}}" -osarch='$(TARGETS)' $(GOFLAGS) $(if $(TAGS),-tags '$(TAGS)',) -ldflags '$(LDFLAGS)'
|
|
|
|
clean:
|
|
@rm -rf $(BINDIR) _dist/
|
|
|
|
fmt:
|
|
@gofmt -l -w $(SRC)
|
|
|
|
simplify:
|
|
@gofmt -s -l -w $(SRC)
|
|
|
|
check:
|
|
@test -z $(shell gofmt -l main.go | tee /dev/stderr) || echo "[WARN] Fix formatting issues with 'make fmt'"
|
|
@golangci-lint run
|
|
@go vet ${SRC}
|
|
|
|
# Check for required executables
|
|
HAS_GOX := $(shell command -v gox 2> /dev/null)
|
|
HAS_GOLANGCI := $(shell command -v golangci-lint 2> /dev/null)
|
|
|
|
ifndef HAS_GOX
|
|
go get -u github.com/mitchellh/gox
|
|
endif
|
|
ifndef HAS_GOLANGCI
|
|
go get -u github.com/golangci/golangci-lint/cmd/golangci-lint
|
|
endif |