-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
86 lines (69 loc) · 1.88 KB
/
Copy pathMakefile
File metadata and controls
86 lines (69 loc) · 1.88 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
# Proka Kernel - Rust Kernel Makefile
# Copyright (C) RainSTR Studio 2025-2026, All Rights Reserved.
# Disable built-in rules and variables for performance
MAKEFLAGS += -rR
.SUFFIXES:
# Output directory
OUT_DIR := $(CURDIR)/output
# Output binary name
OUTPUT := $(OUT_DIR)/proka-kernel
# Cargo package name
PKG_NAME := proka-kernel
# Rust target triple
RUST_TARGET := x86_64-unknown-none
# Build profile (dev, release)
PROFILE ?= dev
# Map 'dev' to Cargo's 'debug' directory
ifeq ($(PROFILE),dev)
PROFILE_DIR := debug
else
PROFILE_DIR := $(PROFILE)
endif
# Verbosity control
ifeq ($(V),1)
Q :=
else
Q := @
endif
# Rust compilation flags
RUSTFLAGS := -C relocation-model=static \
-C code-model=large \
-C no-redzone \
-C force-frame-pointers=yes
# Binary path relative to kernel directory
BIN_PATH ?= target/$(RUST_TARGET)/$(PROFILE_DIR)/$(PKG_NAME)
.PHONY: all clean menuconfig fmt clippy
all: $(OUTPUT)
$(OUTPUT): $(BIN_PATH)
$(Q)mkdir -p $(OUT_DIR)
$(Q)cp $< $@.elf
$(Q)objcopy -O binary $@.elf $@
$(Q)rm -f $(BIN_PATH)
@echo "[INFO] Kernel binary ready: $@"
$(BIN_PATH): .FORCE
@echo "[INFO] Building kernel in $(PROFILE) mode..."
$(Q)RUSTFLAGS="$(RUSTFLAGS)" cargo anaxa build --no-env --target $(RUST_TARGET) --profile $(PROFILE)
clippy:
$(Q)RUSTFLAGS="$(RUSTFLAGS)" cargo clippy --target $(RUST_TARGET) --all-features
.FORCE:
menuconfig:
$(Q)cargo anaxa menuconfig
fmt:
$(Q)cargo fmt
# Documentation targets
doc:
@echo "[INFO] Building guide (mdBook)..."
$(Q)mdbook build
@echo "[INFO] Building API documentation (rustdoc)..."
$(Q)cargo doc --no-deps
$(Q)rm -rf book/api
$(Q)cp -r target/doc book/api
@echo "[INFO] Documentation has successfully built in book"
docs-clean:
@echo "[INFO] Cleaning documentation..."
$(Q)mdbook clean
$(Q)rm -rf book
$(Q)cargo clean --doc
clean: docs-clean
$(Q)cargo clean
$(Q)rm -rf $(OUT_DIR)