1
0
mirror of https://github.com/sgmarz/osblog.git synced 2024-11-24 10:26:20 +04:00
osblog/risc_v/userspace/Makefile

24 lines
595 B
Makefile
Raw Normal View History

CROSS=riscv64-unknown-linux-gnu-
CXX=g++
OBJCOPY=objcopy
CXXFLAGS=-Wall -O3 -ffreestanding -nostartfiles -nostdlib -static -march=rv64g -mabi=lp64d
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)
%.elf:%.cpp Makefile startlib/linker.lds startlib/*.h
$(CROSS)$(CXX) $(CXXFLAGS) $(INCLUDES) $(LIBS) -o $@ $< $(LIB)
$(CROSS)$(OBJCOPY) -O binary $@ $@.bin
mv $@.bin $(basename $@)
clean:
rm -f $(OUT)
rm -f *.bin *.elf
rm -f $(PROGS)