| 1 | # plugin_tetris_3d - SCORPIOX BOT open-source 3D block game |
| 2 | # |
| 3 | # Targets: |
| 4 | # make native build -> ./plugin_tetris_3d |
| 5 | # make musl static musl x86_64 -> ./plugin_tetris_3d.musl |
| 6 | # make arm64 static aarch64 -> ./plugin_tetris_3d.arm64 |
| 7 | # make win64 MinGW-w64 static PE -> ./plugin_tetris_3d.exe |
| 8 | # make macos Apple clang (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 -Wno-overlength-strings |
| 16 | ARM_CC ?= aarch64-linux-gnu-gcc |
| 17 | ARM_CFLAGS := -O2 -std=c99 -Wall -Wextra -static -Wno-overlength-strings |
| 18 | WIN_CC ?= x86_64-w64-mingw32-gcc |
| 19 | WIN_CFLAGS := -O2 -std=c99 -Wall -Wextra -static -Wno-overlength-strings |
| 20 | SRC := src/plugin_tetris_3d.c |
| 21 | BIN := plugin_tetris_3d |
| 22 | EXE := plugin_tetris_3d.exe |
| 23 | PREFIX ?= $(HOME)/.scorpiox/plugins |
| 24 | |
| 25 | .PHONY: all native musl arm64 win64 macos install test clean help |
| 26 | |
| 27 | all: native |
| 28 | |
| 29 | native: $(BIN) |
| 30 | |
| 31 | $(BIN): $(SRC) src/ui_html.h |
| 32 | @echo "==> native build ($(CC))" |
| 33 | $(CC) $(CFLAGS) -o $(BIN) $(SRC) |
| 34 | |
| 35 | # Static musl build - the universal Linux artifact (Alpine, Debian, Arch, Omarchy) |
| 36 | musl: $(SRC) src/ui_html.h |
| 37 | @echo "==> static musl build ($(MUSL_CC))" |
| 38 | $(MUSL_CC) $(MUSL_CFLAGS) -o $(BIN).musl $(SRC) |
| 39 | |
| 40 | # Static aarch64 build - Raspberry Pi 5 / ARM64 servers |
| 41 | arm64: $(SRC) src/ui_html.h |
| 42 | @echo "==> static arm64 build ($(ARM_CC))" |
| 43 | $(ARM_CC) $(ARM_CFLAGS) -o $(BIN).arm64 $(SRC) |
| 44 | |
| 45 | # Native Win64 static PE - runs on any Windows 10/11 x64 node |
| 46 | win64: $(SRC) src/ui_html.h |
| 47 | @echo "==> MinGW-w64 build ($(WIN_CC))" |
| 48 | $(WIN_CC) $(WIN_CFLAGS) -o $(EXE) $(SRC) |
| 49 | |
| 50 | # Apple clang build (run this on macOS) |
| 51 | macos: $(SRC) src/ui_html.h |
| 52 | @echo "==> Apple clang build" |
| 53 | $(CC) -O2 -std=c99 -Wall -Wextra -Wno-overlength-strings -o $(BIN) $(SRC) |
| 54 | |
| 55 | install: native |
| 56 | @echo "==> install to $(PREFIX)" |
| 57 | mkdir -p "$(PREFIX)" |
| 58 | cp $(BIN) "$(PREFIX)/" |
| 59 | chmod +x "$(PREFIX)/$(BIN)" |
| 60 | |
| 61 | test: native |
| 62 | @sh tests/run.sh |
| 63 | |
| 64 | clean: |
| 65 | rm -f $(BIN) $(EXE) $(BIN).musl $(BIN).arm64 $(BIN).macos-arm64 $(BIN).macos-x86_64 |
| 66 | rm -rf bin |
| 67 | |
| 68 | help: |
| 69 | @echo "make | make musl | make arm64 | make win64 | make macos | make install | make test | make clean" |