scorpiox-bot-plugin-netcheck
←Makefiletext
79 lines · 2 KBHEADBlameDownload
1# plugin_netcheck - SCORPIOX BOT open-source network diagnostics for your node
2#
3# Targets:
4# make native build -> ./plugin_netcheck
5# make musl static musl x86_64 -> ./plugin_netcheck.musl
6# make arm64 static arm64 musl (aarch64 cross) -> ./plugin_netcheck.arm64
7# make win64 MinGW-w64 static -> ./plugin_netcheck.exe
8# make macos Apple clang -> ./plugin_netcheck (run this on macOS)
9# make ui regenerate src/ui_html.h from src/ui.html
10# make test build + run tests/run.sh
11# make e2e build + run tests/e2e.py (Playwright)
12# make clean
13#
14# The resolver deadline runs in a worker thread, so every POSIX leg links
15# -lpthread (musl and macOS carry pthread inside libc).
16
17CC ?= cc
18CFLAGS ?= -O2 -std=c99 -Wall -Wextra -Wno-overlength-strings -I src
19MUSL_CC ?= musl-gcc
20MUSL_CFLAGS := -O2 -std=c99 -Wall -Wextra -Wno-overlength-strings -I src -static
21ARM_CC ?= aarch64-linux-gnu-gcc
22ARM_CFLAGS := -O2 -std=c99 -Wall -Wextra -Wno-overlength-strings -I src -static
23WIN_CC ?= x86_64-w64-mingw32-gcc
24WIN_CFLAGS := -O2 -std=c99 -Wall -Wextra -Wno-overlength-strings -I src -static
25PTHREAD := -lpthread
26SRC := src/plugin_netcheck.c
27UI_SRC := src/ui.html
28UI_HDR := src/ui_html.h
29BIN := plugin_netcheck
30EXE := plugin_netcheck.exe
31
32.PHONY: all native musl arm64 win64 macos ui test e2e clean help
33
34all: native
35
36$(UI_HDR): $(UI_SRC) tools/gen_ui.py
37 @echo "==> regenerating $(UI_HDR)"
38 python3 tools/gen_ui.py
39
40ui: $(UI_HDR)
41
42native: $(BIN)
43
44$(BIN): $(SRC) $(UI_HDR)
45 @echo "==> native build ($(CC))"
46 $(CC) $(CFLAGS) -o $(BIN) $(SRC) $(PTHREAD)
47
48# Static musl build - the universal Linux artifact (Alpine, Debian, Arch, Omarchy)
49musl: $(SRC) $(UI_HDR)
50 @echo "==> static musl build ($(MUSL_CC))"
51 $(MUSL_CC) $(MUSL_CFLAGS) -o $(BIN).musl $(SRC) $(PTHREAD)
52
53# Static aarch64 build - Raspberry Pi 5 / ARM64 servers
54arm64: $(SRC) $(UI_HDR)
55 @echo "==> static arm64 build ($(ARM_CC))"
56 $(ARM_CC) $(ARM_CFLAGS) -o $(BIN).arm64 $(SRC) $(PTHREAD)
57
58# Native Win64 static PE - runs on any Windows 10/11 x64 node
59win64: $(SRC) $(UI_HDR)
60 @echo "==> MinGW-w64 build ($(WIN_CC))"
61 $(WIN_CC) $(WIN_CFLAGS) -o $(EXE) $(SRC) -lws2_32 -liphlpapi
62
63# Apple clang build (run this on macOS)
64macos: $(SRC) $(UI_HDR)
65 @echo "==> Apple clang build"
66 $(CC) $(CFLAGS) -o $(BIN) $(SRC) $(PTHREAD)
67
68test: native
69 @sh tests/run.sh
70
71e2e: native
72 @python3 tests/e2e.py
73
74clean:
75 rm -f $(BIN) $(EXE) $(BIN).musl $(BIN).arm64 $(BIN).macos-arm64 $(BIN).macos-x86_64
76 rm -rf bin
77
78help:
79 @echo "make | make musl | make arm64 | make win64 | make macos | make ui | make test | make e2e | make clean"