Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
107 lines (83 loc) · 2.24 KB
/
Copy pathMakefile
File metadata and controls
107 lines (83 loc) · 2.24 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
# Planck — Linux x86-64, NASM, no libc.
# Apple Silicon: docker build --platform linux/amd64.
NASM ?= nasm
LD ?= ld
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
LD := x86_64-elf-ld
endif
NASMFLAGS ?= -f elf64 -g -F dwarf -I src/include/ -Wall
LDFLAGS ?= -static -nostdlib -z noexecstack
SRC_HOST = \
src/host/start.asm \
src/host/syscall.asm \
src/host/die.asm \
src/host/string.asm \
src/host/io.asm \
src/host/mem.asm \
src/host/hash.asm \
src/host/time.asm \
src/host/file.asm
SRC_CORE = \
src/core/cpu.asm \
src/core/bits.asm \
src/core/decode.asm \
src/core/trap.asm \
src/core/csr.asm \
src/core/exec.asm \
src/core/exec_alu.asm \
src/core/exec_mem.asm \
src/core/exec_br.asm \
src/core/exec_m.asm \
src/core/exec_sys.asm \
src/core/interp.asm
SRC_ASM = \
src/asm/lexer.asm \
src/asm/tables.asm \
src/asm/compile.asm
SRC_DIS = src/disasm/disasm.asm
SRC_CACHE = src/cache/cache.asm
SRC_PRED = src/predict/predict.asm
SRC_OOO = \
src/ooo/fu.asm \
src/ooo/pipeline.asm
SRC_STAT = src/stats/report.asm
SRC_MON = src/monitor/ecall.asm
SRC_TEST = \
tests/harness.asm \
tests/test_hash.asm \
tests/test_decode.asm \
tests/test_alu.asm \
tests/test_m.asm \
tests/test_mem.asm \
tests/test_branch.asm \
tests/test_asm.asm \
tests/test_cache.asm \
tests/test_programs.asm
SRCS = $(SRC_HOST) $(SRC_CORE) $(SRC_ASM) $(SRC_DIS) $(SRC_CACHE) \
$(SRC_PRED) $(SRC_OOO) $(SRC_STAT) $(SRC_MON) $(SRC_TEST)
OBJS = $(patsubst src/%.asm,obj/%.o,$(filter src/%,$(SRCS))) \
$(patsubst tests/%.asm,obj/tests/%.o,$(filter tests/%,$(SRCS)))
INCLUDES = $(wildcard src/include/*.inc)
.PHONY: all clean lines dirs test
all: dirs bin/planck
dirs:
@mkdir -p bin obj/host obj/core obj/asm obj/disasm obj/cache \
obj/predict obj/ooo obj/stats obj/monitor obj/tests
obj/%.o: src/%.asm $(INCLUDES)
@mkdir -p $(dir $@)
$(NASM) $(NASMFLAGS) -o $@ $<
obj/tests/%.o: tests/%.asm $(INCLUDES)
@mkdir -p $(dir $@)
$(NASM) $(NASMFLAGS) -o $@ $<
bin/planck: $(OBJS) | bin
$(LD) $(LDFLAGS) -o $@ $(OBJS)
bin:
@mkdir -p $@
test: all
./bin/planck test
clean:
rm -rf obj bin
lines:
@echo "NASM + guest sources:"
@find src tests programs -name '*.asm' -o -name '*.s' -o -name '*.inc' | sort | xargs wc -l