2020-05-24 20:42:04 +04:00
|
|
|
CROSS=riscv64-unknown-linux-gnu-
|
2020-04-26 05:23:00 +04:00
|
|
|
CXX=g++
|
|
|
|
OBJCOPY=objcopy
|
2020-05-24 20:42:04 +04:00
|
|
|
CXXFLAGS=-Wall -O3 -ffreestanding -nostartfiles -nostdlib -static -march=rv64g -mabi=lp64d
|
2020-04-26 05:23:00 +04:00
|
|
|
LINKER_SCRIPT=-T./startlib/linker.lds
|
|
|
|
INCLUDES=-I./startlib
|
|
|
|
LIBS=-L./startlib
|
|
|
|
LIB=-lstart
|
|
|
|
SOURCES=$(wildcard *.cpp)
|
|
|
|
OUT=$(patsubst %.cpp,%.elf,$(SOURCES))
|
|
|
|
PROGS=$(patsubst %.cpp,%,$(SOURCES))
|
|
|
|
|
|
|
|
all: $(OUT)
|
|
|
|
|
2020-04-26 16:33:49 +04:00
|
|
|
%.elf:%.cpp Makefile startlib/linker.lds startlib/*.h
|
|
|
|
$(CROSS)$(CXX) $(CXXFLAGS) $(INCLUDES) $(LIBS) -o $@ $< $(LIB)
|
2020-04-26 05:23:00 +04:00
|
|
|
$(CROSS)$(OBJCOPY) -O binary $@ $@.bin
|
|
|
|
mv $@.bin $(basename $@)
|
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -f $(OUT)
|
|
|
|
rm -f *.bin *.elf
|
|
|
|
rm -f $(PROGS)
|