-
Notifications
You must be signed in to change notification settings - Fork 27
/
Makefile
139 lines (111 loc) · 3.25 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
128
129
130
131
132
133
134
135
136
137
138
139
# ---------------------------------------------------------------------
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ---------------------------------------------------------------------
GO ?= go
#
# Check that commands exist
#
EXECUTABLES = git go date
K := $(foreach exec,$(EXECUTABLES),\
$(if $(shell which $(exec)),some string,$(error "No $(exec) in PATH")))
#
# Version info
#
VERSION = 1.0.3
COMPILED_AT = $(shell date +%s)
GIT_DIRTY = $(shell git diff --quiet|| echo 'Dirty')
GIT_COMMIT = $(shell git rev-parse HEAD)
LDFLAGS = -ldflags "-s -w \
-X $(PKG).Version=$(VERSION) \
-X $(PKG).CompiledAt=$(COMPILED_AT) \
-X $(PKG).GitCommit=$(GIT_COMMIT) \
-X $(PKG).GitDirty=$(GIT_DIRTY)"
API_CLIENT_OUTFILE=leakdb
API_SERVER_OUTFILE=leakdb-server
API_LAMDBA_OUTFILE=leakdb-lambda
CURATOR_OUTFILE=leakdb-curator
.bin:
mkdir -p ./bin/
bin/leakdb-curator: PKG=github.com/moloch--/leakdb/internal/curator
bin/leakdb-curator: .bin
GOOS=$(GOOS) $(GO) build $(LDFLAGS) -o ./bin/$(CURATOR_OUTFILE) ./cmd/curator
bin/leakdb: PKG=github.com/moloch--/leakdb/internal/api-client
bin/leakdb: .bin
GOOS=$(GOOS) $(GO) build $(LDFLAGS) -o ./bin/$(API_CLIENT_OUTFILE) ./cmd/api-client
bin/leakdb-server: PKG=github.com/moloch--/leakdb/internal/api-server
bin/leakdb-server: .bin
GOOS=$(GOOS) $(GO) build $(LDFLAGS) -o ./bin/$(API_SERVER_OUTFILE) ./cmd/api-server
bin/leakdb-lambda: .bin
cd aws/lambda/leakdb && GOOS=linux go build -o ./$(API_LAMDBA_OUTFILE) .
zip ./bin/$(API_LAMDBA_OUTFILE).zip ./aws/lambda/leakdb/$(API_LAMDBA_OUTFILE)
#
# Curator Builds
#
.PHONY: macos
macos: GOOS=darwin
macos: bin/leakdb-curator
.PHONY: linux
linux: GOOS=linux
linux: bin/leakdb-curator
.PHONY: windows
windows: GOOS=windows
windows: CURATOR_OUTFILE=leakdb-curator.exe
windows: bin/leakdb-curator
#
# API Client Builds
#
.PHONY: macos
macos: GOOS=darwin
macos: bin/leakdb
.PHONY: linux
linux: GOOS=linux
linux: bin/leakdb
.PHONY: windows
windows: GOOS=windows
windows: CURATOR_OUTFILE=leakdb.exe
windows: bin/leakdb
#
# API Server Builds
#
.PHONY: macos
macos: GOOS=darwin
macos: bin/leakdb-server
.PHONY: linux
linux: GOOS=linux
linux: bin/leakdb-server
.PHONY: windows
windows: GOOS=windows
windows: CURATOR_OUTFILE=leakdb-server.exe
windows: bin/leakdb-server
#
# API Lambda Builds
#
.PHONY: lambda
lambda: bin/leakdb-lambda
.PHONY: release
release:
rm -rf ./release
mkdir -p ./release
$(MAKE) clean
$(MAKE) lambda
cp ./bin/$(API_LAMDBA_OUTFILE).zip ./release
$(MAKE) clean
$(MAKE) linux
zip -r ./release/leakdb-linux.zip ./bin/
$(MAKE) clean
$(MAKE) windows
zip -r ./release/leakdb-windows.zip ./bin/
$(MAKE) clean
$(MAKE) macos
zip -r ./release/leakdb-macos.zip ./bin/
clean:
rm -f ./bin/leakdb*