-
Notifications
You must be signed in to change notification settings - Fork 17
/
Makefile
executable file
·182 lines (152 loc) · 6.35 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
EXECUTABLE := qng
EXECUTABLE_QX := qx
GITVER := $(shell git rev-parse --short=7 HEAD )
GITDIRTY := $(shell git diff --quiet || echo '-dirty')
GITVERSION = "$(GITVER)$(GITDIRTY)"
ifeq ($(DEV),)
DEV := dev
endif
RELEASE=release
LDFLAG_DEV = -X github.com/Qitmeer/qng/version.Build=$(DEV)-$(GITVERSION)
LDFLAG_RELEASE = -X github.com/Qitmeer/qng/version.Build=$(RELEASE)-$(GITVERSION)
GOFLAGS_DEV = -ldflags "$(LDFLAG_DEV)"
GOFLAGS_RELEASE = -ldflags "$(LDFLAG_RELEASE)"
GOFLAGS_RELEASE_QX = -ldflags "$(LDFLAG_RELEASE)"
VERSION=$(shell ./build/bin/qng --version | grep ^QNG | cut -d' ' -f3|cut -d'+' -f1)
GOBIN = ./build/bin
# Automatic detection operating system
ifeq ($(OS),Windows_NT)
# Windows Environment
OUTPUT_SUFFIX=.exe
else
OUTPUT_SUFFIX=
endif
UNIX_EXECUTABLES := \
build/release/darwin/amd64/bin/$(EXECUTABLE) \
build/release/darwin/arm64/bin/$(EXECUTABLE) \
build/release/linux/amd64/bin/$(EXECUTABLE) \
build/release/freebsd/amd64/bin/$(EXECUTABLE)
WIN_EXECUTABLES := \
build/release/windows/amd64/bin/$(EXECUTABLE).exe
UNIX_EXECUTABLES_QX := \
build/release/darwin/amd64/bin/$(EXECUTABLE_QX) \
build/release/darwin/arm64/bin/$(EXECUTABLE_QX) \
build/release/linux/amd64/bin/$(EXECUTABLE_QX) \
build/release/freebsd/amd64/bin/$(EXECUTABLE_QX)
WIN_EXECUTABLES_QX := \
build/release/windows/amd64/bin/$(EXECUTABLE_QX).exe
EXECUTABLES=$(UNIX_EXECUTABLES) $(WIN_EXECUTABLES) $(UNIX_EXECUTABLES_QX) $(WIN_EXECUTABLES_QX)
DEV_EXECUTABLES := \
build/dev/darwin/amd64/bin/$(EXECUTABLE) \
build/dev/darwin/arm64/bin/$(EXECUTABLE) \
build/dev/linux/amd64/bin/$(EXECUTABLE) \
build/dev/freebsd/amd64/bin/$(EXECUTABLE) \
build/dev/windows/amd64/bin/$(EXECUTABLE).exe
COMPRESSED_EXECUTABLES := \
$(UNIX_EXECUTABLES:%=%.qng.tar.gz) \
$(WIN_EXECUTABLES:%.exe=%.qng.zip) \
$(WIN_EXECUTABLES:%.exe=%.qng.cn.zip) \
$(UNIX_EXECUTABLES_QX:%=%.qx.tar.gz) \
$(WIN_EXECUTABLES_QX:%.exe=%.qx.zip)
RELEASE_TARGETS=$(EXECUTABLES) $(COMPRESSED_EXECUTABLES)
DEV_TARGETS=$(DEV_EXECUTABLES)
ZMQ = FALSE
DEBUG = OFF
.PHONY: qng qx release
qng: qng-build
@echo "Done building."
@echo " $(shell $(GOBIN)/qng --version))"
@echo "Run \"$(GOBIN)/qng\" to launch."
qng-build:
ifeq ($(ZMQ),TRUE)
@echo "Enalbe ZMQ"
@go build -o $(GOBIN)/qng$(OUTPUT_SUFFIX) $(GOFLAGS_DEV) -tags=zmq "github.com/Qitmeer/qng/cmd/qng"
else ifeq ($(DEBUG),ON)
@echo "Enable DEBUG"
@go build -o $(GOBIN)/qng$(OUTPUT_SUFFIX) $(GOFLAGS_DEV) -gcflags="all=-N -l" "github.com/Qitmeer/qng/cmd/qng"
else
@go build -o $(GOBIN)/qng$(OUTPUT_SUFFIX) $(GOFLAGS_DEV) "github.com/Qitmeer/qng/cmd/qng"
endif
qx:
@go build -o $(GOBIN)/qx $(GOFLAGS_DEV) "github.com/Qitmeer/qng/cmd/qx"
relay:
@go build -o $(GOBIN)/relaynode $(GOFLAGS_DEV) "github.com/Qitmeer/qng/cmd/relaynode"
generate-contracts-pkg:
@git submodule update --init --recursive
@if [ ! -d $(GOBIN) ]; then \
echo "Directory $(GOBIN) does not exist. Creating it now..."; \
mkdir -p $(GOBIN); \
fi
@if [ ! -e "$(GOBIN)/MeerChange.abi" ]; then \
touch $(GOBIN)/MeerChange.abi; \
jq -r '.abi' ./meerevm/contracts/meerchange/contracts/artifacts/MeerChange.json > $(GOBIN)/MeerChange.abi; \
touch $(GOBIN)/MeerChange.bin; \
jq -r '.bytecode' ./meerevm/contracts/meerchange/contracts/artifacts/MeerChange.json > $(GOBIN)/MeerChange.bin; \
touch $(GOBIN)/EntryPoint.abi; \
jq -r '.abi' ./meerevm/contracts/eip4337-account-abstraction/contracts/artifacts/EntryPoint.json > $(GOBIN)/EntryPoint.abi; \
touch $(GOBIN)/QngAccount.abi; \
jq -r '.abi' ./meerevm/contracts/eip4337-account-abstraction/contracts/artifacts/QngAccount.json > $(GOBIN)/QngAccount.abi; \
fi
@abigen --abi=$(GOBIN)/MeerChange.abi --bin=$(GOBIN)/MeerChange.bin --pkg=meerchange --out=./meerevm/meer/meerchange/meerchange.go
@abigen --abi=$(GOBIN)/EntryPoint.abi --pkg=entrypoint --out=./meerevm/meer/entrypoint/entrypoint.go
@abigen --abi=$(GOBIN)/QngAccount.abi --pkg=qngaccount --out=./meerevm/meer/qngaccount/qngaccount.go
checkversion: qng-build
# @echo version $(VERSION)
all: qng-build qx relay
# 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/qng/cmd/qng"
build/release/%/$(EXECUTABLE).exe:
@echo Build $(@)
@GOOS=$(OS) GOARCH=$(ARCH) go build $(GOFLAGS_RELEASE) -o $(@) "github.com/Qitmeer/qng/cmd/qng"
build/release/%/$(EXECUTABLE_QX):
@echo Build $(@)
@GOOS=$(OS) GOARCH=$(ARCH) go build $(GOFLAGS_RELEASE_QX) -o $(@) "github.com/Qitmeer/qng/cmd/qx"
build/release/%/$(EXECUTABLE_QX).exe:
@echo Build $(@)
@GOOS=$(OS) GOARCH=$(ARCH) go build $(GOFLAGS_RELEASE_QX) -o $(@) "github.com/Qitmeer/qng/cmd/qx"
# 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/qng/cmd/qng"
build/dev/%/$(EXECUTABLE).exe:
@echo Build $(@)
@GOOS=$(OS) GOARCH=$(ARCH) go build $(GOFLAGS_DEV) -o $(@) "github.com/Qitmeer/qng/cmd/qng"
%.qng.zip: %.exe
@echo zip $(EXECUTABLE)-$(VERSION)-$(OS)-$(ARCH)
@zip $(EXECUTABLE)-$(VERSION)-$(OS)-$(ARCH).zip "$<"
%.qng.cn.zip: %.exe
@echo zip $(EXECUTABLE)-$(VERSION)-$(OS)-$(ARCH)
@zip -j $(EXECUTABLE)-$(VERSION)-$(OS)-$(ARCH).cn.zip "$<" script/win/start.bat
%.qng.tar.gz : %
@echo tar $(EXECUTABLE)-$(VERSION)-$(OS)-$(ARCH)
@tar -zcvf $(EXECUTABLE)-$(VERSION)-$(OS)-$(ARCH).tar.gz "$<"
%.qx.tar.gz : %
@echo qx.tar.gz: $(@)
@tar -zcvf $(EXECUTABLE_QX)-$(VERSION)-$(OS)-$(ARCH).tar.gz "$<"
%.qx.zip: %.exe
@echo qx.zip: $(@)
@echo zip $(EXECUTABLE_QX)-$(VERSION)-$(OS)-$(ARCH)
@zip $(EXECUTABLE_QX)-$(VERSION)-$(OS)-$(ARCH).zip "$<"
release: clean checkversion
@echo "Build release version : $(VERSION)"
@$(MAKE) $(RELEASE_TARGETS)
@shasum -a 512 $(EXECUTABLES) > release-$(VERSION)_checksum.txt
@shasum -a 512 $(EXECUTABLE)-$(VERSION)-* >> release-$(VERSION)_checksum.txt
@shasum -a 512 $(EXECUTABLE_QX)-$(VERSION)-* >> release-$(VERSION)_checksum.txt
dev: clean checkversion
@echo "Build dev version : $(VERSION)"
@$(MAKE) $(DEV_TARGETS)
checksum: checkversion
@cat release-$(VERSION)_checksum.txt|shasum -c
clean:
@rm -f *.zip
@rm -f *.tar.gz
@rm -f ./build/bin/*
@rm -rf ./build/release
@rm -rf ./build/dev