This repository was archived by the owner on Aug 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathMakefile
More file actions
94 lines (74 loc) · 1.95 KB
/
Makefile
File metadata and controls
94 lines (74 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#
# Based on http://chrismckenzie.io/post/deploying-with-golang/
#
.PHONY: version all quartermaster run dist clean
APP_NAME := quartermaster
SHA := $(shell git rev-parse --short HEAD)
BRANCH := $(subst /,-,$(shell git rev-parse --abbrev-ref HEAD))
VER := $(shell git describe)
ARCH := $(shell go env GOARCH)
GOOS := $(shell go env GOOS)
+GLIDEPATH := $(shell command -v glide 2> /dev/null)
DIR=.
ifdef APP_SUFFIX
VERSION = $(VER)-$(subst /,-,$(APP_SUFFIX))
else
ifeq (master,$(BRANCH))
VERSION = $(VER)
else
VERSION = $(VER)-$(BRANCH)
endif
endif
# Go setup
GO=go
# Sources and Targets
EXECUTABLES :=$(APP_NAME)
# Build Binaries setting main.version and main.build vars
LDFLAGS :=-ldflags "-X main.QUARTERMASTER_VERSION=$(VERSION) -extldflags '-z relro -z now'"
# Package target
PACKAGE :=$(DIR)/dist/$(APP_NAME)-$(VERSION).$(GOOS).$(ARCH).tar.gz
GOFILES=$(shell go list ./... | grep -v vendor)
.DEFAULT: all
all: quartermaster
vendor: glide.lock
ifndef GLIDEPATH
echo "Installing Glide"
curl https://glide.sh/get | sh
endif
echo "Installing vendor directory"
glide install -v
echo "Building dependencies to make builds faster"
go install github.com/coreos/quartermaster/cmd/quartermaster
glide.lock: glide.yaml
echo "Glide.yaml has changed, updating glide.lock"
glide update -v
# print the version
version:
@echo $(VERSION)
# print the name of the app
name:
@echo $(APP_NAME)
# print the package path
package:
@echo $(PACKAGE)
quartermaster: glide.lock vendor
go build $(LDFLAGS) -o $(APP_NAME) cmd/quartermaster/main.go
run: quartermaster
./$(APP_NAME)
test:
go test $(GOFILES)
clean:
@echo Cleaning Workspace...
rm -rf $(APP_NAME)
rm -rf dist
$(PACKAGE): all
@echo Packaging Binaries...
@mkdir -p tmp/$(APP_NAME)
@cp $(APP_NAME) tmp/$(APP_NAME)/
@mkdir -p $(DIR)/dist/
tar -czf $@ -C tmp $(APP_NAME);
@rm -rf tmp
@echo
@echo Package $@ saved in dist directory
dist: $(PACKAGE) $(CLIENT_PACKAGE)
.PHONY: server client test clean name run version