-
Notifications
You must be signed in to change notification settings - Fork 56
Expand file tree
/
Copy pathMakefile
More file actions
86 lines (71 loc) · 2.6 KB
/
Makefile
File metadata and controls
86 lines (71 loc) · 2.6 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
GO_VER := 1.24.0
BLOAT_FILES := AUTHORS CONTRIBUTORS PATENTS VERSION favicon.ico robots.txt SECURITY.md CONTRIBUTING.md LICENSE README.md ./doc ./test ./api ./misc
GARBLE_VER := 0.14.2
GO ?= go
APP_VERSION ?= v2.2.1
VERSION_PKG := github.com/ttpreport/ligolo-mp/v2/internal/version
LDFLAGS := -X $(VERSION_PKG).Version=$(APP_VERSION)
ARCH := $(shell uname -m)
ifeq ($(ARCH),aarch64)
ARCH := arm64
else ifneq (,$(findstring armv5,$(ARCH)))
ARCH := armv5
else ifneq (,$(findstring armv6,$(ARCH)))
ARCH := armv6
else ifneq (,$(findstring armv7,$(ARCH)))
ARCH := arm
else ifeq ($(ARCH),x86_64)
ARCH := amd64
else ifeq ($(ARCH),x86)
ARCH := 386
else ifeq ($(ARCH),i686)
ARCH := 386
else ifeq ($(ARCH),i386)
ARCH := 386
endif
TARGET_ARCH ?= $(ARCH)
TARGET_OS ?= linux
.PHONY: build
build: assets binaries
.PHONY: assets
assets: go agent
.PHONY: binaries
binaries: server client
.PHONY: go
go:
# Build go
cd artifacts && curl -L --output go/$(TARGET_OS)/$(TARGET_ARCH)/go.tar.gz https://dl.google.com/go/go$(GO_VER).$(TARGET_OS)-$(TARGET_ARCH).tar.gz
cd artifacts/go/$(TARGET_OS)/$(TARGET_ARCH) && tar xvf go.tar.gz
cd artifacts/go/$(TARGET_OS)/$(TARGET_ARCH) && rm -rf $(BLOAT_FILES)
rm -f artifacts/go/$(TARGET_OS)/$(TARGET_ARCH)/go/pkg/tool/$(TARGET_OS)_$(TARGET_ARCH)/doc
rm -f artifacts/go/$(TARGET_OS)/$(TARGET_ARCH)/go/pkg/tool/$(TARGET_OS)_$(TARGET_ARCH)/tour
rm -f artifacts/go/$(TARGET_OS)/$(TARGET_ARCH)/go/pkg/tool/$(TARGET_OS)_$(TARGET_ARCH)/test2json
# Build garble
cd artifacts/go/$(TARGET_OS)/$(TARGET_ARCH)/go/bin && curl -L --output garble https://github.com/ttpreport/garble/releases/download/v$(GARBLE_VER)/garble_$(TARGET_OS)_$(TARGET_ARCH) && chmod +x garble
# Bundle
cd artifacts/go/$(TARGET_OS)/$(TARGET_ARCH) && zip -r go.zip ./go
# Clean up
cd artifacts/go/$(TARGET_OS)/$(TARGET_ARCH) && rm -rf go go.tar.gz
.PHONY: agent
agent:
cd artifacts/agent && go mod tidy
cd artifacts/agent && go mod vendor
cd artifacts/agent && zip -r ../agent.zip .
.PHONY: server
server:
GOOS=$(TARGET_OS) GOARCH=$(TARGET_ARCH) CGO_ENABLED=0 $(GO) build -mod=vendor -trimpath -ldflags "$(LDFLAGS)" -o ligolo-mp ./cmd/server/
.PHONY: client
client:
GOOS=$(TARGET_OS) GOARCH=$(TARGET_ARCH) CGO_ENABLED=0 $(GO) build -mod=vendor -trimpath -ldflags "$(LDFLAGS)" -o ligolo-mp-client ./cmd/client/
.PHONY: protobuf
protobuf:
protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative protobuf/ligolo.proto
.PHONY: clean
clean:
rm -rf artifacts/agent.zip artifacts/go/*/*/*
.PHONY: install
install:
./install_server.sh
.PHONY: service
service:
./install_service.sh