export PATH := $(CURDIR)/tools/gnu/bin:$(PATH) CROSS = 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) \ -nostdlib \ -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 # Generate MIF file for 2Kx32 RAM boot_depth := 2048 boot_width := 32 boot_stride := 1 boot.elf: head.o hello.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) -o $@ $< clean: rm -f *.o *.i *.s *.elf *.bin .*.d spotless: clean rm -f *.mem *.hex *.mif -include .*.d