forked from ReKernel/ReKernel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
executable file
·44 lines (34 loc) · 1.23 KB
/
Makefile
File metadata and controls
executable file
·44 lines (34 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
# Makefile
CC = gcc
CFLAGS = -m32 -ffreestanding -fno-pic -fno-stack-protector -nostdlib \
-O2 -Wall -Wextra -Wno-unused-parameter
AS = nasm
ASFLAGS = -f elf32
LD = ld
LDFLAGS = -m elf_i386 -T linker.ld
C_SRCS = kernel.c vga.c pic.c idt.c keyboard.c memory.c gdt.c
ASM_SRCS = boot.asm isr.asm gdt.asm
C_OBJS = $(C_SRCS:.c=.o)
ASM_OBJS = $(ASM_SRCS:.asm=_asm.o) # _asm suffix avoids collision with .c objects
OBJS = $(ASM_OBJS) $(C_OBJS)
# ── Targets ──────────────────────────────────────────────────────────────────
all: kernel.bin
%_asm.o: %.asm
$(AS) $(ASFLAGS) $< -o $@
%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
kernel.bin: $(OBJS) linker.ld
$(LD) $(LDFLAGS) -o $@ $(OBJS)
@echo "Built kernel.bin"
iso: kernel.bin
mkdir -p iso/boot/grub
cp kernel.bin iso/boot/
printf 'set timeout=0\nset default=0\nmenuentry "MyKernel" {\n multiboot /boot/kernel.bin\n}\n' \
> iso/boot/grub/grub.cfg
grub-mkrescue -o kernel.iso iso/ 2>/dev/null
@echo "Created kernel.iso"
run: iso
qemu-system-i386 -cdrom kernel.iso
clean:
rm -rf *.o *.bin *.iso iso/
.PHONY: all iso run clean