-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
43 lines (33 loc) · 864 Bytes
/
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
CC = i686-elf-gcc.exe
AS = i686-elf-gcc.exe
LD = i686-elf-gcc.exe
AS_FLAGS = -std=gnu99 -ffreestanding -g -c
LD_FLAGS = -ffreestanding -nostdlib -g -Tsrc/linker.ld -lgcc
CC_FLAGS = -std=gnu99 -ffreestanding -g -c
SOURCE_C := $(wildcard src/*.c) $(wildcard src/*/*.c)
SOURCE_ASM := $(wildcard src/*.s) $(wildcard src/*/*.s)
OBJS := $(SOURCE_C:.c=.o) $(SOURCE_ASM:.s=.o)
KERNEL_BIN := bin/kernel.elf
VM = qemu-system-i386.exe
VM_FLAGS = -vga virtio
ifeq ($(OS),Windows_NT)
SHELL=cmd
RM = del /S
DEL_OBJS = *.o *.elf *.out
else
RM = rm -f
DEL_OBJS = $(OBJS) $(KERNEL_BIN)
endif
all: $(KERNEL_BIN)
.PHONY: clean run rebuild
clean:
$(RM) $(DEL_OBJS)
$(KERNEL_BIN): $(OBJS)
$(LD) $^ $(LD_FLAGS) -o $@
%.o: %.c
$(CC) $< $(CC_FLAGS) -o $@
%.o: %.s
$(AS) $< $(AS_FLAGS) -o $@
run: all
$(VM) $(VM_FLAGS) -kernel $(KERNEL_BIN)
rebuild: clean $(KERNEL_BIN)