upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/makefile.mingw
blob: e076c499dec4e853bef8bedfda4dbc6756331f27 (plain)
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
# Bitflash Windows build — ImGui + GLFW + OpenGL3
# Run from MSYS2 UCRT64: make -f makefile.mingw

CXX = g++

DEPS      = ../deps
RANDOMX   = ../RandomX
IMGUI_DIR = imgui

# See the long note in Makefile: -w hid the format bug that segfaulted the node
# on glibc (issue #5), and -w cannot be narrowed, so format diagnostics are now
# fatal and only the categories this tree actually produces are silenced.
WARNFLAGS = -Wformat -Werror=format \
            -Wno-deprecated-declarations -Wno-write-strings \
            -Wno-narrowing -Wno-unused-result

# FD_SETSIZE has to be defined before winsock2.h and it has to be the same
# number in every translation unit -- fd_set carries an array of that length,
# so disagreeing about it means disagreeing about sizeof(fd_set). That is why
# it lives here as a -D and not as a #define in a header. Windows defaults to
# 64, which capped this node at 63 watchable peers no matter how many it had.
CXXFLAGS = -std=gnu++14 -O2 $(WARNFLAGS) -fpermissive -pthread \
           -DWIN32 -DNOPCH -DFD_SETSIZE=1024 \
           -DSECP256K1_STATIC \
           -I$(DEPS)/include -I$(RANDOMX)/src \
           -I$(DEPS)/include/nlohmann \
           -IC:/msys64/ucrt64/include \
           -I$(IMGUI_DIR)

LIBS = -L$(DEPS)/lib -lsecp256k1 \
       -L$(RANDOMX)/build -lrandomx \
       -lsodium -lssl -lcrypto -ldb_cxx -lpthread \
       -LC:/msys64/ucrt64/lib \
       -lglfw3 -lopengl32 -lgdi32 \
       -lkernel32 -luser32 -lcomdlg32 -lwinspool -lwinmm \
       -lshell32 -lcomctl32 -lole32 -loleaut32 -luuid \
       -lrpcrt4 -ladvapi32 -lws2_32 -lmswsock -lcrypt32

IMGUI_OBJS = obj/imgui.o obj/imgui_draw.o obj/imgui_tables.o \
             obj/imgui_widgets.o obj/imgui_impl_glfw.o obj/imgui_impl_opengl3.o

NODE_OBJS = obj/util.o obj/script.o obj/db.o obj/net.o obj/main.o \
            obj/market.o obj/sha.o obj/nostr.o obj/randomx_pow.o \
            obj/btfaddr.o obj/btfchan.o obj/btfrv.o obj/btftunnel.o obj/rpc.o \
            obj/selftest.o obj/bip32.o obj/walletcmd.o

GUI_OBJS = obj/gui.o obj/main_gui.o obj/bitflash_res.o

# Every header a .cpp here includes has to be listed, not just the interesting
# ones. sockcount.h was missing, and it declares a struct that lives in a
# function-local static shared across translation units: editing it rebuilt
# some objects and not others, and the linker said so in a warning easy to walk
# past -- "duplicate section ... has different size". That is one object
# indexing a struct by the old layout and another by the new one, in the same
# binary. Nothing crashed here, and nothing would say so if it had.
HEADERS = headers_core.h headers.h util.h main.h serialize.h uint256.h \
          key.h bignum.h script.h db.h base58.h net.h nostr.h \
          randomx_pow.h btfaddr.h btfchan.h btfrv.h btftunnel.h market.h \
          selftest.h walletcmd.h sockcount.h compat.h font_roboto.h

all: bitflash.exe

obj/bitflash_res.o: bitflash.rc rc/bitcoin.ico
	mkdir -p obj
	windres -o $@ -i bitflash.rc

obj/%.o: %.cpp $(HEADERS)
	mkdir -p obj
	$(CXX) -c $(CXXFLAGS) -o $@ $<

obj/sha.o: sha.cpp sha.h
	mkdir -p obj
	$(CXX) -c $(CXXFLAGS) -O3 -o $@ $<

obj/imgui.o:              $(IMGUI_DIR)/imgui.cpp
	mkdir -p obj
	$(CXX) -c $(CXXFLAGS) -o $@ $<

obj/imgui_draw.o:         $(IMGUI_DIR)/imgui_draw.cpp
	mkdir -p obj
	$(CXX) -c $(CXXFLAGS) -o $@ $<

obj/imgui_tables.o:       $(IMGUI_DIR)/imgui_tables.cpp
	mkdir -p obj
	$(CXX) -c $(CXXFLAGS) -o $@ $<

obj/imgui_widgets.o:      $(IMGUI_DIR)/imgui_widgets.cpp
	mkdir -p obj
	$(CXX) -c $(CXXFLAGS) -o $@ $<

obj/imgui_impl_glfw.o:    $(IMGUI_DIR)/imgui_impl_glfw.cpp
	mkdir -p obj
	$(CXX) -c $(CXXFLAGS) -o $@ $<

obj/imgui_impl_opengl3.o: $(IMGUI_DIR)/imgui_impl_opengl3.cpp
	mkdir -p obj
	$(CXX) -c $(CXXFLAGS) -o $@ $<

bitflash.exe: $(IMGUI_OBJS) $(NODE_OBJS) $(GUI_OBJS)
	$(CXX) $(CXXFLAGS) -mwindows -o $@ $^ $(LIBS)
	@echo "Built: bitflash.exe"

clean:
	rm -rf obj bitflash.exe test_bip32.exe

test_bip32.exe: test_bip32.cpp bip32.cpp bip32.h bip39_english.h
	$(CXX) $(CXXFLAGS) -o $@ test_bip32.cpp bip32.cpp -lssl -lcrypto -lcrypt32
	@echo "Built: test_bip32.exe"

tests: test_bip32.exe bitflash.exe
	./test_bip32.exe
	./bitflash.exe -selftest=wallet-keypool
	./bitflash.exe -selftest=wallet-hd
	./bitflash.exe -selftest=wallet-format
	./bitflash.exe -selftest=wallet-crypto
	./bitflash.exe -selftest=wallet-encrypt
	./bitflash.exe -selftest=net-message
	./bitflash.exe -selftest=consensus-limits