-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
62 lines (49 loc) · 1.79 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
OS_ID = generic
MACHINE = generic
UNAME_S := $(shell uname -s)
UNAME_M := $(shell uname -m)
ifeq ($(UNAME_S),Linux)
OS_ID = Linux_$(UNAME_M)
GID = god
endif
ifeq ($(UNAME_S),Darwin)
OS_ID = Darwin_$(UNAME_M)
GID = staff
endif
CODE_NAME = deployer
SOURCES = $(CODE_NAME).go \
mod/initialize/initialize.go \
mod/utils/utils.go \
mod/vars/vars.go \
mod/msg/msg.go \
mod/logs/logs.go \
mod/help/help.go \
mod/config/config.go \
mod/api/api.go
BUILT_SOURCES = $(SOURCES)
TOOL_VERSION := $(shell cat mod/vars/vars.go | grep MyVersion | egrep -v MyProgname | awk '{print $$3}')
all: release/$(CODE_NAME)_$(OS_ID) \
release/$(CODE_NAME)_$(OS_ID).tar.gz \
release/$(CODE_NAME)_$(OS_ID).sha256
release/$(CODE_NAME)_$(OS_ID): $(BUILT_SOURCES)
@echo "build the $(CODE_NAME)_$(OS_ID) binary..."
@go build -o release/$(CODE_NAME)_$(OS_ID) $(CODE_NAME).go
@echo "set owner and strip the binary"
@chown luc:$(GID) release/$(CODE_NAME)_$(OS_ID)
@strip release/$(CODE_NAME)_$(OS_ID)
release/$(CODE_NAME)_$(OS_ID).tar.gz: release/$(CODE_NAME)_$(OS_ID)
@echo "create the $(CODE_NAME)_$(OS_ID).tar.gz archive..."
@(cd release ; tar zcf $(CODE_NAME)_$(OS_ID).tar.gz $(CODE_NAME)_$(OS_ID))
release/$(CODE_NAME)_$(OS_ID).sha256: release/$(CODE_NAME)_$(OS_ID).tar.gz
@echo "create the sha256 information file..."
@sha256sum release/$(CODE_NAME)_$(OS_ID).tar.gz | awk '{print $$1}' > release/$(CODE_NAME)_$(OS_ID).sha256
@echo "SHA256: $$(cat release/$(CODE_NAME)_$(OS_ID).sha256)"
install: release/$(CODE_NAME)_$(OS_ID)
@echo "Installing the new $(CODE_NAME) binary..."
@sudo cp release/$(CODE_NAME)_$(OS_ID) /usr/local/sbin/$(CODE_NAME)
@sudo chmod 0755 /usr/local/sbin/$(CODE_NAME)
@sudo chown 0:0 /usr/local/sbin/$(CODE_NAME)
clean:
@rm -f release/*$(OS_ID)*
changelog:
@echo "version built $(TOOL_VERSION)"