-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
50 lines (39 loc) · 1.46 KB
/
Makefile
File metadata and controls
50 lines (39 loc) · 1.46 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
# MoiMoiOS Makefile
# ----------------------------------------------------------
# Toolchain Configuration
# ----------------------------------------------------------
CC = gcc
AS = nasm
LD = ld
# Compiler and Linker Flags
CFLAGS = -Wall -Wextra -std=c11 -ffreestanding -O2 -Ikernel/core -Ikernel/services
LDFLAGS = -T kernel/boot/linker.ld -nostdlib
ASFLAGS = -f elf64
# ----------------------------------------------------------
# Source Files
# ----------------------------------------------------------
C_SOURCES = $(wildcard kernel/core/*.c) $(wildcard kernel/services/chest/*.c) $(wildcard kernel/services/io/*.c) $(wildcard kernel/services/notification/*.c) kernel/core/klog.c kernel/core/panic.c
ASM_SOURCES = $(wildcard kernel/boot/*.asm)
# Object Files
C_OBJECTS = $(C_SOURCES:.c=.o)
ASM_OBJECTS = $(ASM_SOURCES:.asm=.o)
# ----------------------------------------------------------
# Build Targets
# ----------------------------------------------------------
all: moimoios.bin
moimoios.bin: $(ASM_OBJECTS) $(C_OBJECTS)
$(LD) $(LDFLAGS) -o $@ $^
%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
%.o: %.asm
$(AS) $(ASFLAGS) $< -o $@
clean:
rm -f *.bin *.o $(C_OBJECTS) $(ASM_OBJECTS)
# ----------------------------------------------------------
# ISO Generation (for emulation)
# ----------------------------------------------------------
iso: moimoios.bin
mkdir -p iso/boot/grub
cp moimoios.bin iso/boot/
cp kernel/boot/grub.cfg iso/boot/grub/
grub-mkrescue -o moimoios.iso iso