-
Notifications
You must be signed in to change notification settings - Fork 884
/
Makefile
62 lines (47 loc) · 1.33 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
MAIN_FILE=main.go
TEST_FILE=main_test.go
BINARY_NAME=proxy
BINARY_LINUX=$(BINARY_NAME)_linux
BINARY_WINDOWS=$(BINARY_NAME)_windows
BINARY_BSD=$(BINARY_NAME)_freebsd
GO=go
GOBUILD=$(GO) build
GOCLEAN=$(GO) clean
GOTEST=$(GO) test
GOGET=$(GO) get
.DEFAULT_GOAL := all
.PHONY: test
DIST_DIR=dist
TEST_DIR=
all: test build
build:
$(GOBUILD) -ldflags "-s -w" -o $(DIST_DIR)/$(BINARY_NAME) $(MAIN_FILE)
test:
$(GOTEST) -v $(MAIN_FILE) $(TEST_FILE)
clean:
$(GOCLEAN)
rm -f $(DIST_DIR)/$(BINARY_NAME)
rm -f $(DIST_DIR)/$(BINARY_LINUX)
rm -f $(DIST_DIR)/$(BINARY_WINDOWS)
rm -f $(DIST_DIR)/$(BINARY_BSD)
deps:
$(GOGET) ./..
build_linux: test linux
build_linux_xgo: test linux
build_windows: test windows
build_windows_xgo: test windows
build_freebsd: test freebsd
linux:
GOOS=linux GOARCH=amd64 $(GOBUILD) -ldflags "-s -w" -o $(DIST_DIR)/$(BINARY_LINUX) $(MAIN_FILE)
windows:
GOOS=windows GOARCH=amd64 $(GOBUILD) -ldflags "-s -w" -o $(DIST_DIR)/$(BINARY_WINDOWS) $(MAIN_FILE)
freebsd:
GOOS=freebsd GOARCH=amd64 $(GOBUILD) -ldflags "-s -w" -o $(DIST_DIR)/$(BINARY_BSD) $(MAIN_FILE)
linux_amd64_xgo:
xgo --targets=linux/amd64 --dest $(DIST_DIR)/ ./
linux_386_xgo:
xgo --targets=linux/386 --dest $(DIST_DIR)/ ./
windows_xgo:
xgo --targets=windows/amd64 --dest $(DIST_DIR)/ ./
freebsd_xgo:
xgo --targets=freebsd/amd64 --dest $(DIST_DIR)/ ./