-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
32 lines (25 loc) · 900 Bytes
/
Makefile
File metadata and controls
32 lines (25 loc) · 900 Bytes
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
BUILD_DIR = build
BOOTLOADER = $(BUILD_DIR)/bootloader.bin
KERNEL = $(BUILD_DIR)/kernel.bin
DISK_IMG = $(BUILD_DIR)/disk.img
.PHONY: all clean run
all: $(DISK_IMG)
$(DISK_IMG): $(BOOTLOADER) $(KERNEL)
@echo "Creating disk image..."
mkdir -p $(BUILD_DIR)
dd if=/dev/zero of=$@ bs=512 count=2880 2>/dev/null
mkfs.fat -F 12 -n "MYOS" $@ >/dev/null
dd if=$(BOOTLOADER) of=$@ conv=notrunc 2>/dev/null
dd if=$(KERNEL) of=$@ bs=512 seek=33 conv=notrunc 2>/dev/null
$(BOOTLOADER): src/bootloader/boot.asm src/bootloader/disk.asm src/bootloader/print.asm
@echo "Building bootloader..."
mkdir -p $(BUILD_DIR)
nasm -f bin -Isrc/bootloader/ $< -o $@
$(KERNEL): src/kernel/kernel.asm
@echo "Building kernel..."
mkdir -p $(BUILD_DIR)
nasm -f bin -Isrc/bootloader/ $< -o $@ # Critical fix here
run: $(DISK_IMG)
qemu-system-x86_64 -drive file=$(DISK_IMG),format=raw
clean:
rm -rf $(BUILD_DIR)/*