-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
229 lines (194 loc) · 6.6 KB
/
Makefile
File metadata and controls
229 lines (194 loc) · 6.6 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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
KDBG_ENABLE ?= 1
KDBG_LEVEL ?= 1
GPP_PARAMS = -m32 -g -ffreestanding -Iinclude -fno-use-cxa-atexit -nostdlib -fno-builtin -fno-rtti -fno-exceptions -fno-common -fno-omit-frame-pointer -DKDBG_ENABLE=$(KDBG_ENABLE) -DKDBG_LEVEL=$(KDBG_LEVEL)
ASM_PARAMS = --32 -g
ASM_NASM_PARAMS = -f elf32
objects = asm/common_handler.o \
asm/load_gdt.o \
asm/load_tss.o \
asm/loader.o \
audio/wav.o \
core/driver.o \
core/drivers/ata.o \
core/drivers/AudioMixer.o \
core/drivers/GraphicsDriver.o \
core/drivers/keyboard.o \
core/drivers/ModuleLoader.o \
core/drivers/mouse.o \
core/drivers/SymbolTable.o \
core/drivers/vbe.o \
core/elf.o \
core/filesystem/FAT32.o \
core/filesystem/File.o \
core/filesystem/msdospart.o \
core/gdt.o \
core/globals.o \
core/interrupts.o \
core/KernelSymbolResolver.o \
core/memory.o \
core/paging.o \
core/pci.o \
core/pmm.o \
core/ports.o \
core/scheduler.o \
core/syscalls.o \
debug.o \
gui/bmp.o \
gui/button.o \
gui/desktop.o \
gui/elements/window_action_button.o \
gui/elements/window_action_button_round.o \
gui/fonts/font.o \
gui/Hgui.o \
gui/label.o \
gui/renderer/nina.o \
gui/taskbar.o \
gui/widget.o \
gui/window.o \
kernel.o \
stdlib.o \
stdlib/math.o \
utils/string.o
LD_PARAMS = -melf_i386 -Map kernel.map
# Compiling C++ files inside the main directory
%.o: %.cpp
g++ $(GPP_PARAMS) -o $@ -c $<
# Compiling C++ files inside the core directory
core/%.o: core/%.cpp
g++ $(GPP_PARAMS) -o $@ -c $<
core/%.o: %.c
g++ $(GPP_PARAMS) -o $@ -c $<
# Compiling C++ files inside the gui directory
gui/%.o: gui/%.cpp
g++ $(GPP_PARAMS) -o $@ -c $<
# Compiling C++ files inside the stdlib directory
stdlib/%.o: stdlib/%.cpp
g++ $(GPP_PARAMS) -o $@ -c $<
# Compiling assembly files
asm/%.o: asm/%.s
as $(ASM_PARAMS) -o $@ $<
# Compiling NASM assembly files
asm/%.o: asm/%.asm
nasm $(ASM_NASM_PARAMS) -o $@ $<
# Linking the kernel binary
kernel.bin: linker.ld $(objects)
ld $(LD_PARAMS) -T $< -o $@ $(objects)
# Install the kernel binary
install: kernel.bin
sudo cp kernel.bin /boot/kernel.bin
# Clean rule: removes object files and the final binary
clean:
rm -f $(objects) kernel.bin
build:
make clean
make
make -C user_prog clean
make -C user_prog
make iso
make hdd
make runq
runq:
qemu-system-i386 -cdrom kernel.iso -boot d -vga std -serial stdio -m 1G \
-drive file=HDD.vdi,format=vdi \
-audiodev pa,id=snd0 \
-device ac97,audiodev=snd0
run:
make clean
make
make iso
make runq
hdd:
# Cleanup from previous mounts
-sudo umount /mnt/vdi_p1
-sudo qemu-nbd --disconnect /dev/nbd0
# 1. Load the NBD module
sudo modprobe nbd max_part=16
# 2. Connect VHD to /dev/nbd0
sudo qemu-nbd --connect=/dev/nbd0 HDD.vdi
# 3. Mount Partition 1 (p1)
sudo mkdir -p /mnt/vdi_p1
sudo mount /dev/nbd0p1 /mnt/vdi_p1
# 4. Copy Files
-sudo mkdir -p /mnt/vdi_p1/bin
-sudo mkdir -p /mnt/vdi_p1/fonts
-sudo mkdir -p /mnt/vdi_p1/bitmaps
-sudo mkdir -p /mnt/vdi_p1/drivers
-sudo mkdir -p /mnt/vdi_p1/audio
-sudo mkdir -p /mnt/vdi_p1/SYS32
-sudo mkdir -p /mnt/vdi_p1/ProgFile/Game3D
-sudo cp kernel.map /mnt/vdi_p1/kernel.map
-sudo cp bin/audio/boot.wav /mnt/vdi_p1/audio/boot.wav
-sudo cp bin/bitmaps/boot.bmp /mnt/vdi_p1/bitmaps/boot.bmp
-sudo cp bin/bitmaps/icon.bmp /mnt/vdi_p1/bitmaps/icon.bmp
-sudo cp bin/bitmaps/cursor.bmp /mnt/vdi_p1/bitmaps/cursor.bmp
-sudo cp bin/bitmaps/desktop.bmp /mnt/vdi_p1/bitmaps/desktop.bmp
-sudo cp bin/bitmaps/panic.bmp /mnt/vdi_p1/bitmaps/panic.bmp
-sudo cp bin/ProgFile/Game3D/obj.obj /mnt/vdi_p1/ProgFile/Game3D/obj.obj
-sudo cp bin/ProgFile/Game3D/floor.obj /mnt/vdi_p1/ProgFile/Game3D/floor.obj
-sudo cp bin/ProgFile/Game3D/map.bmp /mnt/vdi_p1/ProgFile/Game3D/map.bmp
-sudo cp bin/ProgFile/Game3D/sky.bmp /mnt/vdi_p1/ProgFile/Game3D/sky.bmp
# -sudo cp bin/sound.wav /mnt/vdi_p1/sound.wav
# -sudo rm -f /mnt/vdi_p1/drivers/ac97.sys
-sudo cp drivers/bga.sys /mnt/vdi_p1/drivers/bga.sys
-sudo cp drivers/ac97.sys /mnt/vdi_p1/drivers/ac97.sys
-sudo cp bin/fonts/segoeui.bin /mnt/vdi_p1/fonts/segoeui.bin
-sudo cp user_prog/MeMView/prog.bin /mnt/vdi_p1/SYS32/MeMView.bin
-sudo cp user_prog/test/prog.bin /mnt/vdi_p1/SYS32/test.bin
-sudo cp user_prog/Game3D/prog.bin /mnt/vdi_p1/ProgFile/Game3D/Game3D.bin
# 5. Cleanup
sudo umount /mnt/vdi_p1
sudo qemu-nbd --disconnect /dev/nbd0
runvb: kernel.iso
(killall VirtualBox && sleep 1) || true
VirtualBox --startvm 'My Operating System' &
iso: kernel.bin
mkdir iso
mkdir iso/boot
mkdir iso/boot/grub
mkdir iso/boot/fonts
cp kernel.bin iso/boot/kernel.bin
# cp bin/fonts/segoeui.bin iso/boot/fonts/segoeui.bin
echo 'set timeout=0' >> iso/boot/grub/grub.cfg
echo 'set default=0' >> iso/boot/grub/grub.cfg
# echo 'set gfxmode=1152x864x32' >> iso/boot/grub/grub.cfg
# echo 'set gfxpayload=keep' >> iso/boot/grub/grub.cfg
echo 'terminal_output gfxterm' >> iso/boot/grub/grub.cfg
echo '' >> iso/boot/grub/grub.cfg
echo 'menuentry "My Operating System" {' >> iso/boot/grub/grub.cfg
echo ' multiboot /boot/kernel.bin' >> iso/boot/grub/grub.cfg
# echo ' module /boot/fonts/segoeui.bin' >> iso/boot/grub/grub.cfg
echo ' boot' >> iso/boot/grub/grub.cfg
echo '}' >> iso/boot/grub/grub.cfg
grub-mkrescue --output=kernel.iso --modules="video gfxterm video_bochs video_cirrus" iso
rm -rf iso
prog:
make hdd
make runq
# -----------------------------------
# CODE QUALITY TOOLS
# Check style (Report Only)
check-style:
@echo "--- Checking Code Formatting ---"
@find . -name "*.cpp" -o -name "*.c" -o -name "*.h" | xargs clang-format --dry-run -Werror
@echo "Style check passed."
# Check Logic (Report Only)
check-bugs:
@echo "--- Static Analysis ---"
@cppcheck --enable=warning,performance,portability \
--suppress=missingIncludeSystem \
--inline-suppr \
--quiet \
.
# Check Headers (Report Only)
check-headers:
@./check_headers.sh
# Check EOF (Report Only)
check-eof:
@./check_eof.sh
# Master Check
check: check-style check-bugs check-eof check-headers
# Auto-Fix-Style
fix-style:
@echo "--- Applying Auto-Formatting ---"
@find . -name "*.cpp" -o -name "*.c" -o -name "*.h" | xargs clang-format -i -style=file
@echo "Code formatted."