-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
61 lines (47 loc) · 1.23 KB
/
Makefile
File metadata and controls
61 lines (47 loc) · 1.23 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
55
56
57
58
59
60
61
# Tools
AS = nasm
CC = i686-elf-gcc
LD = i686-elf-ld
# Folders
BUILD = build
ISO = iso
# Kernel
KERNEL = $(BUILD)/OpenKernel.bin
ISOFILE = OpenKernel_1.0.iso
# Compile Tools
CFLAGS = -m32 -ffreestanding -O2 -Wall -Wextra -ISystemLib/Std -IDrivers/Vga
LDFLAGS = -m elf_i386 -T link.ld
# Source Files
ASM_SRC = Boot/boot.asm Boot/Mboot_desc/mboot.asm
C_SRC = main.c Drivers/Vga/vga.c SystemLib/SysCalls/basic_syscall.c SystemLib/TimeMng/time.c Kernel/KernelServices/SystemManagement/sysmng.c Kernel/KernelServices/Shell/shell.c SystemLib/Std/std.c Drivers/Keyboard/keyboard.c
# Obj
ASM_OBJ = $(ASM_SRC:%.asm=$(BUILD)/%.o)
C_OBJ = $(C_SRC:%.c=$(BUILD)/%.o)
OBJS = $(ASM_OBJ) $(C_OBJ)
all: $(KERNEL)
# Build Folders
$(BUILD):
mkdir -p $(BUILD)
# Compile ASM
$(BUILD)/%.o: %.asm
@mkdir -p $(dir $@)
$(AS) -f elf32 $< -o $@
# Compile C
$(BUILD)/%.o: %.c
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) -c $< -o $@
# Kernel link
$(KERNEL): $(OBJS)
$(LD) $(LDFLAGS) $(OBJS) -o $(KERNEL)
# ISO Folder Structure
iso: $(KERNEL)
mkdir -p $(ISO)/boot/grub
cp $(KERNEL) $(ISO)/boot/
cp Boot/grub/grub.cfg $(ISO)/boot/grub/
grub-mkrescue -o $(ISOFILE) $(ISO)
# Run
run: iso
qemu-system-i386 -cdrom $(ISOFILE)
# Clean
clean:
rm -rf $(BUILD) $(ISO) $(ISOFILE)