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

24 lines
596 B
Makefile
Raw Normal View History

CROSS=riscv64-unknown-linux-gnu-
CXX=g++
OBJCOPY=objcopy
CXXFLAGS=-Wall -O3 -ffreestanding -nostartfiles -nostdlib -static -march=rv64gc -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)