-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
165 lines (139 loc) · 5.04 KB
/
Makefile
File metadata and controls
165 lines (139 loc) · 5.04 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
.PHONY: all clean help kernel rootfs iso image packages busybox runit fish curl git dropbear modules warp
export CFLAGS := -O2 -pipe -march=x86-64 -mtune=generic
export CXXFLAGS := $(CFLAGS)
export CPPFLAGS :=
export LDFLAGS :=
KERNEL_DIR := $(CURDIR)/kernel/linux-7.0
CUSTOM_DIR := $(CURDIR)/custom
BUILD_DIR := $(CURDIR)/build
SCRIPTS_DIR := $(CURDIR)/scripts
# Default target
all: help
# Help target
help:
@echo ""
@echo " ██╗ ██╗ ██╗ ██████╗ ███████╗"
@echo " ██║ ██╔╝███║██╔═══██╗██╔════╝"
@echo " █████╔╝ ╚██║██║ ██║███████╗"
@echo " ██╔═██╗ ██║██║ ██║╚════██║"
@echo " ██║ ██╗ ██║╚██████╔╝███████║"
@echo " ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝"
@echo " Minimalist Developer OS"
@echo ""
@echo "Build targets:"
@echo " make kernel - Build Linux kernel"
@echo " make rootfs - Build rootfs (BusyBox + runit + fish)"
@echo " make iso - Build bootable ISO image"
@echo " make all-build - Full build: kernel + rootfs + iso"
@echo " make image - Build K1OS container image"
@echo ""
@echo "Package targets:"
@echo " make busybox - Build BusyBox userland"
@echo " make runit - Build runit init system"
@echo " make fish - Build fish shell"
@echo " make tmux - Build tmux terminal multiplexer"
@echo " make nano - Build nano text editor"
@echo " make warp - Build warp package manager from KEYTRON/WARP"
@echo ""
@echo "Custom code:"
@echo " make modules - Build custom kernel modules"
@echo ""
@echo "Utilities:"
@echo " make clean - Clean all build artifacts"
@echo " make qemu - Test in QEMU (RAM mode)"
@echo " make make-persist - Create persist.qcow2 for QEMU"
@echo " make qemu-persist - Test in QEMU with persistent storage"
@echo ""
# Full build
all-build: kernel rootfs iso
# Kernel build
kernel:
@echo "[kernel] Configuring and building Linux kernel..."
@if [ ! -d "$(KERNEL_DIR)" ]; then \
echo "ERROR: Kernel source not found at $(KERNEL_DIR)"; \
exit 1; \
fi
@if [ ! -f "$(KERNEL_DIR)/.config" ]; then \
echo "[kernel] No .config found, using K1OS default config..."; \
cp $(BUILD_DIR)/kernel.config $(KERNEL_DIR)/.config; \
$(MAKE) -C $(KERNEL_DIR) olddefconfig; \
fi
$(MAKE) -C $(KERNEL_DIR) -j$(shell nproc)
@echo "[kernel] Build complete: $(KERNEL_DIR)/arch/x86/boot/bzImage"
# Rootfs build (all components)
rootfs: busybox runit fish curl git dropbear tmux nano python3 htop warp
@bash $(SCRIPTS_DIR)/build-rootfs.sh
# Individual packages
busybox:
@bash $(CURDIR)/packages/busybox/build.sh all
runit:
@bash $(CURDIR)/packages/runit/build.sh all
fish:
@bash $(CURDIR)/packages/fish/build.sh all
curl:
@bash $(CURDIR)/packages/curl/build.sh all
git:
@bash $(CURDIR)/packages/git/build.sh all
dropbear:
@bash $(CURDIR)/packages/dropbear/build.sh all
tmux:
@bash $(CURDIR)/packages/tmux/build.sh all
nano:
@bash $(CURDIR)/packages/nano/build.sh all
python3:
@bash $(CURDIR)/packages/python3/build.sh all
htop:
@bash $(CURDIR)/packages/htop/build.sh all
warp:
@bash $(CURDIR)/packages/warp/build.sh all
# Container image
image: rootfs
@docker build -t k1os:local -f $(CURDIR)/Dockerfile $(CURDIR)
# ISO image
iso:
@bash $(SCRIPTS_DIR)/build-iso.sh
# Custom kernel modules
modules:
@echo "[modules] Building custom kernel modules..."
@for module in $(CUSTOM_DIR)/modules/*/; do \
if [ -f "$$module/Makefile" ]; then \
echo "[modules] Building $$(basename $$module)..."; \
$(MAKE) -C "$$module" KERNEL_SRC=$(KERNEL_DIR); \
fi; \
done
# Test in QEMU
qemu:
@if [ ! -f "$(CURDIR)/k1os.iso" ]; then \
echo "ERROR: k1os.iso not found. Run: make iso"; \
exit 1; \
fi
qemu-system-x86_64 -m 512M -cdrom $(CURDIR)/k1os.iso -vga virtio -enable-kvm -cpu host,+avx,+avx2
qemu-nographic:
@if [ ! -f "$(CURDIR)/k1os.iso" ]; then \
echo "ERROR: k1os.iso not found. Run: make iso"; \
exit 1; \
fi
qemu-system-x86_64 -m 512M -cdrom $(CURDIR)/k1os.iso -nographic -enable-kvm -cpu host,+avx,+avx2
# Persistent storage: создать qcow2 + запустить QEMU с ним
make-persist:
@bash $(SCRIPTS_DIR)/make-persist.sh $(CURDIR)/persist.qcow2 2048
qemu-persist:
@if [ ! -f "$(CURDIR)/k1os.iso" ]; then \
echo "ERROR: k1os.iso not found. Run: make iso"; \
exit 1; \
fi
@if [ ! -f "$(CURDIR)/persist.qcow2" ]; then \
echo "No persist.qcow2 found. Run: make make-persist"; \
exit 1; \
fi
qemu-system-x86_64 -m 512M -cdrom $(CURDIR)/k1os.iso -hda $(CURDIR)/persist.qcow2 -vga virtio -enable-kvm -cpu host,+avx,+avx2
# Clean
clean:
@echo "[clean] Cleaning build artifacts..."
@$(MAKE) -C $(KERNEL_DIR) clean 2>/dev/null || true
@rm -rf $(CURDIR)/packages/busybox/build \
$(CURDIR)/packages/runit/build \
$(CURDIR)/packages/fish/build \
$(CURDIR)/iso \
$(CURDIR)/k1os.iso
@echo "[clean] Done"