forked from scragnog/HOT-Step-CPP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
119 lines (104 loc) · 4.38 KB
/
Copy pathMakefile
File metadata and controls
119 lines (104 loc) · 4.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# Convenience wrapper for Linux / WSL development.
# Windows-native development uses dev.bat / LAUNCH.bat / dev-rebuild.bat instead.
# Configuration
REPO_DIR = .
BACKEND ?=
# Detect if running inside WSL
IS_WSL := $(shell grep -qi microsoft /proc/version 2>/dev/null && echo 1 || echo 0)
# Auto-detect backend if not explicitly provided: CUDA if a driver is visible,
# else Vulkan if the SDK's shader compiler is installed, else CPU.
ifeq ($(BACKEND),)
ifeq ($(IS_WSL),1)
# In WSL, check if NVIDIA CUDA driver bridge is present
ifneq ($(wildcard /usr/lib/wsl/lib/libcuda.so*),)
BACKEND = cuda
endif
else
# Native Linux detection
ifneq ($(wildcard /usr/local/cuda*),)
BACKEND = cuda
endif
endif
endif
ifeq ($(BACKEND),)
ifneq ($(shell command -v glslc 2>/dev/null),)
BACKEND = vulkan
else
BACKEND = cpu
endif
endif
# Determine CMake flags based on backend selection
ifeq ($(BACKEND),cuda)
CMAKE_FLAGS = -DGGML_CUDA=ON -DCMAKE_BUILD_TYPE=Release
else ifeq ($(BACKEND),vulkan)
CMAKE_FLAGS = -DGGML_VULKAN=ON -DCMAKE_BUILD_TYPE=Release
else
CMAKE_FLAGS = -DCMAKE_BUILD_TYPE=Release
endif
NODE_MAJOR := $(shell node -v 2>/dev/null | sed 's/^v\([0-9]*\).*/\1/')
.PHONY: check-config check-node setup submodules build install run clean help
check-config: ## Check current configuration before building
@echo "========================================"
@echo " BUILD CONFIGURATION "
@echo "========================================"
@echo " Environment : $(if $(filter 1,$(IS_WSL)),WSL (Windows Subsystem for Linux),Native Linux)"
@echo " Backend : $(BACKEND)"
@echo " CMake Flags : $(CMAKE_FLAGS)"
@echo " Node.js : $(if $(NODE_MAJOR),v$(NODE_MAJOR) (need 18-22),not found)"
@echo " Repository : $(REPO_DIR)"
@echo "========================================"
check-node: ## Verify Node.js 18-22 LTS is installed
@if [ -z "$(NODE_MAJOR)" ]; then \
echo "ERROR: Node.js not found. Install Node 18-22 LTS, e.g. with nvm:"; \
echo " https://github.com/nvm-sh/nvm then: nvm install 22 && nvm use 22"; \
exit 1; \
fi
@if [ "$(NODE_MAJOR)" -lt 18 ] || [ "$(NODE_MAJOR)" -gt 22 ]; then \
echo "ERROR: Node v$(NODE_MAJOR) detected, but HOT-Step requires Node 18-22 LTS"; \
echo " (Node 24+ breaks native dependencies - see README)."; \
echo " With nvm: nvm install 22 && nvm use 22"; \
exit 1; \
fi
setup: ## Install system dependencies (except Node - use nvm for that)
@echo "==> Installing system dependencies..."
sudo apt update && sudo apt install -y build-essential cmake git
@echo ""
@echo "==> NOTE: Node.js 18-22 LTS is also required (apt's version is often wrong)."
@echo " Recommended: install via nvm - https://github.com/nvm-sh/nvm"
@echo " Then run 'make check-node' to verify."
submodules: ## Initialise git submodules (required before first build)
@echo "==> Initialising git submodules..."
git submodule update --init --recursive
build: submodules ## Build the C++ engine
ifeq ($(BACKEND),vulkan)
@command -v glslc >/dev/null 2>&1 || { \
echo "ERROR: Vulkan backend selected but glslc not found."; \
echo " Install the Vulkan SDK: https://vulkan.lunarg.com/sdk/home"; \
exit 1; }
endif
@echo "==> Building C++ engine ($(BACKEND) backend)..."
cd $(REPO_DIR)/engine && mkdir -p build && cd build && \
cmake .. $(CMAKE_FLAGS) && \
cmake --build . -j $$(nproc)
install: check-node ## Install Node.js dependencies for server and UI
@echo "==> Installing Node.js dependencies for server..."
cd $(REPO_DIR)/server && npm install
@echo "==> Installing Node.js dependencies for UI..."
cd $(REPO_DIR)/ui && npm install
run: ## Launch the application
@echo "==> Launching application..."
cd $(REPO_DIR) && ./launch.sh
clean: ## Clean build artifacts (requires CONFIRM=1 - CUDA rebuild takes 20+ min)
ifneq ($(CONFIRM),1)
@echo "This deletes engine/build and all node_modules."
@echo "A CUDA engine rebuild from scratch takes 20+ minutes."
@echo "Run 'make clean CONFIRM=1' if you really want this."
@exit 1
else
@echo "==> Cleaning build files..."
rm -rf $(REPO_DIR)/engine/build
rm -rf $(REPO_DIR)/server/node_modules
rm -rf $(REPO_DIR)/ui/node_modules
endif
help: ## Show this help message
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'