-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
47 lines (37 loc) · 793 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
44
45
46
47
CC = riscv64-unknown-elf-gcc
LD = riscv64-unknown-elf-ld
QEMU = qemu-system-riscv64
GDBPORT = 26000
CFLAGS = -std=c17 -Wall -Werror -nostdlib -fno-builtin -mcmodel=medany
QEMUFLAGS = -machine virt -nographic -smp 1 -bios none
QEMUGDB = -S -gdb tcp::$(GDBPORT)
KERNEL = kernel.elf
OBJS = \
entry.o \
start.o \
uart.o \
context_switch.o \
print.o \
timer.o \
task.o \
user_tasks.o \
trap_vector.o \
trap.o \
error.o
.PHONY: kernel
kernel: $(KERNEL)
$(KERNEL): $(OBJS)
$(LD) -T kernel.ld -o $@ $^
%.o: %.c
$(CC) $(CFLAGS) -c -g -o $@ $^
%.o: %.S
$(CC) $(CFLAGS) -c -g -o $@ $^
.PHONY: qemu
qemu: $(KERNEL)
$(QEMU) $(QEMUFLAGS) -kernel $(KERNEL)
.PHONY: qemu-gdb
qemu-gdb: $(KERNEL)
$(QEMU) $(QEMUFLAGS) -kernel $(KERNEL) $(QEMUGDB)
.PHONY: clean
clean:
rm -f *.o *.elf