-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathMakefile
More file actions
423 lines (401 loc) · 19 KB
/
Makefile
File metadata and controls
423 lines (401 loc) · 19 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
# ZEVM Makefile
# Automatically detects OS and installs dependencies, then builds the project
# Detect OS
UNAME_S := $(shell uname -s)
UNAME_M := $(shell uname -m)
# Default target
.DEFAULT_GOAL := build
# Colors for output
BLUE := \033[0;34m
GREEN := \033[0;32m
YELLOW := \033[0;33m
RED := \033[0;31m
NC := \033[0m # No Color
# Build options
BLST_ENABLED ?= true
MCL_ENABLED ?= true
BLST_INCLUDE ?=
MCL_INCLUDE ?=
# Auto-detect blst location - only use /tmp/blst if not installed system-wide
ifeq ($(BLST_INCLUDE),)
ifeq ($(BLST_ENABLED),true)
# Check if blst is installed in standard locations first
ifeq ($(shell test -f /opt/homebrew/include/blst.h && echo yes),yes)
# Already installed in /opt/homebrew/include/, don't override
else ifeq ($(shell test -f /opt/homebrew/include/blst/blst.h && echo yes),yes)
# Already installed in /opt/homebrew/include/blst/, don't override
else ifeq ($(shell test -f /usr/local/include/blst.h && echo yes),yes)
# Already installed in /usr/local/include/, don't override
else ifeq ($(shell test -f /usr/local/include/blst/blst.h && echo yes),yes)
# Already installed in /usr/local/include/blst/, don't override
else ifeq ($(shell test -f /tmp/blst/libblst.a && test -f /tmp/blst/bindings/blst.h && echo yes),yes)
# Use /tmp/blst if it exists and not installed system-wide
# blst.h is in bindings/, and our code includes <blst.h>, so point to bindings/
BLST_INCLUDE := /tmp/blst/bindings
endif
endif
endif
# Auto-detect mcl location - only use /tmp/mcl if not installed system-wide
ifeq ($(MCL_INCLUDE),)
ifeq ($(MCL_ENABLED),true)
# Check if mcl is installed in standard locations first
ifeq ($(shell test -d /opt/homebrew/include/mcl && echo yes),yes)
# Already installed in /opt/homebrew/include/mcl, don't override
else ifeq ($(shell test -d /usr/local/include/mcl && echo yes),yes)
# Already installed in /usr/local/include/mcl, don't override
else ifeq ($(shell test -f /tmp/mcl/libmcl.a && echo yes),yes)
# Use /tmp/mcl if it exists and not installed system-wide
MCL_INCLUDE := /tmp/mcl/include
endif
endif
endif
# Zig build command with options
ZIG_BUILD_CMD := zig build
ifneq ($(BLST_ENABLED),true)
ZIG_BUILD_CMD += -Dblst=false
endif
ifneq ($(MCL_ENABLED),true)
ZIG_BUILD_CMD += -Dmcl=false
endif
ifneq ($(BLST_INCLUDE),)
ZIG_BUILD_CMD += -Dblst-include=$(BLST_INCLUDE)
endif
ifneq ($(MCL_INCLUDE),)
ZIG_BUILD_CMD += -Dmcl-include=$(MCL_INCLUDE)
endif
.PHONY: help install-deps build test clean check-deps install-brew-deps install-apt-deps install-dnf-deps install-vcpkg-deps
help: ## Show this help message
@echo "$(BLUE)ZEVM Build System$(NC)"
@echo ""
@echo "Usage: make [target]"
@echo ""
@echo "Targets:"
@echo " $(GREEN)build$(NC) - Build the project (default, installs deps if needed)"
@echo " $(GREEN)install-deps$(NC) - Install required dependencies"
@echo " $(GREEN)check-deps$(NC) - Check if dependencies are installed"
@echo " $(GREEN)test$(NC) - Run tests"
@echo " $(GREEN)clean$(NC) - Clean build artifacts"
@echo ""
@echo "Build Options:"
@echo " BLST_ENABLED=$(BLST_ENABLED) - Enable/disable blst (default: true)"
@echo " MCL_ENABLED=$(MCL_ENABLED) - Enable/disable mcl (default: true)"
@echo " BLST_INCLUDE=$(BLST_INCLUDE) - Custom blst include path"
@echo " MCL_INCLUDE=$(MCL_INCLUDE) - Custom mcl include path"
@echo ""
@echo "Examples:"
@echo " make # Build with all dependencies"
@echo " make BLST_ENABLED=false # Build without blst"
@echo " make install-deps # Install dependencies only"
@echo " make test # Run tests"
# Check if dependencies are installed
check-deps:
@echo "$(BLUE)Checking dependencies...$(NC)"
@command -v zig >/dev/null 2>&1 || (echo "$(RED)✗ Zig is not installed$(NC)" && exit 1)
@echo "$(GREEN)✓ Zig is installed$(NC)"
@command -v pkg-config >/dev/null 2>&1 || echo "$(YELLOW)⚠ pkg-config not found (may be needed)$(NC)"
@BLST_FOUND=0; MCL_FOUND=0; \
if [ "$(BLST_ENABLED)" = "true" ]; then \
if pkg-config --exists blst 2>/dev/null; then \
echo "$(GREEN)✓ blst library found (via pkg-config)$(NC)"; \
BLST_FOUND=1; \
elif [ -f /opt/homebrew/lib/libblst.a ] || [ -f /opt/homebrew/lib/libblst.dylib ]; then \
if [ -f /opt/homebrew/include/blst/blst.h ] || [ -f /opt/homebrew/include/blst.h ]; then \
echo "$(GREEN)✓ blst library found in /opt/homebrew$(NC)"; \
BLST_FOUND=1; \
else \
echo "$(YELLOW)⚠ blst library found but headers missing$(NC)"; \
fi \
elif [ -f /usr/local/lib/libblst.a ] || [ -f /usr/local/lib/libblst.dylib ]; then \
if [ -f /usr/local/include/blst/blst.h ] || [ -f /usr/local/include/blst.h ]; then \
echo "$(GREEN)✓ blst library found in /usr/local$(NC)"; \
BLST_FOUND=1; \
else \
echo "$(YELLOW)⚠ blst library found but headers missing$(NC)"; \
fi \
elif [ -f /tmp/blst/libblst.a ] && [ -f /tmp/blst/bindings/blst.h ]; then \
echo "$(GREEN)✓ blst library found in /tmp/blst$(NC)"; \
echo "$(YELLOW) Headers at /tmp/blst/bindings/blst.h$(NC)"; \
BLST_FOUND=1; \
else \
echo "$(RED)✗ blst library not found$(NC)"; \
fi \
fi; \
if [ "$(MCL_ENABLED)" = "true" ]; then \
if pkg-config --exists mcl 2>/dev/null || [ -f /usr/local/lib/libmcl.a ] || [ -f /opt/homebrew/lib/libmcl.a ] || [ -f /usr/lib/libmcl.a ] || [ -f /usr/local/lib/libmcl.dylib ] || [ -f /opt/homebrew/lib/libmcl.dylib ] || [ -f /usr/lib/libmcl.dylib ]; then \
echo "$(GREEN)✓ mcl library found$(NC)"; \
MCL_FOUND=1; \
else \
echo "$(RED)✗ mcl library not found$(NC)"; \
fi \
fi; \
if [ "$(BLST_ENABLED)" = "true" ] && [ "$$BLST_FOUND" = "0" ]; then \
echo ""; \
echo "$(RED)Error: blst library is required but not found.$(NC)"; \
echo "$(YELLOW)Options:$(NC)"; \
echo " 1. Install blst: $(BLUE)make install-deps$(NC)"; \
echo " 2. Build without blst: $(BLUE)make BLST_ENABLED=false$(NC)"; \
echo " 3. See CROSS_PLATFORM.md for manual installation instructions"; \
exit 1; \
fi; \
if [ "$(MCL_ENABLED)" = "true" ] && [ "$$MCL_FOUND" = "0" ]; then \
echo ""; \
echo "$(RED)Error: mcl library is required but not found.$(NC)"; \
echo "$(YELLOW)Options:$(NC)"; \
echo " 1. Install mcl: $(BLUE)make install-deps$(NC)"; \
echo " 2. Build without mcl: $(BLUE)make MCL_ENABLED=false$(NC)"; \
echo " 3. See CROSS_PLATFORM.md for manual installation instructions"; \
exit 1; \
fi
# Install dependencies based on OS
install-deps: check-os
@echo "$(BLUE)Installing dependencies for $(UNAME_S)...$(NC)"
ifeq ($(UNAME_S),Darwin)
@$(MAKE) install-brew-deps
else ifeq ($(UNAME_S),Linux)
@if command -v apt-get >/dev/null 2>&1; then \
$(MAKE) install-apt-deps; \
elif command -v dnf >/dev/null 2>&1; then \
$(MAKE) install-dnf-deps; \
else \
echo "$(RED)✗ Unsupported Linux distribution. Please install dependencies manually.$(NC)"; \
exit 1; \
fi
else ifeq ($(UNAME_S),MINGW64_NT-10.0)
@$(MAKE) install-vcpkg-deps
else
@echo "$(RED)✗ Unsupported OS: $(UNAME_S)$(NC)"
@echo "Please install dependencies manually. See CROSS_PLATFORM.md for instructions."
@exit 1
endif
# Check OS and provide helpful message
check-os:
@echo "$(BLUE)Detected OS: $(UNAME_S) ($(UNAME_M))$(NC)"
# Install dependencies on macOS using Homebrew
install-brew-deps:
@echo "$(BLUE)Installing dependencies via Homebrew...$(NC)"
@command -v brew >/dev/null 2>&1 || (echo "$(RED)✗ Homebrew is not installed. Install from https://brew.sh$(NC)" && exit 1)
@echo "$(GREEN)✓ Homebrew found$(NC)"
@echo "$(YELLOW)Installing system dependencies...$(NC)"
@brew install secp256k1 openssl || true
@if [ "$(BLST_ENABLED)" = "true" ]; then \
if [ -f /opt/homebrew/lib/libblst.a ] || [ -f /usr/local/lib/libblst.a ] || [ -f /usr/lib/libblst.a ] || [ -f /opt/homebrew/lib/libblst.dylib ] || [ -f /usr/local/lib/libblst.dylib ] || [ -f /usr/lib/libblst.dylib ]; then \
echo "$(GREEN)✓ blst library already installed$(NC)"; \
else \
echo "$(YELLOW)Building blst from source...$(NC)"; \
if [ ! -d /tmp/blst ]; then \
cd /tmp && git clone https://github.com/supranational/blst.git || exit 1; \
fi; \
cd /tmp/blst && ./build.sh || (echo "$(RED)✗ Failed to build blst$(NC)" && exit 1); \
if [ ! -f /tmp/blst/bindings/blst.h ]; then \
echo "$(RED)✗ blst.h not found after build at /tmp/blst/bindings/blst.h$(NC)"; \
echo "$(YELLOW)Checking /tmp/blst structure...$(NC)"; \
ls -la /tmp/blst/ 2>/dev/null || true; \
ls -la /tmp/blst/bindings/ 2>/dev/null || true; \
exit 1; \
fi; \
echo "$(GREEN)✓ blst headers verified at /tmp/blst/bindings/blst.h$(NC)"; \
echo "$(YELLOW)Installing blst library...$(NC)"; \
if [ -d /opt/homebrew/lib ] && [ -w /opt/homebrew/lib ]; then \
cp libblst.a /opt/homebrew/lib/ 2>/dev/null || true; \
mkdir -p /opt/homebrew/include 2>/dev/null || true; \
cp bindings/*.h /opt/homebrew/include/ 2>/dev/null || true; \
if [ -f /opt/homebrew/include/blst.h ]; then \
echo "$(GREEN)✓ blst installed to /opt/homebrew/include$(NC)"; \
else \
echo "$(YELLOW)⚠ Could not install to /opt/homebrew/include, will use /tmp/blst/bindings$(NC)"; \
fi \
else \
sudo cp libblst.a /opt/homebrew/lib/ 2>/dev/null || cp libblst.a /usr/local/lib/ 2>/dev/null || true; \
sudo mkdir -p /opt/homebrew/include 2>/dev/null || mkdir -p /usr/local/include 2>/dev/null || true; \
sudo cp bindings/*.h /opt/homebrew/include/ 2>/dev/null || cp bindings/*.h /usr/local/include/ 2>/dev/null || true; \
if [ -f /opt/homebrew/include/blst.h ] || [ -f /usr/local/include/blst.h ]; then \
echo "$(GREEN)✓ blst installed$(NC)"; \
else \
echo "$(YELLOW)⚠ Could not install headers, will use /tmp/blst/bindings$(NC)"; \
fi \
fi; \
echo "$(GREEN)✓ blst build complete (headers available at /tmp/blst/bindings/blst.h)$(NC)"; \
fi \
fi
@if [ "$(MCL_ENABLED)" = "true" ]; then \
if [ -f /opt/homebrew/lib/libmcl.a ] || [ -f /usr/local/lib/libmcl.a ] || [ -f /usr/lib/libmcl.a ] || [ -f /opt/homebrew/lib/libmcl.dylib ] || [ -f /usr/local/lib/libmcl.dylib ] || [ -f /usr/lib/libmcl.dylib ]; then \
echo "$(GREEN)✓ mcl library already installed$(NC)"; \
else \
echo "$(YELLOW)Building mcl from source...$(NC)"; \
if [ ! -d /tmp/mcl ]; then \
cd /tmp && git clone https://github.com/herumi/mcl.git || exit 1; \
fi; \
cd /tmp/mcl && \
if [ -f Makefile ]; then \
make -j$$(sysctl -n hw.ncpu 2>/dev/null || echo 4) || (echo "$(RED)✗ Failed to build mcl$(NC)" && exit 1); \
elif [ -f CMakeLists.txt ]; then \
mkdir -p build && cd build && \
cmake .. && make -j$$(sysctl -n hw.ncpu 2>/dev/null || echo 4) || (echo "$(RED)✗ Failed to build mcl$(NC)" && exit 1); \
else \
echo "$(YELLOW)Building mcl (using default build method)...$(NC)"; \
make -j$$(sysctl -n hw.ncpu 2>/dev/null || echo 4) || (echo "$(RED)✗ Failed to build mcl - may need manual installation$(NC)" && exit 1); \
fi; \
echo "$(YELLOW)Installing mcl library...$(NC)"; \
if [ -d /opt/homebrew/lib ]; then \
find /tmp/mcl/lib -name "libmcl*.a" -exec cp {} /opt/homebrew/lib/ \; 2>/dev/null || \
find /tmp/mcl/lib -name "libmcl*.a" -exec sudo cp {} /opt/homebrew/lib/ \; 2>/dev/null || true; \
find /tmp/mcl/lib -name "libmcl*.dylib" -exec cp {} /opt/homebrew/lib/ \; 2>/dev/null || \
find /tmp/mcl/lib -name "libmcl*.dylib" -exec sudo cp {} /opt/homebrew/lib/ \; 2>/dev/null || true; \
if [ -d /tmp/mcl/include/mcl ]; then \
cp -r /tmp/mcl/include/mcl /opt/homebrew/include/ 2>/dev/null || \
sudo cp -r /tmp/mcl/include/mcl /opt/homebrew/include/ 2>/dev/null || true; \
fi; \
echo "$(GREEN)✓ mcl installed to /opt/homebrew$(NC)"; \
else \
find /tmp/mcl/lib -name "libmcl*.a" -exec sudo cp {} /usr/local/lib/ \; 2>/dev/null || true; \
find /tmp/mcl/lib -name "libmcl*.dylib" -exec sudo cp {} /usr/local/lib/ \; 2>/dev/null || true; \
if [ -d /tmp/mcl/include/mcl ]; then \
sudo cp -r /tmp/mcl/include/mcl /usr/local/include/ 2>/dev/null || true; \
fi; \
echo "$(GREEN)✓ mcl installed to /usr/local$(NC)"; \
fi \
fi \
fi
@echo "$(GREEN)✓ Dependencies installation complete$(NC)"
# Install dependencies on Linux (Debian/Ubuntu) using apt
install-apt-deps:
@echo "$(BLUE)Installing dependencies via apt...$(NC)"
@sudo apt-get update
@sudo apt-get install -y libsecp256k1-dev libssl-dev build-essential git cmake
@if [ "$(BLST_ENABLED)" = "true" ]; then \
if [ -f /usr/local/lib/libblst.a ] || [ -f /usr/lib/libblst.a ] || [ -f /usr/local/lib/libblst.so ] || [ -f /usr/lib/libblst.so ]; then \
echo "$(GREEN)✓ blst library already installed$(NC)"; \
else \
echo "$(YELLOW)Building blst from source...$(NC)"; \
if [ ! -d /tmp/blst ]; then \
cd /tmp && git clone https://github.com/supranational/blst.git || exit 1; \
fi; \
cd /tmp/blst && ./build.sh || (echo "$(RED)✗ Failed to build blst$(NC)" && exit 1); \
echo "$(YELLOW)Installing blst library...$(NC)"; \
sudo cp libblst.a /usr/local/lib/ 2>/dev/null || true; \
sudo mkdir -p /usr/local/include 2>/dev/null || true; \
sudo cp bindings/*.h /usr/local/include/ 2>/dev/null || true; \
echo "$(GREEN)✓ blst installed$(NC)"; \
fi \
fi
@if [ "$(MCL_ENABLED)" = "true" ]; then \
if [ -f /usr/local/lib/libmcl.a ] || [ -f /usr/lib/libmcl.a ] || [ -f /usr/local/lib/libmcl.so ] || [ -f /usr/lib/libmcl.so ]; then \
echo "$(GREEN)✓ mcl library already installed$(NC)"; \
else \
echo "$(YELLOW)Building mcl from source...$(NC)"; \
if [ ! -d /tmp/mcl ]; then \
cd /tmp && git clone https://github.com/herumi/mcl.git || exit 1; \
fi; \
cd /tmp/mcl && \
if [ -f Makefile ]; then \
make -j$$(nproc 2>/dev/null || echo 4) || (echo "$(RED)✗ Failed to build mcl$(NC)" && exit 1); \
elif [ -f CMakeLists.txt ]; then \
mkdir -p build && cd build && \
cmake .. && make -j$$(nproc 2>/dev/null || echo 4) || (echo "$(RED)✗ Failed to build mcl$(NC)" && exit 1); \
else \
echo "$(YELLOW)Building mcl (using default build method)...$(NC)"; \
make -j$$(nproc 2>/dev/null || echo 4) || (echo "$(RED)✗ Failed to build mcl - may need manual installation$(NC)" && exit 1); \
fi; \
echo "$(YELLOW)Installing mcl library...$(NC)"; \
find /tmp/mcl/lib -name "libmcl*.a" -exec sudo cp {} /usr/local/lib/ \; 2>/dev/null || true; \
find /tmp/mcl/lib -name "libmcl*.so" -exec sudo cp {} /usr/local/lib/ \; 2>/dev/null || true; \
if [ -d /tmp/mcl/include/mcl ]; then \
sudo cp -r /tmp/mcl/include/mcl /usr/local/include/ 2>/dev/null || true; \
fi; \
echo "$(GREEN)✓ mcl installed$(NC)"; \
fi \
fi
@echo "$(GREEN)✓ Dependencies installation complete$(NC)"
# Install dependencies on Linux (Fedora/RHEL) using dnf
install-dnf-deps:
@echo "$(BLUE)Installing dependencies via dnf...$(NC)"
@sudo dnf install -y libsecp256k1-devel openssl-devel gcc gcc-c++ make git cmake
@if [ "$(BLST_ENABLED)" = "true" ]; then \
if [ -f /usr/local/lib/libblst.a ] || [ -f /usr/lib/libblst.a ] || [ -f /usr/local/lib/libblst.so ] || [ -f /usr/lib/libblst.so ]; then \
echo "$(GREEN)✓ blst library already installed$(NC)"; \
else \
echo "$(YELLOW)Building blst from source...$(NC)"; \
if [ ! -d /tmp/blst ]; then \
cd /tmp && git clone https://github.com/supranational/blst.git || exit 1; \
fi; \
cd /tmp/blst && ./build.sh || (echo "$(RED)✗ Failed to build blst$(NC)" && exit 1); \
echo "$(YELLOW)Installing blst library...$(NC)"; \
sudo cp libblst.a /usr/local/lib/ 2>/dev/null || true; \
sudo mkdir -p /usr/local/include 2>/dev/null || true; \
sudo cp bindings/*.h /usr/local/include/ 2>/dev/null || true; \
echo "$(GREEN)✓ blst installed$(NC)"; \
fi \
fi
@if [ "$(MCL_ENABLED)" = "true" ]; then \
if [ -f /usr/local/lib/libmcl.a ] || [ -f /usr/lib/libmcl.a ] || [ -f /usr/local/lib/libmcl.so ] || [ -f /usr/lib/libmcl.so ]; then \
echo "$(GREEN)✓ mcl library already installed$(NC)"; \
else \
echo "$(YELLOW)Building mcl from source...$(NC)"; \
if [ ! -d /tmp/mcl ]; then \
cd /tmp && git clone https://github.com/herumi/mcl.git || exit 1; \
fi; \
cd /tmp/mcl && \
if [ -f Makefile ]; then \
make -j$$(nproc 2>/dev/null || echo 4) || (echo "$(RED)✗ Failed to build mcl$(NC)" && exit 1); \
elif [ -f CMakeLists.txt ]; then \
mkdir -p build && cd build && \
cmake .. && make -j$$(nproc 2>/dev/null || echo 4) || (echo "$(RED)✗ Failed to build mcl$(NC)" && exit 1); \
else \
echo "$(YELLOW)Building mcl (using default build method)...$(NC)"; \
make -j$$(nproc 2>/dev/null || echo 4) || (echo "$(RED)✗ Failed to build mcl - may need manual installation$(NC)" && exit 1); \
fi; \
echo "$(YELLOW)Installing mcl library...$(NC)"; \
find /tmp/mcl/lib -name "libmcl*.a" -exec sudo cp {} /usr/local/lib/ \; 2>/dev/null || true; \
find /tmp/mcl/lib -name "libmcl*.so" -exec sudo cp {} /usr/local/lib/ \; 2>/dev/null || true; \
if [ -d /tmp/mcl/include/mcl ]; then \
sudo cp -r /tmp/mcl/include/mcl /usr/local/include/ 2>/dev/null || true; \
fi; \
echo "$(GREEN)✓ mcl installed$(NC)"; \
fi \
fi
@echo "$(GREEN)✓ Dependencies installation complete$(NC)"
# Install dependencies on Windows using vcpkg
install-vcpkg-deps:
@echo "$(BLUE)Installing dependencies via vcpkg...$(NC)"
@command -v vcpkg >/dev/null 2>&1 || (echo "$(RED)✗ vcpkg is not installed. Install from https://github.com/Microsoft/vcpkg$(NC)" && exit 1)
@vcpkg install secp256k1 openssl
@if [ "$(BLST_ENABLED)" = "true" ]; then \
vcpkg install blst || echo "$(YELLOW)Note: blst may need to be built from source$(NC)"; \
fi
@if [ "$(MCL_ENABLED)" = "true" ]; then \
vcpkg install mcl || echo "$(YELLOW)Note: mcl may need to be built from source$(NC)"; \
fi
@echo "$(GREEN)✓ Dependencies installation complete$(NC)"
# Build the project
build: check-deps
@echo "$(BLUE)Building ZEVM...$(NC)"
@echo "$(YELLOW)Build command: $(ZIG_BUILD_CMD) install$(NC)"
@$(ZIG_BUILD_CMD) install
@if [ "$(UNAME_S)" = "Darwin" ]; then \
echo "$(BLUE)Cleaning up duplicate RPATHs in installed binaries...$(NC)"; \
for bin in zig-out/bin/zevm-test zig-out/bin/zevm-bench zig-out/bin/zevm-example; do \
if [ -f "$$bin" ]; then \
install_name_tool -delete_rpath "/opt/homebrew/Cellar/openssl@3/3.6.0/lib" "$$bin" 2>/dev/null || true; \
install_name_tool -delete_rpath "/opt/homebrew/Cellar/openssl@3/3.6.0/lib" "$$bin" 2>/dev/null || true; \
otool -l "$$bin" | grep -q "path /opt/homebrew/Cellar/openssl@3/3.6.0/lib" || install_name_tool -add_rpath "/opt/homebrew/Cellar/openssl@3/3.6.0/lib" "$$bin" 2>/dev/null || true; \
fi; \
done; \
fi
@echo "$(GREEN)✓ Build complete!$(NC)"
# Build with dependency installation
build-with-deps: install-deps build
# Run tests
test: build
@echo "$(BLUE)Running tests...$(NC)"
@if [ "$(UNAME_S)" = "Darwin" ]; then \
export DYLD_LIBRARY_PATH="/opt/homebrew/lib:/usr/local/lib:$$DYLD_LIBRARY_PATH"; \
fi; \
./zig-out/bin/zevm-test || zig build test
@echo "$(GREEN)✓ Tests complete!$(NC)"
# Clean build artifacts
clean:
@echo "$(BLUE)Cleaning build artifacts...$(NC)"
@rm -rf zig-out zig-cache .zig-cache
@echo "$(GREEN)✓ Clean complete!$(NC)"
# Install dependencies and build (convenience target)
all: install-deps build