forked from octra-labs/webcli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
147 lines (126 loc) · 5.2 KB
/
Copy pathMakefile
File metadata and controls
147 lines (126 loc) · 5.2 KB
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
#
# This file is part of Octra Wallet (webcli).
#
# Octra Wallet is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# Octra Wallet is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Octra Wallet. If not, see <http://www.gnu.org/licenses/>.
#
# This program is released under the GPL with the additional exemption
# that compiling, linking, and/or using OpenSSL is allowed.
# You are free to remove this exemption from derived works.
#
# Copyright 2025-2026 Octra Labs
# 2025-2026 David A.
# 2025-2026 Alex T.
# 2025-2026 Vadim S.
# 2025-2026 Julia L.
#
CXX:=g++
CC:=gcc
UNAME_M:=$(shell uname -m)
UNAME_S:=$(shell uname -s)
IS_WIN:=$(findstring MINGW,$(UNAME_S))$(findstring MSYS,$(UNAME_S))
ifeq ($(UNAME_M),arm64)
ARCH:=-march=armv8-a+crypto
else
ARCH:=-march=native
endif
CXXFLAGS:=-std=c++17 -O2 $(ARCH) -Wall -pthread
CFLAGS:=-O2 $(ARCH) -Wall
PVAC_DIR:=pvac
PVAC_BUILD:=$(PVAC_DIR)/build
ifeq ($(UNAME_S),Darwin)
SHARED_EXT:=dylib
SHARED_FLAGS:=-dynamiclib
SSL_PREFIX:=$(shell brew --prefix openssl 2>/dev/null || echo /usr/local/opt/openssl)
LDB_PREFIX:=$(shell brew --prefix leveldb 2>/dev/null || echo /opt/homebrew/opt/leveldb)
CXXFLAGS+=-I$(SSL_PREFIX)/include -I$(LDB_PREFIX)/include -DCPPHTTPLIB_OPENSSL_SUPPORT
LDFLAGS:=-L$(SSL_PREFIX)/lib -lssl -lcrypto -L$(LDB_PREFIX)/lib -lleveldb -L$(PVAC_BUILD) -lpvac -Wl,-rpath,@executable_path/$(PVAC_BUILD)
TARGET:=octra_wallet
else ifneq ($(IS_WIN),)
SHARED_EXT:=a
SHARED_FLAGS:=
SSL_PREFIX:=$(shell echo $$MINGW_PREFIX)
LDB_PREFIX:=$(shell echo $$MINGW_PREFIX)
CXXFLAGS+=-I$(SSL_PREFIX)/include -DCPPHTTPLIB_OPENSSL_SUPPORT
LDFLAGS:=-static -L$(SSL_PREFIX)/lib -L$(PVAC_BUILD) -lpvac -lleveldb -lssl -lcrypto -lws2_32 -lbcrypt -lcrypt32 -lgdi32 -lz
TARGET:=octra_wallet.exe
else
SHARED_EXT:=so
SHARED_FLAGS:=-shared
CXXFLAGS+=-DCPPHTTPLIB_OPENSSL_SUPPORT
LDFLAGS:=-lssl -lcrypto -lleveldb -L$(PVAC_BUILD) -lpvac -Wl,-rpath,'$$ORIGIN/$(PVAC_BUILD)'
TARGET:=octra_wallet
endif
CXXFLAGS+=-I$(PVAC_DIR)
LIBPVAC:=$(PVAC_BUILD)/libpvac.$(SHARED_EXT)
all: check-deps $(TARGET)
LEVELDB_PATHS:=/usr/include/leveldb/db.h /usr/local/include/leveldb/db.h /opt/homebrew/include/leveldb/db.h /opt/local/include/leveldb/db.h /mingw64/include/leveldb/db.h /ucrt64/include/leveldb/db.h /clang64/include/leveldb/db.h $(LDB_PREFIX)/include/leveldb/db.h
OPENSSL_PATHS:=/usr/include/openssl/evp.h /usr/local/include/openssl/evp.h /opt/homebrew/include/openssl/evp.h /opt/local/include/openssl/evp.h /mingw64/include/openssl/evp.h /ucrt64/include/openssl/evp.h /clang64/include/openssl/evp.h $(SSL_PREFIX)/include/openssl/evp.h
HAVE_LEVELDB:=$(shell for p in $(LEVELDB_PATHS); do [ -f "$$p" ] && { echo yes; exit 0; }; done; echo no)
HAVE_OPENSSL:=$(shell for p in $(OPENSSL_PATHS); do [ -f "$$p" ] && { echo yes; exit 0; }; done; echo no)
check-deps:
ifeq ($(OCTRA_SKIP_AUTOSETUP),)
ifeq ($(HAVE_LEVELDB)$(HAVE_OPENSSL),yesyes)
@true
else
@echo 'missing dependencies (leveldb=$(HAVE_LEVELDB) openssl=$(HAVE_OPENSSL))'
@echo 'running ./setup.sh --deps-only to install...'
@echo ''
@if [ -x ./setup.sh ]; then \
./setup.sh --deps-only || { \
echo ''; \
echo 'auto-install failed. install manually:'; \
echo 'sudo apt install libleveldb-dev libssl-dev (debian/ubuntu)'; \
echo 'brew install leveldb openssl@3 (macos)'; \
echo 'setup.bat from cmd.exe (windows)'; \
exit 1; \
}; \
else \
echo 'setup.sh not found. install manually:'; \
echo 'sudo apt install libleveldb-dev libssl-dev (debian/ubuntu)'; \
echo 'brew install leveldb openssl@3 (macos)'; \
echo 'setup.bat from cmd.exe (windows)'; \
exit 1; \
fi
@ok=no; for p in $(LEVELDB_PATHS); do [ -f "$$p" ] && ok=yes; done; \
[ "$$ok" = "yes" ] || { echo 'error: leveldb still missing. on windows run setup.bat from cmd.exe'; exit 1; }
@ok=no; for p in $(OPENSSL_PATHS); do [ -f "$$p" ] && ok=yes; done; \
[ "$$ok" = "yes" ] || { echo 'error: openssl still missing. on windows run setup.bat from cmd.exe'; exit 1; }
endif
else
@true
endif
$(PVAC_BUILD):
@mkdir -p $(PVAC_BUILD)
$(LIBPVAC): $(PVAC_DIR)/pvac_c_api.cpp | $(PVAC_BUILD)
ifneq ($(IS_WIN),)
$(CXX) $(CXXFLAGS) -c -I$(PVAC_DIR)/include -o $(PVAC_BUILD)/pvac_c_api.o $<
ar rcs $@ $(PVAC_BUILD)/pvac_c_api.o
else
$(CXX) $(CXXFLAGS) -fPIC $(SHARED_FLAGS) -I$(PVAC_DIR)/include -o $@ $<
ifeq ($(UNAME_S),Darwin)
install_name_tool -id @rpath/libpvac.$(SHARED_EXT) $@
endif
endif
lib/tweetnacl.o: lib/tweetnacl.c
$(CC) $(CFLAGS) -c -o $@ $<
lib/randombytes.o: lib/randombytes.c
$(CC) $(CFLAGS) -c -o $@ $<
$(TARGET): main.cpp lib/tweetnacl.o lib/randombytes.o $(LIBPVAC)
$(CXX) $(CXXFLAGS) -o $@ main.cpp lib/tweetnacl.o lib/randombytes.o $(LDFLAGS)
clean:
rm -f $(TARGET) lib/*.o
rm -rf $(PVAC_BUILD)
run: $(TARGET)
./$(TARGET) 8420
.PHONY: all clean run check-deps