forked from BishopFox/sliver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
94 lines (75 loc) · 2.68 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
#
# Makefile for Sliver
#
GO ?= go
ENV = CGO_ENABLED=0
TAGS = -tags netgo
LDFLAGS = -ldflags '-s -w'
GIT_DIRTY = $(shell git diff --quiet|| echo 'Dirty')
GIT_VERSION = $(shell git rev-parse HEAD)
SED_INPLACE := sed -i
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
SED_INPLACE := sed -i ''
endif
.PHONY: macos
macos: clean version pb
GOOS=darwin $(ENV) $(GO) build $(TAGS) $(LDFLAGS) -o sliver-server ./server
GOOS=darwin $(ENV) $(GO) build $(TAGS) $(LDFLAGS) -o sliver-client ./client
.PHONY: linux
linux: clean version pb
GOOS=linux $(ENV) $(GO) build $(TAGS) $(LDFLAGS) -o sliver-server ./server
GOOS=linux $(ENV) $(GO) build $(TAGS) $(LDFLAGS) -o sliver-client ./client
.PHONY: windows
windows: clean version pb
GOOS=windows $(ENV) $(GO) build $(TAGS) $(LDFLAGS) -o sliver-server.exe ./server
GOOS=windows $(ENV) $(GO) build $(TAGS) $(LDFLAGS) -o sliver-client.exe ./client
#
# Static builds were we bundle everything together
#
.PHONY: static-macos
static-macos: clean version pb packr
packr
$(SED_INPLACE) '/$*.windows\/go\.zip/d' ./server/assets/a_assets-packr.go
$(SED_INPLACE) '/$*.linux\/go\.zip/d' ./server/assets/a_assets-packr.go
GOOS=darwin $(ENV) $(GO) build $(TAGS) $(LDFLAGS) -o sliver-server ./server
.PHONY: static-windows
static-windows: clean version pb packr
packr
$(SED_INPLACE) '/$*.darwin\/go\.zip/d' ./server/assets/a_assets-packr.go
$(SED_INPLACE) '/$*.linux\/go\.zip/d' ./server/assets/a_assets-packr.go
GOOS=windows $(ENV) $(GO) build $(TAGS) $(LDFLAGS) -o sliver-server.exe ./server
.PHONY: static-linux
static-linux: clean version pb packr
$(SED_INPLACE) '/$*.darwin\/go\.zip/d' ./server/assets/a_assets-packr.go
$(SED_INPLACE) '/$*.windows\/go\.zip/d' ./server/assets/a_assets-packr.go
GOOS=linux $(ENV) $(GO) build $(TAGS) $(LDFLAGS) -o sliver-server ./server
.PHONY: pb
pb:
go install ./vendor/github.com/golang/protobuf/protoc-gen-go
protoc -I protobuf/ protobuf/sliver/sliver.proto --go_out=protobuf/
protoc -I protobuf/ protobuf/client/client.proto --go_out=protobuf/
.PHONY: version
version:
printf "package version\n\nconst GitVersion = \"%s\"\n" $(GIT_VERSION) > ./client/version/version.go
printf "const GitDirty = \"%s\"\n" $(GIT_DIRTY) >> ./client/version/version.go
.PHONY: packr
packr:
cd ./server/
packr
cd ..
.PHONY: clean-version
clean-version:
printf "package version\n\nconst GitVersion = \"\"\n" > ./client/version/version.go
.PHONY: clean-all
clean-all: clean clean-version
rm -f ./assets/darwin/go.zip
rm -f ./assets/windows/go.zip
rm -f ./assets/linux/go.zip
rm -f ./assets/*.zip
.PHONY: clean
clean: clean-version
packr clean
rm -f ./protobuf/client/*.pb.go
rm -f ./protobuf/sliver/*.pb.go
rm -f sliver-client sliver-server *.exe