-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
133 lines (114 loc) · 3.51 KB
/
Makefile
File metadata and controls
133 lines (114 loc) · 3.51 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# ARM64 bare-metal toolchain
AS = aarch64-none-elf-as
LD = aarch64-none-elf-ld
OBJCOPY = aarch64-none-elf-objcopy
# Output files
KERNEL_ELF = kernel.elf
KERNEL_BIN = kernel.bin
TEST_ELF = kernel_test.elf
BENCH_ELF = kernel_bench.elf
# Common source files (shared between server and tests)
COMMON_SRCS = src/drivers/uart.s \
src/drivers/virtio.s \
src/drivers/timer.s \
src/net/ethernet.s \
src/net/arp.s \
src/net/ipv4.s \
src/net/tcp.s \
src/net/http.s
# Memory and database sources
MEM_DB_SRCS = src/mem/slab.s \
src/db/db.s
# SlowAPI framework sources
SLOWAPI_SRCS = src/slowapi/request.s \
src/slowapi/response.s \
src/slowapi/router.s \
src/slowapi/query.s \
src/slowapi/json.s \
src/slowapi/string.s \
src/slowapi/slowapi.s \
src/app.s
# Server sources
SERVER_SRCS = src/boot.s $(COMMON_SRCS) $(MEM_DB_SRCS) $(SLOWAPI_SRCS)
SERVER_OBJS = $(SERVER_SRCS:.s=.o)
# Test sources
TEST_SRCS = src/test/test_main.s \
src/test/test_harness.s \
src/test/test_virtio.s \
src/test/test_ethernet.s \
src/test/test_arp.s \
src/test/test_ipv4.s \
src/test/test_tcp.s \
src/test/test_http.s \
src/test/test_slowapi.s \
src/test/test_slab.s \
src/test/test_db.s \
src/test/test_query.s \
src/test/test_json.s \
$(COMMON_SRCS) \
$(MEM_DB_SRCS) \
src/slowapi/request.s \
src/slowapi/response.s \
src/slowapi/router.s \
src/slowapi/query.s \
src/slowapi/json.s \
src/slowapi/string.s \
src/slowapi/slowapi.s \
src/app.s
TEST_OBJS = $(TEST_SRCS:.s=.o)
# Benchmark sources
BENCH_SRCS = src/bench/bench_main.s \
src/bench/bench_harness.s \
src/bench/bench_slab.s \
src/bench/bench_db.s \
src/bench/bench_string.s \
src/bench/bench_json.s \
src/bench/bench_request.s \
$(COMMON_SRCS) \
$(MEM_DB_SRCS) \
$(SLOWAPI_SRCS)
BENCH_OBJS = $(BENCH_SRCS:.s=.o)
# Flags
ASFLAGS = -g
LDFLAGS = -T linker.ld -nostdlib
.PHONY: all clean run test bench
all: $(KERNEL_ELF)
$(KERNEL_ELF): $(SERVER_OBJS) linker.ld
$(LD) $(LDFLAGS) -o $@ $(SERVER_OBJS)
$(TEST_ELF): $(TEST_OBJS) linker.ld
$(LD) $(LDFLAGS) -o $@ $(TEST_OBJS)
$(BENCH_ELF): $(BENCH_OBJS) linker.ld
$(LD) $(LDFLAGS) -o $@ $(BENCH_OBJS)
$(KERNEL_BIN): $(KERNEL_ELF)
$(OBJCOPY) -O binary $< $@
%.o: %.s
$(AS) $(ASFLAGS) -o $@ $<
clean:
rm -f $(SERVER_OBJS) $(TEST_OBJS) $(BENCH_OBJS) $(KERNEL_ELF) $(KERNEL_BIN) $(TEST_ELF) $(BENCH_ELF)
run: $(KERNEL_ELF)
qemu-system-aarch64 \
-machine virt \
-cpu cortex-a72 \
-nographic \
-global virtio-mmio.force-legacy=true \
-kernel $(KERNEL_ELF) \
-device virtio-net-device,netdev=net0 \
-netdev user,id=net0,hostfwd=tcp::8888-:80
test: $(TEST_ELF)
qemu-system-aarch64 \
-machine virt \
-cpu cortex-a72 \
-nographic \
-global virtio-mmio.force-legacy=true \
-kernel $(TEST_ELF) \
-device virtio-net-device,netdev=net0 \
-netdev user,id=net0
bench: $(BENCH_ELF)
qemu-system-aarch64 \
-machine virt \
-cpu cortex-a72 \
-nographic \
-global virtio-mmio.force-legacy=true \
-kernel $(BENCH_ELF) \
-device virtio-net-device,netdev=net0 \
-netdev user,id=net0