-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
48 lines (31 loc) · 1.2 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
CROSS_COMPILE = riscv64-linux-gnu-
CC = $(CROSS_COMPILE)gcc
AS = $(CROSS_COMPILE)as
LD = $(CROSS_COMPILE)ld
OBJCOPY = $(CROSS_COMPILE)objcopy
CFLAGS = -march=rv64g -mabi=lp64 -static -mcmodel=medany \
-fvisibility=hidden -nostdlib -nostartfiles -g -O0
QEMU = qemu-system-riscv64
all: kernel.elf
boot.o: src/boot.S
$(CC) $(CFLAGS) -c src/boot.S -o boot.o
kernel.o: src/kernel.c
$(CC) $(CFLAGS) -c src/kernel.c -o kernel.o
userland.o: src/userland.c
$(CC) $(CFLAGS) -c src/userland.c -o userland.o
trap.o: src/trap.c
$(CC) $(CFLAGS) -c src/trap.c -o trap.o
debug_uart.o: src/debug_uart.c
$(CC) $(CFLAGS) -c src/debug_uart.c -o debug_uart.o
device_tree.o: src/device_tree.c
$(CC) $(CFLAGS) -c src/device_tree.c -o device_tree.o
util.o: src/util.c
$(CC) $(CFLAGS) -c src/util.c -o util.o
kernel.elf: boot.o userland.o trap.o debug_uart.o kernel.o device_tree.o util.o linker.ld
$(LD) -T linker.ld boot.o userland.o trap.o debug_uart.o device_tree.o util.o kernel.o -o kernel.elf
run: kernel.elf
$(QEMU) -machine sifive_u,firmware=/usr/share/opensbi/lp64/generic/firmware/fw_dynamic.bin -cpu rv64 -smp 4 -m 512M \
-nographic -kernel kernel.elf \
clean:
rm -f *.o kernel.elf
.PHONY: clean run