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
107 lines (89 loc) · 3.24 KB
/
Copy pathMakefile
File metadata and controls
107 lines (89 loc) · 3.24 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
#
# 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)
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: $(TARGET)
$(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