-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
46 lines (34 loc) · 837 Bytes
/
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
CC = gcc
AS = nasm
LD = ld
VM = qemu-system-i386
CFLAGS = -m32 -ffreestanding -nostdlib -Iinclude
ASFLAGS = -felf32
LDFLAGS = -m elf_i386 -T linker.ld
VMFLAGS = -cdrom trace.iso -serial mon:stdio
SRC = $(shell find kernel -name "*.c")
OBJ = $(SRC:.c=.o)
all: kernel.bin
boot.o: boot.s
$(AS) $(ASFLAGS) -o boot.o boot.s
gdt.o: gdt.s
$(AS) $(ASFLAGS) -o gdt.o gdt.s
idt.o: idt.s
$(AS) $(ASFLAGS) -o idt.o idt.s
%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $<
kernel.bin: boot.o gdt.o idt.o $(OBJ)
$(LD) $(LDFLAGS) -o kernel.bin boot.o gdt.o idt.o $(OBJ)
mkdir -p iso/boot
cp kernel.bin iso/boot/kernel.bin
iso: kernel.bin
mkdir -p iso/boot/grub
cp grub.cfg iso/boot/grub/grub.cfg
grub-mkrescue -o trace.iso iso/
clean:
rm -f *.o $(OBJ) kernel.bin
rm -rf iso
rm trace.iso
test-qemu:
$(VM) $(VMFLAGS)
full: iso test-qemu clean