forked from heketi/heketi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
101 lines (82 loc) · 2.37 KB
/
Makefile
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
95
96
97
98
99
100
101
#
# Based on http://chrismckenzie.io/post/deploying-with-golang/
#
.PHONY: version all run dist clean
APP_NAME := heketi
CLIENT_PKG_NAME := heketi-client
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)
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.HEKETI_VERSION=$(VERSION) -extldflags '-z relro -z now'"
# Package target
PACKAGE :=$(DIR)/dist/$(APP_NAME)-$(VERSION).$(GOOS).$(ARCH).tar.gz
CLIENT_PACKAGE :=$(DIR)/dist/$(APP_NAME)-client-$(VERSION).$(GOOS).$(ARCH).tar.gz
GOFILES=$(shell go list ./... | grep -v vendor)
.DEFAULT: all
all: server client
# print the version
version:
@echo $(VERSION)
# print the name of the app
name:
@echo $(APP_NAME)
# print the package path
package:
@echo $(PACKAGE)
server:
godep go build $(LDFLAGS) -o $(APP_NAME)
client:
@$(MAKE) -C client/cli/go
run: server
./$(APP_NAME)
test:
godep go test $(GOFILES)
clean:
@echo Cleaning Workspace...
rm -rf $(APP_NAME)
rm -rf dist
@$(MAKE) -C client/cli/go clean
$(PACKAGE): all
@echo Packaging Binaries...
@mkdir -p tmp/$(APP_NAME)
@cp $(APP_NAME) tmp/$(APP_NAME)/
@cp client/cli/go/heketi-cli tmp/$(APP_NAME)/
@cp etc/heketi.json tmp/$(APP_NAME)/
@mkdir -p $(DIR)/dist/
tar -czf $@ -C tmp $(APP_NAME);
@rm -rf tmp
@echo
@echo Package $@ saved in dist directory
$(CLIENT_PACKAGE): all
@echo Packaging client Binaries...
@mkdir -p tmp/$(CLIENT_PKG_NAME)/bin
@mkdir -p tmp/$(CLIENT_PKG_NAME)/share/heketi/openshift/templates
@mkdir -p tmp/$(CLIENT_PKG_NAME)/share/heketi/kubernetes
@cp client/cli/go/topology-sample.json tmp/$(CLIENT_PKG_NAME)/share/heketi
@cp client/cli/go/heketi-cli tmp/$(CLIENT_PKG_NAME)/bin
@cp extras/openshift/templates/* tmp/$(CLIENT_PKG_NAME)/share/heketi/openshift/templates
@cp extras/kubernetes/* tmp/$(CLIENT_PKG_NAME)/share/heketi/kubernetes
@mkdir -p $(DIR)/dist/
tar -czf $@ -C tmp $(CLIENT_PKG_NAME);
@rm -rf tmp
@echo
@echo Package $@ saved in dist directory
dist: $(PACKAGE) $(CLIENT_PACKAGE)
.PHONY: server client test clean name run version