-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile.windows
More file actions
94 lines (78 loc) · 3.56 KB
/
Makefile.windows
File metadata and controls
94 lines (78 loc) · 3.56 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
# Makefile.windows — VoidCache build for Windows (MSYS2 UCRT64)
#
# IMPORTANT: Open the "MSYS2 UCRT64" terminal (not MSYS2, not MinGW, not Cygwin)
# You can find it in Start Menu → "MSYS2 UCRT64"
#
# Install deps once:
# pacman -S --needed mingw-w64-ucrt-x86_64-gcc mingw-w64-ucrt-x86_64-openssl make
#
# Build:
# make -f Makefile.windows vcli
#
# Note: wepoll and mman are bundled in compat/ — no pacman packages needed.
# ─────────────────────────────────────────────────────────────────────────────
CC := gcc
CFLAGS := -O2 -std=c11 \
-Iinclude -Inet -Icompat \
-I$(MSYSTEM_PREFIX)/include \
-D_WIN32_WINNT=0x0A00 \
-DVCACHE_WINDOWS \
-Wno-unused-function -Wno-unused-parameter
LDFLAGS := -L$(MSYSTEM_PREFIX)/lib \
-lssl -lcrypto \
-lpthread \
-lws2_32 -lbcrypt \
-lm
CORE_SRC := src/voidcache.c
NET_SRC := net/proto.c net/auth.c net/commands.c net/server.c net/cluster.c
CLI_SRC := cli/vcli.c
COMPAT_SRC := compat/wepoll.c compat/mman.c
TEST_SRC := tests/test_voidcache.c
BENCH_SRC := bench/benchmark.c
TARGET := vcli.exe
TEST_BIN := voidcache_test.exe
BENCH_BIN := voidcache_bench.exe
.PHONY: all vcli test bench smoke clean deps bundle
all: vcli
# ── Install prerequisites ──────────────────────────────────────────────────
deps:
pacman -S --noconfirm --needed \
mingw-w64-ucrt-x86_64-gcc \
mingw-w64-ucrt-x86_64-openssl \
make
@echo "Done. Now run: make -f Makefile.windows vcli"
# ── Main binary (wepoll.c + mman.c compiled inline, no extra libs needed) ──
vcli: $(CORE_SRC) $(NET_SRC) $(CLI_SRC) $(COMPAT_SRC)
$(CC) $(CFLAGS) $^ -o $(TARGET) $(LDFLAGS)
@echo "Built: $(TARGET)"
# ── Tests (core only, no network) ─────────────────────────────────────────
$(TEST_BIN): $(CORE_SRC) $(TEST_SRC) compat/mman.c
$(CC) $(CFLAGS) $^ -o $@ -lpthread -lm
@echo "Built: $(TEST_BIN)"
test: $(TEST_BIN)
./$(TEST_BIN)
# ── Benchmark ─────────────────────────────────────────────────────────────
$(BENCH_BIN): $(CORE_SRC) $(BENCH_SRC) compat/mman.c
$(CC) $(CFLAGS) $^ -o $@ -lpthread -lm
@echo "Built: $(BENCH_BIN)"
bench: $(BENCH_BIN)
./$(BENCH_BIN)
# ── Quick smoke test ───────────────────────────────────────────────────────
smoke: vcli
@echo "Starting server on :16399..."
start "" ./$(TARGET) server --port 16399
sleep 1
./$(TARGET) -p 16399 --no-color PING
./$(TARGET) -p 16399 --no-color SET hello world
./$(TARGET) -p 16399 --no-color GET hello
./$(TARGET) -p 16399 --no-color SHUTDOWN NOSAVE 2>nul || true
# ── Bundle DLLs for standalone use ────────────────────────────────────────
bundle:
@for dll in libssl-3-x64.dll libcrypto-3-x64.dll \
libgcc_s_seh-1.dll libwinpthread-1.dll; do \
cp "$(MSYSTEM_PREFIX)/bin/$$dll" . 2>/dev/null && \
echo " Copied $$dll" || true; \
done
@echo "DLLs bundled. vcli.exe runs standalone."
clean:
rm -f $(TARGET) $(TEST_BIN) $(BENCH_BIN)