-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
73 lines (52 loc) · 1.31 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
.PHONY: init proto build debug test clean image
tag?= "curve-manager:unknown"
# go env
GOPROXY := "https://goproxy.cn,direct"
GOOS := $(if $(GOOS),$(GOOS),$(shell go env GOOS))
GOARCH := $(if $(GOARCH),$(GOARCH),$(shell go env GOARCH))
CGO_LDFLAGS := "-static"
CC := musl-gcc
GOENV := GO111MODULE=on
GOENV += GOPROXY=$(GOPROXY)
GOENV += CC=$(CC)
GOENV += CGO_ENABLED=1 CGO_LDFLAGS=$(CGO_LDFLAGS)
GOENV += GOOS=$(GOOS) GOARCH=$(GOARCH)
# go
GO := go
# output
OUTPUT := bin/pigeon
# build flags
LDFLAGS := -s -w
LDFLAGS += -extldflags "-static -fpic"
BUILD_FLAGS := -a
BUILD_FLAGS += -trimpath
BUILD_FLAGS += -ldflags '$(LDFLAGS)'
BUILD_FLAGS += $(EXTRA_FLAGS)
# debug flags
GCFLAGS := "all=-N -l"
DEBUG_FLAGS := -gcflags=$(GCFLAGS)
# packages
PACKAGES := $(PWD)/cmd/pigeon/main.go
# test flags
TEST_FLAGS := -v
TEST_FLAGS += -p 3
TEST_FLAGS += -cover
TEST_FLAGS += $(DEBUG_FLAGS)
# test env
TEST_ENV := ROOT=$(PWD)
# curve-go-rpc path
RPC_PATH = external/curve-go-rpc
init:
$(GO) mod init
proto:
cd $(RPC_PATH) && make proto
build: proto
$(GOENV) $(GO) build -o $(OUTPUT) $(BUILD_FLAGS) $(PACKAGES)
debug:
$(GOENV) $(GO) build -o $(OUTPUT) $(DEBUG_FLAGS) $(PACKAGES)
test:
$(TEST_ENV) $(GO) test $(TEST_FLAGS) ./...
clean:
rm -rf bin/* docker/pigeon docker/website
image:
bash image.sh $(tag)