-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
81 lines (62 loc) · 1.75 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
K=kernel
U=user
OBJS = \
$K/entry.o \
$K/start.o \
$K/vga.o \
$K/pci.o \
$K/uart.o \
$K/main.o \
ifndef TOOLPREFIX
TOOLPREFIX := $(shell if riscv64-unknown-elf-objdump -i 2>&1 | grep 'elf64-big' >/dev/null 2>&1; \
then echo 'riscv64-unknown-elf-'; \
elif riscv64-linux-gnu-objdump -i 2>&1 | grep 'elf64-big' >/dev/null 2>&1; \
then echo 'riscv64-linux-gnu-'; \
elif riscv64-unknown-linux-gnu-objdump -i 2>&1 | grep 'elf64-big' >/dev/null 2>&1; \
then echo 'riscv64-unknown-linux-gnu-'; \
else echo "***" 1>&2; \
echo "*** Error: Couldn't find a riscv64 version of GCC/binutils." 1>&2; \
echo "*** To turn off this error, run 'gmake TOOLPREFIX= ...'." 1>&2; \
echo "***" 1>&2; exit 1; fi)
endif
QEMU = qemu-system-riscv64
CC = $(TOOLPREFIX)gcc
AS = $(TOOLPREFIX)as
LD = $(TOOLPREFIX)ld
CFLAGS = -Wall
CFLAGS += -O0
CFLAGS += -ggdb
CFLAGS += -mcmodel=medany
RUNFLAGS = -machine virt
RUNFLAGS += -bios none
RUNFLAGS += -gdb tcp::1234
RUNFLAGS += -kernel kernel/kernel
RUNFLAGS += -m 128M
# RUNFLAGS += -nographic
RUNFLAGS += -device VGA
RUNFLAGS += -vga cirrus
RUNFLAGS += -monitor stdio
RUNFLAGS += -smp 1
DEBUGFLAGS = -machine virt
DEBUGFLAGS += -bios none
DEBUGFLAGS += -gdb tcp::1234
DEBUGFLAGS += -kernel kernel/kernel
DEBUGFLAGS += -m 128M
# DEBUGFLAGS += -nographic
DEBUGFLAGS += -device VGA
DEBUGFLAGS += -vga cirrus
DEBUGFLAGS += -monitor stdio
DEBUGFLAGS += -smp 1
DEBUGFLAGS += -S
RUN = qemu-system-riscv64 $(RUNFLAGS)
DEBUG = qemu-system-riscv64 $(DEBUGFLAGS)
# qemu-system-riscv64 -machine virt -bios none -gdb tcp::1234 -kernel kernel -m 128M -nographic
$K/kernel: $(OBJS) $K/kernel.ld
$(LD) $(LDFLAGS) -T $K/kernel.ld -o $K/kernel $(OBJS)
compile: $K/kernel
run: $K/kernel
$(RUN)
debug: $K/kernel
$(DEBUG)
clean:
rm */*.asm */*.sym */*.o