-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
76 lines (63 loc) · 2.58 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
69
70
71
72
73
74
75
76
#Global Variables
GPP_PARAMETERS = -m64 -I include -fno-use-cxa-atexit -nostdlib -fno-builtin -fno-rtti -fno-exceptions -fno-leading-underscore
AS_PARAMETERS = --32
LD_PARAMETERS = -n
#Other Variables $(BUILD_PATH)/kernel.o
BUILD_PATH = build
KRNL_DEPENDENCIES = $(BUILD_PATH)/osloader/osloader.o \
$(BUILD_PATH)/osloader/os64loader.o \
$(BUILD_PATH)/tools/kernelrtl/printf.o \
$(BUILD_PATH)/tools/kernelrtl/strings.o \
$(BUILD_PATH)/drivers/hal/pic8259.o \
$(BUILD_PATH)/drivers/hal/apic.o \
$(BUILD_PATH)/drivers/hal/virtkbd.o \
$(BUILD_PATH)/drivers/ps2/keyboard.o \
$(BUILD_PATH)/drivers/acpi/acpidef.o \
$(BUILD_PATH)/drivers/acpi/acpipvdr.o \
$(BUILD_PATH)/drivers/video/vga.o \
$(BUILD_PATH)/kernel/assert/logging.o \
$(BUILD_PATH)/kernel/mem/bootmem.o \
$(BUILD_PATH)/kernel/mem/physicalmm.o \
$(BUILD_PATH)/kernel/mem/virtualmm.o \
$(BUILD_PATH)/kernel/multiboot/mbpvdr.o \
$(BUILD_PATH)/kernel/interrupts/isrdef.o \
$(BUILD_PATH)/kernel/interrupts/intrdef.o \
$(BUILD_PATH)/kernel/tacoskrnl.o
#Define PHONY
.PHONY = run run-debug clean
#Compile *.cpp to *.o
$(BUILD_PATH)/%.o: %.cpp
mkdir -p $(dir $@)
g++ $(GPP_PARAMETERS) -o $@ -c $<
#Compile *.asm to *.o
$(BUILD_PATH)/%.o: %.asm
mkdir -p $(dir $@)
nasm -f elf64 $< -o $@
#Kernel.bin depends on linker.ld, defined files
$(BUILD_PATH)/kernel.bin: linker.ld $(KRNL_DEPENDENCIES)
mkdir -p $(dir $@)
ld $(LD_PARAMETERS) -T $< -o $@ $(KRNL_DEPENDENCIES)
$(BUILD_PATH)/tacos.iso: $(BUILD_PATH)/kernel.bin
# Copy kernel.bin, Create GRUB Config, Folder needs to be named "boot"
mkdir -p $(BUILD_PATH)/iso_build/boot/grub
cp $< $(BUILD_PATH)/iso_build/boot
echo 'set timeout=5' >> $(BUILD_PATH)/iso_build/boot/grub/grub.cfg
echo '' >> $(BUILD_PATH)/iso_build/boot/grub.cfg
echo 'menuentry "tacOS 0.1" {' >> $(BUILD_PATH)/iso_build/boot/grub/grub.cfg
echo ' multiboot2 /boot/kernel.bin' >> $(BUILD_PATH)/iso_build/boot/grub/grub.cfg
echo ' boot' >> $(BUILD_PATH)/iso_build/boot/grub/grub.cfg
echo '}' >> $(BUILD_PATH)/iso_build/boot/grub/grub.cfg
# Create ISO image
grub-mkrescue --output=$@ $(BUILD_PATH)/iso_build
rm -rf $(BUILD_PATH)/iso_build/
run: $(BUILD_PATH)/tacos.iso
qemu-system-x86_64 -cdrom $(BUILD_PATH)/tacos.iso
run-uefi: $(BUILD_PATH)/tacos.iso
qemu-system-x86_64 -bios /usr/share/ovmf/OVMF.fd -cdrom $(BUILD_PATH)/tacos.iso
run-vbox: $(BUILD_PATH)/tacos.iso
virtualboxvm --startvm tacOS --dbg
run-debug: $(BUILD_PATH)/tacos.iso
qemu-system-x86_64 -s -S -cdrom $(BUILD_PATH)/tacos.iso
echo "-d int -no-reboot -no-shutdown"
clean:
rm -rf $(BUILD_PATH)/