54 lines
2.0 KiB
Makefile
54 lines
2.0 KiB
Makefile
OSFLAG :=
|
|
ifeq ($(OS),Windows_NT)
|
|
RISCV_GNU_TOOLCHAIN_INSTALL_PREFIX = C:\riscv_precompiled
|
|
else
|
|
RISCV_GNU_TOOLCHAIN_INSTALL_PREFIX = /opt/riscv32
|
|
endif
|
|
ifeq ($(OS),Windows_NT)
|
|
PYTHON_VER = python
|
|
else
|
|
PYTHON_VER = python3
|
|
endif
|
|
|
|
|
|
FIRMWARE_OBJS = firmware/start.o firmware/irq.o firmware/print.o firmware/inch.o firmware/timer.o firmware/prng.o firmware/leds.o firmware/fftbench.o firmware/main.o
|
|
GCC_WARNS = -Wall -Wextra -Wshadow -Wundef -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings
|
|
GCC_WARNS += -Wredundant-decls -Wstrict-prototypes -Wmissing-prototypes -pedantic # -Wconversion
|
|
ifeq ($(OS),Windows_NT)
|
|
TOOLCHAIN_PREFIX = $(RISCV_GNU_TOOLCHAIN_INSTALL_PREFIX)/bin/riscv-none-elf-
|
|
else
|
|
TOOLCHAIN_PREFIX = $(RISCV_GNU_TOOLCHAIN_INSTALL_PREFIX)im/bin/riscv32-unknown-elf-
|
|
endif
|
|
COMPRESSED_ISA =
|
|
|
|
firmware/firmware.mif: firmware/firmware.bin firmware/makemif.py
|
|
$(PYTHON_VER) firmware/makemif.py $< 16384 > $@
|
|
|
|
firmware/firmware.hex: firmware/firmware.bin firmware/makehex.py
|
|
$(PYTHON_VER) firmware/makehex.py $< 16384 firmware > $@
|
|
|
|
firmware/firmware.fpga:firmware/firmware.hex
|
|
$(PYTHON_VER) firmware/makebin.py $< 16384 > $@
|
|
|
|
firmware/firmware.bin: firmware/firmware.elf
|
|
$(TOOLCHAIN_PREFIX)objcopy -O binary $< $@
|
|
chmod -x $@
|
|
|
|
firmware/firmware.elf: $(FIRMWARE_OBJS) $(TEST_OBJS) firmware/sections.lds
|
|
$(TOOLCHAIN_PREFIX)gcc -Os -ffreestanding -nostdlib -o $@ \
|
|
-Wl,-Bstatic,-T,firmware/sections.lds,-Map,firmware/firmware.map,--strip-debug \
|
|
$(FIRMWARE_OBJS) $(TEST_OBJS) -lgcc
|
|
chmod -x $@
|
|
|
|
firmware/start.o: firmware/start.S
|
|
$(TOOLCHAIN_PREFIX)gcc -c -march=rv32im$(subst C,c,$(COMPRESSED_ISA)) -o $@ $<
|
|
|
|
firmware/%.o: firmware/%.c
|
|
$(TOOLCHAIN_PREFIX)gcc -c -march=rv32im$(subst C,c,$(COMPRESSED_ISA)) -Os -W --std=c99 $(GCC_WARNS) -ffreestanding -nostdlib -o $@ $<
|
|
|
|
clean:
|
|
rm -vrf $(FIRMWARE_OBJS) $(TEST_OBJS) \
|
|
firmware/firmware.elf firmware/firmware.bin firmware/firmware.hex firmware/firmware.mif firmware/firmware.map firmware/Memory.v_toplevel_memory_1_symbol*
|
|
|
|
.PHONY: clean
|