MAKEFLAGS += -R -r CROSS = ../tools/gnu/bin/riscv32-unknown-elf- CC = $(CROSS)gcc LD = $(CROSS)ld OBJCOPY = $(CROSS)objcopy PERL = perl INCLUDE = -I. -I./include include ../riscv-opts.mk CPPFLAGS = $(INCLUDE) $(riscv_flags) CFLAGS = $(CPPFLAGS) SFLAGS = $(CPPFLAGS) -D__ASSEMBLY__ LDFLAGS = $(CFLAGS) \ -Wl,--gc-sections \ -Wl,--section-start=.init=0 \ -Wl,-z,common-page-size=16 \ -Wl,-z,max-page-size=16 gendeps = -MD -MF .$(@F).d # Delete output files on error .DELETE_ON_ERROR: # Don't delete intermediate files .SECONDARY: all: boot.mif testdata.hex # Generate MIF file for 8Kx32 RAM boot_depth := 8192 boot_width := 32 boot_stride := 1 boot.elf: head.o die.o hello.o console.o %.mif: %.bin bin2mif.pl $(PERL) bin2mif.pl $< $@ $($*_depth) $($*_width) $($*_stride) %.hex: %.elf $(OBJCOPY) -O ihex $< $@ %.mem: %.bin $(BIN2MEM) $< > $@ %.bin: %.elf $(OBJCOPY) -O binary $< $@ %.elf: $(CC) $(LDFLAGS) -o $@ $^ %.o: %.c $(CC) $(CFLAGS) $(CFLAGS_$<) $(gendeps) -c -o $@ $< %.s: %.c $(CC) $(CFLAGS) $(CFLAGS_$<) $(gendeps) -S -o $@ $< %.i: %.c $(CC) $(CFLAGS) $(CFLAGS_$<) $(gendeps) -E -o $@ $< %.o: %.S $(CC) $(SFLAGS) $(SFLAGS_$<) $(gendeps) -c -o $@ $< %.s: %.S $(CC) $(SFLAGS) $(SFLAGS_$<) $(gendeps) -E -o $@ $< testdata.bin: testdata.pl $(PERL) $< > $@ testdata.hex: testdata.bin $(OBJCOPY) -I binary -O ihex $< $@ clean: rm -f *.o *.i *.s *.elf *.bin .*.d spotless: clean rm -f *.mem *.hex *.mif -include .*.d