forked from racerxdl/riscv-emulator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
38 lines (29 loc) · 1001 Bytes
/
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
SOURCES := $(shell find . -name '*.s')
OBJECTS := $(SOURCES:%.s=%.o)
TESTDATA := $(SOURCES:%.s=%.elf)
HEXDATA := $(SOURCES:%.s=%.hex)
MEMDATA := $(SOURCES:%.s=%.mem)
CFLAGS=-mabi=ilp32e -march=rv32e
LDFLAGS=-T ../gcc/riskow.ld -m elf32lriscv -O binary
OC=riscv64-linux-gnu-objcopy
CC=riscv64-linux-gnu-gcc-10
LD=riscv64-linux-gnu-ld
all: clean $(TESTDATA)
%.elf: %.s
@echo "Building $< -> $@"
@$(CC) -c $(CFLAGS) -o $(@:%.elf=%.o) $<
@$(LD) $(LDFLAGS) $(@:%.elf=%.o) -o $@
%.hex: %.elf
@echo "Building $< -> $@"
@$(OC) -O ihex $(@:%.hex=%.elf) $@ --only-section .text\*
%.mem: %.elf
@echo "Building $< -> $@"
@$(OC) -O binary $(@:%.mem=%.elf) $(@:%.mem=%.bin) --only-section .text\*
@hexdump -ve '1/4 "%08x\n"' $(@:%.mem=%.bin) > $@
simhex: $(HEXDATA)
@echo "Building prog.hex for http://tice.sea.eseo.fr/riscv/"
testmem: $(MEMDATA)
@echo "Building memdata for unit tests"
clean:
@echo "Cleaning build files"
@rm -f $(OBJECTS) *.elf *.hex *.mem *.bin