-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
48 lines (35 loc) · 1.04 KB
/
Makefile
File metadata and controls
48 lines (35 loc) · 1.04 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
BOOT_SRC = $(wildcard src/boot/*.s)
KERNEL_SRC = $(wildcard src/kernel/*.s)
BOOT_OBJ = $(subst src/,bin/,$(BOOT_SRC:.s=.o))
KERNEL_OBJ = $(subst src/,bin/,$(KERNEL_SRC:.s=.o))
AS_FLAGS = -c $(subst bin/,src/,$(@:.o=.s)) -o $@
BOOT_LD_FLAGS = $^ -o $@ -Ttext 0x7C00 --oformat=binary
KERNEL_LD_FLAGS = $^ -o $@ -T src/kernel/link.ld --oformat=binary
QEMU_FLAGS = -drive file=$<,index=0,if=floppy,format=raw -serial stdio
AS = as
LD = ld
QEMU = qemu-system-i386
BOOT = bin/boot/boot
KERNEL = bin/kernel/kernel
FLOPPY = floppy.img
run: $(FLOPPY)
$(QEMU) $(QEMU_FLAGS)
clean:
rm -rf $^ $(FLOPPY) bin/
$(FLOPPY): $(BOOT) $(KERNEL)
mkdir -p $(@D)
dd if=/dev/zero of=$@ bs=512 count=2880
dd if=bin/boot/boot of=$@ bs=512 count=1 conv=notrunc
dd if=bin/kernel/kernel of=$@ bs=512 seek=1 conv=notrunc
$(BOOT): $(BOOT_OBJ)
mkdir -p $(@D)
$(LD) $(BOOT_LD_FLAGS)
$(BOOT_OBJ): $(BOOT_SRC)
mkdir -p $(@D)
$(AS) $(AS_FLAGS)
$(KERNEL): $(KERNEL_OBJ)
mkdir -p $(@D)
$(LD) $(KERNEL_LD_FLAGS)
$(KERNEL_OBJ): $(KERNEL_SRC)
mkdir -p $(@D)
$(AS) $(AS_FLAGS)