This repository has been archived by the owner on Aug 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathMakefile
executable file
·115 lines (94 loc) · 3.78 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
EXECUTABLE := qitmeer
GITVER := $(shell git rev-parse --short=7 HEAD )
GITDIRTY := $(shell git diff --quiet || echo '-dirty')
GITVERSION = "$(GITVER)$(GITDIRTY)"
DEV=dev
RELEASE=release
LDFLAG_DEV = -X github.com/Qitmeer/qitmeer/version.Build=$(DEV)-$(GITVERSION)
LDFLAG_RELEASE = -X github.com/Qitmeer/qitmeer/version.Build=$(RELEASE)-$(GITVERSION)
GOFLAGS_DEV = -ldflags "$(LDFLAG_DEV)"
GOFLAGS_RELEASE = -ldflags "$(LDFLAG_RELEASE)"
VERSION=$(shell ./build/bin/qitmeer --version | grep ^qitmeer | cut -d' ' -f3|cut -d'+' -f1)
GOBIN = ./build/bin
UNIX_EXECUTABLES := \
build/release/darwin/amd64/bin/$(EXECUTABLE) \
build/release/linux/amd64/bin/$(EXECUTABLE)
WIN_EXECUTABLES := \
build/release/windows/amd64/bin/$(EXECUTABLE).exe
EXECUTABLES=$(UNIX_EXECUTABLES) $(WIN_EXECUTABLES)
DEV_EXECUTABLES := \
build/dev/darwin/amd64/bin/$(EXECUTABLE) \
build/dev/linux/amd64/bin/$(EXECUTABLE) \
build/dev/windows/amd64/bin/$(EXECUTABLE).exe
COMPRESSED_EXECUTABLES=$(UNIX_EXECUTABLES:%=%.tar.gz) $(WIN_EXECUTABLES:%.exe=%.zip) $(WIN_EXECUTABLES:%.exe=%.cn.zip)
RELEASE_TARGETS=$(EXECUTABLES) $(COMPRESSED_EXECUTABLES)
DEV_TARGETS=$(DEV_EXECUTABLES)
ZMQ = FALSE
.PHONY: qitmeer qx release
qitmeer: qitmeer-build
@echo "Done building."
@echo " $(shell $(GOBIN)/qitmeer --version))"
@echo "Run \"$(GOBIN)/qitmeer\" to launch."
qitmeer-build:
ifeq ($(ZMQ),TRUE)
@echo "Enalbe ZMQ"
@go build -o $(GOBIN)/qitmeer $(GOFLAGS_DEV) -tags=zmq "github.com/Qitmeer/qitmeer/cmd/qitmeerd"
else
@go build -o $(GOBIN)/qitmeer $(GOFLAGS_DEV) "github.com/Qitmeer/qitmeer/cmd/qitmeerd"
endif
qx:
@go build -o $(GOBIN)/qx $(GOFLAGS_DEV) "github.com/Qitmeer/qitmeer/cmd/qx"
burn:
@go build -o $(GOBIN)/burn $(GOFLAGS_DEV) "github.com/Qitmeer/qitmeer/cmd/burn"
relay:
@go build -o $(GOBIN)/relaynode $(GOFLAGS_DEV) "github.com/Qitmeer/qitmeer/cmd/relaynode"
fastibd:
@go build -o $(GOBIN)/fastibd $(GOFLAGS_DEV) "github.com/Qitmeer/qitmeer/cmd/fastibd"
checkversion: qitmeer-build
# @echo version $(VERSION)
all: qitmeer-build qx burn relay fastibd
# amd64 release
build/release/%: OS=$(word 3,$(subst /, ,$(@)))
build/release/%: ARCH=$(word 4,$(subst /, ,$(@)))
build/release/%/$(EXECUTABLE):
@echo Build $(@)
@GOOS=$(OS) GOARCH=$(ARCH) go build $(GOFLAGS_RELEASE) -o $(@) "github.com/Qitmeer/qitmeer/cmd/qitmeerd"
build/release/%/$(EXECUTABLE).exe:
@echo Build $(@)
@GOOS=$(OS) GOARCH=$(ARCH) go build $(GOFLAGS_RELEASE) -o $(@) "github.com/Qitmeer/qitmeer/cmd/qitmeerd"
# amd64 dev
build/dev/%: OS=$(word 3,$(subst /, ,$(@)))
build/dev/%: ARCH=$(word 4,$(subst /, ,$(@)))
build/dev/%/$(EXECUTABLE):
@echo Build $(@)
@GOOS=$(OS) GOARCH=$(ARCH) go build $(GOFLAGS_DEV) -o $(@) "github.com/Qitmeer/qitmeer/cmd/qitmeerd"
build/dev/%/$(EXECUTABLE).exe:
@echo Build $(@)
@GOOS=$(OS) GOARCH=$(ARCH) go build $(GOFLAGS_DEV) -o $(@) "github.com/Qitmeer/qitmeer/cmd/qitmeerd"
%.zip: %.exe
@echo zip $(EXECUTABLE)-$(VERSION)-$(OS)-$(ARCH)
@zip $(EXECUTABLE)-$(VERSION)-$(OS)-$(ARCH).zip "$<"
%.cn.zip: %.exe
@echo Build $(@).cn.zip
@echo zip $(EXECUTABLE)-$(VERSION)-$(OS)-$(ARCH)
@zip -j $(EXECUTABLE)-$(VERSION)-$(OS)-$(ARCH).cn.zip "$<" script/win/start.bat
%.tar.gz : %
@echo tar $(EXECUTABLE)-$(VERSION)-$(OS)-$(ARCH)
@tar -zcvf $(EXECUTABLE)-$(VERSION)-$(OS)-$(ARCH).tar.gz "$<"
release: clean checkversion
@echo "Build release version : $(VERSION)"
@$(MAKE) $(RELEASE_TARGETS)
@shasum -a 512 $(EXECUTABLES) > $(EXECUTABLE)-$(VERSION)_checksum.txt
@shasum -a 512 $(EXECUTABLE)-$(VERSION)-* >> $(EXECUTABLE)-$(VERSION)_checksum.txt
dev: clean checkversion
@echo "Build dev version : $(VERSION)"
@$(MAKE) $(DEV_TARGETS)
checksum: checkversion
@cat $(EXECUTABLE)-$(VERSION)_checksum.txt|shasum -c
clean:
@rm -f *.zip
@rm -f *.tar.gz
@rm -f ./build/bin/qx
@rm -f ./build/bin/qitmeer
@rm -rf ./build/release
@rm -rf ./build/dev