scorpiox-bot-plugin-ntfy
←Makefiletext
106 lines · 3 KBHEADBlameDownload
1# plugin_ntfy - SCORPIOX BOT open-source ntfy push & pub/sub channel connector
2#
3# Targets:
4# make native build -> ./plugin_ntfy
5# make musl static musl x86_64
6# make arm64 static arm64 (aarch64 cross)
7# make win64 MinGW-w64 static PE
8# make macos Apple clang (run on macOS)
9# make ui regenerate src/ui_html.h from src/ui.html
10# make cabundle regenerate src/ca_bundle_pem.h
11# make asan ASan + UBSan build under tests/asan/
12# make fortify -D_FORTIFY_SOURCE=2 build under tests/fortify/
13# make test build + run tests/run.sh
14# make e2e build + run tests/e2e.py (Playwright)
15# make clean
16#
17# Sources: the plugin itself (src/plugin_ntfy.c + src/sx_http.c +
18# src/sx_connectors.c) plus the two vendored libraries:
19# vendor/yyjson.c (MIT, ibireme)
20# vendor/mbedtls/*.c (Apache-2.0, Mbed TLS 3.6.6, client config
21# pinned in src/sx_ntfy_mbedtls_config.h)
22# The vendored mbedTLS public headers live in src/mbedtls + src/psa because
23# the SCORPIOX BOT release CLI compiles every .c under src/ + vendor/ with a
24# fixed -I src -I vendor flag set, and quoted "mbedtls/*.h" includes resolve
25# through -I src.
26
27CC ?= cc
28MBEDTLS_CFG := -DMBEDTLS_CONFIG_FILE=\<sx_ntfy_mbedtls_config.h\>
29BASE_INC := -I src -I vendor
30CFLAGS ?= -O2 -std=c99 -Wall -Wextra -Wno-overlength-strings $(BASE_INC) $(MBEDTLS_CFG)
31MUSL_CC ?= musl-gcc
32MUSL_CFLAGS := -O2 -std=c99 -Wall -Wextra -Wno-overlength-strings $(BASE_INC) $(MBEDTLS_CFG) -static
33ARM_CC ?= aarch64-linux-gnu-gcc
34ARM_CFLAGS := -O2 -std=c99 -Wall -Wextra -Wno-overlength-strings $(BASE_INC) $(MBEDTLS_CFG) -static
35WIN_CC ?= x86_64-w64-mingw32-gcc
36WIN_CFLAGS := -O2 -std=c99 -Wall -Wextra -Wno-overlength-strings $(BASE_INC) $(MBEDTLS_CFG) -static
37
38PLUGINSRCS := src/plugin_ntfy.c src/sx_http.c src/sx_connectors.c
39VENDORSRCS := vendor/yyjson.c $(wildcard vendor/mbedtls/*.c)
40ALLSRCS := $(PLUGINSRCS) $(VENDORSRCS)
41UI_SRC := src/ui.html
42UI_HDR := src/ui_html.h
43CA_HDR := src/ca_bundle_pem.h
44BIN := plugin_ntfy
45EXE := plugin_ntfy.exe
46LIBS := -lpthread
47
48.PHONY: all native musl arm64 win64 macos ui cabundle asan fortify test e2e clean help
49
50all: native
51
52$(UI_HDR): $(UI_SRC) tools/gen_ui.py
53 @echo "==> regenerating $(UI_HDR)"
54 python3 tools/gen_ui.py
55
56ui: $(UI_HDR)
57
58cabundle:
59 python3 tools/gen_ca_bundle.py
60
61$(CA_HDR):
62 python3 tools/gen_ca_bundle.py
63
64native: $(BIN)
65
66$(BIN): $(ALLSRCS) $(UI_HDR) $(CA_HDR)
67 @echo "==> native build ($(CC))"
68 $(CC) $(CFLAGS) -o $(BIN) $(ALLSRCS) $(LIBS)
69
70musl: $(ALLSRCS) $(UI_HDR) $(CA_HDR)
71 @echo "==> static musl build ($(MUSL_CC))"
72 $(MUSL_CC) $(MUSL_CFLAGS) -o $(BIN).musl $(ALLSRCS) $(LIBS)
73
74arm64: $(ALLSRCS) $(UI_HDR) $(CA_HDR)
75 @echo "==> static arm64 build ($(ARM_CC))"
76 $(ARM_CC) $(ARM_CFLAGS) -o $(BIN).arm64 $(ALLSRCS) $(LIBS)
77
78win64: $(ALLSRCS) $(UI_HDR) $(CA_HDR)
79 @echo "==> MinGW-w64 build ($(WIN_CC))"
80 $(WIN_CC) $(WIN_CFLAGS) -o $(EXE) $(ALLSRCS) -lws2_32 -lbcrypt
81
82macos: $(ALLSRCS) $(UI_HDR) $(CA_HDR)
83 @echo "==> Apple clang build"
84 $(CC) $(CFLAGS) -o $(BIN) $(ALLSRCS) $(LIBS)
85
86asan: $(UI_HDR) $(CA_HDR)
87 @mkdir -p tests/asan
88 $(CC) $(CFLAGS) -g -O1 -fsanitize=address,undefined -fno-omit-frame-pointer \
89 -o tests/asan/plugin_ntfy_asan $(ALLSRCS) $(LIBS)
90
91fortify: $(UI_HDR) $(CA_HDR)
92 @mkdir -p tests/fortify
93 $(CC) $(CFLAGS) -O2 -D_FORTIFY_SOURCE=2 -o tests/fortify/plugin_ntfy_fortify $(ALLSRCS) $(LIBS)
94
95test: native
96 @bash tests/run.sh
97
98e2e: native
99 @python3 tests/e2e.py
100
101clean:
102 rm -f $(BIN) $(EXE) $(BIN).musl $(BIN).arm64 $(BIN).macos-arm64 $(BIN).macos-x86_64
103 rm -rf tests/asan tests/fortify bin
104
105help:
106 @echo "make | make musl | make arm64 | make win64 | make macos | make ui | make cabundle | make asan | make fortify | make test | make e2e | make clean"