-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
68 lines (56 loc) · 1.51 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
GO ?= go
GOFMT ?= gofmt -s
GOPATH ?= $($(GO) env GOPATH)
BIN ?= /usr/local/bin
UDEV ?= /etc/udev/rules.d
DASH ?= $(if $(GOOS),_,)
GOOS ?=
GOARCH ?=
EXEC := xavierSrv$(DASH)$(GOOS)$(DASH)$(GOARCH)
GOOUT := $(shell pwd)/bin
GOFILES := main.go
.PHONY: help
help:
@echo "Make Routines:"
@echo " - \"\" print Make routines list"
@echo " - build creates the binary, Cross-Compiling ex : 'make build GOOS='linux' GOARCH='arm''"
@echo " - release Build for Linux 64/32/arm and OpenBSD 64/32"
@echo " - clean delete build files"
@echo " - install install the binary and service"
@echo " - remove remove binary and service"
@echo " - upgrade build and update installed binary"
.PHONY: install
install: build
sudo cp $(GOOUT)/$(EXEC) $(BIN)/$(EXEC)
# Add service
make clean
.PHONY: remove
remove:
sudo rm -rf $(BIN)/$(EXEC)
# Remove service
.PHONY: upgrade
upgrade: build
sudo cp $(GOOUT)/$(EXEC) $(BIN)/$(EXEC)
# Restart service
make clean
.PHONY: fmt
fmt:
$(GOFMT) -e -w $(GOFILES)
.PHONY: godep
godep:
$(GO) get github.com/BurntSushi/toml
$(GO) get github.com/xhit/go-simple-mail
.PHONY: build
build: godep
GOARCH=$(GOARCH) GOOS=$(GOOS) $(GO) build -o $(GOOUT)/$(EXEC) -a
.PHONY: buildall
buildall:
GOARCH=amd64 GOOS=linux make build
GOARCH=amd64 GOOS=openbsd make build
GOARCH=arm GOOS=linux make build
GOARCH=arm GOOS=openbsd make build
GOARCH=386 GOOS=linux make build
.PHONY: clean
clean:
$(GO) clean
rm -rf $(GOOUT)/*