forked from gbowne1/8088-OS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
54 lines (41 loc) · 1.34 KB
/
Makefile
File metadata and controls
54 lines (41 loc) · 1.34 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
48
49
50
51
52
53
54
# Emulator settings: ISA-only machine, 1MB real-mode memory, floppy boot
QEMU = qemu-system-i386
QEMUFLAGS = -M isapc -m 1M -cpu 486 \
-drive file=$(FLOPPY_IMG),format=raw,if=floppy \
-boot a
# Directories
BOOTLOADER_DIR = bootloader
KERNEL_DIR = kernel
USER_DIR = user
BUILD_DIR = build
# Output files
BOOTLOADER_BIN = $(BUILD_DIR)/boot.bin
KERNEL_BIN = $(BUILD_DIR)/kernel.bin
SHELL_BIN = $(BUILD_DIR)/shell.bin
FLOPPY_IMG = $(BUILD_DIR)/floppy.img
# Tools
ASM = nasm
ASMFLAGS = -f bin
# Targets
all: $(FLOPPY_IMG)
# Ensure build directory exists
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
$(FLOPPY_IMG): $(BOOTLOADER_BIN) $(KERNEL_BIN) $(SHELL_BIN) | $(BUILD_DIR)
dd if=/dev/zero of=$(FLOPPY_IMG) bs=512 count=2880
dd if=$(BOOTLOADER_BIN) of=$(FLOPPY_IMG) bs=512 seek=0 conv=notrunc
dd if=$(KERNEL_BIN) of=$(FLOPPY_IMG) bs=512 seek=1 conv=notrunc
dd if=$(SHELL_BIN) of=$(FLOPPY_IMG) bs=512 seek=4 conv=notrunc
$(BOOTLOADER_BIN): $(BOOTLOADER_DIR)/boot.asm | $(BUILD_DIR)
$(ASM) $(ASMFLAGS) $< -o $@
$(KERNEL_BIN): $(KERNEL_DIR)/kernel.asm | $(BUILD_DIR)
$(ASM) $(ASMFLAGS) $< -o $@
$(SHELL_BIN): $(USER_DIR)/shell.asm | $(BUILD_DIR)
$(ASM) $(ASMFLAGS) $< -o $@
run: all
$(QEMU) $(QEMUFLAGS)
run-debug: all
$(QEMU) $(QEMUFLAGS) -S -s
clean:
rm -rf $(BUILD_DIR)
.PHONY: all run run-debug clean