| OUTPREFIX ?= $(abspath .)/ |
| ROOTDIR := $(abspath $(shell git rev-parse --show-toplevel)) |
| SHODANROOTDIR := $(abspath $(ROOTDIR)/../..) |
| SRCDIR := $(abspath .) |
| BUILDDIR := $(OUTPREFIX)build |
| |
| CFLAGS += -std=gnu11 |
| |
| CCFLAGS += -std=gnu++11 |
| CCFLAGS += -fno-exceptions |
| |
| CXXFLAGS += -Wall |
| CXXFLAGS += -Werror |
| CXXFLAGS += -march=rv32imv |
| CXXFLAGS += -I${ROOTDIR}/springbok/include |
| CXXFLAGS += -O3 -g3 -ggdb |
| CXXFLAGS += -fomit-frame-pointer |
| CXXFLAGS += -ffreestanding |
| CXXFLAGS += -fstack-usage |
| CXXFLAGS += -mstrict-align |
| |
| LDFLAGS += -nostartfiles |
| LDFLAGS += -specs=nano.specs |
| LDFLAGS += -Wl,--gc-sections |
| LDFLAGS += -Wl,--print-memory-usage |
| LDFLAGS += -Wl,-Map=${BUILDDIR}/hello_vec.map |
| LDFLAGS += -T${ROOTDIR}/springbok/springbok_no_wmmu.ld |
| |
| CC := ${SHODANROOTDIR}/cache/toolchain_vp/bin/riscv32-unknown-elf-gcc |
| CPP := ${SHODANROOTDIR}/cache/toolchain_vp/bin/riscv32-unknown-elf-g++ |
| |
| ${BUILDDIR}/hello_vec.elf: ${BUILDDIR}/main.o ${BUILDDIR}/springbok_gloss.o ${BUILDDIR}/springbok.o ${BUILDDIR}/crt0.o |
| mkdir -p $(dir $@) |
| ${CPP} ${CXXFLAGS} ${CPPFLAGS} $^ ${LDFLAGS} -o $@ |
| @cat ${BUILDDIR}/hello_vec.map | awk '/\.heap/ {printf("%16s: %13s\n", "heap (reserved)", int(strtonum($$3)/1024) " KB")} /\.stack/ {printf("%16s: %13s\n", "stack (reserved)", int(strtonum($$3)/1024) " KB")}' |
| |
| ${BUILDDIR}/main.o: ${SRCDIR}/main.cpp ${MAKEFILE_LIST} |
| mkdir -p $(dir $@) |
| ${CPP} ${CXXFLAGS} ${CPPFLAGS} -c $< -o $@ |
| |
| ${BUILDDIR}/springbok_gloss.o: ${ROOTDIR}/springbok/springbok_gloss.cpp ${MAKEFILE_LIST} |
| mkdir -p $(dir $@) |
| ${CPP} ${CXXFLAGS} ${CPPFLAGS} -c $< -o $@ |
| |
| ${BUILDDIR}/springbok.o: ${ROOTDIR}/springbok/springbok.cpp ${MAKEFILE_LIST} |
| mkdir -p $(dir $@) |
| ${CPP} ${CXXFLAGS} ${CPPFLAGS} -c $< -o $@ |
| |
| ${BUILDDIR}/crt0.o: ${ROOTDIR}/springbok/crt0.s ${MAKEFILE_LIST} |
| mkdir -p $(dir $@) |
| ${CC} ${CXXFLAGS} ${CFLAGS} -c $< -o $@ |
| |
| .PHONY: clean |
| clean: |
| rm -rf ${BUILDDIR} |