aboutsummaryrefslogtreecommitdiff
path: root/devkit/Makefile
blob: 2a8d74416ca68f28e3e9d9c24c5595adcc065058 (plain)
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
SOURCES = $(wildcard *.c)
OBJECTS = $(patsubst %.c,obj/%.o,$(SOURCES))
TARGETS = $(patsubst %.c,bin/%,$(SOURCES))

CC = riscv64-unknown-elf-gcc

COMMONFLAGS += -Wall
# COMMONFLAGS += -Werror

COMMONFLAGS += -O3

COMMONFLAGS += -static
# Use the 32-bit variant of RISC-V, with no floating-point support.
COMMONFLAGS += -m32 -msoft-float -march=RV32I

# Add debugging symbols
COMMONFLAGS += -g3

# Use C11.
COMMONFLAGS += -std=c11

# Link options: disable system libraries, and use the program
# layout in test.x.
LINKFLAGS = $(FLAGS) -nostartfiles -nodefaultlibs
LINKFLAGS += -Wl,-T,cacheracer.x

# Merge the common flags and the per-file FLAGS_xxx settings.
FLAGS = $(COMMONFLAGS) $(FLAGS_$(basename $(notdir $@)))

all: $(TARGETS)

$(TARGETS): bin/%: obj/%.o cacheracer.h
	$(CC) $(LINKFLAGS) $< -o $@

$(OBJECTS): obj/%.o: %.c
	$(CC) $(FLAGS) -c $< -o $@

clean:
	rm -f obj/*.o bin/*