-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
68 lines (60 loc) · 1.91 KB
/
Makefile
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
objects = bin/loader.o \
bin/kernel.o \
bin/gdt.o \
bin/multitasking/task.o \
bin/multitasking/task_manager.o \
bin/resources/dynamic_memory_management.o \
bin/drivers/drivers.o \
bin/drivers/video_graphics_array.o \
bin/libgui/colors.o \
bin/libgui/widget.o \
bin/libgui/composite_widget.o \
bin/libgui/desktop.o \
bin/libgui/window.o \
bin/libgui/graphics_context.o \
bin/events/keyboard_event_handler.o \
bin/events/mouse_event_handler.o \
bin/drivers/keyboard.o \
bin/drivers/mouse.o \
bin/hardware_interaction/port.o \
bin/hardware_interaction/interrupt_stubs.o \
bin/hardware_interaction/interrupt.o \
bin/resources/system_calls.o \
bin/hardware_interaction/pci.o \
bin/core/streamio.o \
bin/core/base_string.o \
bin/libc/cmath.o \
bin/libc/assert.o
bin/%.o: src/%.cpp
mkdir -p $(@D)
g++ -m32 -Iinclude -fno-use-cxa-atexit -nostdlib -fno-builtin -fno-rtti -fno-exceptions -fno-leading-underscore -fno-stack-protector -fpermissive -o $@ -c $< -g
bin/%.o: src/%.asm
mkdir -p $(@D)
nasm -f elf32 -o $@ $<
bin/%.o: src/%.s
mkdir -p $(@D)
as --32 -o $@ $<
run: kernel.iso
(killall VirtualBox && sleep 1) || true
VirtualBox --startVM 'Minor Project' &
kernel.bin: linker.ld ${objects}
ld -m elf_i386 -T $< -o $@ ${objects}
qemu: kernel.bin
qemu-system-x86_64 -kernel $<
kernel.iso: kernel.bin
mkdir iso
mkdir iso/boot
mkdir iso/boot/grub
cp $< iso/boot
echo 'set timeout=0' >> iso/boot/grub/grub.cfg
echo 'set default=0' >> 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 ' boot' >> iso/boot/grub/grub.cfg
echo '}' >> iso/boot/grub/grub.cfg
grub-mkrescue --output=$@ iso
rm -rf iso
.PHONY: clean
clean:
rm -rf bin kernel.bin kernel.iso