| 1 | # plugin_disks - SCORPIOX BOT open-source local storage inspector plugin |
| 2 | # |
| 3 | # Targets: |
| 4 | # make native build -> ./plugin_disks |
| 5 | # make musl static musl x86_64 -> ./plugin_disks (fully static) |
| 6 | # make arm64 static musl aarch64 -> ./plugin_disks.arm64 |
| 7 | # make win64 MinGW-w64 static -> ./plugin_disks.exe |
| 8 | # make macos Apple clang -> ./plugin_disks (run on macOS) |
| 9 | # make test build + run tests/run.sh |
| 10 | # make clean |
| 11 | |
| 12 | CC ?= cc |
| 13 | CFLAGS ?= -O2 -std=c99 -Wall -Wextra -pedantic -Wno-overlength-strings |
| 14 | MUSL_CC ?= musl-gcc |
| 15 | MUSL_CFLAGS := -O2 -std=c99 -Wall -Wextra -static |
| 16 | ARM64_CC ?= $(shell command -v aarch64-linux-musl-gcc 2>/dev/null || \ |
| 17 | command -v aarch64-linux-gnu-gcc 2>/dev/null || \ |
| 18 | echo aarch64-linux-musl-gcc) |
| 19 | ARM64_CFLAGS := -O2 -std=c99 -Wall -Wextra -static |
| 20 | WIN_CC ?= x86_64-w64-mingw32-gcc |
| 21 | WIN_CFLAGS := -O2 -std=c99 -Wall -Wextra -static |
| 22 | SRC := src/plugin_disks.c |
| 23 | BIN := plugin_disks |
| 24 | EXE := plugin_disks.exe |
| 25 | |
| 26 | .PHONY: all native musl arm64 win64 macos test clean help |
| 27 | |
| 28 | all: native |
| 29 | |
| 30 | native: $(BIN) |
| 31 | |
| 32 | $(BIN): $(SRC) |
| 33 | @echo "==> native build ($(CC))" |
| 34 | $(CC) $(CFLAGS) -o $(BIN) $(SRC) |
| 35 | |
| 36 | # Static musl build - the universal Linux artifact (Alpine, Debian, Arch, Omarchy) |
| 37 | musl: $(SRC) |
| 38 | @echo "==> static musl build ($(MUSL_CC))" |
| 39 | $(MUSL_CC) $(MUSL_CFLAGS) -o $(BIN) $(SRC) |
| 40 | |
| 41 | # Static aarch64 musl build - Raspberry Pi 5 / ARM64 servers |
| 42 | arm64: $(SRC) |
| 43 | @echo "==> static arm64 musl build ($(ARM64_CC))" |
| 44 | $(ARM64_CC) $(ARM64_CFLAGS) -o $(BIN).arm64 $(SRC) |
| 45 | |
| 46 | # Native Win64 static PE - runs on any Windows 10/11 x64 node |
| 47 | win64: $(SRC) |
| 48 | @echo "==> MinGW-w64 build ($(WIN_CC))" |
| 49 | $(WIN_CC) $(WIN_CFLAGS) -o $(EXE) $(SRC) |
| 50 | |
| 51 | # Apple clang build (run this on macOS) |
| 52 | macos: $(SRC) |
| 53 | @echo "==> Apple clang build" |
| 54 | $(CC) $(CFLAGS) -o $(BIN) $(SRC) |
| 55 | |
| 56 | test: native |
| 57 | @sh tests/run.sh |
| 58 | |
| 59 | clean: |
| 60 | rm -f $(BIN) $(EXE) $(BIN).musl $(BIN).arm64 \ |
| 61 | $(BIN).macos-arm64 $(BIN).macos-x86_64 |
| 62 | rm -rf bin |
| 63 | |
| 64 | help: |
| 65 | @echo "make | make musl | make arm64 | make win64 | make macos | make test | make clean" |