.PHONY: all clean bindings lib zig-example help test
all: bindings zig-example
lib:
@echo "Building Rust library..."
cargo build --release
bindings: lib
@echo "C header generated at: bindings/h"
zig-example: bindings zig-basic zig-mosaic
zig-basic: bindings
@echo "Building Zig basic example..."
@if ! command -v zig &> /dev/null; then \
echo "Error: zig not found. Please install Zig from https://ziglang.org/"; \
exit 1; \
fi
cd bindings/zig && zig build -Doptimize=ReleaseSafe
zig-mosaic: zig-basic
@echo "Zig mosaic example built with basic example"
run-zig: zig-basic
@echo "Running Zig basic example..."
@echo "Note: This requires a terminal (TTY). Run directly if make fails:"
@echo " On macOS: DYLD_LIBRARY_PATH=target/release ./bindings/zig/zig-out/bin/basic"
@echo " On Linux: LD_LIBRARY_PATH=target/release ./bindings/zig/zig-out/bin/basic"
@echo ""
@if [ "$(shell uname)" = "Darwin" ]; then \
DYLD_LIBRARY_PATH=target/release ./bindings/zig/zig-out/bin/basic; \
else \
LD_LIBRARY_PATH=target/release ./bindings/zig/zig-out/bin/basic; \
fi
run-zig-mosaic: zig-mosaic
@echo "Running Zig mosaic example..."
@echo "Note: This requires a terminal (TTY). Run directly if make fails:"
@echo " On macOS: DYLD_LIBRARY_PATH=target/release ./bindings/zig/zig-out/bin/mosaic"
@echo " On Linux: LD_LIBRARY_PATH=target/release ./bindings/zig/zig-out/bin/mosaic"
@echo ""
@if [ "$(shell uname)" = "Darwin" ]; then \
DYLD_LIBRARY_PATH=target/release ./bindings/zig/zig-out/bin/mosaic; \
else \
LD_LIBRARY_PATH=target/release ./bindings/zig/zig-out/bin/mosaic; \
fi
test:
@echo "Running Rust tests..."
cargo test
clean:
@echo "Cleaning build artifacts..."
cargo clean
rm -rf bindings/zig/zig-out
rm -rf bindings/zig/.zig-cache
help:
@echo "Library Bindings - Makefile targets:"
@echo ""
@echo " make - Build everything (lib + bindings + zig examples)"
@echo " make lib - Build the Rust library"
@echo " make bindings - Generate C header file"
@echo " make zig-example - Build all Zig examples"
@echo " make zig-basic - Build basic Zig example"
@echo " make zig-mosaic - Build mosaic Zig example"
@echo " make run-zig - Build and run basic Zig example"
@echo " make run-zig-mosaic - Build and run mosaic Zig example"
@echo " make test - Run Rust tests"
@echo " make clean - Remove all build artifacts"
@echo " make help - Show this help message"
@echo ""
@echo "Requirements:"
@echo " - Rust (cargo)"
@echo " - Zig compiler (for building Zig examples)"
@echo ""