-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
121 lines (107 loc) · 5.13 KB
/
Makefile
File metadata and controls
121 lines (107 loc) · 5.13 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
SPEC_TEST_VERSION = bal@v5.6.1
SPEC_TEST_DIR = spec-tests
ZIG_BUILD_CMD = zig build
ARGS ?=
UNAME_S := $(shell uname -s)
.PHONY: install-deps install-brew-deps install-apt-deps check-deps check-os \
spec-tests state-tests blockchain-tests fetch-fixtures
check-deps:
@echo "Checking dependencies..."
@command -v zig >/dev/null 2>&1 || (echo "zig not found" && exit 1)
@(pkg-config --exists libsecp256k1 2>/dev/null || \
test -f /opt/homebrew/lib/libsecp256k1.a || \
test -f /opt/homebrew/lib/libsecp256k1.dylib || \
test -f /usr/local/lib/libsecp256k1.a || \
test -f /usr/lib/libsecp256k1.so || \
test -f /usr/lib/x86_64-linux-gnu/libsecp256k1.so) || \
(echo "libsecp256k1 not found" && exit 1)
@(test -f /opt/homebrew/lib/libblst.a || \
test -f /usr/local/lib/libblst.a || \
test -f /usr/lib/libblst.a) || \
(echo "libblst not found" && exit 1)
@(test -f /opt/homebrew/lib/libmcl.a || \
test -f /opt/homebrew/lib/libmcl.dylib || \
test -f /usr/local/lib/libmcl.so || \
test -f /usr/local/lib/libmcl.a || \
test -f /usr/lib/libmcl.a) || \
(echo "libmcl not found" && exit 1)
@echo "All dependencies satisfied."
install-deps: check-os
@if $(MAKE) check-deps --no-print-directory >/dev/null 2>&1; then \
echo "All dependencies already satisfied, skipping installation."; \
else \
if [ "$(UNAME_S)" = "Darwin" ]; then \
$(MAKE) install-brew-deps --no-print-directory; \
elif command -v apt-get >/dev/null 2>&1; then \
$(MAKE) install-apt-deps --no-print-directory; \
else \
echo "Unsupported Linux package manager. Please install dependencies manually."; \
exit 1; \
fi \
fi
check-os:
@echo "Detected OS: $(UNAME_S)"
install-brew-deps:
@echo "Installing dependencies via Homebrew..."
@command -v brew >/dev/null 2>&1 || (echo "Homebrew not found: https://brew.sh" && exit 1)
brew install secp256k1 openssl || true
@if [ ! -f /opt/homebrew/lib/libblst.a ] && [ ! -f /usr/local/lib/libblst.a ]; then \
echo "Building blst from source..."; \
if [ ! -d /tmp/blst ]; then cd /tmp && git clone https://github.com/supranational/blst.git; fi; \
cd /tmp/blst && ./build.sh; \
sudo cp libblst.a /opt/homebrew/lib/ 2>/dev/null || cp libblst.a /usr/local/lib/; \
sudo cp bindings/blst.h bindings/blst_aux.h /opt/homebrew/include/ 2>/dev/null || cp bindings/blst.h bindings/blst_aux.h /usr/local/include/; \
else echo "blst already installed"; fi
@if [ ! -f /opt/homebrew/lib/libmcl.a ] && [ ! -f /usr/local/lib/libmcl.a ]; then \
echo "Building mcl from source..."; \
if [ ! -d /tmp/mcl ]; then cd /tmp && git clone https://github.com/herumi/mcl.git; fi; \
cd /tmp/mcl && make -j$$(sysctl -n hw.ncpu 2>/dev/null || echo 4); \
sudo cp lib/libmcl.a /opt/homebrew/lib/ 2>/dev/null || cp lib/libmcl.a /usr/local/lib/; \
sudo cp -r include/mcl /opt/homebrew/include/ 2>/dev/null || cp -r include/mcl /usr/local/include/; \
else echo "mcl already installed"; fi
install-apt-deps:
@echo "Installing dependencies via apt..."
sudo apt-get update -qq
sudo apt-get install -y libsecp256k1-dev libssl-dev build-essential git cmake
@if [ ! -f /usr/local/lib/libblst.a ] && [ ! -f /usr/lib/libblst.a ]; then \
echo "Building blst from source..."; \
if [ ! -d /tmp/blst ]; then cd /tmp && git clone https://github.com/supranational/blst.git; fi; \
cd /tmp/blst && ./build.sh; \
sudo cp libblst.a /usr/local/lib/; \
sudo cp bindings/blst.h bindings/blst_aux.h /usr/local/include/; \
else echo "blst already installed"; fi
@if [ ! -f /usr/local/lib/libmcl.so ] && [ ! -f /usr/lib/libmcl.so ]; then \
echo "Building mcl from source..."; \
if [ ! -d /tmp/mcl ]; then cd /tmp && git clone https://github.com/herumi/mcl.git; fi; \
cd /tmp/mcl && make -j$$(nproc 2>/dev/null || echo 4); \
sudo rm -f /usr/local/lib/libmcl.a; \
sudo cp lib/libmcl.so /usr/local/lib/; \
sudo cp -r include/mcl /usr/local/include/; \
sudo ldconfig; \
else echo "mcl already installed"; fi
$(SPEC_TEST_DIR)/.fixtures-$(SPEC_TEST_VERSION):
@echo "Downloading execution-spec-tests $(SPEC_TEST_VERSION)..."
rm -rf $(SPEC_TEST_DIR)/fixtures
mkdir -p $(SPEC_TEST_DIR)/fixtures
curl -fL "https://github.com/ethereum/execution-spec-tests/releases/download/$(SPEC_TEST_VERSION)/fixtures_bal.tar.gz" \
| tar xz --strip-components=1 -C $(SPEC_TEST_DIR)/fixtures/
touch $@
@echo "Downloaded execution-spec-tests $(SPEC_TEST_VERSION)"
fetch-fixtures: $(SPEC_TEST_DIR)/.fixtures-$(SPEC_TEST_VERSION)
# Build and run all spec tests (state + blockchain)
spec-tests: $(SPEC_TEST_DIR)/.fixtures-$(SPEC_TEST_VERSION)
@$(ZIG_BUILD_CMD) install
@./zig-out/bin/spec-test-runner \
--fixtures $(SPEC_TEST_DIR)/fixtures/state_tests \
$(ARGS)
@./zig-out/bin/blockchain-test-runner \
--fixtures $(SPEC_TEST_DIR)/fixtures/blockchain_tests \
$(ARGS)
# State tests only
state-tests: $(SPEC_TEST_DIR)/.fixtures-$(SPEC_TEST_VERSION)
@$(ZIG_BUILD_CMD) install
@./zig-out/bin/spec-test-runner --fixtures $(SPEC_TEST_DIR)/fixtures/state_tests $(ARGS)
# Blockchain tests only
blockchain-tests: $(SPEC_TEST_DIR)/.fixtures-$(SPEC_TEST_VERSION)
@$(ZIG_BUILD_CMD) install
@./zig-out/bin/blockchain-test-runner --fixtures $(SPEC_TEST_DIR)/fixtures/blockchain_tests $(ARGS)