-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile.release
229 lines (200 loc) · 10.6 KB
/
Makefile.release
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
# Thanks to https://gist.github.com/asukakenji/f15ba7e588ac42795f421b48b8aede63#file-go-os-arch-md
# https://github.com/golang/go/wiki/GoArm
TARGET_TOOLS =
TARGET_TOOLS += geth
TARGET_TOOLS += abigen
TARGET_TOOLS += bootnode
TARGET_TOOLS += clef
TARGET_TOOLS += evm
TARGET_TOOLS += rlpdump
RELEASE_GOFLAGS = -mod=vendor
#RELEASE_GOFLAGS+=-v
RELEASE_MAIN = energi3
RELEASE_RAW_VER = $(shell jq -r .version futoin.json)
RELEASE_VER = $(RELEASE_MAIN)-$(RELEASE_RAW_VER)
.PHONY: release release-tools
.PHONY: release-linux release-windows release-macos
release: release-linux release-windows release-macos
release-tools:
-sudo -n dpkg --add-architecture i386
-sudo -n apt-get update
-sudo -n apt-get -yq --no-install-suggests --no-install-recommends --force-yes install \
gcc-multilib-i686-linux-gnu gcc-i686-linux-gnu libc6-dev-i386-amd64-cross \
g++-multilib-i686-linux-gnu g++-i686-linux-gnu \
mingw-w64 binutils-mingw-w64 gcc-mingw-w64 \
wine32-development wine64-development wine64-development-tools \
nsis nsis-pluginapi \
gcc-multilib-arm-linux-gnueabi gcc-arm-linux-gnueabi libc6-dev-armel-cross \
g++-multilib-arm-linux-gnueabi g++-arm-linux-gnueabi \
gcc-multilib-arm-linux-gnueabihf gcc-arm-linux-gnueabihf libc6-dev-armhf-cross \
g++-multilib-arm-linux-gnueabihf g++-arm-linux-gnueabihf \
gcc-aarch64-linux-gnu libc6-dev-arm64-cross \
g++-aarch64-linux-gnu \
gcc-multilib-mips-linux-gnu gcc-mips-linux-gnu libc6-dev-mips-cross \
g++-multilib-mips-linux-gnu g++-mips-linux-gnu \
gcc-multilib-mips64-linux-gnuabi64 gcc-mips64-linux-gnuabi64 libc6-dev-mips64-cross \
g++-multilib-mips64-linux-gnuabi64 g++-mips64-linux-gnuabi64 \
gcc-multilib-mipsel-linux-gnu gcc-mipsel-linux-gnu libc6-dev-mipsel-cross \
g++-multilib-mipsel-linux-gnu g++-mipsel-linux-gnu \
gcc-multilib-mips64el-linux-gnuabi64 gcc-mips64el-linux-gnuabi64 libc6-dev-mips64el-cross \
g++-multilib-mips64el-linux-gnuabi64 g++-mips64el-linux-gnuabi64 \
zip dos2unix
.PHONY: release-linux-common
.PHONY: release-linux-amd64 release-linux-i686
.PHONY: release-linux-armv5 release-linux-armv6 release-linux-armv7 release-linux-armv8
.PHONY: release-linux-mips release-linux-mipsel release-linux-mips64 release-linux-mips64el
release-linux: release-linux-amd64 release-linux-i686
release-linux: release-linux-armv5 release-linux-armv6 release-linux-armv7 release-linux-armv8
release-linux: release-linux-mips release-linux-mipsel release-linux-mips64 release-linux-mips64el
RELEASE_LINUX_COMMON := make -f Makefile.release release-linux-common --no-print-directory
release-linux-common:
@echo Building $(RELEASE_TARGET)
@rm -rf build/release/$(RELEASE_TARGET)
@mkdir -p build/release/$(RELEASE_TARGET)
@for t in $(TARGET_TOOLS); do \
export GOCACHE=$(CURDIR)/build/release/$(RELEASE_TARGET)/cache; \
export PKG_CONFIG_PATH=/usr/$(HOST)/lib/pkgconfig; \
export CC=$(HOST)-gcc-7; \
export CXX=$(HOST)-g++-7; \
export CGO_ENABLED=1; \
go build -o build/release/$(RELEASE_TARGET)/bin/$$t $(RELEASE_GOFLAGS) ./cmd/$$t; \
done
@mv build/release/$(RELEASE_TARGET)/bin/geth build/release/$(RELEASE_TARGET)/bin/$(RELEASE_MAIN)
@cp COPYING build/release/$(RELEASE_TARGET)/
@tar czf build/release/$(RELEASE_TARGET)/$(RELEASE_TARGET).tgz \
-C build/release $(RELEASE_TARGET)/bin/$(RELEASE_MAIN) $(RELEASE_TARGET)/COPYING
@tar czf build/release/$(RELEASE_TARGET)/$(RELEASE_TARGET)-alltools.tgz \
-C build/release $(RELEASE_TARGET)/bin/ $(RELEASE_TARGET)/COPYING
@ls build/release/$(RELEASE_TARGET)/$(RELEASE_TARGET)*.tgz
release-linux-amd64:
@RELEASE_TARGET=$(RELEASE_VER)-linux-amd64 \
GOOS=linux GOARCH=amd64 HOST=x86_64-linux-gnu $(RELEASE_LINUX_COMMON)
release-linux-i686:
@RELEASE_TARGET=$(RELEASE_VER)-linux-i686 \
GOOS=linux GOARCH=386 HOST=i686-linux-gnu $(RELEASE_LINUX_COMMON)
release-linux-armv5:
@RELEASE_TARGET=$(RELEASE_VER)-linux-armv5 \
CFLAGS="-march=armv5" CXXFLAGS="-march=armv5" \
CGO_CFLAGS="-march=armv5" CGO_CXXFLAGS="-march=armv5" \
GOOS=linux GOARCH=arm GOARM=5 HOST=arm-linux-gnueabi $(RELEASE_LINUX_COMMON)
release-linux-armv6:
@RELEASE_TARGET=$(RELEASE_VER)-linux-armv6 \
CFLAGS="-march=armv6" CXXFLAGS="-march=armv6" \
CGO_CFLAGS="-march=armv6" CGO_CXXFLAGS="-march=armv6" \
GOOS=linux GOARCH=arm GOARM=6 HOST=arm-linux-gnueabi $(RELEASE_LINUX_COMMON)
release-linux-armv7:
@RELEASE_TARGET=$(RELEASE_VER)-linux-armv7 \
CFLAGS="-march=armv7-a -fPIC" CXXFLAGS="-march=armv7-a -fPIC" \
CGO_CFLAGS="-march=armv7-a -fPIC" CGO_CXXFLAGS="-march=armv7-a -fPIC" \
GOOS=linux GOARCH=arm GOARM=7 HOST=arm-linux-gnueabi $(RELEASE_LINUX_COMMON)
release-linux-armv8:
@RELEASE_TARGET=$(RELEASE_VER)-linux-armv8 \
GOOS=linux GOARCH=arm64 HOST=aarch64-linux-gnu $(RELEASE_LINUX_COMMON)
release-linux-mips:
@RELEASE_TARGET=$(RELEASE_VER)-linux-mips \
GOOS=linux GOARCH=mips HOST=mips-linux-gnu $(RELEASE_LINUX_COMMON)
release-linux-mipsel:
@RELEASE_TARGET=$(RELEASE_VER)-linux-mipsel \
GOOS=linux GOARCH=mipsle HOST=mipsel-linux-gnu $(RELEASE_LINUX_COMMON)
release-linux-mips64:
@RELEASE_TARGET=$(RELEASE_VER)-linux-mips64 \
GOOS=linux GOARCH=mips64 HOST=mips64-linux-gnuabi64 $(RELEASE_LINUX_COMMON)
release-linux-mips64el:
@RELEASE_TARGET=$(RELEASE_VER)-linux-mips64el \
GOOS=linux GOARCH=mips64le HOST=mips64el-linux-gnuabi64 $(RELEASE_LINUX_COMMON)
.PHONY: release-windows-common
.PHONY: release-windows-amd64 release-windows-i686
release-windows: release-windows-amd64 release-windows-i686
RELEASE_WINDOWS_COMMON := make -f Makefile.release release-windows-common --no-print-directory
RELEASE_RENDER_NSIS := sed \
-e 's,{{.License}},COPYING.txt,g' \
-e 's,{{.EnergiCore}},bin/energi3.exe,g'
# -e 's,{{range .DevTools}}file {{.}},file bin/abigen.exe\n file bin/bootnode.exe\n file bin/clef.exe\n file bin/evm.exe\n file bin/rlpdump.exe,g' \
# -e 's,{{range $$}}Delete $$INSTDIR\\{{.}},Delete \$$INSTDIR\abigen.exe\n Delete \$$INSTDIR\bootnode.exe\n Delete \$$INSTDIR\clef.exe\n Delete \$$INSTDIR\evm.exe\n Delete $$INSTDIR\rlpdump.exe,g' \
# -e 's,{{end}},,g'
# The above could be done better...
release-windows-common:
@echo Building $(RELEASE_TARGET)
@rm -rf build/release/$(RELEASE_TARGET)
@mkdir -p build/release/$(RELEASE_TARGET)
@for t in $(TARGET_TOOLS); do \
export GOCACHE=$(CURDIR)/build/release/$(RELEASE_TARGET)/cache; \
export PREFIX=/usr/$(HOST); \
export PKG_CONFIG_PATH=/usr/$(HOST)/lib/pkgconfig; \
export CC=$(HOST)-gcc-7.3-posix; \
export CXX=$(HOST)-g++-7.3-posix; \
export CGO_CFLAGS="-D_WIN32_WINNT=0x0601"; \
export CGO_CXXFLAGS="$$CGO_CXXFLAGS"; \
export CGO_ENABLED=1; \
go build -o build/release/$(RELEASE_TARGET)/bin/$$t.exe $(RELEASE_GOFLAGS) ./cmd/$$t; \
done
@mv build/release/$(RELEASE_TARGET)/bin/geth.exe build/release/$(RELEASE_TARGET)/bin/$(RELEASE_MAIN).exe
@unix2dos -n COPYING build/release/$(RELEASE_TARGET)/COPYING.txt
@$(RELEASE_RENDER_NSIS) < build/nsis.geth.nsi > build/release/$(RELEASE_TARGET)/energi3.nsi
@$(RELEASE_RENDER_NSIS) < build/nsis.install.nsh > build/release/$(RELEASE_TARGET)/install.nsh
@$(RELEASE_RENDER_NSIS) < build/nsis.uninstall.nsh > build/release/$(RELEASE_TARGET)/uninstall.nsh
@$(RELEASE_RENDER_NSIS) < build/nsis.pathupdate.nsh > build/release/$(RELEASE_TARGET)/PathUpdate.nsh
@$(RELEASE_RENDER_NSIS) < build/nsis.envvarupdate.nsh > build/release/$(RELEASE_TARGET)/EnvVarUpdate.nsh
@cp build/nsis.simplefc.dll build/release/$(RELEASE_TARGET)/SimpleFC.dll
@makensis \
-DOUTPUTFILE=$(RELEASE_TARGET)-setup.exe \
-DMAJORVERSION=$(word 1,$(subst ., ,$(RELEASE_RAW_VER))) \
-DMINORVERSION=$(word 2,$(subst ., ,$(RELEASE_RAW_VER))) \
-DBUILDVERSION=$(word 3,$(subst ., ,$(RELEASE_RAW_VER))) \
-DARCH=$(GOARCH) \
build/release/$(RELEASE_TARGET)/energi3.nsi
@cd build/release && zip $(RELEASE_TARGET)/$(RELEASE_TARGET).zip \
$(RELEASE_TARGET)/bin/$(RELEASE_MAIN).exe $(RELEASE_TARGET)/COPYING.txt
@cd build/release && zip $(RELEASE_TARGET)/$(RELEASE_TARGET)-alltools.zip \
-r $(RELEASE_TARGET)/bin/ $(RELEASE_TARGET)/COPYING.txt
@ls build/release/$(RELEASE_TARGET)/$(RELEASE_TARGET)*.zip \
build/release/$(RELEASE_TARGET)/$(RELEASE_TARGET)-setup.exe
release-windows-amd64:
@RELEASE_TARGET=$(RELEASE_VER)-windows-amd64 \
GOOS=windows GOARCH=amd64 HOST=x86_64-w64-mingw32 $(RELEASE_WINDOWS_COMMON)
release-windows-i686:
@RELEASE_TARGET=$(RELEASE_VER)-windows-i686 \
GOOS=windows GOARCH=386 HOST=i686-w64-mingw32 $(RELEASE_WINDOWS_COMMON)
.PHONY: release-macos-common
.PHONY: release-macos-amd64
release-macos: release-macos-amd64
RELEASE_MACOS_COMMON := make -f Makefile.release release-macos-common --no-print-directory
release-macos-common:
@echo Building $(RELEASE_TARGET)
@rm -rf build/release/$(RELEASE_TARGET)
@mkdir -p build/release/$(RELEASE_TARGET)
@for t in $(TARGET_TOOLS); do \
export GOCACHE=$(CURDIR)/build/release/$(RELEASE_TARGET)/cache; \
export CC=clang; \
export CXX=clang++; \
export CGO_CFLAGS="-mmacosx-version-min=10.11"; \
export CGO_CXXFLAGS="$$CGO_CXXFLAGS"; \
export CGO_ENABLED=1; \
go build -o build/release/$(RELEASE_TARGET)/bin/$$t $(RELEASE_GOFLAGS) --ldflags="-s" ./cmd/$$t; \
done
@mv build/release/$(RELEASE_TARGET)/bin/geth build/release/$(RELEASE_TARGET)/bin/$(RELEASE_MAIN)
@cp COPYING build/release/$(RELEASE_TARGET)/
@tar czf build/release/$(RELEASE_TARGET)/$(RELEASE_TARGET).tgz \
-C build/release $(RELEASE_TARGET)/bin/$(RELEASE_MAIN) $(RELEASE_TARGET)/COPYING
@tar czf build/release/$(RELEASE_TARGET)/$(RELEASE_TARGET)-alltools.tgz \
-C build/release $(RELEASE_TARGET)/bin/ $(RELEASE_TARGET)/COPYING
@ls build/release/$(RELEASE_TARGET)/$(RELEASE_TARGET)*.tgz
release-macos-amd64:
@RELEASE_TARGET=$(RELEASE_VER)-macos-amd64 \
GOOS=darwin GOARCH=amd64 HOST=x86_64-apple-darwin $(RELEASE_MACOS_COMMON)
RELEASE_REPO := s3://download.energi.software/releases/energi3
.PHONY: release-upload
release-upload:
@find build/release/ -name '*.tgz' -or -name '*.zip' -or -name '*-setup.exe' | while read fn; do \
dst=$(RELEASE_REPO)/$(RELEASE_RAW_VER)/$$(basename $$fn); \
aws s3 ls "$$dst" >/dev/null || aws s3 cp "$$fn" "$$dst" --acl public-read || exit $$?; \
done
@find build/release/ -name '*.tgz' -or -name '*.zip' -or -name '*-setup.exe' | xargs sha256sum
.PHONY: release-sign release-sign-download release-sign-upload
release-sign-download:
@aws s3 sync $(RELEASE_REPO)/$(RELEASE_RAW_VER) build/release/sign
@cd build/release/sign && ls | xargs sha256sum
release-sign: release-sign-download
@for f in build/release/sign/*; do gpg --sign --detach $$f; done
release-sign-upload:
@aws s3 sync build/release/sign $(RELEASE_REPO)/$(RELEASE_RAW_VER) --acl public-read