-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
127 lines (99 loc) · 3.39 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
NAME = onesky-sdk-cli
NAME_BIN=onesky
SHELL = /bin/bash
LOCAL_DIR = $(shell pwd)
LOCAL_BIN = $(LOCAL_DIR)/bin
INSTALL_DIR = /usr/local/bin
all:
@echo "################################################################################################"
@echo "Posible jobs: setup test, build, install, uninstall, build_all, build_mac, build_win, build_nix"
@echo " setup == 'make test && make build && make install'"
@echo " test - run tests"
@echo " build - build binary for current platform"
@echo " install - install builded binary"
@echo " uninstall - uninstall binary from system"
@echo " build_all - create builds for mac, windows and linux"
@echo " build_mac, build_win, build_nix - create binaries for specific platform"
@echo "!by default, the builded binaries are located in local 'bin/' dorrectory"
@echo "################################################################################################"
@echo "Use chain 'make test && make build && make install' or 'make setup'"
@echo ""
install:
@echo " *** Install binary"
install $(LOCAL_BIN)/$(NAME_BIN) $(INSTALL_DIR)/$(NAME_BIN)
setup: test build install
uninstall:
@rm -r $(INSTALL_DIR)/$(NAME_BIN)
build:
@echo "###############################"
@echo "# Compile build"
@echo "###############################"
$(MAKE) clean
mkdir -p $(LOCAL_BIN)
@go version
GO111MODULE=on go build -v -o $(LOCAL_BIN)/$(NAME_BIN) src/onesky.go
@echo " *** Done ***"
@echo "See: " $(LOCAL_BIN)/$(NAME_BIN)
@echo ""
build_mac:
@echo "###############################"
@echo "# Compile MacOS build"
@echo "###############################"
$(MAKE) clean
mkdir -p $(LOCAL_BIN)
@go version
GOOS=darwin GOARCH=amd64 go build -v -o $(LOCAL_BIN)/$(NAME_BIN) src/onesky.go
@echo " *** Build is compiled ***"
@echo "See: " $(LOCAL_BIN)/$(NAME_BIN)
@echo ""
build_win:
@echo "###############################"
@echo "# Compile Windows build"
@echo "###############################"
$(MAKE) clean
@mkdir -p $(LOCAL_BIN)
@go version
GOOS=windows GOARCH=amd64 go build -v -o $(LOCAL_BIN)/$(NAME_BIN) src/onesky.go
@echo " *** Build is compiled ***"
@echo "See: " $(LOCAL_BIN)/$(NAME_BIN)
@echo ""
build_nix:
@echo "###############################"
@echo "# Compile Linux build"
@echo "###############################"
$(MAKE) clean
@mkdir -p $(LOCAL_BIN)
@go version
GOOS=linux GOARCH=amd64 go build -v -o $(LOCAL_BIN)/$(NAME_BIN) src/onesky.go
@echo " *** Build is compiled ***"
@echo "See: " $(LOCAL_BIN)/$(NAME_BIN)
@echo ""
build_all:
@echo "###############################"
@echo "# Compile cross-platfom builds"
@echo "###############################"
mkdir -p $(LOCAL_BIN)
@go version
go build -v -o $(LOCAL_BIN)/$(NAME_BIN) src/onesky.go
GOOS=linux GOARCH=amd64 GO111MODULE=on go build -v -o $(LOCAL_BIN)/$(NAME_BIN)_nix src/onesky.go
GOOS=windows GOARCH=amd64 GO111MODULE=on go build -v -o $(LOCAL_BIN)/$(NAME_BIN)_mac src/onesky.go
GOOS=darwin GOARCH=amd64 GO111MODULE=on go build -v -o $(LOCAL_BIN)/$(NAME_BIN)_win src/onesky.go
@echo " *** Done ***"
@echo "bin/:"
@ls -lh bin/
@echo ""
test:
@echo "###############################"
@echo "#**** TESTING BUILD ****#"
@echo "###############################"
@echo " ==> Testing..."
go test -v -tags=test ./...
@echo " *** Build is OK ***"
@echo ""
clean:
@rm -rf $(LOCAL_BIN)/$(NAME_BIN)
clean_all:
@rm -rf $(LOCAL_BIN)
purge:
@rm -rf $(LOCAL_BIN)
$(MAKE) uninstall