github.com/jchauncey/draft@v0.3.0/Makefile (about) 1 DOCKER_REGISTRY ?= docker.io 2 IMAGE_PREFIX ?= microsoft 3 IMAGE_TAG ?= canary 4 SHORT_NAME ?= draft 5 TARGETS = darwin/amd64 linux/amd64 linux/386 linux/arm windows/amd64 6 DIST_DIRS = find * -type d -exec 7 APP = draft 8 9 # go option 10 GO ?= go 11 PKG := $(shell glide novendor) 12 TAGS := kqueue 13 TESTS := . 14 TESTFLAGS := 15 LDFLAGS := 16 GOFLAGS := 17 BINDIR := $(CURDIR)/bin 18 BINARIES := draft 19 20 # Required for globs to work correctly 21 SHELL=/bin/bash 22 23 .PHONY: all 24 all: build 25 26 .PHONY: build 27 build: 28 GOBIN=$(BINDIR) $(GO) install $(GOFLAGS) -tags '$(TAGS)' -ldflags '$(LDFLAGS)' github.com/Azure/draft/cmd/... 29 30 # usage: make clean build-cross dist APP=draft|draftd VERSION=v2.0.0-alpha.3 31 .PHONY: build-cross 32 build-cross: LDFLAGS += -extldflags "-static" 33 build-cross: 34 CGO_ENABLED=0 gox -output="_dist/{{.OS}}-{{.Arch}}/{{.Dir}}" -osarch='$(TARGETS)' $(GOFLAGS) -tags '$(TAGS)' -ldflags '$(LDFLAGS)' github.com/Azure/draft/cmd/$(APP) 35 36 .PHONY: dist 37 dist: 38 ( \ 39 cd _dist && \ 40 $(DIST_DIRS) cp ../LICENSE {} \; && \ 41 $(DIST_DIRS) cp ../README.md {} \; && \ 42 $(DIST_DIRS) tar -zcf draft-${VERSION}-{}.tar.gz {} \; \ 43 ) 44 45 .PHONY: checksum 46 checksum: 47 for f in _dist/*.gz ; do \ 48 shasum -a 256 "$${f}" | awk '{print $$1}' > "$${f}.sha256" ; \ 49 done 50 51 .PHONY: check-docker 52 check-docker: 53 @if [ -z $$(which docker) ]; then \ 54 echo "Missing \`docker\` client which is required for development"; \ 55 exit 2; \ 56 fi 57 58 .PHONY: check-helm 59 check-helm: 60 @if [ -z $$(which helm) ]; then \ 61 echo "Missing \`helm\` client which is required for development"; \ 62 exit 2; \ 63 fi 64 65 .PHONY: docker-binary 66 docker-binary: BINDIR = ./rootfs/bin 67 docker-binary: GOFLAGS += -a -installsuffix cgo 68 docker-binary: 69 GOOS=linux GOARCH=amd64 CGO_ENABLED=0 $(GO) build -o $(BINDIR)/draftd $(GOFLAGS) -tags '$(TAGS)' -ldflags '$(LDFLAGS)' github.com/Azure/draft/cmd/draftd 70 71 .PHONY: docker-build 72 docker-build: check-docker docker-binary compress-binary 73 docker build --rm -t ${IMAGE} . 74 docker tag ${IMAGE} ${MUTABLE_IMAGE} 75 76 .PHONY: compress-binary 77 compress-binary: BINDIR = ./rootfs/bin 78 compress-binary: 79 @if [ -z $$(which upx) ]; then \ 80 echo "Missing \`upx\` tool to compress binaries"; \ 81 else \ 82 upx --quiet ${BINDIR}/draftd; \ 83 fi 84 85 .PHONY: serve 86 serve: check-helm 87 helm install chart/ --name ${APP} --namespace kube-system \ 88 --set image.name=${SHORT_NAME},image.org=${IMAGE_PREFIX},image.registry=${DOCKER_REGISTRY},image.tag=${IMAGE_TAG} 89 90 .PHONY: unserve 91 unserve: check-helm 92 -helm delete --purge ${APP} 93 94 .PHONY: clean 95 clean: 96 -rm bin/* 97 -rm rootfs/bin/* 98 99 .PHONY: test 100 test: TESTFLAGS += -race -v 101 test: test-lint test-unit 102 103 .PHONY: test-lint 104 test-lint: 105 _scripts/lint.sh 106 107 .PHONY: test-unit 108 test-unit: 109 $(GO) test $(GOFLAGS) -cover -run $(TESTS) $(PKG) $(TESTFLAGS) 110 111 .PHONY: test-e2e 112 test-e2e: 113 ./tests/e2e.sh 114 115 HAS_GOMETALINTER := $(shell command -v gometalinter;) 116 HAS_GLIDE := $(shell command -v glide;) 117 HAS_GOX := $(shell command -v gox;) 118 HAS_GIT := $(shell command -v git;) 119 120 .PHONY: bootstrap 121 bootstrap: 122 ifndef HAS_GOMETALINTER 123 go get -u github.com/alecthomas/gometalinter 124 gometalinter --install 125 endif 126 ifndef HAS_GLIDE 127 go get -u github.com/Masterminds/glide 128 endif 129 ifndef HAS_GOX 130 go get -u github.com/mitchellh/gox 131 endif 132 ifndef HAS_GIT 133 $(error You must install git) 134 endif 135 glide install 136 137 include versioning.mk