-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
64 lines (55 loc) · 1.38 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
ASM=nasm
CC=gcc
BUILD_DIR=build
TOOLS_DIR=tools
.PHNONY: all floppy_image kernel bootloader clean always run debug tools_fat
all: floppy_image tools_fat
#
# Floppy Image
#
floppy_image: $(BUILD_DIR)\main_floppy.img
$(BUILD_DIR)\main_floppy.img: bootloader kernel
wsl dd if=/dev/zero of=$(BUILD_DIR)/main_floppy.img bs=512 count=2880
wsl mkfs.fat -F 12 -n "MyOS" $(BUILD_DIR)/main_floppy.img
wsl dd if=$(BUILD_DIR)/bootloader.bin of=$(BUILD_DIR)/main_floppy.img conv=notrunc
wsl mcopy -i $(BUILD_DIR)/main_floppy.img $(BUILD_DIR)/kernel.bin "::kernel.bin"
wsl mcopy -i $(BUILD_DIR)/main_floppy.img test.txt "::test.txt"
#
# Bootloader
#
bootloader: $(BUILD_DIR)\bootloader.bin
$(BUILD_DIR)\bootloader.bin: always
$(ASM) Bootsektor\bootloader.asm -f bin -o $(BUILD_DIR)\bootloader.bin
#
# Kernel
#
kernel: $(BUILD_DIR)\kernel.bin
$(BUILD_DIR)\kernel.bin: always
$(ASM) Kernel\main.asm -f bin -o $(BUILD_DIR)\kernel.bin
#
# Tools FAT
#
tools_fat: $(BUILD_DIR)\tools\fat.exe
$(BUILD_DIR)\tools\fat.exe: always $(TOOLS_DIR)\fat\fat.c
if not exist $(BUILD_DIR)\tools mkdir $(BUILD_DIR)\tools
$(CC) -g -o $(BUILD_DIR)\tools\fat.exe tools\fat\fat.c
#
# Always
#
always:
if not exist $(BUILD_DIR) mkdir $(BUILD_DIR)
#
# Clean
#
clean:
rd /s /q $(BUILD_DIR)
#
# Run
#
run: floppy_image
qemu-system-i386 -fda $(BUILD_DIR)/main_floppy.img
#
# Debug
#
debug: floppy_image
bochsdbg -f bochs_config -q