forked from FlowingSPDG/gotv-plus-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
71 lines (65 loc) · 1.83 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
# Go
GOCMD=go
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOGET=$(GOCMD) get
BINARY_NAME=gotv_plus
DIST_DIR=build
SERVER_DIR=server
OS_Linux=linux
OS_Windows=windows
OS_Mac=darwin
ARCH_386=386
ARCH_AMD64=amd64
# Replacing "RM" command for Windows PowerShell.
RM = rm -rf
ifeq ($(OS),Windows_NT)
RM = Remove-Item -Recurse -Force
endif
# Replacing "MKDIR" command for Windows PowerShell.
MKDIR = mkdir -p
ifeq ($(OS),Windows_NT)
MKDIR = New-Item -ItemType Directory
endif
# Replacing "CP" command for Windows PowerShell.
CP = cp -R
ifeq ($(OS),Windows_NT)
CP = powershell -Command Copy-Item -Recurse -Force
endif
# Replacing "GOPATH" command for Windows PowerShell.
GOPATHDIR = $GOPATH
ifeq ($(OS),Windows_NT)
GOPATHDIR = $$env:GOPATH
endif
.DEFAULT_GOAL := build-all
test:
$(GOTEST) -v ./...
clean:
@$(GOCLEAN)
-@$(RM) $(DIST_DIR)/*
deps-go:
@$(GOGET)
# Cross compile for go
build-prepare:
@cd ./server && $(GOGET) github.com/mitchellh/gox \
github.com/konsorten/go-windows-terminal-sequences
build-all: clean build-linux build-windows build-mac
build-linux: build-prepare
@cd ./server && gox \
-os="$(OS_Linux)" \
-arch="$(ARCH_AMD64)" \
--output "../$(DIST_DIR)/$(BINARY_NAME)_$(OS_Linux)_$(ARCH_AMD64)/$(BINARY_NAME)"
$(CP) ./server/templates $(DIST_DIR)/$(BINARY_NAME)_$(OS_Linux)_$(ARCH_AMD64)/
build-windows: build-prepare
@cd ./server && gox \
-os="$(OS_Windows)" \
-arch="$(ARCH_AMD64)" \
--output "../$(DIST_DIR)/$(BINARY_NAME)_$(OS_Windows)_$(ARCH_AMD64)/$(BINARY_NAME)"
$(CP) ./server/templates $(DIST_DIR)/$(BINARY_NAME)_$(OS_Windows)_$(ARCH_AMD64)/
build-mac: build-prepare
@cd ./server && gox \
-os="$(OS_Mac)" \
-arch="$(ARCH_AMD64)" \
--output "../$(DIST_DIR)/$(BINARY_NAME)_$(OS_Mac)_$(ARCH_AMD64)/$(BINARY_NAME)"
$(CP) ./server/templates $(DIST_DIR)/$(BINARY_NAME)_$(OS_Mac)_$(ARCH_AMD64)/