2020-09-27 18:04:08 -06:00
|
|
|
all: test.hex
|
|
|
|
|
|
|
|
CC = riscv64-linux-gnu-gcc
|
|
|
|
# CFLAGS = -march=rv32i -mabi=ilp32
|
|
|
|
CFLAGS = -march=rv64i -mabi=lp64
|
|
|
|
|
|
|
|
AS = riscv64-linux-gnu-as
|
|
|
|
ASFLAGS = $(CFLAGS)
|
|
|
|
|
|
|
|
LD = riscv64-linux-gnu-ld
|
|
|
|
LDFLAGS = -T test.ld
|
|
|
|
|
|
|
|
%.o: %.S
|
|
|
|
$(AS) $(ASFLAGS) $^ -o $@
|
|
|
|
|
2020-09-27 18:38:35 -06:00
|
|
|
%.o: %.c
|
|
|
|
$(CC) $(CFLAGS) $^ -o $@
|
|
|
|
|
2020-09-27 18:04:08 -06:00
|
|
|
%.elf: %.o
|
|
|
|
$(LD) $(LDFLAGS) $^ -o $@
|
|
|
|
|
|
|
|
test.hex: test.elf
|
2020-09-27 18:38:35 -06:00
|
|
|
riscv64-linux-gnu-objdump -s $^ | sed -n '/0000/,$$p' | cut -f3-6 -d ' ' | sed -e 's/ /\n/g' | sed 's/^\(..\)\(..\)\(..\)\(..\)/\4\3\2\1/' > $@
|