draft-classic/Makefile

111 строки
2.4 KiB
Makefile
Исходник Обычный вид История

2017-05-08 19:33:37 +03:00
DOCKER_REGISTRY ?= docker.io
IMAGE_PREFIX ?= microsoft
IMAGE_TAG ?= canary
TARGETS = darwin/amd64 linux/amd64 linux/386 linux/arm windows/amd64
2017-01-18 11:10:11 +03:00
DIST_DIRS = find * -type d -exec
2017-04-21 18:19:58 +03:00
APP = draft
INSTALL_DIR := /usr/local/bin
PROJECT := draft
ifeq ($(OS),Windows_NT)
TARGET = $(PROJECT).exe
else
TARGET = $(PROJECT)
endif
2017-01-18 11:10:11 +03:00
# go option
GO ?= go
2017-03-13 22:18:29 +03:00
TAGS := kqueue
2017-01-18 11:10:11 +03:00
TESTS := .
TESTFLAGS :=
LDFLAGS :=
GOFLAGS :=
GOXFLAGS :=
2017-01-18 11:10:11 +03:00
BINDIR := $(CURDIR)/bin
2017-04-21 18:19:58 +03:00
BINARIES := draft
2017-01-18 11:10:11 +03:00
# Required for globs to work correctly
SHELL=/bin/bash
.PHONY: all
all: build
.PHONY: build
build:
2017-05-08 19:33:37 +03:00
GOBIN=$(BINDIR) $(GO) install $(GOFLAGS) -tags '$(TAGS)' -ldflags '$(LDFLAGS)' github.com/Azure/draft/cmd/...
2017-01-18 11:10:11 +03:00
2018-03-15 22:34:41 +03:00
# usage: make clean build-cross dist APP=draft VERSION=v2.0.0-alpha.3
2017-01-18 11:10:11 +03:00
.PHONY: build-cross
build-cross: LDFLAGS += -extldflags "-static"
build-cross:
CGO_ENABLED=0 gox -output="_dist/{{.OS}}-{{.Arch}}/{{.Dir}}" -osarch='$(TARGETS)' $(GOFLAGS) -tags '$(TAGS)' -ldflags '$(LDFLAGS)' $(GOXFLAGS) github.com/Azure/draft/cmd/$(APP)
2017-01-18 11:10:11 +03:00
.PHONY: dist
dist:
( \
cd _dist && \
$(DIST_DIRS) cp ../LICENSE {} \; && \
$(DIST_DIRS) cp ../README.md {} \; && \
$(DIST_DIRS) tar -zcf draft-${VERSION}-{}.tar.gz {} \; && \
$(DIST_DIRS) zip -r draft-${VERSION}-{}.zip {} \; \
2017-01-18 11:10:11 +03:00
)
.PHONY: checksum
checksum:
2018-04-27 18:57:40 +03:00
for f in _dist/*.{gz,zip} ; do \
2017-01-18 11:10:11 +03:00
shasum -a 256 "$${f}" | awk '{print $$1}' > "$${f}.sha256" ; \
done
.PHONY: clean
clean:
-rm bin/*
-rm rootfs/bin/*
-rm -rf _dist/
.PHONY: install
install:
install $(BINDIR)/$(TARGET) $(INSTALL_DIR)
2017-01-18 11:10:11 +03:00
.PHONY: test
test: TESTFLAGS += -race -v
test: test-lint test-unit
2017-06-06 21:39:04 +03:00
test-cover:
scripts/cover.sh
.PHONY: test-lint
test-lint:
scripts/lint.sh
2017-01-18 11:10:11 +03:00
.PHONY: test-unit
test-unit:
2017-10-05 00:52:20 +03:00
$(GO) test $(GOFLAGS) -cover -run $(TESTS) ./... $(TESTFLAGS)
2017-01-18 11:10:11 +03:00
HAS_GOMETALINTER := $(shell command -v gometalinter;)
2017-10-05 00:52:20 +03:00
HAS_DEP := $(shell command -v dep;)
2017-01-18 11:10:11 +03:00
HAS_GOX := $(shell command -v gox;)
HAS_GIT := $(shell command -v git;)
HAS_BINDATA := $(shell command -v go-bindata;)
2017-01-18 11:10:11 +03:00
.PHONY: bootstrap
bootstrap:
ifndef HAS_GOMETALINTER
go get -u github.com/alecthomas/gometalinter
gometalinter --install
endif
2017-10-05 00:52:20 +03:00
ifndef HAS_DEP
go get -u github.com/golang/dep/cmd/dep
2017-01-18 11:10:11 +03:00
endif
ifndef HAS_GOX
go get -u github.com/mitchellh/gox
endif
ifndef HAS_GIT
$(error You must install git)
endif
ifndef HAS_BINDATA
go get github.com/jteeuwen/go-bindata/...
2017-01-18 11:10:11 +03:00
endif
2017-10-05 00:52:20 +03:00
dep ensure -v
2017-01-18 11:10:11 +03:00
include versioning.mk