blob: c116b926d27745120082409abcf9d4d0fad0d584 [file] [log] [blame] [raw]
CC=gcc
CFLAGS=-O2 -Wall -g -Werror -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -MMD
CFLAGS+=-DCONFIG_VERSION=\"$(shell cat VERSION)\"
LDFLAGS=
CROSS_PREFIX=riscv64-unknown-linux-gnu-
CROSS_CC=$(CROSS_PREFIX)gcc
CROSS_LD=$(CROSS_PREFIX)ld
CROSS_OBJCOPY=$(CROSS_PREFIX)objcopy
CROSS_CFLAGS=-O2 -Wall -g -Werror
CROSS_LDFLAGS=-static
PROGS= riscvemu32 riscvemu64 riscvemu splitimg
# Note: the 128 bit target does not compile if gcc does not support
# the int128 type (32 bit hosts).
PROGS+=riscvemu128
# compile rv128test.bin if a RISCV toolchain is available
#PROGS+=rv128test.bin
all: $(PROGS)
RISCVEMU_OBJS:=softfp.o ide.o
riscvemu32: riscvemu32.o $(RISCVEMU_OBJS)
$(CC) $(LDFLAGS) -o $@ $^ -lrt
riscvemu64: riscvemu64.o $(RISCVEMU_OBJS)
$(CC) $(LDFLAGS) -o $@ $^ -lrt
riscvemu128: riscvemu128.o $(RISCVEMU_OBJS)
$(CC) $(LDFLAGS) -o $@ $^ -lrt
riscvemu32.o: riscvemu.c
$(CC) $(CFLAGS) -DMAX_XLEN=32 -c -o $@ $<
riscvemu64.o: riscvemu.c
$(CC) $(CFLAGS) -DMAX_XLEN=64 -c -o $@ $<
riscvemu128.o: riscvemu.c
$(CC) $(CFLAGS) -DMAX_XLEN=128 -c -o $@ $<
riscvemu:
ln -sf riscvemu64 riscvemu
splitimg: splitimg.o
$(CC) $(LDFLAGS) -o $@ $^
%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $<
clean:
rm -f *.o *.d *~ $(PROGS)
rv128test: rv128test.o rv128test.lds
$(CROSS_LD) -T rv128test.lds -o $@ rv128test.o
rv128test.bin: rv128test
$(CROSS_OBJCOPY) -O binary $< $@
rv128test.o: rv128test.S
$(CROSS_CC) -c -o $@ $<
-include $(wildcard *.d)