diff options
Diffstat (limited to 'src/Makefile')
| -rw-r--r-- | src/Makefile | 146 |
1 files changed, 146 insertions, 0 deletions
diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000..3577dd6 --- /dev/null +++ b/src/Makefile | |||
| @@ -0,0 +1,146 @@ | |||
| 1 | # Bitflash Linux build — ImGui + GLFW + OpenGL3 | ||
| 2 | # Called by: make linux (root Makefile) | ||
| 3 | |||
| 4 | CXX ?= g++ | ||
| 5 | |||
| 6 | SECP_INC ?= /usr/local/include | ||
| 7 | SECP_LIB ?= /usr/local/lib | ||
| 8 | RANDOMX_DIR ?= $(HOME)/RandomX | ||
| 9 | |||
| 10 | IMGUI_DIR = imgui | ||
| 11 | |||
| 12 | # -w used to sit here and suppressed every diagnostic in the build, including | ||
| 13 | # the one that mattered: `%I64d` is MSVC-only, glibc mis-parses it as the GNU | ||
| 14 | # `I` flag with a width of 64 and an `int` conversion, and the resulting vararg | ||
| 15 | # desynchronisation segfaulted the node while logging a received block (issue | ||
| 16 | # #5, deterministic at height 1062 -- the first block carrying a real | ||
| 17 | # transaction). GCC had been reporting it all along: | ||
| 18 | # | ||
| 19 | # warning: format '%d' expects argument of type 'int', | ||
| 20 | # but argument 4 has type 'int64_t' | ||
| 21 | # | ||
| 22 | # -w cannot be narrowed: it wins over any -W or -Werror= that follows it, so it | ||
| 23 | # has to go. The four -Wno- entries below are the categories this 2009-era tree | ||
| 24 | # genuinely produces (measured: 248 deprecated-declarations, 157 write-strings, | ||
| 25 | # 18 narrowing, 1 unused-result); silencing them by name instead of silencing | ||
| 26 | # everything keeps the build quiet while leaving format errors fatal. | ||
| 27 | WARNFLAGS = -Wformat -Werror=format \ | ||
| 28 | -Wno-deprecated-declarations -Wno-write-strings \ | ||
| 29 | -Wno-narrowing -Wno-unused-result | ||
| 30 | |||
| 31 | CXXFLAGS = -std=gnu++14 -O2 $(WARNFLAGS) -fpermissive -pthread \ | ||
| 32 | -DSECP256K1_STATIC \ | ||
| 33 | -I$(SECP_INC) -I$(RANDOMX_DIR)/src \ | ||
| 34 | -I/usr/include/nlohmann \ | ||
| 35 | -I$(IMGUI_DIR) | ||
| 36 | |||
| 37 | LIBS = -L$(SECP_LIB) -lsecp256k1 \ | ||
| 38 | -L$(RANDOMX_DIR)/build -lrandomx \ | ||
| 39 | -lsodium -lssl -lcrypto -ldb_cxx -lpthread \ | ||
| 40 | -lglfw -lGL | ||
| 41 | |||
| 42 | # Every header a .cpp here includes has to be listed, not just the interesting | ||
| 43 | # ones. sockcount.h was missing, and it declares a struct that lives in a | ||
| 44 | # function-local static shared across translation units: editing it rebuilt | ||
| 45 | # some objects and not others, and the linker said so in a warning easy to walk | ||
| 46 | # past -- "duplicate section ... has different size". That is one object | ||
| 47 | # indexing a struct by the old layout and another by the new one, in the same | ||
| 48 | # binary. Nothing crashed here, and nothing would say so if it had. | ||
| 49 | HEADERS = headers_core.h headers.h util.h main.h serialize.h uint256.h \ | ||
| 50 | key.h bignum.h script.h db.h base58.h net.h nostr.h \ | ||
| 51 | randomx_pow.h btfaddr.h btfchan.h btfrv.h btftunnel.h market.h \ | ||
| 52 | selftest.h walletcmd.h compat.h sockcount.h font_roboto.h | ||
| 53 | |||
| 54 | IMGUI_OBJS = obj/imgui.o obj/imgui_draw.o obj/imgui_tables.o \ | ||
| 55 | obj/imgui_widgets.o obj/imgui_impl_glfw.o obj/imgui_impl_opengl3.o | ||
| 56 | |||
| 57 | NODE_OBJS = obj/util.o obj/script.o obj/db.o obj/net.o obj/main.o \ | ||
| 58 | obj/market.o obj/sha.o obj/nostr.o obj/randomx_pow.o \ | ||
| 59 | obj/btfaddr.o obj/btfchan.o obj/btfrv.o obj/btftunnel.o obj/rpc.o \ | ||
| 60 | obj/selftest.o obj/bip32.o obj/walletcmd.o | ||
| 61 | |||
| 62 | GUI_OBJS = obj/gui.o obj/main_gui.o | ||
| 63 | |||
| 64 | all: bitflash | ||
| 65 | |||
| 66 | obj/%.o: %.cpp $(HEADERS) | ||
| 67 | @mkdir -p obj | ||
| 68 | $(CXX) -c $(CXXFLAGS) -o $@ $< | ||
| 69 | |||
| 70 | obj/sha.o: sha.cpp sha.h | ||
| 71 | @mkdir -p obj | ||
| 72 | $(CXX) -c $(CXXFLAGS) -O3 -o $@ $< | ||
| 73 | |||
| 74 | obj/imgui.o: $(IMGUI_DIR)/imgui.cpp | ||
| 75 | @mkdir -p obj | ||
| 76 | $(CXX) -c $(CXXFLAGS) -o $@ $< | ||
| 77 | |||
| 78 | obj/imgui_draw.o: $(IMGUI_DIR)/imgui_draw.cpp | ||
| 79 | @mkdir -p obj | ||
| 80 | $(CXX) -c $(CXXFLAGS) -o $@ $< | ||
| 81 | |||
| 82 | obj/imgui_tables.o: $(IMGUI_DIR)/imgui_tables.cpp | ||
| 83 | @mkdir -p obj | ||
| 84 | $(CXX) -c $(CXXFLAGS) -o $@ $< | ||
| 85 | |||
| 86 | obj/imgui_widgets.o: $(IMGUI_DIR)/imgui_widgets.cpp | ||
| 87 | @mkdir -p obj | ||
| 88 | $(CXX) -c $(CXXFLAGS) -o $@ $< | ||
| 89 | |||
| 90 | obj/imgui_impl_glfw.o: $(IMGUI_DIR)/imgui_impl_glfw.cpp | ||
| 91 | @mkdir -p obj | ||
| 92 | $(CXX) -c $(CXXFLAGS) -o $@ $< | ||
| 93 | |||
| 94 | obj/imgui_impl_opengl3.o: $(IMGUI_DIR)/imgui_impl_opengl3.cpp | ||
| 95 | @mkdir -p obj | ||
| 96 | $(CXX) -c $(CXXFLAGS) -o $@ $< | ||
| 97 | |||
| 98 | bitflash: $(IMGUI_OBJS) $(NODE_OBJS) $(GUI_OBJS) | ||
| 99 | $(CXX) $(CXXFLAGS) -o $@ $^ $(LIBS) | ||
| 100 | @echo "Built: bitflash" | ||
| 101 | |||
| 102 | # ---- headless node --------------------------------------------------------- | ||
| 103 | # | ||
| 104 | # Same node, built without ImGui, GLFW or OpenGL. Linking the GUI made the | ||
| 105 | # binary require libGL at load time even when started with -nogui, because the | ||
| 106 | # dynamic loader resolves everything before main() runs -- so on a clean server, | ||
| 107 | # which is where a node most naturally lives, it failed to start with an error | ||
| 108 | # about shared libraries and no hint that it would otherwise work. | ||
| 109 | # | ||
| 110 | # Objects go to obj-node/ because main_gui.cpp is compiled twice, with and | ||
| 111 | # without -DBITFLASH_NO_GUI, and the two must not overwrite each other. | ||
| 112 | |||
| 113 | NODE_LIBS = -L$(SECP_LIB) -lsecp256k1 \ | ||
| 114 | -L$(RANDOMX_DIR)/build -lrandomx \ | ||
| 115 | -lsodium -lssl -lcrypto -ldb_cxx -lpthread | ||
| 116 | |||
| 117 | NODE_ONLY_OBJS = $(patsubst obj/%,obj-node/%,$(NODE_OBJS)) \ | ||
| 118 | obj-node/main_gui.o obj-node/headless.o | ||
| 119 | |||
| 120 | obj-node/%.o: %.cpp $(HEADERS) | ||
| 121 | @mkdir -p obj-node | ||
| 122 | $(CXX) -c $(CXXFLAGS) -DBITFLASH_NO_GUI -o $@ $< | ||
| 123 | |||
| 124 | obj-node/sha.o: sha.cpp sha.h | ||
| 125 | @mkdir -p obj-node | ||
| 126 | $(CXX) -c $(CXXFLAGS) -DBITFLASH_NO_GUI -O3 -o $@ $< | ||
| 127 | |||
| 128 | bitflash-node: $(NODE_ONLY_OBJS) | ||
| 129 | $(CXX) $(CXXFLAGS) -o $@ $^ $(NODE_LIBS) | ||
| 130 | @echo "Built: bitflash-node (headless, no libGL needed)" | ||
| 131 | |||
| 132 | clean: | ||
| 133 | rm -rf obj obj-node bitflash bitflash-node test_bip32 | ||
| 134 | |||
| 135 | test_bip32: test_bip32.cpp bip32.cpp bip32.h bip39_english.h | ||
| 136 | $(CXX) $(CXXFLAGS) -o $@ test_bip32.cpp bip32.cpp -lssl -lcrypto | ||
| 137 | |||
| 138 | tests: test_bip32 bitflash-node | ||
| 139 | ./test_bip32 | ||
| 140 | ./bitflash-node -selftest=wallet-keypool | ||
| 141 | ./bitflash-node -selftest=wallet-hd | ||
| 142 | ./bitflash-node -selftest=wallet-format | ||
| 143 | ./bitflash-node -selftest=wallet-crypto | ||
| 144 | ./bitflash-node -selftest=wallet-encrypt | ||
| 145 | ./bitflash-node -selftest=net-message | ||
| 146 | ./bitflash-node -selftest=consensus-limits | ||