-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
52 lines (44 loc) · 1.03 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
RAM=1G
QEMU=qemu-system-i386 -m $(RAM)
KERNEL=-kernel mel.elf
CCFLAGS= -g -c -w -m32 -fno-stack-protector -fno-pie -masm=intel -O0 -I include
LINKER=linker.ld
LDFLAGS= -z noexecstack -m elf_i386 -T $(LINKER)
ASFLAGS= --32
SRC_BOOT = boot/boot.s
SRC_C = $(shell find -name "*.c")
SRC_S = $(shell find -name "*.s" -not -name "boot.s")
OBJ_BOOT = bin/boot.elf
OBJ_C = $(SRC_C:%.c=bin/%.elf)
OBJ_S = $(SRC_S:%.s=bin/%_s.elf)
OBJS = $(OBJ_BOOT) $(OBJ_C) $(OBJ_S)
mel.elf : dirs $(OBJS) $(LINKER)
@ld $(LDFLAGS) $(OBJS) -o mel.elf
$(OBJ_BOOT) : $(SRC_BOOT)
@as --32 $(SRC_BOOT) -o $(OBJ_BOOT)
dirs :
@mkdir -p $(dir $(OBJS))
bin/%.elf: %.c
@gcc $(CCFLAGS) $< -o $@
bin/%_s.elf : %.s
@as $(ASFLAGS) $< -o $@
clean:
@rm -rf bin
@rm *.elf
run:
$(QEMU) $(KERNEL)
kvm:
$(QEMU) --enable-kvm $(KERNEL)
debug:
$(QEMU) $(KERNEL) -d in_asm
cpu:
$(QEMU) $(KERNEL) -d cpu
int:
$(QEMU) $(KERNEL) -d int
gdb:
$(QEMU) -s -S $(KERNEL)
mel.iso : mel.elf
cp mel.elf iso/boot/mel.elf
strip iso/boot/mel.elf
grub-mkrescue -o mel.iso iso
rm iso/boot/mel.elf