upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbitflash-maintainer <noreply@bitflash.invalid>2026-09-03 21:49:26 +0000
committerbitflash-maintainer <noreply@bitflash.invalid>2026-09-03 21:49:26 +0000
commitad62cfc9e7301a5ac456b92fa31523a516688d30 (patch)
tree40dc43bd29bc4c7370ed5c32b1a802cbc1db9c1a
parente4f898c4a6b9900553c64b9804889b5fdae3e55f (diff)
parent3d6373874f3972b776dd48e86321b1f8c78cd23b (diff)
merge: !1 fix/build-system into deploy/all-2026-08-24
-rw-r--r--Makefile107
-rw-r--r--src/Makefile4
2 files changed, 91 insertions, 20 deletions
diff --git a/Makefile b/Makefile
index 9f97b73..ace07d8 100644
--- a/Makefile
+++ b/Makefile
@@ -37,6 +37,12 @@ VERSION := 1.2.19+sec
37# resolves the object by its own hash). Bump deliberately, and rebuild and 37# resolves the object by its own hash). Bump deliberately, and rebuild and
38# resync before shipping the result. 38# resync before shipping the result.
39# 39#
40# The check has to decide the exit status, so each recipe below joins its
41# commands with && the whole way to the closing echo. Ending that chain with a
42# `;` meant a failed `test` only skipped the build steps: the echo still ran,
43# the target still exited 0, and make announced a pinned dependency that
44# nothing had verified.
45#
40# RandomX pin is the commit this tree has been building and syncing against 46# RandomX pin is the commit this tree has been building and syncing against
41# (post-v2.0.1 master, 2026-05-24) -- identical to upstream's pin. 47# (post-v2.0.1 master, 2026-05-24) -- identical to upstream's pin.
42# 48#
@@ -59,6 +65,32 @@ APPIMAGETOOL_SHA256 := ed4ce84f0d9caff66f50bcca6ff6f35aae54ce8135408b3fa33abfc3c
59 65
60# ---- Linux ---------------------------------------------------------------- 66# ---- Linux ----------------------------------------------------------------
61 67
68# RandomX used to build in $(HOME)/RandomX, and deps-randomx would rm -rf that
69# path whenever the library was missing -- deleting a tree the build did not
70# create and does not own (issue #27; a hand-managed pinned checkout there is
71# what this machine's miners build against). The default is now in-tree, like
72# secp256k1-build. A host that deliberately keeps RandomX elsewhere can set
73# RANDOMX_DIR=... explicitly; the recipe below will still never delete a
74# directory that lacks the marker file this build writes after a successful
75# build. Exported so src/Makefile's own RANDOMX_DIR ?= picks the same tree.
76#
77# Every use of it below is quoted, and the recipe rejects a value that cannot
78# name exactly one directory before it reaches anything destructive. Unquoted,
79# the marker guard could be stepped around: a value holding a glob that matches
80# two directories made `[ -d $(RANDOMX_DIR) ]` a two-argument test, which dies
81# with "unexpected operator" instead of answering, so the && short-circuited,
82# the guard was skipped, and the rm -rf below ran against every match. A value
83# holding a space or a `&&` broke the outer test the same way and reported
84# "already built". Whitespace and glob characters are refused outright rather
85# than merely quoted, because src/Makefile interpolates this same value into
86# -I$(RANDOMX_DIR)/src and -L$(RANDOMX_DIR)/build unquoted, where neither can
87# survive. A relative value is refused rather than silently made absolute: it
88# would mean two different directories to this Makefile and to src/Makefile,
89# whose cwd is src/, and a command-line assignment reaches the sub-make through
90# MAKEFLAGS, where it outranks anything exported from here.
91RANDOMX_DIR ?= $(ROOT)/randomx-build
92export RANDOMX_DIR
93
62linux: deps-linux 94linux: deps-linux
63 $(MAKE) -C src -f Makefile -j$(NPROC) 95 $(MAKE) -C src -f Makefile -j$(NPROC)
64 strip src/bitflash 96 strip src/bitflash
@@ -78,11 +110,24 @@ linux-node: deps-linux
78 110
79deps-linux: deps-apt deps-secp256k1 deps-randomx 111deps-linux: deps-apt deps-secp256k1 deps-randomx
80 112
113# libboost-dev, not libboost-system-dev: Boost.System has been header-only
114# since 1.69 and Ubuntu 26.04 (resolute) no longer ships the -system package.
115# This tree only includes two boost headers and links no boost library. The
116# apt-get update comes first: a fresh image's package lists are empty, and
117# install then fails on the first name it cannot find.
118#
119# A failed update is deliberately not fatal: one unreachable repository should
120# not block an install the lists already on disk can satisfy. It does say so,
121# though -- "unable to locate package" several seconds later is otherwise hard
122# to connect back to it. The install is the last command in the branch, so its
123# status is the target's, and that one does abort.
81deps-apt: 124deps-apt:
82 @if command -v apt-get >/dev/null 2>&1; then \ 125 @if command -v apt-get >/dev/null 2>&1; then \
126 $(SUDO) apt-get update || \
127 echo " warning: apt-get update failed, using the package lists on disk"; \
83 $(SUDO) apt-get install -y build-essential cmake git pkg-config autoconf \ 128 $(SUDO) apt-get install -y build-essential cmake git pkg-config autoconf \
84 libtool libssl-dev libdb5.3++-dev libsodium-dev nlohmann-json3-dev \ 129 libtool libssl-dev libdb5.3++-dev libsodium-dev nlohmann-json3-dev \
85 libboost-system-dev libglfw3-dev libgl-dev python3-pil clang; \ 130 libboost-dev libglfw3-dev libgl-dev python3-pil clang; \
86 else \ 131 else \
87 echo "Not an apt system — install: g++ cmake git autoconf libtool"; \ 132 echo "Not an apt system — install: g++ cmake git autoconf libtool"; \
88 echo " libssl libdb++ libsodium nlohmann-json boost glfw3 opengl python3-pil"; \ 133 echo " libssl libdb++ libsodium nlohmann-json boost glfw3 opengl python3-pil"; \
@@ -91,8 +136,8 @@ deps-apt:
91deps-secp256k1: 136deps-secp256k1:
92 @if [ ! -f /usr/local/lib/libsecp256k1.a ]; then \ 137 @if [ ! -f /usr/local/lib/libsecp256k1.a ]; then \
93 echo "==> building libsecp256k1"; \ 138 echo "==> building libsecp256k1"; \
94 rm -rf $(ROOT)/secp256k1-build; \ 139 rm -rf $(ROOT)/secp256k1-build && \
95 git init -q $(ROOT)/secp256k1-build; \ 140 git init -q $(ROOT)/secp256k1-build && \
96 cd $(ROOT)/secp256k1-build && \ 141 cd $(ROOT)/secp256k1-build && \
97 git remote add origin $(SECP256K1_REPO) && \ 142 git remote add origin $(SECP256K1_REPO) && \
98 git fetch -q --depth 1 origin $(SECP256K1_COMMIT) && \ 143 git fetch -q --depth 1 origin $(SECP256K1_COMMIT) && \
@@ -102,26 +147,41 @@ deps-secp256k1:
102 cd $(ROOT)/secp256k1-build && ./autogen.sh && \ 147 cd $(ROOT)/secp256k1-build && ./autogen.sh && \
103 ./configure --enable-module-schnorrsig --enable-module-extrakeys \ 148 ./configure --enable-module-schnorrsig --enable-module-extrakeys \
104 --disable-shared --with-pic --disable-benchmark --disable-tests && \ 149 --disable-shared --with-pic --disable-benchmark --disable-tests && \
105 make -j$(NPROC) && $(SUDO) make install && $(SUDO) ldconfig; \ 150 make -j$(NPROC) && $(SUDO) make install && $(SUDO) ldconfig && \
106 echo "==> libsecp256k1 done"; \ 151 echo "==> libsecp256k1 done"; \
107 else \ 152 else \
108 echo "==> libsecp256k1 already installed"; \ 153 echo "==> libsecp256k1 already installed"; \
109 fi 154 fi
110 155
111deps-randomx: 156deps-randomx:
112 @if [ ! -f $(HOME)/RandomX/build/librandomx.a ]; then \ 157 @ws="$$(printf ' \t')"; \
158 case "$(RANDOMX_DIR)" in \
159 "") echo "ERROR: RANDOMX_DIR is empty"; exit 1 ;; \
160 /) echo "ERROR: RANDOMX_DIR is /, refusing"; exit 1 ;; \
161 *[$$ws]*) echo "ERROR: RANDOMX_DIR contains whitespace: $(RANDOMX_DIR)"; exit 1 ;; \
162 *[*?[]*) echo "ERROR: RANDOMX_DIR contains a glob character: $(RANDOMX_DIR)"; exit 1 ;; \
163 /*) ;; \
164 *) echo "ERROR: RANDOMX_DIR must be an absolute path: $(RANDOMX_DIR)"; exit 1 ;; \
165 esac
166 @if [ ! -f "$(RANDOMX_DIR)/build/librandomx.a" ]; then \
167 if [ -d "$(RANDOMX_DIR)" ] && [ ! -f "$(RANDOMX_DIR)/.bitflash-built" ]; then \
168 echo "ERROR: $(RANDOMX_DIR) exists but was not created by this build"; \
169 echo " refusing to rm -rf it -- remove it yourself or set RANDOMX_DIR"; \
170 exit 1; \
171 fi; \
113 echo "==> building RandomX"; \ 172 echo "==> building RandomX"; \
114 rm -rf $(HOME)/RandomX; \ 173 rm -rf "$(RANDOMX_DIR)" && \
115 git init -q $(HOME)/RandomX; \ 174 git init -q "$(RANDOMX_DIR)" && \
116 cd $(HOME)/RandomX && \ 175 cd "$(RANDOMX_DIR)" && \
117 git remote add origin $(RANDOMX_REPO) && \ 176 git remote add origin $(RANDOMX_REPO) && \
118 git fetch -q --depth 1 origin $(RANDOMX_COMMIT) && \ 177 git fetch -q --depth 1 origin $(RANDOMX_COMMIT) && \
119 git checkout -q --detach FETCH_HEAD && \ 178 git checkout -q --detach FETCH_HEAD && \
120 test "$$(git rev-parse HEAD)" = "$(RANDOMX_COMMIT)" && \ 179 test "$$(git rev-parse HEAD)" = "$(RANDOMX_COMMIT)" && \
121 echo "==> RandomX pinned at $(RANDOMX_COMMIT)" && \ 180 echo "==> RandomX pinned at $(RANDOMX_COMMIT)" && \
122 mkdir -p $(HOME)/RandomX/build; \ 181 mkdir -p "$(RANDOMX_DIR)/build" && \
123 cd $(HOME)/RandomX/build && cmake .. -DCMAKE_BUILD_TYPE=Release && \ 182 cd "$(RANDOMX_DIR)/build" && cmake .. -DCMAKE_BUILD_TYPE=Release && \
124 make -j$(NPROC) randomx; \ 183 make -j$(NPROC) randomx && \
184 touch "$(RANDOMX_DIR)/.bitflash-built" && \
125 echo "==> RandomX done"; \ 185 echo "==> RandomX done"; \
126 else \ 186 else \
127 echo "==> RandomX already built"; \ 187 echo "==> RandomX already built"; \
@@ -177,8 +237,17 @@ d + '/usr/share/icons/hicolor/256x256/apps/bitflash.png')"
177 [ -z "$$path" ] && path=$$(find /usr/lib /lib -name "$$lib" 2>/dev/null | head -1); \ 237 [ -z "$$path" ] && path=$$(find /usr/lib /lib -name "$$lib" 2>/dev/null | head -1); \
178 [ -n "$$path" ] && cp -L "$$path" $(APPDIR)/usr/lib/ && echo " bundled $$lib" || echo " missing $$lib"; \ 238 [ -n "$$path" ] && cp -L "$$path" $(APPDIR)/usr/lib/ && echo " bundled $$lib" || echo " missing $$lib"; \
179 done 239 done
240# appimagetool's output used to be piped through grep ... || true, which
241# discarded its exit status: the target succeeded and announced "Built:"
242# even when no AppImage existed. Run the tool bare so its status decides,
243# then require the artefact to exist, be non-empty, and be newer than the
244# binary it was packaged from before saying so.
180 @ARCH=x86_64 $(APPIMAGETOOL) --no-appstream $(APPDIR) \ 245 @ARCH=x86_64 $(APPIMAGETOOL) --no-appstream $(APPDIR) \
181 $(ROOT)/Bitflash-$(VERSION)-x86_64.AppImage 2>&1 | grep -E "^Built|^Error" || true 246 $(ROOT)/Bitflash-$(VERSION)-x86_64.AppImage
247 @test -s $(ROOT)/Bitflash-$(VERSION)-x86_64.AppImage || \
248 { echo "ERROR: Bitflash-$(VERSION)-x86_64.AppImage missing or empty"; exit 1; }
249 @test $(ROOT)/Bitflash-$(VERSION)-x86_64.AppImage -nt src/bitflash || \
250 { echo "ERROR: Bitflash-$(VERSION)-x86_64.AppImage is not newer than src/bitflash"; exit 1; }
182 @echo "Built: Bitflash-$(VERSION)-x86_64.AppImage" 251 @echo "Built: Bitflash-$(VERSION)-x86_64.AppImage"
183 252
184# ---- Windows (MSYS2 UCRT64) ----------------------------------------------- 253# ---- Windows (MSYS2 UCRT64) -----------------------------------------------
@@ -196,8 +265,8 @@ deps-windows:
196 mingw-w64-ucrt-x86_64-cmake \ 265 mingw-w64-ucrt-x86_64-cmake \
197 autoconf automake libtool 266 autoconf automake libtool
198 @if [ ! -f deps/lib/libsecp256k1.a ]; then \ 267 @if [ ! -f deps/lib/libsecp256k1.a ]; then \
199 rm -rf secp256k1-build; \ 268 rm -rf secp256k1-build && \
200 git init -q secp256k1-build; \ 269 git init -q secp256k1-build && \
201 cd secp256k1-build && \ 270 cd secp256k1-build && \
202 git remote add origin $(SECP256K1_REPO) && \ 271 git remote add origin $(SECP256K1_REPO) && \
203 git fetch -q --depth 1 origin $(SECP256K1_COMMIT) && \ 272 git fetch -q --depth 1 origin $(SECP256K1_COMMIT) && \
@@ -208,23 +277,23 @@ deps-windows:
208 ./configure --prefix=$(ROOT)/deps \ 277 ./configure --prefix=$(ROOT)/deps \
209 --enable-module-schnorrsig --enable-module-extrakeys \ 278 --enable-module-schnorrsig --enable-module-extrakeys \
210 --disable-shared --with-pic --disable-benchmark --disable-tests && \ 279 --disable-shared --with-pic --disable-benchmark --disable-tests && \
211 make install; \ 280 make install && \
212 echo "==> secp256k1 done"; \ 281 echo "==> secp256k1 done"; \
213 else \ 282 else \
214 echo "==> secp256k1 already built"; \ 283 echo "==> secp256k1 already built"; \
215 fi 284 fi
216 @if [ ! -f RandomX/build/librandomx.a ]; then \ 285 @if [ ! -f RandomX/build/librandomx.a ]; then \
217 rm -rf RandomX; \ 286 rm -rf RandomX && \
218 git init -q RandomX; \ 287 git init -q RandomX && \
219 cd RandomX && \ 288 cd RandomX && \
220 git remote add origin $(RANDOMX_REPO) && \ 289 git remote add origin $(RANDOMX_REPO) && \
221 git fetch -q --depth 1 origin $(RANDOMX_COMMIT) && \ 290 git fetch -q --depth 1 origin $(RANDOMX_COMMIT) && \
222 git checkout -q --detach FETCH_HEAD && \ 291 git checkout -q --detach FETCH_HEAD && \
223 test "$$(git rev-parse HEAD)" = "$(RANDOMX_COMMIT)" && \ 292 test "$$(git rev-parse HEAD)" = "$(RANDOMX_COMMIT)" && \
224 echo "==> RandomX pinned at $(RANDOMX_COMMIT)" && \ 293 echo "==> RandomX pinned at $(RANDOMX_COMMIT)" && \
225 mkdir -p $(ROOT)/RandomX/build; \ 294 mkdir -p $(ROOT)/RandomX/build && \
226 cd $(ROOT)/RandomX/build && cmake .. -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release && \ 295 cd $(ROOT)/RandomX/build && cmake .. -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release && \
227 make randomx; \ 296 make randomx && \
228 echo "==> RandomX done"; \ 297 echo "==> RandomX done"; \
229 else \ 298 else \
230 echo "==> RandomX already built"; \ 299 echo "==> RandomX already built"; \
diff --git a/src/Makefile b/src/Makefile
index 1bc3ae8..2c6d304 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -6,7 +6,9 @@ FUZZ_CXX ?= clang++
6 6
7SECP_INC ?= /usr/local/include 7SECP_INC ?= /usr/local/include
8SECP_LIB ?= /usr/local/lib 8SECP_LIB ?= /usr/local/lib
9RANDOMX_DIR ?= $(HOME)/RandomX 9# The root Makefile exports RANDOMX_DIR (default: <repo>/randomx-build, built
10# by deps-randomx). This fallback only applies when src/ is built standalone.
11RANDOMX_DIR ?= $(abspath $(CURDIR)/..)/randomx-build
10 12
11IMGUI_DIR = imgui 13IMGUI_DIR = imgui
12 14