|
1 | | -export RUSTFLAGS := -Ctarget-cpu=native |
| 1 | +EXE := reckless |
| 2 | +TARGET := $(shell rustc --print host-tuple) |
2 | 3 |
|
3 | | -EXE := reckless |
4 | | -TARGET_TUPLE := $(shell rustc --print host-tuple) |
| 4 | +RUSTFLAGS ?= -C target-cpu=native |
| 5 | +export RUSTFLAGS |
5 | 6 |
|
6 | 7 | ifdef MSYSTEM |
7 | 8 | NAME := $(EXE).exe |
8 | | - ENV = UNIX |
| 9 | + ENV := UNIX |
9 | 10 | else ifeq ($(OS),Windows_NT) |
10 | 11 | NAME := $(EXE).exe |
11 | | - ENV = WINDOWS |
| 12 | + ENV := WINDOWS |
12 | 13 | else |
13 | 14 | NAME := $(EXE) |
14 | | - ENV := UNIX |
| 15 | + ENV := UNIX |
15 | 16 | endif |
16 | 17 |
|
17 | 18 | ifeq ($(ENV),UNIX) |
18 | | - PGO_MOVE := mv "target/$(TARGET_TUPLE)/release/reckless" "$(NAME)" |
| 19 | + PGO_MOVE := mv "target/$(TARGET)/release/$(EXE)" "$(NAME)" |
19 | 20 | else |
20 | | - PGO_MOVE := move /Y "target\$(TARGET_TUPLE)\release\reckless.exe" "$(NAME)" |
| 21 | + PGO_MOVE := move /Y "target\$(TARGET)\release\$(EXE).exe" "$(NAME)" |
21 | 22 | endif |
22 | 23 |
|
23 | | -rule: |
24 | | - cargo rustc --release --bin reckless -- -C target-cpu=native --emit link=$(NAME) |
| 24 | +.PHONY: all no-syzygy pgo wasm x64-check checkdeps clean help |
25 | 25 |
|
26 | | -wasm: |
27 | | - unset RUSTFLAGS && rustup run nightly \ |
| 26 | +all: ## Build the engine |
| 27 | + cargo rustc --release --bin $(EXE) -- --emit link=$(NAME) |
| 28 | + |
| 29 | +no-syzygy: ## Build without syzygy support |
| 30 | + cargo rustc --release --bin $(EXE) --no-default-features -- --emit link=$(NAME) |
| 31 | + |
| 32 | +pgo: ## Build with profile-guided optimization |
| 33 | + cargo pgo instrument |
| 34 | + cargo pgo run -- bench |
| 35 | + cargo pgo optimize |
| 36 | + $(PGO_MOVE) |
| 37 | + |
| 38 | +wasm: ## Build the WebAssembly target |
| 39 | + RUSTFLAGS= rustup run nightly \ |
28 | 40 | cargo build -Z build-std=panic_abort,std \ |
29 | 41 | --lib --target wasm32-unknown-unknown --release --no-default-features |
30 | 42 | wasm-bindgen target/wasm32-unknown-unknown/release/reckless.wasm --target web --out-dir pkg |
31 | 43 | wasm-opt -O3 --enable-simd --enable-threads --enable-relaxed-simd \ |
32 | 44 | pkg/reckless_bg.wasm -o pkg/reckless_bg.wasm |
33 | 45 |
|
34 | | - |
35 | | -x64-check: |
| 46 | +x64-check: ## Check compilation for x86-64 v1-v4 |
36 | 47 | RUSTFLAGS="-C target-cpu=x86-64" cargo check --target x86_64-unknown-linux-gnu --no-default-features |
| 48 | + RUSTFLAGS="-C target-cpu=x86-64-v2" cargo check --target x86_64-unknown-linux-gnu --no-default-features |
37 | 49 | RUSTFLAGS="-C target-cpu=x86-64-v3" cargo check --target x86_64-unknown-linux-gnu --no-default-features |
38 | 50 | RUSTFLAGS="-C target-cpu=x86-64-v4 -C target-feature=+gfni,+avx512bw,+avx512vl,+avx512vbmi,+avx512vbmi2,+avx512vnni,+avx512bitalg" cargo check --target x86_64-unknown-linux-gnu --no-default-features |
39 | 51 |
|
40 | | -pgo: |
41 | | - cargo pgo instrument |
42 | | - cargo pgo run -- bench |
43 | | - cargo pgo optimize |
44 | | - $(PGO_MOVE) |
| 52 | +checkdeps: ## Verify build dependencies are installed |
| 53 | + @echo "-- required --" |
| 54 | + @command -v rustc >/dev/null 2>&1 && echo " rustc ok" || (echo " rustc MISSING"; exit 1) |
| 55 | + @command -v clang >/dev/null 2>&1 && echo " clang ok" || echo " clang MISSING (required for Syzygy; use 'make no-syzygy' to skip)" |
| 56 | + @echo "-- pgo --" |
| 57 | + @command -v cargo-pgo >/dev/null 2>&1 && echo " cargo-pgo ok" || echo " cargo-pgo missing (run: cargo install cargo-pgo)" |
| 58 | + @echo "-- wasm --" |
| 59 | + @rustup toolchain list 2>/dev/null | grep -q nightly && echo " nightly ok" || echo " nightly missing (run: rustup toolchain install nightly)" |
| 60 | + @command -v wasm-bindgen >/dev/null 2>&1 && echo " wasm-bindgen ok" || echo " wasm-bindgen missing (run: cargo install wasm-bindgen-cli)" |
| 61 | + @command -v wasm-opt >/dev/null 2>&1 && echo " wasm-opt ok" || echo " wasm-opt missing (install binaryen)" |
| 62 | + |
| 63 | +clean: ## Remove build artifacts |
| 64 | + cargo clean |
| 65 | + rm -f "$(EXE)" "$(EXE).exe" |
| 66 | + |
| 67 | +help: ## Show this help |
| 68 | + @awk 'BEGIN {FS = ":.*##"} /^[a-zA-Z0-9_-]+:.*?##/ { \ |
| 69 | + printf " %-12s %s\n", $$1, $$2 \ |
| 70 | + }' $(MAKEFILE_LIST) |
0 commit comments