MAKEFLAGS += -R -r CROSS = ../tools/gnu/bin/riscv32-unknown-elf- CC = $(CROSS)gcc LD = $(CROSS)ld OBJCOPY = $(CROSS)objcopy AR = $(CROSS)ar PERL = perl INCLUDE = -I. -I./include -I./fatfs/source include ../riscv-opts.mk CPPFLAGS = $(INCLUDE) $(riscv_flags) CFLAGS = $(CPPFLAGS) -W -Wextra SFLAGS = $(CPPFLAGS) -D__ASSEMBLY__ LDSCRIPT = max80.ild LDFLAGS = $(CFLAGS) \ -Wl,--gc-sections \ -Wl,-T,$(LDSCRIPT) \ -Wl,-z,common-page-size=16 \ -Wl,-z,max-page-size=16 gendeps = -MD -MF .$(@F).d -MT $@ # Delete output files on error .DELETE_ON_ERROR: # Don't delete intermediate files .SECONDARY: genhdrs = iodevs.h gensrcs = irqtable.c all: boot.mif dram.hex # Generate MIF file for 8Kx32 RAM boot_depth := 8192 boot_width := 32 boot_stride := 1 max80.elf: head.o die.o dummy.o irqtable.o irqasm.o sbrk.o hello.o \ console.o rtc.o \ sdcard.o diskcache.o abcdrive.o \ memset.o memcpy.o \ testdata.o \ fatfs.a FATFS_C = $(wildcard fatfs/source/*.c) FATFS_O = $(FATFS_C:.c=.o) fatfs.a: $(FATFS_O) rm -f $@ $(AR) cq $@ $(FATFS_O) CFLAGS_memset.c := -O2 %.mif: %.bin bin2mif.pl $(PERL) bin2mif.pl $< $@ $($*_depth) $($*_width) $($*_stride) %.hex: %.elf $(OBJCOPY) -O ihex $< $@ %.mem: %.bin $(BIN2MEM) $< > $@ boot.bin: max80.elf $(OBJCOPY) -O binary -R '.dram*' $< $@ dram.bin: max80.elf $(OBJCOPY) -O binary -j '.dram*' $< $@ dram.hex: max80.elf $(OBJCOPY) -O ihex -j '.dram*' $< $@ %.elf: $(LDSCRIPT) $(CC) $(LDFLAGS) -o $@ $(filter-out $(LDSCRIPT),$^) %.o: %.c | $(genhdrs) $(CC) $(CFLAGS) $(CFLAGS_$<) $(gendeps) -c -o $@ $< %.s: %.c | $(genhdrs) $(CC) $(CFLAGS) $(CFLAGS_$<) $(gendeps) -S -o $@ $< %.i: %.c | $(genhdrs) $(CC) $(CFLAGS) $(CFLAGS_$<) $(gendeps) -E -o $@ $< %.o: %.S | $(genhdrs) $(CC) $(SFLAGS) $(SFLAGS_$<) $(gendeps) -c -o $@ $< %.s: %.S | $(genhdrs) $(CC) $(SFLAGS) $(SFLAGS_$<) $(gendeps) -E -o $@ $< %.ild: %.ld | $(genhdrs) $(CC) $(CFLAGS) $(CFLAGS_$<) $(gendeps) \ -x assembler-with-cpp \ -fdollars-in-identifiers \ -C -P -E $< | $(PERL) -pe 's:^(#.*)$$:/* $$1 */:' > $@ iodevs.h: ../iodevs.conf ../tools/iodevs.pl $(PERL) ../tools/iodevs.pl h $< $@ irqtable.c: ../iodevs.conf ../tools/iodevs.pl $(PERL) ../tools/iodevs.pl c $< $@ clean: rm -f *.o *.i *.s *.elf *.bin .*.d *.ild $(genhdrs) $(gensrcs) spotless: clean rm -f *.mem *.hex *.mif -include .*.d