-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
64 lines (48 loc) · 1.71 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
#
# SaturnOS makefile
#
AS=nasm
ASFLAGS=-f elf32
CC=gcc
CFLAGS=-ffreestanding -fno-stack-protector -fno-pie -m32 -O0 -c -I./include
LDFLAGS=-melf_i386
KERNOBJ=bootloader/loader.o kernel/kernel.o sys/io.o sys/mutex.o sys/display/display.o sys/display/consolemode.o arch/x86/gdt.o arch/x86/interrupt_trampoline.o arch/x86/idt.o arch/x86/interrupt.o arch/x86/pic.o arch/x86/pit.o sys/keyboard/keyboard.o
all: SaturnOS.iso
run: SaturnOS.iso
virtualbox --startvm "SaturnOS"
SaturnOS.iso: SaturnOS.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 "Saturn" {' >> iso/boot/grub/grub.cfg
echo 'multiboot /boot/SaturnOS.bin' >> iso/boot/grub/grub.cfg
echo 'boot' >> iso/boot/grub/grub.cfg
echo '}' >> iso/boot/grub/grub.cfg
grub-mkrescue --output=$@ iso
SaturnOS.bin: linker.ld $(KERNOBJ)
ld $(LDFLAGS) -T $< -o $@ $(KERNOBJ)
bootloader/loader.o: bootloader/loader.asm
$(AS) $(ASFLAGS) bootloader/loader.asm -o bootloader/loader.o
kernel/kernel.bin: $(KERNOBJ)
ld -o kernel/kernel.bin -Ttext 0x7e00 $(KERNOBJ) -m elf_i386 --oformat binary
kernel/%.o: kernel/%.c
$(CC) $(CFLAGS) $< -o $@
sys/keyboard/%.o: sys/keyboard/%.c
$(CC) $(CFLAGS) $< -o $@
sys/display/%.o: sys/display/%.c
$(CC) $(CFLAGS) $< -o $@
arch/x86/interrupt_trampoline.o: arch/x86/interrupt_trampoline.asm
$(AS) $(ASFLAGS) arch/x86/interrupt_trampoline.asm -o arch/x86/interrupt_trampoline.o
arch/x86/%.o: arch/x86/%.c
$(CC) $(CFLAGS) $< -o $@
sys/%.o: sys/%.c
$(CC) $(CFLAGS) $< -o $@
clean:
find . -name *.o -exec rm -rf '{}' \;
find . -name *.bin -exec rm -rf '{}' \;
rm -rf iso
rm *.iso