2019-01-01 14:37:34 -06:00
|
|
|
BIN2C = ../../../../src/helper/bin2char.sh
|
|
|
|
|
|
|
|
CROSS_COMPILE ?= riscv64-unknown-elf-
|
|
|
|
|
2021-11-08 11:26:51 -06:00
|
|
|
RISCV_CC=$(CROSS_COMPILE)gcc
|
|
|
|
RISCV_OBJCOPY=$(CROSS_COMPILE)objcopy
|
|
|
|
RISCV_OBJDUMP=$(CROSS_COMPILE)objdump
|
2019-01-01 14:37:34 -06:00
|
|
|
|
2021-11-08 11:26:51 -06:00
|
|
|
CFLAGS = -nostdlib -nostartfiles -Wall -Werror -Os -fPIC -Wunused-result -g
|
|
|
|
RISCV32_CFLAGS = -march=rv32e -mabi=ilp32e $(CFLAGS)
|
|
|
|
RISCV64_CFLAGS = -march=rv64i -mabi=lp64 $(CFLAGS)
|
2019-01-01 14:37:34 -06:00
|
|
|
|
2021-11-08 11:26:51 -06:00
|
|
|
all: riscv32_fespi.inc riscv64_fespi.inc
|
2019-01-01 14:37:34 -06:00
|
|
|
|
|
|
|
.PHONY: clean
|
|
|
|
|
2021-11-08 11:26:51 -06:00
|
|
|
# .c -> .o
|
|
|
|
riscv32_%.o: riscv_%.c
|
|
|
|
$(RISCV_CC) -c $(RISCV32_CFLAGS) $^ -o $@
|
2019-01-01 14:37:34 -06:00
|
|
|
|
2021-11-08 11:26:51 -06:00
|
|
|
riscv64_%.o: riscv_%.c
|
|
|
|
$(RISCV_CC) -c $(RISCV64_CFLAGS) $< -o $@
|
|
|
|
|
|
|
|
# .S -> .o
|
|
|
|
riscv32_%.o: riscv_%.S
|
|
|
|
$(RISCV_CC) -c $(RISCV32_CFLAGS) $^ -o $@
|
|
|
|
|
|
|
|
riscv64_%.o: riscv_%.S
|
|
|
|
$(RISCV_CC) -c $(RISCV64_CFLAGS) $^ -o $@
|
|
|
|
|
|
|
|
# .o -> .elf
|
|
|
|
riscv32_%.elf: riscv32_%.o riscv32_wrapper.o
|
|
|
|
$(RISCV_CC) -T riscv.lds $(RISCV32_CFLAGS) $^ -o $@
|
2019-01-01 14:37:34 -06:00
|
|
|
|
2021-11-08 11:26:51 -06:00
|
|
|
riscv64_%.elf: riscv64_%.o riscv64_wrapper.o
|
|
|
|
$(RISCV_CC) -T riscv.lds $(RISCV64_CFLAGS) $^ -o $@
|
|
|
|
|
|
|
|
# .elf -> .bin
|
2019-01-01 14:37:34 -06:00
|
|
|
%.bin: %.elf
|
2021-11-08 11:26:51 -06:00
|
|
|
$(RISCV_OBJCOPY) -Obinary $< $@
|
2019-01-01 14:37:34 -06:00
|
|
|
|
2021-11-08 11:26:51 -06:00
|
|
|
# .bin -> .inc
|
2019-01-01 14:37:34 -06:00
|
|
|
%.inc: %.bin
|
|
|
|
$(BIN2C) < $< > $@
|
|
|
|
|
2021-11-08 11:26:51 -06:00
|
|
|
# utility
|
|
|
|
%.lst: %.elf
|
|
|
|
$(RISCV_OBJDUMP) -S $< > $@
|
|
|
|
|
2019-01-01 14:37:34 -06:00
|
|
|
clean:
|
2021-11-08 11:26:51 -06:00
|
|
|
-rm -f *.elf *.o *.lst *.bin *.inc
|