calculator/Makefile

67 lines
1.6 KiB
Makefile
Raw Permalink Normal View History

CC=riscv64-unknown-elf-gcc
2025-02-09 01:09:13 +00:00
AS=riscv64-unknown-elf-as
2025-02-09 06:58:41 +00:00
ASFLAGS=-g -mabi=ilp32e -march=rv32ec
2025-03-09 10:15:33 +00:00
CFLAGS=$(ASFLAGS) -Os -Wall -std=c99
2025-02-09 01:09:13 +00:00
LD=riscv64-unknown-elf-ld
export JQ?=jaq
export QEMU?=qemu-riscv32
2025-02-09 01:09:13 +00:00
2025-02-15 09:45:25 +00:00
TEST_SRC := $(shell find tests -name '*.s')
# Replace .s with .elf
TESTS := $(patsubst %.s,%.elf,$(TEST_SRC))
2025-03-08 01:21:47 +00:00
all: calc.elf tests
2025-02-09 01:09:13 +00:00
check: tests
@tests/unittest
2025-02-13 10:32:51 +00:00
clean:
rm -f *.o tests/*.o *.elf tests/*.elf
2025-02-09 01:09:13 +00:00
hello.elf: hello.o
$(LD) -m elf32lriscv $^ -o $@
calc.elf: mem.o hex.o debug.o math.o calc.o
$(LD) -m elf32lriscv -T link.ld $^ -o $@
2025-02-15 09:45:25 +00:00
tests: $(TESTS)
tests/math_add64.elf: hex.o math.o tests/math_add64.o
$(LD) -m elf32lriscv -T link.ld $^ -o $@
2025-02-14 11:09:46 +00:00
tests/math_mul.elf: hex.o math.o tests/math_mul.o
$(LD) -m elf32lriscv -T link.ld $^ -o $@
2025-02-15 09:45:25 +00:00
tests/math_div.elf: hex.o math.o tests/math_div.o
$(LD) -m elf32lriscv -T link.ld $^ -o $@
tests/math_divmod.elf: hex.o math.o tests/math_divmod.o
$(LD) -m elf32lriscv -T link.ld $^ -o $@
tests/math_mod.elf: hex.o math.o tests/math_mod.o
$(LD) -m elf32lriscv -T link.ld $^ -o $@
tests/math_clz.elf: hex.o math.o tests/math_clz.o
$(LD) -m elf32lriscv -T link.ld $^ -o $@
tests/fmt_count_digits.elf: hex.o math.o fmt.o tests/fmt_count_digits.o
$(LD) -m elf32lriscv -T link.ld $^ -o $@
tests/fmt_decimal.elf: math.o fmt.o tests/fmt_decimal.o
$(LD) -m elf32lriscv -T link.ld $^ -o $@
tests/btohex.elf: mem.o hex.o debug.o tests/btohex.o
2025-02-09 05:09:53 +00:00
$(LD) -m elf32lriscv -T link.ld $^ -o $@
2025-02-09 01:09:13 +00:00
tests/tohex.elf: hex.o tests/tohex.o
$(LD) -m elf32lriscv -T link.ld $^ -o $@
2025-03-09 10:15:33 +00:00
tests/harness.elf: tests/harness.o tests/charness.o
2025-03-04 11:57:01 +00:00
$(LD) -m elf32lriscv -T link.ld $^ -o $@
2025-02-09 01:09:13 +00:00
%.o : %.s
2025-02-09 06:58:41 +00:00
$(AS) $(ASFLAGS) $< -o $@
.PHONY: check tests